import { __decorate, __metadata } from "tslib";
import { Component, Input } from '@angular/core';
import { OrderFormSectionData } from './order-form-section-data';
let OrderFormSectionComponent = class OrderFormSectionComponent {
    constructor() { }
    ngOnInit() {
        // The first section should always be expanded.
        const topSection = this.getTopSection();
        if (topSection) {
            topSection.startOpen = true;
        }
    }
    getTopSection() {
        if (!this.data) {
            return null;
        }
        if (this.data.primarySection) {
            return this.data.primarySection;
        }
        if (this.data.subsections && this.data.subsections.length > 0) {
            return this.data.subsections[0];
        }
        return null;
    }
};
__decorate([
    Input(),
    __metadata("design:type", OrderFormSectionData)
], OrderFormSectionComponent.prototype, "data", void 0);
OrderFormSectionComponent = __decorate([
    Component({
        selector: 'va-order-form-section',
        template: "<div>\n  <mat-card class=\"va-order-form-section-header mat-card display\">\n    <div class=\"product-overview\">\n      <div class=\"product-id\">\n        <va-icon [iconUrl]=\"data.iconUrl\" [name]=\"data.titleText\" [diameter]=\"45\"></va-icon>\n        <div class=\"product-id-text\">\n          <h1 class=\"product-title\">{{ data.titleText }}</h1>\n          <span *ngIf=\"data.subtitleText\" class=\"tagline\">{{ data.subtitleText }}</span>\n        </div>\n      </div>\n      <div class=\"description\" *ngIf=\"data.descriptionText\">\n        <span>{{ data.descriptionText }}</span>\n      </div>\n    </div>\n  </mat-card>\n  <div class=\"print\">\n    <h2>{{ data.titleText }}</h2>\n  </div>\n  <va-dropdown-form-section class=\"va-primary-form-section\" *ngIf=\"data.primarySection\"\n                            [titleText]=\"data.primarySection.titleText\"\n                            [editingHint]=\"data.primarySection.editingHint\"\n                            [displayAutoDescription]=\"data.primarySection.displayAutoDescription\"\n                            [descriptionText]=\"data.primarySection.descriptionText\"\n                            [displayAutoTitle]=\"data.primarySection.displayAutoTitle\"\n                            [prepopulatedData]=\"data.primarySection.prepopulatedData\"\n                            [parentForm]=\"data.parentForm\"\n                            [fields]=\"data.primarySection.fields\"\n                            [startOpen]=\"data.primarySection.startOpen\"\n                            [expandable]=\"data.primarySection.expandable\">\n  </va-dropdown-form-section>\n  <ng-container *ngIf=\"data.subsections?.length > 0\">\n    <va-dropdown-form-section class=\"va-secondary-form-section\" *ngFor=\"let addon of data.subsections\"\n                              [titleText]=\"addon.titleText\"\n                              [editingHint]=\"addon.editingHint\"\n                              [displayAutoDescription]=\"addon.displayAutoDescription\"\n                              [descriptionText]=\"addon.descriptionText\"\n                              [displayAutoTitle]=\"addon.displayAutoTitle\"\n                              [prepopulatedData]=\"addon.prepopulatedData\"\n                              [parentForm]=\"data.parentForm\"\n                              [fields]=\"addon.fields\"\n                              [startOpen]=\"addon.startOpen\"\n                              [expandable]=\"addon.expandable\">\n    </va-dropdown-form-section>\n  </ng-container>\n  <ng-container *ngIf=\"!data.primarySection && !(data.subsections?.length > 0)\">\n    <mat-card class=\"not-expandable-card\">\n      <ng-content></ng-content>\n    </mat-card>\n  </ng-container>\n</div>\n",
        styles: [":host{font-size:16px}mat-card.va-order-form-section-header{margin-bottom:0;border-bottom-color:#e0e0e0;border-bottom-width:1px;box-shadow:0 0 1px -2px rgba(0,0,0,.2),0 0 2px 0 rgba(0,0,0,.14),0 0 5px 0 rgba(0,0,0,.12)}.product-title{font-size:16px}va-mat-card{margin-bottom:24px}.product-overview{display:flex;flex-wrap:wrap}.product-overview h1{margin:0;font-weight:700}.product-id{display:flex;width:100%;flex-grow:1}.product-id va-icon{margin-right:20px}@media screen and (max-width:600px){.product-id va-icon ::ng-deep .va-icon-container{width:40px!important;height:40px!important}}.product-id .product-id-text{display:flex;flex-direction:column;justify-content:center}.product-id span{display:block;overflow:hidden}.product-id .tagline{color:#616161;margin-top:8px;font-size:16px}@media screen and (min-width:600px){.product-id{width:66%;padding-right:16px}}.description{padding-top:16px;width:100%;color:#616161}.print{display:none}@media print{.display{display:none}.print{display:block}}"]
    }),
    __metadata("design:paramtypes", [])
], OrderFormSectionComponent);
export { OrderFormSectionComponent };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JkZXItZm9ybS1zZWN0a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