export interface RecordLink {
    href: string;
    inertia: boolean;
}

export interface RecordFieldOption {
    value: string;
    label: string;
    meta?: string | null;
    icon?: string | null;
    disabled?: boolean;
}

export interface RecordLookupOption extends RecordFieldOption {
    /**
     * Application metadata returned by the lookup endpoint. It is never
     * submitted by the component, but lets a form react to a selected record
     * (for example, pre-filling a fund currency).
     */
    data?: Record<string, unknown>;
}

export interface RecordLookupConfig {
    url: string;
    minChars?: number;
    limit?: number;
    initialOption?: RecordLookupOption | null;
}

export type DynamicRecordFieldType =
    | 'text'
    | 'textarea'
    | 'date'
    | 'datetime-local'
    | 'money'
    | 'percent'
    | 'number'
    | 'dropdown'
    | 'boolean'
    | 'country'
    | 'lookup'
    | 'file'
    | 'separator';

export type RecordFormValue = string | boolean | File | null;

export type RecordFormValues = Record<string, RecordFormValue>;

export type LaravelValidationErrors = Record<string, string>;

export interface DynamicRecordField {
    name: string;
    type: DynamicRecordFieldType;
    label: string;
    value?: RecordFormValue;
    placeholder?: string | null;
    hint?: string | null;
    required?: boolean;
    disabled?: boolean;
    readonly?: boolean;
    wide?: boolean;
    rows?: number;
    inputmode?: 'decimal' | 'numeric' | 'text' | null;
    autocomplete?: string | null;
    min?: string | null;
    max?: string | null;
    step?: string | null;
    currency?: string | null;
    accept?: string | null;
    previewUrl?: string | null;
    maxlength?: number | null;
    options?: RecordFieldOption[];
    lookup?: RecordLookupConfig | null;
}

export interface DynamicRecordFormSchema {
    fields: DynamicRecordField[];
    values: RecordFormValues;
}

export interface RecordMetric {
    id: string;
    label: string;
    value: string;
}

export interface RecordSummaryDetail {
    id: string;
    label: string;
    value: string;
    link?: RecordLink | null;
}

export interface RecordDisplayField {
    id: string;
    label: string;
    value?: string | null;
    imageUrl?: string | null;
    description?: string | null;
    link?: RecordLink | null;
    wide?: boolean;
    separator?: boolean;
}

export interface RecordDeleteConfirmation {
    title: string;
    message: string;
    label: string;
    cancelLabel?: string;
    pendingLabel?: string;
}

export interface AliasRow {
    name: string;
    comment: string;
}
