import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{memo}from"react";import{useAtomValue}from"jotai";import{joinWithSeparator}from"../../services";import{TagItem}from"../TagItem";import{OperationItem}from"../OperationItem";import{Section}from"../common";import{useIsExpanded}from"./useIsExpanded";import{SectionItem}from"../SectionItem";import useScrollOnRender from"../ContentItems/useScrollOnRender";import{isRootItem}from"../ContentItems/helpers";import{ApiInfo}from"../ApiInfo";import{layoutAtom}from"../../jotai/app";const ContentComponentMap={group:null,tag:TagItem,section:SectionItem,schema:TagItem,operation:OperationItem,root:ApiInfo};function ContentItemComponent({item:t,routingBasePath:e,children:o,layout:n}){var m;const r=ContentComponentMap[isRootItem(t)?"root":t.type],i="tag"===t.type&&t.items.length>0,a=useIsExpanded({item:t,routingBasePath:e});let s=useScrollOnRender(t,e);const p=useAtomValue(layoutAtom);return _jsxs(_Fragment,{children:[r&&_jsx(Section,{id:t.id,ref:s,sectionId:joinWithSeparator(e,t.id),underlined:"operation"===t.type||"schema"===t.type,expanded:i&&!a,children:_jsx(r,{item:t,routingBasePath:e,isExpanded:a,layout:n||p})}),(a||"tag"!==t.type)&&Boolean(null===(m=t.items)||void 0===m?void 0:m.length)&&_jsx(_Fragment,{children:o})]})}export const ContentItem=memo(ContentItemComponent);
//# sourceMappingURL=ContentItem.js.map