"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),I=require("react"),e=require("../../src/components/TextInput/textInput.module.css"),i=require("../../utils/cn/cn.cjs.js"),V=require("../Button/Button.cjs.js"),B=require("../Icon/Icon.cjs.js"),F=require("../Icon/constants.cjs.js"),E=require("../Typography/Typography.cjs.js"),M=({placeholder:_,variant:c="primary",handleChange:r,handleKeyDown:l,disabled:u=!1,buttonText:h="SUBMIT",onButtonClick:t,error:a=!1,errorText:p,active:d=!1,value:m,label:y,type:j="button",showButton:N=!1})=>{const[v,f]=I.useState(!1),[q,T]=I.useState(""),x=typeof m=="string"&&typeof r=="function",o=x?m:q,g=s=>{x?r&&r(s):T(s.target.value)},b=()=>{t&&t(o||"")},S=s=>{s.key==="Enter"&&t&&t(o||""),l&&l(s)};return n.jsxs("div",{className:e.root,children:[y&&n.jsx("div",{className:i.cn(e.label,o&&e.hidden),children:y}),n.jsxs("div",{className:i.cn(e.container,e[c],{[e.focused]:v},{[e.disabled]:u},{[e.error]:a},{[e.active]:d}),children:[n.jsx("div",{className:e.input_container,children:n.jsx("input",{className:i.cn(e.input,e[`input_${c}`],{[e.error]:a},{[e.active]:d}),disabled:u,placeholder:_,onChange:g,onKeyDown:S,onFocus:()=>f(!0),onBlur:()=>f(!1),value:o,style:{outline:"none"}})}),N&&n.jsx("div",{className:e.button_container,children:n.jsx(V.Button,{variant:c==="primary"?"primary":"primary-invert",as:"button",size:"sm",type:j,onClick:b,children:h})})]}),a&&p&&n.jsxs("div",{className:e.errorTextContainer,children:[n.jsx(B.Icon,{name:F.EIconName.INFO,className:e.errorIcon}),n.jsx(E.Typography,{defaultVariant:"labelSm",className:e.errorText,children:p})]})]})};exports.TextInput=M;
