"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BodyContent=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),styled_components_1=__importDefault(require("styled-components")),jotai_1=require("jotai"),theme_1=require("@redocly/theme"),Dropdown_1=require("../Dropdown"),Fields_1=require("../Fields"),ConstraintsView_1=require("../ConstraintsView"),Schema_1=require("../../Schema"),models_1=require("../../../models"),Markdown_1=require("../../Markdown"),app_1=require("../../../jotai/app"),LinkToField_1=require("../LinkToField");function BodyContentComponent({required:e,skipReadOnly:i,skipWriteOnly:t,description:n,content:r,deepLink:o}){const[s,a]=(0,jotai_1.useAtom)(app_1.activeMimeNameAtom);if(!r)return null;const{schema:l,examples:d,operation:_,name:m}=(0,models_1.getActiveMediaType)(r,s),p=r.mediaTypes.map((({name:e})=>({label:e,value:e})));return(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsxs)(Title,{children:[o&&(0,jsx_runtime_1.jsx)(LinkToField_1.LinkToField,{to:o}),"Body",(0,jsx_runtime_1.jsx)(Dropdown_1.Dropdown,{options:p,value:m,triggerVariant:"ghost",triggerSize:"large",onChange:({value:e})=>a(e)})]}),e&&(0,jsx_runtime_1.jsx)(Fields_1.RequiredLabel,{children:"required"}),(0,jsx_runtime_1.jsx)(StyledMarkdown,{source:n}),"object"===(null==l?void 0:l.type)&&(null==l?void 0:l.constraints)&&(0,jsx_runtime_1.jsx)(ConstraintsView_1.ConstraintsView,{constraints:(null==l?void 0:l.constraints)||[]}),(0,jsx_runtime_1.jsx)(Schema_1.Schema,{skipReadOnly:i,skipWriteOnly:t,schema:l,examples:d,operation:_,level:1,disableDeepLinks:!o},"schema")]})}exports.BodyContent=(0,react_1.memo)(BodyContentComponent);const StyledMarkdown=(0,styled_components_1.default)(Markdown_1.Markdown)`
  margin: var(--spacing-xxs) 0 0;
`,Title=styled_components_1.default.span`
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--spacing-xxs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-color-primary);
  margin-top: var(--spacing-md);
  font-size: 18px;
  line-height: var(--line-height-lg);
  padding: var(--spacing-xxs) 0;

  :hover {
    ${theme_1.LinkIcon} {
      opacity: 1;
      visibility: visible;
    }
  }

  & button:not(:has(*)) {
    font-family: var(--font-family-monospaced);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-lg);
  }
`;
//# sourceMappingURL=BodyContent.js.map