import{jsx as o,Fragment as l,jsxs as s}from"react/jsx-runtime";import{css as d}from"styled-components";import{memo as w,useEffect as $,useState as j}from"react";import{isUndefined as C}from"@redocly/theme/core/openapi";import{cycleColorsByLevel as N}from"../PropertyDetails/cycleColorsByLevel.js";import{CircleIcon as S}from"../PropertyDetails/PlusCircleIcon.js";import{LabelValue as V}from"../common/styled.js";import{styled as c}from"../../styled-components.js";function _({expandByDefault:e,level:g,expandable:h=!1,expandText:v,hideText:x,hideDivider:y=!1,children:i,expandedAll:t,isNestedArray:n}){const[r,p]=j((e||n)??!1);$(()=>{C(t)||p(t)},[t]);const a=r?N(g):void 0;if(!h)return i;const b=()=>{p(u=>!u)};return n?s(l,{children:[o(V,{children:"Array ["}),o(f,{$isArrayInsideArray:n,className:"view-nested-wrapper",children:o(m,{color:a,children:i})})]}):o(l,{children:s(f,{$divider:!y&&!r,className:"view-nested-wrapper",children:[s(k,{onClick:b,children:[o(S,{sign:r?"-":"+",color:a}),!r&&v,r&&(x||"")]}),r&&o(m,{color:a,children:i})]})})}const U=w(_),k=c.button`
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
  gap: var(--spacing-xxs);
  color: var(--text-color-secondary);
  font-size: var(--font-size-base);
  font-family: var(--font-family-base);
  line-height: var(--line-height-base);
  margin-top: var(--spacing-xxs);
  width: 100%;
`,m=c.div`
  padding-left: var(--schema-nested-offset);
  border-left: 1px solid ${({color:e})=>e||"var(--border-color-primary)"};
  margin: -10px 0 0 9px;
  ${({color:e})=>e&&d`
      .schema-name {
        color: ${e};
      }
    `}
`,f=c.div`
  width: 100%;
  ${({$isArrayInsideArray:e})=>e&&d`
      padding-top: var(--schema-property-details-spacing);
    `}

  ${({$divider:e})=>e&&d`
      border-bottom: 1px solid var(--border-color-primary);
      padding-bottom: var(--schema-property-details-spacing);
    `}
`;export{U as ViewNested};
