import { Host, h } from "@stencil/core";
import { IcInformationStatus, } from "../../utils/types";
import errorIcon from "../../assets/error-icon.svg";
import successIcon from "../../assets/success-icon.svg";
import warningIcon from "../../assets/warning-icon.svg";
import { getInputValidationTextID, onComponentRequiredPropUndefined, } from "../../utils/helpers";
const icon = {
    [IcInformationStatus.Warning]: warningIcon,
    [IcInformationStatus.Error]: errorIcon,
    [IcInformationStatus.Success]: successIcon,
};
/**
 * @slot validation-message-adornment - Content will be placed to the right of the validation message.
 */
export class InputValidation {
    constructor() {
        /**
         *  The ARIA live mode to apply to the message.
         */
        this.ariaLiveMode = "polite";
        /**
         *  If `true`, the input validation will fill the width of the container.
         */
        this.fullWidth = false;
        /**
         * The status of the validation - e.g. 'error' | 'warning' | 'success'.
         */
        this.status = "";
    }
    componentDidLoad() {
        onComponentRequiredPropUndefined([{ prop: this.message, propName: "message" }], "Input Validation");
    }
    render() {
        const { ariaLiveMode, fullWidth, status, message } = this;
        const displayIcon = status !== "" ? icon[status] : "";
        return (h(Host, { key: 'f61832a182b954a8b114547acd18ce38576daf06', class: {
                [`ic-input-validation-${status}`]: status !== "",
                "ic-input-validation-full-width": !!fullWidth,
            } }, displayIcon !== "" && (h("span", { key: '2d0766ad790827b8757354c2dc3d29e3aa9a5f71', class: {
                "status-icon": true,
                [`icon-${status}`]: true,
            }, innerHTML: displayIcon })), h("ic-typography", { key: 'b1a98a5b7fd18ab96cde1ff555410f35f76a66e2', variant: "caption", class: "statustext" }, h("span", { key: '5306d723ea7527eb997d778e82fbe10e00af7852', "aria-live": ariaLiveMode, id: this.for && getInputValidationTextID(this.for) }, message)), h("slot", { key: 'a7e3c126ac89a1c616a327da99b8324df7c4464e', name: "validation-message-adornment" })));
    }
    static get is() { return "ic-input-validation"; }
    static get originalStyleUrls() {
        return {
            "$": ["ic-input-validation.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["ic-input-validation.css"]
        };
    }
    static get properties() {
        return {
            "ariaLiveMode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "IcAriaLiveModeVariants",
                    "resolved": "\"assertive\" | \"polite\" | undefined",
                    "references": {
                        "IcAriaLiveModeVariants": {
                            "location": "import",
                            "path": "./ic-input-validation.types",
                            "id": "src/components/ic-input-validation/ic-input-validation.types.tsx::IcAriaLiveModeVariants"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The ARIA live mode to apply to the message."
                },
                "getter": false,
                "setter": false,
                "attribute": "aria-live-mode",
                "reflect": false,
                "defaultValue": "\"polite\""
            },
            "for": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The ID of the form element the validation is bound to."
                },
                "getter": false,
                "setter": false,
                "attribute": "for",
                "reflect": false
            },
            "fullWidth": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "If `true`, the input validation will fill the width of the container."
                },
                "getter": false,
                "setter": false,
                "attribute": "full-width",
                "reflect": false,
                "defaultValue": "false"
            },
            "message": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The validation message to display."
                },
                "getter": false,
                "setter": false,
                "attribute": "message",
                "reflect": false
            },
            "status": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "IcInformationStatusOrEmpty",
                    "resolved": "\"\" | \"error\" | \"success\" | \"warning\" | undefined",
                    "references": {
                        "IcInformationStatusOrEmpty": {
                            "location": "import",
                            "path": "../../utils/types",
                            "id": "src/utils/types.ts::IcInformationStatusOrEmpty"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The status of the validation - e.g. 'error' | 'warning' | 'success'."
                },
                "getter": false,
                "setter": false,
                "attribute": "status",
                "reflect": false,
                "defaultValue": "\"\""
            }
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=ic-input-validation.js.map
