"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConditionalFormattingsExtXform = void 0;
const composite_xform_1 = require("../../composite-xform.js");
const cf_rule_ext_xform_1 = require("./cf-rule-ext-xform.js");
const conditional_formatting_ext_xform_1 = require("./conditional-formatting-ext-xform.js");
class ConditionalFormattingsExtXform extends composite_xform_1.CompositeXform {
    constructor() {
        super();
        this.map = {
            "x14:conditionalFormatting": (this.cfXform = new conditional_formatting_ext_xform_1.ConditionalFormattingExtXform())
        };
    }
    get tag() {
        return "x14:conditionalFormattings";
    }
    hasContent(model) {
        if (model.hasExtContent === undefined) {
            model.hasExtContent = model.some(cf => cf.rules.some(cf_rule_ext_xform_1.CfRuleExtXform.isExt));
        }
        return model.hasExtContent;
    }
    prepare(model) {
        model.forEach(cf => {
            this.cfXform.prepare(cf);
        });
    }
    render(xmlStream, model) {
        if (this.hasContent(model)) {
            xmlStream.openNode(this.tag);
            model.forEach(cf => this.cfXform.render(xmlStream, cf));
            xmlStream.closeNode();
        }
    }
    createNewModel() {
        return [];
    }
    onParserClose(name, parser) {
        // model is array of conditional formatting objects
        this.model.push(parser.model);
    }
}
exports.ConditionalFormattingsExtXform = ConditionalFormattingsExtXform;
