import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_components__ from "@tachybase/components";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_antd_style__ from "antd-style";
import * as __WEBPACK_EXTERNAL_MODULE__built_in_acl_index_mjs__ from "../../../built-in/acl/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__ from "../../../collection-manager/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__index_mjs__ from "../../index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__select_Select_mjs__ from "../select/Select.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_mjs__ from "./hooks.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_mjs__ from "./schema.mjs";
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n      .ant-formily-item-bordered-none {\n        .ant-input-number-group-addon {\n          border: none !important;\n          background: none;\n        }\n        .ant-checkbox-wrapper {\n          margin-left: 8px;\n        }\n        .ant-table {\n          margin: 0px !important;\n        }\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const useStyles = (0, __WEBPACK_EXTERNAL_MODULE_antd_style__.createStyles)((param)=>{
    let { css } = param;
    return {
        container: css(_templateObject())
    };
});
const InternalSubTable = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)(()=>{
    var _field_componentProps;
    const { styles } = useStyles();
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const insert = (0, __WEBPACK_EXTERNAL_MODULE__hooks_mjs__.useInsertSchema)('SubTable');
    const insertSelector = (0, __WEBPACK_EXTERNAL_MODULE__hooks_mjs__.useInsertSchema)('Selector');
    const { options } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_mjs__.useAssociationFieldContext)();
    const { actionName } = (0, __WEBPACK_EXTERNAL_MODULE__built_in_acl_index_mjs__.useACLActionParamsContext)();
    (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
        insert(__WEBPACK_EXTERNAL_MODULE__schema_mjs__["default"].SubTable);
        field.required = fieldSchema['required'];
    }, []);
    (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
        var _field_componentProps;
        if (null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps.allowSelectExistingRecord) insertSelector(__WEBPACK_EXTERNAL_MODULE__schema_mjs__["default"].Selector);
    }, [
        null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps.allowSelectExistingRecord
    ]);
    const option = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useSchemaOptionsContext)();
    const components = {
        ...option.components,
        FormItem: __WEBPACK_EXTERNAL_MODULE__index_mjs__.FormItem,
        'Radio.Group': __WEBPACK_EXTERNAL_MODULE__select_Select_mjs__["default"],
        'Checkbox.Group': (props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__select_Select_mjs__["default"], {
                multiple: true,
                mode: "multiple",
                ...props
            })
    };
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.CollectionProvider_deprecated, {
        name: options.target,
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__built_in_acl_index_mjs__.ACLCollectionProvider, {
            actionPath: "".concat(options.target, ":").concat(actionName || 'view'),
            children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_components__.FormLayout, {
                className: styles.container,
                layout: 'vertical',
                bordered: false,
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.SchemaOptionsContext.Provider, {
                    value: {
                        scope: option.scope,
                        components
                    },
                    children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.RecursionField, {
                        onlyRenderProperties: true,
                        basePath: field.address,
                        schema: fieldSchema,
                        filterProperties: (s)=>'AssociationField.SubTable' === s['x-component']
                    })
                })
            })
        })
    });
}, {
    displayName: 'InternalSubTable'
});
export { InternalSubTable };
