import { $ as E } from "./utils-oAGBWzI5.es.js";
import { $ as I } from "./mergeProps-Dsl8k3Ig.es.js";
import { $ as M } from "./filterDOMProps-BSVCO5jK.es.js";
import { $ as S } from "./useFormReset-BGuIA_u2.es.js";
import { $ as V } from "./useControlledState-u436Wbp1.es.js";
import D, { useState as L, useEffect as O } from "react";
import { $ as R } from "./useField-CHrpmkxe.es.js";
import { $ as q } from "./useFocusable-Cs6i58WP.es.js";
import { $ as B, a as T } from "./useFormValidation-BCVLtR0U.es.js";
function F(e, a) {
  let { inputElementType: c = "input", isDisabled: f = !1, isRequired: r = !1, isReadOnly: m = !1, type: $ = "text", validationBehavior: l = "aria" } = e, [i, d] = V(e.value, e.defaultValue || "", e.onChange), { focusableProps: b } = q(e, a), u = B({
    ...e,
    value: i
  }), { isInvalid: o, validationErrors: s, validationDetails: v } = u.displayValidation, { labelProps: C, fieldProps: P, descriptionProps: p, errorMessageProps: g } = R({
    ...e,
    isInvalid: o,
    errorMessage: e.errorMessage || s
  }), y = M(e, {
    labelable: !0
  });
  const h = {
    type: $,
    pattern: e.pattern
  };
  let [x] = L(i);
  var n;
  return S(a, (n = e.defaultValue) !== null && n !== void 0 ? n : x, d), T(e, u, a), O(() => {
    if (a.current instanceof E(a.current).HTMLTextAreaElement) {
      let t = a.current;
      Object.defineProperty(t, "defaultValue", {
        get: () => t.value,
        set: () => {
        },
        configurable: !0
      });
    }
  }, [
    a
  ]), {
    labelProps: C,
    inputProps: I(y, c === "input" ? h : void 0, {
      disabled: f,
      readOnly: m,
      required: r && l === "native",
      "aria-required": r && l === "aria" || void 0,
      "aria-invalid": o || void 0,
      "aria-errormessage": e["aria-errormessage"],
      "aria-activedescendant": e["aria-activedescendant"],
      "aria-autocomplete": e["aria-autocomplete"],
      "aria-haspopup": e["aria-haspopup"],
      "aria-controls": e["aria-controls"],
      value: i,
      onChange: (t) => d(t.target.value),
      autoComplete: e.autoComplete,
      autoCapitalize: e.autoCapitalize,
      maxLength: e.maxLength,
      minLength: e.minLength,
      name: e.name,
      form: e.form,
      placeholder: e.placeholder,
      inputMode: e.inputMode,
      autoCorrect: e.autoCorrect,
      spellCheck: e.spellCheck,
      [parseInt(D.version, 10) >= 17 ? "enterKeyHint" : "enterkeyhint"]: e.enterKeyHint,
      // Clipboard events
      onCopy: e.onCopy,
      onCut: e.onCut,
      onPaste: e.onPaste,
      // Composition events
      onCompositionEnd: e.onCompositionEnd,
      onCompositionStart: e.onCompositionStart,
      onCompositionUpdate: e.onCompositionUpdate,
      // Selection events
      onSelect: e.onSelect,
      // Input events
      onBeforeInput: e.onBeforeInput,
      onInput: e.onInput,
      ...b,
      ...P
    }),
    descriptionProps: p,
    errorMessageProps: g,
    isInvalid: o,
    validationErrors: s,
    validationDetails: v
  };
}
export {
  F as $
};
//# sourceMappingURL=useTextField-yuaT8-G4.es.js.map
