import { h } from '@stencil/core';
import { delay } from '../../shared/utils';
export class BsAlert {
  constructor() {
    this.variant = undefined;
    this.show = true;
    this.transition = 'fade';
    this.dismissible = false;
    this.closeLabel = 'Close alert';
    this.removeOnClose = true;
    this.closing = false;
  }
  async handleCloseAlert() {
    this.closing = true;
    await delay(150); // let CSS animations finish
    this.close.emit();
    if (this.removeOnClose) {
      this.el.parentElement.removeChild(this.el);
    }
  }
  render() {
    return (h("div", { role: "alert", class: `
                    alert 
                    alert-${this.variant} 
                    ${(this.show && !this.closing) ? 'show' : ''}
                    ${this.transition || ''} 
                    ${this.dismissible ? 'alert-dismissible' : ''}
                ` }, h("slot", null), this.dismissible && (h("button", { type: "button", class: "close", "data-dismiss": "alert", "aria-label": this.closeLabel, onClick: this.handleCloseAlert.bind(this) }, h("span", { "aria-hidden": "true" }, "\u00D7"), h("span", { class: "sr-only" }, this.closeLabel)))));
  }
  static get is() { return "bs-alert"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() {
    return {
      "$": ["bs-alert.scss"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["bs-alert.css"]
    };
  }
  static get properties() {
    return {
      "variant": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "Variant",
          "resolved": "string",
          "references": {
            "Variant": {
              "location": "import",
              "path": "../../shared/types"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "variant",
        "reflect": false
      },
      "show": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "show",
        "reflect": false,
        "defaultValue": "true"
      },
      "transition": {
        "type": "any",
        "mutable": false,
        "complexType": {
          "original": "AlertTransition",
          "resolved": "\"fade\" | boolean",
          "references": {
            "AlertTransition": {
              "location": "local",
              "path": "/Users/aadebayo/Repositories/stenciljs-bootstrap/src/components/bs-alert/bs-alert.tsx"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "transition",
        "reflect": false,
        "defaultValue": "'fade'"
      },
      "dismissible": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "dismissible",
        "reflect": false,
        "defaultValue": "false"
      },
      "closeLabel": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "close-label",
        "reflect": false,
        "defaultValue": "'Close alert'"
      },
      "removeOnClose": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "remove-on-close",
        "reflect": false,
        "defaultValue": "true"
      }
    };
  }
  static get states() {
    return {
      "closing": {}
    };
  }
  static get events() {
    return [{
        "method": "close",
        "name": "close",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": ""
        },
        "complexType": {
          "original": "any",
          "resolved": "any",
          "references": {}
        }
      }];
  }
  static get elementRef() { return "el"; }
}
//# sourceMappingURL=bs-alert.js.map
