@spotify/backstage-plugin-soundcheck 0.9.0 → 0.9.1

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @spotify/backstage-plugin-soundcheck
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Upgraded Backstage to `v1.20.3`.
8
+ - Updated dependency `cross-fetch` to `^4.0.0`.
9
+ - Added Track owner select to Track form.
10
+ - Checks are now linkable by id via the following url format `soundcheck/checks/:checkId`. Pages will now properly link to the check instead of the checks list page.
11
+ - Renamed Soundcheck menu options for Checks, Tracks, and Collectors to include "Library".
12
+ - Tracks are now linkable by id via the following url format `soundcheck/tracks/:trackId`. Pages will now properly link to the track instead of the tracks list page.
13
+ - Check descriptions, check passed messages, check failed messages, and track descriptions now support markdown in the UI.
14
+ - Updated dependencies
15
+ - @spotify/backstage-plugin-soundcheck-common@0.9.1
16
+ - @spotify/backstage-plugin-core@0.5.8
17
+
3
18
  ## 0.9.0
4
19
 
5
20
  ### Minor Changes
@@ -84,10 +99,6 @@
84
99
  - Resolved an issue where newly added Checks would not immediately show up in the Track UI.
85
100
  - Resolved an issue where the text for warning messages on the Soundcheck Group page was not accurate.
86
101
  - Tooltips in the overview table now support Markdown in check descriptions.
87
- - Updated dependencies
88
- - Updated dependencies
89
- - Updated dependencies
90
- - Updated dependencies
91
102
  - Updated dependencies
92
103
  - @spotify/backstage-plugin-soundcheck-common@0.8.0
93
104
  - @spotify/backstage-plugin-core@0.5.6
