import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_record_CollectionRecordProvider_mjs__ from "../../../data-source/collection-record/CollectionRecordProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_AssociationProvider_mjs__ from "../../../data-source/collection/AssociationProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__flag_provider_hooks_useFlag_mjs__ from "../../../flag-provider/hooks/useFlag.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__useBaseVariable_mjs__ from "./useBaseVariable.mjs";
const useParentRecordVariable = (props)=>{
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const currentRecordVariable = (0, __WEBPACK_EXTERNAL_MODULE__useBaseVariable_mjs__.useBaseVariable)({
        collectionField: props.collectionField,
        uiSchema: props.schema,
        name: '$nParentRecord',
        title: t('Parent record'),
        maxDepth: 5,
        collectionName: props.collectionName,
        noDisabled: props.noDisabled,
        targetFieldSchema: props.targetFieldSchema
    });
    return currentRecordVariable;
};
const useCurrentParentRecordVariable = function() {
    let props = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
    var _record_parentRecord, _record_parentRecord1;
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const record = (0, __WEBPACK_EXTERNAL_MODULE__data_source_collection_record_CollectionRecordProvider_mjs__.useCollectionRecord)();
    const { name: parentCollectionName } = (0, __WEBPACK_EXTERNAL_MODULE__data_source_collection_AssociationProvider_mjs__.useParentCollection)() || {};
    const { isInSubForm, isInSubTable } = (0, __WEBPACK_EXTERNAL_MODULE__flag_provider_hooks_useFlag_mjs__.useFlag)() || {};
    const currentParentRecordSettings = (0, __WEBPACK_EXTERNAL_MODULE__useBaseVariable_mjs__.useBaseVariable)({
        collectionField: props.collectionField,
        uiSchema: props.schema,
        name: '$nParentRecord',
        title: t('Parent record'),
        collectionName: parentCollectionName,
        noDisabled: props.noDisabled,
        targetFieldSchema: props.targetFieldSchema
    });
    return {
        currentParentRecordSettings,
        currentParentRecordCtx: null == record ? void 0 : null === (_record_parentRecord = record.parentRecord) || void 0 === _record_parentRecord ? void 0 : _record_parentRecord.data,
        shouldDisplayCurrentParentRecord: !!(null == record ? void 0 : null === (_record_parentRecord1 = record.parentRecord) || void 0 === _record_parentRecord1 ? void 0 : _record_parentRecord1.data) && !isInSubForm && !isInSubTable,
        collectionName: parentCollectionName
    };
};
export { useCurrentParentRecordVariable, useParentRecordVariable };
