@spotify/backstage-plugin-soundcheck 0.5.0 → 0.6.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.
@@ -0,0 +1,2 @@
1
+ import t,{useState as v,useEffect as D,useCallback as G,createContext as $e,useContext as Me,useMemo as j,useReducer as we}from"react";import{useSearchParams as Ve,useLocation as Ft,Routes as $t,Route as Mt}from"react-router-dom";import{MarkdownContent as Vt,Link as Bt,DismissableBanner as Gt,Page as zt,Header as Wt,TabbedLayout as fe}from"@backstage/core-components";import{SpotifyLicenseBanner as qt}from"@spotify/backstage-plugin-core";import{Box as I,Paper as Ne,Grid as u,Button as A,Slide as Kt,Dialog as Ut,AppBar as Ht,Toolbar as jt,Typography as C,IconButton as he,TextField as z,Collapse as _t,makeStyles as k,ButtonGroup as Be,Menu as Ge,MenuItem as ye,FormControl as Qt,InputLabel as Jt,Select as Yt,FormControlLabel as Zt,Checkbox as Xt,Card as Le,ListItemIcon as Y,ListItemText as _,withStyles as ze,CardContent as We,CardHeader as ea,Divider as ta,CardActions as aa,List as be,ListItem as Z,Tooltip as X,InputAdornment as qe,NativeSelect as Se,Chip as Pe,CircularProgress as na}from"@material-ui/core";import{makeStyles as ee,createStyles as Ke}from"@material-ui/core/styles";import{a as ra,b as Ue,u as la,U as oa,G as sa,O as ia}from"./OverviewPageContent-6a667a18.esm.js";import He from"@material-ui/icons/Close";import{Controller as Ee,useWatch as je,useForm as ca}from"react-hook-form";import da from"@material-ui/icons/AddCircleOutline";import ma from"@material-ui/icons/ArrowDropDown";import _e from"@material-ui/icons/Delete";import{useApi as R,alertApiRef as pa}from"@backstage/core-plugin-api";import{useQuery as te,useQueryClient as ae,useMutation as ne}from"@tanstack/react-query";import{s as M,Q as F,k as Q,M as re,l as Ce,m as ua,S as ga,w as ha}from"./index-104979d0.esm.js";import{asArray as Ea,parseFactRef as Te,stringifyFactRef as va,soundcheckCheckUpdatePermission as fa,soundcheckCheckDeletePermission as ya,soundcheckCheckCreatePermission as ba,soundcheckTrackUpdatePermission as Ca,soundcheckTrackDeletePermission as ka,soundcheckTrackCreatePermission as xa}from"@spotify/backstage-plugin-soundcheck-common";import{Autocomplete as Qe,Skeleton as Je}from"@material-ui/lab";import wa from"@material-ui/icons/CheckBox";import Na from"@material-ui/icons/CheckBoxOutlineBlank";import La from"@material-ui/icons/ExpandMore";import{catalogApiRef as Sa,EntityRefLink as Ye}from"@backstage/plugin-catalog-react";import"@backstage/catalog-model";import{v4 as Ze}from"uuid";import Pa from"@material-ui/icons/MoreVert";import Xe from"@material-ui/icons/Group";import{usePermission as le}from"@backstage/plugin-permission-react";import Ta from"@material-ui/icons/Search";import{useDrag as Da,useDrop as Ia,DndProvider as Aa}from"react-dnd";import{HTML5Backend as Ra}from"react-dnd-html5-backend";import Oa from"@material-ui/icons/OpenInNew";import Fa from"@material-ui/icons/DoneAllRounded";import $a from"@material-ui/icons/Menu";import et from"@material-ui/icons/DragIndicator";import Ma from"@material-ui/icons/Visibility";import Va from"@material-ui/icons/Add";import Ba from"@material-ui/icons/Remove";import"@material-ui/lab/Autocomplete";import"react-use/lib/useAsync";import"./RefetchingIndicator-b344d8b2.esm.js";import"react-use/lib/useDebounce";import"lodash";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/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function Ga(e,n,a){const r=R(M);return te([F.GetAllPrograms,e,n,a],async()=>r.getAllPrograms(e,n,a))}function za(e){const n=R(M);return te([F.GetAllPrograms,e],async()=>n.getAllPrograms([e]))}const Wa="Error Creating Track";function qa(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.createProgram(l);if(!o)throw new Error("Failed to create track.");return o};return ne([re.CreateProgram],r,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[F.GetAllPrograms]})},onError:l=>{let o="Failed to create track.";l instanceof Error&&(o=l.message),a({severity:"error",title:Wa,message:o})}})}function tt(e,n,a){const r=R(M);return te([F.GetChecks,e,n,a],async()=>r.getChecks(e,n,a))}const Ka=e=>{const[n,a]=v(void 0),[r,l]=v([[]]),[o,s]=v([!1]);D(()=>{n===void 0&&e!=null&&e.length&&a(e)},[e,n]);const c=G((h,g)=>{l(E=>{const f=[...E];return f[g]=[...f[g],h],f}),a(E=>E==null?void 0:E.filter(f=>f.id!==h.id)),s(E=>{if(E[g]){const f=[...E];return f[g]=!1,f}return E})},[]),d=G((h,g)=>{l(E=>{const f=[...E];return f[g]=f[g].filter(x=>x.id!==h.id),f}),a(E=>[...E!=null?E:[],h])},[]),m=G(()=>{l(h=>[...h,[]]),s(h=>[...h,!1])},[]),p=G(h=>{r.length>1&&l(g=>{const E=[...g],f=E.splice(h,1)[0];return a(x=>[...x!=null?x:[],...f]),E})},[r]),i=G(()=>{const h=r.map(g=>g.length===0);return s(h),!h.some(g=>g)},[r]);return{chips:n,inputChipsList:r,handleDrop:c,handleDelete:d,addInput:m,removeInput:p,inputErrors:o,setInputErrors:s,areInputsValid:i,setInputChipsList:l}},Ua=ee(e=>({box:{zIndex:9,position:"fixed",bottom:"0",width:"100%"},footer:{padding:e.spacing(2)}})),at=({onCancel:e,saveButtonText:n,isLoading:a,onSave:r,disableSave:l})=>{const o=Ua();return t.createElement(I,{className:o.box},t.createElement(Ne,{elevation:3,className:o.footer},t.createElement(u,{container:!0,item:!0,spacing:2,justifyContent:"space-between"},t.createElement(u,{item:!0},t.createElement(A,{variant:"contained",color:"primary",onClick:e},"Cancel")),t.createElement(u,{item:!0},r&&t.createElement(A,{variant:"contained",color:"primary",disabled:a||l,onClick:r?()=>r():void 0},n)))))},nt=$e({selectedProgram:null,setSelectedProgram:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{}}),Ha=({children:e})=>{const[n,a]=v(null),[r,l]=v(!1),[o,s]=v(!1);return t.createElement(nt.Provider,{value:{selectedProgram:n,setSelectedProgram:a,isLoading:r,setIsLoading:l,showAddModal:o,setShowAddModal:s}},e)},oe=()=>Me(nt),rt=$e({selectedCheck:null,setSelectedCheck:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{},isReadOnly:!1,showReadOnlyModal:()=>{},hideModal:()=>{}}),ja=({children:e})=>{const[n,a]=v(null),[r,l]=v(!1),[o,s]=v(!1),[c,d]=v(!1),m=i=>{l(!0),a(i)},p=()=>{a(null),l(!1),d(!1)};return t.createElement(rt.Provider,{value:{selectedCheck:n,setSelectedCheck:a,isLoading:o,setIsLoading:s,showAddModal:c,setShowAddModal:d,isReadOnly:r,showReadOnlyModal:m,hideModal:p}},e)},W=()=>Me(rt),_a=ee(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),overflowX:"hidden",backgroundColor:e.palette.type==="dark"?"#333":e.palette.common.white}})),Qa=t.forwardRef(function(e,n){return t.createElement(Kt,{direction:"up",ref:n,...e})}),lt=({open:e,handleClose:n,title:a,children:r})=>{const l=_a();return t.createElement(Ut,{fullScreen:!0,open:e,onClose:n,TransitionComponent:Qa},t.createElement(Ht,{className:l.appBar},t.createElement(jt,null,t.createElement(C,{className:l.title},a),t.createElement(he,{edge:"end",color:"inherit",onClick:n,"aria-label":"close",className:l.closeIcon},t.createElement(He,null)))),t.createElement(I,{className:l.content},r))},ve=({name:e,control:n,error:a,label:r,placeholder:l,disabled:o,rules:s,messages:c,helperText:d,multiline:m,minRows:p})=>t.createElement(Ee,{name:e,control:n,defaultValue:"",rules:s,render:({field:i})=>t.createElement(z,{...i,fullWidth:!0,multiline:m,minRows:p,placeholder:l,label:r,disabled:o,variant:"outlined",margin:"normal",error:!!a,helperText:a&&c?c[a.type]:d})}),Ja=ee(()=>({section:{gap:0}})),Ya=({control:e,error:n,isLoading:a,disabled:r})=>{const l=Ja();return t.createElement("div",{className:l.section},t.createElement(ve,{name:"checkName",control:e,error:n,label:"Check Name",placeholder:"Choose a name",disabled:a||r,rules:{required:!0,maxLength:100},messages:{required:"This field is required",maxLength:"Input must be less than 100 characters"}}))},Za=ee(e=>({root:{display:"flex",flexDirection:"column",gap:0},button:{marginLeft:-e.spacing(1)},title:{fontWeight:700,color:e.palette.primary.main}})),ke=({title:e,children:n})=>{const[a,r]=v(!1),l=Za(),o=()=>{r(!a)};return t.createElement("div",{className:l.root},t.createElement(u,{container:!0,alignItems:"center",spacing:0},t.createElement(u,{item:!0},t.createElement(he,{onClick:o,className:l.button},t.createElement(da,null))),t.createElement(u,{item:!0},t.createElement(C,{className:l.title},e))),t.createElement(_t,{in:a},n))},Xa=({control:e,passError:n,failError:a,isLoading:r,disabled:l})=>t.createElement(ke,{title:l?"Pass and fail messages":"Pass and fail messages (optional)"},t.createElement(ve,{name:"passMessage",control:e,error:n,label:"Pass Message",placeholder:"Enter pass message...",disabled:r||l}),t.createElement(ve,{name:"failMessage",control:e,error:a,label:"Fail Message",placeholder:"Enter fail message...",disabled:r||l})),en=({control:e,error:n,isLoading:a,disabled:r})=>t.createElement(ve,{name:"description",control:e,error:n,label:"Check Description",disabled:a||r,multiline:!0,minRows:4,placeholder:r?void 0:"Enter a brief description about the check",helperText:r?void 0:"Enter a brief description about the check",rules:{required:!0,maxLength:500},messages:{required:"This field is required",maxLength:"Description must be less than 500 characters"}}),tn=k(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"}})),an=({onAddCondition:e,onAddExpression:n})=>{const a=tn(),[r,l]=v(null),o=!!r,s=d=>{l(d.currentTarget)},c=()=>{l(null)};return t.createElement(I,null,t.createElement(Be,{color:"primary"},t.createElement(A,{id:"add-button",className:a.button,"aria-controls":o?"add-menu":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:s},t.createElement(I,{className:a.label},"Add"),t.createElement(I,{className:a.icon},t.createElement(ma,null)))),t.createElement(Ge,{id:"add-menu",anchorEl:r,open:o,onClose:c,classes:{paper:a.menu},MenuListProps:{"aria-labelledby":"add-button"}},t.createElement(ye,{onClick:()=>{e(),c()}},"Add Condition"),t.createElement(ye,{onClick:()=>{n(),c()}},"Add Expression")))},ot=({name:e,control:n,selectLabel:a,options:r,disabled:l})=>t.createElement(Ee,{name:e,control:n,render:({field:o})=>t.createElement(Qt,{variant:"outlined",style:{minWidth:200}},t.createElement(Jt,{id:`${e}-select-label`},a),t.createElement(Yt,{...o,disabled:l,"data-testid":`${e}-select`,labelId:`${e}-select-label`,label:a},r.map(({value:s,label:c})=>t.createElement(ye,{key:s,value:s},c))))});var H=(e=>(e.AllOf="all",e.AnyOf="any",e))(H||{});const nn={all:"ALL OF",any:"ANY OF"};var st=(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))(st||{});const rn={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"},ln=k(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 on(e){const n=R(M);return te([F.GetCollectors,e],async()=>n.getCollectors(e))}function sn(e,n){const a=R(M);return te([F.GetFactSchema,e,n],()=>a.getFactSchema(e,n),{enabled:!!e&&!!n})}const cn=(e,n,a,r)=>{const l={};return r&&r.forEach(o=>{var s,c;o&&(l[o.id]={id:o.id,name:(s=o.name)!=null?s:o.id,description:(c=o.description)!=null?c:""})}),e.map((o,s)=>{const c=o.map(d=>l[d.id]);return{name:n[s],description:a[s],ordinal:s+1,checks:c}})},dn=e=>e.map(n=>n.checks.map(a=>{var r;return{id:a.id,label:(r=a.name)!=null?r:a.id}})),mn=e=>{var n;return{id:e.id,name:e.name,description:e.description||"",ownerEntityRef:e.ownerEntityRef,documentationURL:e.documentationURL||"",levels:((n=e.levels)==null?void 0:n.map(a=>({ordinal:a.ordinal,name:a.name||"",description:a.description||"",checks:a.checks.map(r=>({id:r.id,name:r.name,description:r.description}))})))||[],filter:e.filter}},De={selectedKinds:"kind",selectedTypes:"spec.type",selectedLifecycles:"spec.lifecycle",selectedOwners:"spec.owner",selectedSystems:"spec.system",selectedTags:"metadata.tags"},it=e=>!e||Object.values(e).every(n=>n.length===0)?void 0:{catalog:Object.entries(e).reduce((n,[a,r])=>{const l=De[a];return r.length>0&&(n[l]=r),n},{})},ct=e=>Object.keys(De).reduce((n,a)=>{var r,l;return n[a]=Ea((l=(r=e==null?void 0:e.catalog)==null?void 0:r[De[a]])!=null?l:[]),n},{}),pn=(e,n)=>{const a=e?dn(e.levels):[[]],r=a.flat().map(o=>o.id),l=n.filter(o=>!r.includes(o.id));return{inputChips:a,used:l}},Ie=e=>{var n,a;if(!e)return{};if(e.expressionType){const r={[e.expressionType]:(n=e.conditions)==null?void 0:n.map(l=>({factRef:l.factRef,path:l.path,operator:l.operator,value:l.value}))};return e.expression&&((a=r[e.expressionType])==null||a.push(Ie(e.expression))),r}if(e.expression)return Ie(e.expression);if(e.conditions&&e.conditions.length===1){const r=e.conditions[0];return{factRef:r.factRef,path:r.path,operator:r.operator,value:r.value}}return{}},dt=(e,n=!0)=>{if(!e)return{factRef:"",path:"",operator:"",value:"",conditions:[]};const a=Object.keys(e),r=a.includes("all")||n&&!a.includes("any")?H.AllOf:H.AnyOf;if(a.includes(r)||n){const l=e[r]||[e],o=[];let s=null;l.forEach(d=>{const m=Object.keys(d);m.includes("all")||m.includes("any")?s=dt(d,!1):o.push({factRef:d.factRef,path:d.path,operator:d.operator,value:d.value,conditions:[]})});const c={factRef:"",path:"",operator:"",value:"",expression:void 0,conditions:o,expressionType:r};return s&&(c.expression=s),c}return{factRef:e.factRef,path:e.path,operator:e.operator,value:e.value,expressionType:H.AllOf,conditions:[]}},un=e=>({checkName:e.name||"",description:e.description||"",teamOwner:e.ownerEntityRef||"",supportChannel:e.supportChannel||"",expression:dt(e.rule),passMessage:e.passedMessage||void 0,failMessage:e.failedMessage||void 0,filters:ct(e.filter)}),Ae=(e,n="$")=>{const a=[];if(e.type==="object"&&e.properties){const r=e.properties;for(const l in r)if(r.hasOwnProperty(l)){const o=`${n}.${l}`;a.push(o);const s=r[l];a.push(...Ae(s,o))}}if(e.type==="array"&&e.items){const r=`${n}[*]`;a.push(r);const l=Array.isArray(e.items)?e.items:[e.items];for(const o of l)a.push(...Ae(o,r))}return a},gn={checkName:"",description:"",teamOwner:"",supportChannel:"",expression:{factRef:"",path:"",operator:"",value:"",expressionType:H.AllOf,conditions:[{factRef:"",path:"",operator:"",value:"",conditions:[]}]},filters:{selectedKinds:[],selectedTypes:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[]}},hn=(e,n)=>{const{data:a}=on(),r=je({control:n,name:`${e}.factRef`}),[l,o]=v(()=>mt(r));D(()=>{o(mt(r))},[r]);const{data:s}=sn(l==null?void 0:l.source,l==null?void 0:l.name),c=j(()=>s?Ae(s.schema):[],[s]),d=j(()=>a==null?void 0:a.flatMap(m=>m.factNames.map(p=>{const i=Te(p,{defaultSource:m.id,defaultScope:"default"});return{label:i.name,value:va(i)}})),[a]);return{pathOptions:c,factRefOptions:d}};function mt(e){if(e)try{return Te(e,{defaultSource:"unknown",defaultScope:"default"})}catch{return null}return null}const pt=({name:e,rules:n,label:a,control:r,options:l,getOptionLabel:o,disabled:s})=>t.createElement(Ee,{name:e,control:r,rules:n,render:({field:c,fieldState:d})=>t.createElement(Qe,{...c,freeSolo:!0,"data-testid":`${e}-autocomplete`,style:{minWidth:250},disabled:s,options:l,getOptionLabel:o,renderInput:m=>t.createElement(z,{...m,variant:"outlined",label:a,error:d.invalid,helperText:d.error?d.error.message:null}),onChange:(m,p)=>c.onChange(p),onInputChange:(m,p)=>c.onChange(p)})}),En=e=>{try{return Te(e),!0}catch{return"Invalid fact reference. [source]:[scope]/[name]."}},vn=({control:e,name:n,handleDelete:a,disabled:r})=>{var l;const o=ln(),s=j(()=>Object.values(st).map(m=>({value:m,label:rn[m]})),[]),{pathOptions:c,factRefOptions:d}=hn(n,e);return t.createElement(I,{className:o.container},t.createElement(I,{className:o.connector}),t.createElement(I,{className:o.innerContainer},t.createElement(I,{className:o.header}),t.createElement(I,{className:o.inputsContainer},t.createElement(pt,{name:`${n}.factRef`,control:e,rules:{required:!0,maxLength:500,validate:En},label:"Fact",options:(l=d==null?void 0:d.map(m=>m.value))!=null?l:[],getOptionLabel:m=>{var p,i;return(i=(p=d==null?void 0:d.find(h=>m===h.value))==null?void 0:p.label)!=null?i:m},disabled:r}),t.createElement(pt,{name:`${n}.path`,label:"Path",control:e,disabled:r,options:c}),t.createElement(ot,{name:`${n}.operator`,control:e,selectLabel:"Operator",options:s,disabled:r}),t.createElement(Ee,{name:`${n}.value`,control:e,defaultValue:"",render:({field:m})=>t.createElement(z,{...m,label:"Value",variant:"outlined",placeholder:"Enter a value",disabled:r})}))),!r&&t.createElement(he,{onClick:a,className:o.deleteButton,"data-test-id":`${n}-delete-button`},t.createElement(_e,{className:o.deleteIcon})))},fn=({conditions:e,control:n,name:a,handleDelete:r,disabled:l,setValue:o})=>t.createElement(t.Fragment,null,e.filter(s=>!s.expressionType).map((s,c)=>t.createElement(u,{item:!0,key:c},t.createElement(vn,{control:n,name:`${a}.conditions[${c}]`,"data-testid":`${a}-condition-input`,handleDelete:()=>r(c),disabled:l,setValue:o})))),yn=({expression:e,control:n,name:a,depth:r,getValues:l,setValue:o,trigger:s,disabled:c})=>e?t.createElement(u,{item:!0},t.createElement(ut,{control:n,name:`${a}.expression`,depth:r+1,getValues:l,setValue:o,trigger:s,disabled:c})):null,bn=k(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)"}})),Cn=({control:e,name:n,getValues:a,disabled:r})=>{const l=bn(),o=`${n}`,s=a(o),[c,d]=v(s||H.AllOf),m=p=>{d(p)};return t.createElement(Ee,{control:e,name:n,render:({field:{onChange:p}})=>t.createElement(Be,{color:"primary"},Object.values(H).map(i=>t.createElement(A,{key:i,className:c===i?`${l.selectedButton} ${l.button}`:`${l.button}`,onClick:()=>{m(i),p(i)},disabled:r},nn[i])))})},kn=(e,n,a,r)=>({handleAddCondition:async()=>{const l=`${e}`,o=n(l),s=[...(o==null?void 0:o.conditions)||[],{factRef:"",path:"",operator:"",value:""}],c=`${e}.conditions`;a(c,s),await r(c)},handleAddExpression:async()=>{a(`${e}.expression`,{factRef:"",path:"",operator:"",value:"",expressionType:H.AllOf,conditions:[{factRef:"",path:"",operator:"",value:""}]}),await r(`${e}.expression`)},handleDeleteCondition:async l=>{const o=`${e}`,s=[...n(o).conditions||[]];if(s.splice(l,1),s.length===0)a(o,void 0);else{const c=`${e}.conditions`;a(c,s)}await r(o)}}),xn=ee(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"}})),ut=({control:e,name:n,depth:a,getValues:r,setValue:l,trigger:o,disabled:s})=>{const c=xn(),{handleAddCondition:d,handleAddExpression:m,handleDeleteCondition:p}=kn(n,r,l,o),i=`${n}`,h=r(i),g=(h==null?void 0:h.conditions)||[],E=h==null?void 0:h.expression;return t.createElement(I,{className:a>0?c.inner:c.root},a>0&&t.createElement(I,{className:c.connector}),t.createElement(u,{container:!0,spacing:0,direction:"column"},t.createElement(u,{item:!0},t.createElement(Cn,{control:e,disabled:s,name:`${n}.expressionType`,getValues:r})),t.createElement(u,{item:!0,container:!0,spacing:0,direction:"column"},t.createElement(fn,{handleDelete:p,disabled:s,conditions:g,control:e,name:n,setValue:l}),t.createElement(yn,{expression:E,control:e,name:n,depth:a,getValues:r,setValue:l,trigger:o,disabled:s})),!s&&t.createElement(u,{item:!0},t.createElement(an,{onAddCondition:d,onAddExpression:m}))))},wn=({control:e,supportContactError:n,disabled:a,isLoading:r,options:l})=>{var o;return t.createElement(ke,{title:a?"Team details":"Team details (optional)"},t.createElement(ot,{name:"teamOwner",control:e,selectLabel:"Check owner",options:(o=l==null?void 0:l.map(s=>({value:s.ref,label:s.name})))!=null?o:[],disabled:a||r}),t.createElement(ve,{name:"supportChannel",control:e,error:n,label:"Support channel",placeholder:"Enter a channel or email to get check support",disabled:a||r,rules:{},messages:{}}))},gt=[{facet:"kind",label:"Kind",stateKey:"selectedKinds"},{facet:"spec.type",label:"Type",stateKey:"selectedTypes"},{facet:"spec.lifecycle",label:"Lifecycle",stateKey:"selectedLifecycles"},{facet:"spec.owner",label:"Owner",stateKey:"selectedOwners"},{facet:"spec.system",label:"System",stateKey:"selectedSystems"},{facet:"metadata.tags",label:"Tags",stateKey:"selectedTags"}],Nn=e=>{const n=R(pa),a=R(Sa);return te([F.GetEntityFacets,e],async()=>{var r;return((r=(await a.getEntityFacets({facets:[e]})).facets[e])==null?void 0:r.map(l=>l.value).sort())||[]},{onError:()=>{n.post({message:`Failed to load facet: ${e}`,severity:"error"})}})},Ln=k({formControl:{flexGrow:1}}),ht=({facet:e,label:n,values:a,onChange:r,disabled:l})=>{const o=Ln(),{data:s,error:c}=Nn(e),d=j(()=>s==null?void 0:s.map(i=>i.toLocaleLowerCase("en-US")),[s]),m=G((i,h)=>{r(d&&d.every(g=>h.includes(g))?void 0:h)},[d,r]),p=G(()=>{r(a!=null&&a.length?a:void 0)},[a,r]);return!(s!=null&&s.length)||!(d!=null&&d.length)||c?t.createElement(C,{color:"error"},"Failed to load facet: ",e):t.createElement(I,{pb:1,pt:1},t.createElement(C,{variant:"subtitle2"},n),t.createElement(Qe,{className:o.formControl,multiple:!0,limitTags:4,disableCloseOnSelect:!0,"aria-label":n,options:d,value:a!=null?a:[],getOptionLabel:i=>{var h;return(h=s[d.indexOf(i)])!=null?h:i},onChange:m,onBlur:p,disabled:l,renderOption:(i,{selected:h})=>{var g;return t.createElement(Zt,{control:t.createElement(Xt,{icon:t.createElement(Na,{fontSize:"small"}),checkedIcon:t.createElement(wa,{fontSize:"small"}),checked:h}),label:(g=s[d.indexOf(i)])!=null?g:i})},size:"small",popupIcon:t.createElement(La,{"data-testid":"selected-facets-expand"}),renderInput:i=>t.createElement(z,{...i,variant:"outlined"})}))},Sn=k(e=>({title:{fontWeight:700},container:{padding:e.spacing(0,1.5)},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)}})),Pn=({control:e,setFilters:n,disabled:a})=>{const r=Sn(),l=je({control:e,name:"filters",defaultValue:{selectedKinds:[],selectedTypes:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[]}}),o=s=>c=>{n(s,c)};return t.createElement(ke,{title:a?"Filters":"Filters (optional)"},t.createElement(u,{className:r.container,item:!0,xs:12},t.createElement(C,{variant:"body2"},"Apply filters so it's only applicable to relevant entities."),t.createElement(u,{item:!0,xs:12},t.createElement(Ne,null,t.createElement(u,{container:!0,className:r.filterContainer,spacing:2},gt.map(s=>t.createElement(u,{item:!0,xs:12,sm:6,md:4,key:s.stateKey},t.createElement(ht,{facet:s.facet,label:s.label,values:l==null?void 0:l[s.stateKey],onChange:o(s.stateKey),disabled:a}))))))))},Tn=({control:e,setValue:n,trigger:a,disabled:r})=>t.createElement(Pn,{control:e,setFilters:async(l,o)=>{n(`filters.${l}`,o!=null?o:[]),await a(`filters.${l}`)},disabled:r}),Dn=e=>{const{selectedCheck:n}=W();let a=gn;n&&(a=un(n));const{control:r,handleSubmit:l,getValues:o,setValue:s,trigger:c,formState:{errors:d}}=ca({defaultValues:a}),{showModal:m}=Ce();function p(i){var h,g,E,f,x;if(i===void 0)return!1;let L=!0;if((h=i.conditions)!=null&&h.length&&((g=i.conditions)==null?void 0:g.length)>0)for(const S in i.conditions)i.conditions.hasOwnProperty(S)&&(L=L&&p((E=i.conditions)==null?void 0:E[S]));return i.expression&&(L=L&&p(i.expression)),L?!!(i.value!==""&&i.path!==""&&i.factRef!==""&&i.operator!==""||(f=i.conditions)!=null&&f.length&&((x=i.conditions)==null?void 0:x.length)>0||i.expression!==void 0):!1}return{control:r,handleSubmit:l,getValues:o,setValue:s,trigger:c,errors:d,onSubmit:async i=>{var h,g,E,f,x,L,S,w;const N=o();let P=p(N.expression);if((g=(h=N.expression)==null?void 0:h.conditions)!=null&&g.length&&(P=P&&((f=(E=N.expression)==null?void 0:E.conditions)==null?void 0:f.length)>0),!P){await m({title:"Invalid Rule(s)",message:"The check is invalid as it is either missing a rule or a rule is missing a value.",error:!0});return}if(!await m({title:"Save Check",message:`Are you sure you want to save check: ${i.checkName}?`,error:!1}))return;const T={id:n?n.id:Ze(),ownerEntityRef:(x=i.teamOwner)!=null?x:void 0,name:i.checkName,description:i.description,passedMessage:(L=i.passMessage)!=null?L:void 0,failedMessage:(S=i.failMessage)!=null?S:void 0,rule:Ie(i.expression),filter:i.filters?it(i.filters):void 0,supportChannel:(w=i.supportChannel)!=null?w:void 0};e(T)}}},In=()=>t.createElement("div",{style:{display:"flex",gap:"10px",flexDirection:"column"}},t.createElement(C,{variant:"h6"},"Creating and managing checks"),t.createElement(C,{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(C,{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(C,{variant:"body1"},"Once created, you will be able to manage and edit your track on its detail page.")),Et=ee(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}})),Re=({title:e,open:n,onSave:a})=>{const r=Et(),{hideModal:l,isLoading:o,isReadOnly:s}=W(),{control:c,handleSubmit:d,getValues:m,setValue:p,trigger:i,errors:h,onSubmit:g}=Dn(a),{options:E}=ra();return t.createElement(lt,{handleClose:l,title:e,open:n},t.createElement("form",{onSubmit:d(g)},t.createElement(u,{container:!0,spacing:2,className:r.root},t.createElement(u,{item:!0,xs:9},t.createElement(Le,{className:r.card},t.createElement(C,{className:r.sectionLabel,style:{margin:0}},"Check Details"),t.createElement(Ya,{control:c,error:h.checkName,isLoading:o,disabled:s}),t.createElement(en,{control:c,error:h.description,isLoading:o,disabled:s}),t.createElement(wn,{control:c,disabled:s,isLoading:o,options:E}),t.createElement(C,{className:r.sectionLabel},"Rules"),t.createElement(ut,{control:c,getValues:m,setValue:p,trigger:i,disabled:s,name:"expression",depth:0}),t.createElement(Tn,{control:c,setValue:p,trigger:i,disabled:s}),t.createElement(Xa,{control:c,passError:h.passMessage,failError:h.failMessage,isLoading:o,disabled:s}))),t.createElement(u,{item:!0,xs:3},t.createElement(In,null))),t.createElement(u,{container:!0,spacing:4,className:r.root},t.createElement(at,{onCancel:l,saveButtonText:"Save Check",isLoading:o,onSave:s?void 0:d(g)}))))},An="Error Creating Check";function Rn(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.updateCheck(l);if(!o)throw new Error("Failed to update check.");return o};return ne([re.UpdateCheck],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[F.GetChecks]})},onError:l=>{let o="Failed to update check.";l instanceof Error&&(o=l.message),a({severity:"error",title:An,message:o})}})}const On=()=>{const{selectedCheck:e,hideModal:n}=W(),{setIsLoading:a}=W(),{mutateAsync:r,isLoading:l}=Rn();return D(()=>{a(l)},[a,l]),t.createElement(Re,{title:"Edit a Check",open:!!e,onSave:async o=>{await r(o)&&n()}})},Fn="Error Creating Check";function $n(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.createCheck(l);if(!o)throw new Error("Failed to create check.");return o};return ne([re.CreateCheck],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[F.GetChecks]})},onError:l=>{let o="Failed to create check.";l instanceof Error&&(o=l.message),a({severity:"error",title:Fn,message:o})}})}const Mn=()=>{const{hideModal:e,showAddModal:n,setIsLoading:a}=W(),{mutateAsync:r,isLoading:l}=$n();return D(()=>{a(l)},[a,l]),t.createElement(Re,{title:"Create a Check",open:n,onSave:async o=>{await r(o)&&e()}})},Vn=({handleDelete:e})=>{const[n,a]=v(null),r=!!n,l=s=>{s.stopPropagation(),a(s.currentTarget)},o=s=>{s.stopPropagation(),a(null)};return t.createElement(t.Fragment,null,t.createElement(he,{"aria-label":"summary-card-actions",id:"summary-card-action-menu-button","aria-controls":r?"summary-card-action-menu":void 0,"aria-expanded":r?"true":void 0,"aria-haspopup":"true",onClick:l},t.createElement(Pa,null)),t.createElement(Ge,{id:"summary-card-action-menu",anchorEl:n,open:r,onClose:o,getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{"aria-labelledby":"summary-card-action-menu-button"}},e&&t.createElement(ye,{"data-testid":"summary-card-action-delete",onClick:s=>{e(s),o(s)}},t.createElement(Y,null,t.createElement(_e,{fontSize:"small"})),t.createElement(_,null,"Delete"))))},Bn=ze(e=>Ke({root:{width:"100%",height:"100%",minHeight:"385px",display:"flex",flexDirection:"column",padding:e.spacing(2),position:"relative"}}))(Le),Gn=ze(()=>Ke({root:{display:"flex",flexDirection:"column",flex:1,gap:"3px"}}))(We),zn=k(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},summaryName:{fontSize:e.typography.pxToRem(24),color:e.palette.primary.main,maxHeight:"75px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical","-webkit-line-clamp":2,"-webkit-box-orient":"vertical",wordBreak:"break-word"},summaryDescription:{maxHeight:"150px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical",wordBreak:"break-word"}})),vt=({title:e,description:n,children:a,handleDelete:r,handleEdit:l,handleView:o})=>{const s=zn();return t.createElement(Bn,null,t.createElement("div",{className:s.summaryName},t.createElement(ea,{title:e,action:r&&t.createElement(Vn,{handleDelete:r})})),t.createElement(Gn,null,t.createElement("div",{className:s.cardSection},t.createElement("div",{className:s.summaryDescription},t.createElement(Vt,{content:n!=null?n:""}))),a&&t.createElement("div",{className:s.cardSection},a)),t.createElement(ta,null),t.createElement(aa,null,t.createElement(A,{size:"small",color:"primary",role:"link",onClick:l||o},l?"Edit":"View")))},Wn="Error Deleting Check";function qn(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.deleteCheck(l);if(!o)throw new Error(`Failed to delete check ${l}`);return o};return ne([re.DeleteCheck],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[F.GetChecks]})},onError:(l,o)=>{let s=`Failed to delete check ${o}`;l instanceof Error&&(s=l.message),a({severity:"error",title:Wn,message:s})}})}const Kn=k(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Un=({check:e})=>{var n;const a=Kn();return t.createElement(be,{dense:!0,disablePadding:!0,className:a.cardSection},t.createElement(C,{variant:"overline",color:"textSecondary"},"Check Details"),t.createElement(Z,{disableGutters:!0,className:a.listItem},t.createElement(X,{title:"Owner"},t.createElement(Y,null,t.createElement(Xe,{color:"action",fontSize:"small"}))),t.createElement(_,{className:a.listItemText,primary:t.createElement(Ye,{entityRef:(n=e.ownerEntityRef)!=null?n:"No Owner"})})))},Hn=({check:e})=>{const{id:n,name:a,description:r,isEditable:l,ownerEntityRef:o}=e,{loading:s,allowed:c}=le({permission:fa,resourceRef:n}),{loading:d,allowed:m}=le({permission:ya,resourceRef:n}),{showModal:p}=Ce(),{mutate:i}=qn(),{showReadOnlyModal:h,setSelectedCheck:g}=W(),E=G(async()=>{await p({title:"Delete Check",message:`Are you sure you want to delete the check '${a!=null?a:n}'?`})&&i(n)},[p,a,i,n]);return t.createElement(vt,{title:a!=null?a:n,description:r,children:o&&t.createElement(Un,{check:e}),handleView:()=>h(e),handleEdit:l&&!s&&c?()=>g(e):void 0,handleDelete:l&&!d&&m?E:void 0})},jn=()=>t.createElement(t.Fragment,null,Array.from({length:10},(e,n)=>t.createElement(u,{key:`loading-${n}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Je,{variant:"rect",height:385})))),_n=k(()=>({searchIcon:{opacity:".5"},clearButton:{height:"36px",width:"36px"}})),ft=({searchTerm:e,setSearchTerm:n,showClear:a=!0,placeholder:r="Search...",...l})=>{const o=_n(),s=d=>{n(d.target.value)},c=()=>{n("")};return t.createElement(z,{...l,fullWidth:!0,placeholder:r,value:e,onChange:s,InputProps:{startAdornment:t.createElement(qe,{position:"start"},t.createElement(Ta,{className:o.searchIcon,"data-testid":"search-icon"})),endAdornment:a&&e?t.createElement(qe,{position:"end"},t.createElement(he,{edge:"end",onClick:c,className:o.clearButton},t.createElement(He,null))):null}})},Qn=k(()=>({searchbar:{maxWidth:"350px"},filters:{display:"flex",alignItems:"center"},dropdownFilters:{margin:"0 15px",display:"flex",alignItems:"center"},selectHolder:{marginLeft:"10px"}})),yt=({searchPlaceholder:e,isLoading:n,searchTerm:a,setSearchTerm:r,filterAlpha:l,handleAlphabeticalFilterChange:o,filterOwner:s,handleOwnerFilterChange:c,owners:d})=>{const m=Qn();return t.createElement(u,{item:!0,xs:9,className:m.filters},t.createElement(ft,{searchTerm:a,disabled:n,setSearchTerm:r,placeholder:e||"Search",variant:"outlined",size:"small",className:m.searchbar}),t.createElement("div",{className:m.dropdownFilters},t.createElement(C,null,"Sort by: "),t.createElement(Se,{className:m.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:m.dropdownFilters},t.createElement(C,null,"Filter by owner: "),t.createElement(Se,{className:m.selectHolder,value:s,onChange:c},t.createElement("option",{key:"all",value:"all"},"All"),d==null?void 0:d.map((p,i)=>t.createElement("option",{key:p+i,value:p},p)))))},Jn=(e,n)=>e==null?void 0:e.sort((a,r)=>{var l,o,s,c;const d=(o=(l=a==null?void 0:a.name)==null?void 0:l.toLocaleLowerCase())!=null?o:a==null?void 0:a.id.toLocaleLowerCase(),m=(c=(s=r==null?void 0:r.name)==null?void 0:s.toLocaleLowerCase())!=null?c:r==null?void 0:r.id.toLocaleLowerCase();return!d||!m?0:d<m?n==="ascending"?-1:1:d>m?n==="ascending"?1:-1:0}),bt=e=>{const n=e==null?void 0:e.map(a=>a==null?void 0:a.ownerEntityRef).filter(a=>a!=="");return[...new Set(n)]},se=({searchTermProp:e,filterAlphaProp:n,filterOwnerProp:a,checks:r,tracks:l})=>{var o,s;const c=r||l||[],d=(o=c==null?void 0:c.filter)==null?void 0:o.call(c,p=>{var i;return((i=p==null?void 0:p.name)!=null?i:p==null?void 0:p.id).toLocaleLowerCase().includes(e.toLocaleLowerCase())}),m=a&&a!=="all"?(s=d==null?void 0:d.filter)==null?void 0:s.call(d,p=>{var i;return((i=p==null?void 0:p.ownerEntityRef)==null?void 0:i.toLowerCase())===a.toLowerCase()}):d;return n==="default"?m:Jn(m!=null?m:[],n)},Yn=k(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"center"},header:{padding:e.spacing(0,0,1)},pagination:{display:"flex",width:"-webkit-fill-available",justifyContent:"space-between",position:"fixed",bottom:0,marginRight:"40px",backgroundColor:"#424242"},pageTotal:{padding:e.spacing(1),marginLeft:"-20px"}})),Zn=({checksPerPage:e,currentCursor:n})=>{const a=Yn(),[r,l]=v(n),[o,s]=v([]),{data:c,isLoading:d}=tt(void 0,e,r),{loading:m,allowed:p}=le({permission:ba}),[i,h]=v(c);D(()=>{c&&h(()=>{var y;return{endCursor:c.endCursor,totalCount:c.totalCount,hasNextPage:(y=c==null?void 0:c.hasNextPage)!=null?y:!1,edges:c.edges}})},[c]);const g=i==null?void 0:i.edges[(i==null?void 0:i.edges.length)-1],E=i==null?void 0:i.edges.map(y=>y.checker),{setShowAddModal:f}=W(),[x,L]=v(),[S,w]=v(""),[N,P]=v("default"),[T,q]=v("all"),[ie,B]=v([]),ce=y=>{const O=se({searchTermProp:S,filterAlphaProp:y.target.value,filterOwnerProp:T,checks:E!=null?E:[]});P(y.target.value),L(O)},de=y=>{const O=se({searchTermProp:S,filterAlphaProp:N,filterOwnerProp:y.target.value,checks:E!=null?E:[]});q(y.target.value),L(O)};D(()=>{const y=i==null?void 0:i.edges.map(b=>b.checker),O=bt(y!=null?y:[]);L(y),B(O!=null?O:[])},[d,i]),D(()=>{const y=i==null?void 0:i.edges.map(b=>b.checker),O=se({searchTermProp:S,filterAlphaProp:N,filterOwnerProp:T,checks:y!=null?y:[]});L(O)},[S,N,T,i]);const me=()=>{s(y=>[...y,r]),l(g==null?void 0:g.cursor)},pe=()=>{l(o[o.length-1]),s(y=>y.slice(0,-1))},J=i!=null&&i.totalCount&&e?Math.ceil((i==null?void 0:i.totalCount)/e):0,ue=y=>{window.open(`/soundcheck/checks?checksPerPage=${y.target.value}`,"_self")};return t.createElement(u,{container:!0,direction:"row"},t.createElement(u,{container:!0,spacing:4,className:a.header},t.createElement(yt,{searchPlaceholder:"Search available checks",isLoading:d,searchTerm:S,setSearchTerm:w,filterAlpha:N,handleAlphabeticalFilterChange:ce,filterOwner:T,handleOwnerFilterChange:de,owners:ie}),t.createElement(u,{item:!0,xs:3},t.createElement("div",{className:a.headerButtons},t.createElement(C,null,"Checks shown:"),t.createElement(Se,{value:e,onChange:ue},["10","25","50","100"].map(y=>t.createElement("option",{value:y},y))),!m&&t.createElement(A,{disabled:!p,variant:"contained",color:"primary",onClick:()=>f(!0)},"Create Check")))),t.createElement(u,{container:!0,spacing:4,role:"list","aria-label":"checks"},d?t.createElement(jn,null):x==null?void 0:x.map(y=>t.createElement(u,{key:y.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(Hn,{check:y})))),((i==null?void 0:i.hasNextPage)||(o==null?void 0:o.length)>0)&&t.createElement("div",{className:a.pagination},t.createElement(A,{disabled:(o==null?void 0:o.length)<=0,onClick:pe},"Load Previous Checks"),t.createElement(C,{className:a.pageTotal},"Page ",o.length+1,"/",J),t.createElement(A,{disabled:!(i!=null&&i.hasNextPage),onClick:me},"Load Next Checks")))},Xn=()=>{const{selectedCheck:e}=W();return t.createElement(Re,{title:"Check Details",open:!!e,onSave:()=>{}})},er=k(e=>({checksPageContainer:{padding:e.spacing(3)}})),tr=()=>{const e=er(),[n]=Ve(),a=n.get("checksPerPage"),r=a?parseInt(a,10):10,{selectedCheck:l,showAddModal:o,isReadOnly:s}=W();return t.createElement("div",{className:e.checksPageContainer},t.createElement(Zn,{checksPerPage:r}),o&&t.createElement(Mn,null),l&&!s&&t.createElement(On,null),l&&s&&t.createElement(Xn,null))},ar=()=>t.createElement(ja,null,t.createElement(tr,null)),nr=k(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),rr=({program:e})=>{var n,a,r;const l=nr(),o=(a=(n=e.levels)==null?void 0:n.length)!=null?a:0,s=(r=e.levels)==null?void 0:r.reduce((c,d)=>c+d.checks.length,0);return t.createElement(be,{dense:!0,disablePadding:!0,className:l.cardSection},t.createElement(C,{variant:"overline",color:"textSecondary"},"Track Details"),t.createElement(Z,{disableGutters:!0,className:l.listItem},t.createElement(X,{title:"Levels"},t.createElement(Y,null,t.createElement($a,{color:"action",fontSize:"small"}))),t.createElement(_,{className:l.listItemText,primary:t.createElement(C,{variant:"body2",color:"textSecondary"},`${o} ${o===1?"Level":"Levels"}`)})),t.createElement(Z,{disableGutters:!0,className:l.listItem},t.createElement(X,{title:"Checks"},t.createElement(Y,null,t.createElement(Fa,{color:"action",fontSize:"small"}))),t.createElement(_,{className:l.listItemText,primary:t.createElement(C,{variant:"body2",color:"textSecondary"},`${s} ${s===1?"Check":"Checks"}`)})),e.documentationURL&&t.createElement(Z,{disableGutters:!0,className:l.listItem},t.createElement(X,{title:"Documentation"},t.createElement(Y,null,t.createElement(Oa,{color:"action",fontSize:"small"}))),t.createElement(_,{className:l.listItemText,primary:t.createElement(Bt,{to:e.documentationURL,target:"_blank",rel:"noopener noreferrer"},"Learn more")})),t.createElement(Z,{disableGutters:!0,className:l.listItem},t.createElement(X,{title:"Owner"},t.createElement(Y,null,t.createElement(Xe,{color:"action",fontSize:"small"}))),t.createElement(_,{className:l.listItemText,primary:t.createElement(Ye,{entityRef:e.ownerEntityRef})})))},lr="Error Deleting Track";function or(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.deleteProgram(l);if(!o)throw new Error(`Failed to delete track ${l}`);return o};return ne([re.DeleteProgram],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[F.GetAllPrograms]})},onError:(l,o)=>{let s=`Failed to delete track ${o}`;l instanceof Error&&(s=l.message),a({severity:"error",title:lr,message:s})}})}const sr=({summary:e})=>{const{loading:n,allowed:a}=le({permission:Ca,resourceRef:e.id}),{loading:r,allowed:l}=le({permission:ka,resourceRef:e.id}),{showModal:o}=Ce(),{mutate:s}=or(),{setSelectedProgram:c}=oe(),d=G(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]);return t.createElement(vt,{title:e.name,description:e.description,children:t.createElement(rr,{program:e}),handleView:()=>{c(e)},handleEdit:e.isEditable&&!n&&a?()=>{c(e)}:void 0,handleDelete:e.isEditable&&!r&&l?d:void 0})},ir=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,n)=>t.createElement(u,{key:`loading-${n}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Je,{variant:"rect",height:385})))),cr=k(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end"},header:{padding:e.spacing(0,0,1)},pagination:{display:"flex",width:"100%",justifyContent:"space-between"}})),dr=({programsPerPage:e,currentCursor:n})=>{var a;const r=cr(),{loading:l,allowed:o}=le({permission:xa}),{setShowAddModal:s}=oe(),[c,d]=v(n),[m,p]=v([]),{data:i,isLoading:h}=Ga(void 0,e,c),[g,E]=v(i);D(()=>{i&&E(()=>{var b;return{endCursor:i.endCursor,totalCount:i.totalCount,hasNextPage:(b=i==null?void 0:i.hasNextPage)!=null?b:!1,edges:i.edges}})},[i]);const f=(a=g==null?void 0:g.edges)==null?void 0:a.map(b=>b==null?void 0:b.program),x=g==null?void 0:g.edges[(g==null?void 0:g.edges.length)-1],{userEntityRef:L}=Ue(),{showAlert:S}=Q(),[w,N]=v(),[P,T]=v(""),[q,ie]=v("default"),[B,ce]=v("all"),[de,me]=v([]),pe=b=>{const $=se({searchTermProp:P,filterAlphaProp:b.target.value,filterOwnerProp:B,tracks:f!=null?f:[]});ie(b.target.value),N($)},J=b=>{const $=se({searchTermProp:P,filterAlphaProp:q,filterOwnerProp:b.target.value,tracks:f!=null?f:[]});ce(b.target.value),N($)};D(()=>{const b=g==null?void 0:g.edges.map(ge=>ge.program),$=bt(b!=null?b:[]);N(b),me($!=null?$:[])},[h,g]),D(()=>{const b=g==null?void 0:g.edges.map(ge=>ge.program),$=se({searchTermProp:P,filterAlphaProp:q,filterOwnerProp:B,tracks:b!=null?b:[]});N($)},[P,q,B,g]);const ue=()=>{p(b=>[...b,c]),d(x==null?void 0:x.cursor)},y=()=>{d(m[m.length-1]),p(b=>b.slice(0,-1))},O=()=>{L?s(!0):S({severity:"error",title:"User Error",message:"Logged in user has not been found in Catalog. Unable to create a Track at this time"})};return t.createElement(u,{container:!0,direction:"row"},t.createElement(u,{container:!0,spacing:4,className:r.header},t.createElement(yt,{searchPlaceholder:"Search available tracks",isLoading:h,searchTerm:P,setSearchTerm:T,filterAlpha:q,handleAlphabeticalFilterChange:pe,filterOwner:B,handleOwnerFilterChange:J,owners:de}),t.createElement(u,{item:!0,xs:3},t.createElement("div",{className:r.headerButtons},!l&&t.createElement(A,{disabled:!o,variant:"contained",color:"primary",onClick:()=>O()},"Create Track")))),t.createElement(u,{container:!0,spacing:4,role:"list","aria-label":"tracks"},h?t.createElement(ir,null):w==null?void 0:w.map(b=>t.createElement(u,{key:b.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(sr,{summary:b})))),((g==null?void 0:g.hasNextPage)||(m==null?void 0:m.length)>0)&&t.createElement("div",{className:r.pagination},t.createElement(A,{disabled:(m==null?void 0:m.length)<=0,onClick:y},"Load Previous Tracks"),t.createElement(A,{disabled:!(g!=null&&g.hasNextPage),onClick:ue},"Load Next Tracks")))},mr=k(e=>({titleInput:{marginBottom:e.spacing(1)},title:{fontWeight:700}})),Ct=({programName:e,programNameError:n,handleProgramNameChange:a,disabled:r})=>{const l=mr();return t.createElement(u,{item:!0,xs:12},t.createElement(z,{fullWidth:!0,placeholder:"Untitled track",value:e,onChange:a,disabled:r,className:l.titleInput,variant:"outlined",size:"small",margin:"normal",error:n,helperText:n?"Track name must be at least 1 character and less than 100 characters":""}))},kt=k(e=>{const n=e.palette.type==="dark",a=n?e.palette.common.white:e.palette.common.black,r=n?e.palette.grey[700]:e.palette.common.white,l=n?e.palette.grey[500]:e.palette.grey[300],o=n?e.palette.common.white:e.palette.common.black;return{chip:{width:"100%",height:"36px",color:a,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"}}}),pr=({chip:e,disabled:n})=>{var a;const[r,l]=Da(()=>({type:"chip",item:{id:e.id,label:e.label},collect:s=>({isDragging:s.isDragging()})})),o=kt();return t.createElement(Pe,{ref:l,label:e.label,className:o.chip,icon:t.createElement(et,{"data-testid":"drag-indicator-icon"}),disabled:n,onDelete:()=>{},deleteIcon:t.createElement(X,{title:(a=e.description)!=null?a:""},t.createElement(Ma,{className:o.icon,"data-testid":"visibility-icon"}))})},xt=k(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{color:e.palette.primary.main,fontWeight:"bold"},chipContainer:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:e.spacing(1),gap:e.spacing(1)},loadingContainer:{marginTop:e.spacing(1),display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}})),ur=()=>{const e=xt();return t.createElement(u,{container:!0,className:e.loadingContainer},t.createElement(na,null))},gr=({chips:e,disabled:n})=>t.createElement(t.Fragment,null,e.map(a=>t.createElement(pr,{disabled:n,key:a.id,chip:a}))),hr=()=>t.createElement(C,{variant:"body1",color:"textSecondary"},"There are no matches."),Er=({isLoading:e,chips:n=[],disabled:a})=>{const r=xt(),[l,o]=v(""),s=j(()=>n.filter(m=>m.label.toLowerCase().includes(l.toLowerCase())),[n,l]),c=n.length>0||l,d=()=>{if(e)return t.createElement(ur,null);if(s.length>0)return t.createElement(gr,{disabled:a!=null?a:!1,chips:s});if(c)return t.createElement(hr,null)};return t.createElement(u,{container:!0},t.createElement(u,{item:!0,xs:12,className:r.columnHeader},t.createElement(C,{className:r.subtitle},"Checks")),t.createElement(u,{item:!0,xs:12},t.createElement(ft,{searchTerm:l,disabled:e||a,setSearchTerm:o,placeholder:"Search available checks",variant:"outlined",size:"small"})),t.createElement(u,{item:!0,className:r.chipContainer,xs:12},d()))},vr=k(e=>({button:{border:"none",fontWeight:700,fontSize:e.typography.subtitle2.fontSize,lineHeight:"19px",color:e.palette.primary.main,textTransform:"none"}})),wt=({label:e,...n})=>{const a=vr();return t.createElement(A,{className:a.button,...n},e)},fr=k(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]}})),yr=({chips:e,onDelete:n,onDrop:a,error:r=!1,placeholder:l="",disabled:o})=>{const s=fr(),c=kt(),[{isOver:d},m]=Ia(()=>({accept:"chip",drop:p=>{a(p)},collect:p=>({isOver:p.isOver()})}));return t.createElement("div",{ref:m,className:`${s.input} ${r?s.error:""} ${d?s.hoverBackground:s.normalBackground}`,"data-testid":"droppable-input"},t.createElement("div",{className:s.chipContainer},e!=null&&e.length?e.map(p=>t.createElement(Pe,{key:p.id,label:p.label,className:c.chip,icon:t.createElement(et,null),style:{cursor:"pointer"},onDelete:()=>n(p),disabled:o})):l))},br=k(e=>({inputBase:{fontSize:e.typography.subtitle1.fontSize,fontWeight:700}})),Cr=({levelName:e,handleLevelNameChange:n,disabled:a})=>{const r=br();return t.createElement(z,{fullWidth:!0,placeholder:"Untitled level",value:e,size:"small",variant:"outlined",onChange:n,label:"Level Name",disabled:a,InputProps:{classes:{input:r.inputBase}}})},kr=k(e=>({inputBase:{fontSize:e.typography.fontSize,fontWeight:"normal"}})),xr=({levelDescription:e,levelNameLabel:n,handleLevelDescriptionChange:a,disabled:r})=>{const l=kr();return t.createElement(z,{fullWidth:!0,placeholder:"Enter description here",multiline:!0,value:e,size:"small",variant:"outlined",label:`${n} Description`,onChange:a,disabled:r,InputProps:{classes:{input:l.inputBase}}})},wr=k(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}})),Nr=({inputChipsList:e,handleDelete:n,handleDrop:a,addInput:r,removeInput:l,levelsErrors:o,levelNames:s,levelDescriptions:c,handleLevelNameChange:d,handleLevelDescriptionChange:m,disabled:p})=>{const i=wr();return t.createElement(u,{container:!0},t.createElement(u,{item:!0,xs:12,className:i.columnHeader},t.createElement(C,{className:i.subtitle},"Levels"),!p&&t.createElement(wt,{label:"Add Level",startIcon:t.createElement(Va,null),onClick:r,disabled:p})),t.createElement(u,{container:!0,item:!0,spacing:5},e.map((h,g)=>t.createElement(u,{container:!0,item:!0,xs:12,key:g,spacing:2},t.createElement(u,{item:!0,xs:12,className:i.levelHeader},t.createElement(u,{container:!0,spacing:1},t.createElement(u,{item:!0,xs:!0},t.createElement(Cr,{levelName:s[g],handleLevelNameChange:E=>d(E.target.value,g),disabled:p!=null?p:!1})),e.length>1&&!p&&t.createElement(u,{item:!0,className:i.removeButton},t.createElement(wt,{label:"Remove Level",startIcon:t.createElement(Ba,null),onClick:()=>l(g),disabled:p})))),t.createElement(u,{item:!0,xs:12},t.createElement(yr,{chips:h,onDelete:E=>n(E,g),onDrop:E=>a(E,g),error:o[g],placeholder:"Drag and drop checks here to include them in this level",disabled:p})),t.createElement(u,{item:!0,xs:12},t.createElement(xr,{levelDescription:c[g],levelNameLabel:s[g],handleLevelDescriptionChange:E=>m(E.target.value,g),disabled:p!=null?p:!1}))))))},Lr=k(e=>({titleInput:{marginBottom:e.spacing(1)},regularFontSize:{fontSize:e.typography.fontSize},title:{fontWeight:700,fontSize:e.typography.fontSize}})),Nt=({programDescription:e,programDescriptionError:n,handleProgramDescriptionChange:a,disabled:r})=>{const l=Lr();return t.createElement(u,{item:!0,xs:12},t.createElement(z,{fullWidth:!0,placeholder:"Example: Make sure the project has a ReadMe file and is using the latest version of JavaScript",value:e,onChange:a,disabled:r,className:l.titleInput,minRows:4,variant:"outlined",size:"small",margin:"normal",multiline:!0,InputProps:{classes:{input:l.regularFontSize}},error:n,helperText:n?"Track description must be at least 1 character and less than 250 characters":""}))};var Sr=(e=>(e.SetProgramNameError="VALIDATE_NAME",e.SetName="SET_NAME",e))(Sr||{});const Pr={programName:"",programNameError:!1},Tr=(e,n)=>{switch(n.type){case"SET_NAME":return{...e,programName:n.value};case"VALIDATE_NAME":return{...e,programNameError:n.value};default:return e}},Dr=(e="")=>{const[n,a]=we(Tr,{...Pr,programName:e}),r=()=>{const s=n.programName.trim().length,c=s>0&&s<=100;return a({type:"VALIDATE_NAME",value:!c}),c},l=s=>{a({type:"SET_NAME",value:s})},o=s=>{l(s.target.value),n.programNameError&&r()};return{programName:n.programName,programNameError:n.programNameError,handleProgramNameChange:o,setProgramName:l,isProgramNameValid:r}};var Ir=(e=>(e.SetProgramDescriptionError="VALIDATE_DESCRIPTION",e.SetDescription="SET_DESCRIPTION",e))(Ir||{});const Ar={programDescription:"",programDescriptionError:!1},Rr=(e,n)=>{switch(n.type){case"SET_DESCRIPTION":return{...e,programDescription:n.value};case"VALIDATE_DESCRIPTION":return{...e,programDescriptionError:n.value};default:return e}},Or=(e="")=>{const[n,a]=we(Rr,{...Ar,programDescription:e}),r=()=>{const s=n.programDescription.trim().length,c=s>0&&s<=250;return a({type:"VALIDATE_DESCRIPTION",value:!c}),c},l=s=>{a({type:"SET_DESCRIPTION",value:s})},o=s=>{l(s.target.value),n.programDescriptionError&&r()};return{programDescription:n.programDescription,programDescriptionError:n.programDescriptionError,handleProgramDescriptionChange:o,setProgramDescription:l,isProgramDescriptionValid:r}},Fr=({programName:e,programDescription:n,areInputsValid:a,isProgramNameValid:r,isProgramDescriptionValid:l,inputChipsList:o,checkers:s,onSave:c,programId:d,levelNames:m,levelDescriptions:p,filters:i})=>{const{showModal:h}=Ce(),{userEntityRef:g}=Ue();return async()=>{if(!(r()&&l()&&a())||!await h({title:"Save Track",message:`Are you sure you want to save track: ${e}?`})||!g)return;const E=d!=null?d:Ze(),f=cn(o,m,p,s),x={description:n,id:E,levels:f,name:e,ownerEntityRef:g,filter:it(i)};c(x)}},$r=e=>{const n=j(()=>e?mn(e):null,[e]),[a,r]=v([]),[l,o]=v(!1),{data:s,isLoading:c}=tt(),d=s==null?void 0:s.edges.map(w=>w.checker),m=j(()=>(d!=null?d:[]).filter(w=>!!w).map(w=>{var N,P,T;return{id:(N=w.id)!=null?N:"",label:(P=w.name)!=null?P:w.id,description:(T=w.description)!=null?T:""}}),[d]),{chips:p,inputChipsList:i,handleDrop:h,handleDelete:g,addInput:E,removeInput:f,inputErrors:x,areInputsValid:L,setInputChipsList:S}=Ka(a);return D(()=>{if(!a.length&&m.length&&!l){const{inputChips:w,used:N}=pn(n,m);S(w),r(N),o(!0)}},[m,S,a.length,n,l]),{checkers:d,checkersLoading:c,chips:p,inputChipsList:i,handleDrop:h,handleDelete:g,addInput:E,removeInput:f,inputErrors:x,areInputsValid:L}},Mr=e=>{const[n,a]=v(e);return{levelNames:n,handleLevelNameChange:(r,l)=>{a(n.map((o,s)=>s===l?r:o))},addLevelName:r=>{a([...n,r])},removeLevelName:r=>{a(n.filter((l,o)=>o!==r))}}},Vr=e=>{const[n,a]=v(e);return{levelDescriptions:n,handleLevelDescriptionChange:(r,l)=>{a(n.map((o,s)=>s===l?r:o))},addLevelDescription:r=>{a([...n,r])},removeLevelDescription:r=>{a(n.filter((l,o)=>o!==r))}}},Br=k(e=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)},description:{fontSize:e.typography.fontSize}})),Lt=({filters:e,setFilters:n,disabled:a})=>{const r=Br(),l=o=>s=>{n(o,s!=null?s:[])};return t.createElement(ke,{title:a?"Filters":"Filters (optional)"},t.createElement(u,{container:!0,item:!0,xs:12,spacing:2},!a&&t.createElement(u,{item:!0},t.createElement(C,{className:r.description},"Apply filters so it's only applicable to relevant entities.")),t.createElement(u,{item:!0,xs:12},t.createElement(Ne,null,t.createElement(u,{container:!0,className:r.filterContainer,spacing:2},gt.map(o=>t.createElement(u,{item:!0,xs:12,sm:6,md:4,key:o.stateKey},t.createElement(ht,{facet:o.facet,label:o.label,values:e[o.stateKey],onChange:l(o.stateKey),disabled:a}))))))))};var Gr=(e=>(e.SetFilter="SET_FILTER",e))(Gr||{});const zr={selectedKinds:[],selectedTypes:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[]},Wr=(e,n)=>{switch(n.type){case"SET_FILTER":return{...e,[n.key]:n.values};default:return e}},St=e=>{let n=zr;e&&(n=ct(e));const[a,r]=we(Wr,n);return{filters:a,setFilters:(l,o)=>{r({type:"SET_FILTER",key:l,values:o})}}},qr=k(e=>({regularFontSize:{fontSize:e.typography.fontSize,fontWeight:"bold"},description:{fontWeight:"normal",fontSize:e.typography.fontSize},root:{overflow:"hidden",display:"flex",padding:e.spacing(1),marginBottom:"53px"}})),Pt=({onSave:e,title:n,open:a,handleClose:r})=>{var l,o,s,c;const{selectedProgram:d,isLoading:m,setSelectedProgram:p}=oe(),{checkers:i,checkersLoading:h,chips:g,inputChipsList:E,handleDrop:f,handleDelete:x,addInput:L,removeInput:S,inputErrors:w,areInputsValid:N}=$r(d),{programName:P,programNameError:T,handleProgramNameChange:q,isProgramNameValid:ie}=Dr(d==null?void 0:d.name),{programDescription:B,programDescriptionError:ce,handleProgramDescriptionChange:de,isProgramDescriptionValid:me}=Or(d==null?void 0:d.description),pe=(o=d?(l=d.levels)==null?void 0:l.map(V=>{var U;return(U=V.name)!=null?U:`Level ${V.ordinal}`}):E.map((V,U)=>`Level ${U+1}`))!=null?o:[],{levelNames:J,handleLevelNameChange:ue,addLevelName:y,removeLevelName:O}=Mr(pe),b=(c=d?(s=d.levels)==null?void 0:s.map(V=>{var U;return(U=V.description)!=null?U:""}):E.map((V,U)=>""))!=null?c:[],{levelDescriptions:$,handleLevelDescriptionChange:ge,addLevelDescription:Tt,removeLevelDescription:Dt}=Vr(b),It=()=>{L(),y(`Level ${E.length+1}`),Tt("")},At=V=>{S(V),O(V),Dt(V)},{filters:Oe,setFilters:Rt}=St(d==null?void 0:d.filter),Ot=Fr({programName:P,programDescription:B,areInputsValid:N,isProgramNameValid:ie,isProgramDescriptionValid:me,inputChipsList:E,checkers:i,onSave:e,programId:d==null?void 0:d.id,levelNames:J,levelDescriptions:$,filters:Oe}),xe=qr(),Fe=Et(),K=d?!(d!=null&&d.isEditable):!1;return t.createElement(lt,{handleClose:r,title:n,open:a},t.createElement(u,{container:!0,spacing:4,className:xe.root},t.createElement(u,{item:!0,xs:12},t.createElement(u,{item:!0,xs:12},t.createElement(C,{className:Fe.sectionLabel,style:{margin:0}},"Track Details"),t.createElement(Ct,{disabled:m||K,programName:P,programNameError:T,handleProgramNameChange:q})),t.createElement(u,{item:!0,xs:12},t.createElement(Nt,{disabled:m||K,programDescription:B,programDescriptionError:ce,handleProgramDescriptionChange:de}))),t.createElement(u,{item:!0,xs:12},t.createElement(Lt,{disabled:K,filters:Oe,setFilters:Rt})),t.createElement(u,{item:!0,xs:12},t.createElement(u,{container:!0,spacing:4},t.createElement(u,{item:!0,xs:12},t.createElement(C,{className:Fe.sectionLabel,style:{margin:0}},"Track Levels"),!K&&t.createElement(C,{className:xe.description},"Add the checks that apply to each level. You can preview the checks to see the rules that apply to each check.")),!K&&t.createElement(u,{item:!0,xs:5},t.createElement(Er,{chips:g,isLoading:h||m,disabled:K})),t.createElement(u,{item:!0,xs:7},t.createElement(Nr,{inputChipsList:E,handleDelete:x,handleDrop:f,addInput:It,removeInput:At,levelsErrors:w,levelNames:J,handleLevelNameChange:ue,levelDescriptions:$,handleLevelDescriptionChange:ge,disabled:K}))))),t.createElement(u,{container:!0,spacing:4,className:xe.root},t.createElement(at,{onCancel:()=>{p(null),r()},saveButtonText:"Save Track",isLoading:m||h,onSave:Ot,disableSave:K})))},Kr=()=>{const{setIsLoading:e,setShowAddModal:n,showAddModal:a}=oe(),{mutateAsync:r,isLoading:l}=qa();return D(()=>{e(l)},[e,l]),t.createElement(Pt,{handleClose:()=>n(!1),title:"Create Track",open:a,onSave:async o=>{await r(o)&&n(!1)}})},Ur="Error Updating Track";function Hr(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.updateProgram(l);if(!o)throw new Error("Failed to update track.");return o};return ne([re.UpdateProgram],r,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[F.GetAllPrograms]})},onError:l=>{let o="Failed to update track.";l instanceof Error&&(o=l.message),a({severity:"error",title:Ur,message:o})}})}const jr=()=>{const{setSelectedProgram:e,setIsLoading:n,selectedProgram:a}=oe(),{mutateAsync:r,isLoading:l}=Hr();D(()=>n(l),[n,l]);const o=async s=>{await r(s)&&e(null)};return t.createElement(Pt,{handleClose:()=>e(null),title:a!=null&&a.isEditable?"Edit Track":"View Track",open:!!a,onSave:o})},_r=k(e=>({programsPageContainer:{padding:e.spacing(3)},headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap"}})),Qr=()=>{const{selectedProgram:e,showAddModal:n}=oe(),[a]=Ve(),r=a.get("tracksPerPage"),l=r?parseInt(r,10):10,o=_r(),s="Programs will now be referred to as Tracks throughout the Soundcheck UI.";return t.createElement("div",{className:o.programsPageContainer},t.createElement(Gt,{variant:"info",message:s,id:"programTrackBanner"}),t.createElement(Aa,{backend:Ra},t.createElement(dr,{programsPerPage:l}),n&&t.createElement(Kr,null),e&&t.createElement(jr,null)))},Jr=k(e=>({programsPageContainer:{padding:e.spacing(3)},lists:{padding:e.spacing(2)},checksDescription:{padding:"0 0 10px 5px"},levelHeader:{marginBottom:"10px"},chip:{marginTop:"10px"}})),Yr=({})=>{var e,n;const a=Jr(),r=window.location.pathname.split("tracks/")[1],{data:l,isLoading:o}=za(r||""),s=(e=l==null?void 0:l.edges[0])==null?void 0:e.program,{filters:c,setFilters:d}=St(s==null?void 0:s.filter),m=()=>{window.open("/soundcheck/tracks","_self")};return t.createElement(t.Fragment,null,t.createElement("div",{className:a.programsPageContainer},o?"loading":t.createElement(u,{container:!0,spacing:3},t.createElement(u,{item:!0,xs:12},t.createElement(C,{variant:"h4"},"Owner: ",s==null?void 0:s.ownerEntityRef)),t.createElement(u,{item:!0,xs:12},t.createElement(Ct,{disabled:!0,programName:s?s.name:"",programNameError:!1,handleProgramNameChange:()=>null})),t.createElement(u,{item:!0,xs:12},t.createElement(Nt,{disabled:!0,programDescription:s!=null&&s.description?s.description:"",programDescriptionError:!1,handleProgramDescriptionChange:()=>null})),t.createElement(u,{item:!0,xs:12},t.createElement(Lt,{disabled:!0,filters:c,setFilters:d})),t.createElement(u,{item:!0,xs:12},t.createElement(Le,null,t.createElement(We,null,t.createElement(u,{container:!0,spacing:4},t.createElement(u,{item:!0,xs:12},t.createElement(be,{dense:!0,className:a.lists},(n=s==null?void 0:s.levels)==null?void 0:n.map((p,i)=>t.createElement("div",{key:`levels-${i}`},t.createElement(C,{className:a.levelHeader,variant:"h6"},p.name),t.createElement(_,null,"Description: ",p.description),t.createElement(be,{key:`levels-${i}`,dense:!0,className:a.lists},t.createElement(C,{variant:"h6"},"Checks"),p.checks.map((h,g)=>t.createElement("div",{key:`checks-${g}`},t.createElement(Pe,{key:h.name+g,label:h.name,className:a.chip}),t.createElement(Z,{divider:!0,className:a.checksDescription},h.description)))))))))))))),t.createElement(A,{variant:"contained",color:"primary",onClick:m},"Track List"))},Zr=()=>{const e=window.location.pathname.split("tracks/");return t.createElement(Ha,null,e[1]?t.createElement(Yr,null):t.createElement(Qr,null))},Xr=k(()=>({tabContent:{margin:0,padding:0}})),el=({title:e="Soundcheck"})=>{const n=Xr(),[a,r]=la(),{group:l}=a,[o,s]=v(void 0),c=m=>{m&&r({...a,group:m})},d=Ft();return t.createElement(ua,null,t.createElement(oa,null,t.createElement(ga,null,t.createElement(ha,null,t.createElement(zt,{themeId:"website"},t.createElement(qt,{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(Wt,{title:e},d.pathname.split("/").length-1===1&&t.createElement(sa,{onChange:c,initialValue:l,setError:s})),t.createElement($t,null,t.createElement(Mt,{path:"/*",element:t.createElement(fe,null,t.createElement(fe.Route,{title:"Overview",path:"/"},t.createElement("div",{className:n.tabContent},t.createElement(ia,{groupSelectorError:o,searchParams:a,setSearchParams:r}))),t.createElement(fe.Route,{title:"Checks",path:"/checks"},t.createElement(ar,null)),t.createElement(fe.Route,{title:"Tracks",path:"/tracks"},t.createElement(Zr,null)))})))))))};export{el as RoutingPage};
2
+ //# sourceMappingURL=index-62a0beb1.esm.js.map
@@ -1,2 +1,2 @@
1
- import t from"react";import{S as o,f as i}from"./index-40aa00c1.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-b3600988.esm.js.map
1
+ import t from"react";import{S as o,g as i}from"./index-104979d0.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-ddb40786.esm.js.map
package/dist/index.d.ts CHANGED
@@ -46,6 +46,13 @@ declare const EntitySoundcheckContent: () => React.JSX.Element;
46
46
  * Must be used within {@link @backstage/plugin-catalog#EntityLayout}.
47
47
  */
48
48
  declare const EntitySoundcheckCard: ({ title }: EntitySoundcheckCardProps) => React.JSX.Element;
49
+ /**
50
+ * @public
51
+ *
52
+ * Provides an GroupPage tab containing Soundcheck content relevant for the
53
+ * current group. Expected to be used within {@link @backstage/plugin-catalog#GroupLayout}.
54
+ */
55
+ declare const GroupSoundcheckContent: () => React.JSX.Element;
49
56
  /**
50
57
  * @public
51
58
  *
@@ -60,4 +67,4 @@ declare const SoundcheckOverviewPage: (props: OverviewPageProps) => JSX.Element;
60
67
  */
61
68
  declare const SoundcheckRoutingPage: (props: OverviewPageProps) => JSX.Element;
62
69
 
63
- export { EntitySoundcheckCard, EntitySoundcheckCardProps, EntitySoundcheckContent, OverviewPageProps, SoundcheckOverviewPage, SoundcheckRoutingPage, soundcheckPlugin };
70
+ export { EntitySoundcheckCard, EntitySoundcheckCardProps, EntitySoundcheckContent, GroupSoundcheckContent, OverviewPageProps, SoundcheckOverviewPage, SoundcheckRoutingPage, soundcheckPlugin };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{l as f,E as w,m as x,n as O,k as R}from"./esm/index-40aa00c1.esm.js";import"react";import"@backstage/core-plugin-api";import"graphql-request";import"graphql-tag";import"@tanstack/react-query";import"lodash";import"@material-ui/core/styles/makeStyles";import"@material-ui/core";import"@backstage/core-components";import"@backstage/plugin-catalog-react";import"@spotify/backstage-plugin-core";import"@backstage/catalog-model";import"@material-ui/lab";import"react-router-dom";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";export{f as EntitySoundcheckCard,w as EntitySoundcheckContent,x as SoundcheckOverviewPage,O as SoundcheckRoutingPage,R as soundcheckPlugin};
1
+ import{o as f,E as l,G as q,p as w,q as x,n as O}from"./esm/index-104979d0.esm.js";import"react";import"@backstage/core-plugin-api";import"graphql-request";import"graphql-tag";import"@tanstack/react-query";import"lodash";import"@material-ui/core/styles/makeStyles";import"@material-ui/core";import"@backstage/core-components";import"@backstage/plugin-catalog-react";import"@spotify/backstage-plugin-core";import"@backstage/catalog-model";import"@material-ui/lab";import"react-router-dom";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";export{f as EntitySoundcheckCard,l as EntitySoundcheckContent,q as GroupSoundcheckContent,w as SoundcheckOverviewPage,x as SoundcheckRoutingPage,O as soundcheckPlugin};
2
2
  //# sourceMappingURL=index.esm.js.map
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@spotify/backstage-plugin-soundcheck",
3
3
  "description": "Ensure quality, reliability and alignment of software development with codified checks and guidance.",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
- "homepage": "https://backstage.spotify.com/",
6
+ "homepage": "https://backstage.spotify.com",
7
7
  "main": "dist/index.esm.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "publishConfig": {
@@ -26,16 +26,18 @@
26
26
  "prepare": "yarn generate"
27
27
  },
28
28
  "dependencies": {
29
- "@backstage/catalog-model": "^1.4.0",
30
- "@backstage/core-components": "^0.13.2",
31
- "@backstage/core-plugin-api": "^1.5.2",
32
- "@backstage/plugin-catalog-react": "^1.7.0",
33
- "@backstage/theme": "^0.4.0",
29
+ "@backstage/catalog-model": "^1.4.1",
30
+ "@backstage/core-components": "^0.13.3",
31
+ "@backstage/core-plugin-api": "^1.5.3",
32
+ "@backstage/plugin-catalog-react": "^1.8.0",
33
+ "@backstage/plugin-permission-react": "^0.4.14",
34
+ "@backstage/theme": "^0.4.1",
34
35
  "@backstage/types": "^1.1.0",
35
36
  "@material-ui/core": "^4.12.2",
36
37
  "@material-ui/icons": "^4.9.1",
37
38
  "@material-ui/lab": "4.0.0-alpha.61",
38
- "@spotify/backstage-plugin-core": "^0.5.3",
39
+ "@spotify/backstage-plugin-core": "^0.5.4",
40
+ "@spotify/backstage-plugin-soundcheck-common": "^0.7.0",
39
41
  "@tanstack/react-query": "^4.6.1",
40
42
  "classnames": "^2.3.2",
41
43
  "graphql-request": "6.1.0",
@@ -54,16 +56,15 @@
54
56
  "react-router-dom": "6.0.0-beta.0 || ^6.3.0"
55
57
  },
56
58
  "devDependencies": {
57
- "@backstage/cli": "^0.22.8",
58
- "@backstage/core-app-api": "^1.8.1",
59
- "@backstage/dev-utils": "^1.0.16",
60
- "@backstage/test-utils": "^1.4.0",
59
+ "@backstage/cli": "^0.22.9",
60
+ "@backstage/core-app-api": "^1.9.0",
61
+ "@backstage/dev-utils": "^1.0.17",
62
+ "@backstage/test-utils": "^1.4.1",
61
63
  "@graphql-codegen/cli": "^4.0.0",
62
64
  "@graphql-codegen/typescript": "^4.0.0",
63
65
  "@graphql-codegen/typescript-graphql-request": "^5.0.0",
64
66
  "@graphql-codegen/typescript-operations": "^4.0.0",
65
- "@spotify/backstage-plugin-core-common": "^0.5.3",
66
- "@spotify/backstage-plugin-soundcheck-common": "^0.6.0",
67
+ "@spotify/backstage-plugin-core-common": "^0.5.4",
67
68
  "@testing-library/jest-dom": "^5.10.1",
68
69
  "@testing-library/react": "^12.1.5",
69
70
  "@testing-library/react-hooks": "^8.0.1",
@@ -1,2 +0,0 @@
1
- import n,{createContext as c,useState as e,useContext as i}from"react";const h=c({selectedProgram:null,setSelectedProgram:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{}}),m=({children:o})=>{const[d,t]=e(null),[s,r]=e(!1),[a,l]=e(!1);return n.createElement(h.Provider,{value:{selectedProgram:d,setSelectedProgram:t,isLoading:s,setIsLoading:r,showAddModal:a,setShowAddModal:l}},o)},u=()=>i(h),g=c({selectedCheck:null,setSelectedCheck:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{}}),C=({children:o})=>{const[d,t]=e(null),[s,r]=e(!1),[a,l]=e(!1);return n.createElement(g.Provider,{value:{selectedCheck:d,setSelectedCheck:t,isLoading:s,setIsLoading:r,showAddModal:a,setShowAddModal:l}},o)},P=()=>i(g);export{C,m as P,u as a,P as u};
2
- //# sourceMappingURL=CheckFormContext-6f85a3bf.esm.js.map
@@ -1,2 +0,0 @@
1
- import e,{useState as W,useEffect as M}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-0caa936c.esm.js";import{s as H,R as c,A as y,F as x,a as J,u as B,L as K,N as X,b,c as g,d as Z,C as _,e as F,S as ee}from"./index-40aa00c1.esm.js";import{Skeleton as s}from"@material-ui/lab";import{MarkdownContent as P}from"@backstage/core-components";import{stringifyEntityRef as te}from"@backstage/catalog-model";import{useApi as ae,useRouteRef as C,useRouteRefParams as ne}from"@backstage/core-plugin-api";import{useQuery as re}from"@tanstack/react-query";import ie from"react-use/lib/useMeasure";import $ from"react-use/lib/usePrevious";import le from"react-confetti";import"react-use/lib/useDebounce";import"graphql-request";import"graphql-tag";import"lodash";import"@material-ui/core/styles/makeStyles";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function oe(t,n,a){const r=ae(H),i=te(t);return re(["soundcheck/check-details",i,n,a],async()=>r.getCheckResultDetails(i,n,a),{enabled:!!n&&!!a})}const ce=p({markdownContent:{"& :last-child":{marginBottom:0}}}),se=({state:t,notes:n})=>{const a=ce(),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)},me=()=>{const t=A();return e.createElement(x,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))))},A=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)}})),de=({programId:t,checkId:n})=>{const a=A(),{entity:r}=u(),{data:i,isLoading:l,isError:o}=oe(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(me,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(se,{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})))},pe=p(()=>({root:{position:"absolute",width:"100%",height:"100%"}})),ue=({programId:t})=>{var n,a;const r=pe(),{entity:i}=u(),{data:l,isLoading:o}=B(i,t),[h,{width:d,height:v}]=ie(),m=o?void 0:(a=(n=l==null?void 0:l.highestLevel)==null?void 0:n.ordinal)!=null?a:-1,E=$(m),R=$(t),[z,S]=W(!1);return M(()=>{typeof E!="undefined"&&typeof m!="undefined"&&t===R&&m>E&&S(!0)},[m,E,t,R]),z?e.createElement("div",{ref:h,className:r.root},e.createElement(le,{width:d,height:v,numberOfPieces:1e3,gravity:1,initialVelocityY:20,recycle:!1,onConfettiComplete:()=>S(!1)})):null},D=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)}})),he=({id:t,name:n,badge:a,href:r,selected:i=!1})=>{const l=D();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=D();return e.createElement(L,{className:t.root,classes:{wrapper:t.wrapper},label:e.createElement(s,{width:180})})},Ee=()=>e.createElement(x,null,e.createElement(T,{value:!1,indicatorColor:"primary"},e.createElement(w,null),e.createElement(w,null),e.createElement(w,null)));function fe(t=[],n){const a=t.findIndex(r=>r.program.id===n);return a<0?!1:a}const ge=({trackId:t})=>{const{entity:n}=u(),{isLoading:a,data:r}=b(n),i=C(g);if(a||!t)return e.createElement(Ee,null);const l=fe(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(he,{key:o,id:o,name:h,badge:d==null?void 0:d.badge,selected:o===t,href:i({trackId:o})})))},ve=p({paper:{overflow:"hidden",position:"relative"},view:{display:"grid",gridTemplateColumns:"1fr 2fr"}}),ke=()=>{const{trackId:t,checkId:n}=Q(),a=ve(),{entity:r}=u(),{isError:i,isFetched:l,data:o}=b(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(ge,{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(de,{programId:t,checkId:n}),e.createElement(ue,{programId:t})))},ye=p(t=>({root:{"&:not(:first-child)":{marginTop:t.spacing(2)}}})),N=()=>{const t=ye();return e.createElement(e.Fragment,null,e.createElement(q,{backend:"soundcheck",invalidLicenseMessage:"Submitted check results will still be stored, but it will not be possible to view certifications or individual results until a valid license is present.",inline:!0}),e.createElement("div",{className:t.root},e.createElement(ke,null)))},be=()=>{var t;const{entity:n}=u(),a=C(g),{data:r}=b(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},Ce=()=>{var t,n;const{entity:a}=u(),{trackId:r}=ne(g),i=C(F),{data:l}=B(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},we=()=>e.createElement(j,null,e.createElement(k,{path:"/",element:e.createElement(e.Fragment,null,e.createElement(N,null),e.createElement(be,null))}),e.createElement(k,{path:g.path,element:e.createElement(e.Fragment,null,e.createElement(N,null),e.createElement(Ce,null))}),e.createElement(k,{path:F.path,element:e.createElement(N,null)})),Ne=()=>e.createElement(ee,null,e.createElement(we,null));export{Ne as EntitySoundcheckContent};
2
- //# sourceMappingURL=EntitySoundcheckContent-8fdad07c.esm.js.map
@@ -1,2 +0,0 @@
1
- import e,{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-40aa00c1.esm.js";import"@backstage/plugin-catalog-react";import"react-router-dom";const p=a(t=>({indicator:{position:"absolute",width:"100%",zIndex:t.zIndex.speedDial}})),l=()=>{const t=c(),i=p(),[r,o]=n(!!t);return s(()=>{o(!!t)},250,[t]),r?e.createElement(d,null,e.createElement("div",{className:i.indicator},e.createElement(m,{variant:"indeterminate","data-testid":"refetching-indicator"}))):null};export{l as R};
2
- //# sourceMappingURL=RefetchingIndicator-0caa936c.esm.js.map
@@ -1,2 +0,0 @@
1
- import t,{useState as k,useEffect as A,useCallback as B,useMemo as me,useReducer as Ce}from"react";import{Link as Ze,useSearchParams as ye,Routes as Je,Route as et}from"react-router-dom";import{MarkdownContent as tt,Link as at,ContentHeader as rt,Page as nt,Header as lt,TabbedLayout as J}from"@backstage/core-components";import{SpotifyLicenseBanner as ot}from"@spotify/backstage-plugin-core";import{Box as L,Paper as it,Grid as m,Button as w,Slide as st,Dialog as ct,AppBar as mt,Toolbar as dt,Typography as C,IconButton as j,TextField as R,Collapse as pt,makeStyles as y,ButtonGroup as ke,Menu as be,MenuItem as M,FormControl as ut,InputLabel as gt,Select as ht,Card as de,ListItemIcon as P,ListItemText as I,withStyles as pe,CardContent as Ne,CardHeader as Et,Divider as vt,CardActions as ft,List as xe,ListItem as Q,Tooltip as U,InputAdornment as Se,NativeSelect as Le,Chip as we,CircularProgress as Ct}from"@material-ui/core";import{makeStyles as F,createStyles as ue}from"@material-ui/core/styles";import{u as O,C as yt,a as G,P as kt}from"./CheckFormContext-6f85a3bf.esm.js";import De from"@material-ui/icons/Close";import{Controller as ge,useForm as bt}from"react-hook-form";import Nt from"@material-ui/icons/AddCircleOutline";import xt from"@material-ui/icons/ArrowDropDown";import Pe from"@material-ui/icons/Delete";import"@backstage/catalog-model";import{useApi as z}from"@backstage/core-plugin-api";import{useQuery as Ie,useQueryClient as ee,useMutation as te}from"@tanstack/react-query";import{s as q,Q as W,j as ae,M as re,w as ne,S as St,P as Lt,i as wt}from"./index-40aa00c1.esm.js";import{EntityRefLink as Te}from"@backstage/plugin-catalog-react";import Dt from"@material-ui/icons/MoreVert";import Pt from"@material-ui/icons/ControlPointDuplicate";import It from"@material-ui/icons/Edit";import Ae from"@material-ui/icons/Visibility";import $e from"@material-ui/icons/Group";import{Skeleton as Ve}from"@material-ui/lab";import Tt from"@material-ui/icons/Search";import{useDrag as At,useDrop as $t,DndProvider as Vt}from"react-dnd";import{HTML5Backend as Bt}from"react-dnd-html5-backend";import Rt from"@material-ui/icons/OpenInNew";import Mt from"@material-ui/icons/DoneAllRounded";import Ft from"@material-ui/icons/Menu";import Be from"@material-ui/icons/Add";import Re from"@material-ui/icons/DragIndicator";import Ot from"@material-ui/icons/Remove";import{v4 as Gt}from"uuid";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/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function zt(e,a,r){const l=z(q);return Ie([W.GetAllPrograms,e,a,r],async()=>l.getAllPrograms(e,a,r))}const qt="Error Creating Track";function Wt(){const e=z(q),a=ee(),{showAlert:r}=ae(),l=async n=>{const o=await e.createProgram(n);if(!o)throw new Error("Failed to create track.");return o};return te([re.CreateProgram],l,{onSuccess:async()=>{await a.invalidateQueries({queryKey:[W.GetAllPrograms]})},onError:n=>{let o="Failed to create track.";n instanceof Error&&(o=n.message),r({severity:"error",title:qt,message:o})}})}function Me(e,a,r){const l=z(q);return Ie([W.GetCheckers,e,a,r],async()=>l.getCheckers(e,a,r))}const Ht=e=>{const[a,r]=k(void 0),[l,n]=k([[]]),[o,i]=k([!1]);A(()=>{a===void 0&&e!=null&&e.length&&r(e)},[e,a]);const s=B((p,u)=>{n(h=>{const v=[...h];return v[u]=[...v[u],p],v}),r(h=>h==null?void 0:h.filter(v=>v.id!==p.id)),i(h=>{if(h[u]){const v=[...h];return v[u]=!1,v}return h})},[]),d=B((p,u)=>{n(h=>{const v=[...h];return v[u]=v[u].filter(b=>b.id!==p.id),v}),r(h=>[...h!=null?h:[],p])},[]),c=B(()=>{n(p=>[...p,[]]),i(p=>[...p,!1])},[]),g=B(p=>{l.length>1&&n(u=>{const h=[...u],v=h.splice(p,1)[0];return r(b=>[...b!=null?b:[],...v]),h})},[l]),E=B(()=>{const p=l.map(u=>u.length===0);return i(p),!p.some(u=>u)},[l]);return{chips:a,inputChipsList:l,handleDrop:s,handleDelete:d,addInput:c,removeInput:g,inputErrors:o,setInputErrors:i,areInputsValid:E,setInputChipsList:n}},_t=F(e=>({footer:{padding:e.spacing(2)}})),Fe=({onCancel:e,saveButtonText:a,onSave:r,isLoading:l})=>{const n=_t();return t.createElement(L,{position:"fixed",bottom:"0",width:"100%"},t.createElement(it,{elevation:3,className:n.footer},t.createElement(m,{container:!0,item:!0,spacing:2,justifyContent:"space-between"},t.createElement(m,{item:!0},t.createElement(w,{variant:"contained",color:"primary",onClick:e},"Cancel")),t.createElement(m,{item:!0},t.createElement(w,{variant:"contained",color:"primary",disabled:l,onClick:()=>r()},a)))))},jt=F(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),overflowX:"hidden",backgroundColor:e.palette.type==="dark"?"#333":e.palette.common.white}})),Qt=t.forwardRef(function(e,a){return t.createElement(st,{direction:"up",ref:a,...e})}),Oe=({open:e,handleClose:a,title:r,children:l})=>{const n=jt();return t.createElement(ct,{fullScreen:!0,open:e,onClose:a,TransitionComponent:Qt},t.createElement(mt,{className:n.appBar},t.createElement(dt,null,t.createElement(C,{className:n.title},r),t.createElement(j,{edge:"end",color:"inherit",onClick:a,"aria-label":"close",className:n.closeIcon},t.createElement(De,null)))),t.createElement(L,{className:n.content},l))},le=({name:e,control:a,error:r,label:l,placeholder:n,disabled:o,rules:i,messages:s,helperText:d,multiline:c,minRows:g})=>t.createElement(ge,{name:e,control:a,defaultValue:"",rules:i,render:({field:E})=>t.createElement(R,{...E,fullWidth:!0,multiline:c,minRows:g,placeholder:n,label:l,disabled:o,variant:"outlined",margin:"normal",error:!!r,helperText:r?s[r.type]:d})}),Ut=F(e=>({section:{gap:0},sectionLabel:{fontWeight:700,color:e.palette.primary.main}})),Kt=({control:e,error:a,isLoading:r})=>{const l=Ut();return t.createElement("div",{className:l.section},t.createElement(C,{className:l.sectionLabel},"Check Details"),t.createElement(le,{name:"checkName",control:e,error:a,label:"Check Name",placeholder:"Choose a name",disabled:r,rules:{required:!0,maxLength:100},messages:{required:"This field is required",maxLength:"Input must be less than 100 characters"}}))},Xt=F(e=>({root:{display:"flex",flexDirection:"column",gap:0},button:{marginLeft:-e.spacing(1)},title:{fontWeight:700,color:e.palette.primary.main}})),Yt=({title:e,children:a})=>{const[r,l]=k(!1),n=Xt(),o=()=>{l(!r)};return t.createElement("div",{className:n.root},t.createElement(m,{container:!0,alignItems:"center",spacing:0},t.createElement(m,{item:!0},t.createElement(j,{onClick:o,className:n.button},t.createElement(Nt,null))),t.createElement(m,{item:!0},t.createElement(C,{className:n.title},e))),t.createElement(pt,{in:r},a))},Zt=({control:e,passError:a,failError:r,isLoading:l})=>t.createElement(Yt,{title:"Pass and fail messages (optional)"},t.createElement(le,{name:"passMessage",control:e,error:a,label:"Pass Message",placeholder:"Enter pass message...",disabled:l,rules:{},messages:{}}),t.createElement(le,{name:"failMessage",control:e,error:r,label:"Fail Message",placeholder:"Enter fail message...",disabled:l,rules:{},messages:{}})),Jt=({control:e,error:a,isLoading:r})=>t.createElement(le,{name:"description",control:e,error:a,label:"Check Description",disabled:r,multiline:!0,minRows:4,placeholder:"Enter a brief description about the check",helperText:"Enter a brief description about the check",rules:{required:!0,maxLength:500},messages:{required:"This field is required",maxLength:"Description must be less than 500 characters"}}),ea=y(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"}})),ta=({onAddCondition:e,onAddExpression:a})=>{const r=ea(),[l,n]=k(null),o=!!l,i=d=>{n(d.currentTarget)},s=()=>{n(null)};return t.createElement(L,null,t.createElement(ke,{color:"primary"},t.createElement(w,{id:"add-button",className:r.button,"aria-controls":o?"add-menu":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:i},t.createElement(L,{className:r.label},"Add"),t.createElement(L,{className:r.icon},t.createElement(xt,null)))),t.createElement(be,{id:"add-menu",anchorEl:l,open:o,onClose:s,classes:{paper:r.menu},MenuListProps:{"aria-labelledby":"add-button"}},t.createElement(M,{onClick:()=>{e(),s()}},"Add Condition"),t.createElement(M,{onClick:()=>{a(),s()}},"Add Expression")))},he=({name:e,control:a,selectLabel:r,options:l})=>t.createElement(ge,{name:e,control:a,render:({field:n})=>t.createElement(ut,{variant:"outlined",style:{minWidth:200}},t.createElement(gt,{id:`${e}-select-label`},r),t.createElement(ht,{...n,"data-testid":`${e}-select`,labelId:`${e}-select-label`,label:r},l.map(({value:o,label:i})=>t.createElement(M,{key:o,value:o},i))))});var Ge=(e=>(e.AllOf="ALL OF",e.AnyOf="ANY OF",e))(Ge||{}),ze=(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))(ze||{});const aa={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"},ra=y(e=>({container:{borderLeft:`1px solid ${e.palette.grey[500]}`,marginLeft:e.spacing(2),padding:e.spacing(2,0,2,0),display:"flex",flexDirection:"row",gap: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"},deleteIcon:{color:e.palette.type==="dark"?e.palette.background.default:e.palette.common.black}})),na=({control:e,name:a,handleDelete:r})=>{const l=ra(),n=Object.values(ze).map(o=>({value:o,label:aa[o]}));return t.createElement(L,{className:l.container},t.createElement(L,{className:l.connector}),t.createElement(L,{className:l.innerContainer},t.createElement(L,{className:l.header}),t.createElement(L,{className:l.inputsContainer},t.createElement(he,{name:`${a}.factRef`,control:e,selectLabel:"Fact",options:n}),t.createElement(he,{name:`${a}.path`,control:e,selectLabel:"Path",options:n}),t.createElement(he,{name:`${a}.operator`,control:e,selectLabel:"Operator",options:n}),t.createElement(ge,{name:`${a}.value`,control:e,defaultValue:"",render:({field:o})=>t.createElement(R,{...o,label:"Value",variant:"outlined"})}))),t.createElement(j,{onClick:r,"data-test-id":`${a}-delete-button`},t.createElement(Pe,{className:l.deleteIcon})))},la=({conditions:e,control:a,name:r,handleDelete:l})=>t.createElement(t.Fragment,null,e.map((n,o)=>t.createElement(m,{item:!0,key:o},t.createElement(na,{control:a,name:`${r}.conditions[${o}]`,"data-testid":`${r}-condition-input`,handleDelete:l})))),oa=({expression:e,control:a,name:r,depth:l,getValues:n,setValue:o,trigger:i})=>e?t.createElement(m,{item:!0},t.createElement(qe,{control:a,name:`${r}.expression`,depth:l+1,getValues:n,setValue:o,trigger:i})):null,ia=y(e=>({selectedButton:{backgroundColor:"rgba(46, 119, 208, 0.08)"},button:{fontWeight:700,backgroundColor:e.palette.background.default,color:e.palette.primary.main,"&:hover":{backgroundColor:"rgba(46, 119, 208, 0.2)"}}})),sa=({onSelect:e})=>{const[a,r]=k(null),l=ia(),n=o=>{r(o),e(o)};return t.createElement(ke,{color:"primary"},Object.values(Ge).map(o=>t.createElement(w,{key:o,className:a===o?`${l.selectedButton} ${l.button}`:`${l.button}`,onClick:()=>n(o)},o)))},ca=(e,a,r,l)=>({handleAddCondition:async()=>{const n=`${e}`,o=a(n),i=[...(o==null?void 0:o.conditions)||[],{factRef:"",path:"",operator:"",value:""}],s=`${e}.conditions`;r(s,i),await l(s)},handleAddExpression:async()=>{r(`${e}.expression`,{factRef:"",path:"",operator:"",value:"",conditions:[{factRef:"",path:"",operator:"",value:""}]}),await l(`${e}.expression`)}}),ma=F(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),borderLeft:`1px solid ${e.palette.grey[500]}`},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"20px"}})),qe=({control:e,name:a,depth:r,getValues:l,setValue:n,trigger:o})=>{const i=ma(),{handleAddCondition:s,handleAddExpression:d}=ca(a,l,n,o),c=`${a}`,g=l(c),E=(g==null?void 0:g.conditions)||[],p=g==null?void 0:g.expression;return t.createElement(L,{className:r>0?i.inner:i.root},r>0&&t.createElement(L,{className:i.connector}),t.createElement(m,{container:!0,spacing:0,direction:"column"},t.createElement(m,{item:!0},t.createElement(sa,{onSelect:()=>{}})),t.createElement(m,{item:!0,container:!0,spacing:0,direction:"column"},t.createElement(la,{handleDelete:()=>{},conditions:E,control:e,name:a}),t.createElement(oa,{expression:p,control:e,name:a,depth:r,getValues:l,setValue:n,trigger:o})),t.createElement(m,{item:!0},t.createElement(ta,{onAddCondition:s,onAddExpression:d}))))},da=()=>{const{control:e,handleSubmit:a,getValues:r,setValue:l,trigger:n,formState:{errors:o}}=bt({defaultValues:{checkName:"",description:"",expression:{factRef:"",path:"",operator:"",value:"",conditions:[{factRef:"",path:"",operator:"",value:"",conditions:[]}]}}}),{showModal:i}=ne();return{control:e,handleSubmit:a,getValues:r,setValue:l,trigger:n,errors:o,onSubmit:async s=>{await i({title:"Save Check",message:`Are you sure you want to save check: ${s.checkName}?`})}}},pa=F(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}})),We=({title:e,open:a,handleClose:r})=>{const l=pa(),{setSelectedCheck:n,isLoading:o}=O(),{control:i,handleSubmit:s,getValues:d,setValue:c,trigger:g,errors:E,onSubmit:p}=da();return t.createElement(Oe,{handleClose:r,title:e,open:a},t.createElement("form",{onSubmit:s(p)},t.createElement(m,{container:!0,spacing:2,className:l.root},t.createElement(m,{item:!0,xs:9},t.createElement(de,{className:l.card},t.createElement(C,{className:l.sectionLabel,style:{margin:0}},"Check Details"),t.createElement(Kt,{control:i,error:E.checkName,isLoading:o}),t.createElement(Jt,{control:i,error:E.description,isLoading:o}),t.createElement(C,{className:l.sectionLabel},"Rules"),t.createElement(qe,{control:i,getValues:d,setValue:c,trigger:g,name:"expression",depth:0}),t.createElement(Zt,{control:i,passError:E.passMessage,failError:E.failMessage,isLoading:o}))),t.createElement(m,{item:!0,xs:3},t.createElement(C,{variant:"body1"},"..."))),t.createElement(m,{container:!0,spacing:4,className:l.root},t.createElement(Fe,{onCancel:()=>{n(null),r()},saveButtonText:"Save new check",isLoading:o,onSave:s(p)}))))},ua=()=>{const{selectedCheck:e,setSelectedCheck:a}=O();return t.createElement(We,{handleClose:()=>a(null),title:"Edit a Check",open:!!e,onSave:async()=>{a(null)}})},ga=()=>{const{setShowAddModal:e,showAddModal:a}=O();return t.createElement(We,{handleClose:()=>e(!1),title:"Create a Check",open:a,onSave:async()=>{e(!1)}})},ha=({handleEdit:e,handleView:a,handleDuplicate:r,handleDelete:l})=>{const[n,o]=k(null),i=!!n,s=c=>{c.stopPropagation(),o(c.currentTarget)},d=c=>{c.stopPropagation(),o(null)};return t.createElement(t.Fragment,null,t.createElement(j,{"aria-label":"summary-card-actions",id:"summary-card-action-menu-button","aria-controls":i?"summary-card-action-menu":void 0,"aria-expanded":i?"true":void 0,"aria-haspopup":"true",onClick:s},t.createElement(Dt,null)),t.createElement(be,{id:"summary-card-action-menu",anchorEl:n,open:i,onClose:d,getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{"aria-labelledby":"summary-card-action-menu-button"}},e?t.createElement(M,{"data-testid":"summary-card-action-edit",onClick:c=>{e(c),d(c)}},t.createElement(P,null,t.createElement(It,{fontSize:"small"})),t.createElement(I,null,"Edit")):t.createElement(M,{"data-testid":"summary-card-action-view",onClick:c=>{a(c),d(c)}},t.createElement(P,null,t.createElement(Ae,{fontSize:"small"})),t.createElement(I,null,"View")),t.createElement(M,{"data-testid":"summary-card-action-duplicate",onClick:c=>{r(c),d(c)}},t.createElement(P,null,t.createElement(Pt,{fontSize:"small"})),t.createElement(I,null,"Duplicate")),l&&t.createElement(M,{"data-testid":"summary-card-action-delete",onClick:c=>{l(c),d(c)}},t.createElement(P,null,t.createElement(Pe,{fontSize:"small"})),t.createElement(I,null,"Delete"))))},Ea=pe(e=>ue({root:{width:"100%",height:"100%",minHeight:"385px",display:"flex",flexDirection:"column",padding:e.spacing(2),position:"relative"}}))(de),va=pe(()=>ue({root:{display:"flex",flexDirection:"column",flex:1,gap:"3px"}}))(Ne);pe(()=>ue({root:{position:"absolute",display:"block",zIndex:10,top:2.5,left:2.5,right:2.5,bottom:2.5,"&:hover ~ div > .burst":{backgroundSize:"200%"}}}))(({classes:e,to:a,message:r,children:l,onClick:n})=>t.createElement(Ze,{className:e==null?void 0:e.root,to:a,onClick:n},t.createElement(C,{variant:"srOnly"},r),l));const fa=y(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},summaryDescription:{maxHeight:"150px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical",wordBreak:"break-word"}})),He=({title:e,description:a,children:r,handleDuplicate:l,handleDelete:n,handleEdit:o,handleView:i})=>{const s=fa();return t.createElement(Ea,null,t.createElement(Et,{title:e,action:t.createElement(t.Fragment,null,t.createElement(ha,{handleDelete:n,handleEdit:o,handleDuplicate:l,handleView:i}))}),t.createElement(va,null,t.createElement("div",{className:s.cardSection},t.createElement("div",{className:s.summaryDescription},t.createElement(tt,{content:a!=null?a:""}))),r&&t.createElement("div",{className:s.cardSection},r)),t.createElement(vt,null),t.createElement(ft,null,t.createElement(w,{size:"small",color:"primary",role:"link",onClick:o||i},o?"Edit":"View")))},Ca="Error Deleting Check";function ya(){const e=z(q),a=ee(),{showAlert:r}=ae(),l=async n=>{const o=await e.deleteChecker(n);if(!o)throw new Error(`Failed to delete check ${n}`);return o};return te([re.DeleteChecker],l,{onSuccess:()=>{a.invalidateQueries({queryKey:[W.GetCheckers]})},onError:(n,o)=>{let i=`Failed to delete check ${o}`;n instanceof Error&&(i=n.message),r({severity:"error",title:Ca,message:i})}})}const ka=y(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),ba=({check:e})=>{var a;const r=ka();return t.createElement(xe,{dense:!0,disablePadding:!0,className:r.cardSection},t.createElement(C,{variant:"overline",color:"textSecondary"},"Check Details"),t.createElement(Q,{disableGutters:!0,className:r.listItem},t.createElement(U,{title:"Owner"},t.createElement(P,null,t.createElement($e,{color:"action",fontSize:"small"}))),t.createElement(I,{className:r.listItemText,primary:t.createElement(Te,{entityRef:(a=e.ownerEntityRef)!=null?a:"No Owner"})})))},Na=({checker:e})=>{const{showModal:a}=ne(),{mutate:r}=ya(),{setSelectedCheck:l}=O(),{id:n,name:o,description:i,isEditable:s}=e,d=B(async()=>{await a({title:"Delete Check",message:`Are you sure you want to delete the check '${o}'?`})&&r(n)},[a,o,r,n]);return t.createElement(He,{title:o!=null?o:n,description:i,children:e.ownerEntityRef&&t.createElement(ba,{check:e}),handleView:()=>{},handleEdit:s?()=>l(e):void 0,handleDuplicate:()=>{},handleDelete:s?d:void 0})},xa=()=>t.createElement(t.Fragment,null,Array.from({length:10},(e,a)=>t.createElement(m,{key:`loading-${a}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Ve,{variant:"rect",height:385})))),Sa=y(()=>({searchIcon:{opacity:".5"},clearButton:{height:"36px",width:"36px"}})),_e=({searchTerm:e,setSearchTerm:a,showClear:r=!0,placeholder:l="Search...",...n})=>{const o=Sa(),i=d=>{a(d.target.value)},s=()=>{a("")};return t.createElement(R,{...n,fullWidth:!0,placeholder:l,value:e,onChange:i,InputProps:{startAdornment:t.createElement(Se,{position:"start"},t.createElement(Tt,{className:o.searchIcon,"data-testid":"search-icon"})),endAdornment:r&&e?t.createElement(Se,{position:"end"},t.createElement(j,{edge:"end",onClick:s,className:o.clearButton},t.createElement(De,null))):null}})},La=y(()=>({searchbar:{maxWidth:"350px"},filters:{display:"flex",alignItems:"center"},dropdownFilters:{margin:"0 15px",display:"flex",alignItems:"center"},selectHolder:{marginLeft:"10px"}})),wa=({isLoading:e,searchTerm:a,setSearchTerm:r,filterAlpha:l,handleAlphabeticalFilterChange:n,filterOwner:o,handleOwnerFilterChange:i,owners:s})=>{const d=La();return t.createElement(m,{item:!0,xs:9,className:d.filters},t.createElement(_e,{searchTerm:a,disabled:e,setSearchTerm:r,placeholder:"Search available checks",variant:"outlined",size:"small",className:d.searchbar}),t.createElement("div",{className:d.dropdownFilters},t.createElement(C,null,"Sort by: "),t.createElement(Le,{className:d.selectHolder,value:l,onChange:n},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:d.dropdownFilters},t.createElement(C,null,"Filter by owner: "),t.createElement(Le,{className:d.selectHolder,value:o,onChange:i},t.createElement("option",{key:"all",value:"all"},"All"),s==null?void 0:s.map((c,g)=>t.createElement("option",{key:c+g,value:c},c)))))},Da=y(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end"},header:{padding:"16px 0"}})),Pa=(e,a)=>e==null?void 0:e.sort((r,l)=>{var n,o;const i=(n=r==null?void 0:r.name)==null?void 0:n.toLowerCase(),s=(o=l==null?void 0:l.name)==null?void 0:o.toLowerCase();return!i||!s?0:i<s?a==="ascending"?-1:1:i>s?a==="ascending"?1:-1:0}),Ia=e=>{const a=e==null?void 0:e.map(r=>r==null?void 0:r.ownerEntityRef);return[...new Set(a)]},Ee=({searchTermProp:e,filterAlphaProp:a,filterOwnerProp:r,checks:l})=>{const n=l==null?void 0:l.filter(i=>{var s;return(s=i==null?void 0:i.name)==null?void 0:s.toLowerCase().includes(e.toLowerCase())}),o=r&&r!=="all"?n==null?void 0:n.filter(i=>{var s;return((s=i==null?void 0:i.ownerEntityRef)==null?void 0:s.toLowerCase())===r.toLowerCase()}):n;return a==="default"?o:Pa(o!=null?o:[],a)},Ta=({checksPerPage:e,currentCursor:a})=>{const r=Da(),[l,n]=k(a),{data:o,isLoading:i}=Me(void 0,e,l),[s,d]=k(o);A(()=>{o&&d(f=>{var x,T;const ie=(x=f==null?void 0:f.edges)!=null?x:[],se=o.edges,K=[...ie,...se],X=[],ce=K.reduce((Y,_)=>X.includes(_.checker.id)?Y:(X.push(_.checker.id),[...Y,_]),[]);return{endCursor:o.endCursor,totalCount:o.totalCount,hasNextPage:(T=o==null?void 0:o.hasNextPage)!=null?T:!1,edges:ce}})},[o]);const c=s==null?void 0:s.edges[(s==null?void 0:s.edges.length)-1],g=s==null?void 0:s.edges.map(f=>f.checker),{setShowAddModal:E}=O(),[p,u]=k(),[h,v]=k(""),[b,N]=k("default"),[S,D]=k("all"),[H,$]=k([]),V=f=>{const x=Ee({searchTermProp:h,filterAlphaProp:f.target.value,filterOwnerProp:S,checks:g!=null?g:[]});N(f.target.value),u(x)},oe=f=>{const x=Ee({searchTermProp:h,filterAlphaProp:b,filterOwnerProp:f.target.value,checks:g!=null?g:[]});D(f.target.value),u(x)};return A(()=>{const f=s==null?void 0:s.edges.map(T=>T.checker),x=Ia(f!=null?f:[]);u(f),$(x!=null?x:[])},[i,s]),A(()=>{const f=s==null?void 0:s.edges.map(T=>T.checker),x=Ee({searchTermProp:h,filterAlphaProp:b,filterOwnerProp:S,checks:f!=null?f:[]});u(x)},[h,b,S,s]),t.createElement(m,{container:!0,direction:"row"},t.createElement(m,{container:!0,spacing:4,className:r.header},t.createElement(wa,{isLoading:i,searchTerm:h,setSearchTerm:v,filterAlpha:b,handleAlphabeticalFilterChange:V,filterOwner:S,handleOwnerFilterChange:oe,owners:H}),t.createElement(m,{item:!0,xs:3},t.createElement("div",{className:r.headerButtons},t.createElement(w,{variant:"contained",color:"primary",onClick:()=>E(!0)},"Add New Check")))),t.createElement(m,{container:!0,spacing:4,role:"list","aria-label":"checks"},i?t.createElement(xa,null):p==null?void 0:p.map(f=>t.createElement(m,{key:f.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(Na,{checker:f})))),(s==null?void 0:s.hasNextPage)&&t.createElement(w,{onClick:()=>n(c==null?void 0:c.cursor)},"Load More Checkers"))},Aa=y(e=>({checksPageContainer:{padding:e.spacing(3)}})),$a=()=>{const e=Aa(),[a]=ye(),r=a.get("checksPerPage"),l=r?parseInt(r,10):10,{selectedCheck:n,showAddModal:o}=O();return t.createElement("div",{className:e.checksPageContainer},t.createElement(Ta,{checksPerPage:l}),o&&t.createElement(ga,null),n&&t.createElement(ua,null))},Va=()=>t.createElement(yt,null,t.createElement($a,null)),Ba=y(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Ra=({program:e})=>{var a,r,l;const n=Ba(),o=(r=(a=e.levels)==null?void 0:a.length)!=null?r:0,i=(l=e.levels)==null?void 0:l.reduce((s,d)=>s+d.checks.length,0);return t.createElement(xe,{dense:!0,disablePadding:!0,className:n.cardSection},t.createElement(C,{variant:"overline",color:"textSecondary"},"Track Details"),t.createElement(Q,{disableGutters:!0,className:n.listItem},t.createElement(U,{title:"Levels"},t.createElement(P,null,t.createElement(Ft,{color:"action",fontSize:"small"}))),t.createElement(I,{className:n.listItemText,primary:t.createElement(C,{variant:"body2",color:"textSecondary"},`${o} ${o===1?"Level":"Levels"}`)})),t.createElement(Q,{disableGutters:!0,className:n.listItem},t.createElement(U,{title:"Checks"},t.createElement(P,null,t.createElement(Mt,{color:"action",fontSize:"small"}))),t.createElement(I,{className:n.listItemText,primary:t.createElement(C,{variant:"body2",color:"textSecondary"},`${i} ${i===1?"Check":"Checks"}`)})),e.documentationURL&&t.createElement(Q,{disableGutters:!0,className:n.listItem},t.createElement(U,{title:"Documentation"},t.createElement(P,null,t.createElement(Rt,{color:"action",fontSize:"small"}))),t.createElement(I,{className:n.listItemText,primary:t.createElement(at,{to:e.documentationURL,target:"_blank",rel:"noopener noreferrer"},"Learn more")})),t.createElement(Q,{disableGutters:!0,className:n.listItem},t.createElement(U,{title:"Owner"},t.createElement(P,null,t.createElement($e,{color:"action",fontSize:"small"}))),t.createElement(I,{className:n.listItemText,primary:t.createElement(Te,{entityRef:e.ownerEntityRef})})))},Ma="Error Deleting Track";function Fa(){const e=z(q),a=ee(),{showAlert:r}=ae(),l=async n=>{const o=await e.deleteProgram(n);if(!o)throw new Error(`Failed to delete track ${n}`);return o};return te([re.DeleteProgram],l,{onSuccess:()=>{a.invalidateQueries({queryKey:[W.GetAllPrograms]})},onError:(n,o)=>{let i=`Failed to delete track ${o}`;n instanceof Error&&(i=n.message),r({severity:"error",title:Ma,message:i})}})}const Oa=({summary:e})=>{const{showModal:a}=ne(),{mutate:r}=Fa(),{setSelectedProgram:l}=G(),n=B(async()=>{await a({title:"Delete Track",message:`Are you sure you want to delete track ${e.name}?`})&&r(e.id)},[a,e.id,e.name,r]);return t.createElement(He,{title:e.name,description:e.description,children:t.createElement(Ra,{program:e}),handleView:()=>{},handleEdit:e.isEditable?()=>{l(e)}:void 0,handleDuplicate:()=>{},handleDelete:e.isEditable?n:void 0})},Ga=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,a)=>t.createElement(m,{key:`loading-${a}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Ve,{variant:"rect",height:385})))),za=y(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap"}})),qa=({programsPerPage:e,currentCursor:a})=>{var r;const l=za(),{setShowAddModal:n}=G(),[o,i]=k(a),{data:s,isLoading:d}=zt(void 0,e,o),[c,g]=k(s);A(()=>{s&&g(u=>{var h,v;const b=(h=u==null?void 0:u.edges)!=null?h:[],N=s.edges,S=[...b,...N],D=[],H=S.reduce(($,V)=>D.includes(V.program.id)?$:(D.push(V.program.id),[...$,V]),[]);return{endCursor:s.endCursor,totalCount:s.totalCount,hasNextPage:(v=s==null?void 0:s.hasNextPage)!=null?v:!1,edges:H}})},[s]);const E=(r=c==null?void 0:c.edges)==null?void 0:r.map(u=>u==null?void 0:u.program),p=c==null?void 0:c.edges[(c==null?void 0:c.edges.length)-1];return t.createElement(m,{container:!0,direction:"row"},t.createElement(rt,{title:"Tracks"},t.createElement("div",{className:l.headerButtons},t.createElement(w,{variant:"contained",color:"primary",onClick:()=>n(!0)},"Create Track"))),t.createElement(m,{container:!0,spacing:4,role:"list","aria-label":"tracks"},d?t.createElement(Ga,null):E==null?void 0:E.map(u=>t.createElement(m,{key:u.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(Oa,{summary:u})))),(c==null?void 0:c.hasNextPage)&&t.createElement(w,{onClick:()=>i(p==null?void 0:p.cursor)},"Load More Programs"))},Wa=y(e=>({titleInput:{marginBottom:e.spacing(1)},title:{fontWeight:700},container:{padding:"0 12px"}})),Ha=({programName:e,programNameError:a,handleProgramNameChange:r,disabled:l})=>{const n=Wa();return t.createElement(m,{className:n.container,item:!0,xs:12},t.createElement(C,{className:n.title,variant:"subtitle2"},"Track name"),t.createElement(C,{variant:"body2"},"Give your track a meaningful name so it\u2019s easy to remember it"),t.createElement(R,{fullWidth:!0,placeholder:"Untitled track",value:e,onChange:r,disabled:l,className:n.titleInput,variant:"outlined",size:"small",margin:"normal",error:a,helperText:a?"Track name must be at least 1 character and less than 100 characters":""}))},_a=y(e=>({button:{border:"none",fontWeight:700,fontSize:e.typography.subtitle2.fontSize,lineHeight:"19px",color:e.palette.primary.main,textTransform:"none"}})),ve=({label:e,...a})=>{const r=_a();return t.createElement(w,{className:r.button,...a},e)},je=y(e=>{const a=e.palette.type==="dark",r=a?e.palette.common.white:e.palette.common.black,l=a?e.palette.grey[700]:e.palette.common.white,n=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:r,justifyContent:"space-between",background:l,border:`1px solid ${n}`,borderRadius:4,boxShadow:"0px 2px 5px rgba(0, 0, 0, 0.1)",cursor:"move","&:focus":{background:l,borderColor:o,"& $icon":{color:e.palette.primary.main}}},icon:{}}}),ja=({chip:e})=>{const[a,r]=At(()=>({type:"chip",item:{id:e.id,label:e.label},collect:n=>({isDragging:n.isDragging()})})),l=je();return t.createElement(we,{ref:r,label:e.label,className:l.chip,icon:t.createElement(Re,{"data-testid":"drag-indicator-icon"}),onDelete:()=>{},deleteIcon:t.createElement(Ae,{className:l.icon,"data-testid":"visibility-icon"})})},Qe=y(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{fontSize:e.typography.h6.fontSize},chipContainer:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:e.spacing(1),gap:e.spacing(1)},loadingContainer:{marginTop:e.spacing(1),display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}})),Qa=()=>{const e=Qe();return t.createElement(m,{container:!0,className:e.loadingContainer},t.createElement(Ct,null))},Ua=({chips:e})=>t.createElement(t.Fragment,null,e.map(a=>t.createElement(ja,{key:a.id,chip:a}))),Ka=()=>t.createElement(C,{variant:"body1",color:"textSecondary"},"There are no matches."),Xa=({isLoading:e,chips:a=[]})=>{const r=Qe(),[l,n]=k(""),o=me(()=>a.filter(d=>d.label.toLowerCase().includes(l.toLowerCase())),[a,l]),i=a.length>0||l,s=()=>{if(e)return t.createElement(Qa,null);if(o.length>0)return t.createElement(Ua,{chips:o});if(i)return t.createElement(Ka,null)};return t.createElement(m,{container:!0},t.createElement(m,{item:!0,xs:12,className:r.columnHeader},t.createElement(C,{className:r.subtitle},"Checks"),t.createElement(ve,{label:"Add Check",startIcon:t.createElement(Be,null)})),t.createElement(m,{item:!0,xs:12},t.createElement(_e,{searchTerm:l,disabled:e,setSearchTerm:n,placeholder:"Search available checks",variant:"outlined",size:"small"})),t.createElement(m,{item:!0,className:r.chipContainer,xs:12},s()))},Ya=y(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"}})),Za=({chips:e,onDelete:a,onDrop:r,error:l=!1,placeholder:n=""})=>{const o=Ya(),i=je(),[{isOver:s},d]=$t(()=>({accept:"chip",drop:c=>{r(c)},collect:c=>({isOver:c.isOver()})}));return t.createElement("div",{ref:d,className:`${o.input} ${l?o.error:""} ${s?o.hoverBackground:o.normalBackground}`,"data-testid":"droppable-input"},t.createElement("div",{className:o.chipContainer},e!=null&&e.length?e.map(c=>t.createElement(we,{key:c.id,label:c.label,className:i.chip,icon:t.createElement(Re,null),onDelete:()=>a(c)})):n))},Ja=y(e=>({inputBase:{fontSize:e.typography.subtitle1.fontSize,fontWeight:700}})),er=({levelName:e,handleLevelNameChange:a,disabled:r})=>{const l=Ja();return t.createElement(R,{fullWidth:!0,placeholder:"Untitled level",value:e,onChange:a,disabled:r,InputProps:{classes:{input:l.inputBase}}})},tr=y(e=>({inputBase:{fontSize:e.typography.subtitle1.fontSize},inputContainer:{margin:"16px 0 0"}})),ar=({levelDescription:e,levelNameLabel:a,handleLevelDescriptionChange:r,disabled:l})=>{const n=tr();return t.createElement(R,{fullWidth:!0,placeholder:"Enter description here",className:n.inputContainer,multiline:!0,value:e,variant:"outlined",label:`${a} Description`,onChange:r,disabled:l,InputProps:{classes:{input:n.inputBase}}})},rr=y(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(2)},subtitle:{fontSize:e.typography.h6.fontSize},levelHeader:{display:"flex",alignItems:"center"},removeButton:{minWidth:150}})),nr=({inputChipsList:e,handleDelete:a,handleDrop:r,addInput:l,removeInput:n,levelsErrors:o,levelNames:i,levelDescriptions:s,handleLevelNameChange:d,handleLevelDescriptionChange:c})=>{const g=rr();return t.createElement(m,{container:!0},t.createElement(m,{item:!0,xs:12,className:g.columnHeader},t.createElement(C,{className:g.subtitle},"Levels"),t.createElement(ve,{label:"Add Level",startIcon:t.createElement(Be,null),onClick:l})),e.map((E,p)=>t.createElement(m,{container:!0,item:!0,xs:12,key:p,spacing:1},t.createElement(m,{item:!0,xs:12,className:g.levelHeader},t.createElement(m,{container:!0,spacing:1},t.createElement(m,{item:!0,xs:!0},t.createElement(er,{levelName:i[p],handleLevelNameChange:u=>d(u.target.value,p),disabled:!1})),e.length>1&&t.createElement(m,{item:!0,className:g.removeButton},t.createElement(ve,{label:"Remove Level",startIcon:t.createElement(Ot,null),onClick:()=>n(p)})))),t.createElement(m,{item:!0,xs:12},t.createElement(Za,{chips:E,onDelete:u=>a(u,p),onDrop:u=>r(u,p),error:o[p],placeholder:"Drag and drop checks here to include them in this level"})),t.createElement(m,{item:!0,xs:12},t.createElement(ar,{levelDescription:s[p],levelNameLabel:i[p],handleLevelDescriptionChange:u=>c(u.target.value,p),disabled:!1})))))},lr=y(e=>({titleInput:{marginBottom:e.spacing(1)},inputBase:{fontSize:e.typography.fontSize},title:{fontWeight:700},container:{padding:"0 12px"}})),or=({programDescription:e,programDescriptionError:a,handleProgramDescriptionChange:r,disabled:l})=>{const n=lr();return t.createElement(m,{className:n.container,item:!0,xs:12},t.createElement(C,{className:n.title,variant:"subtitle2"},"Track description"),t.createElement(C,{variant:"body2"},"Give your track a meaningful description so others can understand how to use it"),t.createElement(R,{fullWidth:!0,placeholder:"Example: Make sure the project has a ReadMe file and is using the latest version of JavaScript",value:e,onChange:r,disabled:l,className:n.titleInput,variant:"outlined",size:"small",margin:"normal",multiline:!0,InputProps:{classes:{input:n.inputBase}},error:a,helperText:a?"Track description must be at least 1 character and less than 250 characters":""}))};var ir=(e=>(e.SetProgramNameError="VALIDATE_NAME",e.SetName="SET_NAME",e))(ir||{});const sr={programName:"",programNameError:!1},cr=(e,a)=>{switch(a.type){case"SET_NAME":return{...e,programName:a.value};case"VALIDATE_NAME":return{...e,programNameError:a.value};default:return e}},mr=(e="")=>{const[a,r]=Ce(cr,{...sr,programName:e}),l=()=>{const i=a.programName.trim().length,s=i>0&&i<=100;return r({type:"VALIDATE_NAME",value:!s}),s},n=i=>{r({type:"SET_NAME",value:i})},o=i=>{n(i.target.value),a.programNameError&&l()};return{programName:a.programName,programNameError:a.programNameError,handleProgramNameChange:o,setProgramName:n,isProgramNameValid:l}};var dr=(e=>(e.SetProgramDescriptionError="VALIDATE_DESCRIPTION",e.SetDescription="SET_DESCRIPTION",e))(dr||{});const pr={programDescription:"",programDescriptionError:!1},ur=(e,a)=>{switch(a.type){case"SET_DESCRIPTION":return{...e,programDescription:a.value};case"VALIDATE_DESCRIPTION":return{...e,programDescriptionError:a.value};default:return e}},gr=(e="")=>{const[a,r]=Ce(ur,{...pr,programDescription:e}),l=()=>{const i=a.programDescription.trim().length,s=i>0&&i<=250;return r({type:"VALIDATE_DESCRIPTION",value:!s}),s},n=i=>{r({type:"SET_DESCRIPTION",value:i})},o=i=>{n(i.target.value),a.programDescriptionError&&l()};return{programDescription:a.programDescription,programDescriptionError:a.programDescriptionError,handleProgramDescriptionChange:o,setProgramDescription:n,isProgramDescriptionValid:l}},hr=(e,a,r,l)=>{const n={};return l&&l.forEach(o=>{var i,s;o&&(n[o.id]={id:o.id,name:(i=o.name)!=null?i:"",description:(s=o.description)!=null?s:""})}),e.map((o,i)=>{const s=o.map(d=>n[d.id]);return{name:a[i],description:r[i],ordinal:i,checks:s}})},Er=e=>e.map(a=>a.checks.map(r=>({id:r.id,label:r.name}))),vr=e=>{var a;return{id:e.id,name:e.name,description:e.description||"",ownerEntityRef:e.ownerEntityRef,documentationURL:e.documentationURL||"",levels:((a=e.levels)==null?void 0:a.map(r=>({ordinal:r.ordinal,name:r.name||"",description:r.description||"",checks:r.checks.map(l=>({id:l.id,name:l.name,description:l.description}))})))||[]}},fr=(e,a)=>{const r=e?Er(e.levels):[[]],l=r.flat().map(o=>o.id),n=a.filter(o=>!l.includes(o.id));return{inputChips:r,used:n}},Cr=({programName:e,programDescription:a,areInputsValid:r,isProgramNameValid:l,isProgramDescriptionValid:n,inputChipsList:o,checkers:i,onSave:s,programId:d,levelNames:c,levelDescriptions:g})=>{const{showModal:E}=ne();return async()=>{if(!(l()&&n()&&r())||!await E({title:"Save Program",message:`Are you sure you want to save program: ${e}?`}))return;const p=d!=null?d:Gt(),u=hr(o,c,g,i);await s({description:a,id:p,levels:u,name:e,ownerEntityRef:"group:default/toast-infra"})}},yr=e=>{const a=me(()=>e?vr(e):null,[e]),[r,l]=k([]),{data:n,isLoading:o}=Me(),i=n==null?void 0:n.edges.map(N=>N.checker),s=me(()=>(i!=null?i:[]).filter(N=>!!N).map(N=>{var S,D;return{id:(S=N.id)!=null?S:"",label:(D=N.name)!=null?D:""}}),[i]),{chips:d,inputChipsList:c,handleDrop:g,handleDelete:E,addInput:p,removeInput:u,inputErrors:h,areInputsValid:v,setInputChipsList:b}=Ht(r);return A(()=>{if(!r.length&&s.length){const{inputChips:N,used:S}=fr(a,s);b(N),l(S)}},[s,b,r.length,a]),{checkers:i,checkersLoading:o,chips:d,inputChipsList:c,handleDrop:g,handleDelete:E,addInput:p,removeInput:u,inputErrors:h,areInputsValid:v}},kr=e=>{const[a,r]=k(e);return{levelNames:a,handleLevelNameChange:(l,n)=>{r(a.map((o,i)=>i===n?l:o))},addLevelName:l=>{r([...a,l])},removeLevelName:l=>{r(a.filter((n,o)=>o!==l))}}},br=e=>{const[a,r]=k(e);return{levelDescriptions:a,handleLevelDescriptionChange:(l,n)=>{r(a.map((o,i)=>i===n?l:o))},addLevelDescription:l=>{r([...a,l])},removeLevelDescription:l=>{r(a.filter((n,o)=>o!==l))}}},Nr=y(e=>({description:{fontSize:e.typography.subtitle1.fontSize},cardContent:{"& *":{fontWeight:700}}})),Ue=({onSave:e,title:a,open:r,handleClose:l})=>{const{selectedProgram:n,isLoading:o,setSelectedProgram:i}=G(),{checkers:s,checkersLoading:d,chips:c,inputChipsList:g,handleDrop:E,handleDelete:p,addInput:u,removeInput:h,inputErrors:v,areInputsValid:b}=yr(n),{programName:N,programNameError:S,handleProgramNameChange:D,isProgramNameValid:H}=mr(n==null?void 0:n.name),{programDescription:$,programDescriptionError:V,handleProgramDescriptionChange:oe,isProgramDescriptionValid:f}=gr(n==null?void 0:n.description),{levelNames:x,handleLevelNameChange:T,addLevelName:ie,removeLevelName:se}=kr(g.map((Z,Ye)=>`Level ${Ye+1}`)),{levelDescriptions:K,handleLevelDescriptionChange:X,addLevelDescription:ce,removeLevelDescription:Y}=br(g.map(()=>"")),_=()=>{u(),ie(`Level ${g.length+1}`),ce("")},Ke=Z=>{h(Z),se(Z),Y(Z)},Xe=Cr({programName:N,programDescription:$,areInputsValid:b,isProgramNameValid:H,isProgramDescriptionValid:f,inputChipsList:g,checkers:s,onSave:e,programId:n==null?void 0:n.id,levelNames:x,levelDescriptions:K}),fe=Nr();return t.createElement(Oe,{handleClose:l,title:a,open:r},t.createElement(m,{container:!0,spacing:3,style:{overflow:"hidden"}},t.createElement(m,{item:!0,xs:12},t.createElement(Ha,{disabled:o,programName:N,programNameError:S,handleProgramNameChange:D})),t.createElement(m,{item:!0,xs:12},t.createElement(or,{disabled:o,programDescription:$,programDescriptionError:V,handleProgramDescriptionChange:oe})),t.createElement(m,{item:!0,xs:12},t.createElement(de,null,t.createElement(Ne,{className:fe.cardContent},t.createElement(m,{container:!0,spacing:4},t.createElement(m,{item:!0,xs:12},t.createElement(C,{className:fe.description},"Add the checks that apply to each level. You can preview the checks to see the rules that apply to each check.")),t.createElement(m,{item:!0,xs:5},t.createElement(Xa,{chips:c,isLoading:d||o})),t.createElement(m,{item:!0,xs:7},t.createElement(nr,{inputChipsList:g,handleDelete:p,handleDrop:E,addInput:_,removeInput:Ke,levelsErrors:v,levelNames:x,handleLevelNameChange:T,levelDescriptions:K,handleLevelDescriptionChange:X})))))),t.createElement(Fe,{onCancel:()=>{i(null),l()},saveButtonText:"Save Track",isLoading:o||d,onSave:Xe})))},xr=()=>{const{setIsLoading:e,setShowAddModal:a,showAddModal:r}=G(),{mutateAsync:l,isLoading:n}=Wt();return A(()=>{e(n)},[e,n]),t.createElement(Ue,{handleClose:()=>a(!1),title:"Create Track",open:r,onSave:async o=>{const i=await l(o);i&&window.open(`/soundcheck/tracks/${i.id}`,"_self")}})},Sr="Error Updating Track";function Lr(){const e=z(q),a=ee(),{showAlert:r}=ae(),l=async n=>{const o=await e.updateProgram(n);if(!o)throw new Error("Failed to update track.");return o};return te([re.UpdateProgram],l,{onSuccess:()=>{a.invalidateQueries({queryKey:[W.GetAllPrograms]})},onError:n=>{let o="Failed to update track.";n instanceof Error&&(o=n.message),r({severity:"error",title:Sr,message:o})}})}const wr=()=>{const{setSelectedProgram:e,setIsLoading:a,selectedProgram:r}=G(),{mutateAsync:l,isLoading:n}=Lr();return A(()=>a(n),[a,n]),t.createElement(Ue,{handleClose:()=>e(null),title:"Edit Track",open:!!r,onSave:async o=>{await l(o)&&e(null)}})},Dr=y(e=>({programsPageContainer:{padding:e.spacing(3)},headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap"}})),Pr=()=>{const{selectedProgram:e,showAddModal:a}=G(),[r]=ye(),l=r.get("tracksPerPage"),n=l?parseInt(l,10):10,o=Dr();return t.createElement("div",{className:o.programsPageContainer},t.createElement(Vt,{backend:Bt},t.createElement(qa,{programsPerPage:n}),a&&t.createElement(xr,null),e&&t.createElement(wr,null)))},Ir=()=>t.createElement(kt,null,t.createElement(Pr,null)),Tr=()=>t.createElement(C,null,"Coming Soon..."),Ar=({title:e="Soundcheck"})=>t.createElement(St,null,t.createElement(Lt,null,t.createElement(nt,{themeId:"website"},t.createElement(ot,{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(lt,{title:e}),t.createElement(wt,null,t.createElement(Je,null,t.createElement(et,{path:"/*",element:t.createElement(J,null,t.createElement(J.Route,{title:"Overview",path:"/"},t.createElement(Tr,null)),t.createElement(J.Route,{title:"Checks",path:"/checks"},t.createElement(Va,null)),t.createElement(J.Route,{title:"Tracks",path:"/tracks"},t.createElement(Ir,null)))}))))));export{Ar as RoutingPage};
2
- //# sourceMappingURL=index-0a05659f.esm.js.map