import*as e from"react";import{useState as w}from"react";import N from"styled-components";import{HighlightContext as x}from"@redocly/portal-legacy-ui";import{breakpoints as O,getScorecardColorVariable as B}from"@redocly/theme/core/utils";import{FilterContent as D}from"@redocly/theme/components/Filter/FilterContent";import{FilterPopover as I}from"@redocly/theme/components/Filter/FilterPopover";import{CatalogPageWrapper as L,CatalogPageContent as R,CatalogTitle as W,CatalogDescription as M,CatalogPageDescriptionWrapper as j}from"@redocly/theme/components/CatalogClassic/CatalogClassic";import{useModalScrollLock as $}from"@redocly/theme/core/hooks";import{CatalogClassicActions as H}from"@redocly/theme/components/CatalogClassic/CatalogClassicActions";import{Sidebar as _}from"@redocly/theme/components/Sidebar/Sidebar";import{CardValue as p,CardsWrapper as q,ModeSwitcherTab as z,ModeSwitcherTabs as G,CardRow as J,ProblemsByStatusCardBody as K,ScoreCardStatusCardBody as Q,TableWrap as d,ContentWithDotWrap as U,ScorecardCard as h,ScorecardCardTitle as y}from"./index.styles";import{NON_CONFORMANT as T}from"./utils";import{ApiLevel as X,StatusDistribution as Y}from"./components";import{ApiListView as Z,TeamsView as ee,RulesView as te}from"./views";import{useData as re}from"./useData";function he(v){const{apis:A,summary:r,problemsByRule:S,nonConformantByTeam:P,sortedStatsByTeam:s,filterTerm:l,setFilterTerm:u,filters:a,scorecardInfo:f,hasTeam:i,hasPublishedAt:V,catalogConfig:E,teamLabel:n,teamProperty:F}=re(v),C={apis:"APIs",rules:"Rules",...i&&{teams:n}},[b,g]=e.useState(!1),[m,o]=w("apis");return $(b),e.createElement(x.Provider,{value:[l]},e.createElement(L,null,e.createElement(le,{menu:e.createElement(D,{setFilterTerm:u,filters:a,filterTerm:l,filterValuesCasing:E.filterValuesCasing})}),b&&e.createElement(I,{onClose:()=>g(!1),setFilterTerm:u,filterTerm:l,filters:a,filterValuesCasing:E.filterValuesCasing}),e.createElement(H,{onOpenFilter:()=>g(!0),filters:a,filterTerm:l}),e.createElement(R,{id:"scorecard-page-content"},e.createElement(j,null,e.createElement(W,null,"API design scorecard"),e.createElement(M,null,"See the health of your API designs.")),e.createElement(q,null,e.createElement(h,null,e.createElement(y,null,"Scorecard status"),e.createElement(Q,null,e.createElement("div",null,e.createElement(p,null,r.total),e.createElement("br",null),"APIs"),e.createElement("div",null,Object.entries(r.levels).map(([t,c],k)=>e.createElement(U,{key:t},e.createElement(p,{style:{width:"40px",textAlign:"right"}},c),e.createElement(X,{level:t,colorVariable:B(k,Object.values(r.levels).length)}))))),e.createElement(Y,{summary:r})),i&&e.createElement(h,null,e.createElement(y,null,`${T} APIs by ${n}`),e.createElement(K,null,P.slice(0,4).map((t,c)=>e.createElement(J,{key:c},e.createElement("span",{style:{flex:1,textAlign:"left"}},t.team),e.createElement(p,null,t.levels[T].apis))),s.length>4&&e.createElement("a",{href:"#",onClick:()=>o("teams")},"See all (",s.length,")")))),e.createElement(G,null,Object.keys(C).map(t=>t&&e.createElement(z,{key:t,isActive:m===t,onClick:()=>o(t)},C[t]))),e.createElement(d,{isActive:m==="apis"},e.createElement(Z,{data:A,levelNames:f.levelNames,hasTeam:i,hasPublishedAt:V,teamLabel:n})),e.createElement(d,{isActive:m==="rules"},e.createElement(te,{data:S})),i&&e.createElement(d,{isActive:m==="teams"},e.createElement(ee,{data:s,levelNames:f.levelNames,filters:a,setActiveTab:o,teamLabel:n,teamProperty:F})))))}const le=N(_)`
  display: none;

  @media screen and (min-width: ${O.medium}) {
    display: flex;
  }
  --menu-container-padding-top: 0;
`;export{he as ScorecardDashboard};
