import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{memo}from"react";import{useLocation}from"react-router-dom";import styled from"styled-components";import{Tabs,useTabsState}from"../Tabs";import{ResponseDetails}from"./ResponseDetails";import{makeDeepLink}from"../../services";import{Row,StyledTitle}from"./styled";import{LinkToField}from"../common/LinkToField";import{pathIncludesLink}from"../../utils";import{ExpandAllButton}from"../ExpandAllButton";export const OperationResponseList=memo((({responses:e,renderTitle:o,operationId:t,operationPointer:s,activeResponseTab:n,onTabChange:a,callbackId:i})=>{const r=useLocation(),l=e.map((({code:e})=>({key:e,title:e}))),p=l.find((({key:e})=>e===n||pathIncludesLink(r,t)&&pathIncludesLink(r,`c=${e}`))),{activeTab:m,handleTabChange:d}=useTabsState({tabs:l,defaultTab:null==p?void 0:p.key,onChange:a}),c=l.find((e=>e.key===(n||m)));return c?_jsxs(_Fragment,{children:[_jsxs(TitleWrap,{children:[(null==o?void 0:o(c))||_jsxs(StyledTitle,{children:[_jsx(LinkToField,{to:makeDeepLink(t,`response&c=${c.key}`)}),"Responses"]}),_jsx(Tabs,{tabs:l,activeTab:c,onChange:d}),_jsx(ExpandAllButton,{type:"response",operationPointer:s})]}),e.map((e=>e.code===c.key?_jsx("div",{children:_jsx(ResponseDetails,{response:e,operationId:t,operationPointer:s,callbackId:i})},e.code):null))]}):null}));const TitleWrap=styled(Row)`
  flex-wrap: wrap;
  gap: var(--spacing-unit);
`;
//# sourceMappingURL=OperationResponseList.js.map