"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SubSchema=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),react_router_dom_1=require("react-router-dom"),index_1=require("jotai/index"),theme_1=require("@redocly/theme"),utils_1=require("../../utils"),operation_1=require("../../jotai/operation"),helpers_1=require("./helpers"),ViewNested_1=require("../ViewNested");function SubSchemaComponent({expandByDefault:e,deepLink:r,level:t,expandable:i=!1,isArray:n="",propertyLength:o="",children:a,operationPointer:s}){var d;const u=(0,react_router_dom_1.useLocation)(),p=(0,utils_1.pathIncludesLink)(u,r),c=(0,helpers_1.extractTypeFromDeepLink)(r),[l,_]=(0,index_1.useAtom)((0,operation_1.operationStore)(s)),m=null===(d=l[c])||void 0===d?void 0:d.expandedFields[r||""],x=e=>{c&&r&&_((t=>{var i;return Object.assign(Object.assign({},t),{[c]:{expandedFields:Object.assign(Object.assign({},(null===(i=t[c])||void 0===i?void 0:i.expandedFields)||{}),{[r]:e})}})}))};(0,theme_1.useMount)((()=>{i&&(e||p)&&x(!0)}));const h=`Show ${1===Number(o)?"":o} ${n&&"array "}${1!==o?"properties":"property"}`;return(0,jsx_runtime_1.jsx)(ViewNested_1.ViewNested,{expandByDefault:e||p,isExpandedFromParent:m,level:t,expandable:i,onChange:()=>{x(!m)},expandText:h,children:a})}exports.SubSchema=(0,react_1.memo)(SubSchemaComponent);
//# sourceMappingURL=SubSchema.js.map