import { useTranslation } from "react-i18next";
import { useCollection } from "../../../data-source/index.mjs";
import { useFlag } from "../../../flag-provider/index.mjs";
import { useSubFormValue } from "../../../schema-component/antd/association-field/hooks.mjs";
import { useBaseVariable } from "./useBaseVariable.mjs";
const useIterationVariable = (param)=>{
    let { currentCollection, collectionField, schema, noDisabled, targetFieldSchema } = param;
    const { t } = useTranslation();
    const result = useBaseVariable({
        collectionField,
        uiSchema: schema,
        targetFieldSchema,
        maxDepth: 4,
        name: '$iteration',
        title: t('Current object'),
        collectionName: currentCollection,
        noDisabled,
        returnFields: (fields, option)=>fields
    });
    return result;
};
const useCurrentObjectVariable = function() {
    let { collectionField, schema, noDisabled, targetFieldSchema } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
    const collection = useCollection();
    const { formValue: currentObjectCtx, collection: collectionOfCurrentObject } = useSubFormValue();
    const { isInSubForm, isInSubTable } = useFlag() || {};
    const { t } = useTranslation();
    const currentObjectSettings = useBaseVariable({
        collectionField,
        uiSchema: schema,
        targetFieldSchema,
        maxDepth: 4,
        name: '$iteration',
        title: t('Current object'),
        collectionName: (null == collectionOfCurrentObject ? void 0 : collectionOfCurrentObject.name) || (null == collection ? void 0 : collection.name),
        noDisabled,
        returnFields: (fields, option)=>fields
    });
    return {
        shouldDisplayCurrentObject: isInSubForm || isInSubTable,
        currentObjectCtx,
        currentObjectSettings
    };
};
export { useCurrentObjectVariable, useIterationVariable };
