/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";const index=require("./index-07fcbac9.js"),InternalUnderlinedBadgeText=require("./InternalUnderlinedBadgeText-58120685.js"),isObject=require("./isObject-6090b636.js"),tslib_es6=require("./tslib.es6-5e301284.js"),componentNames=require("./component-names-cf0c0d8a.js"),Icon=require("./Icon-0eed071b.js"),clsx=require("./clsx-dd4d6dd1.js"),FormFieldMsg=require("./FormFieldMsg-370f014e.js"),getRenderStates=require("./getRenderStates-3c874ec5.js"),icons=require("./icons-310a07cc.js"),prop_validators=require("./prop.validators-96dfedce.js"),common=require("./common-1ab929ac.js"),InputAdornment=(n,t)=>{var{position:e="start",class:o}=n,s=tslib_es6.__rest(n,["position","class"]);const i="kol-input-container__adornment",c=`${i}--${e}`;return index.h("div",Object.assign({class:clsx.clsx(i,c,o)},s),t)},InputAdornment$1=InputAdornment;function hasItems(n){return!!n&&(Array.isArray(n)?n.length>0:Boolean(n))}const Container=(n,t)=>{var{class:e}=n,o=tslib_es6.__rest(n,["class"]);return index.h("div",Object.assign({class:clsx.clsx("kol-input-container__container",e)},o),t)},KolInputContainerFc$1=(n,t)=>{const{class:e,startAdornment:o,endAdornment:s,disabled:i,msg:c,touched:r,containerProps:a,startAdornmentProps:l,endAdornmentProps:d}=n,u=tslib_es6.__rest(n,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]),p=FormFieldMsg.checkHasError(c,r),m={"kol-input-container--disabled":i,[`kol-input-container--${(null==c?void 0:c.type)||"error"}`]:p},b=Object.assign({class:clsx.clsx("kol-input-container",m,e)},u);return hasItems(o)||hasItems(s)?index.h("div",Object.assign({},b),index.h(InputAdornment$1,Object.assign({},l,{position:"start"}),o),index.h(Container,Object.assign({},a),t),index.h(InputAdornment$1,Object.assign({},d,{position:"end"}),s)):index.h("div",Object.assign({},b),index.h(Container,Object.assign({},a),t))},KolInputContainerFc$2=KolInputContainerFc$1,KolButtonFc=n=>{const{label:t,icons:e,hideLabel:o,disabled:s,onClick:i}=n,c=tslib_es6.__rest(n,["label","icons","hideLabel","disabled","onClick"]);return index.h(componentNames.KolButtonWcTag,Object.assign({tabindex:0,_label:t,_disabled:s,_icons:e,_hideLabel:o,_on:{onClick:i}},c))},KolButtonFc$1=KolButtonFc,KolIconButtonFc=n=>{const{componentName:t="button",label:e,icon:o,onClick:s}=n,i=tslib_es6.__rest(n,["componentName","label","icon","onClick"]),c="button"===t?KolButtonFc$1:Icon.KolIconFc;return index.h(c,Object.assign({label:e||"",hideLabel:!0,icons:`codicon codicon-${o}`,onClick:s},i))},KolIconButtonFc$1=KolIconButtonFc;function getInputContainerProps(n){let t,e;return"_icons"in n&&(t=n._icons),"_smartButton"in n&&(e=n._smartButton),{icons:t,smartButton:e,disabled:n._disabled,msg:FormFieldMsg.convertMsgToInternMsg(n._msg),touched:n._touched}}const InputContainerStateWrapperFc=({state:n,endAdornment:t},e)=>{const{icons:o,smartButton:s,disabled:i,msg:c,touched:r}=getInputContainerProps(n);let a=null==o?void 0:o.left;InternalUnderlinedBadgeText.isString(a)&&(a={icon:a});let l=null==o?void 0:o.right;InternalUnderlinedBadgeText.isString(l)&&(l={icon:l});const d=[],u=[];return t&&(Array.isArray(t)?u.push(...t):u.push(t)),a&&d.push(index.h(KolIconButtonFc$1,Object.assign({componentName:"icon"},isObject.isObject(a)?a:{}))),isObject.isObject(s)&&u.push(index.h(KolIconButtonFc$1,Object.assign({componentName:"button"},s,{hideLabel:!0,disabled:i}))),l&&u.push(index.h(KolIconButtonFc$1,Object.assign({componentName:"icon"},isObject.isObject(l)?l:{}))),index.h(KolInputContainerFc$2,{disabled:i,msg:c,touched:r,startAdornment:d,endAdornment:u},e)},KolInputContainerFc=InputContainerStateWrapperFc,beforePatchIcons=(n,t)=>{const e=n;"object"==typeof e&&null!==e&&(common.isString(e.right,1)&&(e.right={icon:e.right}),common.isString(e.left,1)&&(e.left={icon:e.left}),t.set("_icons",e))};class InputIconController extends getRenderStates.InputController{constructor(n,t,e){super(n,t,e),this.component=n}validateIcons(n){prop_validators.objectObjectHandler(n,(()=>{try{n=prop_validators.parseJson(n)}catch(n){}prop_validators.watchValidator(this.component,"_icons",(n=>"object"==typeof n&&null!==n&&(common.isString(n.left,1)||icons.isIcon(n.left)||common.isString(n.right,1)||icons.isIcon(n.right))),new Set(["KoliBriHorizontalIcon"]),n,{hooks:{beforePatch:beforePatchIcons},required:!0})}))}componentWillLoad(){super.componentWillLoad(),this.validateIcons(this.component._icons)}}exports.InputIconController=InputIconController,exports.KolIconButtonFc=KolIconButtonFc$1,exports.KolInputContainerFc=KolInputContainerFc;