import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{memo,useMemo}from"react";import{useAtomValue}from"jotai";import styled from"styled-components";import{LinkIcon}from"@redocly/theme";import{RecursiveLabel,Tag,AccessLabel,RequiredLabel}from"../common";import{ExternalDocumentation}from"../ExternalDocumentation";import{Markdown}from"../Markdown";import{FieldDetail}from"./FieldDetail";import{Extensions}from"./Extensions";import{EnumValues}from"./EnumValues";import{Examples,getSerializedValue}from"./Examples";import{globalOptionsAtom}from"../../jotai/store";import{SchemaTypeInfo}from"./SchemaTypeInfo";import{LinkToField}from"../common/LinkToField";import{Pattern}from"./Pattern";import{getAccessModeLabelText}from"../RenderHook";function FieldDetailsComponent({field:e,renderDiscriminatorSwitch:t,deepLink:a,fieldParentsName:o=[]}){var i;const{hidePropertiesPrefix:r,hideSchemaTitles:s}=useAtomValue(globalOptionsAtom),{schema:n,description:l,example:m,deprecated:c,examples:p,kind:d,required:x,name:f}=e,h="header"===e.in,u=useMemo((()=>{if(void 0!==m||void 0!==p){if(void 0!==p)return _jsx(Examples,{field:e});{const t=!!e.in;return _jsx(FieldDetail,{label:"Example:",value:getSerializedValue(e,e.example),raw:t})}}return null}),[m,p,e]),y=getAccessModeLabelText(e.schema);return _jsxs(_Fragment,{children:[_jsxs(Row,{children:[f&&_jsxs(Name,{children:[a&&_jsx(LinkToField,{to:a}),!r&&o.map((e=>e+".")),_jsx(SchemaName,{className:"schema-name",children:f})]}),_jsx(SchemaTypeInfo,{type:n.typePrefix+n.displayType}),_jsx(SchemaTypeInfo,{type:n.displayFormat&&`(${n.displayFormat})`}),_jsx(SchemaTypeInfo,{type:n.contentEncoding}),_jsx(SchemaTypeInfo,{type:n.title&&!s?`(${n.title})`:""}),null===(i=n.constraints)||void 0===i?void 0:i.map((e=>_jsx(SchemaTypeInfo,{type:e},e))),c&&_jsx(DeprecatedLabel,{children:"Deprecated"}),_jsx(Pattern,{pattern:n.pattern}),"additionalProperties"===d&&_jsx(Tag,{children:"additional property"}),"patternProperties"===d&&_jsx(Tag,{children:"pattern property"}),y&&_jsx(AccessLabel,{children:y}),x&&_jsx(RequiredLabel,{children:"required"}),n.isCircular&&_jsx(RecursiveLabel,{children:"Recursive"})]}),_jsx(StyledDescription,{source:l}),_jsx(FieldDetail,{raw:h,label:"Default",value:n.default}),_jsx(EnumValues,{type:n.type,values:n["x-enumDescriptions"]||n.enum}),u,_jsx(Extensions,{extensions:Object.assign(Object.assign({},e.extensions),n.extensions)}),n.externalDocs&&_jsx(ExternalDocumentation,{externalDocs:n.externalDocs,compact:!0}),null==t?void 0:t(),_jsx(FieldDetail,{label:"Value",value:e.const||void 0})]})}export const FieldDetails=memo(FieldDetailsComponent);const Row=styled.div`
  display: flex;
  align-items: center;
  gap: calc(var(--spacing-xxs) / 4) var(--spacing-xxs);
  flex-wrap: wrap;
  margin-bottom: 2px;
  position: relative;
`,DeprecatedLabel=styled(Tag)`
  color: var(--badge-deprecated-text-color);
  background-color: var(--badge-deprecated-bg-color);
  font-family: var(--font-family-base);
`,StyledDescription=styled(Markdown)`
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);

  article p:last-child {
    margin-bottom: 0;
  }
`,Name=styled.span`
  position: relative;
  font-family: var(--font-family-monospaced);
  line-height: var(--line-height-base);
  font-size: var(--font-size-base);
  color: var(--text-color-description);
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;

  :hover {
    ${LinkIcon} {
      opacity: 1;
      visibility: visible;
      background-color: var(--bg-color);
    }
  }
`,SchemaName=styled.span`
  font-family: var(--font-family-monospaced);
  font-weight: var(--font-weight-semibold);
  font-size: var(--schemas-property-name-font-size);
  line-height: var(--schemas-property-name-line-height);
  color: var(--text-color-primary);
`;
//# sourceMappingURL=FieldDetails.js.map