/*!
 * KoliBri - The accessible HTML-Standard
 */
import{h as o}from"./index-91489a9f.js";import{i as t}from"./InternalUnderlinedBadgeText-22278de8.js";import{i as n}from"./isObject-ffcbbb76.js";import{_ as e}from"./tslib.es6-1173d062.js";import{a as s}from"./component-names-a18a51c8.js";import{K as i}from"./Icon-936c5cfc.js";import{c}from"./clsx-09a06a12.js";import{c as r,a}from"./FormFieldMsg-1ed3f51d.js";import{I as d}from"./getRenderStates-a7a33541.js";import{i as l}from"./icons-199f1746.js";import{o as m,p as b,w as p}from"./prop.validators-9feb1d92.js";import{i as f}from"./common-54bf85ba.js";const u=(n,t)=>{var{position:s="start",class:i}=n,a=e(n,["position","class"]);const r="kol-input-container__adornment",l=`${r}--${s}`;return o("div",Object.assign({class:c(r,l,i)},a),t)},j=u;function h(o){return!!o&&(Array.isArray(o)?o.length>0:Boolean(o))}const O=(n,t)=>{var{class:s}=n,i=e(n,["class"]);return o("div",Object.assign({class:c("kol-input-container__container",s)},i),t)},v=(n,t)=>{const{class:s,startAdornment:i,endAdornment:a,disabled:l,msg:d,touched:m,containerProps:p,startAdornmentProps:b,endAdornmentProps:u}=n,f=e(n,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]),g=r(d,m),_={"kol-input-container--disabled":l,[`kol-input-container--${(null==d?void 0:d.type)||"error"}`]:g},A=Object.assign({class:c("kol-input-container",_,s)},f);return h(i)||h(a)?o("div",Object.assign({},A),o(j,Object.assign({},b,{position:"start"}),i),o(O,Object.assign({},p),t),o(j,Object.assign({},u,{position:"end"}),a)):o("div",Object.assign({},A),o(O,Object.assign({},p),t))},_=v,A=n=>{const{label:t,icons:i,hideLabel:a,disabled:c,onClick:r}=n,l=e(n,["label","icons","hideLabel","disabled","onClick"]);return o(s,Object.assign({tabindex:0,_label:t,_disabled:c,_icons:i,_hideLabel:a,_on:{onClick:r}},l))},k=A,g=n=>{const{componentName:t="button",label:s,icon:a,onClick:c}=n,r=e(n,["componentName","label","icon","onClick"]);return o("button"===t?k:i,Object.assign({label:s||"",hideLabel:!0,icons:`codicon codicon-${a}`,onClick:c},r))},P=g;function x(o){let n,t;return"_icons"in o&&(n=o._icons),"_smartButton"in o&&(t=o._smartButton),{icons:n,smartButton:t,disabled:o._disabled,msg:a(o._msg),touched:o._touched}}const B=({state:s,endAdornment:e},i)=>{const{icons:a,smartButton:c,disabled:r,msg:l,touched:d}=x(s);let m=null==a?void 0:a.left;t(m)&&(m={icon:m});let p=null==a?void 0:a.right;t(p)&&(p={icon:p});const b=[],u=[];return e&&(Array.isArray(e)?u.push(...e):u.push(e)),m&&b.push(o(P,Object.assign({componentName:"icon"},n(m)?m:{}))),n(c)&&u.push(o(P,Object.assign({componentName:"button"},c,{hideLabel:!0,disabled:r}))),p&&u.push(o(P,Object.assign({componentName:"icon"},n(p)?p:{}))),o(_,{disabled:r,msg:l,touched:d,startAdornment:b,endAdornment:u},i)},C=B,I=(o,n)=>{const t=o;"object"==typeof t&&null!==t&&(f(t.right,1)&&(t.right={icon:t.right}),f(t.left,1)&&(t.left={icon:t.left}),n.set("_icons",t))};class L extends d{constructor(o,n,t){super(o,n,t),this.component=o}validateIcons(o){m(o,(()=>{try{o=b(o)}catch(o){}p(this.component,"_icons",(o=>"object"==typeof o&&null!==o&&(f(o.left,1)||l(o.left)||f(o.right,1)||l(o.right))),new Set(["KoliBriHorizontalIcon"]),o,{hooks:{beforePatch:I},required:!0})}))}componentWillLoad(){super.componentWillLoad(),this.validateIcons(this.component._icons)}}export{L as I,C as K,P as a};