/*!
 * KoliBri - The accessible HTML-Standard
 */
import{h}from"./index-2ae1c631.js";import{i as isString}from"./InternalUnderlinedBadgeText-8da6608d.js";import{i as isObject}from"./isObject-ffcbbb76.js";import{_ as __rest}from"./tslib.es6-1173d062.js";import{a as KolButtonWcTag}from"./component-names-a18a51c8.js";import{K as KolIconFc}from"./Icon-fa673049.js";import{c as clsx}from"./clsx-09a06a12.js";import{c as checkHasError,a as convertMsgToInternMsg}from"./FormFieldMsg-e6f521f5.js";import{I as InputController}from"./getRenderStates-d2dc42b2.js";import{i as isIcon}from"./icons-199f1746.js";import{o as objectObjectHandler,p as parseJson,w as watchValidator}from"./prop.validators-9feb1d92.js";import{i as isString$1}from"./common-54bf85ba.js";const InputAdornment=(n,t)=>{var{position:o="start",class:s}=n,e=__rest(n,["position","class"]);const r="kol-input-container__adornment",c=`${r}--${o}`;return h("div",Object.assign({class:clsx(r,c,s)},e),t)},InputAdornment$1=InputAdornment;function hasItems(n){return!!n&&(Array.isArray(n)?n.length>0:Boolean(n))}const Container=(n,t)=>{var{class:o}=n,s=__rest(n,["class"]);return h("div",Object.assign({class:clsx("kol-input-container__container",o)},s),t)},KolInputContainerFc$1=(n,t)=>{const{class:o,startAdornment:s,endAdornment:e,disabled:r,msg:c,touched:i,containerProps:a,startAdornmentProps:l,endAdornmentProps:d}=n,p=__rest(n,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]),m=checkHasError(c,i),u={"kol-input-container--disabled":r,[`kol-input-container--${(null==c?void 0:c.type)||"error"}`]:m},b=Object.assign({class:clsx("kol-input-container",u,o)},p);return hasItems(s)||hasItems(e)?h("div",Object.assign({},b),h(InputAdornment$1,Object.assign({},l,{position:"start"}),s),h(Container,Object.assign({},a),t),h(InputAdornment$1,Object.assign({},d,{position:"end"}),e)):h("div",Object.assign({},b),h(Container,Object.assign({},a),t))},KolInputContainerFc$2=KolInputContainerFc$1,KolButtonFc=n=>{const{label:t,icons:o,hideLabel:s,disabled:e,onClick:r}=n,c=__rest(n,["label","icons","hideLabel","disabled","onClick"]);return h(KolButtonWcTag,Object.assign({tabindex:0,_label:t,_disabled:e,_icons:o,_hideLabel:s,_on:{onClick:r}},c))},KolButtonFc$1=KolButtonFc,KolIconButtonFc=n=>{const{componentName:t="button",label:o,icon:s,onClick:e}=n,r=__rest(n,["componentName","label","icon","onClick"]);return h("button"===t?KolButtonFc$1:KolIconFc,Object.assign({label:o||"",hideLabel:!0,icons:`codicon codicon-${s}`,onClick:e},r))},KolIconButtonFc$1=KolIconButtonFc;function getInputContainerProps(n){let t,o;return"_icons"in n&&(t=n._icons),"_smartButton"in n&&(o=n._smartButton),{icons:t,smartButton:o,disabled:n._disabled,msg:convertMsgToInternMsg(n._msg),touched:n._touched}}const InputContainerStateWrapperFc=({state:n,endAdornment:t},o)=>{const{icons:s,smartButton:e,disabled:r,msg:c,touched:i}=getInputContainerProps(n);let a=null==s?void 0:s.left;isString(a)&&(a={icon:a});let l=null==s?void 0:s.right;isString(l)&&(l={icon:l});const d=[],p=[];return t&&(Array.isArray(t)?p.push(...t):p.push(t)),a&&d.push(h(KolIconButtonFc$1,Object.assign({componentName:"icon"},isObject(a)?a:{}))),isObject(e)&&p.push(h(KolIconButtonFc$1,Object.assign({componentName:"button"},e,{hideLabel:!0,disabled:r}))),l&&p.push(h(KolIconButtonFc$1,Object.assign({componentName:"icon"},isObject(l)?l:{}))),h(KolInputContainerFc$2,{disabled:r,msg:c,touched:i,startAdornment:d,endAdornment:p},o)},KolInputContainerFc=InputContainerStateWrapperFc,beforePatchIcons=(n,t)=>{const o=n;"object"==typeof o&&null!==o&&(isString$1(o.right,1)&&(o.right={icon:o.right}),isString$1(o.left,1)&&(o.left={icon:o.left}),t.set("_icons",o))};class InputIconController extends InputController{constructor(n,t,o){super(n,t,o),this.component=n}validateIcons(n){objectObjectHandler(n,(()=>{try{n=parseJson(n)}catch(n){}watchValidator(this.component,"_icons",(n=>"object"==typeof n&&null!==n&&(isString$1(n.left,1)||isIcon(n.left)||isString$1(n.right,1)||isIcon(n.right))),new Set(["KoliBriHorizontalIcon"]),n,{hooks:{beforePatch:beforePatchIcons},required:!0})}))}componentWillLoad(){super.componentWillLoad(),this.validateIcons(this.component._icons)}}export{InputIconController as I,KolInputContainerFc as K,KolIconButtonFc$1 as a};