//
// Copyright © 2023 Nevis Security AG. All rights reserved.
//

import NevisMobileAuthentication

final class AuthenticatorSelectorImpl: Sendable {
	// MARK: Properties

	let operationId: String

	// MARK: Initialization

	init(operationId: String) {
		self.operationId = operationId
	}
}

// MARK: - AuthenticatorSelector

extension AuthenticatorSelectorImpl: AuthenticatorSelector {
	func selectAuthenticator(context: AuthenticatorSelectionContext, handler: AuthenticatorSelectionHandler) {
		Task {
			let state = SelectAuthenticatorState(context: context, handler: handler)
			let message = AuthenticatorSelectorMessage(operationId: operationId,
			                                           context: context)
			await selectAuthenticator(operationId: operationId, message: message, userInteractionState: state)
		}
	}
}
