"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ObjectSchema=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),jotai_1=require("jotai"),common_1=require("../common"),Discriminator_1=require("../Discriminator"),store_1=require("../../jotai/store"),PropertyDetails_1=require("../PropertyDetails"),SubSchema_1=require("./SubSchema"),helpers_1=require("./helpers"),hooks_1=require("../../hooks"),styled_1=require("../common/styled");function ObjectSchemaComponent({schema:e,showTitle:r,discriminator:i,level:t,skipWriteOnly:s,skipReadOnly:a,fieldParentsName:n,expandable:l,deepLink:o,required:m,disableDeepLinks:c,shouldCloseArray:u,oneOfLevel:_,slug:d}){const{fields:p=[],title:h}=e,x=(0,hooks_1.useTranslate)(),{schemasExpansionLevel:j}=(0,jotai_1.useAtomValue)(store_1.globalOptionsAtom),y=a||s?p.filter((e=>!(a&&e.schema.readOnly||s&&e.schema.writeOnly))):p,b=(0,helpers_1.getExpandByDefault)({required:m,level:t,schemasExpansionLevel:j});return(0,jsx_runtime_1.jsxs)(SubSchema_1.SubSchema,{expandable:l,expandByDefault:b,level:t,propertyLength:y.length,deepLink:o,operationPointer:e.operationPointer,children:[(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[r&&(0,jsx_runtime_1.jsx)(common_1.PropertiesTableCaption,{children:h}),y.map(((e,l)=>(0,jsx_runtime_1.jsx)(PropertyDetails_1.PropertyDetails,{isFirst:0===l,field:e,fieldParentsName:Number(t)>1?n:[],renderDiscriminatorSwitch:(null==i?void 0:i.fieldName)===e.name&&(null==i?void 0:i.parentSchema)?()=>(0,jsx_runtime_1.jsx)(Discriminator_1.Discriminator,{parent:i.parentSchema,onChange:null==i?void 0:i.onChange,activeOneOfIdx:i.activeOneOfIdx,translate:x}):void 0,skipReadOnly:a,skipWriteOnly:s,showTitle:r,level:t,disableDeepLinks:c,oneOfLevel:_,slug:d},e.name)))]}),u&&(0,jsx_runtime_1.jsx)(styled_1.ArrayClosingLabel,{className:"array-closing-label",children:(0,jsx_runtime_1.jsx)(styled_1.LabelValue,{children:"]"})})]})}exports.ObjectSchema=(0,react_1.memo)(ObjectSchemaComponent);
//# sourceMappingURL=ObjectSchema.js.map