"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperationResponseList=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),react_router_dom_1=require("react-router-dom"),styled_components_1=__importDefault(require("styled-components")),Tabs_1=require("../Tabs"),ResponseDetails_1=require("./ResponseDetails"),services_1=require("../../services"),styled_1=require("./styled"),LinkToField_1=require("../common/LinkToField"),utils_1=require("../../utils"),ExpandAllButton_1=require("../ExpandAllButton");exports.OperationResponseList=(0,react_1.memo)((({responses:e,renderTitle:t,operationId:s,operationPointer:r,activeResponseTab:n,onTabChange:i,callbackId:o})=>{const a=(0,react_router_dom_1.useLocation)(),l=e.map((({code:e})=>({key:e,title:e}))),_=l.find((({key:e})=>e===n||(0,utils_1.pathIncludesLink)(a,s)&&(0,utils_1.pathIncludesLink)(a,`c=${e}`))),{activeTab:u,handleTabChange:d}=(0,Tabs_1.useTabsState)({tabs:l,defaultTab:null==_?void 0:_.key,onChange:i}),p=l.find((e=>e.key===(n||u)));return p?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsxs)(TitleWrap,{children:[(null==t?void 0:t(p))||(0,jsx_runtime_1.jsxs)(styled_1.StyledTitle,{children:[(0,jsx_runtime_1.jsx)(LinkToField_1.LinkToField,{to:(0,services_1.makeDeepLink)(s,`response&c=${p.key}`)}),"Responses"]}),(0,jsx_runtime_1.jsx)(Tabs_1.Tabs,{tabs:l,activeTab:p,onChange:d}),(0,jsx_runtime_1.jsx)(ExpandAllButton_1.ExpandAllButton,{type:"response",operationPointer:r})]}),e.map((e=>e.code===p.key?(0,jsx_runtime_1.jsx)("div",{children:(0,jsx_runtime_1.jsx)(ResponseDetails_1.ResponseDetails,{response:e,operationId:s,operationPointer:r,callbackId:o})},e.code):null))]}):null}));const TitleWrap=(0,styled_components_1.default)(styled_1.Row)`
  flex-wrap: wrap;
  gap: var(--spacing-unit);
`;
//# sourceMappingURL=OperationResponseList.js.map