"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[2924],{12924:function(et,j,a){a.r(j),a.d(j,{TechDocsCustomHome:function(){return at}});var e=a(52322),h=a(2784),Z=a(64279),p=a(79692),b=a(81269),D=a(88624),P=a(88797),H=a(16787),I=a(95573),g=a(51953),B=a(37321),y=a(44394),A=a(6542),v=a(62774),T=a(42494);const R=t=>(0,T.Z)({root:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22em, 1fr))",gridAutoRows:"1fr",gridGap:t.spacing(2)}}),E=(0,p.Z)(R,{name:"BackstageItemCardGrid"});function W(t){const{children:r,...s}=t,n=E(s);return(0,e.jsx)(v.Z,{className:n.root,...s,children:r})}var S=a(90436);const G=t=>(0,T.Z)({root:{color:t.palette.common.white,padding:t.spacing(2,2,3),backgroundImage:t.getPageTheme({themeId:"card"}).backgroundImage,backgroundPosition:0,backgroundSize:"inherit"}}),F=(0,p.Z)(G,{name:"BackstageItemCardHeader"});function N(t){const{title:r,subtitle:s,children:n}=t,i=F(t);return(0,e.jsxs)(v.Z,{className:i.root,children:[s&&(0,e.jsx)(S.Z,{variant:"subtitle2",component:"h3",children:s}),r&&(0,e.jsx)(S.Z,{variant:"h6",component:"h4",children:r}),n]})}var O=a(15929),V=a(94339),L=a(16111),z=a(24579),M=a(14503);const Q=t=>{var r;const{entities:s}=t,n=(0,B.t)(I.Fw),i=(0,y.h_)(A.D);if(!s)return null;var c,l;return(0,e.jsx)(W,{"data-testid":"docs-explore",children:!((r=s)===null||r===void 0)&&r.length?s.map((d,m)=>(0,e.jsxs)(V.Z,{children:[(0,e.jsx)(L.Z,{children:(0,e.jsx)(N,{title:(c=d.metadata.title)!==null&&c!==void 0?c:d.metadata.name})}),(0,e.jsx)(z.Z,{children:d.metadata.description}),(0,e.jsx)(M.Z,{children:(0,e.jsx)(O.Q,{to:n({namespace:(0,g.D)((l=d.metadata.namespace)!==null&&l!==void 0?l:"default",i),kind:(0,g.D)(d.kind,i),name:(0,g.D)(d.metadata.name,i)}),color:"primary","data-testid":"read_docs",children:"Read Docs"})})]},m)):null})};var f=a(42081),U=a(30706),$=a(13788),C=a(42398),J=a(55015),K=a(538),X=a(9791),Y=a(6487),k=a(99152);const w=(0,p.Z)(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 q(t){const{tabs:r,onChange:s,selectedIndex:n}=t,[i,c]=(0,h.useState)(n!=null?n:0),l=w(),d=(0,h.useCallback)((m,o)=>{n===void 0&&c(o),s&&n!==o&&s(o)},[n,s]);return(0,h.useEffect)(()=>{n!==void 0&&c(n)},[n]),(0,e.jsx)(v.Z,{className:l.tabsWrapper,children:(0,e.jsx)(k.Z,{selectionFollowsFocus:!0,indicatorColor:"primary",textColor:"inherit",variant:"scrollable",scrollButtons:"auto","aria-label":"tabs",onChange:d,value:i,children:r.map((m,o)=>(0,h.createElement)(Y.Z,{...m.tabProps,"data-testid":`header-tab-${o}`,label:m.label,key:m.id,value:o,className:l.defaultTab,classes:{selected:l.selected,root:l.tabRoot}}))})})}const _={DocsTable:H.H,DocsCardGrid:Q},tt=({config:t,entities:r,index:s})=>{const i=(0,p.Z)({panelContainer:{marginBottom:"2rem",...t.panelCSS?t.panelCSS:{}}})(),{loading:c,isOwnedEntity:l}=(0,b.Z)(),d=_[t.panelType],m=r.filter(o=>t.filterPredicate==="ownedByUser"?c?!1:l(o):typeof t.filterPredicate=="function"&&t.filterPredicate(o));return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(U.y,{title:t.title,description:t.description,children:s===0?(0,e.jsx)($.q,{children:"Discover documentation in your ecosystem."}):null}),(0,e.jsx)("div",{className:i.panelContainer,children:(0,e.jsx)(d,{"data-testid":"techdocs-custom-panel",entities:m})})]})},at=t=>{const{tabsConfig:r}=t,[s,n]=(0,h.useState)(0),i=(0,y.h_)(D.A),{value:c,loading:l,error:d}=(0,Z.default)(async()=>(await i.getEntities({filter:{"metadata.annotations.backstage.io/techdocs-ref":P.n},fields:["apiVersion","kind","metadata","relations","spec.owner","spec.type"]})).items.filter(u=>{var x;return!!(!((x=u.metadata.annotations)===null||x===void 0)&&x["backstage.io/techdocs-ref"])})),m=r[s];return l?(0,e.jsx)(f.j,{children:(0,e.jsx)(C.V,{children:(0,e.jsx)(J.E,{})})}):d?(0,e.jsx)(f.j,{children:(0,e.jsx)(C.V,{children:(0,e.jsx)(K.G,{severity:"error",title:"Could not load available documentation.",children:(0,e.jsx)(X.O,{language:"text",text:d.toString()})})})}):(0,e.jsxs)(f.j,{children:[(0,e.jsx)(q,{selectedIndex:s,onChange:o=>n(o),tabs:r.map(({label:o},u)=>({id:u.toString(),label:o}))}),(0,e.jsx)(C.V,{"data-testid":"techdocs-content",children:m.panels.map((o,u)=>(0,e.jsx)(tt,{config:o,entities:c||[],index:u},u))})]})}}}]);})();

//# sourceMappingURL=2924.b757596e.chunk.js.map