import{jsx as s,jsxs as y}from"react/jsx-runtime";import{useMemo as E,memo as W,useState as _,useCallback as D}from"react";import{useNavigate as V}from"react-router-dom";import{LayoutVariant as z}from"@redocly/config";import{useAtomValue as K}from"jotai/index";import{SamplesPanel as L}from"../common/index.js";import{layoutAtom as X}from"../../jotai/app.js";import{OperationNavigationItems as i}from"./OperationNavigationItems.js";import{StyledButton as q}from"./styled.js";import{useTranslate as F}from"../../hooks/index.js";import{styled as x}from"../../styled-components.js";import{isRenderableMenuItem as G}from"../../utils/menu.js";const b=8;function H({items:c,routingBasePath:n}){const o=F(),[p,w]=_(!1),C=V(),O=K(X)===z.STACKED,{operations:m,webhooks:h,schemas:u,mcpTools:d,showMoreCount:v,totalCount:P,mcpResources:g,mcpPrompts:f,tags:l}=E(()=>{const a=c.filter(e=>G(e)),T=p?a:a.slice(0,b),{operations:M,additionalOperations:R,webhooks:A,schemas:B,mcpTools:I,mcpResources:N,mcpPrompts:j}=T.reduce((e,t)=>{if(t.type==="operation"&&t.isWebhook)e.webhooks.push(t);else if(t.type==="operation"){const k=t;k.isAdditionalOperation?e.additionalOperations.push(k):e.operations.push(k)}else t.type==="schema"?e.schemas.push(t):t.type==="tool"?e.mcpTools.push(t):t.type==="rsrc"?e.mcpResources.push(t):t.type==="prompt"&&e.mcpPrompts.push(t);return e},{operations:[],additionalOperations:[],webhooks:[],schemas:[],mcpTools:[],mcpResources:[],mcpPrompts:[]});return{operations:[...M,...R],schemas:B,mcpTools:I,webhooks:A,mcpResources:N,mcpPrompts:j,showMoreCount:!p&&a.length>b?a.length-b:0,totalCount:a.length,tags:c.filter(e=>e.type==="tag")}},[p,c]),r=D(a=>C(a),[C]),S=u.length>0||d.length>0||g.length>0||f.length>0||m.length>0||h.length>0;return!P&&l.length===0?null:y(J,{isStacked:O,"data-testid":"operation-navigation-list",children:[u.length>0&&s(i,{items:u,onClick:r,routingBasePath:n,translate:o,title:o("openapi.schemas","Schemas")}),d.length>0&&s(i,{items:d,onClick:r,routingBasePath:n,translate:o,title:o("openapi.mcp.tools","MCP Tools")}),g.length>0&&s(i,{items:g,onClick:r,routingBasePath:n,translate:o,title:o("openapi.mcp.resources","MCP Resources")}),f.length>0&&s(i,{items:f,onClick:r,routingBasePath:n,translate:o,title:o("openapi.mcp.prompts","MCP Prompts")}),m.length>0&&s(i,{items:m,onClick:r,routingBasePath:n,translate:o,title:o("openapi.operations","Operations")}),h.length>0&&s(i,{items:h,onClick:r,routingBasePath:n,translate:o,title:o("openapi.webhooks","Webhooks")}),!p&&!!v&&y(U,{variant:"link",size:"large","data-testid":"show-more-operations",fullWidth:!0,onClick:()=>w(!0),children:[o("openapi.actions.show","Show")," ",v," ",o("openapi.actions.more","more"),"..."]}),l.length>0&&S&&s(Q,{}),l.length>0&&s(i,{items:l,onClick:r,routingBasePath:n,translate:o,disableTooltip:!0})]})}const co=W(H),J=x(L)`
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxs);
  padding-top: var(--spacing-xxl);
`,Q=x.div`
  border-bottom: 1px solid var(--border-color-secondary);
  margin: var(--spacing-xs) 0;
  position: relative;

  &::before,
  &::after {
    content: '';
    position: absolute;
    bottom: -3px;
    width: 6px;
    height: 6px;
    background-color: var(--border-color-secondary);
    border-radius: 50%;
  }

  &::before {
    left: 0;
  }

  &::after {
    right: 0;
  }
`,U=x(q)`
  margin-top: var(--spacing-xxs);
`;export{co as OperationsNavigation,H as OperationsNavigationComponent};
