/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";var index=require("./index-D0FxsaCe.js"),tslib_es6=require("./tslib.es6-7DbU_BSw.js"),componentNames=require("./component-names-CuI-0Pbo.js"),Icon=require("./Icon-CqQh6zkI.js"),clsx=require("./clsx-CkZlkaek.js"),common=require("./common-Cd2qH809.js"),FormFieldStateWrapper=require("./FormFieldStateWrapper-BeAW0hiT.js"),InternalUnderlinedBadgeText=require("./InternalUnderlinedBadgeText-Bv5-Alwn.js"),isObject=require("./isObject-DMA85Fq4.js"),icons=require("./icons-D_PtPRwb.js");const InputAdornment=(n,e)=>{var{position:t="start",class:o}=n,s=tslib_es6.__rest(n,["position","class"]);const i="kol-input-container__adornment",r=`${i}--${t}`;return index.h("div",Object.assign({class:clsx.clsx(i,r,o)},s),e)};function hasItems(n){return!!n&&(Array.isArray(n)?n.length>0:Boolean(n))}const Container=(n,e)=>{var{class:t}=n,o=tslib_es6.__rest(n,["class"]);return index.h("div",Object.assign({class:clsx.clsx("kol-input-container__container",t)},o),e)},KolInputContainerFc=(n,e)=>{const{class:t,startAdornment:o,endAdornment:s,disabled:i,msg:r,touched:c,containerProps:a,startAdornmentProps:l,endAdornmentProps:d}=n,u=tslib_es6.__rest(n,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]),p=FormFieldStateWrapper.checkHasMsg(r,c),m="string"==typeof r?"error":null==r?void 0:r._type,b={"kol-input-container--disabled":i,[`kol-input-container--${m||"error"}`]:p},h=Object.assign({class:clsx.clsx("kol-input-container",b,t)},u);return hasItems(o)||hasItems(s)?index.h("div",Object.assign({},h),index.h(InputAdornment,Object.assign({},l,{position:"start"}),o),index.h(Container,Object.assign({},a),e),index.h(InputAdornment,Object.assign({},d,{position:"end"}),s)):index.h("div",Object.assign({},h),index.h(Container,Object.assign({},a),e))},KolButtonFc=n=>{const{label:e,icons:t,hideLabel:o,disabled:s,onClick:i}=n,r=tslib_es6.__rest(n,["label","icons","hideLabel","disabled","onClick"]);return index.h(componentNames.KolButtonWcTag,Object.assign({_label:e,_disabled:s,_icons:t,_hideLabel:o,_on:{onClick:i}},r))},KolIconButtonFc=n=>{const{componentName:e="button",label:t,icon:o,onClick:s}=n,i=tslib_es6.__rest(n,["componentName","label","icon","onClick"]),r="button"===e?KolButtonFc:Icon.KolIconFc;return index.h(r,Object.assign({label:t||"",hideLabel:!0,icons:`${o}`,onClick:s},i))};function getInputContainerProps(n){let e,t;return"_icons"in n&&(e=n._icons),"_smartButton"in n&&(t=n._smartButton),{icons:e,smartButton:t,disabled:n._disabled,msg:n._msg,touched:n._touched}}const InputContainerStateWrapperFc=({state:n,endAdornment:e},t)=>{const{icons:o,smartButton:s,disabled:i,msg:r,touched:c}=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 e&&(Array.isArray(e)?u.push(...e):u.push(e)),a&&d.push(index.h(KolIconButtonFc,Object.assign({componentName:"icon",class:"kol-input-container__icon"},isObject.isObject(a)?a:{}))),isObject.isObject(s)&&u.push(index.h(KolIconButtonFc,Object.assign({componentName:"button",class:"kol-input-container__smart-button"},s,{hideLabel:!0,disabled:i}))),l&&u.push(index.h(KolIconButtonFc,Object.assign({componentName:"icon",class:"kol-input-container__icon"},isObject.isObject(l)?l:{}))),index.h(KolInputContainerFc,{disabled:i,msg:r,touched:c,startAdornment:d,endAdornment:u},t)};class InputIconController extends FormFieldStateWrapper.InputController{constructor(n,e,t){super(n,e,t),this.numberStringRegex=/^\d+(\.\d+)?$/,this.parseToNumber=n=>"number"==typeof n?isNaN(n)?null:n:this.isNumberString(n)?parseFloat(n):null,this.validateNumber=(n,e)=>common.watchValidator(this.component,n,n=>null==n||"number"==typeof n||"string"==typeof n&&this.numberStringRegex.test(n),new Set(["number","NumberString"]),e,{hooks:{beforePatch:(e,t)=>{(null==t?void 0:t.has(n))&&(null==t||t.set(n,this.parseToNumber(e)))}}}),this.component=n}validateIcons(n){icons.validateIcons(this.component,n)}isNumberString(n){return"string"==typeof n&&this.numberStringRegex.test(n)}componentWillLoad(){super.componentWillLoad(),this.validateIcons(this.component._icons)}}exports.InputContainerStateWrapperFc=InputContainerStateWrapperFc,exports.InputIconController=InputIconController,exports.KolIconButtonFc=KolIconButtonFc;