// src/product-framework/product-routing.ts
var BUILTIN_PRODUCT_SLUGS = {
  "exxat-prism": "prism",
  "exxat-one-schools": "one-schools",
  "exxat-one-sites": "one-sites"
};
function builtInProductSlug(product) {
  if (product === "exxat-custom") return "custom";
  return BUILTIN_PRODUCT_SLUGS[product];
}
function customProductSlugFromSuffix(suffix) {
  const slug = suffix.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
  return slug || "custom-product";
}
function productRouteSlug(product, customProducts = [], activeCustomIndex = 0) {
  if (product === "exxat-custom") {
    const brand = customProducts[activeCustomIndex] ?? customProducts[0];
    if (brand?.suffix?.trim()) {
      return customProductSlugFromSuffix(brand.suffix);
    }
    return "custom";
  }
  return builtInProductSlug(product);
}

// src/product-framework/product-ref.ts
function productRefKey(ref) {
  return ref.customIndex !== void 0 ? `${ref.product}:${ref.customIndex}` : ref.product;
}
function productRefsEqual(a, b) {
  return a.product === b.product && (a.customIndex ?? -1) === (b.customIndex ?? -1);
}
function isProductRefHidden(ref, hiddenProducts) {
  return hiddenProducts.some((entry) => productRefsEqual(entry, ref));
}
function effectiveStartupProduct(startupProduct) {
  return startupProduct ?? { product: "exxat-prism" };
}
function isStartupProductRef(ref, startupProduct) {
  return productRefsEqual(ref, effectiveStartupProduct(startupProduct));
}
function startupDashboardPath(startupProduct, customProducts = []) {
  const ref = effectiveStartupProduct(startupProduct);
  const customIndex = ref.customIndex ?? 0;
  return `/${productRouteSlug(ref.product, customProducts, customIndex)}/dashboard`;
}
function adjustProductRefAfterCustomRemoval(ref, removedIndex) {
  if (!ref || ref.product !== "exxat-custom") return ref;
  const idx = ref.customIndex ?? 0;
  if (idx === removedIndex) return null;
  if (idx > removedIndex) return { ...ref, customIndex: idx - 1 };
  return ref;
}
function adjustHiddenProductsAfterCustomRemoval(hidden, removedIndex) {
  return hidden.filter((entry) => !(entry.product === "exxat-custom" && entry.customIndex === removedIndex)).map((entry) => {
    if (entry.product === "exxat-custom" && entry.customIndex !== void 0 && entry.customIndex > removedIndex) {
      return { ...entry, customIndex: entry.customIndex - 1 };
    }
    return entry;
  });
}
export {
  adjustHiddenProductsAfterCustomRemoval,
  adjustProductRefAfterCustomRemoval,
  effectiveStartupProduct,
  isProductRefHidden,
  isStartupProductRef,
  productRefKey,
  productRefsEqual,
  startupDashboardPath
};
//# sourceMappingURL=product-ref.js.map