import{q as a,W as f,t as l,C as g,s as p,o as _,p as u,w as v,i as y,D as m}from"./index-DJsSmExJ.js";import{s as r,t as s}from"./events-29e84d75-BhxFwhXP.js";import{A as b}from"./associated.controller-d302adf7-BO9dig2p.js";import{v as C,a as d,b as H,c as L}from"./access-and-short-key-914780a7-DSD1jCrI.js";import{v as A}from"./hide-label-0d754c8e-CmRCdJKE.js";import{a as E}from"./label-7d1ce375-BbZF87oK.js";import{v as I}from"./tooltip-align-6964dd71-BBV8gIPB.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const K=(i,t)=>{a(i,"_adjustHeight",t)},B=(i,t,o)=>{a(i,"_hideError",t,o)},S=(i,t)=>{_(t,()=>{try{t=u(t)}catch{}v(i,"_msg",o=>y(o)&&typeof o?._description=="string",new Set(["MsgPropType"]),t,{defaultValue:{_description:"",_type:"error"}})})},x=(i,t)=>{a(i,"_touched",t)},P=i=>{var t,o;const e=!!(((t=i._msg)===null||t===void 0?void 0:t._type)==="error"&&i._msg._description&&((o=i._msg._description)===null||o===void 0?void 0:o.length)>0)&&i._touched===!0,c=typeof i._hint=="string"&&i._hint.length>0,h=[];return e===!0&&h.push(`${i._id}-error`),c===!0&&h.push(`${i._id}-hint`),{hasError:e,hasHint:c,ariaDescribedBy:h}};class T extends b{constructor(t,o,n){super(t,o,n),this.component=t}validateAlert(t){a(this.component,"_alert",t)}validateTouched(t){x(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateAlert(this.component._alert),this.validateTouched(this.component._touched)}}class V extends T{constructor(t,o,n){super(t,o,n),this.valueChangeListeners=[],this.onFacade={onBlur:this.onBlur.bind(this),onChange:this.onChange.bind(this),onClick:this.onClick.bind(this),onFocus:this.onFocus.bind(this),onInput:this.onInput.bind(this)},this.component=t}validateAccessKey(t){C(this.component,t),d(t,this.component._shortKey)}validateAdjustHeight(t){K(this.component,t)}validateDisabled(t){a(this.component,"_disabled",t),t===!0&&f()}validateTooltipAlign(t){I(this.component,t)}validateError(t){typeof t=="string"&&t.length>0?this.validateMsg({_description:t,_type:"error"}):this.validateMsg(void 0)}validateHideError(t){B(this.component,t,{hooks:{afterPatch:()=>{this.component.state._hideError&&m("Property hide-error for inputs: Only use when the error message is shown outside of the input component.")}}})}validateHideLabel(t){A(this.component,t,{hooks:{afterPatch:()=>{this.component.state._hideLabel&&m("Property hide-label for inputs: Only use for exceptions like search inputs that are clearly identifiable by their context.")}}})}validateHint(t){l(this.component,"_hint",t)}validateId(t){l(this.component,"_id",t,{minLength:1}),(t===""||typeof t>"u")&&g("A unique ID on the input fields is not strictly required, but it might be relevant for E2E tests.")}validateLabel(t){E(this.component,t,{required:!0})}validateMsg(t){S(this.component,t)}validateOn(t){typeof t=="object"&&p(this.component,"_on",t)}validateShortKey(t){H(this.component,t),d(this.component._accessKey,t)}validateSmartButton(t){_(t,()=>{try{t=u(t)}catch{}p(this.component,"_smartButton",t)})}validateTabIndex(t){L(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateAccessKey(this.component._accessKey),this.validateAdjustHeight(this.component._adjustHeight),this.validateError(this.component._error),this.component._msg&&this.validateMsg(this.component._msg),this.validateDisabled(this.component._disabled),this.validateHideError(this.component._hideError),this.validateHideLabel(this.component._hideLabel),this.validateHint(this.component._hint),this.validateId(this.component._id),this.validateLabel(this.component._label),this.validateShortKey(this.component._shortKey),this.validateSmartButton(this.component._smartButton),this.validateOn(this.component._on),this.validateTabIndex(this.component._tabIndex),d(this.component._accessKey,this.component._shortKey)}onBlur(t){var o;this.component._touched=!0,r(t),s("blur",this.host),typeof((o=this.component._on)===null||o===void 0?void 0:o.onBlur)=="function"&&this.component._on.onBlur(t)}onChange(t,o){var n;o=o??t.target.value,s("change",this.host,o),typeof((n=this.component._on)===null||n===void 0?void 0:n.onChange)=="function"&&this.component._on.onChange(t,o),this.valueChangeListeners.forEach(e=>e(o))}onInput(t,o=!0,n){var e;n=n??t.target.value,r(t),s("input",this.host,n),o&&this.setFormAssociatedValue(n),typeof((e=this.component._on)===null||e===void 0?void 0:e.onInput)=="function"&&this.component._on.onInput(t,n)}onClick(t){var o;r(t),s("click",this.host),typeof((o=this.component._on)===null||o===void 0?void 0:o.onClick)=="function"&&this.component._on.onClick(t)}onFocus(t){var o;r(t),s("focus",this.host),typeof((o=this.component._on)===null||o===void 0?void 0:o.onFocus)=="function"&&this.component._on.onFocus(t)}addValueChangeListener(t){this.valueChangeListeners.push(t)}}export{V as I,P as g};
//# sourceMappingURL=controller-c87b8bd9-Bbky9kvs.js.map
