;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "dd4709d6-be02-430b-825b-43ba663a27aa", e._sentryDebugIdIdentifier = "sentry-dbid-dd4709d6-be02-430b-825b-43ba663a27aa");
  } catch (e) {
  }
}
;
import { jsxs, Fragment, jsx } from "preact/jsx-runtime";
import cx from "classnames";
import { useState } from "preact/hooks";
import { a3 as createLogger, u as useTranslation, p as useAnalyticsContext } from "./StoreProvider-CqQrndhS.js";
import { d as debouncedInputEvent } from "./debouncedInputEvent-Cv2S512Y.js";
const convertFullToHalf = (str) => str.replace(/[！-～]/g, (r) => String.fromCharCode(r.charCodeAt(0) - 65248));
const logger = createLogger();
function TextArea(props) {
  const {
    autoCorrect,
    isInvalid,
    isValid,
    readonly = null,
    spellCheck,
    disabled,
    maxLength,
    className,
    trimOnBlur,
    enableTracking = false,
    name,
    "aria-describedby": ariaDescribedBy,
    "aria-invalid": ariaInvalid,
    "aria-labelledby": ariaLabelledBy
  } = props;
  const { t } = useTranslation("ui");
  const userEvents = useAnalyticsContext();
  const [value, setValue] = useState("");
  if (Object.prototype.hasOwnProperty.call(props, "onChange")) {
    logger.error("Error: Form fields that rely on InputBase may not have an onChange property");
  }
  const handleInput = (e) => {
    if (enableTracking) {
      debouncedInputEvent(userEvents, {
        actionType: "input",
        field: name
      });
    }
    e.currentTarget.value = convertFullToHalf(e.currentTarget.value);
    setValue(e.currentTarget.value);
    props?.onInput?.(e);
  };
  const handleBlur = (e) => {
    if (enableTracking) {
      userEvents.addFieldEvent("Interacted with form field", {
        actionType: "blur",
        field: name
      });
    }
    props?.onBlurHandler?.(e);
    if (trimOnBlur) {
      e.currentTarget.value = e.currentTarget.value.trim();
    }
    props?.onBlur?.(e);
  };
  const handleFocus = (e) => {
    if (enableTracking) {
      userEvents.addFieldEvent("Interacted with form field", {
        actionType: "focus",
        field: name
      });
    }
    props?.onFocusHandler?.(e);
  };
  const inputClassNames = cx("adyen-kyc-input", "adyen-kyc-input--textarea", className, {
    "adyen-kyc-input--invalid": isInvalid,
    "adyen-kyc-field--valid": isValid,
    "adyen-kyc-input--disabled": disabled
  });
  const charactersLeft = maxLength - value.length;
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(
      "textarea",
      {
        ...props,
        className: inputClassNames,
        readOnly: readonly,
        spellCheck,
        autoCorrect,
        "aria-describedby": ariaDescribedBy,
        "aria-invalid": ariaInvalid,
        "aria-labelledby": ariaLabelledBy,
        ...disabled && { "aria-disabled": true },
        onInput: handleInput,
        onBlur: handleBlur,
        onFocus: handleFocus
      }
    ),
    !isInvalid && maxLength && charactersLeft >= 0 ? /* @__PURE__ */ jsx("span", { className: "adyen-kyc-input__counter", children: t(($) => $["xCharactersLeft"], { charactersLeft }) }) : null
  ] });
}
export {
  TextArea as T,
  convertFullToHalf as c
};
