/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2026.5.0-rc1
 * Contact: hello@goauthentik.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import type { AuthenticatorAttachmentEnum } from "./AuthenticatorAttachmentEnum";
import {
    AuthenticatorAttachmentEnumFromJSON,
    AuthenticatorAttachmentEnumToJSON,
} from "./AuthenticatorAttachmentEnum";
import type { FlowSet } from "./FlowSet";
import { FlowSetFromJSON } from "./FlowSet";
import type { UserVerificationEnum } from "./UserVerificationEnum";
import { UserVerificationEnumFromJSON, UserVerificationEnumToJSON } from "./UserVerificationEnum";
import type { WebAuthnDeviceType } from "./WebAuthnDeviceType";
import { WebAuthnDeviceTypeFromJSON } from "./WebAuthnDeviceType";
import type { WebAuthnHintEnum } from "./WebAuthnHintEnum";
import { WebAuthnHintEnumFromJSON, WebAuthnHintEnumToJSON } from "./WebAuthnHintEnum";

/**
 * AuthenticatorWebAuthnStage Serializer
 * @export
 * @interface AuthenticatorWebAuthnStage
 */
export interface AuthenticatorWebAuthnStage {
    /**
     *
     * @type {string}
     * @memberof AuthenticatorWebAuthnStage
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof AuthenticatorWebAuthnStage
     */
    name: string;
    /**
     * Get object type so that we know how to edit the object
     * @type {string}
     * @memberof AuthenticatorWebAuthnStage
     */
    readonly component: string;
    /**
     * Return object's verbose_name
     * @type {string}
     * @memberof AuthenticatorWebAuthnStage
     */
    readonly verboseName: string;
    /**
     * Return object's plural verbose_name
     * @type {string}
     * @memberof AuthenticatorWebAuthnStage
     */
    readonly verboseNamePlural: string;
    /**
     * Return internal model name
     * @type {string}
     * @memberof AuthenticatorWebAuthnStage
     */
    readonly metaModelName: string;
    /**
     *
     * @type {Array<FlowSet>}
     * @memberof AuthenticatorWebAuthnStage
     */
    readonly flowSet: Array<FlowSet>;
    /**
     * Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.
     * @type {string}
     * @memberof AuthenticatorWebAuthnStage
     */
    configureFlow?: string | null;
    /**
     *
     * @type {string}
     * @memberof AuthenticatorWebAuthnStage
     */
    friendlyName?: string;
    /**
     *
     * @type {UserVerificationEnum}
     * @memberof AuthenticatorWebAuthnStage
     */
    userVerification?: UserVerificationEnum;
    /**
     *
     * @type {AuthenticatorAttachmentEnum}
     * @memberof AuthenticatorWebAuthnStage
     */
    authenticatorAttachment?: AuthenticatorAttachmentEnum | null;
    /**
     *
     * @type {UserVerificationEnum}
     * @memberof AuthenticatorWebAuthnStage
     */
    residentKeyRequirement?: UserVerificationEnum;
    /**
     *
     * @type {Array<WebAuthnHintEnum>}
     * @memberof AuthenticatorWebAuthnStage
     */
    hints?: Array<WebAuthnHintEnum>;
    /**
     *
     * @type {Array<string>}
     * @memberof AuthenticatorWebAuthnStage
     */
    deviceTypeRestrictions?: Array<string>;
    /**
     *
     * @type {Array<WebAuthnDeviceType>}
     * @memberof AuthenticatorWebAuthnStage
     */
    readonly deviceTypeRestrictionsObj: Array<WebAuthnDeviceType>;
    /**
     * When enabled, a given device can only be registered once.
     * @type {boolean}
     * @memberof AuthenticatorWebAuthnStage
     */
    preventDuplicateDevices?: boolean;
    /**
     *
     * @type {number}
     * @memberof AuthenticatorWebAuthnStage
     */
    maxAttempts?: number;
}

