"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ContentItem=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),jotai_1=require("jotai"),services_1=require("../../services"),TagItem_1=require("../TagItem"),OperationItem_1=require("../OperationItem"),common_1=require("../common"),useIsExpanded_1=require("./useIsExpanded"),SectionItem_1=require("../SectionItem"),useScrollOnRender_1=__importDefault(require("../ContentItems/useScrollOnRender")),helpers_1=require("../ContentItems/helpers"),ApiInfo_1=require("../ApiInfo"),app_1=require("../../jotai/app"),ContentComponentMap={group:null,tag:TagItem_1.TagItem,section:SectionItem_1.SectionItem,schema:TagItem_1.TagItem,operation:OperationItem_1.OperationItem,root:ApiInfo_1.ApiInfo};function ContentItemComponent({item:e,routingBasePath:t,children:n,layout:r}){var o;const i=ContentComponentMap[(0,helpers_1.isRootItem)(e)?"root":e.type],a="tag"===e.type&&e.items.length>0,s=(0,useIsExpanded_1.useIsExpanded)({item:e,routingBasePath:t});let m=(0,useScrollOnRender_1.default)(e,t);const u=(0,jotai_1.useAtomValue)(app_1.layoutAtom);return(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[i&&(0,jsx_runtime_1.jsx)(common_1.Section,{id:e.id,ref:m,sectionId:(0,services_1.joinWithSeparator)(t,e.id),underlined:"operation"===e.type||"schema"===e.type,expanded:a&&!s,children:(0,jsx_runtime_1.jsx)(i,{item:e,routingBasePath:t,isExpanded:s,layout:r||u})}),(s||"tag"!==e.type)&&Boolean(null===(o=e.items)||void 0===o?void 0:o.length)&&(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:n})]})}exports.ContentItem=(0,react_1.memo)(ContentItemComponent);
//# sourceMappingURL=ContentItem.js.map