import{__awaiter,__generator}from"tslib";import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-4d3658f6.js";var balToastCss=":root{--bal-toast-font-size:var(--bal-size-normal);--bal-toast-font-family:var(--bal-font-family-text);--bal-toast-background:var(--bal-color-white);--bal-toast-background-primary:var(--bal-color-white);--bal-toast-background-info:var(--bal-color-info-2);--bal-toast-background-success:var(--bal-color-success-2);--bal-toast-background-warning:var(--bal-color-warning-2);--bal-toast-background-danger:var(--bal-color-danger-2);--bal-toast-radius:var(--bal-radius-large);--bal-toast-color:var(--bal-color-text-primary);--bal-toast-color-primary:var(--bal-color-text-primary);--bal-toast-color-info:var(--bal-color-text-primary);--bal-toast-color-success:var(--bal-color-text-primary);--bal-toast-color-warning:var(--bal-color-text-primary);--bal-toast-color-danger:var(--bal-color-text-primary)}.bal-toast{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:-ms-inline-flexbox;display:inline-flex;position:relative;-ms-flex-positive:0 !important;flex-grow:0 !important;width:100%}.bal-toast__inner{min-height:3.5rem;border-radius:var(--bal-toast-radius);font-size:var(--bal-toast-font-size);font-family:var(--bal-toast-font-family);background:var(--bal-toast-background);color:var(--bal-toast-color);-webkit-hyphens:auto;-ms-hyphens:auto;hyphens:auto;position:relative;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-positive:1;flex-grow:1;margin:.5rem 0 0 0;-webkit-box-shadow:var(--bal-shadow-normal);box-shadow:var(--bal-shadow-normal);padding:1rem}.bal-toast__inner--is-primary{background:var(--bal-toast-background-primary);color:var(--bal-toast-color-primary)}.bal-toast__inner--is-info{background:var(--bal-toast-background-info);color:var(--bal-toast-color-info)}.bal-toast__inner--is-danger{background:var(--bal-toast-background-danger);color:var(--bal-toast-color-danger)}.bal-toast__inner--is-warning{background:var(--bal-toast-background-warning);color:var(--bal-toast-color-warning)}.bal-toast__inner--is-success{background:var(--bal-toast-background-success);color:var(--bal-toast-color-success)}@media screen and (min-width: 769px),print{.bal-toast__inner{padding:1rem}}@media screen and (min-width: 1024px){.bal-toast__inner{padding:1rem}}@media screen and (min-width: 769px),print{.bal-toast__inner{max-width:28.75rem;width:28.75rem}}@media screen and (min-width: 1024px){.bal-toast__inner{max-width:30rem;width:30rem}}.bal-toast__label{margin-right:3rem;-webkit-hyphens:auto;-ms-hyphens:auto;hyphens:auto}.bal-toast__close.bal-close{position:absolute;top:50%;right:1rem;margin-top:-0.75rem}";var BalToastStyle0=balToastCss;var Toast=function(){function a(a){registerInstance(this,a);this.balClose=createEvent(this,"balClose",7);this.toastId="bal-toast-".concat(toastIds++);this.color="";this.duration=0;this.message="";this.closeHandler=function(){return void 0}}a.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(a){switch(a.label){case 0:if(!(this.duration>0))return[3,2];return[4,this.closeIn(this.duration)];case 1:a.sent();a.label=2;case 2:return[2]}}))}))};a.prototype.closeIn=function(a){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){this.timer=setTimeout((function(){return t.close()}),a);return[2]}))}))};a.prototype.close=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(a){this.element.remove();clearTimeout(this.timer);this.balClose.emit(this.toastId);this.closeHandler();return[2]}))}))};Object.defineProperty(a.prototype,"colorType",{get:function(){if(this.color===""){return""}return"bal-toast__inner--is-".concat(this.color)},enumerable:false,configurable:true});a.prototype.render=function(){var a=this;return h(Host,{id:this.toastId,class:"bal-toast"},h("div",{role:"alert",onClick:function(){return a.close()},class:"bal-toast__inner ".concat(this.colorType)},h("span",{class:"bal-toast__label",innerHTML:this.message,"data-testid":"bal-toast-label"},h("slot",null)),h("bal-close",{class:"bal-toast__close",inverted:false,"data-testid":"bal-toast-close"})))};Object.defineProperty(a.prototype,"element",{get:function(){return getElement(this)},enumerable:false,configurable:true});return a}();var toastIds=0;Toast.style=BalToastStyle0;export{Toast as bal_toast};