import{jsx as n,jsxs as a,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:s,operationPointer:d,activeResponseTab:m,onTabChange:u,callbackId:h,onPanelToggle:T})=>{const p=j(),b=P(),l=w($),r=i.map(({code:e})=>({key:e,title:e})),g=r.find(({key:e})=>e===m||c(p,s)&&c(p,`c=${e}`)),{activeTab:k,handleTabChange:x}=M({tabs:r,defaultTab:g?.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?a(v,{children:[a(O,{children:[f?.(o)||a(_,{children:[n(B,{to:N(s,`response&c=${o.key}`)}),b("openapi.responses","Responses")]}),n(F,{tabs:r,activeTab:o,onChange:x}),y&&n(E,{type:"response",operationPointer:d,onPanelToggle:T})]}),t?n("div",{children:n(C,{response:t,operationId:s,callbackId:h})},t.code):null]}):null}),O=I(R)`
  flex-wrap: wrap;
  gap: var(--spacing-unit);
`;export{oe as OperationResponseList};
