import{jsx as n,jsxs as s,Fragment as v}from"react/jsx-runtime";import{memo as A,useMemo as L}from"react";import{useLocation as j}from"react-router-dom";import{useAtomValue as w}from"jotai";import{Tabs as F,useTabsState as M}from"../Tabs/index.js";import{ResponseDetails as C}from"./ResponseDetails.js";import{makeDeepLink as N}from"../../services/index.js";import{Row as R,StyledTitle as _}from"./styled.js";import{LinkToField as B}from"../common/LinkToField.js";import{pathIncludesLink as c,hasNestedFields as D}from"../../utils/index.js";import{ExpandAllButton as E}from"../ExpandAllButton/index.js";import{useTranslate as P}from"../../hooks/index.js";import{getActiveMediaType as S}from"../../models/index.js";import{activeMimeNameAtom as $}from"../../jotai/app.js";import{styled as I}from"../../styled-components.js";const oe=A(({responses:i,renderTitle:f,operationId:a,operationPointer:d,activeResponseTab:m,onTabChange:u,callbackId:g,onPanelToggle:h})=>{const p=j(),T=P(),l=w($),r=i.map(({code:e})=>({key:e,title:e})),b=r.find(({key:e})=>e===m||c(p,a)&&c(p,`c=${e}`)),{activeTab:k,handleTabChange:x}=M({tabs:r,defaultTab:b?.key,onChange:u}),o=r.find(e=>e.key===(m||k)),t=i.find(e=>e.code===o?.key),y=L(()=>{if(!t?.content)return!1;const{schema:e}=S(t?.content,l)||{};return D(e)},[l,t?.content]);return o?s(v,{children:[s(O,{children:[f?.(o)||s(_,{children:[n(B,{to:N(a,`response&c=${o.key}`)}),T("openapi.responses","Responses")]}),n(F,{tabs:r,activeTab:o,onChange:x}),y&&n(E,{type:"response",operationPointer:d,onPanelToggle:h})]}),t?n("div",{children:n(C,{response:t,operationId:a,callbackId:g})},t.code):null]}):null}),O=I(R)`
  flex-wrap: wrap;
  gap: var(--spacing-unit);
  margin-top: var(--spacing-xl);
`;export{oe as OperationResponseList};
