"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../../Class/Holder");
const Array_1 = require("../../../../../../wrap/Array");
const _ids_1 = require("../../../../../_ids");
class Encode0 extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['opt', 'text', 'encoder'],
            fo: ['data'],
            i: [],
            o: [],
        }, {
            input: {
                encoder: {
                    ref: true,
                },
            },
            output: {
                data: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_ENCODE_1);
    }
    async f({ opt, text, encoder }, done, fail) {
        let data_;
        try {
            const text_ = text.raw();
            data_ = encoder.encode(opt, text_);
        }
        catch (err) {
            fail(err.message.toLowerCase());
            return;
        }
        const data = (0, Array_1.wrapUint8Array)(data_, this.__system);
        done({
            data,
        });
    }
}
exports.default = Encode0;
//# sourceMappingURL=index.js.map