import{h as e,w as N,e as j}from"./index-B6uGkrgD.js";import{_ as h}from"./tslib.es6-CxX45GIN-BGVaTf34.js";import{I as b}from"./component-N8_W7bhu-Q1tppvIJ.js";import{a as v,i as O,I as P}from"./FormFieldStateWrapper-BZKfIiSI-z8H1tm5r.js";import{c as I}from"./clsx-COFh-Vc8-D7cYsJM5.js";import{i as C}from"./component-CPMwSMOM-C0jaO_VE.js";import{i as _}from"./isObject-BJgq02Md-C3e4t58V.js";import{v as B}from"./icons-CmA8Oww0-B3CW7Bon.js";const L=n=>{const{label:s,icons:i,hideLabel:r,disabled:o,onClick:c}=n,t=h(n,["label","icons","hideLabel","disabled","onClick"]);return e(j,Object.assign({_label:s,_disabled:o,_icons:i,_hideLabel:r,_on:{onClick:c}},t))},F=n=>{const{componentName:s="button",label:i,icon:r,onClick:o}=n,c=h(n,["componentName","label","icon","onClick"]);return e(s==="button"?L:b,Object.assign({label:i||"",hideLabel:!0,icons:`${r}`,onClick:o},c))},k=(n,s)=>{var{position:i="start",class:r}=n,o=h(n,["position","class"]);const c="kol-input-container__adornment",t=`${c}--${i}`;return e("div",Object.assign({class:I(c,t,r)},o),s)};function A(n){return n?Array.isArray(n)?n.length>0:!!n:!1}const y=(n,s)=>{var{class:i}=n,r=h(n,["class"]);return e("div",Object.assign({class:I("kol-input-container__container",i)},r),s)},$=(n,s)=>{const{class:i,startAdornment:r,endAdornment:o,disabled:c,msg:t,touched:a,containerProps:p,startAdornmentProps:g,endAdornmentProps:f}=n,l=h(n,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]),u={"kol-input-container--disabled":c,[`kol-input-container--${v(t)}`]:O(t,a)},d=Object.assign({class:I("kol-input-container",u,i)},l);return!A(r)&&!A(o)?e("div",Object.assign({},d),e(y,Object.assign({},p),s)):e("div",Object.assign({},d),e(k,Object.assign({},g,{position:"start"}),r),e(y,Object.assign({},p),s),e(k,Object.assign({},f,{position:"end"}),o))};function K(n){let s,i;return"_icons"in n&&(s=n._icons),"_smartButton"in n&&(i=n._smartButton),{icons:s,smartButton:i,disabled:n._disabled,msg:n._msg,touched:n._touched}}const V=({state:n,startAdornment:s,endAdornment:i},r)=>{var o,c;const{icons:t,smartButton:a,disabled:p,msg:g,touched:f}=K(n);let l=t?.left;C(l)&&(l={icon:l});let u=t?.right;C(u)&&(u={icon:u});const d=[],m=[];return s&&(Array.isArray(s)?d.push(...s):d.push(s)),l&&(_(l)?d.push(e(b,{class:"kol-input-container__icon",icons:l.icon,label:(o=l.label)!==null&&o!==void 0?o:"",style:l.style})):d.push(e(b,{class:"kol-input-container__icon",icons:l,label:""}))),_(a)&&m.push(e(F,Object.assign({componentName:"button",class:"kol-input-container__smart-button"},a,{hideLabel:!0,disabled:p}))),u&&(_(u)?m.push(e(b,{class:"kol-input-container__icon",icons:u.icon,label:(c=u.label)!==null&&c!==void 0?c:"",style:u.style})):m.push(e(b,{class:"kol-input-container__icon",icons:u,label:""}))),i&&(Array.isArray(i)?m.push(...i):m.push(i)),e($,{disabled:p,msg:g,touched:f,startAdornment:d,endAdornment:m},r)};class q extends P{constructor(s,i,r){super(s,i,r),this.numberStringRegex=/^\d+(\.\d+)?$/,this.parseToNumber=o=>typeof o=="number"?isNaN(o)?null:o:this.isNumberString(o)?parseFloat(o):null,this.validateNumber=(o,c)=>N(this.component,o,t=>t==null||typeof t=="number"||typeof t=="string"&&this.numberStringRegex.test(t),new Set(["number","NumberString"]),c,{hooks:{beforePatch:(t,a)=>{a?.has(o)&&a?.set(o,this.parseToNumber(t))}}}),this.component=s}validateIcons(s){B(this.component,s)}isNumberString(s){return typeof s=="string"&&this.numberStringRegex.test(s)}componentWillLoad(){super.componentWillLoad(),this.validateIcons(this.component._icons)}}export{V as I,F as K,q as a};
//# sourceMappingURL=controller-icon-SbmKNSTK-Bd5Jqbpp.js.map
