// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { CommandHandler } from "../../../../../core/decorator/CommandHandlerDecorator";
import TransactionService from "../../../../service/transaction/TransactionService";
import { ConnectCommand, ConnectCommandResponse } from "./ConnectCommand";
import { ConnectCommandError } from "./error/ConnectCommandError";
let ConnectCommandHandler = class ConnectCommandHandler {
    async execute(command) {
        try {
            const handler = TransactionService.getHandlerClass(command.wallet);
            const debug = command.debug ? command.debug : false;
            const input = command.custodialSettings === undefined
                ? command.HWCSettings === undefined
                    ? command.account
                    : command.HWCSettings
                : command.custodialSettings;
            const registration = await handler.register(input, debug);
            return Promise.resolve(new ConnectCommandResponse(registration, command.wallet));
        }
        catch (error) {
            throw new ConnectCommandError(error);
        }
    }
};
ConnectCommandHandler = __decorate([
    CommandHandler(ConnectCommand)
], ConnectCommandHandler);
export { ConnectCommandHandler };
