import { mountComponentRenderer } from "./Components.js";
import { MIN_CLERK_JS_VERSION } from "./constants.js";
import { ClerkRuntimeError } from "@clerk/shared/error";
import { logger } from "@clerk/shared/logger";
import { isVersionAtLeast, parseVersion } from "@clerk/shared/versionCheck";

//#region src/ClerkUI.ts
var ClerkUI = class ClerkUI {
	static version = "1.0.0-canary.v20260210004030";
	version = "1.0.0-canary.v20260210004030";
	#componentRenderer;
	constructor(getClerk, getEnvironment, options, moduleManager) {
		const clerk = getClerk();
		const clerkVersion = clerk?.version;
		const isDevelopmentInstance = clerk?.instanceType === "development";
		const parsedVersion = parseVersion(clerkVersion ?? "");
		let incompatibilityMessage = null;
		if (parsedVersion && !isVersionAtLeast(clerkVersion, MIN_CLERK_JS_VERSION)) incompatibilityMessage = `@clerk/ui@${ClerkUI.version} requires @clerk/clerk-js@>=${MIN_CLERK_JS_VERSION}, but found @clerk/clerk-js@${clerkVersion}. Please upgrade @clerk/clerk-js (or your framework SDK) to a compatible version.`;
		else if (!parsedVersion && !moduleManager) incompatibilityMessage = `@clerk/ui@${ClerkUI.version} requires @clerk/clerk-js@>=${MIN_CLERK_JS_VERSION}, but found an incompatible version${clerkVersion ? ` (${clerkVersion})` : ""}. Please upgrade @clerk/clerk-js (or your framework SDK) to a compatible version.`;
		if (incompatibilityMessage) if (isDevelopmentInstance) throw new ClerkRuntimeError(incompatibilityMessage, { code: "clerk_ui_version_mismatch" });
		else logger.warnOnce(incompatibilityMessage);
		this.#componentRenderer = mountComponentRenderer(getClerk, getEnvironment, options, moduleManager);
	}
	ensureMounted(opts) {
		return this.#componentRenderer.ensureMounted(opts);
	}
};

//#endregion
export { ClerkUI };
//# sourceMappingURL=ClerkUI.js.map