/*!
 * KoliBri - The accessible HTML-Standard
 */
import{r as registerInstance,h,H as Host}from"./index-9ca46203.js";import{L as Log,z as watchBoolean,y as validateHasCloser,v as validateLabel,k as setState,w as watchValidator,au as alertTypeOptions,av as alertVariantOptions}from"./index-0489af72.js";import{t as translate}from"./i18n-3bac791b.js";import{w as watchHeadingLevel}from"./validation-7e615a5b.js";import{b as KolHeadingWcTag,c as KolButtonWcTag,g as KolIconTag}from"./component-names-61247f2f.js";import"./i18n-fddf0324.js";const Icon=a=>h(KolIconTag,{class:"heading-icon",_label:"string"==typeof a.label&&a.label.length>0?"":a.ariaLabel,_icons:a.icon}),AlertIcon=a=>{switch(a.type){case"error":return h(Icon,{ariaLabel:translate("kol-error"),icon:"codicon codicon-error",label:a.label});case"info":return h(Icon,{ariaLabel:translate("kol-info"),icon:"codicon codicon-info",label:a.label});case"warning":return h(Icon,{ariaLabel:translate("kol-warning"),icon:"codicon codicon-warning",label:a.label});case"success":return h(Icon,{ariaLabel:translate("kol-success"),icon:"codicon codicon-pass",label:a.label});default:return h(Icon,{ariaLabel:translate("kol-message"),icon:"codicon codicon-comment",label:a.label})}},KolAlertWc=class{constructor(a){registerInstance(this,a),this.close=()=>{var a;void 0!==(null===(a=this._on)||void 0===a?void 0:a.onClose)&&this._on.onClose(new Event("Close"))},this.on={onClick:this.close},this.validateOnValue=a=>"object"==typeof a&&null!==a&&"function"==typeof a.onClose,this._alert=!1,this._hasCloser=!1,this._label=void 0,this._level=1,this._on=void 0,this._type="default",this._variant="msg",this.state={_level:1}}render(){var a;if(this.state._alert){try{Log.debug(["Navigator should vibrate ...",navigator.vibrate([100,75,100,75,100])])}catch(a){Log.debug("Navigator does not support vibration.")}setTimeout((()=>{this.validateAlert(!1)}),1e4)}return h(Host,{key:"056ebeba8b0ebc0d76a98e3855a0022e1c689e09",class:{"kol-alert-wc":!0,alert:!0,[this.state._type]:!0,[this.state._variant]:!0,hasCloser:!!this.state._hasCloser},role:this.state._alert?"alert":void 0},h("div",{key:"e2807b51c729dc7814aa46bc40f371d9b785b590",class:"heading"},h(AlertIcon,{key:"207367acb5c59e0977feb68adefb0a7cdb0f4668",label:this.state._label,type:this.state._type}),h("div",{key:"1d9b3c352e84393eb31fbd056a6aa9ec639d13cd",class:"heading-content"},"string"==typeof this.state._label&&(null===(a=this.state._label)||void 0===a?void 0:a.length)>0&&h(KolHeadingWcTag,{_label:this.state._label,_level:this.state._level}),"msg"===this.state._variant&&h("div",{class:"content"},h("slot",null))),this.state._hasCloser&&h(KolButtonWcTag,{class:"close",_hideLabel:!0,_icons:{left:{icon:"codicon codicon-close"}},_label:translate("kol-close"),_on:this.on,_tooltipAlign:"left"})),"card"===this.state._variant&&h("div",{class:"content"},h("slot",null)))}validateAlert(a){watchBoolean(this,"_alert",a)}validateHasCloser(a){validateHasCloser(this,a)}validateLabel(a){validateLabel(this,a)}validateLevel(a){watchHeadingLevel(this,a)}validateOn(a){this.validateOnValue(a)&&setState(this,"_on",{onClose:a.onClose})}validateType(a){watchValidator(this,"_type",(a=>"string"==typeof a&&alertTypeOptions.includes(a)),new Set(`String {${alertTypeOptions.join(", ")}`),a)}validateVariant(a){watchValidator(this,"_variant",(a=>"string"==typeof a&&alertVariantOptions.includes(a)),new Set(`AlertVariant {${alertVariantOptions.join(", ")}`),a)}componentWillLoad(){this.validateAlert(this._alert),this.validateHasCloser(this._hasCloser),this.validateLabel(this._label),this.validateLevel(this._level),this.validateOn(this._on),this.validateType(this._type),this.validateVariant(this._variant)}static get watchers(){return{_alert:["validateAlert"],_hasCloser:["validateHasCloser"],_label:["validateLabel"],_level:["validateLevel"],_on:["validateOn"],_type:["validateType"],_variant:["validateVariant"]}}};export{KolAlertWc as kol_alert_wc};