const RESERVED_SLUGS = [
  // Core system routes
  "api",
  "auth",
  "admin",
  "login",
  "register",
  "dashboard",
  "signin",
  "signout",
  "signup",
  "verify",
  "reset-password",
  "forgot-password",
  // Next.js internals
  "_next",
  "_vercel",
  "_error",
  "_document",
  "_app",
  // Common static assets
  "public",
  "static",
  "assets",
  "images",
  "theme",
  "favicon.ico",
  "robots.txt",
  "sitemap.xml",
  "manifest.json",
  // Reserved for potential future use
  "app",
  "core",
  "lib",
  "components",
  "utils",
  "styles",
  "fonts",
  // Common page names that might conflict
  "index",
  "home",
  "page",
  "post",
  "posts",
  "blog",
  "article",
  "articles",
  // API versioning
  "v1",
  "v2",
  "v3"
  // Will be extended with entity slugs from ENTITY_REGISTRY
  // by build-registry.mjs
];
function isReservedSlug(slug) {
  return RESERVED_SLUGS.includes(slug.toLowerCase());
}
function validatePageSlug(slug) {
  if (!slug || slug.trim().length === 0) {
    return "Slug cannot be empty";
  }
  const slugRegex = /^[a-z0-9\-]+$/;
  if (!slugRegex.test(slug)) {
    return "Slug can only contain lowercase letters, numbers, and hyphens";
  }
  if (slug.startsWith("-") || slug.endsWith("-")) {
    return "Slug cannot start or end with a hyphen";
  }
  if (slug.includes("--")) {
    return "Slug cannot contain consecutive hyphens";
  }
  if (slug.length > 100) {
    return "Slug cannot be longer than 100 characters";
  }
  if (slug.length < 2) {
    return "Slug must be at least 2 characters long";
  }
  if (isReservedSlug(slug)) {
    return `Slug "${slug}" is reserved by the system`;
  }
  return null;
}
function generateSlug(input) {
  return input.toLowerCase().trim().replace(/[^\w\s\-]/g, "").replace(/\s+/g, "-").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "").slice(0, 100);
}
function suggestAlternativeSlug(slug, existingSlugs = []) {
  const suggestions = [];
  const baseSlug = slug.replace(/-\d+$/, "");
  for (let i = 1; i <= 5; i++) {
    const candidate = `${baseSlug}-${i}`;
    if (!isReservedSlug(candidate) && !existingSlugs.includes(candidate)) {
      suggestions.push(candidate);
    }
  }
  const suffixes = ["page", "new", "info", "details", "view"];
  for (const suffix of suffixes) {
    const candidate = `${baseSlug}-${suffix}`;
    if (!isReservedSlug(candidate) && !existingSlugs.includes(candidate)) {
      suggestions.push(candidate);
    }
  }
  return suggestions.slice(0, 5);
}
export {
  RESERVED_SLUGS,
  generateSlug,
  isReservedSlug,
  suggestAlternativeSlug,
  validatePageSlug
};
