"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.TransactionSignatureView = void 0;
class TransactionSignatureView {
    /**
     * Creates an instance of TransactionSignatureView.
     * @param {SignedTransaction} tx
     */
    constructor(tx) {
        this.tx = tx;
    }
    /**
     * @static
     * @param {Transaction} transaction
     * @returns {ITransactionHeaderView}
     */
    static get(signedTransaction) {
        return new TransactionSignatureView(signedTransaction).render();
    }
    /**
     * @private
     * @returns {ITransactionHeaderView}
     */
    render() {
        return {
            SignatureDetailsTitle: this.title,
            Payload: this.formattedPayload,
            Hash: this.tx.hash,
            Signer: this.tx.signerPublicKey,
        };
    }
    /**
     * Creates a full-width and vertically centered cell
     * @readonly
     * @type {Cell} Table title
     */
    get title() {
        return {
            content: 'Signature details',
            colSpan: 2,
            hAlign: 'center',
        };
    }
    /**
     * Formatted payload that fits in the command line.
     * @readonly
     * @protected
     * @type {(string | undefined)}
     */
    get formattedPayload() {
        var _a;
        const payload = (_a = this.tx.payload.match(/.{1,64}/g)) === null || _a === void 0 ? void 0 : _a.join('\n');
        if (!payload) {
            return 'N/A';
        }
        return payload;
    }
}
exports.TransactionSignatureView = TransactionSignatureView;
