"use strict";
/*
 *
 * Copyright 2018-present NEM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.transactionDetailViewFactory = void 0;
const symbol_sdk_1 = require("symbol-sdk");
const transaction_types_1 = require("./transaction-types");
/**
 * @param  {Transaction} transaction
 * @returns {CellRecord}
 */
const transactionDetailViewFactory = (tx) => {
    try {
        const type = tx.type;
        if (type === symbol_sdk_1.TransactionType.RESERVED) {
            throw new Error('The transaction type can not be reserved');
        }
        // @ts-ignore
        const formatters = {
            [symbol_sdk_1.TransactionType.RESERVED]: {},
            [symbol_sdk_1.TransactionType.ACCOUNT_METADATA]: transaction_types_1.AccountMetadataView,
            [symbol_sdk_1.TransactionType.ACCOUNT_ADDRESS_RESTRICTION]: transaction_types_1.AccountAddressRestrictionView,
            [symbol_sdk_1.TransactionType.ACCOUNT_MOSAIC_RESTRICTION]: transaction_types_1.AccountMosaicRestrictionView,
            [symbol_sdk_1.TransactionType.ACCOUNT_OPERATION_RESTRICTION]: transaction_types_1.AccountOperationRestrictionView,
            [symbol_sdk_1.TransactionType.ADDRESS_ALIAS]: transaction_types_1.AddressAliasView,
            [symbol_sdk_1.TransactionType.AGGREGATE_BONDED]: transaction_types_1.AggregateBondedView,
            [symbol_sdk_1.TransactionType.AGGREGATE_COMPLETE]: transaction_types_1.AggregateCompleteView,
            [symbol_sdk_1.TransactionType.ACCOUNT_KEY_LINK]: transaction_types_1.AccountKeyLinkView,
            [symbol_sdk_1.TransactionType.HASH_LOCK]: transaction_types_1.HashLockView,
            [symbol_sdk_1.TransactionType.MULTISIG_ACCOUNT_MODIFICATION]: transaction_types_1.MultisigAccountModificationView,
            [symbol_sdk_1.TransactionType.MOSAIC_ADDRESS_RESTRICTION]: transaction_types_1.MosaicAddressRestrictionView,
            [symbol_sdk_1.TransactionType.MOSAIC_ALIAS]: transaction_types_1.MosaicAliasView,
            [symbol_sdk_1.TransactionType.MOSAIC_GLOBAL_RESTRICTION]: transaction_types_1.MosaicGlobalRestrictionView,
            [symbol_sdk_1.TransactionType.NAMESPACE_METADATA]: transaction_types_1.NamespaceMetadataView,
            [symbol_sdk_1.TransactionType.MOSAIC_SUPPLY_CHANGE]: transaction_types_1.MosaicSupplyChangeView,
            [symbol_sdk_1.TransactionType.MOSAIC_DEFINITION]: transaction_types_1.MosaicDefinitionView,
            [symbol_sdk_1.TransactionType.MOSAIC_METADATA]: transaction_types_1.MosaicMetadataView,
            [symbol_sdk_1.TransactionType.NAMESPACE_REGISTRATION]: transaction_types_1.NamespaceRegistrationView,
            [symbol_sdk_1.TransactionType.NODE_KEY_LINK]: transaction_types_1.NodeKeyLinkView,
            [symbol_sdk_1.TransactionType.SECRET_LOCK]: transaction_types_1.SecretLockView,
            [symbol_sdk_1.TransactionType.SECRET_PROOF]: transaction_types_1.SecretProofView,
            [symbol_sdk_1.TransactionType.TRANSFER]: transaction_types_1.TransferView,
            [symbol_sdk_1.TransactionType.VRF_KEY_LINK]: transaction_types_1.VrfKeyLinkView,
            [symbol_sdk_1.TransactionType.VOTING_KEY_LINK]: transaction_types_1.VotingKeyLinkView,
        };
        const formatter = formatters[type];
        return formatter.get(tx);
    }
    catch (error) {
        throw new Error(`Transaction type not found: ${tx.type}`);
    }
};
exports.transactionDetailViewFactory = transactionDetailViewFactory;
