import { Component, ChangeDetectorRef, Input, NgModule } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { SdUtilityService, SdUtilityModule } from '@sd-angular/core/utility';
import { v4 } from 'uuid';

class SdDynamicReportComponent {
    constructor(ref, sanitizer, utilityService) {
        this.ref = ref;
        this.sanitizer = sanitizer;
        this.utilityService = utilityService;
        this.printId = 'sd' + v4();
        this.print = () => {
            //  this.utilityService.printHtml(this.printId);
        };
    }
    set html(value) {
        // tslint:disable-next-line: max-line-length
        const regex = /\{[a-zA-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠàáâãèéêìíòóôõùúăđĩũơƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂẾưăạảấầẩẫậắằẳẵặẹẻẽềềểếỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪễệỉịọỏốồổỗộớờởỡợụủứừỬỮỰỲỴÝỶỸửữựỳỵỷỹ0-9 ]*\}/g;
        // tslint:disable-next-line: max-line-length
        const style = 'border-top: none !important; border-left: none !important;  border-right: none !important;border-bottom: dotted 1px black !important;background-color: lightgray !important;outline: none !important;';
        let result = value;
        if (typeof (value) === 'string') {
            while (1) {
                const strs = regex.exec(value);
                if (!strs) {
                    break;
                }
                const placeholder = strs[0].substr(1, strs[0].length - 2);
                result = result.replace(strs[0], `<input id="sd${v4()}" placeholder="${placeholder}" style="${style}">`);
            }
        }
        this.cHtml = this.sanitizer.bypassSecurityTrustHtml(result);
    }
    ngOnInit() {
    }
    ngAfterViewInit() {
        this.ref.detectChanges();
    }
}
SdDynamicReportComponent.decorators = [
    { type: Component, args: [{
                selector: 'sd-dynamic-report',
                template: "<div [id]=\"printId\" [innerHtml]=\"cHtml\">\r\n  <div [innerHtml]=\"cHtml\"></div>\r\n</div>"
            },] }
];
SdDynamicReportComponent.ctorParameters = () => [
    { type: ChangeDetectorRef },
    { type: DomSanitizer },
    { type: SdUtilityService }
];
SdDynamicReportComponent.propDecorators = {
    title: [{ type: Input }],
    html: [{ type: Input }]
};

class SdDynamicReportModule {
}
SdDynamicReportModule.decorators = [
    { type: NgModule, args: [{
                imports: [
                    SdUtilityModule
                ],
                declarations: [
                    SdDynamicReportComponent
                ],
                exports: [
                    SdDynamicReportComponent
                ],
                providers: []
            },] }
];

/*
 * Public API Surface of superdev-angular-core
 */

/**
 * Generated bundle index. Do not edit.
 */

export { SdDynamicReportComponent, SdDynamicReportModule };
//# sourceMappingURL=sd-angular-core-dynamic-report.js.map