/**
 * Check if a given object implements the AuthenticatorWebAuthnStage interface.
 */
export function instanceOfAuthenticatorWebAuthnStage(
    value: object,
): value is AuthenticatorWebAuthnStage {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("component" in value) || value["component"] === undefined) return false;
    if (!("verboseName" in value) || value["verboseName"] === undefined) return false;
    if (!("verboseNamePlural" in value) || value["verboseNamePlural"] === undefined) return false;
    if (!("metaModelName" in value) || value["metaModelName"] === undefined) return false;
    if (!("flowSet" in value) || value["flowSet"] === undefined) return false;
    if (!("deviceTypeRestrictionsObj" in value) || value["deviceTypeRestrictionsObj"] === undefined)
        return false;
    return true;
}

export function AuthenticatorWebAuthnStageFromJSON(json: any): AuthenticatorWebAuthnStage {
    return AuthenticatorWebAuthnStageFromJSONTyped(json, false);
}

export function AuthenticatorWebAuthnStageFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): AuthenticatorWebAuthnStage {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        name: json["name"],
        component: json["component"],
        verboseName: json["verbose_name"],
        verboseNamePlural: json["verbose_name_plural"],
        metaModelName: json["meta_model_name"],
        flowSet: (json["flow_set"] as Array<any>).map(FlowSetFromJSON),
        configureFlow: json["configure_flow"] == null ? undefined : json["configure_flow"],
        friendlyName: json["friendly_name"] == null ? undefined : json["friendly_name"],
        userVerification:
            json["user_verification"] == null
                ? undefined
                : UserVerificationEnumFromJSON(json["user_verification"]),
        authenticatorAttachment:
            json["authenticator_attachment"] == null
                ? undefined
                : AuthenticatorAttachmentEnumFromJSON(json["authenticator_attachment"]),
        residentKeyRequirement:
            json["resident_key_requirement"] == null
                ? undefined
                : UserVerificationEnumFromJSON(json["resident_key_requirement"]),
        hints:
            json["hints"] == null
                ? undefined
                : (json["hints"] as Array<any>).map(WebAuthnHintEnumFromJSON),
        deviceTypeRestrictions:
            json["device_type_restrictions"] == null ? undefined : json["device_type_restrictions"],
        deviceTypeRestrictionsObj: (json["device_type_restrictions_obj"] as Array<any>).map(
            WebAuthnDeviceTypeFromJSON,
        ),
        preventDuplicateDevices:
            json["prevent_duplicate_devices"] == null
                ? undefined
                : json["prevent_duplicate_devices"],
        maxAttempts: json["max_attempts"] == null ? undefined : json["max_attempts"],
    };
}

export function AuthenticatorWebAuthnStageToJSON(json: any): AuthenticatorWebAuthnStage {
    return AuthenticatorWebAuthnStageToJSONTyped(json, false);
}

export function AuthenticatorWebAuthnStageToJSONTyped(
    value?: Omit<
        AuthenticatorWebAuthnStage,
        | "pk"
        | "component"
        | "verbose_name"
        | "verbose_name_plural"
        | "meta_model_name"
        | "flow_set"
        | "device_type_restrictions_obj"
    > | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        configure_flow: value["configureFlow"],
        friendly_name: value["friendlyName"],
        user_verification: UserVerificationEnumToJSON(value["userVerification"]),
        authenticator_attachment: AuthenticatorAttachmentEnumToJSON(
            value["authenticatorAttachment"],
        ),
        resident_key_requirement: UserVerificationEnumToJSON(value["residentKeyRequirement"]),
        hints:
            value["hints"] == null
                ? undefined
                : (value["hints"] as Array<any>).map(WebAuthnHintEnumToJSON),
        device_type_restrictions: value["deviceTypeRestrictions"],
        prevent_duplicate_devices: value["preventDuplicateDevices"],
        max_attempts: value["maxAttempts"],
    };
}
