import { jsx as n } from "../../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useMemo as o, useCallback as m } from "../../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { FormTextInput as p } from "../../../../../../internal/FormWrappers/FormTextInput.js";
import { PAYMENT_LINK_CREATION_FIELD_LENGTHS as d } from "../../../../constants.js";
import u from "../../../../../../../core/Context/preact/useCoreContext.js";
const x = () => {
  const { i18n: i } = u(), e = o(
    () => ({
      valid: !1,
      message: i.get("payByLink.creation.fields.shopperEmail.error.validEmail")
    }),
    [i]
  ), l = m(
    (r) => {
      r = String(r).toLowerCase().trim();
      const s = r.split("@");
      if (s.length !== 2)
        return e;
      const [a, t] = s;
      return !a || !t || a.length === 0 || a.startsWith(".") || a.endsWith(".") || a.includes("..") || t.length === 0 || t.startsWith(".") || t.endsWith(".") || t.includes("..") || !t.includes(".") || !// eslint-disable-next-line max-len
      /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(r) ? e : { valid: !0 };
    },
    [e]
  );
  return /* @__PURE__ */ n(
    p,
    {
      fieldName: "shopperEmail",
      label: i.get("payByLink.creation.fields.shopperEmail.label"),
      validate: l,
      maxLength: d.emailAddress.max
    }
  );
};
export {
  x as ShopperEmailField
};
