//#region src/presentation/frontend/CodemationFrontendAuthSnapshotJsonCodec.ts
var CodemationFrontendAuthSnapshotJsonCodec = class {
	serialize(snapshot) {
		return JSON.stringify(snapshot);
	}
	deserialize(serialized) {
		if (!serialized || serialized.trim().length === 0) return null;
		try {
			const parsed = JSON.parse(serialized);
			if (!parsed || typeof parsed !== "object") return null;
			return {
				config: this.resolveAuthConfig(parsed.config),
				credentialsEnabled: parsed.credentialsEnabled === true,
				oauthProviders: this.resolveOauthProviders(parsed.oauthProviders),
				secret: typeof parsed.secret === "string" && parsed.secret.trim().length > 0 ? parsed.secret : null,
				uiAuthEnabled: parsed.uiAuthEnabled !== false
			};
		} catch {
			return null;
		}
	}
	resolveAuthConfig(value) {
		return value && typeof value === "object" ? value : void 0;
	}
	resolveOauthProviders(value) {
		if (!Array.isArray(value)) return [];
		return value.flatMap((entry) => {
			if (!entry || typeof entry !== "object") return [];
			const provider = entry;
			if (typeof provider.id !== "string" || typeof provider.name !== "string") return [];
			return [{
				id: provider.id,
				name: provider.name
			}];
		});
	}
};

//#endregion
//#region src/presentation/frontend/FrontendAppConfigJsonCodec.ts
var FrontendAppConfigJsonCodec = class {
	serialize(config) {
		return JSON.stringify(config);
	}
	deserialize(serialized) {
		if (!serialized || serialized.trim().length === 0) return null;
		try {
			const parsed = JSON.parse(serialized);
			if (!parsed || typeof parsed !== "object" || !parsed.auth || typeof parsed.auth !== "object") return null;
			return {
				auth: {
					config: this.resolveAuthConfig(parsed.auth.config),
					credentialsEnabled: parsed.auth.credentialsEnabled === true,
					oauthProviders: this.resolveOauthProviders(parsed.auth.oauthProviders),
					secret: typeof parsed.auth.secret === "string" && parsed.auth.secret.trim().length > 0 ? parsed.auth.secret : null,
					uiAuthEnabled: parsed.auth.uiAuthEnabled !== false
				},
				productName: typeof parsed.productName === "string" && parsed.productName.trim().length > 0 ? parsed.productName : "Codemation",
				logoUrl: typeof parsed.logoUrl === "string" && parsed.logoUrl.trim().length > 0 ? parsed.logoUrl : null
			};
		} catch {
			return null;
		}
	}
	resolveAuthConfig(value) {
		return value && typeof value === "object" ? value : void 0;
	}
	resolveOauthProviders(value) {
		if (!Array.isArray(value)) return [];
		return value.flatMap((entry) => {
			if (!entry || typeof entry !== "object") return [];
			const provider = entry;
			if (typeof provider.id !== "string" || typeof provider.name !== "string") return [];
			return [{
				id: provider.id,
				name: provider.name
			}];
		});
	}
};

//#endregion
//#region src/presentation/frontend/InternalAuthBootstrapJsonCodec.ts
var InternalAuthBootstrapJsonCodec = class {
	serialize(bootstrap) {
		return JSON.stringify(bootstrap);
	}
	deserialize(serialized) {
		if (!serialized || serialized.trim().length === 0) return null;
		try {
			const parsed = JSON.parse(serialized);
			if (!parsed || typeof parsed !== "object") return null;
			return {
				authConfig: this.resolveAuthConfig(parsed.authConfig),
				credentialsEnabled: parsed.credentialsEnabled === true,
				oauthProviders: this.resolveOauthProviders(parsed.oauthProviders),
				uiAuthEnabled: parsed.uiAuthEnabled !== false
			};
		} catch {
			return null;
		}
	}
	resolveAuthConfig(value) {
		return value && typeof value === "object" ? value : void 0;
	}
	resolveOauthProviders(value) {
		if (!Array.isArray(value)) return [];
		return value.flatMap((entry) => {
			if (!entry || typeof entry !== "object") return [];
			const provider = entry;
			if (typeof provider.id !== "string" || typeof provider.name !== "string") return [];
			return [{
				id: provider.id,
				name: provider.name
			}];
		});
	}
};

//#endregion
//#region src/presentation/frontend/PublicFrontendBootstrapJsonCodec.ts
var PublicFrontendBootstrapJsonCodec = class {
	serialize(bootstrap) {
		return JSON.stringify(bootstrap);
	}
	deserialize(serialized) {
		if (!serialized || serialized.trim().length === 0) return null;
		try {
			const parsed = JSON.parse(serialized);
			if (!parsed || typeof parsed !== "object") return null;
			const base = {
				credentialsEnabled: parsed.credentialsEnabled === true,
				logoUrl: typeof parsed.logoUrl === "string" && parsed.logoUrl.trim().length > 0 ? parsed.logoUrl : null,
				oauthProviders: this.resolveOauthProviders(parsed.oauthProviders),
				productName: typeof parsed.productName === "string" && parsed.productName.trim().length > 0 ? parsed.productName : "Codemation",
				uiAuthEnabled: parsed.uiAuthEnabled !== false
			};
			const cpWebOrigin = typeof parsed.cpWebOrigin === "string" && parsed.cpWebOrigin.trim().length > 0 ? parsed.cpWebOrigin : void 0;
			return cpWebOrigin ? {
				...base,
				cpWebOrigin
			} : base;
		} catch {
			return null;
		}
	}
	resolveOauthProviders(value) {
		if (!Array.isArray(value)) return [];
		return value.flatMap((entry) => {
			if (!entry || typeof entry !== "object") return [];
			const provider = entry;
			if (typeof provider.id !== "string" || typeof provider.name !== "string") return [];
			return [{
				id: provider.id,
				name: provider.name
			}];
		});
	}
};

//#endregion
export { CodemationFrontendAuthSnapshotJsonCodec as i, InternalAuthBootstrapJsonCodec as n, FrontendAppConfigJsonCodec as r, PublicFrontendBootstrapJsonCodec as t };
//# sourceMappingURL=PublicFrontendBootstrapJsonCodec-CegIF_ne.js.map