/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";const index=require("./index-7215e5f8.js"),events=require("./events-221fcb43.js"),associated_controller=require("./associated.controller-9ab5fcdd.js"),getRenderStates=t=>{const e="string"==typeof t._error&&t._error.length>0&&!0===t._touched,n="string"==typeof t._hint&&t._hint.length>0,o=[];return!0===e&&o.push(`${t._id}-error`),!0===n&&o.push(`${t._id}-hint`),{hasError:e,hasHint:n,ariaDescribedBy:o}};class ControlledInputController extends associated_controller.AssociatedInputController{constructor(t,e,n){super(t,e,n),this.component=t}validateAlert(t){index.watchBoolean(this.component,"_alert",t)}validateTouched(t){index.validateTouched(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateAlert(this.component._alert),this.validateTouched(this.component._touched)}}class InputController extends ControlledInputController{constructor(t,e,n){super(t,e,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)},this.component=t}validateAccessKey(t){index.watchString(this.component,"_accessKey",t)}validateAdjustHeight(t){index.validateAdjustHeight(this.component,t)}validateDisabled(t){index.watchBoolean(this.component,"_disabled",t),!0===t&&index.a11yHintDisabled()}validateError(t){index.watchString(this.component,"_error",t)}validateHideError(t){index.validateHideError(this.component,t,{hooks:{afterPatch:()=>{this.component.state._hideError&&index.a11yHint("Property hide-error for inputs: Only use when the error message is shown outside of the input component.")}}})}validateHideLabel(t){index.validateHideLabel(this.component,t,{hooks:{afterPatch:()=>{this.component.state._hideLabel&&index.a11yHint("Property hide-label for inputs: Only use for exceptions like search inputs that are clearly identifiable by their context.")}}})}validateHint(t){index.watchString(this.component,"_hint",t)}validateId(t){index.watchString(this.component,"_id",t,{hooks:{afterPatch:()=>{this.setAttribute("id",this.formAssociated,this.component.state._id)}},minLength:1}),""!==t&&void 0!==t||index.devHint("Eine eindeutige ID an den Eingabefeldern ist nicht zwingend erforderlich, könnte aber für die E2E-Tests relevant sein.")}validateLabel(t){index.validateLabelWithExpertSlot(this.component,t,{required:!0})}validateOn(t){"object"==typeof t&&index.setState(this.component,"_on",t)}validateSmartButton(t){index.objectObjectHandler(t,(()=>{try{t=index.parseJson(t)}catch(t){}index.setState(this.component,"_smartButton",t)}))}validateTabIndex(t){index.validateTabIndex(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateAccessKey(this.component._accessKey),this.validateAdjustHeight(this.component._adjustHeight),this.validateError(this.component._error),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.validateSmartButton(this.component._smartButton),this.validateOn(this.component._on),this.validateTabIndex(this.component._tabIndex)}onBlur(t){var e;this.component._alert=!0,this.component._touched=!0,events.stopPropagation(t),events.tryToDispatchKoliBriEvent("blur",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onBlur)&&this.component._on.onBlur(t)}onChange(t){var e;const n=t.target.value;events.tryToDispatchKoliBriEvent("change",this.host,n),this.setFormAssociatedValue(n),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onChange)&&this.component._on.onChange(t,n),this.valueChangeListeners.forEach((t=>t(n)))}onClick(t){var e;events.stopPropagation(t),events.tryToDispatchKoliBriEvent("click",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onClick)&&this.component._on.onClick(t)}onFocus(t){var e;this.component._alert=!0,events.stopPropagation(t),events.tryToDispatchKoliBriEvent("focus",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onFocus)&&this.component._on.onFocus(t)}addValueChangeListener(t){this.valueChangeListeners.push(t)}}exports.InputController=InputController,exports.getRenderStates=getRenderStates;