import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{memo}from"react";import{useAtomValue}from"jotai";import{PropertiesTableCaption}from"../common";import{Discriminator}from"../Discriminator";import{globalOptionsAtom}from"../../jotai/store";import{PropertyDetails}from"../PropertyDetails";import{SubSchema}from"./SubSchema";import{getExpandByDefault}from"./helpers";function ObjectSchemaComponent({schema:e,showTitle:i,discriminator:t,level:r,skipWriteOnly:a,skipReadOnly:o,fieldParentsName:n,expandable:m,deepLink:s,required:l,disableDeepLinks:p,oneOfLevel:c}){const{fields:d=[],title:h}=e,{schemasExpansionLevel:f}=useAtomValue(globalOptionsAtom),x=o||a?d.filter((e=>!(o&&e.schema.readOnly||a&&e.schema.writeOnly))):d,u=getExpandByDefault({required:l,level:r,schemasExpansionLevel:f});return _jsx(SubSchema,{expandable:m,expandByDefault:u,level:r,propertyLength:x.length,deepLink:s,operationPointer:e.operationPointer,children:_jsxs(_Fragment,{children:[i&&_jsx(PropertiesTableCaption,{children:h}),x.map(((e,m)=>_jsx(PropertyDetails,{isFirst:0===m,field:e,fieldParentsName:Number(r)>1?n:[],renderDiscriminatorSwitch:(null==t?void 0:t.fieldName)===e.name&&(null==t?void 0:t.parentSchema)?()=>_jsx(Discriminator,{parent:t.parentSchema,onChange:null==t?void 0:t.onChange,activeOneOfIdx:t.activeOneOfIdx}):void 0,skipReadOnly:o,skipWriteOnly:a,showTitle:i,level:r,disableDeepLinks:p,oneOfLevel:c},e.name)))]})})}export const ObjectSchema=memo(ObjectSchemaComponent);
//# sourceMappingURL=ObjectSchema.js.map