import type { AllUnionFields, ValueOf } from 'type-fest';
import type { TopLevelDataSchema } from '../context/StateContext/types';
import type { NsTranslationKey } from '../../types';
import type { Scenario } from '../core/models/api/get-scenarios';
import type { PerCountry } from '../utils/perCountry';
export interface FieldSettings<RuleName extends string> {
    obscured?: boolean;
    rule?: RuleName | 'REQUIRED' | 'OPTIONAL';
    rules?: Array<RuleName>;
    /**
     * The default label is a translation of the field name.
     * Usually overridden by an {@link PerCountryFormConfiguration}.
     */
    label?: NsTranslationKey<'common'>;
}
/**
 * We're only interested in the keys of the inner schemas
 */
type GrandchildKeyOf<T> = keyof AllUnionFields<ValueOf<Required<T>>>;
/**
 * A {@link FormConfiguration} tells us for each field within a form, which rule(s) will decide if that
 * field is `REQUIRED` or `OPTIONAL`.
 *
 * Optionally they can mark a field as {@link FieldSettings.obscured},
 * which indicates that the API may give us a (partially) obscured value.
 */
export type FormConfiguration<TLDS extends TopLevelDataSchema, RuleName extends string> = Partial<Record<GrandchildKeyOf<TLDS>, // TODO replace this with `MappingKey<TLDS>` at some point
FieldSettings<RuleName>>>;
export type FormConfigurationWithoutRules<TLDS extends TopLevelDataSchema> = Partial<Record<GrandchildKeyOf<TLDS>, Pick<FieldSettings<string>, 'label'>>>;
/**
 * A form configuration is defined for each {@link Scenario}. Normally this means higher scenarios
 * (e.g. `L1_ID` or `L`) override rules for relevant fields, making more fields `REQUIRED`.
 */
export type PerScenarioFormConfiguration<TLDS extends TopLevelDataSchema, RuleName extends string> = Partial<Record<Scenario, FormConfiguration<TLDS, RuleName>>>;
export type PerCountryFormConfiguration<TLDS extends TopLevelDataSchema> = PerCountry<FormConfigurationWithoutRules<TLDS>>;
export {};
