import { E as compilerRuntimeExports, j as jsxRuntimeExports } from "./vendor-react-DYNCg6N5.js";
import { u as useStyles } from "./styles-C9HVNQJ0.js";
import { w as qXe } from "./vendor-icons-xWhXK_Ui.js";
import { E as TextInput, h as ActionIcon } from "./vendor-mantine-h0WlM2Mj.js";
const TextFieldInput = (t0) => {
  const $ = compilerRuntimeExports.c(42);
  const {
    form,
    fieldName,
    className,
    disabled,
    label,
    clearable,
    rightSection,
    isRequired,
    withAsterisk,
    dataAttribute,
    placeholder,
    description
  } = t0;
  const {
    classes,
    cx
  } = useStyles();
  let t1;
  if ($[0] !== fieldName || $[1] !== form) {
    t1 = () => {
      form.setFieldValue(fieldName, "");
    };
    $[0] = fieldName;
    $[1] = form;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const clearValue = t1;
  let t2;
  if ($[3] !== fieldName || $[4] !== form) {
    t2 = (event) => {
      const newValue = event.target.value;
      if (!newValue.startsWith(" ")) {
        form.setFieldValue(fieldName, newValue);
      }
    };
    $[3] = fieldName;
    $[4] = form;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  const handleInputChange = t2;
  let t3;
  if ($[6] !== clearValue || $[7] !== clearable || $[8] !== fieldName || $[9] !== form || $[10] !== rightSection) {
    t3 = () => {
      if (rightSection) {
        return rightSection;
      } else {
        if (form.getInputProps(fieldName).value && clearable) {
          return /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { variant: "transparent", onClick: clearValue, children: /* @__PURE__ */ jsxRuntimeExports.jsx(qXe, { color: "#667085" }) });
        }
      }
    };
    $[6] = clearValue;
    $[7] = clearable;
    $[8] = fieldName;
    $[9] = form;
    $[10] = rightSection;
    $[11] = t3;
  } else {
    t3 = $[11];
  }
  const rightSectionRender = t3;
  let t4;
  if ($[12] !== fieldName || $[13] !== form) {
    t4 = form.getInputProps(fieldName);
    $[12] = fieldName;
    $[13] = form;
    $[14] = t4;
  } else {
    t4 = $[14];
  }
  let t5;
  if ($[15] !== className || $[16] !== classes.textFieldInput || $[17] !== cx) {
    t5 = cx(classes.textFieldInput, className);
    $[15] = className;
    $[16] = classes.textFieldInput;
    $[17] = cx;
    $[18] = t5;
  } else {
    t5 = $[18];
  }
  let t6;
  if ($[19] !== rightSectionRender) {
    t6 = rightSectionRender();
    $[19] = rightSectionRender;
    $[20] = t6;
  } else {
    t6 = $[20];
  }
  let t7;
  if ($[21] !== fieldName || $[22] !== form) {
    t7 = form.getInputProps(fieldName);
    $[21] = fieldName;
    $[22] = form;
    $[23] = t7;
  } else {
    t7 = $[23];
  }
  let t8;
  if ($[24] !== fieldName || $[25] !== form) {
    t8 = form.getInputProps(fieldName).value || "";
    $[24] = fieldName;
    $[25] = form;
    $[26] = t8;
  } else {
    t8 = $[26];
  }
  let t9;
  if ($[27] !== dataAttribute || $[28] !== description || $[29] !== disabled || $[30] !== fieldName || $[31] !== handleInputChange || $[32] !== isRequired || $[33] !== label || $[34] !== placeholder || $[35] !== t4 || $[36] !== t5 || $[37] !== t6 || $[38] !== t7.error || $[39] !== t8 || $[40] !== withAsterisk) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextInput, { ...t4, className: t5, label, withAsterisk, required: isRequired, disabled, rightSection: t6, error: t7.error, value: t8, onChange: handleInputChange, "data-name": fieldName, "data-cy": dataAttribute, placeholder, description });
    $[27] = dataAttribute;
    $[28] = description;
    $[29] = disabled;
    $[30] = fieldName;
    $[31] = handleInputChange;
    $[32] = isRequired;
    $[33] = label;
    $[34] = placeholder;
    $[35] = t4;
    $[36] = t5;
    $[37] = t6;
    $[38] = t7.error;
    $[39] = t8;
    $[40] = withAsterisk;
    $[41] = t9;
  } else {
    t9 = $[41];
  }
  return t9;
};
export {
  TextFieldInput as T
};
//# sourceMappingURL=index-BvQfhnV_.js.map
