"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var core_1 = require("../..");
var index_1 = require("./index");
var PDFTerminalField = /** @class */ (function (_super) {
    tslib_1.__extends(PDFTerminalField, _super);
    function PDFTerminalField(dict) {
        var _this = _super.call(this, dict) || this;
        _this.validateFieldType();
        return _this;
    }
    PDFTerminalField.fromDict = function (dict) {
        var fieldType = dict.lookup(core_1.PDFName.FT, core_1.PDFName);
        switch (fieldType) {
            case core_1.PDFName.Btn:
                return index_1.PDFAcroButton.fromDict(dict);
            case core_1.PDFName.Tx:
                return index_1.PDFAcroText.fromDict(dict);
            case core_1.PDFName.Ch:
                return index_1.PDFAcroChoice.fromDict(dict);
            case core_1.PDFName.Sig:
                return index_1.PDFSignature.fromDict(dict);
            default:
                return new PDFTerminalField(dict);
        }
    };
    PDFTerminalField.prototype.FT = function () {
        return this.lookupMaybeInheritableAttribute(core_1.PDFName.FT, core_1.PDFName);
    };
    PDFTerminalField.prototype.getKids = function () {
        var _a, _b;
        var kidDicts = (_a = this.Kids()) === null || _a === void 0 ? void 0 : _a.lookupElements(core_1.PDFDict);
        return (_b = kidDicts) === null || _b === void 0 ? void 0 : _b.map(function (childDict) { return core_1.PDFAnnotation.fromDict(childDict); });
    };
    PDFTerminalField.prototype.validateFieldType = function () {
        var fieldType = this.FT();
        var hasValidFieldType = index_1.acroFormFieldTypes.includes(fieldType);
        if (!hasValidFieldType) {
            throw new Error('Invalid PDFAcroField Type');
        }
    };
    return PDFTerminalField;
}(index_1.PDFAcroField));
exports.default = PDFTerminalField;
//# sourceMappingURL=PDFTerminalField.js.map