import { useMemo } from "react";
import { useFieldSchema } from "@tachybase/schema";
import { useParsedFilter } from "../../../../../block-provider/hooks/useParsedFilter.mjs";
import { useParentRecordCommon } from "../../../useParentRecordCommon.mjs";
const useTableBlockDecoratorProps = (props)=>{
    const params = useTableBlockParams(props);
    const parentRecord = useParentRecordCommon(props.association);
    return {
        params,
        parentRecord
    };
};
function useTableBlockParams(props) {
    var _props_params;
    const fieldSchema = useFieldSchema();
    const { filter: parsedFilter } = useParsedFilter({
        filterOption: null == (_props_params = props.params) ? void 0 : _props_params.filter
    });
    return 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 };
