import { Field } from "../Field.mjs";
import { Typography } from "../../../UI/dataDisplay/typography/Typography.mjs";
import { FluentTextField } from "../../../UI/inputs/textField/FluentTextField.mjs";
import { FormControlLabel } from "../../../UI/utilityDisplay/FormControlLabel.mjs";
import { FormControl } from "../../../UI/utilityDisplay/FormControl.mjs";
import { Box } from "../../../UI/Box.mjs";
import { FluentCheckbox } from "../../../UI/inputs/checkbox/FluentCheckbox.mjs";
import { PaymentCard } from "./PaymentCard.mjs";
import { formatCVC, formatCreditCardNumber, formatExpirationDate } from "./CreditCardUtils.mjs";
import { CreditCardAdornment } from "./CreditCardAdornment.mjs";
import { c } from "react-compiler-runtime";
import React from "react";
import { useTranslation } from "react-i18next";
//#region src/utilities/form/paymentForm/NewCreditCardForm.tsx
/**
* NewCardForm component renders a form for entering new credit card details.
*
* @param {Object} props - The properties object.
* @param {boolean} props.isFormDisabled - Flag to disable the form fields.
* @param {Record<string, string>} props.classes - CSS classes for styling the form controls.
* @param {React.Dispatch<React.SetStateAction<string>>} props.setCreditCardNumberInput - Function to set the credit card number input value.
*
* @returns {JSX.Element} The rendered NewCardForm component.
*/
const NewCreditCardForm = (t0) => {
	const $ = c(74);
	const { isFormDisabled, classes, creditCardNumberInput, paymentDetails, setCreditCardNumberInput } = t0;
	let t1;
	if ($[0] !== paymentDetails) {
		t1 = paymentDetails || {};
		$[0] = paymentDetails;
		$[1] = t1;
	} else t1 = $[1];
	const { accountNumber } = t1;
	const { t } = useTranslation();
	const t2 = classes.formControl;
	let t3;
	if ($[2] !== t) {
		t3 = t("Cardholder");
		$[2] = t;
		$[3] = t3;
	} else t3 = $[3];
	let t4;
	if ($[4] !== isFormDisabled || $[5] !== t3) {
		t4 = {
			label: t3,
			variant: "outlined",
			size: "small",
			disabled: isFormDisabled,
			fullWidth: true
		};
		$[4] = isFormDisabled;
		$[5] = t3;
		$[6] = t4;
	} else t4 = $[6];
	const t5 = !isFormDisabled;
	let t6;
	if ($[7] !== t4 || $[8] !== t5) {
		t6 = /* @__PURE__ */ React.createElement(Field, {
			component: FluentTextField,
			ComponentProps: t4,
			name: "nameOnCard",
			initialValue: "",
			required: t5,
			onChange: _temp
		});
		$[7] = t4;
		$[8] = t5;
		$[9] = t6;
	} else t6 = $[9];
	let t7;
	if ($[10] !== classes.formControl || $[11] !== t6) {
		t7 = /* @__PURE__ */ React.createElement(FormControl, { className: t2 }, t6);
		$[10] = classes.formControl;
		$[11] = t6;
		$[12] = t7;
	} else t7 = $[12];
	const t8 = classes.cardNumber;
	let t9;
	if ($[13] !== t) {
		t9 = t("Card Number");
		$[13] = t;
		$[14] = t9;
	} else t9 = $[14];
	let t10;
	if ($[15] !== creditCardNumberInput) {
		t10 = { startAdornment: /* @__PURE__ */ React.createElement(CreditCardAdornment, { creditCardNumberInput }) };
		$[15] = creditCardNumberInput;
		$[16] = t10;
	} else t10 = $[16];
	let t11;
	if ($[17] !== isFormDisabled || $[18] !== t10 || $[19] !== t9) {
		t11 = {
			label: t9,
			variant: "outlined",
			size: "small",
			disabled: isFormDisabled,
			fullWidth: true,
			InputProps: t10
		};
		$[17] = isFormDisabled;
		$[18] = t10;
		$[19] = t9;
		$[20] = t11;
	} else t11 = $[20];
	const t12 = !isFormDisabled;
	let t13;
	if ($[21] !== setCreditCardNumberInput) {
		t13 = (e) => setCreditCardNumberInput(e.target.value);
		$[21] = setCreditCardNumberInput;
		$[22] = t13;
	} else t13 = $[22];
	let t14;
	if ($[23] !== t11 || $[24] !== t12 || $[25] !== t13) {
		t14 = /* @__PURE__ */ React.createElement(Field, {
			component: FluentTextField,
			ComponentProps: t11,
			name: "cardNumber",
			initialValue: "",
			required: t12,
			pattern: "\\d{16,22}",
			format: formatCreditCardNumber,
			onChange: t13
		});
		$[23] = t11;
		$[24] = t12;
		$[25] = t13;
		$[26] = t14;
	} else t14 = $[26];
	let t15;
	if ($[27] !== classes.cardNumber || $[28] !== t14) {
		t15 = /* @__PURE__ */ React.createElement(FormControl, { className: t8 }, t14);
		$[27] = classes.cardNumber;
		$[28] = t14;
		$[29] = t15;
	} else t15 = $[29];
	let t16;
	if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
		t16 = { gap: "10px" };
		$[30] = t16;
	} else t16 = $[30];
	const t17 = classes.formControl;
	let t18;
	if ($[31] !== t) {
		t18 = t("Expiry Date");
		$[31] = t;
		$[32] = t18;
	} else t18 = $[32];
	let t19;
	if ($[33] !== isFormDisabled || $[34] !== t18) {
		t19 = {
			label: t18,
			variant: "outlined",
			margin: "normal",
			size: "small",
			width: "100%",
			disabled: isFormDisabled,
			fullWidth: true
		};
		$[33] = isFormDisabled;
		$[34] = t18;
		$[35] = t19;
	} else t19 = $[35];
	const t20 = t19;
	const t21 = !isFormDisabled;
	let t22;
	if ($[36] !== t20 || $[37] !== t21) {
		t22 = /* @__PURE__ */ React.createElement(Field, {
			component: FluentTextField,
			ComponentProps: t20,
			name: "expiryDate",
			helperText: "MM/YY",
			initialValue: "",
			required: t21,
			pattern: "\\d\\d/\\d\\d",
			format: formatExpirationDate,
			onChange: _temp2
		});
		$[36] = t20;
		$[37] = t21;
		$[38] = t22;
	} else t22 = $[38];
	let t23;
	if ($[39] !== classes.formControl || $[40] !== t22) {
		t23 = /* @__PURE__ */ React.createElement(FormControl, { className: t17 }, t22);
		$[39] = classes.formControl;
		$[40] = t22;
		$[41] = t23;
	} else t23 = $[41];
	const t24 = classes.formControl;
	let t25;
	if ($[42] !== isFormDisabled) {
		t25 = {
			label: "CVV",
			variant: "outlined",
			margin: "normal",
			size: "small",
			width: "100%",
			disabled: isFormDisabled,
			fullWidth: true
		};
		$[42] = isFormDisabled;
		$[43] = t25;
	} else t25 = $[43];
	const t26 = t25;
	let t27;
	if ($[44] !== t) {
		t27 = t("3-digit code on back");
		$[44] = t;
		$[45] = t27;
	} else t27 = $[45];
	const t28 = !isFormDisabled;
	let t29;
	if ($[46] !== t26 || $[47] !== t27 || $[48] !== t28) {
		t29 = /* @__PURE__ */ React.createElement(Field, {
			component: FluentTextField,
			ComponentProps: t26,
			name: "cvv",
			helperText: t27,
			initialValue: "",
			required: t28,
			pattern: "\\d{3,4}",
			format: formatCVC,
			onChange: _temp3
		});
		$[46] = t26;
		$[47] = t27;
		$[48] = t28;
		$[49] = t29;
	} else t29 = $[49];
	let t30;
	if ($[50] !== classes.formControl || $[51] !== t29) {
		t30 = /* @__PURE__ */ React.createElement(FormControl, { className: t24 }, t29);
		$[50] = classes.formControl;
		$[51] = t29;
		$[52] = t30;
	} else t30 = $[52];
	let t31;
	if ($[53] !== t23 || $[54] !== t30) {
		t31 = /* @__PURE__ */ React.createElement(Box, {
			display: "flex",
			flexDirection: "row",
			alignItems: "flex-start",
			padding: "0px",
			width: "100%",
			style: t16
		}, t23, t30);
		$[53] = t23;
		$[54] = t30;
		$[55] = t31;
	} else t31 = $[55];
	let t32;
	if ($[56] !== isFormDisabled) {
		t32 = /* @__PURE__ */ React.createElement(Field, {
			component: FluentCheckbox,
			name: "isSaveAsNewMethod",
			type: "checkbox",
			defaultValue: false,
			disabled: isFormDisabled,
			required: false,
			onChange: _temp4
		});
		$[56] = isFormDisabled;
		$[57] = t32;
	} else t32 = $[57];
	let t33;
	if ($[58] !== accountNumber || $[59] !== t) {
		t33 = accountNumber ? /* @__PURE__ */ React.createElement("span", null, t("Save this card to"), " ", /* @__PURE__ */ React.createElement("strong", null, " ", t("Account"), " ", accountNumber), " ", t("file")) : t("Save");
		$[58] = accountNumber;
		$[59] = t;
		$[60] = t33;
	} else t33 = $[60];
	let t34;
	if ($[61] !== t33) {
		t34 = /* @__PURE__ */ React.createElement(Typography, null, t33);
		$[61] = t33;
		$[62] = t34;
	} else t34 = $[62];
	let t35;
	if ($[63] !== t32 || $[64] !== t34) {
		t35 = /* @__PURE__ */ React.createElement(FormControlLabel, {
			control: t32,
			label: t34
		});
		$[63] = t32;
		$[64] = t34;
		$[65] = t35;
	} else t35 = $[65];
	let t36;
	if ($[66] !== classes.formControlCheck || $[67] !== t35) {
		t36 = /* @__PURE__ */ React.createElement(FormControl, { className: classes.formControlCheck }, t35);
		$[66] = classes.formControlCheck;
		$[67] = t35;
		$[68] = t36;
	} else t36 = $[68];
	let t37;
	if ($[69] !== t15 || $[70] !== t31 || $[71] !== t36 || $[72] !== t7) {
		t37 = /* @__PURE__ */ React.createElement(PaymentCard, null, t7, t15, t31, t36);
		$[69] = t15;
		$[70] = t31;
		$[71] = t36;
		$[72] = t7;
		$[73] = t37;
	} else t37 = $[73];
	return t37;
};
function _temp() {}
function _temp2() {}
function _temp3() {}
function _temp4() {}
//#endregion
export { NewCreditCardForm };

//# sourceMappingURL=NewCreditCardForm.mjs.map