"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const TextEncoder_1 = require("../../../../../wrap/TextEncoder");
const _ids_1 = require("../../../../_ids");
class TextEncoder_ extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['opt'],
            fo: ['encoder'],
        }, {
            output: {
                encoder: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_TEXT_ENCODER);
    }
    f({ opt }, done, fail) {
        const { api: { text: { TextEncoder }, }, } = this.__system;
        let encoder_;
        try {
            encoder_ = new TextEncoder();
        }
        catch (err) {
            fail(err.message.toLowerCase());
            return;
        }
        const encoder = (0, TextEncoder_1.wrapTextEncoder)(encoder_, this.__system);
        done({
            encoder,
        });
    }
}
exports.default = TextEncoder_;
//# sourceMappingURL=index.js.map