"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Data = void 0;
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
// tslint:disable-next-line: no-var-requires
let bindings;
try {
    bindings = require(path.join(__dirname, "../../lib/binding/trusted_mailcore2.node"));
}
catch (e) {
    bindings = require(path.join(__dirname, "../../lib/binding/trusted_mailcore2_no_crypto.node"));
}
// tslint:disable-next-line
const { Data: _Data } = bindings;
/**
 * Data Class
 *
 * @public
 */
class Data extends bindings.Data {
    constructor(bufData) {
        super();
        const handle = new _Data(bufData);
        this.handle = handle;
    }
    /**
     * Length of data
     *
     * @memberof Data
     */
    length() {
        var _a;
        return ((_a = this.handle) === null || _a === void 0 ? void 0 : _a.length()) || 0;
    }
    /**
     * Bytes of data
     *
     * @memberof Data
     */
    bytes() {
        return this.handle.bytes();
    }
    /**
     * Convert data to BASE64 string
     *
     * @memberof Data
     */
    base64String() {
        return this.handle.base64String();
    }
    /**
     * Write data to file
     *
     * @memberof Data
     */
    writeToFile(filename) {
        return this.handle.writeToFile(filename);
    }
}
exports.Data = Data;
//# sourceMappingURL=Data.js.map