const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_locales = require("../../../utils/locales.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
require("./LegalTerms.less");
//#region src/pro/Login2.0/components/LegalTerms.tsx
const LegalTerms = ({ config }) => {
	var _config$terms;
	if (!(config === null || config === void 0 ? void 0 : config.enabled) || !(config === null || config === void 0 || (_config$terms = config.terms) === null || _config$terms === void 0 ? void 0 : _config$terms.length)) return null;
	const getTextByMode = () => {
		if ((config.mode || "register") === "login") return _pisell_utils.locales.getText("pisell-legal-terms-login-text");
		else return _pisell_utils.locales.getText("pisell-legal-terms-register-text");
	};
	const renderTerms = () => {
		var _config$terms2;
		return (_config$terms2 = config.terms) === null || _config$terms2 === void 0 ? void 0 : _config$terms2.map((term, index) => {
			let termName = "";
			if (typeof term.name === "string") termName = term.name;
			else if (typeof term.name === "object") {
				const locale = require_locales.getLocale() || "zh-CN";
				termName = term.name[locale] || term.name.original || "";
			}
			return /* @__PURE__ */ react.default.createElement(react.default.Fragment, { key: index }, index > 0 && /* @__PURE__ */ react.default.createElement("span", { className: "legal-terms-separator" }, _pisell_utils.locales.getText("pisell-legal-terms-and")), /* @__PURE__ */ react.default.createElement("a", {
				href: term.url,
				target: "_blank",
				rel: "noopener noreferrer",
				className: "legal-terms-link"
			}, termName));
		});
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: "legal-terms" }, /* @__PURE__ */ react.default.createElement("span", { className: "legal-terms-text" }, getTextByMode()), renderTerms());
};
//#endregion
exports.default = LegalTerms;
