/*!
 * KoliBri - The accessible HTML-Standard
 */
import{r as i,h as t,F as s,H as e,g as n}from"./index-9ca46203.js";import{aI as o,I as l}from"./index-0489af72.js";import{t as a}from"./i18n-3bac791b.js";import{F as h}from"./form-field-msg-4b406780.js";import{a as d,g as r,c as u}from"./component-names-61247f2f.js";import"./i18n-fddf0324.js";function f(t){var i,s,e="";if("string"==typeof t||"number"==typeof t)e+=t;else if("object"==typeof t)if(Array.isArray(t)){var o=t.length;for(i=0;i<o;i++)t[i]&&(s=f(t[i]))&&(e&&(e+=" "),e+=s)}else for(s in t)t[s]&&(e&&(e+=" "),e+=s);return e}function c(){for(var t,i,s=0,e="",o=arguments.length;s<o;s++)(t=arguments[s])&&(i=f(t))&&(e&&(e+=" "),e+=i);return e}const b=class{constructor(t){i(this,t),this.slotName="input",this.catchInputSlot=t=>{o(this.host,t,this.slotName)},this._accessKey=void 0,this._alert=!0,this._currentLength=void 0,this._disabled=!1,this._hasCounter=!1,this._hideError=!1,this._hideLabel=!1,this._hint="",this._icons=void 0,this._id=void 0,this._label=void 0,this._maxLength=void 0,this._msg=void 0,this._readOnly=!1,this._renderNoLabel=!1,this._required=!1,this._slotName=void 0,this._suggestions=void 0,this._smartButton=void 0,this._tooltipAlign="top",this._touched=!1}componentWillRender(){this.slotName=this._slotName?this._slotName:"input"}getIconStyles(t){return t&&"object"==typeof t&&t.style?t.style:{}}render(){var i,o,n,_,m,g,b,p,f,v,y,B;const j=Boolean("error"===(null===(i=this._msg)||void 0===i?void 0:i._type)&&this._msg._description&&(null===(o=this._msg._description)||void 0===o?void 0:o.length)>0),k=!this._readOnly&&j&&!0===this._touched,L=Boolean(k||"error"!==(null===(n=this._msg)||void 0===n?void 0:n._type)&&(null===(_=this._msg)||void 0===_?void 0:_._description)),N=l(this._label),A="string"==typeof this._hint&&this._hint.length>0,I=!N&&this._hideLabel;return t(e,{key:"acb6294dbb3bb30298be633a4728d890d24c6dc7",class:c("kol-input",this.getModifierClassNameByMsgType(),{disabled:!0===this._disabled,error:!0===k,"read-only":!0===this._readOnly,required:!0===this._required,touched:!0===this._touched,"hidden-error":!0===this._hideError})},t("label",{key:"356dbae7d6b7b02202e1020131dc7e8bb70a69c2",class:"input-label",id:I?void 0:`${this._id}-label`,hidden:I,htmlFor:this._id},t("span",{key:"c5ee06729ca4bb5c1458085068ac6a64fcfeae1a",class:"input-label-span"},t("slot",{key:"146aeb9bef32ebc54b1fcbf282841d7d44fd5730",name:"label"}))),A&&t("span",{class:"hint",id:`${this._id}-hint`},this._hint),t("div",{key:"755e40c1da91b382387ddea16935235e793fff1b",class:{input:!0,"icon-left":"object"==typeof(null===(m=this._icons)||void 0===m?void 0:m.left),"icon-right":"object"==typeof(null===(g=this._icons)||void 0===g?void 0:g.right)}},(null===(b=this._icons)||void 0===b?void 0:b.left)&&t(r,{_label:"",_icons:(null===(p=this._icons)||void 0===p?void 0:p.left).icon,style:this.getIconStyles(null===(f=this._icons)||void 0===f?void 0:f.left)}),t("div",{key:"49c2557719125b83a696987ee88ec72a254b5077",ref:this.catchInputSlot,id:this.slotName,class:"input-slot"}),"object"==typeof this._smartButton&&null!==this._smartButton&&t(u,{_customClass:this._smartButton._customClass,_disabled:this._smartButton._disabled,_icons:this._smartButton._icons,_hideLabel:!0,_id:this._smartButton._id,_label:this._smartButton._label,_on:this._smartButton._on,_tooltipAlign:this._smartButton._tooltipAlign,_variant:this._smartButton._variant}),(null===(v=this._icons)||void 0===v?void 0:v.right)&&t(r,{_label:"",_icons:(null===(y=this._icons)||void 0===y?void 0:y.right).icon,style:this.getIconStyles(null===(B=this._icons)||void 0===B?void 0:B.right)})),I&&t(d,{"aria-hidden":"true",class:"input-tooltip",_accessKey:this._accessKey,_align:this._tooltipAlign,_id:this._hideLabel?`${this._id}-label`:void 0,_label:this._label}),L&&t(h,{_alert:this._alert,_hideError:this._hideError,_msg:this._msg,_id:this._id}),Array.isArray(this._suggestions)&&this._suggestions.length>0&&t("datalist",{id:`${this._id}-list`},this._suggestions.map((i=>t("option",{value:i})))),this._hasCounter&&t("span",{class:"counter","aria-atomic":"true","aria-live":"polite"},this._currentLength,this._maxLength&&t(s,null,t("span",{"aria-label":a("kol-of"),role:"img"},"/"),this._maxLength)," ",t("span",null,a("kol-characters"))))}getModifierClassNameByMsgType(){var t,i;if(null===(t=this._msg)||void 0===t?void 0:t._type)return{default:"msg-type-default",info:"msg-type-info",success:"msg-type-success",warning:"msg-type-warning",error:"msg-type-error"}[null===(i=this._msg)||void 0===i?void 0:i._type]}get host(){return n(this)}};export{b as kol_input};