try {
	let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
	n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "87bc7e56-51dd-43a3-8783-f877a574bc29", e._sentryDebugIdIdentifier = "sentry-dbid-87bc7e56-51dd-43a3-8783-f877a574bc29");
} catch (e) {}
import { c as entriesOf } from "./AnalyticsContext-C0HNdPss.js";
import { r as getDataByFields } from "./validationResult-BC9WLYOC.js";
//#region src/utils/formUtils.ts
var createFormUtils = (props, t) => ({
	getLabel: (field, fallbackLabelKey) => {
		let translationKey = props.labels?.[field] ?? fallbackLabelKey ?? field;
		if (props.labels && !props.labels?.[field] && Object.keys(props.labels).length) {
			const parentKey = Object.keys(props.labels).find((fieldKey) => typeof props.labels?.[fieldKey] === "object");
			if (parentKey) translationKey = props.labels[parentKey][field] ?? translationKey;
		}
		return t(($) => $[translationKey]);
	},
	getMask: (field) => props.masks?.[field],
	isRequiredField: (field, showIfNotInRequiredFields = true) => props.requiredFields ? props.requiredFields.includes(field) && (field !== "role" || field === "role" && props.taskType !== "individual") : showIfNotInRequiredFields,
	isOptionalField: (field) => props.optionalFields?.includes(field) ?? false,
	isVisibleField(field, showIfNotInRequiredFields = true) {
		return this.isRequiredField(field, showIfNotInRequiredFields) || this.isOptionalField(field);
	},
	isReadOnly: (field) => props.readOnly || (props.readOnlyFields ? props.readOnlyFields.includes(field) : false),
	isObscured: (field) => props.obscuredFields ? props.obscuredFields.includes(field) : false,
	isTrusted: (field) => props.trustedFields ? props.trustedFields.includes(field) : false,
	getErrorMessage: (field, errors, fieldProblems) => {
		return errors?.[field]?.errorMessage || Boolean(fieldProblems?.[field]);
	},
	getFieldData: (formData, fieldKeys) => getDataByFields(formData, fieldKeys),
	getFieldValid: (formValid, fieldKeys) => entriesOf(formValid).reduce((acc, [key, val]) => fieldKeys.includes(key) ? {
		...acc,
		[key]: val
	} : acc, {}),
	getFieldErrors: (formErrors, fieldProblems, fieldKeys) => Object.keys(formErrors).reduce((acc, key) => {
		if (fieldKeys.includes(key)) {
			const error = formErrors?.[key]?.errorMessage;
			return error ? {
				...acc,
				[key]: error
			} : {
				...acc,
				[key]: Boolean(fieldProblems?.[key])
			};
		}
		return acc;
	}, {}),
	getFieldLabels: (fieldKeys, fallbackLabelKeys) => fieldKeys.reduce((acc, field) => {
		let translationKey = props.labels?.[field] ?? fallbackLabelKeys?.[field] ?? field;
		if (props.labels && !props.labels?.[field] && Object.keys(props.labels).length) {
			const parentKey = Object.keys(props.labels).find((fieldKey) => typeof props.labels?.[fieldKey] === "object");
			if (parentKey) translationKey = props.labels[parentKey][field] ?? translationKey;
		}
		return {
			...acc,
			[field]: t(($) => $[translationKey])
		};
	}, {})
});
var mergeFieldMetadataIntoProps = (fieldName, metadata, otherProps) => {
	const existingProps = otherProps ?? {};
	return {
		...existingProps,
		labels: {
			...existingProps.labels,
			[fieldName]: metadata.label
		},
		masks: {
			...existingProps.masks,
			[fieldName]: metadata.mask
		},
		validators: {
			...existingProps.validators,
			[fieldName]: metadata.validators
		}
	};
};
//#endregion
export { mergeFieldMetadataIntoProps as n, createFormUtils as t };