@@ -0,0 +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-a31faa1d.esm.js";import{s as H,R as c,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-c3aebdd7.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 oe from"react-use/lib/useMeasure";import A from"react-use/lib/usePrevious";import ce 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";import"../images/empty-state.svg";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={[c.Passed]:"success",[c.Failed]:"error",[c.NotReported]:"info",[c.NotApplicable]:"info"}[t],i={[c.Passed]:"Check passed",[c.Failed]:"Check did not pass",[c.NotReported]:"Check not reported",[c.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:o}=se(r,t,n);if(o)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:o}=x(i,t),[h,{width:d,height:v}]=oe(),m=o?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(ce,{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:o,name:h},highestLevel:d})=>e.createElement(fe,{key:o,id:o,name:h,badge:d==null?void 0:d.badge,selected:o===t,href:i({trackId:o})})))},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:o}=C(r);return i?e.createElement(y,{severity:"error",title:"Error loading certifications"}):l&&!(o!=null&&o.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),o=(n=(t=l==null?void 0:l.levels[0])==null?void 0:t.checks[0])==null?void 0:n.id;return o?e.createElement(I,{to:i({trackId:r,checkId:o}),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-d8bf249e.esm.js.map
@@ -0,0 +1,2 @@
1
+ import t,{useState as L,useEffect as E,useMemo as P,useCallback as M,createContext as ge,useContext as he,memo as b,Fragment as fe}from"react";import{useSearchParams as ye}from"react-router-dom";import{makeStyles as f,alpha as j,TextField as ve,CircularProgress as Ee,Tooltip as K,LinearProgress as ke,withStyles as be,Grid as C,Typography as k}from"@material-ui/core";import Ce from"@material-ui/lab/Autocomplete";import{stringifyEntityRef as A,parseEntityRef as x}from"@backstage/catalog-model";import{useApi as v,identityApiRef as U,useRouteRef as F,configApiRef as Re}from"@backstage/core-plugin-api";import{useQuery as T}from"@tanstack/react-query";import{s as D,R,h as we,B as Ne,L as Q,N as _,Q as q,A as $e,d as xe,j as Te}from"./index-c3aebdd7.esm.js";import{catalogApiRef as B,humanizeEntityRef as O,entityRouteRef as S}from"@backstage/plugin-catalog-react";import Ie from"react-use/lib/useAsync";import{HeaderTabs as J,MarkdownContent as Le,Link as z,EmptyState as Be}from"@backstage/core-components";import{R as Oe}from"./RefetchingIndicator-a31faa1d.esm.js";import Pe,{countBy as X}from"lodash";import{Skeleton as H}from"@material-ui/lab";import{VariableSizeGrid as Ae}from"react-window";function Y(e,r){const a=v(D);return T(["soundcheck/track-overview-for-owner",e,r],async()=>a.getProgramOverviewForOwner(e,r),{enabled:!!e&&!!(r!=null&&r.kind)})}function Z(){const e=v(B);return T(["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,s,i;return{name:(i=(s=(l=(n=a.spec)==null?void 0:n.profile)==null?void 0:l.displayName)!=null?s:a.metadata.title)!=null?i:a.metadata.name,ref:A(a)}})},{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function Fe(){const e=v(U),r=v(B);return T(["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,s,i,c;return{name:(c=(i=(s=(l=n.spec)==null?void 0:l.profile)==null?void 0:s.displayName)!=null?i:n.metadata.title)!=null?c:n.metadata.name,ref:A(n)}})})}function Se(e){const r=v(D);return T(["soundcheck/facets-for-owner",e],async()=>r.getFacetsForOwner(e),{enabled:!!e})}const ze=()=>{const[e,r]=ye(),a=Object.fromEntries(e.entries()),[n,l]=L(a);return E(()=>{r(n,{replace:!0})},[n]),[n,l]},ee=()=>{const{data:e,isLoading:r,isError:a}=Fe(),{data:n,isLoading:l,isError:s}=Z();return{options:P(()=>{const i=new Map;return e&&e.forEach(({name:c,ref:o})=>{i.set(`${o}`,{name:c,ref:o,key:"My Groups"})}),n&&n.forEach(({name:c,ref:o})=>{i.has(`${o}`)||i.set(`${o}`,{name:c,ref:o,key:"All Groups"})}),[...i.values()]},[e,n]),isLoading:r||l,isError:a||s}},He=f(e=>({root:{width:"100%",minWidth:250},textField:{"& $notchedOutline":{borderColor:j(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:{}})),We=e=>{const{onChange:r,initialValue:a,setError:n}=e,{options:l,isLoading:s,isError:i}=ee(),c=He(),[o,d]=L(null);E(()=>{if(!s&&l!=null&&l.length&&!o){const m=a?l.find(p=>p.ref===a):l[0];m&&(d(m),r==null||r(m.ref))}},[s,l,o,r,a]);const u=M((m,p)=>{d(p),r==null||r(p==null?void 0:p.ref)},[r,d]);return E(()=>{n==null||n(i?new Error("Error loading groups"):void 0)},[i,n]),i?null:t.createElement(Ce,{"aria-label":"Current group",className:c.root,classes:{clearIndicator:c.clearIndicator,popupIndicator:c.popupIndicator},disableClearable:!0,options:l!=null?l:[],loading:s,groupBy:m=>m.key,value:o,freeSolo:!1,onChange:u,getOptionLabel:m=>m.name,renderInput:m=>t.createElement(ve,{...m,variant:"outlined",placeholder:s?"Loading":"Select a group",className:c.textField,InputProps:{...m.InputProps,className:c.input,classes:{notchedOutline:c.notchedOutline},endAdornment:t.createElement(t.Fragment,null,s?t.createElement(Ee,{color:"inherit",size:20}):null,m.InputProps.endAdornment)}})})},te={loading:!1},re=ge(te),Ge=()=>he(re),Ve=({children:e})=>{const[r,a]=L(te),n=v(B),l=v(U),{value:s,loading:i,error:c}=Ie(async()=>{const[{token:o},d]=await Promise.all([l.getCredentials(),l.getBackstageIdentity()]);return o?await n.getEntityByRef(d.userEntityRef):null},[n,l]);return E(()=>{if(s){const o=A(s);a({user:s,userEntityRef:o,loading:i,error:c})}else a({loading:i,error:c})},[s,i,c]),t.createElement(re.Provider,{value:r},e)},Me=e=>({key:`skeleton${e}`,label:"",id:`skeleton${e}`}),je=()=>{const e=Array.from({length:4},(r,a)=>Me(a));return t.createElement(J,{tabs:e})},Ke=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)}})),Ue=({unfilteredFacets:e,onChange:r,kind:a,type:n})=>{var l,s,i;const c=Ke(),o={types:(l=e==null?void 0:e.types.filter(({count:p})=>p>0))!=null?l:[]},d=M(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]);E(()=>{var p,g,y;const h=(o==null?void 0:o.types)&&o.types.length>=0,I=!a&&h,G=a&&h&&!(o!=null&&o.types.find(({kind:N,type:$})=>a===N&&(!n&&!$||n===$)));(I||G)&&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=(s=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?s:[];if(!u.length)return null;const m=(i=o==null?void 0:o.types.findIndex(p=>p.kind===a&&(!p.type&&!n||p.type===n)))!=null?i:-1;return t.createElement(t.Fragment,null,t.createElement(Oe,null),t.createElement(J,{onChange:d,tabs:u,selectedIndex:m>-1?m:void 0}))},De=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"}})),ae=e=>{var r,a;const n=De(e),l=P(()=>Object.entries(e.progress).reduce((i,[,c])=>i+c,0),[e.progress]);if(l===0)return null;const s=(r=e.progress[R.Passed])!=null?r:0;return t.createElement(K,{arrow:!0,title:`Check passing for ${s} of ${l} ${l===1?"entity":"entities"}`,enterDelay:0,placement:"top"},t.createElement(ke,{variant:"determinate",value:((a=e.progress[R.Passed])!=null?a:0)/l*100,classes:{root:n.root,bar:n.bar}}))},Qe=f(e=>({headerWrapper:{marginTop:e.spacing(.5)},entityRefName:{fontWeight:"bold"},iconWrapper:{padding:e.spacing(1.5,.5),display:"flex",alignItems:"center",justifyContent:"center"}})),_e=({check:{name:e,description:r},icon:a,entityRef:n})=>{const l=Qe(),s=x(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},O(s,{defaultKind:s.kind}))),t.createElement(Le,{content:r}))},qe=be(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),Je=({children:e,check:r,icon:a,entityRef:n})=>t.createElement(qe,{arrow:!0,title:t.createElement(_e,{check:r,icon:a,entityRef:n}),enterDelay:150,placement:"top"},e),Xe=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}`}})),ne=b(({programId:e,check:r,entityRef:a,result:n,entityRoute:l,isVirtualized:s})=>{const i=Xe();if(typeof a!="string"){const u=t.createElement("div",{className:i.iconWrapper},t.createElement("div",{className:i.icon}));return s?t.createElement("div",{className:`${i.root} ${i.virtualized}`,"aria-hidden":!0},u):t.createElement("td",{className:i.root,"aria-hidden":!0},u)}const c=t.createElement(we,{className:i.icon,result:n!=null?n:R.NotReported}),o=t.createElement("div",{className:i.iconWrapper},c),d=n&&n===R.NotApplicable?o:t.createElement(z,{className:i.link,to:`${l(x(a))}/soundcheck/${e}/${r.id}`},o);return s?t.createElement("div",{className:`${i.root} ${i.virtualized}`},t.createElement(Je,{check:r,icon:c,entityRef:a},d)):t.createElement("td",{className:`${i.root}`},d)}),le=8,Ye=16,w={programTitle:70,levelTitle:30,check:42,entityRefFooter:100},W={programTitle:350+Ye*2,checkResult:42},Ze=e=>e.reduce((r,a)=>r+a.height,0),et=e=>e*W.checkResult+W.programTitle,tt=e=>e.filter(r=>r!==void 0).map(r=>{const a=x(r);return O(a,{defaultKind:a.kind})}).reduce((r,a)=>r.length>a.length?r:a,""),rt=e=>le*e+le,oe="NoLevel",at=e=>({name:oe,badge:{options:{level:0,color:""},variant:Ne.Medal},entityRef:e,ordinal:0}),ie=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:`${w.check}px`,lineHeight:`${w.check}px`,borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),nt=b(({programId:e,programName:r,check:a,entityRefs:n,results:l,entityRoute:s})=>{const i=ie(),c=P(()=>X(l.filter(({result:d})=>d!==R.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:i.checkNameCell,"aria-label":`${a.name} check for ${r} track`},t.createElement("div",{className:i.checkNameContent},t.createElement(k,{className:i.checkNameTypography,variant:"subtitle2",component:"p"},a.name),t.createElement(ae,{className:i.checkIndicator,progress:c}))),n.map((d,u)=>t.createElement(ne,{key:u,programId:e,check:a,entityRef:d,result:typeof d=="string"?o.get(d):void 0,entityRoute:s})))}),lt=({name:e,progress:r})=>{const a=ie();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(ae,{className:a.checkIndicator,progress:r})))},ot=f(e=>({virtualized:{borderRight:`1px solid ${e.palette.divider}`,height:`${w.programTitle}px`,display:"flex",justifyContent:"center",alignItems:"center"}})),it=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(Q,{badge:a.badge}):t.createElement(_,null))}),st=({highestLevel:e})=>{const r=ot();if(!(e!=null&&e.badge))return t.createElement("div",{className:r.virtualized},"\xA0");const a=e.name!==oe;return t.createElement("div",{className:r.virtualized},a?t.createElement(Q,{badge:e.badge}):t.createElement(_,null))},se=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}`}})),ct=b(({program:e,entityRefs:r,highestLevels:a})=>{const n=se();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,s)=>typeof l!="string"?t.createElement("td",{key:s,"aria-hidden":!0}):t.createElement("td",{key:s,"data-testid":"track-certification-cell"},t.createElement("div",{className:n.badgeCellContent},t.createElement(it,{entityRef:l,highestLevels:a})))))}),dt=b(({name:e})=>{const r=se();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:j(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:`${w.levelTitle}px`}}}),pt=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,s)=>t.createElement("td",{key:s,className:n.root,"aria-hidden":!0})))}),mt=({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))},ut=()=>{const e=V();return t.createElement("div",{className:`${e.levelHeaderCell} ${e.root}`},"\xA0")},gt=({program:e,highestLevels:r,levels:a,entityRefs:n,entityRoute:l})=>t.createElement("tbody",null,t.createElement(ct,{program:e,entityRefs:n,highestLevels:r}),a.map((s,i)=>t.createElement(fe,{key:i},t.createElement(pt,{entityRefs:n,level:s,programName:e.name}),s.checks.map(({check:c,results:o},d)=>t.createElement(nt,{key:d,check:c,programId:e.id,programName:e.name,entityRefs:n,results:o,entityRoute:l}))))),ce=e=>{const r=v(B);return T([q.EntityByRef,e],async()=>r.getEntityByRef(e),{onError:()=>{},enabled:!!e})},ht=e=>{const r=v(B);return T([q.EntitiesByRefs,e],async()=>r.getEntitiesByRefs({entityRefs:e.entityRefs,fields:e.fields}),{onError:()=>{},enabled:!!e.entityRefs})},de=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)"}})),ft=({entityRefs:e})=>{const r=F(S),a=de(),{data:n}=ht({entityRefs:Pe.compact(e),fields:["kind","metadata.name","metadata.namespace","metadata.title"]});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((l,s)=>{if(typeof l!="string")return t.createElement("th",{key:s,className:a.cell,"aria-hidden":!0});const i=x(l),c=n==null?void 0:n.items.find(o=>o&&A(o)===l);return t.createElement("th",{scope:"col",key:s,className:a.cell},t.createElement("div",{className:a.cellInner},t.createElement(z,{to:r(i)},c!=null&&c.metadata.title?c.metadata.title:O(i,{defaultKind:i.kind}))))})))},yt=({entityRef:e})=>{const{data:r}=ce(e),a=F(S),n=de(),l=e?x(e):void 0,s=l?t.createElement(z,{to:a(l)},r!=null&&r.metadata.title?r.metadata.title:O(l,{defaultKind:l.kind})):t.createElement(t.Fragment,null);return t.createElement("div",{className:n.cell},t.createElement("div",{className:n.cellInner},s))},vt=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]}})),pe=()=>{const e=vt(),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(H,{width:180,height:40})),r.map((l,s)=>t.createElement("td",{key:s}))),n.map((l,s)=>t.createElement(t.Fragment,{key:s},t.createElement("tr",{className:e.header},t.createElement("td",{className:e.title},t.createElement(H,{width:180})),r.map((i,c)=>t.createElement("td",{key:c}))),a.map((i,c)=>t.createElement("tr",{key:c},t.createElement("td",{className:e.title},t.createElement(H,{width:240})),r.map((o,d)=>t.createElement("td",{key:d,className:e.checkResult},t.createElement(H,{width:18,height:18,variant:"rect"})))))))))},Et=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}`}}})),kt=b(e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,s=Et(),i=F(S),{data:c,isLoading:o,isError:d}=Y(l,{kind:a,type:n});if(E(()=>{r==null||r(d?new Error("Error loading track overview"):void 0)},[d,r]),o)return t.createElement(pe,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c;if(!o&&!u.length)return t.createElement(Be,{missing:"data",title:"Missing tracks",description:t.createElement(t.Fragment,null,"Looks like the group"," ",O(x(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(z,{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:s.root},t.createElement("table",{className:s.table,"aria-label":"Check results"},u.map(({program:g,levels:y,highestLevels:h},I)=>t.createElement(gt,{key:I,program:g,entityRefs:p,levels:y,highestLevels:h,entityRoute:i})),t.createElement(ft,{entityRefs:p})))}),bt=e=>t.createElement(dt,{name:e}),Ct=e=>({type:"ProgramHeader",render:()=>bt(e)}),Rt=e=>e?t.createElement(mt,{name:e}):t.createElement(ut,null),me=e=>({type:"LevelHeader",render:()=>Rt(e)}),wt=(e,r)=>t.createElement(lt,{name:e,progress:r}),Nt=(e,r)=>({type:"CheckTitle",render:()=>wt(e,r)}),$t=(e,r,a,n,l)=>t.createElement(ne,{check:r,entityRef:a,entityRoute:l,programId:e,result:n,isVirtualized:!0}),xt=(e,r,a,n,l)=>({type:"CheckResult",render:()=>$t(e,r,a,n,l)}),Tt=e=>t.createElement(yt,{entityRef:e}),ue=e=>({type:"EntityHeader",render:()=>Tt(e)}),It=e=>t.createElement(st,{highestLevel:e}),Lt=e=>({type:"LevelBadge",render:()=>It(e)}),Bt=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})},Ot=(e,r,a)=>{var n;const l=[];for(const{program:i,levels:c,highestLevels:o}of e){l.push({height:w.programTitle,cells:[Ct(i.name),...r.map(d=>{const u=d?o.find(m=>m.entityRef===d)||at(d):void 0;return Lt(u)})]});for(const d of c){l.push({height:w.levelTitle,cells:[me(d.name),...r.map(u=>me(""))]});for(const{check:u,results:m}of d.checks)l.push({height:w.check,cells:[Nt(u.name,X(m.filter(({result:p})=>p!==R.NotApplicable),"result")),...r.map(p=>{var g,y;return xt(i.id,u,p,(y=(g=m.find(h=>h.entityRef===p))==null?void 0:g.result)!=null?y:R.NotApplicable,a)})]})}}const s=tt(r!=null?r:[]);return l.push({height:rt((n=s.length)!=null?n:1),cells:[ue(""),...r.map(i=>ue(i||""))]}),l},Pt=f(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left",overflow:"auto"}})),At=e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,s=Pt(),i=F(S),{data:c,isLoading:o,isError:d}=Y(l,{kind:a,type:n});if(E(()=>{r==null||r(d?new Error("Error loading program overview"):void 0)},[d,r]),o)return t.createElement(pe,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=Ot(u,p,i),y=Bt(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(Ae,{className:s.table,columnCount:p.length+1,columnWidth:h=>h===0?W.programTitle:W.checkResult,rowCount:g.length,rowHeight:h=>g[h].height,height:Ze(g),width:et(p.length)},y))},Ft=({facets:e,ownerEntityRef:r,kind:a,type:n,setError:l})=>{const s=P(()=>{const i=new Map;return e.types.forEach(({kind:c,type:o})=>{const d=`${c}|${o!=null?o:""}`;i.set(d,t.createElement(At,{key:d,ownerEntityRef:r,kind:c,type:o,setError:l}))}),i},[e,r,l]);return t.createElement("div",null,s.get(`${a}|${n!=null?n:""}`))},St=f(()=>({scrollContainer:{overflow:"auto"}})),zt=({facets:e,ownerEntityRef:r,hasError:a,kind:n,type:l,setError:s,useVirtualizedResultsTable:i,isFixedGroup:c})=>{var o,d,u;const m=St();if(a)return t.createElement($e,{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},i?t.createElement(Ft,{facets:e,kind:n,type:l,setError:s,ownerEntityRef:r,hasError:a}):t.createElement(kt,{ownerEntityRef:r,kind:n,type:l,setError:s})):t.createElement(xe,{ownerEntityRef:r,selectGroupHint:p}):t.createElement(Te,{ownerEntityRef:r,selectGroupHint:c?void 0:p})},Ht=f(()=>({tableContainer:{padding:0,backgroundColor:"transparent"}})),Wt=({groupSelectorError:e,searchParams:r,setSearchParams:a,isFixedGroup:n=!1})=>{var l;const{group:s,kind:i,type:c}=r,[o,d]=L(void 0),[u,m]=L(void 0);E(()=>{((o==null?void 0:o.kind)!==i||(o==null?void 0:o.type)!==c)&&d({kind:i,type:c})},[i,c,o]);const{data:p,isLoading:g}=Se(s),y=(l=v(Re).getOptionalBoolean("soundcheck.virtualizeOverviewPage"))!=null?l:!0,h=u||e,I=(N,$)=>{N&&(d({kind:N,type:$}),$?a({...r,kind:N,type:$}):(r!=null&&r.hasOwnProperty("type")&&delete r.type,a({...r,kind:N})))},G=Ht();return t.createElement(C,{container:!0,spacing:0},t.createElement(C,{item:!0,xs:12},g?t.createElement(je,null):t.createElement(Ue,{unfilteredFacets:p,kind:o==null?void 0:o.kind,type:o==null?void 0:o.type,onChange:I})),t.createElement(C,{item:!0,xs:12,className:G.tableContainer},!g&&t.createElement(zt,{facets:p,kind:o==null?void 0:o.kind,type:o==null?void 0:o.type,setError:m,hasError:h,ownerEntityRef:s,useVirtualizedResultsTable:y,isFixedGroup:n})))};export{We as G,Wt as O,Ve as U,ee as a,Ge as b,Z as c,ce as d,ze as u};
2
+ //# sourceMappingURL=OverviewPageContent-5557813a.esm.js.map
@@ -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-6e141f2f.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-3707a744.esm.js.map
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-c3aebdd7.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-a31faa1d.esm.js.map
@@ -0,0 +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-5557813a.esm.js";import{S as l,w as y,e as p,i as u}from"./index-c3aebdd7.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{Routes as C,Route as G}from"react-router-dom";import{makeStyles as L}from"@material-ui/core";import"@material-ui/lab/Autocomplete";import"react-use/lib/useAsync";import"./RefetchingIndicator-a31faa1d.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";import"../images/empty-state.svg";const O=L(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(C,null,e.createElement(G,{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-293deb4d.esm.js.map
@@ -1,2 +1,2 @@
1
- import t from"react";import{S as o,g as i}from"./index-6e141f2f.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-01c3a9f5.esm.js.map
1
+ import t from"react";import{S as o,g as i}from"./index-c3aebdd7.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";import"../images/empty-state.svg";const m=({title:r})=>t.createElement(o,null,t.createElement(i,{title:r}));export{m as EntitySoundcheckCard};
2
+ //# sourceMappingURL=index-920b177e.esm.js.map
@@ -0,0 +1,2 @@
1
+ import t,{useCallback as U,createContext as Je,useState as C,useContext as et,useEffect as F,useMemo as H,useRef as vr,memo as Er}from"react";import{useNavigate as pe,useLocation as Ba,useSearchParams as Ht,Routes as Ga,Route as Pe,useParams as _t}from"react-router-dom";import{MarkdownContent as Va,Link as fr,DismissableBanner as yr,TabbedLayout as Z,WarningPanel as qa,Page as br,Header as Cr}from"@backstage/core-components";import{DATA_VIZ_DARK_THEME as kr,DATA_VIZ_LIGHT_THEME as xr,SpotifyLicenseBanner as wr}from"@spotify/backstage-plugin-core";import{Box as k,Paper as Ha,Grid as h,Button as V,Slide as Tr,Dialog as Pr,AppBar as Rr,Toolbar as Sr,Typography as b,IconButton as Re,makeStyles as x,TextField as K,Collapse as Nr,useTheme as Se,Tabs as _a,Tab as Ve,FormControl as tt,InputLabel as zt,Select as Wt,MenuItem as he,FormHelperText as za,ButtonGroup as Wa,Menu as Ut,RadioGroup as Lr,Radio as Ua,Divider as qe,FormControlLabel as at,Checkbox as He,Card as nt,ListItemIcon as J,ListItemText as ee,withStyles as Dr,CardHeader as Ir,CardContent as Or,CardActions as Fr,List as rt,ListItem as ge,Tooltip as te,InputAdornment as Ka,NativeSelect as Kt,TablePagination as jt,Chip as lt,CircularProgress as Ar,Table as $r,TableHead as Mr,TableRow as ja,TableCell as Qa,TableBody as Br,Switch as Gr,Stepper as Vr,Step as qr,StepLabel as Hr,StepContent as _r}from"@material-ui/core";import{makeStyles as _,createStyles as zr}from"@material-ui/core/styles";import{a as Qt,b as ot,c as Wr,d as Ur,u as Kr,U as jr,G as Qr,O as Yr}from"./OverviewPageContent-5557813a.esm.js";import{parseEntityRef as q,stringifyEntityRef as Xr}from"@backstage/catalog-model";import{useApi as O,useRouteRef as ae,alertApiRef as Zr,configApiRef as Jr}from"@backstage/core-plugin-api";import{useQuery as j,useQueryClient as ie,useMutation as ce}from"@tanstack/react-query";import{s as A,Q as D,k as me,M as de,l as Ne,m as Ya,E as Yt,t as Xa,n as el,o as tl,p as al,q as nl,r as rl,v as Za,x as ll,S as ol,w as sl}from"./index-c3aebdd7.esm.js";import{catalogApiRef as il,EntityRefLink as _e,humanizeEntityRef as cl,entityRouteRef as Ja}from"@backstage/plugin-catalog-react";import en from"@material-ui/icons/Close";import{Controller as M,useWatch as Xt,useForm as st,useFormContext as it,useFieldArray as ct,FormProvider as ml}from"react-hook-form";import tn from"@material-ui/icons/ArrowDropUp";import Zt from"@material-ui/icons/ArrowDropDown";import dl from"rehype-sanitize";import an from"@uiw/react-md-editor";import ze,{uniqBy as Jt,isObject as ul,findIndex as nn,capitalize as pl}from"lodash";import rn from"@material-ui/icons/Delete";import{asArray as ea,FrequencySchema as hl,parseFactRef as ta,stringifyFactRef as gl,soundcheckCheckUpdatePermission as ln,soundcheckCheckDeletePermission as vl,soundcheckCheckCreatePermission as El,soundcheckTrackUpdatePermission as on,soundcheckTrackDeletePermission as fl,soundcheckTrackCreatePermission as yl,soundcheckCollectorUpdatePermission as bl,soundcheckCampaignUpdatePermission as Cl,soundcheckCampaignDeletePermission as kl,soundcheckCampaignCreatePermission as xl,soundcheckTrackReadPermission as wl,soundcheckCheckReadPermission as Tl,soundcheckCollectorReadPermission as Pl}from"@spotify/backstage-plugin-soundcheck-common";import{v4 as sn}from"uuid";import Rl from"cron-validate";import Sl from"cronstrue";import{Autocomplete as aa,Skeleton as mt,ToggleButtonGroup as Nl,ToggleButton as cn}from"@material-ui/lab";import mn from"@material-ui/icons/CheckBox";import dn from"@material-ui/icons/CheckBoxOutlineBlank";import Ll from"@material-ui/icons/ExpandMore";import Dl from"@material-ui/icons/MoreVert";import Il from"@material-ui/icons/Archive";import dt from"@material-ui/icons/Group";import{usePermission as Q}from"@backstage/plugin-permission-react";import Ol from"@material-ui/icons/Search";import na from"../images/no-results.svg";import{useDrag as Fl,useDrop as Al,DndProvider as un}from"react-dnd";import pn from"@material-ui/icons/DragIndicator";import $l from"@material-ui/icons/Visibility";import hn from"@material-ui/icons/Add";import gn from"@material-ui/icons/Remove";import{HTML5Backend as vn}from"react-dnd-html5-backend";import Ml from"@material-ui/icons/OpenInNew";import Bl from"@material-ui/icons/DoneAllRounded";import Gl from"@material-ui/icons/Menu";import{ResponsiveContainer as En,LineChart as ra,CartesianGrid as ut,XAxis as We,YAxis as Ue,Line as la,Tooltip as fn,Legend as yn,BarChart as bn,Bar as Cn,Cell as Vl}from"recharts";import{DateTime as pt}from"luxon";import{motion as oa}from"framer-motion";import kn from"react-use/lib/useLocalStorage";import ql from"@material-ui/icons/GetApp";import{CSVLink as xn}from"react-csv";import{CircularProgressbar as Hl,buildStyles as _l}from"react-circular-progressbar";import"react-circular-progressbar/dist/styles.css";import zl from"@material-ui/icons/TrendingUp";import Wl from"@material-ui/icons/TrendingDown";import Ul from"@material-ui/icons/TrendingFlat";import Kl from"@material-ui/icons/Reorder";import jl from"@material-ui/icons/Apps";import Ql from"@material-ui/icons/GridOn";import Yl from"@material-ui/icons/KeyboardArrowDown";import Xl from"../images/catalog.svg";import Zl from"../images/git.svg";import Jl from"../images/octocat.svg";import eo from"../images/settings.svg";import to from"../images/soundcheck.png";import ao from"../images/tech_insights.png";import no from"react-use/lib/useDebounce";import{MuiPickersUtilsProvider as wn}from"@material-ui/pickers/MuiPickersUtilsProvider";import{KeyboardDatePicker as Tn}from"@material-ui/pickers/DatePicker";import{DatePickerToolbar as ro}from"@material-ui/pickers/DatePicker/DatePickerToolbar";import Pn from"@date-io/luxon";import"@material-ui/lab/Autocomplete";import"react-use/lib/useAsync";import"./RefetchingIndicator-a31faa1d.esm.js";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";import"../images/empty-state.svg";function ht(e,a,n){const r=O(A);return j([D.GetChecks,e,a,n],async()=>r.getChecks(e,a,n),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function sa(e,a,n){const r=O(A);return j([D.GetAllPrograms,e,a,n],async()=>r.getAllPrograms(e,a,n),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const lo="Error Creating Track";function oo(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.createProgram(l);if(!o)throw new Error("Failed to create track.");return o};return ce([de.CreateProgram],r,{onSuccess:async()=>{const l=[D.GetAllPrograms,D.GetOverallTrackPassRate,D.GetIndividualTrackPassRate];for(const o of l)a.invalidateQueries({queryKey:[o]})},onError:l=>{let o="Failed to create track.";l instanceof Error&&(o=l.message),n({severity:"error",title:lo,message:o})}})}const so=e=>{const a=O(A);return j([D.GetOverallCheckPassRates,e],async()=>a.getOverallCheckPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},io=e=>{const a=O(A);return j([D.GetIndividualCheckPassRate,e],async()=>a.getIndividualCheckPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},co=e=>{const a=O(A);return j([D.GetOverallTrackPassRate,e],async()=>a.getOverallTrackPassRate(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},mo=e=>{const a=O(A);return j([D.GetIndividualTrackPassRate,e],async()=>a.getIndividualTrackPassRate(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},uo=e=>{const a=O(A);return j([D.GetOverallEntityPassRates,e],async()=>a.getOverallEntityPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},po=e=>{const a=O(A);return j([D.GetIndividualEntityPassRate,e],async()=>a.getIndividualEntityPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},ho=e=>{const a=O(A);return j([D.GetOverallGroupPassRates,e],async()=>a.getOverallGroupPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},go=e=>{const a=O(A);return j([D.GetIndividualGroupPassRates,e],async()=>a.getIndividualGroupPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},ia=e=>{const a=ae(e),n=pe(),{key:r}=Ba();return[U(()=>{n(r?-1:a())},[n,a,r]),U(()=>n(a()),[n,a])]},vo=_(e=>({box:{zIndex:9,position:"fixed",bottom:"0",width:"100%"},footer:{padding:e.spacing(2)}})),gt=({onCancel:e,saveButtonText:a,isLoading:n,onSave:r,disableSave:l})=>{const o=vo();return t.createElement(k,{className:o.box},t.createElement(Ha,{elevation:3,className:o.footer},t.createElement(h,{container:!0,item:!0,spacing:2,justifyContent:"space-between"},t.createElement(h,{item:!0},t.createElement(V,{variant:"contained",color:"primary",onClick:e},"Cancel")),t.createElement(h,{item:!0},r&&t.createElement(V,{variant:"contained",color:"primary",disabled:n||l,onClick:r?()=>r():void 0},a)))))},ca=()=>Je({selectedItem:null,setSelectedItem:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{},isReadOnly:!1,showReadOnlyModal:()=>{},hideModal:()=>{}}),ma=e=>({children:a})=>{const[n,r]=C(null),[l,o]=C(!1),[s,i]=C(!1),[c,d]=C(!1),m=p=>{o(!0),r(p)},u=()=>{r(null),o(!1),d(!1)};return t.createElement(e.Provider,{value:{selectedItem:n,setSelectedItem:r,isLoading:s,setIsLoading:i,showAddModal:c,setShowAddModal:d,isReadOnly:l,showReadOnlyModal:m,hideModal:u}},a)},da=e=>et(e),Rn=ca(),Sn=ma(Rn),Le=()=>da(Rn),Nn=ca(),Ln=ma(Nn),ve=()=>da(Nn),Dn=ca(),Eo=ma(Dn),ua=()=>da(Dn),In=Je({selectedCollector:null,setSelectedCollector:()=>{},showModal:!1,setShowModal:()=>{},hideModal:()=>{}}),fo=({children:e})=>{const[a,n]=C(null),[r,l]=C(!1),o=()=>{n(null),l(!1)};return t.createElement(In.Provider,{value:{selectedCollector:a,setSelectedCollector:n,showModal:r,setShowModal:l,hideModal:o}},e)},vt=()=>et(In),yo=_(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","& .wmde-markdown-var":{"--color-canvas-default":e.palette.background.paper,"--color-border-default":e.palette.border},"& .wmde-markdown":{"--color-canvas-default":e.palette.background.paper}}})),bo=t.forwardRef(function(e,a){return t.createElement(Tr,{direction:"up",ref:a,...e})}),Ke=({open:e,handleClose:a,title:n,children:r})=>{const l=yo();return t.createElement(Pr,{fullScreen:!0,open:e,onClose:a,TransitionComponent:bo},t.createElement(Rr,{className:l.appBar},t.createElement(Sr,null,t.createElement(b,{className:l.title,"data-testid":`dialog-${n}`},n),t.createElement(Re,{"data-testid":"close-dialog",edge:"end",color:"inherit",onClick:a,"aria-label":"close",className:l.closeIcon},t.createElement(en,null)))),t.createElement(k,{className:l.content},r))},Co=x(()=>({helperText:{marginLeft:0}})),De=({name:e,control:a,error:n,label:r,placeholder:l,disabled:o,numbersOnly:s,inputProps:i,rules:c,messages:d,helperText:m,multiline:u,minRows:p,variant:v="standard",size:f,margin:E="normal"})=>{const g=Co();return t.createElement(M,{name:e,control:a,defaultValue:"",rules:c,render:({field:y})=>t.createElement(K,{...y,FormHelperTextProps:{className:g.helperText},fullWidth:!0,multiline:u,minRows:p,placeholder:l,label:r,disabled:o,type:s?"number":"text",InputProps:i,margin:E,error:!!n,helperText:n&&d?d[n.type]:m,variant:v,size:f})})},ko=_(()=>({section:{gap:0}})),xo=({control:e,error:a,isLoading:n,disabled:r})=>{const l=ko();return t.createElement("div",{className:l.section},t.createElement(De,{name:"checkName",control:e,error:a,label:"Name",placeholder:"Enter a name for the check",disabled:n||r,rules:{required:!0,maxLength:100},messages:{required:"This field is required",maxLength:"Input must be less than 100 characters"}}))},wo=_(e=>({root:{display:"flex",flexDirection:"column",gap:0},button:{marginLeft:-e.spacing(1)},title:{fontWeight:700,color:e.palette.primary.main,cursor:"pointer"}})),Et=({title:e,alwaysExpanded:a=!1,children:n})=>{const[r,l]=C(a),o=wo(),s=()=>{a||l(!r)};return t.createElement("div",{className:o.root},t.createElement(h,{container:!0,alignItems:"center",spacing:0},t.createElement(h,{item:!0},!a&&t.createElement(Re,{onClick:s,className:o.button},r?t.createElement(Zt,{fontSize:"large"}):t.createElement(tn,{fontSize:"large"}))),t.createElement(h,{item:!0},t.createElement(b,{onClick:s,className:o.title},e))),t.createElement(Nr,{in:r},n))},To=_(e=>({markdown:{paddingTop:e.spacing(2),whiteSpace:"pre-wrap"}})),ft=({name:e,control:a,label:n,rules:r,helperText:l,placeholder:o,disabled:s})=>{const i=Se(),c=To();return t.createElement(M,{name:e,control:a,defaultValue:"",rules:r,render:({field:d})=>t.createElement("div",{"data-color-mode":i.palette.type},n&&t.createElement(b,{variant:"subtitle2"},n),s?t.createElement(an.Markdown,{className:c.markdown,source:d.value}):t.createElement(an,{placeholder:o,value:d.value,onChange:d.onChange,previewOptions:{rehypePlugins:[[dl]]},"data-testid":`markdown-editor-${e}`}),l&&t.createElement(b,{variant:"subtitle2"},l))})},Po=_(e=>({tabContent:{padding:e.spacing(1)}})),Ro=({control:e,isLoading:a,disabled:n})=>{const r=Po(),[l,o]=C(0);return t.createElement(Et,{title:n?"Pass and fail messages":"Pass and fail messages (optional)"},t.createElement("div",{style:{height:"100%",width:"100%"}},t.createElement(_a,{orientation:"horizontal",variant:"scrollable",value:l,onChange:(s,i)=>{o(i)}},t.createElement(Ve,{label:"Passed Message"}),t.createElement(Ve,{label:"Failed Message"})),t.createElement("div",{className:r.tabContent},l===0&&t.createElement(ft,{name:"passMessage",control:e,placeholder:"Enter pass message...",disabled:a||n}),l===1&&t.createElement(ft,{name:"failMessage",control:e,placeholder:"Enter fail message...",disabled:a||n}))))},So=({control:e,isLoading:a,disabled:n})=>t.createElement(ft,{name:"description",control:e,label:"Description",placeholder:n?void 0:"Enter a brief description about the check",disabled:n||a}),No=x(()=>({helperText:{marginLeft:0}})),yt=({name:e,control:a,selectLabel:n,options:r,disabled:l,rules:o,style:s,helperText:i})=>{const c=No();return t.createElement(M,{name:e,control:a,rules:o,render:({field:d,fieldState:m})=>t.createElement(tt,{variant:"outlined",style:s!=null?s:{minWidth:200},error:m.invalid},t.createElement(zt,{id:`${e}-select-label`},n),t.createElement(Wt,{...d,disabled:l,error:m.invalid,"data-testid":`${e}-select`,labelId:`${e}-select-label`,label:n,value:r?d.value:"",defaultValue:""},r==null?void 0:r.map(({value:u,label:p})=>t.createElement(he,{key:u,value:u},p))),t.createElement(za,{className:c.helperText},i))})},Lo=({control:e,supportContactError:a,disabled:n,isLoading:r,options:l,alwaysExpanded:o=!1})=>{const s=Se(),i=l==null?void 0:l.map(c=>({value:c.ref,label:c.name}));return t.createElement(Et,{title:n?"Owner Details":"Owner Details (optional)",alwaysExpanded:o!=null?o:!1},t.createElement(yt,{name:"teamOwner",control:e,selectLabel:"Owner",options:i&&Jt(i,"value"),disabled:n||r}),t.createElement("div",{style:{marginTop:s.spacing(2)}},t.createElement(De,{name:"supportChannel",control:e,error:a,label:"Support Channel",placeholder:"Enter a channel or email to get check support",disabled:n||r,rules:{},messages:{}})))},Do=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"}})),Io=({onAddCondition:e,onAddExpression:a})=>{const n=Do(),[r,l]=C(null),o=!!r,s=c=>{l(c.currentTarget)},i=()=>{l(null)};return t.createElement(k,null,t.createElement(Wa,{color:"primary"},t.createElement(V,{"data-testid":"add-button",id:"add-button",className:n.button,"aria-controls":o?"add-menu":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:s},t.createElement(k,{className:n.label},"Add"),t.createElement(k,{className:n.icon},t.createElement(Zt,null)))),t.createElement(Ut,{id:"add-menu",anchorEl:r,open:o,onClose:i,classes:{paper:n.menu},MenuListProps:{"aria-labelledby":"add-button"}},t.createElement(he,{"data-testid":"add-condition",onClick:()=>{e(),i()}},"Add Condition"),t.createElement(he,{"data-testid":"add-expression",onClick:()=>{a(),i()}},"Add Expression")))};var Ee=(e=>(e.AllOf="all",e.AnyOf="any",e))(Ee||{});const Oo={all:"ALL OF",any:"ANY OF"};var On=(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))(On||{});const Fo={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"};var bt=(e=>(e.title="Create a check",e.description="A check is a comparison between a defined acceptable outcome and the actual outcome of a given process.",e.callToAction="Get started",e))(bt||{});const Ao=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 Fn(e){const a=O(A);return j([D.GetCollectors,e],async()=>a.getCollectors(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function $o(e,a){const n=O(A);return j([D.GetFactSchema,e,a],()=>n.getFactSchema(e,a),{enabled:!!e&&!!a,staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const je=()=>({selectedKinds:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[],selectedTypes:[]}),Mo=[{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"}],Ie={selectedKinds:"kind",selectedTypes:"spec.type",selectedLifecycles:"spec.lifecycle",selectedOwners:"spec.owner",selectedSystems:"spec.system",selectedTags:"metadata.tags"},An=e=>!e||Object.values(e).every(a=>a.length===0)?void 0:{catalog:Object.entries(e).reduce((a,[n,r])=>{const l=Ie[n];return r.length>0&&(a[l]=r),a},{})},$n=e=>Object.keys(Ie).reduce((a,n)=>{var r,l;return a[n]=ea((l=(r=e==null?void 0:e.catalog)==null?void 0:r[Ie[n]])!=null?l:[]),a},{}),Ct=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[Ie[n]]=r);return[a]},pa=e=>{if(e&&Array.isArray(e)&&e.length){const a=e[0];return Object.keys(Ie).reduce((n,r)=>{var l;return n[r]=ea((l=a==null?void 0:a[Ie[r]])!=null?l:[]),n},{})}return je()};var B=(e=>(e.Months="months",e.Weeks="weeks",e.Days="days",e.Hours="hours",e.Minutes="minutes",e.Seconds="seconds",e))(B||{});const ha=()=>({type:"HumanDuration",unit:B.Hours,value:1,cron:""}),ga=[B.Months,B.Weeks,B.Days,B.Hours,B.Minutes,B.Seconds];function Bo(e){return ga.includes(e)}function kt(e){switch(e){case"months":return B.Months;case"weeks":return B.Weeks;case"days":return B.Days;case"hours":return B.Hours;case"minutes":return B.Minutes;case"seconds":return B.Seconds;default:return null}}function va(e){if(e){const{cron:a,type:n,unit:r,value:l}=e;return n==="HumanDuration"?{[r]:l}:{cron:a}}}function Ea(e){var a;const n=ha();if(e&&ze.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=kt(l))!=null?a:B.Hours,value:o}}}return n}const Go=e=>Rl(e).isValid(),Mn=e=>{try{return Sl.toString(e)}catch(a){return typeof a=="string"?a.replace(/^Error:\s*/,""):"Invalid cron expression"}},Bn=1,Gn=31536e3,Vn=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},Vo=x(e=>({divider:{marginTop:e.spacing(3),marginBottom:e.spacing(3)},title:{cursor:"pointer"}})),qn=({value:e,onChange:a,disabled:n,errors:r})=>{var l;const o=Vo(),[s,i]=C(e),[c,d]=C(`${e.value}`);F(()=>{a&&a(s)},[s,a]);const m=g=>{i({...e,type:g.target.value})},u=g=>{d(g.target.value);const y=parseInt(g.target.value,10);i({...e,value:isNaN(y)?0:y})},p=g=>{var y;i({...s,unit:(y=kt(g.target.value))!=null?y:B.Hours})},v=g=>{const y=g.target.value;i({...s,cron:y})},f=()=>{i({...s,type:"cron"})},E=()=>{i({...s,type:"HumanDuration"})};return t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{item:!0},t.createElement(Lr,{name:"frequencyType",value:s.type,onChange:m},t.createElement(h,{container:!0,alignItems:"flex-start"},t.createElement(h,{item:!0,style:{paddingLeft:0}},t.createElement(Ua,{disabled:n,value:"HumanDuration"})),t.createElement(h,{item:!0},t.createElement(b,{variant:"body1",className:o.title,onClick:E},"Run on a regular interval"),t.createElement(b,{variant:"caption"},"Run on a regular interval that you define"),s.type==="HumanDuration"&&t.createElement(h,{container:!0,style:{alignItems:"flex-start"}},t.createElement(h,{item:!0},t.createElement(K,{id:"every",type:"number",inputProps:{min:Bn,max:Gn},label:"Every",name:"every",disabled:n,value:c,error:!!(r!=null&&r.message),helperText:r==null?void 0:r.message,onChange:u})),t.createElement(h,{item:!0},t.createElement(tt,null,t.createElement(zt,{id:"frequency-unit"},"Unit"),t.createElement(Wt,{labelId:"frequency-unit",disabled:n,value:s.unit,onChange:p,"data-testid":"frequency-unit"},ga.map(g=>t.createElement(he,{key:g,value:g},g)))))))),t.createElement(qe,{className:o.divider}),t.createElement(h,{container:!0,alignItems:"flex-start"},t.createElement(h,{item:!0,style:{paddingLeft:0}},t.createElement(Ua,{disabled:n,value:"cron"})),t.createElement(h,{item:!0},t.createElement(b,{variant:"body1",className:o.title,onClick:f},"Run on a schedule"),t.createElement(b,{variant:"caption"},"Run on a schedule defined via cron expression"),s.type==="cron"&&t.createElement(h,{item:!0},t.createElement(K,{id:"cron-expression","data-testid":"cron-expression",style:{minWidth:250},label:(l=r==null?void 0:r.message)!=null?l:Mn(s.cron),disabled:n,placeholder:"* * * * *",error:!!(r!=null&&r.message),value:s.cron,onChange:v})))))))},qo=()=>({enabled:!1,frequency:ha()}),Ho=e=>{var a;if(ul(e)&&"frequency"in e){const n=hl.safeParse(e.frequency);if(n.success){const r=n.data;if("cron"in r)return{enabled:!0,frequency:{type:"cron",unit:B.Hours,value:1,cron:r.cron}};const l=Object.keys(r);if(l.length){const o=l[0];if(Bo(o))return{enabled:!0,frequency:{type:"HumanDuration",unit:o,value:(a=r[o])!=null?a:1,cron:""}}}}}return{enabled:!1,frequency:{type:"HumanDuration",unit:B.Hours,value:1,cron:""}}},_o=(e,a)=>{const{enabled:n,frequency:r}=e;if(n){const{cron:l,type:o,unit:s,value:i}=r;return o==="HumanDuration"?{frequency:{[s]:i},filter:Ct(a)}:{frequency:{cron:l}}}},fa=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(fa(r))}),n}if(e.expressions)return e.expressions.map(fa);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{}},Hn=(e,a=!0)=>{if(!e)return{conditions:[]};const n=Object.keys(e),r=n.includes("all")||a&&!n.includes("any")?Ee.AllOf:Ee.AnyOf;if(n.includes(r)||a){const l=e[r]||[e],o=[],s=[];return l.forEach(i=>{const c=Object.keys(i);c.includes("all")||c.includes("any")?s.push(Hn(i,!1)):o.push({factRef:i.factRef,path:i.path,operator:i.operator,value:i.value})}),{expressions:s.length>0?s:void 0,conditions:o,expressionType:r}}return{expressionType:Ee.AllOf,conditions:[{factRef:e.factRef,path:e.path,operator:e.operator,value:e.value}]}},zo=e=>({checkName:e.name||"",description:e.description||"",teamOwner:e.ownerEntityRef||"",supportChannel:e.supportChannel||"",expressions:Hn(e.rule),passMessage:e.passedMessage||void 0,failMessage:e.failedMessage||void 0,filters:$n(e.filter),schedule:Ho(e.schedule)}),Wo=(e,a)=>{var n,r,l,o;return{id:a?a.id:sn(),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:fa(e.expressions),filter:e.filters?An(e.filters):void 0,supportChannel:(o=e.supportChannel)!=null?o:void 0,schedule:_o(e.schedule,e.filters)}},ya=(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 s=r[l];n.push(...ya(s,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(...ya(o,r))}return n},Uo={checkName:"",description:"",teamOwner:"",supportChannel:"",expressions:{expressionType:Ee.AllOf,expressions:void 0,conditions:[{factRef:"",path:"",operator:"",value:"",conditions:[]}]},filters:je(),schedule:qo()},Ko=(e,a)=>{const{data:n,isLoading:r}=Fn(),l=Xt({control:a,name:`${e}.factRef`}),[o,s]=C(()=>_n(l));F(()=>{s(_n(l))},[l]);const{data:i}=$o(o==null?void 0:o.source,o==null?void 0:o.name),c=H(()=>i?ya(i.schema):[],[i]),d=H(()=>n==null?void 0:n.flatMap(m=>m.factNames.map(u=>{const p=ta(u,{defaultSource:m.id,defaultScope:"default"});return{label:p.name,value:gl(p)}})),[n]);return{isLoading:r,pathOptions:c,factRefOptions:d}};function _n(e){if(e)try{return ta(e,{defaultSource:"unknown",defaultScope:"default"})}catch{return null}return null}const zn=({name:e,rules:a,label:n,control:r,options:l,getOptionLabel:o,getOptionValue:s,onChange:i,onInputChange:c,disabled:d})=>t.createElement(M,{name:e,control:r,rules:a,render:({field:m,fieldState:u})=>t.createElement(aa,{...m,freeSolo:!0,"data-testid":`${e}-autocomplete`,style:{minWidth:250},disabled:d,options:l,getOptionLabel:o,renderInput:p=>t.createElement(K,{...p,variant:"outlined",label:n,error:u.invalid,helperText:u.error?u.error.message:null}),onChange:(p,v)=>{const f=s?s(v):v;i==null||i(f),m.onChange(f)},onInputChange:(p,v)=>{const f=s?s(v):v;c==null||c(f),m.onChange(f)}})}),jo=e=>{try{return ta(e),!0}catch{return"Invalid fact reference. [source]:[scope]/[name]."}},Qo=({control:e,name:a,handleDelete:n,disabled:r,disableDelete:l,setValue:o,getValues:s})=>{var i;const c=Ao(),d=H(()=>Object.values(On).map(y=>({value:y,label:Fo[y]})),[]),{pathOptions:m,factRefOptions:u,isLoading:p}=Ko(a,e),v={required:!0},f=H(()=>{var y;return(y=u==null?void 0:u.map(w=>w.value))!=null?y:[]},[u]),E=(i=s("expressions.conditions"))==null?void 0:i.map(({factRef:y})=>y),g=y=>{y&&!(E!=null&&E.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},u&&t.createElement(zn,{name:`${a}.factRef`,control:e,rules:{...v,maxLength:500,validate:jo},label:"Fact",options:f,getOptionLabel:y=>{var w,P;return(P=(w=u==null?void 0:u.find(L=>y===L.value))==null?void 0:w.label)!=null?P:y},getOptionValue:y=>{var w,P,L;return(L=(P=(w=u==null?void 0:u.find(R=>y===R.label))==null?void 0:w.value)!=null?P:y)!=null?L:""},disabled:r||p,onChange:g,onInputChange:g}),t.createElement(zn,{name:`${a}.path`,label:"Path",rules:v,control:e,disabled:r||p,options:m}),t.createElement(yt,{name:`${a}.operator`,rules:v,control:e,selectLabel:"Operator",options:d,disabled:r}),t.createElement(M,{name:`${a}.value`,control:e,defaultValue:"",rules:v,render:({field:y,fieldState:w})=>t.createElement(K,{...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(Re,{onClick:n,className:c.deleteButton,"data-test-id":`${a}-delete-button`},t.createElement(rn,{className:c.deleteIcon})))},Yo=({conditions:e,control:a,name:n,handleDelete:r,disabled:l,disableDelete:o,setValue:s,getValues:i,depth:c})=>t.createElement(t.Fragment,null,e.map((d,m)=>t.createElement(h,{item:!0,key:m},t.createElement(Qo,{control:a,name:`${n}.conditions[${m}]`,"data-testid":`${n}-condition-input`,handleDelete:()=>r(m),disabled:l,disableDelete:c===0&&m===0?!0:o,setValue:s,getValues:i})))),Xo=({expression:e,control:a,name:n,depth:r,getValues:l,setValue:o,trigger:s,disabled:i})=>e?t.createElement(h,{item:!0},t.createElement(Wn,{control:a,name:`${n}`,depth:r+1,getValues:l,setValue:o,trigger:s,disabled:i})):null,Zo=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)"}})),Jo=({control:e,name:a,getValues:n,disabled:r})=>{const l=Zo(),o=`${a}`,s=n(o),[i,c]=C(s||Ee.AllOf),d=m=>{c(m)};return t.createElement(M,{control:e,name:a,render:({field:{onChange:m}})=>t.createElement(Wa,{color:"primary"},Object.values(Ee).map(u=>t.createElement(V,{key:u,className:i===u?`${l.selectedButton} ${l.button}`:`${l.button}`,onClick:()=>{d(u),m(u)},disabled:r},Oo[u])))})},es=(e,a,n,r)=>({handleAddCondition:async()=>{const l=`${e}`,o=a(l),s=[...(o==null?void 0:o.conditions)||[],{factRef:"",path:"",operator:"",value:""}],i=`${e}.conditions`;n(i,s),await r(i)},handleAddExpression:async()=>{const l=`${e}.expressions`,o=a(l)||[];o.push({expressionType:Ee.AllOf,expressions:void 0,conditions:[{factRef:"",path:"",operator:"",value:""}]}),n(l,o),await r(l)},handleDeleteCondition:async(l,o)=>{const s=o.split("[")[0],i=`${o}.conditions`,c=a(i);if(c.splice(l,1),c.length===0){n(i,void 0);const d=parseInt(o.slice(o.lastIndexOf("[")+1,o.lastIndexOf("]")),10),m=a(s);m.splice(d,1),n(s,m.length>0?m:void 0),await r(s)}else n(i,c),await r(i)}}),ts=_(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"}})),Wn=({control:e,name:a,depth:n,getValues:r,setValue:l,trigger:o,disabled:s})=>{const i=ts(),{handleAddCondition:c,handleAddExpression:d,handleDeleteCondition:m}=es(a,r,l,o),u=`${a}`,p=r(u),v=(p==null?void 0:p.conditions)||[],f=p==null?void 0:p.expressions;return t.createElement(k,{className:n>0?i.inner:i.root},n>0&&t.createElement(k,{className:i.connector}),t.createElement(h,{container:!0,spacing:0,direction:"column"},t.createElement(h,{item:!0},t.createElement(Jo,{control:e,disabled:s,name:`${a}.expressionType`,getValues:r})),t.createElement(h,{item:!0,container:!0,spacing:0,direction:"column"},t.createElement(Yo,{depth:n,handleDelete:E=>m(E,a),disabled:s,conditions:v,control:e,name:a,setValue:l,getValues:r}),f==null?void 0:f.map((E,g)=>t.createElement(Xo,{key:g,expression:E,control:e,name:`${a}.expressions[${g}]`,depth:n,getValues:r,setValue:l,trigger:o,disabled:s}))),!s&&t.createElement(h,{item:!0},t.createElement(Io,{onAddCondition:c,onAddExpression:d}))))},Un=({type:e,cron:a,value:n})=>{if(e==="cron"){if(!Go(a))return Mn(a)}else if(e==="HumanDuration")return Vn(n);return!0},as=x(e=>({container:{padding:e.spacing(0,1.5)}})),ns=({control:e,disabled:a})=>{const n=as(),r=Xt({control:e,name:"schedule"});return t.createElement(h,{className:n.container,item:!0,xs:12},t.createElement(h,{item:!0},t.createElement(M,{name:"schedule.enabled",control:e,render:({field:l})=>t.createElement(at,{disabled:a,control:t.createElement(He,{checked:l.value,onChange:l.onChange}),label:"Schedule check"})})),t.createElement(h,{item:!0},t.createElement(M,{name:"schedule.frequency",control:e,rules:{validate:Un},render:({field:l})=>t.createElement(qn,{disabled:a||!r.enabled,value:l.value,onChange:l.onChange})})))},rs=x(e=>({container:{padding:e.spacing(0,1.5)},scheduleContainer:{padding:e.spacing(2)}})),ls=({control:e,disabled:a})=>{const n=rs();return t.createElement(Et,{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(ns,{disabled:a,control:e}))))},os=e=>{const{selectedItem:a}=ve();let n=Uo;a&&(n=zo(a));const{control:r,handleSubmit:l,getValues:o,setValue:s,trigger:i,formState:{errors:c}}=st({defaultValues:n}),{showModal:d}=Ne();return{control:r,handleSubmit:l,getValues:o,setValue:s,trigger:i,errors:c,onSubmit:async m=>{if(!await d({title:"Save Check",message:`Are you sure you want to save check: ${m.checkName}?`,error:!1}))return;const u=Wo(m,a);e(u)}}},ss=()=>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.")),ba=_(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},selectMargin:{marginBottom:e.spacing(1)}})),xt=e=>{const a=O(Zr),n=O(il);return j([D.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"})}})},is=x({container:{padding:0},formControl:{flexGrow:1}}),cs=({facet:e,label:a,values:n,onChange:r,disabled:l})=>{var o;const s=is(),{data:i,isLoading:c,error:d}=xt(e),m=H(()=>i==null?void 0:i.map(E=>E.toLocaleLowerCase("en-US")),[i]),u=(o=n==null?void 0:n.map(E=>E.toLocaleLowerCase("en-US")))!=null?o:[],p=U((E,g)=>{r(m&&m.every(y=>g.includes(y))?void 0:g)},[m,r]),v=U(()=>{r(n!=null&&n.length?n:void 0)},[n,r]);if(!i||!m||d)return t.createElement(b,{color:"error"},"Failed to load facet: ",e);const f=l||c||!(n!=null&&n.length)&&(!(i!=null&&i.length)||!(m!=null&&m.length));return t.createElement(k,{pb:1,pt:1,className:s.container},t.createElement(b,{variant:"subtitle2"},a),t.createElement(aa,{className:s.formControl,multiple:!0,limitTags:4,disableCloseOnSelect:!0,"aria-label":a,options:m,value:u,getOptionLabel:E=>{var g;return(g=i[m.indexOf(E)])!=null?g:E},onChange:p,onBlur:v,disabled:f,renderOption:(E,{selected:g})=>{var y;return t.createElement(at,{control:t.createElement(He,{icon:t.createElement(dn,{fontSize:"small"}),checkedIcon:t.createElement(mn,{fontSize:"small"}),checked:g}),label:(y=i[m.indexOf(E)])!=null?y:E})},size:"small",popupIcon:t.createElement(Ll,{"data-testid":"selected-facets-expand"}),renderInput:E=>t.createElement(K,{...E,variant:"outlined"})}))},ms=x(()=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap"}})),Ca=({value:e,onChange:a,disabled:n})=>{const r=ms(),l=o=>s=>{a({...e,[o]:s!=null?s:[]})};return t.createElement(h,{container:!0,className:r.filterContainer,spacing:2},Mo.map(o=>t.createElement(h,{item:!0,xs:12,sm:6,md:4,key:o.key},t.createElement(cs,{facet:o.facet,label:o.label,values:e==null?void 0:e[o.key],onChange:l(o.key),disabled:n}))))},ds=x(e=>({title:{fontWeight:700},container:{padding:e.spacing(0,1.5)},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)}})),Kn=({control:e,disabled:a})=>{const n=ds();return t.createElement(Et,{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(M,{name:"filters",control:e,render:({field:r})=>{var l;return t.createElement(Ca,{value:(l=r.value)!=null?l:je(),onChange:r.onChange})}}))))},ka=({title:e,open:a,onSave:n,onClose:r})=>{const l=ba(),{hideModal:o,isLoading:s,isReadOnly:i}=ve(),c=U(()=>r?r():o(),[r,o]),{control:d,handleSubmit:m,getValues:u,setValue:p,trigger:v,errors:f,onSubmit:E}=os(n),{options:g,isLoading:y}=Qt();return t.createElement(Ke,{handleClose:c,title:e,open:a},t.createElement("form",{onSubmit:m(E)},t.createElement(h,{container:!0,spacing:2,className:l.root},t.createElement(h,{item:!0,xs:9},t.createElement(nt,{className:l.card},t.createElement(b,{className:l.sectionLabel,style:{margin:0}},"Check Details"),t.createElement(xo,{control:d,error:f.checkName,isLoading:s,disabled:i}),t.createElement(So,{control:d,error:f.description,isLoading:s,disabled:i}),t.createElement(Lo,{control:d,disabled:i,isLoading:s,options:y?void 0:g}),t.createElement(b,{className:l.sectionLabel},"Rules"),t.createElement(Wn,{control:d,getValues:u,setValue:p,trigger:v,disabled:i,name:"expressions",depth:0}),t.createElement(Kn,{control:d,disabled:i}),t.createElement(Ro,{control:d,isLoading:s,disabled:i}),t.createElement(ls,{control:d,disabled:i}))),t.createElement(h,{item:!0,xs:3},t.createElement(ss,null))),t.createElement(h,{container:!0,spacing:4,className:l.root},t.createElement(gt,{onCancel:c,saveButtonText:"Save Check",isLoading:s,onSave:i?void 0:m(E)}))))},us="Error Creating Check";function jn(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.createCheck(l);if(!o)throw new Error("Failed to create check.");return o};return ce([de.CreateCheck],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[D.GetChecks]})},onError:l=>{let o="Failed to create check.";l instanceof Error&&(o=l.message),n({severity:"error",title:us,message:o})}})}const ps=()=>{const{hideModal:e,showAddModal:a,setIsLoading:n}=ve(),{mutateAsync:r,isLoading:l}=jn();return F(()=>{n(l)},[n,l]),t.createElement(ka,{title:"Create a Check",open:a,onSave:async o=>{await r(o,{onSuccess:()=>e()})}})},hs=({handleDelete:e,handleArchive:a})=>{const[n,r]=C(null),l=!!n,o=i=>{i.stopPropagation(),r(i.currentTarget)},s=i=>{i.stopPropagation(),r(null)};return t.createElement(t.Fragment,null,t.createElement(Re,{"aria-label":"summary-card-actions",id:"summary-card-action-menu-button","aria-controls":l?"summary-card-action-menu":void 0,"aria-expanded":l?"true":void 0,"aria-haspopup":"true",onClick:o},t.createElement(Dl,null)),t.createElement(Ut,{id:"summary-card-action-menu",anchorEl:n,open:l,onClose:s,getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{"aria-labelledby":"summary-card-action-menu-button"}},a&&t.createElement(he,{"data-testid":"summary-card-action-archive",onClick:i=>{a(i),s(i)}},t.createElement(J,null,t.createElement(Il,{fontSize:"small"})),t.createElement(ee,null,"Archive")),e&&t.createElement(he,{"data-testid":"summary-card-action-delete",onClick:i=>{e(i),s(i)}},t.createElement(J,null,t.createElement(rn,{fontSize:"small"})),t.createElement(ee,null,"Delete"))))},gs=Dr(e=>zr({root:{width:"100%",height:"100%",minHeight:"385px",display:"flex",flexDirection:"column",padding:e.spacing(2),position:"relative"}}))(nt),vs=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)}})),Qe=({title:e,description:a,viewLabel:n="View",editLabel:r="Edit",children:l,handleDelete:o,handleArchive:s,handleEdit:i,handleView:c})=>{const d=vs();return t.createElement(gs,{className:d.card,"data-testid":e},t.createElement(Ir,{title:e,titleTypographyProps:{className:d.summaryName},subheader:t.createElement(Va,{className:d.summaryDescription,content:a!=null?a:""}),action:(o||s)&&t.createElement(hs,{handleDelete:o,handleArchive:s})}),t.createElement(Or,null,l),t.createElement(qe,null),t.createElement(Fr,null,t.createElement(V,{"aria-label":i?r:n,"data-testid":`${e}-button`,size:"medium",color:"primary",role:"link",onClick:i||c,disabled:!c&&!i},i?r:n)))},Es="Error Deleting Check";function fs(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.deleteCheck(l);if(!o)throw new Error(`Failed to delete check ${l}`);return o};return ce([de.DeleteCheck],r,{onSuccess:()=>Promise.all([a.invalidateQueries({queryKey:[D.GetChecks]}),a.invalidateQueries({queryKey:[D.GetAllPrograms]})]),onError:(l,o)=>{let s=`Failed to delete check ${o}`;l instanceof Error&&(s=l.message),n({severity:"error",title:Es,message:s})}})}const ys=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),bs=({check:e})=>{var a;const n=ys();return t.createElement(rt,{dense:!0,disablePadding:!0,className:n.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Check Details"),t.createElement(ge,{disableGutters:!0,className:n.listItem},t.createElement(te,{title:"Owner"},t.createElement(J,null,t.createElement(dt,{color:"action",fontSize:"small"}))),t.createElement(ee,{className:n.listItemText,primary:t.createElement(_e,{entityRef:(a=e.ownerEntityRef)!=null?a:"No Owner"})})))},Cs=({check:e})=>{const{id:a,name:n,description:r,isEditable:l,ownerEntityRef:o}=e,s=pe(),i=ae(Ya),{loading:c,allowed:d}=Q({permission:ln,resourceRef:a}),{loading:m,allowed:u}=Q({permission:vl,resourceRef:a}),{showModal:p}=Ne(),{mutate:v}=fs(),f=U(async()=>{await p({title:"Delete Check",message:`Are you sure you want to delete the check '${n!=null?n:a}'?`})&&v(a)},[p,n,v,a]),E=U(()=>{s(i({checkId:a}))},[i,a,s]);return t.createElement(Qe,{title:n!=null?n:a,description:r,children:o&&t.createElement(bs,{check:e}),handleView:E,handleEdit:l&&!c&&d?E:void 0,handleDelete:l&&!m&&u?f:void 0})},ks=()=>t.createElement("div",{"data-testid":"checks-skeleton"},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(mt,{variant:"rect",height:385})))),xs=x(()=>({searchIcon:{opacity:".5"},clearButton:{height:"36px",width:"36px"}})),xa=({searchTerm:e,setSearchTerm:a,showClear:n=!0,placeholder:r="Search...",disabled:l,...o})=>{const s=xs(),i=vr(null);F(()=>{!l&&i.current&&i.current.focus()},[l]);const c=m=>{a(m.target.value)},d=()=>{a("")};return t.createElement(K,{...o,disabled:l,inputRef:i,fullWidth:!0,placeholder:r,value:e,onChange:c,InputProps:{startAdornment:t.createElement(Ka,{position:"start"},t.createElement(Ol,{className:s.searchIcon,"data-testid":"search-icon"})),endAdornment:n&&e?t.createElement(Ka,{position:"end"},t.createElement(Re,{edge:"end",onClick:d,className:s.clearButton},t.createElement(en,null))):null}})};var wt=(e=>(e.all="All",e.active="Active",e.archived="Archived",e))(wt||{});const ws=x(()=>({searchbar:{maxWidth:"350px"},filters:{display:"flex",alignItems:"center"},dropdownFilters:{margin:"0 15px",display:"flex",alignItems:"center"},selectHolder:{marginLeft:"10px"}})),wa=({searchPlaceholder:e,isLoading:a,searchTerm:n,setSearchTerm:r,filterAlpha:l,handleAlphabeticalFilterChange:o,filterOwner:s,handleOwnerFilterChange:i,filterStatus:c,handleStatusFilterChange:d,owners:m})=>{const u=ws();return t.createElement(h,{item:!0,xs:9,className:u.filters},t.createElement(xa,{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(Kt,{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(Kt,{className:u.selectHolder,value:s,onChange:i},t.createElement("option",{key:"all",value:"all"},"All"),m==null?void 0:m.map((p,v)=>t.createElement("option",{key:p+v,value:p},p)))),c&&d&&t.createElement("div",{className:u.dropdownFilters},t.createElement(b,null,"Filter by status: "),t.createElement(Kt,{className:u.selectHolder,value:c,onChange:d},Object.keys(wt).map(p=>t.createElement(t.Fragment,{key:p},t.createElement("option",{value:p},wt[p]))))))},Ts=(e,a)=>e==null?void 0:e.sort((n,r)=>{var l,o,s,i;const c=(o=(l=n==null?void 0:n.name)==null?void 0:l.toLocaleLowerCase())!=null?o:n==null?void 0:n.id.toLocaleLowerCase(),d=(i=(s=r==null?void 0:r.name)==null?void 0:s.toLocaleLowerCase())!=null?i:r==null?void 0:r.id.toLocaleLowerCase();return!c||!d?0:c<d?a==="ascending"?-1:1:c>d?a==="ascending"?1:-1:0}),Ta=e=>{const a=e==null?void 0:e.map(n=>n==null?void 0:n.ownerEntityRef).filter(n=>n!=="");return[...new Set(a)]},Oe=({searchTermProp:e,filterAlphaProp:a,filterOwnerProp:n,filterStatusProp:r,checks:l,tracks:o,campaigns:s})=>{var i,c,d,m;const u=((i=l!=null?l:o)!=null?i:s)||[],p=(c=u==null?void 0:u.filter)==null?void 0:c.call(u,g=>{var y;return((y=g==null?void 0:g.name)!=null?y:g==null?void 0:g.id).toLocaleLowerCase().includes(e.toLocaleLowerCase())}),v=n&&n!=="all"?(d=p==null?void 0:p.filter)==null?void 0:d.call(p,g=>{var y;return((y=g==null?void 0:g.ownerEntityRef)==null?void 0:y.toLowerCase())===n.toLowerCase()}):p,f=(r==null?void 0:r.toLowerCase())===wt.archived.toLowerCase(),E=r?(m=v==null?void 0:v.filter)==null?void 0:m.call(v,g=>f?g.archived:!g.archived):v;return a==="default"?E:Ts(E,a)},Ps=x(e=>({pagination:{width:"-webkit-fill-available",display:"flex",justifyContent:"center",position:"fixed",bottom:"0",backgroundColor:e.palette.type==="dark"?"#333333":"#F8F8F8",marginRight:"40px"}})),Pa=({response:e,listingsPerPage:a,cursor:n,setCursor:r,prevCursors:l,setPrevCursors:o,labelPerPageDropdown:s,urlRoute:i})=>{var c;const d=Ps(),m=e!=null&&e.edges?e==null?void 0:e.edges[(e==null?void 0:e.edges.length)-1]:{cursor:""},[u,p]=C(0),v=()=>{o(y=>[...y,n]),r(m==null?void 0:m.cursor)},f=()=>{r(l[l.length-1]),o(y=>y.slice(0,-1))},E=(y,w)=>{p(P=>(w>P?v():f(),w))},g=y=>{window.open(`/soundcheck/${i!=null?i:"tracks?tracksPerPage="}${y.target.value}`,"_self")};return t.createElement(jt,{className:d.pagination,component:"div",count:(c=e==null?void 0:e.totalCount)!=null?c:-1,rowsPerPage:a!=null?a:10,onPageChange:E,page:u,onRowsPerPageChange:g,labelRowsPerPage:s!=null?s:"Listings per page:",rowsPerPageOptions:[10,25,50]})},Rs=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"center"},header:{padding:e.spacing(0,0,1)},container:{padding:e.spacing(3)}})),Ss=({checksPerPage:e,currentCursor:a})=>{const n=Rs(),[r,l]=C(a),[o,s]=C([]),{data:i,isLoading:c}=ht(void 0,e,r),{loading:d,allowed:m}=Q({permission:El}),[u,p]=C(i);F(()=>{i&&p(()=>{var I;return{endCursor:i.endCursor,totalCount:i.totalCount,hasNextPage:(I=i==null?void 0:i.hasNextPage)!=null?I:!1,edges:i.edges}})},[i]);const v=u==null?void 0:u.edges.map(I=>I.checker),{setShowAddModal:f}=ve(),[E,g]=C(),[y,w]=C(""),[P,L]=C("default"),[R,T]=C("all"),[z,G]=C([]),se=I=>{const S=Oe({searchTermProp:y,filterAlphaProp:I.target.value,filterOwnerProp:R,checks:v!=null?v:[]});L(I.target.value),g(S)},ke=I=>{const S=Oe({searchTermProp:y,filterAlphaProp:P,filterOwnerProp:I.target.value,checks:v!=null?v:[]});T(I.target.value),g(S)};return F(()=>{const I=u==null?void 0:u.edges.map(W=>W.checker),S=Ta(I!=null?I:[]);g(I),G(S!=null?S:[])},[c,u]),F(()=>{const I=u==null?void 0:u.edges.map(W=>W.checker),S=Oe({searchTermProp:y,filterAlphaProp:P,filterOwnerProp:R,checks:I!=null?I:[]});g(S)},[y,P,R,u]),!E||E.length===0?t.createElement(Yt,{title:bt.title,description:bt.description,imgSrc:na,action:!d&&t.createElement(V,{disabled:!m,variant:"contained",color:"primary",onClick:()=>f(!0)},bt.callToAction)}):t.createElement(h,{container:!0,direction:"row",className:n.container},t.createElement(h,{container:!0,spacing:4,className:n.header},t.createElement(wa,{searchPlaceholder:"Search available checks",isLoading:c,searchTerm:y,setSearchTerm:w,filterAlpha:P,handleAlphabeticalFilterChange:se,filterOwner:R,handleOwnerFilterChange:ke,owners:z}),t.createElement(h,{item:!0,xs:3},t.createElement("div",{className:n.headerButtons},!d&&t.createElement(V,{disabled:!m,variant:"contained",color:"primary",onClick:()=>f(!0)},"Create Check")))),t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"checks"},c?t.createElement(ks,null):E==null?void 0:E.map(I=>t.createElement(h,{key:I.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(Cs,{check:I})))),t.createElement(Pa,{response:u,listingsPerPage:e,cursor:r,setCursor:l,prevCursors:o,setPrevCursors:s,labelPerPageDropdown:"Checks Per Page:",urlRoute:"checks?checksPerPage="}))},Ns=()=>{const[e]=Ht(),a=e.get("checksPerPage"),n=a?parseInt(a,10):10,{showAddModal:r}=ve();return t.createElement("div",null,t.createElement(Ss,{checksPerPage:n}),r&&t.createElement(ps,null))},Ls=()=>t.createElement(Ln,null,t.createElement(Ns,null)),Qn=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"}}}),Ds=({chip:e,disabled:a})=>{var n;const[r,l]=Fl(()=>({type:"chip",item:{id:e.id,label:e.label},collect:s=>({isDragging:s.isDragging()})})),o=Qn();return t.createElement(lt,{ref:l,label:e.label,className:o.chip,icon:t.createElement(pn,{"data-testid":"drag-indicator-icon"}),disabled:a,onDelete:()=>{},deleteIcon:t.createElement(te,{title:(n=e.description)!=null?n:""},t.createElement($l,{className:o.icon,"data-testid":"visibility-icon"}))})},Is=x(e=>({loadingContainer:{marginTop:e.spacing(1),display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}})),Ra=()=>{const e=Is();return t.createElement(h,{container:!0,className:e.loadingContainer},t.createElement(Ar,null))},Os=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)}})),Fs=({chips:e,disabled:a})=>t.createElement(t.Fragment,null,e.map(n=>t.createElement(Ds,{disabled:a,key:n.id,chip:n}))),As=()=>t.createElement(b,{variant:"body1",color:"textSecondary"},"There are no matches."),Yn=({isLoading:e,chips:a=[],disabled:n,label:r})=>{const l=Os(),[o,s]=C(""),i=a.filter(m=>m.label.toLowerCase().includes(o.toLowerCase())),c=a.length>0||o;let d=null;return e?d=t.createElement(Ra,null):i.length>0?d=t.createElement(Fs,{disabled:n!=null?n:!1,chips:i}):c&&(d=t.createElement(As,null)),t.createElement(h,{container:!0},t.createElement(h,{item:!0,xs:12,className:l.columnHeader},t.createElement(b,{className:l.subtitle},r!=null?r:"Checks")),t.createElement(h,{item:!0,xs:12},t.createElement(xa,{searchTerm:o,disabled:e||n,setSearchTerm:s,placeholder:"Search available checks",variant:"outlined",size:"small"})),t.createElement(h,{item:!0,className:l.chipContainer,xs:12},d))},$s=x(e=>({button:{border:"none",fontWeight:700,fontSize:e.typography.subtitle2.fontSize,lineHeight:"19px",color:e.palette.primary.main,textTransform:"none"}})),Tt=({label:e,...a})=>{const n=$s();return t.createElement(V,{className:n.button,...a,"aria-label":e},e)},Ms=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]}})),Xn=({chips:e,onDelete:a,onDrop:n,error:r=!1,placeholder:l="",disabled:o})=>{const s=Ms(),i=Qn(),[{isOver:c},d]=Al(()=>({accept:"chip",drop:m=>{n(m)},collect:m=>({isOver:m.isOver()})}));return t.createElement("div",{ref:d,className:`${s.input} ${r?s.error:""} ${c?s.hoverBackground:s.normalBackground}`,"data-testid":"droppable-input"},t.createElement("div",{className:s.chipContainer},e!=null&&e.length?e.map(m=>t.createElement(lt,{key:m.id,label:m.label,className:i.chip,icon:t.createElement(pn,null),style:{cursor:"pointer"},onDelete:()=>a(m),disabled:o})):l))},Bs=({index:e,disabled:a})=>{var n,r;const{control:l,formState:{errors:o}}=it(),{fields:s,remove:i,append:c}=ct({control:l,name:`levels.${e}.levelChips`,rules:{required:!0}}),d=U(u=>{c(u)},[c]),m=U(u=>{const p=nn(s,v=>v.id===u.id);i(p)},[i,s]);return t.createElement(Xn,{chips:s,onDelete:m,onDrop:d,error:!!((r=(n=o==null?void 0:o.levels)==null?void 0:n[e])!=null&&r.levelChips),placeholder:"Drag and drop checks here to include them in this level",disabled:a})},Gs=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},inputNameBase:{fontSize:e.typography.subtitle1.fontSize,fontWeight:700},inputDescriptionBase:{fontSize:e.typography.fontSize,fontWeight:"normal"}})),Vs=({disabled:e})=>{const a=Gs(),{control:n,formState:{errors:r},getValues:l}=it(),{fields:o,remove:s,append:i}=ct({control:n,name:"levels"});return t.createElement(h,{container:!0},t.createElement(h,{item:!0,xs:12,className:a.columnHeader},t.createElement(b,{className:a.subtitle},"Levels"),!e&&t.createElement(Tt,{label:"Add Level",startIcon:t.createElement(hn,null),onClick:()=>i({levelName:`Level ${o.length+1}`,levelDescription:"",levelChips:[]}),disabled:e})),t.createElement(h,{container:!0,item:!0,spacing:5},o.map((c,d)=>{var m,u;return t.createElement(h,{container:!0,item:!0,xs:12,spacing:2,key:c.id},t.createElement(h,{item:!0,xs:12,className:a.levelHeader},t.createElement(h,{container:!0,spacing:1},t.createElement(h,{item:!0,xs:!0},t.createElement(De,{name:`levels.${d}.levelName`,placeholder:"Untitled level",control:n,disabled:e,label:"Level Name",variant:"outlined",size:"small",inputProps:{classes:{input:a.inputNameBase}},margin:"none",rules:{required:!0},error:(u=(m=r==null?void 0:r.levels)==null?void 0:m[d])==null?void 0:u.levelName})),!e&&o.length>1&&t.createElement(h,{item:!0,className:a.removeButton},t.createElement(Tt,{label:"Remove Level",startIcon:t.createElement(gn,null),onClick:()=>s(d),disabled:e})))),t.createElement(h,{item:!0,xs:12},t.createElement(Bs,{index:d,disabled:e})),t.createElement(h,{item:!0,xs:12},t.createElement(De,{name:`levels.${d}.levelDescription`,placeholder:"Enter description here",control:n,disabled:e,label:`${l(`levels.${d}.levelName`)} description`,variant:"outlined",size:"small",inputProps:{classes:{input:a.inputDescriptionBase},"aria-label":`${l(`levels.${d}.levelName`)} description`},margin:"none"})))})))},qs=({disabled:e})=>{const a=ba(),{control:n,formState:{errors:r}}=it();return t.createElement(h,{className:a.selectMargin,item:!0,xs:12},t.createElement(De,{name:"trackName",placeholder:"Enter a name for the track",control:n,disabled:e,label:"Name",error:r.trackName,messages:{required:"Track name is required",maxLength:"Track name must be at least 1 character and less than 100 characters"},rules:{required:!0,maxLength:100}}))},Hs=({disabled:e,selectedTrack:a})=>{const{options:n,isLoading:r}=Qt(),{user:l,userEntityRef:o}=ot(),{control:s}=it();let i=n==null?void 0:n.map(d=>({value:d.ref,label:d.name}));o&&(i=[{value:o,label:l==null?void 0:l.metadata.name},...i]);const c=a==null?void 0:a.ownerEntityRef;return c&&o!==c&&!i.some(d=>d.value===c)&&(i=[{value:a.ownerEntityRef,label:q(a.ownerEntityRef).name},...i]),t.createElement(yt,{name:"ownerEntityRef",selectLabel:"Owner",control:s,disabled:e,options:r?void 0:Jt(i,"value"),rules:{required:!0}})};function Zn(){const{data:e,isLoading:a}=ht(),n=H(()=>e==null?void 0:e.edges.map(o=>o.checker),[e==null?void 0:e.edges]),r=H(()=>{var o;return(o=n==null?void 0:n.filter(s=>!!s).map(s=>{var i,c,d;return{id:(i=s.id)!=null?i:"",label:(c=s.name)!=null?c:s.id,description:(d=s.description)!=null?d:""}}))!=null?o:[]},[n]),l=H(()=>n==null?void 0:n.reduce((o,s)=>{var i,c,d,m;return o[s.id]={id:s.id,name:(i=s.name)!=null?i:s.id,description:(c=s.description)!=null?c:"",filter:(d=s.filter)!=null?d:void 0,schedule:(m=s.schedule)!=null?m:void 0},o},{}),[n]);return{checkChips:r,checkersMap:l,checkersLoading:a}}const _s={trackName:"",trackDescription:"",ownerEntityRef:"",levels:[{levelName:"Level 1",levelDescription:"",levelChips:[]}]},zs=({name:e,description:a,ownerEntityRef:n,filter:r,levels:l})=>({trackName:e,trackDescription:a!=null?a:"",ownerEntityRef:n,filters:$n(r),levels:(l==null?void 0:l.map(o=>{var s,i,c;return{levelName:(i=(s=o.name)!=null?s:`Level ${o.ordinal}`)!=null?i:"Level 1",levelDescription:(c=o.description)!=null?c:"",levelChips:o.checks.map(d=>{var m;return{id:d.id,label:(m=d.name)!=null?m:d.id}})}}))||[]}),Ws=(e,a,n)=>{var r,l,o;return{id:(r=a==null?void 0:a.id)!=null?r:sn(),ownerEntityRef:e.ownerEntityRef,description:e.trackDescription,name:e.trackName,documentationURL:(l=a==null?void 0:a.documentationURL)!=null?l:"",levels:(o=e.levels)==null?void 0:o.map((s,i)=>{var c,d;return{ordinal:i+1,name:(c=s.levelName)!=null?c:"",description:(d=s.levelDescription)!=null?d:"",checks:s.levelChips.map(m=>n[m.id])}}),filter:An(e.filters)}},Us=e=>{const{selectedItem:a}=Le(),n=H(()=>a?zs(a):_s,[a]),r=st({defaultValues:n}),{userEntityRef:l}=ot();F(()=>{!a&&l&&!r.getValues("ownerEntityRef")&&r.setValue("ownerEntityRef",l)},[a,l,r]);const{checkChips:o,checkersLoading:s,checkersMap:i}=Zn(),c=new Set(r.getValues("levels").flatMap(u=>u.levelChips.map(p=>p.id))),d=o.filter(u=>!c.has(u.id)),{showModal:m}=Ne();return{formMethods:r,onSubmit:async u=>{if(!await m({title:"Save Check",message:`Are you sure you want to save track: ${u.trackName}?`,error:!1}))return;const p=Ws(u,a,i!=null?i:{});e(p)},selectableChips:d,checkersLoading:s}},Ks=x(e=>({regularFontSize:{fontSize:e.typography.fontSize,fontWeight:"bold"},description:{fontWeight:"normal",fontSize:e.typography.fontSize},ownerDescription:{margin:e.spacing(-2,0,2,0)},root:{overflow:"hidden",display:"flex",padding:e.spacing(1),marginBottom:"53px"}})),Jn=({onSave:e,title:a,open:n,handleClose:r})=>{const{selectedItem:l,isLoading:o,setSelectedItem:s,isReadOnly:i}=Le(),{formMethods:c,onSubmit:d,selectableChips:m,checkersLoading:u}=Us(e),{control:p,handleSubmit:v}=c,f=Ks(),E=ba(),g=i||!!l&&!l.isEditable;return t.createElement(un,{backend:vn},t.createElement(Ke,{handleClose:r,title:a,open:n},t.createElement(ml,{...c},t.createElement("form",{onSubmit:v(d)},t.createElement(h,{container:!0,spacing:4,className:f.root},t.createElement(h,{item:!0,xs:12},t.createElement(h,{item:!0,xs:12},t.createElement(b,{className:E.sectionLabel,style:{margin:0}},"Track Details"),t.createElement(qs,{disabled:o||g})),t.createElement(h,{item:!0,xs:12},t.createElement(h,{item:!0,xs:12},t.createElement(ft,{name:"trackDescription",control:p,label:"Description",placeholder:"Enter a brief description about the track",disabled:o||g})))),t.createElement(h,{item:!0,xs:12},t.createElement(h,{item:!0,xs:12},t.createElement(b,{className:E.sectionLabel},"Track Owner"),!g&&t.createElement(b,{className:`${f.ownerDescription} ${f.description}`},"Select an owner for the track. Defaults to the current user.")),t.createElement(h,{item:!0,xs:12},t.createElement(Hs,{disabled:o||g,selectedTrack:l!=null?l:void 0}))),t.createElement(h,{item:!0,xs:12},t.createElement(Kn,{control:p,disabled:o||g})),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:E.sectionLabel,style:{margin:0}},"Track Levels"),!g&&t.createElement(b,{className:f.description},"Add the checks that apply to each level. You can preview the checks to see the rules that apply to each check.")),!g&&t.createElement(h,{item:!0,xs:5},t.createElement(Yn,{chips:m,isLoading:u||o,disabled:g})),t.createElement(h,{item:!0,xs:7},t.createElement(Vs,{disabled:g}))))),t.createElement(h,{container:!0,spacing:4,className:f.root},t.createElement(gt,{onCancel:()=>{s(null),r()},saveButtonText:"Save Track",isLoading:o||u,onSave:g?void 0:v(d),disableSave:g}))))))},js=()=>{const{setIsLoading:e,setShowAddModal:a,showAddModal:n}=Le(),{mutateAsync:r,isLoading:l}=oo();return F(()=>{e(l)},[e,l]),t.createElement(Jn,{handleClose:()=>a(!1),title:"Create Track",open:n,onSave:async o=>{await r(o,{onSuccess:()=>a(!1)})}})},Qs=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Ys=({track:e})=>{var a,n,r;const l=Qs(),o=(n=(a=e.levels)==null?void 0:a.length)!=null?n:0,s=(r=e.levels)==null?void 0:r.reduce((i,c)=>i+c.checks.length,0);return t.createElement(rt,{dense:!0,disablePadding:!0,className:l.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Track Details"),t.createElement(ge,{disableGutters:!0,className:l.listItem},t.createElement(te,{title:"Levels"},t.createElement(J,null,t.createElement(Gl,{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(ge,{disableGutters:!0,className:l.listItem},t.createElement(te,{title:"Checks"},t.createElement(J,null,t.createElement(Bl,{color:"action",fontSize:"small"}))),t.createElement(ee,{className:l.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},`${s} ${s===1?"Check":"Checks"}`)})),e.documentationURL&&t.createElement(ge,{disableGutters:!0,className:l.listItem},t.createElement(te,{title:"Documentation"},t.createElement(J,null,t.createElement(Ml,{color:"action",fontSize:"small"}))),t.createElement(ee,{className:l.listItemText,primary:t.createElement(fr,{to:e.documentationURL,target:"_blank",rel:"noopener noreferrer"},"Learn more")})),t.createElement(ge,{disableGutters:!0,className:l.listItem},t.createElement(te,{title:"Owner"},t.createElement(J,null,t.createElement(dt,{color:"action",fontSize:"small"}))),t.createElement(ee,{className:l.listItemText,primary:t.createElement(_e,{entityRef:e.ownerEntityRef})})))},Xs="Error Deleting Track";function Zs(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.deleteProgram(l);if(!o)throw new Error(`Failed to delete track ${l}`);return o};return ce([de.DeleteProgram],r,{onSuccess:()=>{const l=[D.GetAllPrograms,D.GetOverallTrackPassRate,D.GetIndividualTrackPassRate];for(const o of l)a.invalidateQueries({queryKey:[o]})},onError:(l,o)=>{let s=`Failed to delete track ${o}`;l instanceof Error&&(s=l.message),n({severity:"error",title:Xs,message:s})}})}const Js=({summary:e})=>{const{loading:a,allowed:n}=Q({permission:on,resourceRef:e.id}),{loading:r,allowed:l}=Q({permission:fl,resourceRef:e.id}),{showModal:o}=Ne(),{mutate:s}=Zs(),i=pe(),c=ae(Xa),d=U(async()=>{await o({title:"Delete Track",message:`Are you sure you want to delete track ${e.name}?`})&&s(e.id)},[o,e.id,e.name,s]),m=U(()=>{i(c({trackId:e.id}))},[i,e.id,c]);return t.createElement(Qe,{title:e.name,description:e.description,children:t.createElement(Ys,{track:e}),handleView:m,handleEdit:e.isEditable&&!a&&n?m:void 0,handleDelete:e.isEditable&&!r&&l?d:void 0})},ei=()=>t.createElement("div",{"data-testid":"tracks-skeleton"},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(mt,{variant:"rect",height:385}))));var Pt=(e=>(e.title="Create a track",e.description="A track is composed of levels and checks, and encourages alignment to architectural best practices and standards.",e.callToAction="Get started",e))(Pt||{});const ti=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end"},header:{padding:e.spacing(0,0,1)},container:{padding:e.spacing(3)}})),ai=({tracksPerPage:e,currentCursor:a})=>{var n;const r=ti(),[l,o]=C(a),[s,i]=C([]),{data:c,isLoading:d}=sa(void 0,e,l),{loading:m,allowed:u}=Q({permission:yl}),[p,v]=C(c);F(()=>{c&&v(()=>{var S;return{endCursor:c.endCursor,totalCount:c.totalCount,hasNextPage:(S=c==null?void 0:c.hasNextPage)!=null?S:!1,edges:c.edges}})},[c]);const f=(n=p==null?void 0:p.edges)==null?void 0:n.map(S=>S==null?void 0:S.program),{setShowAddModal:E}=Le(),[g,y]=C(),[w,P]=C(""),[L,R]=C("default"),[T,z]=C("all"),[G,se]=C([]),ke=S=>{const W=Oe({searchTermProp:w,filterAlphaProp:S.target.value,filterOwnerProp:T,tracks:f!=null?f:[]});R(S.target.value),y(W)},I=S=>{const W=Oe({searchTermProp:w,filterAlphaProp:L,filterOwnerProp:S.target.value,tracks:f!=null?f:[]});z(S.target.value),y(W)};return F(()=>{const S=p==null?void 0:p.edges.map($=>$.program),W=Ta(S!=null?S:[]);y(S),se(W!=null?W:[])},[d,p]),F(()=>{const S=p==null?void 0:p.edges.map($=>$.program),W=Oe({searchTermProp:w,filterAlphaProp:L,filterOwnerProp:T,tracks:S!=null?S:[]});y(W)},[w,L,T,p]),!g||g.length===0?t.createElement(Yt,{title:Pt.title,description:Pt.description,imgSrc:na,action:!m&&t.createElement(V,{disabled:!u,variant:"contained",color:"primary",onClick:()=>E(!0)},Pt.callToAction)}):t.createElement(h,{container:!0,direction:"row",className:r.container},t.createElement(h,{container:!0,spacing:4,className:r.header},t.createElement(wa,{searchPlaceholder:"Search available tracks",isLoading:d,searchTerm:w,setSearchTerm:P,filterAlpha:L,handleAlphabeticalFilterChange:ke,filterOwner:T,handleOwnerFilterChange:I,owners:G}),t.createElement(h,{item:!0,xs:3},t.createElement("div",{className:r.headerButtons},!m&&t.createElement(V,{disabled:!u,variant:"contained",color:"primary",onClick:()=>E(!0)},"Create Track")))),t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"tracks"},d?t.createElement(ei,null):g.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(Js,{summary:S})))),t.createElement(Pa,{response:p,listingsPerPage:e,cursor:l,setCursor:o,prevCursors:s,setPrevCursors:i,labelPerPageDropdown:"Track Per Page:",urlRoute:"tracks?tracksPerPage="}))},ni=()=>{const{showAddModal:e}=Le(),[a]=Ht(),n=a.get("tracksPerPage"),r=n?parseInt(n,10):10;return t.createElement("div",null,t.createElement(yr,{variant:"info",message:"Programs will now be referred to as Tracks throughout the Soundcheck UI.",id:"programTrackBanner"}),t.createElement(ai,{tracksPerPage:r}),e&&t.createElement(js,null))},ri=()=>t.createElement(Sn,null,t.createElement(ni,null)),li=e=>e?e.palette.type:"",er=e=>li(e).toLowerCase()==="dark",ue=e=>er(e)?e.palette.grey[200]:e.palette.grey[800],Rt=e=>er(e)?kr:xr;function Sa(e,a){return(a?e.minus({days:a}):e).toFormat("MMM dd")}function fe(e){const a=pt.utc();return e.map((n,r)=>({name:Sa(a,e.length-r-1),passRate:n}))}var oi=(e=>(e.Bar="bar",e.Line="line",e))(oi||{});const si=-25,we=[0,100],tr=85,Na=25,St="name",ii=250,Nt=.5,ar="circle",nr=8,rr="monotone",Lt=({children:e})=>t.createElement(En,{minHeight:ii,debounce:1},e),ci=_(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}})),mi=()=>{const e=[{x:"A",y:25},{x:"B",y:50},{x:"C",y:75}],a=ci();return t.createElement("div",{className:a.container},t.createElement(Lt,null,t.createElement(ra,{data:e},t.createElement(ut,{strokeDasharray:"3 3",vertical:!1,opacity:Nt}),t.createElement(We,{dataKey:"x",stroke:"#ccc",hide:!0}),t.createElement(Ue,{domain:we,stroke:"#ccc",hide:!0}),t.createElement(la,{type:"monotone",dataKey:"y",stroke:"#ccc",dot:!1}))),t.createElement(b,{className:a.chartMessage},"No Data"))},di=x(e=>({legend:{color:ue(e)}})),Dt=({data:e,lines:a})=>{const n=Se(),r=Rt(n),l=ue(n),o=di();return e.length?t.createElement(Lt,null,t.createElement(ra,{data:e},t.createElement(ut,{vertical:!1,opacity:Nt}),t.createElement(We,{dataKey:St,stroke:l}),t.createElement(Ue,{width:Na,domain:we,stroke:l}),t.createElement(fn,{position:{y:si},contentStyle:{backgroundColor:n.palette.background.paper}}),a.length>1&&t.createElement(yn,{iconType:ar,iconSize:nr,formatter:s=>t.createElement("span",{className:o.legend},s)}),a.map((s,i)=>t.createElement(la,{key:s.dataKey,dataKey:s.dataKey,stroke:r[i%r.length],strokeWidth:2,dot:!1,name:s.name,type:rr})))):t.createElement(mi,null)},ui=({data:e,lines:a})=>{const n=Se(),r=Rt(n);return t.createElement(En,{height:50,width:100},t.createElement(ra,{data:e},t.createElement(We,{hide:!0,dataKey:St}),t.createElement(Ue,{width:0,domain:we}),a.map((l,o)=>t.createElement(la,{key:l.dataKey,dataKey:l.dataKey,stroke:r[o%r.length],strokeWidth:2,dot:!1,name:l.name,type:rr}))))},Ye=({chartData:e,tableChart:a})=>{const n=[{dataKey:"passRate",name:"Pass rate"}];return a?t.createElement(ui,{data:e,lines:n}):t.createElement(Dt,{data:e,lines:n})};var N=(e=>(e.Entity="Entity",e.Kind="Entity Kind",e.Type="Entity Type",e.EntityOwner="Entity Owner",e.Lifecycle="Entity Lifecycle",e.Track="Track",e.Level="Track Level",e.Check="Check",e.CheckOwner="Check Owner",e))(N||{});function pi(e){var a;const n=O(A),[r,l]=C(null),o=async()=>(await n.getEntityRefsForTechHealthFilter(e)).entityRefsForTechHealthFilter,s=j([D.GetSoftwareEntityRefsForUser,e],o,{retry:!1,onError:l,enabled:e!==null,staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1});return{data:(a=s.data)!=null?a:[],isLoading:s.isLoading,error:r}}const hi=(e,a)=>{var n,r,l,o;const s=[];for(const c of e)s.push({label:(n=c.name)!=null?n:c.id,value:c.id});const i=e.map(c=>c.id);for(const c of a)for(const d of(r=c.levels)!=null?r:[])for(const m of(l=d.checks)!=null?l:[])i.includes(m.id)||(i.push(m.id),s.push({label:(o=m.name)!=null?o:m.id,value:m.id}));return s},gi=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}`}))},vi=(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}})},Ei=()=>{const[e,a]=C(!1),{userEntityRef:n}=ot(),{data:r,isLoading:l}=pi(n),{data:o,isLoading:s}=Wr(),i=H(()=>ze.mapValues(ze.keyBy(o!=null?o:[],"ref"),R=>R.name),[o]),{data:c,isLoading:d}=sa(void 0,100),m=H(()=>{var R;return(R=c==null?void 0:c.edges.map(T=>T.program))!=null?R:[]},[c]),{data:u,isLoading:p}=ht(void 0,100),v=H(()=>{var R;return(R=u==null?void 0:u.edges.map(T=>T.checker))!=null?R:[]},[u]),{data:f,isLoading:E}=xt("kind"),{data:g,isLoading:y}=xt("spec.lifecycle"),{data:w,isLoading:P}=xt("spec.type"),L=H(()=>{var R;return{[N.Kind]:(f!=null?f:[]).map(T=>({label:T,value:T})),[N.Lifecycle]:(g!=null?g:[]).map(T=>({label:T,value:T})),[N.Type]:(w!=null?w:[]).map(T=>({label:T,value:T})),[N.Entity]:r.map(T=>({label:q(T).name,value:T})),[N.EntityOwner]:(R=o==null?void 0:o.map(T=>({label:T.name,value:T.ref})))!=null?R:[],[N.Track]:m.map(T=>({label:T.name,value:T.id})),[N.Level]:gi(m),[N.Check]:hi(v,m),[N.CheckOwner]:vi(v,i)}},[f,g,w,r,o,i,m,v]);return F(()=>{a(E||y||P||l||s||d||p)},[E,y,P,l,s,d,p]),{facetOptions:L,isLoading:e}},Fe=30,Te=2,Ae=90,$e=()=>Object.fromEntries(Object.values(N).map(e=>[e,[]])),fi=(e,a,n)=>{if(a.length)return a.map(r=>({trackId:r,levels:n.length?n.map(l=>parseInt(l,10)):void 0}));if(n.length)return e.map(r=>({trackId:r.value,levels:n.map(l=>parseInt(l,10))}))},yi=(e,a,n,r)=>({checkIds:a[N.Check].length?{included:a[N.Check]}:void 0,checkOwners:a[N.CheckOwner].length?{included:a[N.CheckOwner]}:void 0,entityOwners:a[N.EntityOwner].length?{included:a[N.EntityOwner]}:void 0,entityRefs:a[N.Entity].length?{included:a[N.Entity]}:void 0,tracks:fi(e[N.Track],a[N.Track],a[N.Level]),numberOfDays:n!=null?n:Fe,context:r?{loggedInUser:r}:void 0,entityTypes:a[N.Type].length?{included:a[N.Type]}:void 0,entityKinds:a[N.Kind].length?{included:a[N.Kind]}:void 0,entityLifecycles:a[N.Lifecycle].length?{included:a[N.Lifecycle]}:void 0});function bi({angle:e,arc:a,direction:n,dist:r,emoji:l,delay:o,fontSize:s,speed:i}){return t.createElement(oa.div,{style:{position:"absolute",fontSize:s},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:i,ease:[.2,.83,.46,.63],repeat:1/0}},l)}const Ci=["\u{1F4C8}","\u{1F4CA}","\u{1F4C9}","\u{1F680}","\u2B50\uFE0F"],ki=x(()=>({container:{position:"relative"}}));function xi({angle:e=125,density:a=20,emojis:n=Ci,fontSizeMin:r=6,fontSizeMax:l=24,size:o=300,speed:s=4}){const i=ki(),c=H(()=>Array.from({length:a*n.length}).map((d,m)=>({emoji:n[Math.floor(Math.random()*n.length)],arc:Math.random()*o*.5,delay:Math.random()*s,dist:Math.random()*o,direction:m%2?1:-1,fontSize:Math.random()*(l-r)+r,angle:e,speed:s})),[a,n,s,o,e,l,r]);return t.createElement("div",{className:i.container},t.createElement(b,{variant:"h1"},"\u{1F469}\u200D\u{1F4BB}"),c.map((d,m)=>t.createElement(bi,{key:`${d.emoji}-${m}`,...d})))}const wi=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 Me({title:e,subtitle:a}){const n=wi();return t.createElement("div",{className:n.container},t.createElement("div",{className:n.textContainer},t.createElement(xi,null),t.createElement(oa.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 Ti=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}})),Pi=()=>{const e=Ti();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(Me,null)))},lr=Je({facetOptionsLoading:!1,getFacetOptions:()=>[],getFacetOptionLabel:()=>"",facetFilters:$e(),clearAllFilters:()=>{},getSelectedFacetValues:()=>[],setSelectedFacetValues:()=>{},numberOfDays:Fe,setNumberOfDays:()=>{},filter:{},loggedInUser:"Unknown"}),ye=()=>et(lr),Ri=e=>{const{userEntityRef:a}=ot(),{isLoading:n,facetOptions:r}=Ei(),[l,o]=kn("soundcheck.techHealth.facetFilters",$e());l&&Object.values(N).forEach(E=>{l[E]||(l[E]=[])});const[s,i]=kn("soundcheck.techHealth.numberOfDays",Fe),c=H(()=>yi(r,l!=null?l:$e(),s,a),[l,r,s,a]),d=()=>{i(Fe),o($e())},m=E=>r[E].map(g=>g.value),u=(E,g)=>{var y;let w=(y=r[E].find(P=>P.value===g))==null?void 0:y.label;if(!w)try{const P=q(g);w=cl(P)}catch{}return w!=null?w:g},p=E=>l?l[E]:[],v=(E,g)=>{const y={...l!=null?l:$e()};y[E]=g,o(y)},f={facetOptionsLoading:n,getFacetOptions:m,getFacetOptionLabel:u,facetFilters:l!=null?l:$e(),clearAllFilters:d,getSelectedFacetValues:p,setSelectedFacetValues:v,numberOfDays:s!=null?s:Fe,setNumberOfDays:i,filter:c!=null?c:{},loggedInUser:"Unknown"};return n?t.createElement(Pi,null):t.createElement(lr.Provider,{...e,value:f})},Si={hidden:{height:0,opacity:0,overflow:"hidden"},visible:{height:"auto",opacity:1,overflow:"visible"}};function Ni({visible:e,...a}){return t.createElement(oa.div,{...a,animate:e?"visible":"hidden",initial:"hidden",variants:Si})}const Li=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%"}}})),Di=({facet:e})=>{var a;const n=Li(),{getFacetOptions:r,getFacetOptionLabel:l,getSelectedFacetValues:o,setSelectedFacetValues:s}=ye(),[i,c]=C(!!((a=o(e))!=null&&a.length)),[d,m]=C(!1),[u,p]=C(""),v=()=>{c(g=>!g)},f=g=>{(g.key==="Enter"||g.key===" ")&&v()},E=g=>{if(e===N.Entity&&g[g.length-1]){const y=g[g.length-1];if(!y.includes(":")||!y.includes("/")){m(!0),p("Custom entities require a valid kind and namespace such as: component:default/entity");return}}m(!1),p(""),s(e,g)};return t.createElement(k,null,t.createElement("div",{className:n.header,onClick:v,onKeyDown:f,role:"button",tabIndex:0},t.createElement(k,{className:n.headerTitle},t.createElement(b,{variant:"subtitle2"},e)),t.createElement(k,null,t.createElement(Re,{size:"small",onKeyDown:f},i?t.createElement(tn,{fontSize:"small"}):t.createElement(Zt,{fontSize:"small"})))),t.createElement(Ni,{visible:i},t.createElement(aa,{disableCloseOnSelect:!0,className:n.autoComplete,fullWidth:!0,multiple:!0,freeSolo:e===N.Entity,popupIcon:null,ChipProps:{color:"primary",className:n.chip,size:"small"},options:r(e),getOptionLabel:g=>l(e,g),value:o(e),onChange:(g,y)=>E(y),renderInput:g=>t.createElement(K,{...g,className:n.autoCompleteInput,margin:"normal",placeholder:`Search for ${e}`,error:d,helperText:u}),renderOption:(g,{selected:y})=>t.createElement(at,{onClick:w=>w.preventDefault(),control:t.createElement(He,{icon:t.createElement(dn,{fontSize:"small"}),checkedIcon:t.createElement(mn,{fontSize:"small"}),checked:y}),label:l(e,g)})})))},Ii=x(({palette:e,spacing:a})=>({root:{padding:({size:n})=>n==="small"?a(1,2):a(2),borderBottom:`1px solid ${e.border}`}}));function La(e){const a=Ii(e);return t.createElement(k,{...e,className:a.root})}const Oi=x(e=>({root:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing(.25)}}));function Fi(){const e=Oi(),{numberOfDays:a,facetFilters:n,clearAllFilters:r}=ye(),l=Object.keys(N).some(o=>n[N[o]].length)||a!==Fe;return t.createElement(k,{className:e.root},t.createElement(k,null,t.createElement(b,{variant:"h6"},"Filters")),l&&t.createElement(k,null,t.createElement(V,{onClick:r,size:"small"},"Clear all")))}const Ai=x(({palette:e,spacing:a})=>({select:{width:"100%",margin:a(1,0)},chip:{backgroundColor:e.info.dark}})),It=[7,30,90].map(e=>({value:e,label:`Last ${e} days`}));function $i(){const e=Ai(),{numberOfDays:a,setNumberOfDays:n}=ye(),r=[...It];It.map(u=>u.value).includes(a)||r.push({value:a,label:`Last ${a} days`});const[l,o]=C(r),[s,i]=C(""),c=()=>{if(s.length){const u=parseInt(s,10);return!isNaN(u)&&(u<Te||u>Ae)}return!1},d=()=>{const u=parseInt(s,10);if(u<Te)return`Minimum of ${Te} days`;if(u>Ae)return`Maximum of ${Ae} days`},m=u=>{if(u.key==="Enter"){const p=parseInt(s,10);p>=Te&&p<=Ae?(It.map(v=>v.value).includes(p)||o([...It,{value:p,label:`Last ${p} days`}]),n(p),i("")):p<Te?i(`${Te}`):i(`${Ae}`)}};return t.createElement(k,null,t.createElement(k,{marginBottom:2},t.createElement(k,null,l.sort((u,p)=>u.value-p.value).map(({label:u,value:p})=>t.createElement(lt,{key:p,label:u,className:a===p?e.chip:void 0,color:a===p?"primary":void 0,size:"small",onClick:()=>n(p)})))),t.createElement(k,null,t.createElement(K,{fullWidth:!0,placeholder:"Number of days",inputProps:{min:Te,max:Ae},onKeyDown:m,helperText:d(),value:s,type:"number",error:c(),onChange:u=>i(u.target.value)})))}const Mi=x(e=>({filters:{maxWidth:"300px",width:"100%",backgroundColor:e.palette.background.paper}})),Bi=()=>{const e=Mi();return t.createElement(k,{className:e.filters},t.createElement(La,null,t.createElement(Fi,null)),t.createElement(La,null,t.createElement($i,null)),Object.values(N).map(a=>t.createElement(La,{key:a,size:"small"},t.createElement(Di,{facet:a}))))},or=Je({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}}),be=()=>et(or),Gi=e=>{const{filter:a}=ye(),n=so(a),r=co(a),l=uo(a),o=ho(a),s=H(()=>({checkPassRateOverview:n,trackPassRateOverview:r,entityPassRatesOverview:l,groupPassRatesOverview:o}),[n,r,l,o]);return n.isLoading||r.isLoading||l.isLoading||o.isLoading?t.createElement(Me,null):t.createElement(or.Provider,{...e,value:s})},sr=e=>{const a=(e==null?void 0:e.overallTrackPassRate)||[];if(!a.length)return[];const n=pt.utc();return a.reduce((r,{trendPassRates:l,levelOrdinal:o},s)=>{var i;const c=(i=l==null?void 0:l.map((d,m)=>({name:Sa(n,l.length-m-1),[`Level${o}`]:d})))!=null?i:[];return s===0?c:r.map((d,m)=>({...d,...c[m]}))},[])},Vi=()=>{var e,a;const{trackPassRateOverview:{data:n,isError:r}}=be();if(r)return t.createElement(b,{color:"error"},"Failed to load track data.");const l=sr(n),o=(a=(e=n==null?void 0:n.overallTrackPassRate)==null?void 0:e.map(({levelOrdinal:s})=>({dataKey:`Level${s}`,name:`Level ${s}`})))!=null?a:[];return t.createElement(Dt,{data:l,lines:o})},qi=e=>{const a=(e==null?void 0:e.overallEntityPassRates)||[];if(!a.length)return[];const n=pt.utc();return a.reduce((r,{trendPassRates:l,id:o},s)=>{var i;const c=(i=l==null?void 0:l.map((d,m)=>({name:Sa(n,l.length-m-1),[o]:d})))!=null?i:[];return s===0?c:r.map((d,m)=>({...d,...c[m]}))},[])},Hi=()=>{var e,a;const{entityPassRatesOverview:{data:n}}=be(),r=(a=(e=n==null?void 0:n.overallEntityPassRates)==null?void 0:e.map(({id:o})=>({dataKey:o,name:q(o).name})))!=null?a:[],l=qi(n);return t.createElement(Dt,{data:l,lines:r})},_i=_(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}})),zi=({layout:e,theme:a})=>{const n=e===Ot.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=_i();return t.createElement("div",{className:o.container},t.createElement(Lt,null,t.createElement(bn,{data:n?l:r,margin:{left:0},layout:e},t.createElement(ut,{strokeDasharray:"3 3",vertical:n,horizontal:!n,opacity:Nt}),t.createElement(We,{dataKey:n?void 0:"x",type:n?Xe.Number:Xe.Category,domain:n?we:void 0,hide:!0}),t.createElement(Ue,{width:n?tr:Na,dataKey:n?"x":void 0,type:n?Xe.Category:Xe.Number,domain:n?void 0:we,hide:!0}),t.createElement(Cn,{dataKey:"y",fill:a.palette.divider,barSize:n?ir:cr}))),t.createElement(b,{className:o.chartMessage},"No Data"))},Wi=x(e=>({legend:{color:ue(e)}}));var Ot=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(Ot||{});const ir=20,cr=50;var Xe=(e=>(e.Category="category",e.Number="number",e))(Xe||{});const mr={dataKey:"passRate",name:"Pass rate"},dr=Er(({data:e,layout:a})=>{const n=a==="vertical",r=Se(),l=Rt(r),o=ue(r),s=Wi();return e.length?t.createElement(Lt,{"aria-label":"Bar chart representing data points."},t.createElement(bn,{data:e,layout:a},t.createElement(ut,{vertical:n,horizontal:!n,opacity:Nt}),t.createElement(We,{dataKey:n?void 0:St,type:n?"number":"category",domain:n?we:void 0,stroke:o}),t.createElement(Ue,{width:n?tr:Na,dataKey:n?St:void 0,type:n?"category":"number",domain:n?void 0:we,stroke:o}),t.createElement(fn,{contentStyle:{backgroundColor:r.palette.background.default},itemStyle:{color:ue(r)},cursor:{fill:"transparent"}}),t.createElement(yn,{iconType:ar,iconSize:nr,formatter:i=>t.createElement("span",{className:s.legend},i),payload:e.map(({name:i},c)=>({id:i,value:i,color:l[c%l.length]}))}),t.createElement(Cn,{barSize:n?ir:cr,dataKey:mr.dataKey,name:mr.name},e.map(({name:i},c)=>t.createElement(Vl,{key:i,fill:l[c%l.length]}))))):t.createElement(zi,{layout:a,theme:r})}),Ui=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:[]},Ki=()=>{const{trackPassRateOverview:{data:e,isError:a}}=be();if(a)return t.createElement(b,{color:"error"},"Failed to load track data.");const n=Ui(e);return t.createElement(dr,{data:n,layout:Ot.Horizontal})},ji=e=>{var a;return(a=e==null?void 0:e.map(({id:n,groupTitle:r,snapshotPassRate:l})=>({name:r!=null?r:q(n).name,passRate:l})))!=null?a:[]},Qi=()=>{var e;const{groupPassRatesOverview:{data:a}}=be(),n=(e=a==null?void 0:a.groupPassRates)==null?void 0:e.sort((l,o)=>o.snapshotPassRate-l.snapshotPassRate),r=ji(n);return t.createElement(dr,{data:r,layout:Ot.Vertical})},Yi=_(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)},headerExportSection:{display:"flex",alignItems:"center",marginLeft:"auto",marginRight:0},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"}})),Ft=({title:e,subtitle:a,summaryCardContent:n,chartSectionContent:r,disableDataExport:l,csvData:o,csvFilename:s})=>{const i=Yi();return t.createElement(nt,{className:i.card},t.createElement(k,{className:i.headerRow},t.createElement(k,{className:i.headerSection},t.createElement(b,{className:i.title},e),t.createElement(b,{variant:"caption"},a)),t.createElement(k,{className:i.headerExportSection},t.createElement(xn,{data:o,filename:s,onClick:()=>!l},t.createElement(te,{title:"Export to CSV"},t.createElement("span",null,t.createElement(V,{disabled:l},t.createElement(ql,null))))))),t.createElement(k,{className:i.contentRow},n&&t.createElement(k,{className:i.leftSection},t.createElement(k,{className:i.summaryCard},n)),t.createElement(k,{className:i.chartSection},r)))};function Ce(e,a){const n=e;if(a){const r=pt.utc();for(let l=a-1;l>=0;l--)n.push(r.minus({day:l}).toISODate())}return n}function Be(e){if(!e)return 0;const a=e.map(n=>{var r,l;return(l=(r=n.trendPassRates)==null?void 0:r.length)!=null?l:1});return Math.max(1,...a)}function Xi(e){const a=[];return a.push(Ce(["check_id","check_name","check_owner_ref"],Be(e))),e!=null&&e.length&&e.map(n=>{var r;a.push([n.id,n.checkName,n.checkOwnerRef,...(r=n.trendPassRates)!=null?r:[n.snapshotPassRate]])}),a}function Zi(e){var a,n;const r=[];if(r.push(Ce(["entity_ref","entity_name","entity_owner_ref"],Be(e))),e!=null&&e.length)for(const l of e){const o=(a=l.trendPassRates)!=null&&a.length?l.trendPassRates:[l.snapshotPassRate];r.push([l.id,q(l.id).name,(n=l.entityOwnerRef)!=null?n:"",...o])}return r}function Ji(e){const a=[];return a.push(Ce(["team_ref","team_name"],Be(e))),e!=null&&e.length&&e.map(n=>{var r,l;a.push([n.id,(r=n.groupTitle)!=null?r:q(n.id).name,...(l=n.trendPassRates)!=null?l:[n.snapshotPassRate]])}),a}function ec(e){const a=[],n=e!=null&&e.length?Math.max(...e.map(r=>Be(r.levels))):0;return a.push(Ce(["track_id","track_name","track_owner_ref","level_ordinal","level_name"],n)),e!=null&&e.length&&e.map(r=>{var l;(l=r.levels)==null||l.map(o=>{var s,i;a.push([r.id,r.trackName,r.trackOwnerRef,o.levelOrdinal,(s=o.levelName)!=null?s:`Level ${o.levelOrdinal}`,...(i=o.trendPassRates)!=null?i:[o.snapshotPassRate]])})}),a}function tc(e){var a,n,r;const l=[];return l.push(Ce(["name"],(n=(a=e==null?void 0:e.overallCheckPassRates)==null?void 0:a.length)!=null?n:0)),(r=e==null?void 0:e.overallCheckPassRates)!=null&&r.length&&l.push(["Check Pass Rate",...e.overallCheckPassRates]),l}function ac(e){var a;const n=[];return n.push(Ce(["level_ordinal","level_name"],Be(e==null?void 0:e.overallTrackPassRate))),(a=e==null?void 0:e.overallTrackPassRate)!=null&&a.length&&e.overallTrackPassRate.map(r=>{var l;n.push([r.levelOrdinal,`Level ${r.levelOrdinal}`,...(l=r.trendPassRates)!=null?l:[r.snapshotPassRate]])}),n}function nc(e){var a;const n=[];return n.push(Ce(["entity_ref","entity_name"],Be(e==null?void 0:e.overallEntityPassRates))),(a=e==null?void 0:e.overallEntityPassRates)!=null&&a.length&&e.overallEntityPassRates.map(r=>{var l;n.push([r.id,q(r.id).name,...(l=r.trendPassRates)!=null?l:[0]])}),n}function rc(e){var a,n;const r=[];return r.push(Ce(["team_ref","team_name"],1)),(a=e==null?void 0:e.groupPassRates)!=null&&a.length&&((n=e==null?void 0:e.groupPassRates)==null||n.map(l=>{var o;r.push([l.id,(o=l.groupTitle)!=null?o:q(l.id).name,l.snapshotPassRate])})),r}const lc="check-pass-rates-summary.csv",oc="track-pass-rates-summary.csv",sc="entity-pass-rates-summary.csv",ic="team-pass-rates-summary.csv",cc="check-pass-rates.csv",mc="track-pass-rates.csv",dc="entity-pass-rates.csv",uc="team-pass-rates.csv",pc=x(e=>({chartHeader:{marginBottom:e.spacing(2)},overallSummaryBox:{display:"flex",flexDirection:"column",height:"100%",color:ue(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`}})),hc=()=>{var e,a,n;const r=Se(),l=pc(),{checkPassRateOverview:{data:o,isLoading:s,isError:i}}=be(),c=(a=(e=o==null?void 0:o.overallCheckPassRates)==null?void 0:e.length)!=null?a:0,d=fe((n=o==null?void 0:o.overallCheckPassRates)!=null?n:[]),m=o!=null&&o.overallCheckPassRates&&c?Math.round(o.overallCheckPassRates[c-1]):0;let u;!(o!=null&&o.overallCheckPassRates)||!c?u="No Data":u=`${m}%`;const p=t.createElement(k,{className:l.overallSummaryBox},t.createElement(Hl,{value:m,text:u,styles:_l({textColor:ue(r),pathColor:Rt(r)[0],trailColor:r.palette.divider,textSize:c?void 0:8})}),t.createElement(b,{className:l.summaryText},"Current check pass rate")),v=!(o!=null&&o.overallCheckPassRates)||!c||s||i;return t.createElement(Ft,{title:"Check pass rate",subtitle:"Aggregate pass rate for checks",summaryCardContent:p,chartSectionContent:t.createElement(Ye,{chartData:d}),disableDataExport:v,csvFilename:lc,csvData:tc(o)})},gc=()=>{var e;const a=t.createElement(Ki,null),n=t.createElement(Vi,null),{trackPassRateOverview:{data:r,isLoading:l,isError:o}}=be(),s=(e=r==null?void 0:r.overallTrackPassRate)==null?void 0:e.length,i=!(r!=null&&r.overallTrackPassRate)||!s||l||o;return t.createElement(Ft,{title:"Track pass rate",subtitle:"Aggregate pass rate for tracks",summaryCardContent:a,chartSectionContent:n,disableDataExport:i,csvFilename:oc,csvData:ac(r)})},vc=()=>{var e;const{entityPassRatesOverview:{data:a,isLoading:n,isError:r}}=be(),l=(e=a==null?void 0:a.overallEntityPassRates)==null?void 0:e.length,o=!(a!=null&&a.overallEntityPassRates)||!l||n||r;return t.createElement(Ft,{title:"Entity pass rate",subtitle:"Compare the aggregate pass rate for entities",chartSectionContent:t.createElement(Hi,null),disableDataExport:o,csvFilename:sc,csvData:nc(a)})},Ec=()=>{var e;const{groupPassRatesOverview:{data:a,isLoading:n,isError:r}}=be(),l=(e=a==null?void 0:a.groupPassRates)==null?void 0:e.length,o=!(a!=null&&a.groupPassRates)||!l||n||r;return t.createElement(Ft,{title:"Team pass rate",subtitle:"Compare the aggregate pass rate for teams",chartSectionContent:t.createElement(Qi,null),disableDataExport:o,csvFilename:ic,csvData:rc(a)})},fc=_(e=>({root:{display:"flex",flexDirection:"column",gap:e.spacing(2),flex:1,background:e.palette.background.default}})),yc=()=>{const e=fc();return t.createElement(k,{className:e.root},t.createElement(Gi,null,t.createElement(hc,null),t.createElement(gc,null),t.createElement(vc,null),t.createElement(Ec,null)))},bc=_(e=>({paper:{width:"100%",boxShadow:"none",border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius},tableHeaderCell:{fontWeight:"bold"}})),At=({data:e,columns:a})=>{const n=bc(),[r,l]=C(0),[o,s]=C(10);F(()=>{l(0)},[e.length]);const i=(u,p)=>{l(p)},c=u=>{s(+u.target.value),l(0)},d=r*o,m=d+o;return t.createElement(Ha,{className:n.paper},t.createElement($r,{size:"small"},t.createElement(Mr,null,t.createElement(ja,null,a.map(u=>t.createElement(Qa,{key:`header-${u.id}`,className:n.tableHeaderCell},u.label)))),t.createElement(Br,null,e.slice(d,m).map(u=>t.createElement(ja,{key:u.id},a.map(p=>t.createElement(Qa,{key:`cell-${p.id}`},p.renderCell?p.renderCell(u):u[p.id])))))),t.createElement(jt,{rowsPerPageOptions:[10,25,50],component:"div",count:e.length,rowsPerPage:o,page:r,onPageChange:i,onRowsPerPageChange:c}))};var Cc=(e=>(e.Check="check",e.Track="track",e.Entity="entity",e.Group="group",e))(Cc||{});const ne=_(e=>({root:{display:"flex",flexDirection:"column",flex:1,background:e.palette.background.default},ownerText:{fontWeight:500,color:ue(e)},flexColumn:{display:"flex",flexDirection:"column",gap:e.spacing(.5)},boldText:{fontWeight:"bold"},descriptionText:{maxWidth:400,color:ue(e),fontSize:e.typography.subtitle2.fontSize,lineHeight:e.typography.subtitle1.fontSize},detailButton:{textTransform:"none",backgroundColor:"transparent","&:hover":{backgroundColor:e.palette.action.hover}}})),$t=({name:e="",description:a=""})=>{const n=ne();return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},e),t.createElement(Va,{className:n.descriptionText,content:a!=null?a:""}))},Mt=({navigateTo:e})=>{const a=ne(),n=pe();return t.createElement(V,{variant:"text",className:a.detailButton,onClick:()=>n(e)},t.createElement(b,{className:a.ownerText},"View detail"))},kc=e=>(e==null?void 0:e.kind)==="Group",xc=e=>(e==null?void 0:e.kind)==="User",Da=({ownerEntityRef:e})=>{var a,n;const{data:r,error:l}=Ur(e!=null?e:void 0);if(r){let o;return kc(r)||xc(r)?o=(n=r.metadata.title)!=null?n:(a=r.spec.profile)==null?void 0:a.displayName:o=r.metadata.name,t.createElement(_e,{entityRef:Xr(r),title:o})}else if(l&&e)return t.createElement(te,{title:"Unable to pull owner reference from Catalog API"},t.createElement(b,{style:{color:"red"},variant:"body2"},(()=>{try{return q(e).name}catch{return e}})()));return null},wc=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=ne(),r=fe(e!=null?e:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Ye,{chartData:r,tableChart:!0}))};var re=(e=>(e[e.UP=0]="UP",e[e.DOWN=1]="DOWN",e[e.FLAT=2]="FLAT",e))(re||{});const Tc=x(e=>({cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Pc=({ownerEntityRef:e,passRates:a})=>{const n=Tc();return t.createElement(rt,{dense:!0,disablePadding:!0,className:n.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Details"),e&&t.createElement(ge,{disableGutters:!0,className:n.listItem},t.createElement(te,{title:"Owner"},t.createElement(J,null,t.createElement(dt,{color:"action",fontSize:"small"}))),t.createElement(ee,{className:n.listItemText,primary:t.createElement(_e,{entityRef:e!=null?e:"No Owner"})})),a.map(({name:r,value:l,trend:o},s)=>t.createElement(ge,{disableGutters:!0,className:n.listItem,key:s},t.createElement(te,{title:"The most recent pass rate."},t.createElement(J,null,o===re.UP&&t.createElement(zl,{color:"primary",fontSize:"small"}),o===re.DOWN&&t.createElement(Wl,{color:"error",fontSize:"small"}),o===re.FLAT&&t.createElement(Ul,{color:"action",fontSize:"small"}))),t.createElement(ee,{className:n.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},r!=null?r:"Latest Pass Rate",": ",t.createElement("b",null,Math.round(l),"%"))}))))},Rc=_(e=>({root:{display:"flex",flexDirection:"column",width:"100%"},gridContainer:{flexGrow:1},cardContent:{display:"flex",flexDirection:"column",gap:e.spacing(1),height:"100%"},footer:{display:"flex",flexDirection:"column",gap:e.spacing(1),justifyContent:"end",marginTop:"auto"}})),Bt=({data:e})=>{const a=Rc(),n=pe(),[r,l]=C(0),[o,s]=C(10);F(()=>{l(0)},[e.length]);const i=(p,v)=>{l(v)},c=p=>{try{const v=Number.parseInt(p.target.value,10);s(v),l(0)}catch{}},d=r*o,m=d+o,u=[{dataKey:"passRate",name:"Pass rate"}];return t.createElement(k,{className:a.root},t.createElement(h,{container:!0,spacing:2,className:a.gridContainer},e.slice(d,m).map((p,v)=>{var f,E;return t.createElement(h,{item:!0,key:v,xs:12,sm:12,md:6,lg:4,xl:3},t.createElement(Qe,{title:(f=p.name)!=null?f:p.id,description:p.description,children:t.createElement(k,{className:a.cardContent},t.createElement(k,{className:a.footer},t.createElement(Pc,{ownerEntityRef:p.owner,passRates:p.lineChart.snapshotPassRates}),t.createElement(Dt,{data:p.lineChart.trendPassRates,lines:(E=p.lineChart.lineConfigs)!=null?E:u}))),handleView:()=>n(p.navigateTo)}))})),t.createElement(jt,{rowsPerPageOptions:[10,25,50],component:"div",count:e.length,rowsPerPage:o,page:r,onPageChange:i,onRowsPerPageChange:c}))};var Y=(e=>(e[e.TABLE=0]="TABLE",e[e.GRID=1]="GRID",e))(Y||{});function Gt(e){if(!e||!e.length)return re.FLAT;if(e.length===1)return e[0]>0?re.UP:re.FLAT;const a=e[e.length-1]-e[0];return a<0?re.DOWN:a>0?re.UP:re.FLAT}function Sc(e,a){return e.map(n=>{var r,l,o,s,i;return{id:n.id,name:(r=n.checkName)!=null?r:n.id,description:(l=n.checkDescription)!=null?l:void 0,lineChart:{snapshotPassRates:[{value:n.snapshotPassRate,trend:Gt((o=n.trendPassRates)!=null?o:[])}],trendPassRates:fe((s=n.trendPassRates)!=null?s:[])},owner:(i=n.checkOwnerRef)!=null?i:void 0,navigateTo:a(n.id)}})}function Nc(e,a){return e.map(n=>{var r,l,o,s;return{id:n.id,name:q(n.id).name,description:(r=n.entityDescription)!=null?r:void 0,lineChart:{snapshotPassRates:[{value:n.snapshotPassRate,trend:Gt((l=n.trendPassRates)!=null?l:[])}],trendPassRates:fe((o=n.trendPassRates)!=null?o:[])},owner:(s=n.entityOwnerRef)!=null?s:void 0,navigateTo:`${a(q(n.id))}/soundcheck`}})}function Lc(e,a){return e.map(n=>{var r,l,o;return{id:n.id,name:(r=n.groupTitle)!=null?r:q(n.id).name,lineChart:{snapshotPassRates:[{value:n.snapshotPassRate,trend:Gt((l=n.trendPassRates)!=null?l:[])}],trendPassRates:fe((o=n.trendPassRates)!=null?o:[])},navigateTo:a(q(n.id))}})}function Dc(e,a){return e.map(n=>{var r,l,o,s,i,c,d;return{id:n.id,name:(r=n.trackName)!=null?r:n.id,description:(l=n.trackDescription)!=null?l:void 0,lineChart:{snapshotPassRates:(s=(o=n.levels)==null?void 0:o.map(({levelOrdinal:m,levelName:u,snapshotPassRate:p,trendPassRates:v})=>({name:u?`Level ${m} (${u})`:`Level ${m}`,value:p,trend:Gt(v!=null?v:[])})))!=null?s:[],trendPassRates:sr({overallTrackPassRate:n.levels}),lineConfigs:(c=(i=n.levels)==null?void 0:i.map(({levelOrdinal:m,levelName:u})=>({dataKey:`Level${m}`,name:u!=null?u:`Level ${m}`})))!=null?c:[]},owner:(d=n.trackOwnerRef)!=null?d:void 0,navigateTo:a({trackId:n.id})}})}const Ic=_(e=>({header:{padding:e.spacing(0,0,1),display:"flex"},headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"end"},exportButton:{height:"40px",width:"112px"},listItemIcon:{minWidth:"30px"},menuItem:{width:"112px"}})),Vt=({viewMode:e,setViewMode:a,isLoading:n,searchTerm:r,setSearchTerm:l,searchPlaceholder:o,csvData:s,csvFilename:i})=>{const c=Ic(),d=(E,g)=>{g!==null&&a(g)},[m,u]=t.useState(null),p=!!m,v=E=>{u(E.currentTarget)},f=()=>{u(null)};return t.createElement(h,{container:!0,spacing:2,className:c.header},t.createElement(h,{item:!0,xs:6},t.createElement(xa,{searchTerm:r,setSearchTerm:l,disabled:n,placeholder:o||"Search",variant:"outlined",size:"small"})),t.createElement(h,{item:!0,xs:6,className:c.headerButtons},t.createElement(V,{id:"export-button",className:c.exportButton,disabled:n,variant:"contained",color:"primary","aria-controls":p?"export-menu":void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,onClick:v,endIcon:t.createElement(Yl,null)},"Export"),t.createElement(Ut,{id:"export-menu",anchorEl:m,getContentAnchorEl:null,open:p,onClose:f,MenuListProps:{"aria-labelledby":"export-button",disablePadding:!0},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"}},t.createElement(xn,{data:s,filename:i},t.createElement(he,{onClick:f,className:c.menuItem},t.createElement(J,{className:c.listItemIcon},t.createElement(Ql,null)),t.createElement(ee,null,"CSV")))),t.createElement(Nl,{size:"small",value:e,exclusive:!0,onChange:d},t.createElement(cn,{value:Y.TABLE},t.createElement(Kl,{color:"primary"})),t.createElement(cn,{value:Y.GRID},t.createElement(jl,{color:"primary"})))))},Oc=(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:s=>{var i;const c=(i=s.levels)==null?void 0:i.find(({levelOrdinal:d})=>d===o);return c?t.createElement(wc,{row:c}):t.createElement(t.Fragment,null)}}})},Fc=(e,a)=>{const n=e.flatMap(o=>{var s;return((s=o.levels)==null?void 0:s.map(i=>i.levelOrdinal))||[]}),r=Math.min(...n),l=Math.max(...n);return[{label:"NAME",id:"trackName",renderCell:o=>{var s;return t.createElement($t,{name:(s=o.trackName)!=null?s:o.id,description:o.trackDescription})}},...Oc(r,l),{label:"OWNER",id:"trackOwnerRef",renderCell:o=>{var s;return t.createElement(Da,{ownerEntityRef:(s=o.trackOwnerRef)!=null?s:void 0})}},{label:"ACTION",id:"action",renderCell:o=>t.createElement(Mt,{navigateTo:a({trackId:o.id})})}]},Ac=()=>{const e=ne(),{filter:a}=ye(),n=ae(Xa),{data:r,isLoading:l,isError:o}=mo(a),[s,i]=C(Y.TABLE),[c,d]=C(""),m=H(()=>{var f;return Fc((f=r==null?void 0:r.individualTrackPassRate)!=null?f:[],n)},[r==null?void 0:r.individualTrackPassRate,n]);if(l)return t.createElement(Me,null);if(o)return t.createElement(b,{color:"error"},"Failed to load tracks");const{individualTrackPassRate:u}=r;if(!u)return t.createElement(b,{color:"error"},"No available tracks");const p=c.length?u.filter(({id:f,trackName:E})=>{var g;return((g=E==null?void 0:E.toLowerCase())==null?void 0:g.includes(c.toLowerCase()))||f.toLowerCase().includes(c.toLowerCase())}):u,v=ec(p);return t.createElement(k,{className:e.root},t.createElement(h,{container:!0,direction:"row"},t.createElement(Vt,{viewMode:s,setViewMode:i,isLoading:l,searchTerm:c,setSearchTerm:d,searchPlaceholder:"Search available tracks",csvData:v,csvFilename:mc}),s===Y.TABLE&&t.createElement(At,{data:p,columns:m}),s===Y.GRID&&t.createElement(Bt,{data:Dc(p,n)})))},$c=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=ne(),r=fe(e!=null?e:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Ye,{chartData:r,tableChart:!0}))};function Mc(e){return[{label:"NAME",id:"entityName",renderCell:({id:a,entityDescription:n})=>t.createElement($t,{name:q(a).name,description:n})},{label:"TREND",id:"trend",renderCell:a=>t.createElement($c,{row:a})},{label:"OWNER",id:"entityOwnerRef",renderCell:({entityOwnerRef:a})=>t.createElement(Da,{ownerEntityRef:a!=null?a:void 0})},{label:"ACTION",id:"action",renderCell:({id:a})=>t.createElement(Mt,{navigateTo:`${e(q(a))}/soundcheck`})}]}const Bc=()=>{const e=ne(),{filter:a}=ye(),n=ae(Ja),{data:r,isLoading:l,isError:o}=po(a),[s,i]=C(Y.TABLE),[c,d]=C("");if(l)return t.createElement(Me,null);if(o)return t.createElement(b,{color:"error"},"Failed to load entities");const{individualEntityPassRates:m}=r;if(!m)return t.createElement(b,{color:"error"},"No available entities");const u=c.length?m.filter(({id:v})=>{var f;return(f=v.toLowerCase())==null?void 0:f.includes(c.toLowerCase())}):m,p=Zi(u);return t.createElement(k,{className:e.root},t.createElement(h,{container:!0,direction:"row"},t.createElement(Vt,{viewMode:s,setViewMode:i,isLoading:l,searchTerm:c,setSearchTerm:d,searchPlaceholder:"Search available entities",csvData:p,csvFilename:dc}),s===Y.TABLE&&t.createElement(At,{data:u,columns:Mc(n)}),s===Y.GRID&&t.createElement(Bt,{data:Nc(u,n)})))},Gc=({row:{trendPassRates:e,snapshotPassRate:a}})=>{const n=ne(),r=fe(e!=null?e:[]);return r.length?t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(a),"%"),t.createElement(Ye,{chartData:r,tableChart:!0})):t.createElement(k,{className:n.flexColumn},t.createElement(b,null,"No data"))};function Vc(e){return[{label:"NAME",id:"groupName",renderCell:({groupTitle:a,id:n})=>t.createElement($t,{name:a!=null?a:q(n).name})},{label:"TREND",id:"trend",renderCell:a=>t.createElement(Gc,{row:a})},{label:"ACTION",id:"action",renderCell:({id:a})=>t.createElement(Mt,{navigateTo:e(q(a))})}]}const qc=()=>{const e=ne(),{filter:a}=ye();a.context=void 0;const n=ae(Ja),{data:r,isLoading:l,isError:o}=go(a),[s,i]=C(Y.TABLE),[c,d]=C("");if(l)return t.createElement(Me,null);if(o)return t.createElement(b,{color:"error"},"Failed to load groups");const{groupPassRates:m}=r;if(!m)return t.createElement(b,{color:"error"},"No available groups");const u=c.length?m.filter(({id:v,groupTitle:f})=>{var E;return((E=f==null?void 0:f.toLowerCase())==null?void 0:E.includes(c.toLowerCase()))||v.toLowerCase().includes(c.toLowerCase())}):m,p=Ji(u);return t.createElement(k,{className:e.root},t.createElement(h,{container:!0,direction:"row"},t.createElement(Vt,{viewMode:s,setViewMode:i,isLoading:l,searchTerm:c,setSearchTerm:d,searchPlaceholder:"Search available teams",csvFilename:uc,csvData:p}),s===Y.TABLE&&t.createElement(At,{data:u,columns:Vc(n)}),s===Y.GRID&&t.createElement(Bt,{data:Lc(u,n)})))},Hc=({row:e})=>{var a;const n=ne(),r=fe((a=e.trendPassRates)!=null?a:[]);return t.createElement(k,{className:n.flexColumn},t.createElement(b,{className:n.boldText},Math.round(e.snapshotPassRate),"%"),t.createElement(Ye,{chartData:r,tableChart:!0}))};function _c(e){return[{label:"NAME",id:"checkName",renderCell:a=>{var n;return t.createElement($t,{name:(n=a.checkName)!=null?n:a.id,description:a.checkDescription})}},{label:"TREND",id:"snapshotPassRate",renderCell:a=>t.createElement(Hc,{row:a})},{label:"OWNER",id:"checkOwner",renderCell:a=>{var n;return t.createElement(Da,{ownerEntityRef:(n=a.checkOwnerRef)!=null?n:void 0})}},{label:"ACTION",id:"action",renderCell:a=>t.createElement(Mt,{navigateTo:e({checkId:a.id})})}]}const zc=()=>{const e=ne(),{filter:a}=ye(),n=ae(Ya),{data:r,isLoading:l,isError:o}=io(a),[s,i]=C(Y.TABLE),[c,d]=C("");if(l)return t.createElement(Me,null);if(o)return t.createElement(b,{color:"error"},"Failed to load checks");const{individualCheckPassRates:m}=r;if(!m)return t.createElement(b,{color:"error"},"No available checks");const u=c.length?m.filter(({id:v,checkName:f})=>{var E;return((E=f==null?void 0:f.toLowerCase())==null?void 0:E.includes(c.toLowerCase()))||v.toLowerCase().includes(c.toLowerCase())}):m,p=Xi(u);return t.createElement(k,{className:e.root},t.createElement(h,{container:!0,direction:"row"},t.createElement(Vt,{viewMode:s,setViewMode:i,isLoading:l,searchTerm:c,setSearchTerm:d,searchPlaceholder:"Search available checks",csvData:p,csvFilename:cc}),s===Y.TABLE&&t.createElement(At,{data:u,columns:_c(n)}),s===Y.GRID&&t.createElement(Bt,{data:Sc(u,n)})))},Wc=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}`}}})),Uc=()=>{const e=Wc();return t.createElement(Ri,null,t.createElement("div",{className:e.container},t.createElement("div",{className:e.fixedColumn},t.createElement(Bi,null)),t.createElement("div",{className:e.flexibleColumn},t.createElement(k,{className:e.pageLayout},t.createElement(Ga,null,t.createElement(Pe,{path:"/*",element:t.createElement(Z,null,t.createElement(Z.Route,{title:"Summary",path:"/"},t.createElement(yc,null)),t.createElement(Z.Route,{title:"Checks",path:"/checks"},t.createElement(zc,null)),t.createElement(Z.Route,{title:"Tracks",path:"/tracks"},t.createElement(Ac,null)),t.createElement(Z.Route,{title:"Entities",path:"/entities"},t.createElement(Bc,null)),t.createElement(Z.Route,{title:"Teams",path:"/teams"},t.createElement(qc,null)))}))))))},Kc=({collector:e,children:a})=>{const{description:n,id:r,isEditable:l,name:o}=e,{setSelectedCollector:s,setShowModal:i}=vt(),{loading:c,allowed:d}=Q({permission:bl}),m=l&&!c&&d,u=()=>{i(!0),s(e)};return t.createElement(Qe,{title:o!=null?o:r,description:n,viewLabel:"Configure",editLabel:"Configure",children:a,handleView:void 0,handleEdit:m?u:void 0})},jc=()=>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(mt,{variant:"rect",height:385}))));function Qc(e){switch(e){case"catalog":return Xl;case"github":return Jl;case"scm":return Zl;case"soundcheck":return to;case"techinsights":return ao;default:return eo}}const Yc=x(e=>({container:{display:"flex",justifyContent:"center",alignItems:"center"},imageContainer:{width:"150px",height:"150px"},image:{width:"100%",height:"100%",objectFit:"contain"}})),Xc=({collector:e})=>{const{id:a}=e,n=Yc();return t.createElement(t.Fragment,null,t.createElement("div",{className:n.container},t.createElement("div",{className:n.imageContainer},t.createElement("img",{src:Qc(a),alt:a,className:n.image}))))},Zc=()=>{const{data:e,isLoading:a}=Fn();return t.createElement(h,{container:!0,direction:"row"},t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"checks"},a?t.createElement(jc,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(Kc,{collector:n},t.createElement(Xc,{collector:n}))))))},ur=()=>({enabled:!1,hasDuration:!1,unit:B.Days,value:1});function Ia(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 Oa(e){var a;const n=ur();if(!e)return n;if(typeof e=="boolean")return{...n,enabled:e};if(!ze.isObject(e)||!("duration"in e))return n;const r=e.duration;if(!ze.isObject(r))return n;const l=Object.entries(r);if(l.length===0)return n;const[o,s]=l[0];return{...n,enabled:!0,hasDuration:!0,unit:(a=kt(o))!=null?a:B.Days,value:s}}const Jc=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"}})),em=({value:e,onChange:a,disabled:n,errors:r})=>{const l=Jc(),[o,s]=C(e),[i,c]=C(`${e.value}`);F(()=>{a&&a(o)},[o,a]);const d=v=>{s({...o,enabled:v.target.checked,hasDuration:v.target.checked&&o.hasDuration})},m=v=>{s({...o,hasDuration:v.target.checked})},u=v=>{c(v.target.value);const f=parseInt(v.target.value,10);s({...o,value:isNaN(f)?0:f})},p=v=>{var f;s({...o,unit:(f=kt(v.target.value))!=null?f:B.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(He,{id:"enableCaching",disabled:n,checked:o.enabled,onChange:d,"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(He,{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(K,{id:"every",type:"number",label:"For",name:"for",disabled:n||!o.hasDuration,value:i,onChange:u,error:!!(r!=null&&r.message),helperText:r==null?void 0:r.message,inputProps:{min:Bn,max:Gn},"data-testid":"forTextField"})),t.createElement(h,{item:!0},t.createElement(tt,null,t.createElement(zt,{id:"duration-unit"},"Unit"),t.createElement(Wt,{labelId:"duration-unit",disabled:n||!o.hasDuration,value:o.unit,onChange:p,"data-testid":"unitSelect"},ga.map(v=>t.createElement(he,{key:v,value:v},v)))))))))},tm=({enabled:e,hasDuration:a,value:n})=>e&&a?Vn(n):!0,am=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)}})),Fa=({name:e,label:a,description:n,control:r,disabled:l,errors:o})=>{const[s,i]=C(0),c=Xt({control:r,name:`${e}.enabled`}),d=(u,p)=>{i(p)},m=am();return t.createElement("div",{className:m.root},t.createElement(M,{name:`${e}.enabled`,control:r,render:({field:u})=>t.createElement(at,{control:t.createElement(Gr,{...u,checked:u.value,"data-testid":`${e}-switch`}),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(_a,{orientation:"horizontal",variant:"scrollable",value:s,onChange:d,className:m.tabsContainer},t.createElement(Ve,{label:"Frequency",className:m.tab}),t.createElement(Ve,{label:"Filters",className:m.tab}),t.createElement(Ve,{label:"Caching",className:m.tab})),t.createElement("div",{className:m.contentContainer},s===0&&t.createElement("div",null,t.createElement(M,{name:`${e}.frequency`,control:r,rules:{validate:Un},render:({field:u})=>t.createElement(qn,{disabled:l,value:u.value,onChange:u.onChange,errors:o==null?void 0:o.frequency})})),s===1&&t.createElement("div",null,t.createElement(M,{name:`${e}.filters`,control:r,render:({field:u})=>t.createElement(Ca,{disabled:l,value:u.value,onChange:u.onChange})})),s===2&&t.createElement("div",null,t.createElement(M,{name:`${e}.cacheConfig`,control:r,rules:{validate:tm},render:({field:u})=>t.createElement(em,{disabled:l,value:u.value,onChange:u.onChange,errors:o==null?void 0:o.cacheConfig})})))))},Aa=()=>({enabled:!1,filters:{...je(),selectedKinds:["Component"]},frequency:ha(),cacheConfig:ur()}),pr=()=>({branchProtections:Aa(),repositoryDetails:Aa(),repositoryLanguages:Aa()});function nm(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:s,frequency:i,filters:c}=a;o.push({factName:"branch_protections",type:"BranchProtections",frequency:va(i),filters:Ct(c),cache:Ia(s)})}if(n.enabled){const{cacheConfig:s,frequency:i,filters:c}=n;o.push({factName:"repository_details",type:"RepositoryDetails",frequency:va(i),filters:Ct(c),cache:Ia(s)})}if(r.enabled){const{cacheConfig:s,frequency:i,filters:c}=r;o.push({factName:"repository_languages",type:"RepositoryLanguages",frequency:va(i),filters:Ct(c),cache:Ia(s)})}return l}return[]}function rm(e){var a,n,r,l,o,s;const i=pr();if(e){const c=e.collects;if(c)for(const d of ea(c)){const m=d.type;m==="BranchProtections"&&(i.branchProtections={enabled:!0,frequency:Ea((a=d.frequency)!=null?a:e.frequency),filters:pa((n=d.filters)!=null?n:e.filters),cacheConfig:Oa(d.cache)}),m==="RepositoryDetails"&&(i.repositoryDetails={enabled:!0,frequency:Ea((r=d.frequency)!=null?r:e.frequency),filters:pa((l=d.filters)!=null?l:e.filters),cacheConfig:Oa(d.cache)}),m==="RepositoryLanguages"&&(i.repositoryLanguages={enabled:!0,frequency:Ea((o=d.frequency)!=null?o:e.frequency),filters:pa((s=d.filters)!=null?s:e.filters),cacheConfig:Oa(d.cache)})}}return i}const lm="Error Configuring Collector";function om(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.updateCollectorConfig(l);if(!o)throw new Error("Failed to update collector configuration.");return o};return ce([de.UpdateCollectorConfig],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[D.GetCollectors]})},onError:l=>{let o="Failed to update collector configuration.";l instanceof Error&&(o=l.message),n({severity:"error",title:lm,message:o})}})}const sm=({disabled:e})=>{const{hideModal:a,selectedCollector:n}=vt(),{control:r,formState:{errors:l},handleSubmit:o}=st({defaultValues:n?rm(n.config):pr(),mode:"onChange"}),s=!!l.branchProtections||!!l.repositoryDetails||!!l.repositoryLanguages,{mutateAsync:i}=om(),c=async d=>{const m=nm(d);await i({collectorId:"github",config:m})&&a()};return t.createElement("form",{onSubmit:o(c)},t.createElement(Fa,{name:"branchProtections",label:"Branch Protections",description:"Collects branch protection information from an entity's repository.",control:r,disabled:e,errors:l.branchProtections}),t.createElement(qe,null),t.createElement(Fa,{name:"repositoryDetails",label:"Repository Details",description:"Collects details about the an entity's repository.",control:r,disabled:e,errors:l.repositoryDetails}),t.createElement(qe,null),t.createElement(Fa,{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(gt,{onCancel:a,saveButtonText:"Save",isLoading:!1,onSave:o(c),disableSave:s})))},im=({title:e,open:a,handleClose:n})=>{const{selectedCollector:r}=vt();return t.createElement(Ke,{handleClose:n,title:e,open:a},(r==null?void 0:r.id)==="github"&&t.createElement(sm,null))},cm=x(e=>({container:{padding:e.spacing(3)}})),mm=()=>{var e;const a=cm(),{selectedCollector:n,showModal:r,hideModal:l}=vt();return t.createElement("div",{className:a.container},t.createElement(Zc,null),t.createElement(im,{title:n?(e=n.name)!=null?e:n.id:"",open:r,handleClose:l}))},dm=()=>t.createElement(fo,null,t.createElement(mm,null)),um=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),pm=({campaign:e})=>{var a;const n=um();return t.createElement(rt,{dense:!0,disablePadding:!0,className:n.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Campaign Details"),t.createElement(ge,{disableGutters:!0,className:n.listItem},t.createElement(te,{title:"Owner"},t.createElement(J,null,t.createElement(dt,{color:"action",fontSize:"small"}))),t.createElement(ee,{className:n.listItemText,primary:t.createElement(_e,{entityRef:(a=e.ownerEntityRef)!=null?a:"No Owner"})})))},hm="Error Deleting Campaign";function gm(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.deleteCampaign(l);if(!o)throw new Error(`Failed to delete campaign ${l}`);return o};return ce([de.DeleteCampaign],r,{onSuccess:()=>a.invalidateQueries({queryKey:[D.GetCampaigns]}),onError:(l,o)=>{let s=`Failed to delete campaign ${o}`;l instanceof Error&&(s=l.message),n({severity:"error",title:hm,message:s})}})}const vm="Error Archiving Campaign";function Em(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.archiveCampaign(l);if(!o)throw new Error(`Failed to archive campaign ${l}`);return o};return ce([de.ArchiveCampaign],r,{onSuccess:()=>a.invalidateQueries({queryKey:[D.GetCampaigns]}),onError:(l,o)=>{let s=`Failed to archive campaign ${o}`;l instanceof Error&&(s=l.message),n({severity:"error",title:vm,message:s})}})}const fm=({campaign:e})=>{const{id:a,name:n,description:r,ownerEntityRef:l}=e,o=ae(el),s=ae(tl),i=pe(),{showModal:c}=Ne(),d=!e.archived,{mutate:m}=gm(),{mutate:u}=Em(),{loading:p,allowed:v}=Q({permission:Cl,resourceRef:e.id}),{loading:f,allowed:E}=Q({permission:kl,resourceRef:e.id}),g=U(async()=>{await c({title:"Delete Campaign",message:`Are you sure you want to delete campaign ${e.name}?`})&&m(e.id)},[c,m,e.id,e.name]),y=U(async()=>{await c({title:"Archive Campaign",message:`Are you sure you want to archive campaign ${e.name}?`})&&u(e.id)},[c,u,e.id,e.name]);return t.createElement(Qe,{title:n!=null?n:a,description:r,children:l&&t.createElement(pm,{campaign:e}),handleView:()=>i(o({campaignId:e.id})),handleEdit:!p&&v?()=>i(s({campaignId:e.id})):void 0,handleDelete:!f&&E?g:void 0,handleArchive:d&&!f&&E?y:void 0})};function ym(e){const a=O(A);return j([D.GetCampaigns,JSON.stringify(e)],async()=>a.getCampaigns(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const bm=()=>t.createElement("div",{"data-testid":"campaigns-skeleton"},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(mt,{variant:"rect",height:385})))),Cm={0:"detailsStep",1:"tracksStep",2:"milestonesStep"};var qt=(e=>(e.title="Create a campaign",e.description="A soundcheck campaign allows you to define a tech health goal, assign it to a team and monitor progress.",e.callToAction="Get started",e))(qt||{});const km=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"center"},header:{padding:e.spacing(0,0,1)},container:{padding:e.spacing(3)}})),xm=({campaignsPerPage:e,currentCursor:a})=>{const n=km(),[r,l]=C(a),[o,s]=C(""),[i,c]=C(""),[d,m]=C("default"),[u,p]=C("all"),[v,f]=C("all"),[E,g]=C([]);no(()=>{c(o)},500,[o]);const{setShowAddModal:y}=ua(),{loading:w,allowed:P}=Q({permission:xl}),{data:L,isLoading:R}=ym({ids:void 0,first:e,after:r,orderAlphabetical:d,searchByOwner:u,searchByName:i,searchByStatus:v}),[T,z]=C(L),G=T==null?void 0:T.edges.map($=>$.campaign),[se,ke]=C([]),I=$=>{m($.target.value)},S=$=>{p($.target.value)},W=$=>{f($.target.value)};return F(()=>{L&&z(()=>{var $;return{endCursor:L.endCursor,totalCount:L.totalCount,hasNextPage:($=L==null?void 0:L.hasNextPage)!=null?$:!1,edges:L.edges}})},[L]),F(()=>{const $=T==null?void 0:T.edges.map(xe=>xe.campaign),X=Ta($!=null?$:[]);g(X)},[R,T]),!G||G.length===0?t.createElement(Yt,{title:qt.title,description:qt.description,imgSrc:na,action:!w&&t.createElement(V,{disabled:!P,variant:"contained",color:"primary",onClick:()=>y(!0)},qt.callToAction)}):t.createElement(h,{container:!0,direction:"row",className:n.container},t.createElement(h,{container:!0,spacing:4,className:n.header},t.createElement(wa,{searchPlaceholder:"Search available campaigns",isLoading:R,searchTerm:o,setSearchTerm:s,filterAlpha:d,handleAlphabeticalFilterChange:I,filterOwner:u,handleOwnerFilterChange:S,filterStatus:v,handleStatusFilterChange:W,owners:E}),t.createElement(h,{item:!0,xs:3},t.createElement("div",{className:n.headerButtons},!w&&t.createElement(V,{disabled:!P,variant:"contained",color:"primary",onClick:()=>y(!0)},"Create campaign")))),t.createElement(h,{container:!0,spacing:4,role:"list","aria-label":"campaigns"},R?t.createElement(bm,null):G==null?void 0:G.map($=>t.createElement(h,{key:$.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(fm,{campaign:$})))),((T==null?void 0:T.hasNextPage)||(se==null?void 0:se.length)>0)&&t.createElement(Pa,{response:T,listingsPerPage:e,cursor:r,setCursor:l,prevCursors:se,setPrevCursors:ke,labelPerPageDropdown:"Campaigns Per Page:",urlRoute:"campaigns?campaignsPerPage="}))},wm=25,Tm=250,Pm=25,Rm=250,le="This field is required",Sm="At least one check is required",oe={details:{name:{rules:{required:!0,maxLength:25},messages:{required:le,maxLength:"Input must be less than 25 characters"}},description:{rules:{required:!0,maxLength:250},messages:{required:le,maxLength:"Description must be no more than 250 characters"}},owner:{rules:{required:!0},messages:{required:le}},supportChannel:{rules:{required:!0},messages:{required:le}},startingDate:{rules:{required:!0},messages:{required:le}},endingDate:{rules:{required:!0},messages:{required:le}}},tracks:{type:{rules:{required:!0},messages:{required:le}},checks:{rules:{required:!0},messages:{required:Sm}}},milestones:{name:{rules:{required:!0,maxLength:25},messages:{required:le,maxLength:"Input must be less than 25 characters"}},description:{rules:{required:!0,maxLength:250},messages:{required:le,maxLength:"Description must be no more than 250 characters"}},passrate:{rules:{required:!0,min:0,max:100},messages:{required:le,min:"Minimum pass rate is 0%",max:"Maximum pass rate is 100%"}}}},Nm={detailsStep:{campaignName:"",campaignDescription:"",campaignOwner:"",supportChannel:"",campaignStartDate:null,campaignEndDate:null},tracksStep:{trackType:"campaigntrack",checks:[]},milestonesStep:{milestones:[{milestoneName:"",milestoneDescription:"",milestonePassrate:""}]}},$a={details:{name:{name:"Campaign name",description:"Give your campaign a meaningful name so it's easy to remember it",helperText:`Max ${wm} characters`,placeholder:"Example: Check for latest version of javascript and Readme files"},description:{name:"Campaign description",description:"Give your campaign a meaningful description so others can understand how to use it",helperText:`Max ${Tm} characters`,placeholder:"Example: Ask my teams to check for the latest version of javascript and Readme files so that we can meet our quality standards this quarter"},owner:{name:"Campaign owner",description:"Add yourself, a colleague or a team as the owner of this campaign"},support:{name:"Support channel",description:"Add a Slack channel to receive updates about the campaign",placeholder:"Enter a channel or email"},startingDate:{name:"Starting date",placeholder:"Starting date"},endingDate:{name:"Ending date"}},milestones:{name:{name:"Milestone name",description:"Give your milestone a meaningful name so it's easy to remember it",helperText:`Max ${Pm} characters`,placeholder:"Example: 80% passrate"},description:{name:"Milestone description",description:"Give your milestone a meaningful description so others can understand how to use it",helperText:`Max ${Rm} characters`,placeholder:"Example: The track in my my campaign has a passrate of 80% or above"},passrate:{name:"Milestone passrate",description:"Enter the pass rate that your tracks have to meet",placeholder:"Example: 80%"}},filter:{description:'Setting the filters below will limit the scope of the Campaign so that only those Entities that match the filter will be monitored by the Campaign. As an example, choosing a "Kind" of "Component" will make this Campaign only apply to Entities whose Kind is indeed set to "Component". This would exclude Entities like Groups, Users, APIs, etc. from being impacted by the Campaign.'}},Lm=()=>{const e=Nm,{control:a,handleSubmit:n,getValues:r,setValue:l,trigger:o,formState:{errors:s}}=st({defaultValues:e,mode:"onChange"}),{showModal:i}=Ne();return{control:a,handleSubmit:n,getValues:r,setValue:l,trigger:o,errors:s,onSubmit:async c=>{await i({title:"Save Campaign",message:`Are you sure you want to save campaign: ${c.detailsStep.campaignName}?`,error:!1})}}},Dm=x(e=>({container:{display:"flex",gap:e.spacing(1),flexDirection:"column"},link:{fontWeight:"bold",padding:0},list:{marginTop:0},listItem:{marginBottom:e.spacing(1)}})),Im=()=>{const e=Dm(),a=ae(al),n=pe();return t.createElement("div",{className:e.container},t.createElement(b,{variant:"h6"},"Creating campaigns"),t.createElement(b,{variant:"body1"},"A Campaign is a focused short term initiative."),t.createElement(b,{variant:"body1"},"You can create campaigns, assign them to teams that own software components, and track them towards a completion milestone via the"," ",t.createElement(V,{variant:"text",onClick:()=>n(a()),className:e.link},"Tech Health")," ","page."),t.createElement(b,{variant:"body1"},"Some use cases for campaigns include:"),t.createElement(b,{variant:"body1"},t.createElement("ul",{className:e.list},t.createElement("li",{className:e.listItem},"When your organization wants to upgrade Spring libraries to use a specific version of Spring Boot."),t.createElement("li",null,"When your organization wants to remove unneeded data endpoints to save costs."))))},Om=x(e=>({helperText:{marginLeft:0},selectFieldGroup:{display:"flex",flexDirection:"column",gap:e.spacing(1),marginTop:e.spacing(1)},selectField:{display:"flex",flexDirection:"column",gap:e.spacing(1)},scheduleTitle:{fontWeight:"bold"},fieldContainer:{width:"250px"},select:{width:"100%"},chip:{backgroundColor:e.palette.primary.main,color:e.palette.primary.contrastText},chips:{width:"310px",marginLeft:e.spacing(1)}})),Fm=[{value:{days:7},label:"1 week"},{value:{days:14},label:"2 weeks"},{value:{month:1},label:"1 month"},{value:{months:3},label:"3 months"},{value:{months:6},label:"6 months"},{value:{year:1},label:"1 year"}],Am=({control:e,errors:a,isLoading:n,disabled:r})=>{const l=Om(),[o,s]=C(!1),{options:i}=Qt(),[c,d]=C(null),[m,u]=C(void 0),p=Jt(i==null?void 0:i.map(X=>({value:X.ref,label:X.name})),"value"),{name:v,description:f,owner:E,support:g,startingDate:y,endingDate:w}=$a.details,{rules:P,messages:L}=oe.details.name,{rules:R,messages:T}=oe.details.description,{rules:z,messages:G}=oe.details.owner,{rules:se,messages:ke}=oe.details.supportChannel,{rules:I,messages:S}=oe.details.startingDate,{rules:W,messages:$}=oe.details.endingDate;return t.createElement(t.Fragment,null,t.createElement("div",null,t.createElement(b,{variant:"subtitle2"},v.name),t.createElement(b,{variant:"caption"},v.description),t.createElement(M,{name:"detailsStep.campaignName",control:e,defaultValue:"",rules:P,render:({field:X})=>t.createElement(K,{...X,FormHelperTextProps:{className:l.helperText},variant:"outlined",fullWidth:!0,placeholder:v.placeholder,disabled:n||r,type:"text",margin:"normal",error:!!(a!=null&&a.campaignName),helperText:a!=null&&a.campaignName?L[a.campaignName.type]:v.helperText})})),t.createElement("div",null,t.createElement(b,{variant:"subtitle2"},f.name),t.createElement(b,{variant:"caption"},f.description),t.createElement(M,{name:"detailsStep.campaignDescription",control:e,defaultValue:"",rules:R,render:({field:X})=>t.createElement(K,{...X,FormHelperTextProps:{className:l.helperText},variant:"outlined",multiline:!0,minRows:4,fullWidth:!0,placeholder:f.placeholder,disabled:n||r,type:"text",margin:"normal",error:!!(a!=null&&a.campaignDescription),helperText:a!=null&&a.campaignDescription?T[a.campaignDescription.type]:f.helperText})})),t.createElement("div",{className:l.selectField},t.createElement("header",null,t.createElement(b,{variant:"subtitle2"},E.name),t.createElement(b,{variant:"caption"},E.description)),t.createElement("div",{className:l.fieldContainer},t.createElement(yt,{name:"detailsStep.campaignOwner",control:e,options:p,selectLabel:"Owner",disabled:r||n,style:{width:"100%"},rules:z,helperText:a!=null&&a.campaignOwner?G[a.campaignOwner.type]:void 0})),t.createElement("div",null,t.createElement(b,{variant:"subtitle2"},g.name),t.createElement(b,{variant:"caption"},g.description),t.createElement("div",{className:l.fieldContainer},t.createElement(De,{name:"detailsStep.supportChannel",control:e,label:g.name,placeholder:g.placeholder,disabled:r||n,variant:"outlined",error:a==null?void 0:a.supportChannel,rules:se,helperText:a!=null&&a.supportChannel?ke[a.supportChannel.type]:void 0})))),t.createElement("div",{className:l.selectFieldGroup},t.createElement(b,{variant:"subtitle2",className:l.scheduleTitle},"Campaign schedule"),t.createElement("div",{className:l.selectField},t.createElement(b,{variant:"subtitle2"},y.name),t.createElement("div",{className:l.fieldContainer},t.createElement(M,{control:e,rules:I,name:"detailsStep.campaignStartDate",render:({field:X})=>{var xe;return t.createElement(wn,{utils:Pn},t.createElement(Tn,{...X,autoOk:!0,FormHelperTextProps:{className:l.helperText},inputVariant:"outlined",className:l.select,error:!!(a!=null&&a.campaignStartDate),helperText:(xe=a==null?void 0:a.campaignStartDate)!=null&&xe.type?S[a.campaignStartDate.type]:void 0,onChange:Ge=>{d(Ge),X.onChange(Ge)},open:o,disabled:n||r,InputProps:{readOnly:!0,placeholder:y.placeholder,onClick:()=>s(!0)},onOpen:()=>s(!0),onClose:()=>s(!1)}))}}))),t.createElement("div",{className:l.selectField},t.createElement(b,{variant:"subtitle2"},w.name),t.createElement("div",{className:l.fieldContainer},t.createElement(M,{name:"detailsStep.campaignEndDate",control:e,rules:W,render:({field:X})=>{var xe;return t.createElement(h,{container:!0,direction:"column"},t.createElement(h,{item:!0},t.createElement(wn,{utils:Pn},t.createElement(Tn,{...X,autoOk:!0,FormHelperTextProps:{className:l.helperText},inputVariant:"outlined",className:l.select,error:!!(a!=null&&a.campaignEndDate),helperText:(xe=a==null?void 0:a.campaignEndDate)!=null&&xe.type?$[a.campaignEndDate.type]:void 0,disabled:n||r,onOpen:()=>u(void 0),ToolbarComponent:Ge=>t.createElement(h,{container:!0,direction:"column"},t.createElement(h,{item:!0},t.createElement(ro,{...Ge})),t.createElement(h,{item:!0,className:l.chips},Fm.map(({value:Ze,label:Ma})=>t.createElement(lt,{key:Ma,label:Ma,className:m===Ze?l.chip:void 0,color:m===Ze?"primary":void 0,size:"small",onClick:()=>{c&&(u(Ze),Ge.onChange(c.plus(Ze),!1))},disabled:n||r}))))}))))}})))))},$m=x(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{fontWeight:"bold",color:e.palette.primary.main,marginLeft:"-16px"},levelsContainer:{marginTop:"0",flexDirection:"column"},errorText:{marginTop:e.spacing(3),marginLeft:e.spacing(-2)},formContainer:{width:"100%"}})),Mm=({control:e,disabled:a,isLoading:n,errors:r})=>{const l=$m(),{rules:o,messages:s}=oe.tracks.checks,{checkChips:i}=Zn(),{fields:c,remove:d,append:m}=ct({control:e,name:"tracksStep.checks",rules:{required:!0}}),u=new Set(c.flatMap(({label:E})=>E)),p=i.filter(E=>!u.has(E.label)),v=U(E=>{m(E)},[m]),f=U(E=>{const g=nn(c,y=>y.id===E.id);d(g)},[d,c]);return t.createElement(M,{control:e,rules:o,name:"tracksStep.trackType",render:()=>t.createElement(tt,{error:!!(r!=null&&r.checks),disabled:a||n,variant:"outlined",className:l.formContainer},t.createElement(h,{item:!0,xs:12},t.createElement(h,{container:!0,spacing:4},t.createElement(un,{backend:vn},t.createElement(h,{item:!0,xs:5},t.createElement(Yn,{chips:p,isLoading:n,disabled:a,label:"Campaign Checks"})),t.createElement(h,{item:!0,xs:7},t.createElement(h,{container:!0},t.createElement(h,{item:!0,xs:12,className:l.columnHeader},t.createElement(b,{className:l.subtitle},"Included Checks")),t.createElement(h,{container:!0,item:!0,spacing:5,className:l.levelsContainer},t.createElement(Xn,{chips:c,onDelete:f,onDrop:v,error:!!(r!=null&&r.checks),placeholder:"Drag and drop checks here to include them in this level",disabled:a}))),t.createElement(za,{className:l.errorText},r!=null&&r.checks?s.required:void 0))))))})},Bm=x(()=>({milestoneHeader:{display:"flex",alignItems:"center"},divider:{margin:"20px 0"},helperText:{marginLeft:0},selectContainer:{width:"250px"}})),Gm=({control:e,errors:a,isLoading:n,disabled:r})=>{const l=Bm(),{name:o,description:s,passrate:i}=$a.milestones,{rules:c,messages:d}=oe.milestones.name,{rules:m,messages:u}=oe.milestones.description,{rules:p,messages:v}=oe.milestones.passrate,{fields:f,append:E,remove:g}=ct({control:e,name:"milestonesStep.milestones"}),y=()=>E({milestoneName:"",milestoneDescription:"",milestonePassrate:""});return t.createElement(t.Fragment,null,f.map((w,P)=>t.createElement("div",{key:w.id},P!==0&&t.createElement(qe,{className:l.divider}),t.createElement(h,{container:!0,spacing:1,className:l.milestoneHeader},t.createElement(h,{item:!0,xs:!0},t.createElement(b,{variant:"subtitle2"},o.name),t.createElement(b,{variant:"caption"},o.description),t.createElement(M,{name:`milestonesStep.milestones.${P}.milestoneName`,control:e,defaultValue:"",rules:c,render:({field:L})=>{var R,T,z,G;return t.createElement(K,{...L,FormHelperTextProps:{className:l.helperText},variant:"outlined",fullWidth:!0,placeholder:o.placeholder,disabled:n||r,type:"text",margin:"normal",error:!!((T=(R=a==null?void 0:a.milestones)==null?void 0:R[P])!=null&&T.milestoneName),helperText:(G=(z=a==null?void 0:a.milestones)==null?void 0:z[P])!=null&&G.milestoneName?d[a.milestones[P].milestoneName.type]:o.helperText})}})),P!==0&&!r&&t.createElement(h,{item:!0},t.createElement(Tt,{label:"Remove Milestone",startIcon:t.createElement(gn,null),onClick:()=>g(P),disabled:r}))),t.createElement("div",null,t.createElement(b,{variant:"subtitle2"},s.name),t.createElement(b,{variant:"caption"},s.description),t.createElement(M,{name:`milestonesStep.milestones.${P}.milestoneDescription`,control:e,defaultValue:"",rules:m,render:({field:L})=>{var R,T,z,G;return t.createElement(K,{...L,FormHelperTextProps:{className:l.helperText},variant:"outlined",multiline:!0,minRows:4,fullWidth:!0,placeholder:s.placeholder,disabled:n||r,type:"text",margin:"normal",error:!!((T=(R=a==null?void 0:a.milestones)==null?void 0:R[P])!=null&&T.milestoneDescription),helperText:(G=(z=a==null?void 0:a.milestones)==null?void 0:z[P])!=null&&G.milestoneDescription?u[a.milestones[P].milestoneDescription.type]:s.helperText})}})),t.createElement("div",null,t.createElement(b,{variant:"subtitle2"},i.name),t.createElement(b,{variant:"caption"},i.description),t.createElement("div",{className:l.selectContainer},t.createElement(M,{name:`milestonesStep.milestones.${P}.milestonePassrate`,control:e,defaultValue:"",rules:p,render:({field:L})=>{var R,T,z,G;return t.createElement(K,{...L,FormHelperTextProps:{className:l.helperText},variant:"outlined",fullWidth:!0,placeholder:i.placeholder,disabled:n||r,type:"number",margin:"normal",error:!!((T=(R=a==null?void 0:a.milestones)==null?void 0:R[P])!=null&&T.milestonePassrate),helperText:(G=(z=a==null?void 0:a.milestones)==null?void 0:z[P])!=null&&G.milestonePassrate?v[a.milestones[P].milestonePassrate.type]:void 0})}}))))),t.createElement(Tt,{label:"Add Milestone",startIcon:t.createElement(hn,null),onClick:()=>y(),disabled:r}))},Vm=_(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},buttonChoices:{margin:"20px 0","& button":{marginRight:"10px"}}})),qm=({title:e,open:a})=>{const n=Vm(),{hideModal:r,isLoading:l,isReadOnly:o}=ua(),[s,i]=C(0),[c,d]=C(je()),m=async w=>{const P=Cm[s];await w(P)&&i(L=>L+1)},u=()=>{i(w=>w-1)},{control:p,handleSubmit:v,errors:f,trigger:E,onSubmit:g}=Lm(),y=[{label:"Enter campaign details",content:()=>t.createElement(Am,{control:p,isLoading:l,disabled:!1,errors:f.detailsStep})},{label:"Add checks",content:()=>t.createElement(Mm,{control:p,isLoading:l,disabled:!1,errors:f.tracksStep})},{label:"Choose Affected Entities",content:()=>t.createElement(t.Fragment,null,t.createElement("text",null,$a.filter.description),t.createElement(Ca,{value:c,onChange:w=>d(w),disabled:!1}))},{label:"Set campaign milestones",content:()=>t.createElement(Gm,{control:p,isLoading:l,disabled:!1,errors:f.milestonesStep})}];return t.createElement(Ke,{handleClose:r,title:e,open:a},t.createElement("form",{onSubmit:v(g)},t.createElement(h,{container:!0,spacing:2,className:n.root},t.createElement(h,{item:!0,xs:9},t.createElement(nt,{className:n.card},t.createElement(Vr,{activeStep:s,orientation:"vertical"},y.map((w,P)=>t.createElement(qr,{key:w.label},t.createElement(Hr,null,w.label),t.createElement(_r,null,w.content(),t.createElement(k,{className:n.buttonChoices,sx:{mb:2}},t.createElement("div",null,t.createElement(V,{variant:"contained",onClick:async()=>{await m(E)}},P===y.length-1?"Save":"Next"),P!==0&&t.createElement(V,{onClick:u},"Back"))))))))),t.createElement(h,{item:!0,xs:3},t.createElement(Im,null))),t.createElement(h,{container:!0,spacing:4,className:n.root},t.createElement(gt,{onCancel:r,saveButtonText:"Save Campaign",isLoading:l,onSave:o?void 0:v(g)}))))},Hm=()=>{const{hideModal:e,showAddModal:a,setIsLoading:n}=ua(),{mutateAsync:r,isLoading:l}=jn();return F(()=>{n(l)},[n,l]),t.createElement(qm,{title:"Create a Campaign",open:a,onSave:async o=>{await r(o,{onSuccess:()=>e()})}})},_m=()=>{const[e]=Ht(),a=e.get("campaignsPerPage"),n=a?parseInt(a,10):9;return t.createElement("div",null,t.createElement(xm,{campaignsPerPage:n}),t.createElement(Hm,null))},zm=()=>t.createElement(Eo,null,t.createElement(_m,null)),hr=()=>{const e=pe(),a=ae(nl),{campaignId:n}=_t();return t.createElement(Ke,{title:"Campaign Detail View",open:!0,handleClose:()=>e(a())},t.createElement("div",null,"Campaign: ",n),t.createElement("div",null,"Placeholder"))},Wm="Error Updating Track";function Um(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.updateProgram(l);if(!o)throw new Error("Failed to update track.");return o};return ce([de.UpdateProgram],r,{onSuccess:async()=>{await a.invalidateQueries({queryKey:[D.GetAllPrograms]})},onError:l=>{let o="Failed to update track.";l instanceof Error&&(o=l.message),n({severity:"error",title:Wm,message:o})}})}const Km=({track:e,canEdit:a})=>{const{setSelectedItem:n,setIsLoading:r,selectedItem:l,showReadOnlyModal:o}=Le(),{mutateAsync:s,isLoading:i}=Um();F(()=>r(i),[r,i]);const c=!a||!e.isEditable;F(()=>{c?o(e):n(e)},[e,n,c,o]);const[d,m]=ia(rl),u=U(async p=>{await s(p,{onSuccess:m})},[m,s]);return F(()=>{},[e,o,c]),l?t.createElement(Jn,{handleClose:d,title:`${c?"View":"Edit"} Track`,open:!0,onSave:u}):null},jm=x({warningPanel:{padding:"24px 24px 0 24px"}}),gr=({entityName:e,entityId:a,showNotFound:n=!1,showCannotView:r=!1})=>{const{warningPanel:l}=jm();return t.createElement(t.Fragment,null,n&&t.createElement("div",{className:l},t.createElement(qa,{title:`${pl(e)} not found`,message:`There is no ${e} with the requested id: ${a}.`})),r&&t.createElement("div",{className:l},t.createElement(qa,{title:`Cannot view ${e}`,message:`User does not have permission to view ${e} id: ${a}.`})))},Qm=()=>{var e,a;const{trackId:n}=_t(),{data:r,isLoading:l}=sa([n!=null?n:""],1),o=(a=(e=r==null?void 0:r.edges)==null?void 0:e[0])==null?void 0:a.program,{loading:s,allowed:i}=Q({permission:on,resourceRef:n}),{loading:c,allowed:d}=Q({permission:wl,resourceRef:n});return t.createElement(t.Fragment,null,t.createElement(gr,{entityName:"track",entityId:n,showNotFound:!l&&!o,showCannotView:!s&&!c&&!d}),l||s||c?t.createElement(Ra,null):d&&o&&t.createElement(Sn,null,t.createElement(Km,{track:o,canEdit:i})))},Ym=({check:e})=>{const{selectedItem:a,showReadOnlyModal:n}=ve();F(()=>{n(e)},[e,n]);const[r]=ia(Za);return a&&t.createElement(ka,{title:"Check Details",open:!0,onClose:r,onSave:()=>{}})},Xm="Error Creating Check";function Zm(){const e=O(A),a=ie(),{showAlert:n}=me(),r=async l=>{const o=await e.updateCheck(l);if(!o)throw new Error("Failed to update check.");return o};return ce([de.UpdateCheck],r,{onSuccess:()=>{a.invalidateQueries({queryKey:[D.GetChecks]})},onError:l=>{let o="Failed to update check.";l instanceof Error&&(o=l.message),n({severity:"error",title:Xm,message:o})}})}const Jm=({check:e})=>{const{selectedItem:a,setSelectedItem:n}=ve(),{setIsLoading:r}=ve(),{mutateAsync:l,isLoading:o}=Zm();F(()=>{r(o)},[r,o]),F(()=>{n(e)},[e,n]);const[s,i]=ia(Za);return a&&t.createElement(ka,{title:"Edit a Check",open:!0,onClose:s,onSave:async c=>{await l(c,{onSuccess:i})}})},ed=()=>{var e,a;const{checkId:n}=_t(),{data:r,isLoading:l}=ht([n!=null?n:""],1),o=(a=(e=r==null?void 0:r.edges)==null?void 0:e[0])==null?void 0:a.checker,{loading:s,allowed:i}=Q({permission:ln,resourceRef:n}),{loading:c,allowed:d}=Q({permission:Tl,resourceRef:n}),m=s||c||l,u=i&&(o==null?void 0:o.isEditable);return t.createElement(t.Fragment,null,t.createElement(gr,{entityName:"check",entityId:n,showCannotView:!m&&!d,showNotFound:!m&&!o}),m&&t.createElement(Ra,null),t.createElement(Ln,null,!m&&!!o&&t.createElement(t.Fragment,null,u&&d&&t.createElement(Jm,{check:o}),!u&&d&&t.createElement(Ym,{check:o}))))},td=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"}}})),ad=({title:e="Soundcheck"})=>{var a;const n=td(),[r,l]=Kr(),{group:o}=r,[s,i]=C(void 0),c=(a=O(Jr).getOptionalBoolean("soundcheck.campaigns.enable"))!=null?a:!1,{loading:d,allowed:m}=Q({permission:Pl}),u=v=>{v&&l({...r,group:v})},p=Ba();return t.createElement(ll,null,t.createElement(jr,null,t.createElement(ol,null,t.createElement(sl,null,t.createElement(k,{className:n.root},t.createElement(br,{themeId:"tool"},t.createElement(wr,{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(Cr,{title:e},p.pathname.split("/").length-1===1&&t.createElement(Qr,{onChange:u,initialValue:o,setError:i})),t.createElement(k,{className:n.pageContent},t.createElement(k,{className:n.pageLayout},t.createElement(Ga,null,t.createElement(Pe,{path:"/*",element:t.createElement(Z,null,t.createElement(Z.Route,{title:"Overview",path:"/"},t.createElement("div",{className:n.tabContent},t.createElement(Yr,{groupSelectorError:s,searchParams:r,setSearchParams:l}))),t.createElement(Z.Route,{title:"Tech Health",path:"/tech-health"},t.createElement(Uc,null)),c&&t.createElement(Z.Route,{title:"Campaign Library",path:"/campaigns"},t.createElement(zm,null)),t.createElement(Z.Route,{title:"Check Library",path:"/checks"},t.createElement(Ls,null)),t.createElement(Z.Route,{title:"Track Library",path:"/tracks"},t.createElement(ri,null)),!d&&m&&t.createElement(Z.Route,{title:"Collector Library",path:"/collectors"},t.createElement(dm,null)))}),t.createElement(Pe,{element:t.createElement(hr,null),path:"/campaigns/:campaignId"}),t.createElement(Pe,{element:t.createElement(hr,null),path:"/campaigns/:campaignId/edit"}),t.createElement(Pe,{element:t.createElement(Qm,null),path:"/tracks/:trackId"}),t.createElement(Pe,{element:t.createElement(ed,null),path:"/checks/:checkId"}))))))))))};export{ad as RoutingPage};
2
+ //# sourceMappingURL=index-927a757e.esm.js.map