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

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