import { jsx as _jsx } from "react/jsx-runtime";
import { memo } from 'react';
import { useLocation } from 'react-router-dom';
import { useAtomValue } from 'jotai/index';
import { pathIncludesLink } from '../../utils/index.js';
import { operationStore } from '../../jotai/operation.js';
import { extractTypeFromDeepLink } from './helpers.js';
import { ViewNested } from '../ViewNested/index.js';
import { useTranslate } from '../../hooks/index.js';
function SubSchemaComponent({ expandByDefault, deepLink, level, expandable = false, isNestedArray = false, isArray = '', propertyLength = '', children, operationPointer, }) {
    const translate = useTranslate();
    const location = useLocation();
    const expandByLocation = pathIncludesLink(location, deepLink);
    const type = extractTypeFromDeepLink(deepLink);
    const operationState = useAtomValue(operationStore(operationPointer || ''));
    const expandText = `${translate('openapi.actions.show', 'Show')} ${Number(propertyLength) === 1 ? '' : propertyLength} ${isArray && 'array '}${propertyLength !== 1 ? 'properties' : 'property'}`;
    return (_jsx(ViewNested, { expandByDefault: expandByDefault || expandByLocation, level: level, isNestedArray: isNestedArray, expandable: expandable, expandText: expandText, children: children, expandedAll: operationState[type]?.expandedAll }));
}
export const SubSchema = memo(SubSchemaComponent);
//# sourceMappingURL=SubSchema.js.map