import lodash from "lodash";
import { useTranslation } from "react-i18next";
import { useFormBlockContext } from "../../../block-provider/FormBlockProvider.mjs";
import { useBaseVariable } from "./useBaseVariable.mjs";
const useRecordVariable = (props)=>{
    const { t } = useTranslation();
    const currentRecordVariable = useBaseVariable({
        collectionField: props.collectionField,
        uiSchema: props.schema,
        name: '$nRecord',
        title: t('Current record'),
        collectionName: props.collectionName,
        noDisabled: props.noDisabled,
        targetFieldSchema: props.targetFieldSchema
    });
    return currentRecordVariable;
};
const useCurrentRecordVariable = function() {
    let props = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
    const { t } = useTranslation();
    const { formRecord, collectionName } = useFormBlockContext();
    const currentRecordSettings = useBaseVariable({
        collectionField: props.collectionField,
        uiSchema: props.schema,
        name: '$nRecord',
        title: t('Current record'),
        collectionName: collectionName,
        noDisabled: props.noDisabled,
        targetFieldSchema: props.targetFieldSchema
    });
    return {
        currentRecordSettings,
        currentRecordCtx: null == formRecord ? void 0 : formRecord.data,
        shouldDisplayCurrentRecord: !(null == formRecord ? void 0 : formRecord.isNew) && !lodash.isEmpty(null == formRecord ? void 0 : formRecord.data),
        collectionName
    };
};
export { useCurrentRecordVariable, useRecordVariable };
