import { h, Host } from "@stencil/core";
import { BEM } from "../../../utils/bem";
import { inheritAttributes } from "../../../utils/attributes";
import { rOnLoad } from "../../../utils/helpers";
export class StageImage {
    constructor() {
        this.imageInheritAttributes = {};
        this.isOnLoadEventDone = false;
    }
    componentDidLoad() {
        rOnLoad(() => {
            this.isOnLoadEventDone = true;
        });
    }
    componentWillLoad() {
        this.imageInheritAttributes = inheritAttributes(this.el, ['alt']);
    }
    render() {
        const block = BEM.block('stage-image');
        const imageSrc = this.fallback ? this.fallback : this.srcSet.split(',')[0];
        return (h(Host, { key: 'bcc5678390b8facb7daf8720f7b26e7af55944fa', class: Object.assign({}, block.class()) }, this.isOnLoadEventDone ? (h("img", Object.assign({ src: imageSrc, srcset: this.srcSet, sizes: "100vw" }, this.imageInheritAttributes))) : ('')));
    }
    static get is() { return "bal-stage-image"; }
    static get properties() {
        return {
            "srcSet": {
                "type": "string",
                "attribute": "src-set",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "set of images to be used as background image"
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "fallback": {
                "type": "string",
                "attribute": "fallback",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "optional fallback image in case the srcSet fails"
                },
                "getter": false,
                "setter": false,
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "isOnLoadEventDone": {}
        };
    }
    static get elementRef() { return "el"; }
}
