import type { ProductConfig } from "@/lib/types";
import { normalizeProductEdition } from "@/lib/editions";

export type NativeZimbraAddonState = {
  editionEnabled: boolean;
  calendarEnabled: boolean;
  tasksEnabled: boolean;
  briefcaseEnabled: boolean;
};

export function getNativeZimbraAddonState(product?: ProductConfig | null): NativeZimbraAddonState {
  return {
    editionEnabled: normalizeProductEdition(product?.edition) === "mail_native_zimbra",
    calendarEnabled: product?.capabilities.calendar_native_zimbra ?? false,
    tasksEnabled: product?.capabilities.tasks_native_zimbra ?? false,
    briefcaseEnabled: product?.capabilities.drive_native_zimbra ?? false,
  };
}

export function isNativeZimbraAddonVisible(product?: ProductConfig | null) {
  return getNativeZimbraAddonState(product).editionEnabled;
}
