import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__block_provider_hooks_useParsedFilter_mjs__ from "../../../../../block-provider/hooks/useParsedFilter.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__useParentRecordCommon_mjs__ from "../../../useParentRecordCommon.mjs";
const useTableBlockDecoratorProps = (props)=>{
    const params = useTableBlockParams(props);
    const parentRecord = (0, __WEBPACK_EXTERNAL_MODULE__useParentRecordCommon_mjs__.useParentRecordCommon)(props.association);
    return {
        params,
        parentRecord
    };
};
function useTableBlockParams(props) {
    var _props_params;
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const { filter: parsedFilter } = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_hooks_useParsedFilter_mjs__.useParsedFilter)({
        filterOption: null === (_props_params = props.params) || void 0 === _props_params ? void 0 : _props_params.filter
    });
    return (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        const params = props.params || {};
        const { dragSortBy } = (null == fieldSchema ? void 0 : fieldSchema['x-decorator-props']) || {};
        if (props.dragSort && dragSortBy) params['sort'] = dragSortBy;
        const paramsWithFilter = {
            ...params,
            filter: parsedFilter
        };
        return paramsWithFilter;
    }, [
        fieldSchema,
        parsedFilter,
        props.dragSort,
        props.params
    ]);
}
export { useTableBlockDecoratorProps, useTableBlockParams };
