import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../../hooks/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__components_index_mjs__ from "../components/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__SchemaSettingsDefaults_mjs__ from "../SchemaSettingsDefaults.mjs";
function useSchemaSettingsRender(name, options) {
    const app = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useApp)();
    const schemaSetting = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>app.schemaSettingsManager.get(name), [
        app.schemaSettingsManager,
        name
    ]);
    const renderCache = __WEBPACK_EXTERNAL_MODULE_react__["default"].useRef({});
    if (!name) return {
        exists: false,
        render: ()=>null
    };
    if (!schemaSetting) {
        console.error('[tachybase]: SchemaSettings "'.concat(name, '" not found'));
        return {
            exists: false,
            render: ()=>null
        };
    }
    return {
        exists: true,
        render: function() {
            let options2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
            const key = JSON.stringify(options2);
            if (key && renderCache.current[key]) return renderCache.current[key];
            const newItems = [
                ...__WEBPACK_EXTERNAL_MODULE__SchemaSettingsDefaults_mjs__.defaultSettingItems,
                ...schemaSetting.options.items
            ];
            return renderCache.current[key] = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__components_index_mjs__.SchemaSettingsWrapper, {
                ...{
                    ...schemaSetting.options,
                    items: newItems
                },
                ...options,
                ...options2
            });
        }
    };
}
export { useSchemaSettingsRender };
