import{jsx as e,jsxs as p,Fragment as E}from"react/jsx-runtime";import{memo as T,useMemo as k}from"react";import{useAtomValue as S}from"jotai";import{LinkIcon as L}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{RecursiveLabel as h,Tag as x,AccessLabel as j,RequiredLabel as q,StyledBadge as A}from"../common/index.js";import{ExternalDocumentation as C}from"../ExternalDocumentation/index.js";import{Markdown as M}from"../Markdown/index.js";import{FieldDetail as l}from"./FieldDetail.js";import{Extensions as R}from"./Extensions.js";import{EnumValues as V}from"./EnumValues.js";import{Examples as $,getSerializedValue as N}from"./Examples.js";import{globalOptionsAtom as _}from"../../jotai/store.js";import{SchemaTypeInfo as i}from"./SchemaTypeInfo.js";import{LinkToField as B}from"../common/LinkToField.js";import{Pattern as I}from"./Pattern.js";import{getAccessModeLabelText as O}from"../RenderHook/index.js";import{useTranslate as G}from"../../hooks/index.js";import{styled as n}from"../../styled-components.js";function H({field:t,renderDiscriminatorSwitch:v,deepLink:m,fieldParentsName:y=[]}){const a=G(),{hidePropertiesPrefix:g,hideSchemaTitles:b}=S(_),{schema:r,description:w,example:c,deprecated:D,examples:s,kind:d,required:F,name:f}=t,P=t.in==="header",z=k(()=>{if(c!==void 0||s!==void 0){if(s!==void 0)return e($,{field:t});{const o=!!t.in;return e(l,{label:`${a("openapi.example","Example")}:`,value:N(t,t.example),raw:o})}}else return null},[c,s,t,a]),u=O(t.schema);return p(E,{children:[p(J,{children:[f&&p(Q,{children:[m&&e(B,{to:m}),!g&&y.map(o=>o+".\u200B"),e(U,{className:"schema-name",children:f})]}),e(i,{type:r.typePrefix+r.displayType}),e(i,{type:r.displayFormat&&`(${r.displayFormat})`}),e(i,{type:r.contentEncoding}),e(i,{type:r.title&&!b?`(${r.title})`:""}),r.constraints?.map(o=>e(i,{type:o},o)),D&&e(A,{deprecated:!0,children:a("openapi.badges.deprecated","Deprecated")}),e(I,{pattern:r.pattern}),d==="additionalProperties"&&e(x,{children:a("openapi.additionalProperties","additional property")}),d==="patternProperties"&&e(x,{children:a("openapi.patternProperties","pattern property")}),u&&e(j,{children:u}),F&&e(q,{children:a("openapi.required","required")}),r.isCircular&&e(h,{children:a("openapi.recursive","Recursive")})]}),r.isComplex&&e(h,{children:a("openapi.complex","Complex")}),e(K,{source:w}),e(l,{raw:P,type:"default",label:a("openapi.default","Default"),value:r.default}),e(V,{type:r.type,values:r["x-enumDescriptions"]||r.enum}),z,e(R,{extensions:{...t.extensions,...r.extensions}}),r.externalDocs&&e(C,{externalDocs:r.externalDocs,compact:!0}),v?.(),e(l,{label:a("openapi.value","Value"),value:t.const||void 0})]})}const ue=T(H),J=n.div`
  display: flex;
  align-items: center;
  gap: calc(var(--spacing-xxs) / 4) var(--spacing-xxs);
  flex-wrap: wrap;
  margin-bottom: 2px;
  position: relative;
`,K=n(M)`
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);

  article p:last-child {
    margin-bottom: 0;
  }
`,Q=n.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%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;

  :hover {
    ${L} {
      opacity: 1;
      visibility: visible;
      background-color: var(--bg-color);
    }
  }
`,U=n.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);
`;export{ue as FieldDetails};
