/*!
 * Built by ShiftSoftware
 * Copyright (c)
 */
import { h } from "@stencil/core";
const formStepperId = 'form-input-preview';
export class FormStepper {
    constructor() {
        this.props = {};
        this.localization = {};
    }
    componentDidLoad() {
        this.form.subscribe(formStepperId, this);
    }
    async disconnectedCallback() {
        this.form.unsubscribe(formStepperId);
    }
    parseTemplate(template) {
        if (!template)
            return '';
        return template.replace(/\$\{(.*?)\}/g, (_, fieldName) => {
            var _a;
            const value = (_a = this.form) === null || _a === void 0 ? void 0 : _a.getValue(fieldName === null || fieldName === void 0 ? void 0 : fieldName.trim());
            return value != null ? String(value) : '';
        });
    }
    render() {
        var _a, _b;
        const [_, language] = this.form.getFormLocale();
        const rawValue = (_b = (_a = this === null || this === void 0 ? void 0 : this.localization) === null || _a === void 0 ? void 0 : _a[language]) === null || _b === void 0 ? void 0 : _b.value;
        const parsedValue = this.parseTemplate(rawValue);
        // @ts-ignore
        window === null || window === void 0 ? void 0 : window.ss = this.form;
        return h("form-input", Object.assign({ key: this === null || this === void 0 ? void 0 : this.name, form: this.form }, this === null || this === void 0 ? void 0 : this.props, { localization: this === null || this === void 0 ? void 0 : this.localization, inputProps: { readOnly: true, value: parsedValue } }));
    }
    static get is() { return "form-input-preview"; }
    static get originalStyleUrls() {
        return {
            "$": ["form-inputs.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["form-inputs.css"]
        };
    }
    static get properties() {
        return {
            "name": {
                "type": "string",
                "attribute": "name",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "props": {
                "type": "any",
                "attribute": "props",
                "mutable": false,
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "{}"
            },
            "form": {
                "type": "unknown",
                "attribute": "form",
                "mutable": false,
                "complexType": {
                    "original": "FormHook<any>",
                    "resolved": "FormHook<any>",
                    "references": {
                        "FormHook": {
                            "location": "import",
                            "path": "~features/form-hook",
                            "id": "src/features/form-hook/index.ts::FormHook"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "localization": {
                "type": "unknown",
                "attribute": "localization",
                "mutable": false,
                "complexType": {
                    "original": "FormInputLocalization<{ value?: string }>",
                    "resolved": "{ [lang: string]: { label?: string; placeholder?: string; require?: string; format?: string; minMessage: string; maxMessage: string; betweenMessage: string; } & { value?: string; }; }",
                    "references": {
                        "FormInputLocalization": {
                            "location": "import",
                            "path": "~features/form-hook",
                            "id": "src/features/form-hook/index.ts::FormInputLocalization"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "defaultValue": "{}"
            }
        };
    }
}
