"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[4487],{94487:(dt,j,e)=>{e.r(j),e.d(j,{TechDocsCustomHome:()=>rt});var a=e(31085),u=e(14041),A=e(73466),v=e(58837),I=e(51372),P=e(6820),h=e(72427),B=e(16009),R=e(67871);function H(){const t=(0,h.gf)(B.K),{loading:o,value:n}=(0,A.A)(async()=>{const{ownershipEntityRefs:r}=await t.getBackstageIdentity();return r},[]),s=(0,u.useMemo)(()=>{const r=new Set(n!=null?n:[]);return m=>{const l=(0,R.t)(m,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 b=e(7341),D=e(86519),E=e(27125),O=e(82779),p=e(95768),W=e(9222),N=e(65461),f=e(10394),S=e(12398);const U=t=>(0,S.A)({root:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22em, 1fr))",gridAutoRows:"1fr",gridGap:t.spacing(2)}}),G=(0,v.A)(U,{name:"BackstageItemCardGrid"});function L(t){const{children:o,...n}=t,s=G(n);return(0,a.jsx)(f.A,{className:s.root,...n,children:o})}var T=e(72501);const V=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"}}),z=(0,v.A)(V,{name:"BackstageItemCardHeader"});function F(t){const{title:o,subtitle:n,children:s}=t,r=z(t);return(0,a.jsxs)(f.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,h.gf)(N.U);return o?(0,a.jsx)(L,{"data-testid":"docs-explore",children:o!=null&&o.length?o.map((r,m)=>{var l,i;return(0,a.jsxs)(K.A,{children:[(0,a.jsx)(J.A,{children:(0,a.jsx)(F,{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,p.V)((i=r.metadata.namespace)!==null&&i!==void 0?i:"default",s),kind:(0,p.V)(r.kind,s),name:(0,p.V)(r.metadata.name,s)}),color:"primary","data-testid":"read_docs",children:"Read Docs"})})]},m)}):null}):null};var x=e(81859),X=e(59428),Z=e(27586),y=e(26280),k=e(68146),w=e(88640),q=e(77310),_=e(38605),tt=e(31653),et=e(72072);const at=(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 nt(t){const{tabs:o,onChange:n,selectedIndex:s}=t,[r,m]=(0,u.useState)(s!=null?s:0),l=at(),i=(0,u.useCallback)((d,c)=>{s===void 0&&m(c),n&&n(c)},[s,n]);(0,u.useEffect)(()=>{s!==void 0&&m(s)},[s]);function g(d){return d.replace(/^\//,"")}return(0,a.jsx)(f.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((d,c)=>(0,a.jsx)(_.A,{"data-testid":`header-tab-${c}`,label:d.label,component:et.N_,to:g(d.id),value:c,className:l.defaultTab,classes:{selected:l.selected,root:l.tabRoot},...d.tabProps},d.id))})})}const st={DocsTable:E.o,DocsCardGrid:Q},ot=({config:t,entities:o,index:n})=>{const r=(0,v.A)({panelContainer:{marginBottom:"2rem",...t.panelCSS?t.panelCSS:{}}})(),{loading:m,isOwnedEntity:l}=H(),i=st[t.panelType],g=o.filter(d=>t.filterPredicate==="ownedByUser"?m?!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:g})})]})},rt=t=>{const{tabsConfig:o}=t,[n,s]=(0,u.useState)(0),r=(0,h.gf)(b.v),{value:m,loading:l,error:i}=(0,A.A)(async()=>(await r.getEntities({filter:{"metadata.annotations.backstage.io/techdocs-ref":D.c},fields:["apiVersion","kind","metadata","relations","spec.owner","spec.type"]})).items.filter(c=>{var C;return!!(!((C=c.metadata.annotations)===null||C===void 0)&&C["backstage.io/techdocs-ref"])})),g=o[n];return l?(0,a.jsx)(x.S,{children:(0,a.jsx)(y.U,{children:(0,a.jsx)(k.k,{})})}):i?(0,a.jsx)(x.S,{children:(0,a.jsx)(y.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)(x.S,{children:[(0,a.jsx)(nt,{selectedIndex:n,onChange:d=>s(d),tabs:o.map(({label:d},c)=>({id:c.toString(),label:d}))}),(0,a.jsx)(y.U,{"data-testid":"techdocs-content",children:g.panels.map((d,c)=>(0,a.jsx)(ot,{config:d,entities:m||[],index:c},c))})]})}}}]);})();

//# sourceMappingURL=4487.5527ff90.chunk.js.map