import { n as useTranslation } from "./i18n-DoP1NB7u.js";
import { _ as y, v as u } from "./vendor-preact-DThS2ZQ_.js";
import { c as useManager, o as useModuleTerminalCallbacks } from "./hooks-Da_yP_Dr.js";
import { t as IncodeComponent } from "./incodeComponent-CCP7GTMj.js";
import { t as LoadingIcon } from "./loadingIcon-B0ysgiNq.js";
import { t as Page } from "./page-DidH_RkX.js";
import { t as Button } from "./button-BMYTQ8fc.js";
import { t as SuccessIcon } from "./successIcon-B5mGvdx1.js";
import { t as InputComposed } from "./inputComposed-C1R2LAa3.js";
import { t as registerIncodeModuleElement } from "./incodeModule-M8DszCee.js";
import { t as CountrySelector } from "./countrySelector-HaBPZOXx.js";
import { t as StatusPage } from "./statusPage-BUm5gtQY.js";
import { createWatchlistForBusinessManager } from "@incodetech/core/watchlist-for-business";
//#region src/modules/watchlist-for-business/watchlistForBusiness.tsx
var WatchlistForBusinessContent = ({ onFinish }) => {
	const { t } = useTranslation();
	const [state, manager] = useManager(() => createWatchlistForBusinessManager());
	y(() => {
		manager.load();
	}, [manager]);
	useModuleTerminalCallbacks({
		status: state.status === "finished" ? "finished" : "loading",
		onFinish
	});
	if (state.status === "finished") return null;
	if (state.status === "submitting") return /* @__PURE__ */ u(StatusPage, {
		variant: "loading",
		icon: /* @__PURE__ */ u(LoadingIcon, { size: 64 }),
		title: t("watchlistForBusiness.processing"),
		subtitle: t("common.wontTakeLong")
	});
	if (state.status === "success") return /* @__PURE__ */ u(StatusPage, {
		variant: "success",
		icon: /* @__PURE__ */ u(SuccessIcon, { size: 64 }),
		title: t("common.done")
	});
	if (state.status === "form" || state.status === "idle") {
		const formState = state.status === "form" ? state : null;
		return /* @__PURE__ */ u(Page, {
			className: "IncodeWatchlistForBusinessPage",
			title: t("watchlistForBusiness.title"),
			hideFooterBranding: true,
			children: /* @__PURE__ */ u("form", {
				class: "IncodeWatchlistForBusinessForm",
				onSubmit: (e) => {
					e.preventDefault();
					manager.submit();
				},
				autoComplete: "off",
				children: [
					/* @__PURE__ */ u(CountrySelector, {
						id: "watchlist-for-business-country",
						label: t("watchlistForBusiness.country"),
						value: formState?.country ?? "US",
						onChange: (country) => manager.setCountry(country),
						"data-testid": "watchlist-for-business-country-selector"
					}),
					/* @__PURE__ */ u(InputComposed, {
						id: "businessName",
						name: "businessName",
						label: t("watchlistForBusiness.businessName"),
						value: formState?.businessName ?? "",
						onInput: (e) => manager.setBusinessName(e.target.value)
					}),
					/* @__PURE__ */ u(Button, {
						type: "submit",
						disabled: !formState?.isValid,
						"data-testid": "watchlist-for-business-submit",
						children: t("watchlistForBusiness.continue")
					})
				]
			})
		});
	}
	return null;
};
var WatchlistForBusiness = ({ onFinish }) => /* @__PURE__ */ u(IncodeComponent, { children: /* @__PURE__ */ u(WatchlistForBusinessContent, { onFinish }) });
registerIncodeModuleElement(WatchlistForBusiness, "incode-watchlist-for-business");
//#endregion
export { WatchlistForBusiness };
