"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[4487],{94487:function(rt,j,e){e.r(j),e.d(j,{TechDocsCustomHome:function(){return ot}});var a=e(31085),m=e(14041),A=e(91638),v=e(58837),I=e(51372),P=e(6820),f=e(72427),B=e(16009),R=e(67871);function b(){const t=(0,f.gf)(B.K),{loading:o,value:n}=(0,A.default)(async()=>{const{ownershipEntityRefs:r}=await t.getBackstageIdentity();return r},[]),s=(0,m.useMemo)(()=>{const r=new Set(n!=null?n:[]);return c=>{const l=(0,R.t)(c,I.vv).map(P.U2);for(const i of l)if(r.has(i))return!0;return!1}},[n]);return{loading:o,isOwnedEntity:s}}var H=e(7341),D=e(86519),E=e(27125),O=e(82779),h=e(95768),W=e(9222),U=e(65461),p=e(10394),S=e(12398);const G=t=>(0,S.A)({root:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22em, 1fr))",gridAutoRows:"1fr",gridGap:t.spacing(2)}}),N=(0,v.A)(G,{name:"BackstageItemCardGrid"});function V(t){const{children:o,...n}=t,s=N(n);return(0,a.jsx)(p.A,{className:s.root,...n,children:o})}var T=e(72501);const z=t=>(0,S.A)({root:{color:t.palette.common.white,padding:t.spacing(2,2,3),backgroundImage:t.getPageTheme({themeId:"card"}).backgroundImage,backgroundPosition:0,backgroundSize:"inherit"}}),F=(0,v.A)(z,{name:"BackstageItemCardHeader"});function L(t){const{title:o,subtitle:n,children:s}=t,r=F(t);return(0,a.jsxs)(p.A,{className:r.root,children:[n&&(0,a.jsx)(T.A,{variant:"subtitle2",component:"h3",children:n}),o&&(0,a.jsx)(T.A,{variant:"h6",component:"h4",children:o}),s]})}var M=e(73896),K=e(40703),Y=e(59469),$=e(48653),J=e(57369);const Q=t=>{const{entities:o}=t,n=(0,W.S)(O.Oc),s=(0,f.gf)(U.U);return o?(0,a.jsx)(V,{"data-testid":"docs-explore",children:o!=null&&o.length?o.map((r,c)=>{var l,i;return(0,a.jsxs)(K.A,{children:[(0,a.jsx)(J.A,{children:(0,a.jsx)(L,{title:(l=r.metadata.title)!==null&&l!==void 0?l:r.metadata.name})}),(0,a.jsx)($.A,{children:r.metadata.description}),(0,a.jsx)(Y.A,{children:(0,a.jsx)(M.z,{to:n({namespace:(0,h.V)((i=r.metadata.namespace)!==null&&i!==void 0?i:"default",s),kind:(0,h.V)(r.kind,s),name:(0,h.V)(r.metadata.name,s)}),color:"primary","data-testid":"read_docs",children:"Read Docs"})})]},c)}):null}):null};var y=e(81859),X=e(59428),Z=e(3851),x=e(26280),k=e(68146),w=e(88640),q=e(77310),_=e(38605),tt=e(31653);const et=(0,v.A)(t=>({tabsWrapper:{gridArea:"pageSubheader",backgroundColor:t.palette.background.paper,paddingLeft:t.spacing(3),minWidth:0},defaultTab:{...t.typography.caption,padding:t.spacing(3,3),textTransform:"uppercase",fontWeight:t.typography.fontWeightBold,color:t.palette.text.secondary},selected:{color:t.palette.text.primary},tabRoot:{"&:hover":{backgroundColor:t.palette.background.default,color:t.palette.text.primary}}}),{name:"BackstageHeaderTabs"});function at(t){const{tabs:o,onChange:n,selectedIndex:s}=t,[r,c]=(0,m.useState)(s!=null?s:0),l=et(),i=(0,m.useCallback)((u,d)=>{s===void 0&&c(d),n&&n(d)},[s,n]);return(0,m.useEffect)(()=>{s!==void 0&&c(s)},[s]),(0,a.jsx)(p.A,{className:l.tabsWrapper,children:(0,a.jsx)(tt.A,{indicatorColor:"primary",textColor:"inherit",variant:"scrollable",scrollButtons:"auto","aria-label":"tabs",onChange:i,value:r,children:o.map((u,d)=>(0,m.createElement)(_.A,{...u.tabProps,"data-testid":`header-tab-${d}`,label:u.label,key:u.id,value:d,className:l.defaultTab,classes:{selected:l.selected,root:l.tabRoot}}))})})}const nt={DocsTable:E.o,DocsCardGrid:Q},st=({config:t,entities:o,index:n})=>{const r=(0,v.A)({panelContainer:{marginBottom:"2rem",...t.panelCSS?t.panelCSS:{}}})(),{loading:c,isOwnedEntity:l}=b(),i=nt[t.panelType],u=o.filter(d=>t.filterPredicate==="ownedByUser"?c?!1:l(d):typeof t.filterPredicate=="function"&&t.filterPredicate(d));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(X.d,{title:t.title,description:t.description,children:n===0?(0,a.jsx)(Z.Y,{children:"Discover documentation in your ecosystem."}):null}),(0,a.jsx)("div",{className:r.panelContainer,children:(0,a.jsx)(i,{"data-testid":"techdocs-custom-panel",entities:u})})]})},ot=t=>{const{tabsConfig:o}=t,[n,s]=(0,m.useState)(0),r=(0,f.gf)(H.v),{value:c,loading:l,error:i}=(0,A.default)(async()=>(await r.getEntities({filter:{"metadata.annotations.backstage.io/techdocs-ref":D.c},fields:["apiVersion","kind","metadata","relations","spec.owner","spec.type"]})).items.filter(g=>{var C;return!!(!((C=g.metadata.annotations)===null||C===void 0)&&C["backstage.io/techdocs-ref"])})),u=o[n];return l?(0,a.jsx)(y.S,{children:(0,a.jsx)(x.U,{children:(0,a.jsx)(k.k,{})})}):i?(0,a.jsx)(y.S,{children:(0,a.jsx)(x.U,{children:(0,a.jsx)(w.B,{severity:"error",title:"Could not load available documentation.",children:(0,a.jsx)(q.z,{language:"text",text:i.toString()})})})}):(0,a.jsxs)(y.S,{children:[(0,a.jsx)(at,{selectedIndex:n,onChange:d=>s(d),tabs:o.map(({label:d},g)=>({id:g.toString(),label:d}))}),(0,a.jsx)(x.U,{"data-testid":"techdocs-content",children:u.panels.map((d,g)=>(0,a.jsx)(st,{config:d,entities:c||[],index:g},g))})]})}}}]);})();

//# sourceMappingURL=4487.7a16d602.chunk.js.map