//#region src/pro/Login2.0/shared/registerFlow.ts
/** 注册步骤类型 */
let RegisterStep = /* @__PURE__ */ function(RegisterStep) {
	/** 初始表单 - 输入账号密码 */
	RegisterStep["INITIAL_FORM"] = "INITIAL_FORM";
	/** 等待邮件链接验证 */
	RegisterStep["WAIT_EMAIL_LINK"] = "WAIT_EMAIL_LINK";
	/** 输入验证码 */
	RegisterStep["INPUT_VERIFICATION_CODE"] = "INPUT_VERIFICATION_CODE";
	/** 验证成功提示 */
	RegisterStep["VERIFICATION_SUCCESS"] = "VERIFICATION_SUCCESS";
	/** 设置密码 */
	RegisterStep["SET_PASSWORD"] = "SET_PASSWORD";
	/** 邮箱已注册错误 */
	RegisterStep["EMAIL_ALREADY_REGISTERED"] = "EMAIL_ALREADY_REGISTERED";
	/** 注册完成 */
	RegisterStep["COMPLETE"] = "COMPLETE";
	return RegisterStep;
}({});
/** 验证方式类型 */
let VerificationMethod = /* @__PURE__ */ function(VerificationMethod) {
	/** 邮件链接验证 */
	VerificationMethod["EMAIL_LINK"] = "EMAIL_LINK";
	/** 邮箱验证码验证 */
	VerificationMethod["EMAIL_CODE"] = "EMAIL_CODE";
	/** 手机验证码验证 */
	VerificationMethod["PHONE_CODE"] = "PHONE_CODE";
	/** 密码验证（无需验证码） */
	VerificationMethod["PASSWORD_ONLY"] = "PASSWORD_ONLY";
	return VerificationMethod;
}({});
/** 预定义流程配置 */
const REGISTER_FLOW_CONFIGS = {
	[VerificationMethod.EMAIL_LINK]: {
		verificationMethod: VerificationMethod.EMAIL_LINK,
		requirePasswordAtStart: true
	},
	[VerificationMethod.EMAIL_CODE]: {
		verificationMethod: VerificationMethod.EMAIL_CODE,
		requirePasswordAtStart: false,
		autoTransition: { [RegisterStep.VERIFICATION_SUCCESS]: {
			delay: 1500,
			nextStep: RegisterStep.SET_PASSWORD
		} }
	},
	[VerificationMethod.PHONE_CODE]: {
		verificationMethod: VerificationMethod.PHONE_CODE,
		requirePasswordAtStart: false,
		autoTransition: { [RegisterStep.VERIFICATION_SUCCESS]: {
			delay: 1500,
			nextStep: RegisterStep.SET_PASSWORD
		} }
	},
	[VerificationMethod.PASSWORD_ONLY]: {
		verificationMethod: VerificationMethod.PASSWORD_ONLY,
		requirePasswordAtStart: true
	}
};
/** 步骤流转映射 */
const STEP_TRANSITIONS = {
	[VerificationMethod.EMAIL_LINK]: {
		[RegisterStep.INITIAL_FORM]: [RegisterStep.WAIT_EMAIL_LINK, RegisterStep.EMAIL_ALREADY_REGISTERED],
		[RegisterStep.WAIT_EMAIL_LINK]: [RegisterStep.COMPLETE, RegisterStep.INITIAL_FORM],
		[RegisterStep.EMAIL_ALREADY_REGISTERED]: [RegisterStep.INITIAL_FORM],
		[RegisterStep.INPUT_VERIFICATION_CODE]: [],
		[RegisterStep.VERIFICATION_SUCCESS]: [],
		[RegisterStep.SET_PASSWORD]: [],
		[RegisterStep.COMPLETE]: []
	},
	[VerificationMethod.EMAIL_CODE]: {
		[RegisterStep.INITIAL_FORM]: [RegisterStep.INPUT_VERIFICATION_CODE, RegisterStep.EMAIL_ALREADY_REGISTERED],
		[RegisterStep.INPUT_VERIFICATION_CODE]: [RegisterStep.VERIFICATION_SUCCESS, RegisterStep.INITIAL_FORM],
		[RegisterStep.VERIFICATION_SUCCESS]: [RegisterStep.SET_PASSWORD],
		[RegisterStep.SET_PASSWORD]: [RegisterStep.COMPLETE],
		[RegisterStep.EMAIL_ALREADY_REGISTERED]: [RegisterStep.INITIAL_FORM],
		[RegisterStep.WAIT_EMAIL_LINK]: [],
		[RegisterStep.COMPLETE]: []
	},
	[VerificationMethod.PHONE_CODE]: {
		[RegisterStep.INITIAL_FORM]: [RegisterStep.INPUT_VERIFICATION_CODE, RegisterStep.EMAIL_ALREADY_REGISTERED],
		[RegisterStep.INPUT_VERIFICATION_CODE]: [RegisterStep.VERIFICATION_SUCCESS, RegisterStep.INITIAL_FORM],
		[RegisterStep.VERIFICATION_SUCCESS]: [RegisterStep.SET_PASSWORD],
		[RegisterStep.SET_PASSWORD]: [RegisterStep.COMPLETE],
		[RegisterStep.EMAIL_ALREADY_REGISTERED]: [RegisterStep.INITIAL_FORM],
		[RegisterStep.WAIT_EMAIL_LINK]: [],
		[RegisterStep.COMPLETE]: []
	},
	[VerificationMethod.PASSWORD_ONLY]: {
		[RegisterStep.INITIAL_FORM]: [RegisterStep.COMPLETE, RegisterStep.EMAIL_ALREADY_REGISTERED],
		[RegisterStep.EMAIL_ALREADY_REGISTERED]: [RegisterStep.INITIAL_FORM],
		[RegisterStep.INPUT_VERIFICATION_CODE]: [],
		[RegisterStep.VERIFICATION_SUCCESS]: [],
		[RegisterStep.SET_PASSWORD]: [],
		[RegisterStep.WAIT_EMAIL_LINK]: [],
		[RegisterStep.COMPLETE]: []
	}
};
/** 步骤定义映射 */
const STEP_DEFINITIONS = {
	[RegisterStep.INITIAL_FORM]: {
		step: RegisterStep.INITIAL_FORM,
		component: "form",
		config: {
			showBack: true,
			showClose: true,
			canEditAccount: true,
			showResend: false
		}
	},
	[RegisterStep.WAIT_EMAIL_LINK]: {
		step: RegisterStep.WAIT_EMAIL_LINK,
		component: "waiting",
		config: {
			showBack: true,
			showClose: true,
			canEditAccount: true,
			showResend: true
		}
	},
	[RegisterStep.INPUT_VERIFICATION_CODE]: {
		step: RegisterStep.INPUT_VERIFICATION_CODE,
		component: "code-input",
		config: {
			showBack: true,
			showClose: true,
			canEditAccount: false,
			showResend: true
		}
	},
	[RegisterStep.VERIFICATION_SUCCESS]: {
		step: RegisterStep.VERIFICATION_SUCCESS,
		component: "success",
		config: {
			showBack: false,
			showClose: false,
			canEditAccount: false,
			showResend: false
		}
	},
	[RegisterStep.SET_PASSWORD]: {
		step: RegisterStep.SET_PASSWORD,
		component: "password-set",
		config: {
			showBack: true,
			showClose: true,
			canEditAccount: false,
			showResend: false
		}
	},
	[RegisterStep.EMAIL_ALREADY_REGISTERED]: {
		step: RegisterStep.EMAIL_ALREADY_REGISTERED,
		component: "error",
		config: {
			showBack: true,
			showClose: true,
			canEditAccount: true,
			showResend: false
		}
	},
	[RegisterStep.COMPLETE]: {
		step: RegisterStep.COMPLETE,
		component: "success",
		config: {
			showBack: false,
			showClose: false,
			canEditAccount: false,
			showResend: false
		}
	}
};
/**
* 验证步骤流转是否合法
*/
function isValidTransition(verificationMethod, fromStep, toStep) {
	var _STEP_TRANSITIONS$ver;
	return (((_STEP_TRANSITIONS$ver = STEP_TRANSITIONS[verificationMethod]) === null || _STEP_TRANSITIONS$ver === void 0 ? void 0 : _STEP_TRANSITIONS$ver[fromStep]) || []).includes(toStep);
}
/**
* 获取步骤配置
*/
function getStepDefinition(step) {
	return STEP_DEFINITIONS[step];
}
/**
* 获取流程配置
*/
function getFlowConfig(verificationMethod) {
	return REGISTER_FLOW_CONFIGS[verificationMethod];
}
/**
* 根据认证配置决定使用哪种验证方式
*/
function determineVerificationMethod(accountType, emailConfig, phoneConfig) {
	if (accountType === "email") {
		if ((emailConfig === null || emailConfig === void 0 ? void 0 : emailConfig.require_email_verification) !== false) return VerificationMethod.EMAIL_CODE;
		return VerificationMethod.PASSWORD_ONLY;
	} else {
		if ((phoneConfig === null || phoneConfig === void 0 ? void 0 : phoneConfig.require_phone_verification) !== false) return VerificationMethod.PHONE_CODE;
		return VerificationMethod.PASSWORD_ONLY;
	}
}
//#endregion
exports.RegisterStep = RegisterStep;
exports.VerificationMethod = VerificationMethod;
exports.determineVerificationMethod = determineVerificationMethod;
exports.getFlowConfig = getFlowConfig;
exports.getStepDefinition = getStepDefinition;
exports.isValidTransition = isValidTransition;
