import { jsxs as t, jsx as e } from "react/jsx-runtime";
import { Link as o } from "react-router-dom";
import { useTranslation as x } from "react-i18next";
import { Layers as g, AlertTriangle as p, CheckCircle2 as u, Database as b, Code2 as C, ArrowRight as i, Package as v } from "lucide-react";
const d = [
  {
    name: "CoreDbContext",
    schema: "core",
    historyTable: "core.__EFMigrationsHistory",
    description: "Manages all SmartStack platform entities. Distributed via NuGet package.",
    entities: [
      "User, Role, Permission, UserRole",
      "NavigationApplication, NavigationModule",
      "AiProvider, AiModel, Prompt, OutputSchema",
      "EntraConfiguration, EntraGroup, EntraSyncState",
      "Ticket, TicketComment, Notification",
      "Setting, License, Workflow"
    ],
    color: "from-blue-500 to-cyan-500"
  },
  {
    name: "ExtensionsDbContext",
    schema: "extensions",
    historyTable: "extensions.__EFMigrationsHistory",
    description: "Manages client-specific entities. Created by CLI in client projects.",
    entities: [
      "Your custom entities (Order, Product, Invoice, etc.)",
      "Client-specific business logic entities",
      "Extension tables that reference Core entities via GUID"
    ],
    color: "from-purple-500 to-pink-500"
  }
];
function m({ context: a, contextKey: n }) {
  const { t: r } = x("docs");
  return /* @__PURE__ */ t("div", { className: "card p-6", children: [
    /* @__PURE__ */ e("div", { className: `w-12 h-12 rounded-lg bg-gradient-to-r ${a.color} flex items-center justify-center mb-4`, children: /* @__PURE__ */ e(b, { className: "w-6 h-6 text-white" }) }),
    /* @__PURE__ */ e("h3", { className: "text-xl font-bold mb-2", children: r(`dualDbContextPage.contextCards.${n}.name`) }),
    /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)] mb-4", children: r(`dualDbContextPage.contextCards.${n}.description`) }),
    /* @__PURE__ */ t("div", { className: "space-y-3", children: [
      /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ e("span", { className: "text-sm text-[var(--text-tertiary)]", children: r(`dualDbContextPage.contextCards.${n}.schema`) }),
        /* @__PURE__ */ e("code", { className: "px-2 py-0.5 bg-[var(--bg-secondary)] rounded text-sm font-mono", children: r(`dualDbContextPage.contextCards.${n}.schemaValue`) })
      ] }),
      /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ e("span", { className: "text-sm text-[var(--text-tertiary)]", children: r(`dualDbContextPage.contextCards.${n}.history`) }),
        /* @__PURE__ */ e("code", { className: "px-2 py-0.5 bg-[var(--bg-secondary)] rounded text-sm font-mono", children: r(`dualDbContextPage.contextCards.${n}.historyTable`) })
      ] })
    ] }),
    /* @__PURE__ */ t("div", { className: "mt-4 pt-4 border-t border-[var(--border-color)]", children: [
      /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: r(`dualDbContextPage.contextCards.${n}.entities`) }),
      /* @__PURE__ */ e("ul", { className: "mt-2 space-y-1", children: [1, 2, 3].map((c) => {
        const h = `entity${c}`, l = r(`dualDbContextPage.contextCards.${n}.${h}`, { defaultValue: "" });
        return l ? /* @__PURE__ */ t("li", { className: "text-sm text-[var(--text-secondary)] flex items-start gap-2", children: [
          /* @__PURE__ */ e("span", { className: "text-[var(--color-primary-600)]", children: "-" }),
          l
        ] }, `entity-${c}`) : null;
      }) })
    ] })
  ] });
}
function s({ code: a, language: n = "csharp" }) {
  return /* @__PURE__ */ e("pre", { className: "bg-[var(--bg-tertiary)] rounded-lg p-4 overflow-x-auto", children: /* @__PURE__ */ e("code", { className: `language-${n} text-sm`, children: a }) });
}
function P() {
  const { t: a } = x("docs");
  return /* @__PURE__ */ t("div", { className: "space-y-8", children: [
    /* @__PURE__ */ t("div", { className: "flex items-center gap-2 text-sm text-[var(--text-secondary)]", children: [
      /* @__PURE__ */ e(o, { to: "/system/docs", className: "hover:text-[var(--color-primary-600)]", children: a("dualDbContextPage.breadcrumb.documentation") }),
      /* @__PURE__ */ e("span", { children: "/" }),
      /* @__PURE__ */ e(o, { to: "/system/docs/developer", className: "hover:text-[var(--color-primary-600)]", children: a("dualDbContextPage.breadcrumb.developer") }),
      /* @__PURE__ */ e("span", { children: "/" }),
      /* @__PURE__ */ e("span", { children: a("dualDbContextPage.breadcrumb.title") })
    ] }),
    /* @__PURE__ */ t("div", { children: [
      /* @__PURE__ */ t("h1", { className: "text-3xl font-bold mb-4 flex items-center gap-3", children: [
        /* @__PURE__ */ e(g, { className: "w-8 h-8 text-[var(--color-primary-600)]" }),
        a("dualDbContextPage.header.title")
      ] }),
      /* @__PURE__ */ e("p", { className: "text-lg text-[var(--text-secondary)]", children: a("dualDbContextPage.header.subtitle") })
    ] }),
    /* @__PURE__ */ t("section", { className: "card p-6", children: [
      /* @__PURE__ */ t("h2", { className: "text-xl font-bold mb-4 flex items-center gap-2", children: [
        /* @__PURE__ */ e(p, { className: "w-5 h-5 text-[var(--warning-text)]" }),
        a("dualDbContextPage.whySection.title")
      ] }),
      /* @__PURE__ */ t("div", { className: "space-y-4 text-[var(--text-secondary)]", children: [
        /* @__PURE__ */ e("p", { children: a("dualDbContextPage.whySection.description") }),
        /* @__PURE__ */ t("ul", { className: "list-disc list-inside space-y-2 ml-4", children: [
          /* @__PURE__ */ t("li", { children: [
            /* @__PURE__ */ e("strong", { children: a("dualDbContextPage.whySection.problem1") }),
            " - ",
            a("dualDbContextPage.whySection.problem1Desc")
          ] }),
          /* @__PURE__ */ t("li", { children: [
            /* @__PURE__ */ e("strong", { children: a("dualDbContextPage.whySection.problem2") }),
            " - ",
            a("dualDbContextPage.whySection.problem2Desc")
          ] }),
          /* @__PURE__ */ t("li", { children: [
            /* @__PURE__ */ e("strong", { children: a("dualDbContextPage.whySection.problem3") }),
            " - ",
            a("dualDbContextPage.whySection.problem3Desc")
          ] })
        ] })
      ] })
    ] }),
    /* @__PURE__ */ t("section", { className: "card p-6", children: [
      /* @__PURE__ */ t("h2", { className: "text-xl font-bold mb-4 flex items-center gap-2", children: [
        /* @__PURE__ */ e(u, { className: "w-5 h-5 text-[var(--success-text)]" }),
        a("dualDbContextPage.solutionSection.title")
      ] }),
      /* @__PURE__ */ t("div", { className: "grid md:grid-cols-2 gap-6", children: [
        /* @__PURE__ */ e(m, { context: d[0], contextKey: "coreDbContext" }),
        /* @__PURE__ */ e(m, { context: d[1], contextKey: "extensionsDbContext" })
      ] })
    ] }),
    /* @__PURE__ */ t("section", { className: "card p-6", children: [
      /* @__PURE__ */ t("h2", { className: "text-xl font-bold mb-4 flex items-center gap-2", children: [
        /* @__PURE__ */ e(b, { className: "w-5 h-5" }),
        a("dualDbContextPage.databaseStructure.title")
      ] }),
      /* @__PURE__ */ e("div", { className: "bg-[var(--bg-secondary)] rounded-lg p-6", children: /* @__PURE__ */ e("pre", { className: "text-sm font-mono whitespace-pre", children: `SmartStack Database (single SQL Server database)
├── core schema
│   ├── __EFMigrationsHistory  (Core migrations only)
│   ├── auth_Users
│   ├── auth_Roles
│   ├── auth_Permissions
│   ├── nav_Applications
│   ├── nav_Modules
│   ├── ai_Providers
│   ├── ai_Models
│   └── ... (all SmartStack tables)
│
└── extensions schema
    ├── __EFMigrationsHistory  (Extensions migrations only)
    ├── biz_Orders             (example client table)
    ├── biz_Products           (example client table)
    └── ... (all client tables)` }) })
    ] }),
    /* @__PURE__ */ t("section", { className: "card p-6", children: [
      /* @__PURE__ */ t("h2", { className: "text-xl font-bold mb-4 flex items-center gap-2", children: [
        /* @__PURE__ */ e(C, { className: "w-5 h-5" }),
        a("dualDbContextPage.efCoreConfiguration.title")
      ] }),
      /* @__PURE__ */ e("h3", { className: "font-semibold mt-4 mb-2", children: a("dualDbContextPage.efCoreConfiguration.coreDbContextTitle") }),
      /* @__PURE__ */ e(s, { code: `// Dans DependencyInjection.cs (SmartStack.Infrastructure)
services.AddDbContext<CoreDbContext>(options =>
{
    options.UseSqlServer(connectionString, b =>
    {
        b.MigrationsAssembly(typeof(CoreDbContext).Assembly.FullName);
        b.MigrationsHistoryTable("__EFMigrationsHistory", "core"); // <-- Schema core
    });
});` }),
      /* @__PURE__ */ e("h3", { className: "font-semibold mt-6 mb-2", children: a("dualDbContextPage.efCoreConfiguration.extensionsDbContextTitle") }),
      /* @__PURE__ */ e(s, { code: `// Dans DependencyInjection.cs (Client.Infrastructure)
services.AddDbContext<ExtensionsDbContext>(options =>
{
    options.UseSqlServer(connectionString, b =>
    {
        b.MigrationsAssembly(typeof(ExtensionsDbContext).Assembly.FullName);
        b.MigrationsHistoryTable("__EFMigrationsHistory", "extensions"); // <-- Schema extensions
    });
});` })
    ] }),
    /* @__PURE__ */ t("section", { className: "card p-6", children: [
      /* @__PURE__ */ t("h2", { className: "text-xl font-bold mb-4 flex items-center gap-2", children: [
        /* @__PURE__ */ e(i, { className: "w-5 h-5" }),
        a("dualDbContextPage.migrationOrder.title")
      ] }),
      /* @__PURE__ */ e("div", { className: "bg-[var(--info-bg)] border border-[var(--info-border)] rounded-lg p-4 mb-4", children: /* @__PURE__ */ t("p", { className: "text-[var(--info-text)]", children: [
        /* @__PURE__ */ e("strong", { children: "Important:" }),
        " ",
        a("dualDbContextPage.migrationOrder.important")
      ] }) }),
      /* @__PURE__ */ e(s, { code: `// Dans Program.cs
if (app.Environment.IsDevelopment())
{
    using var scope = app.Services.CreateScope();

    // 1. D'abord Core (SmartStack platform)
    var coreDb = scope.ServiceProvider.GetRequiredService<CoreDbContext>();
    await coreDb.Database.MigrateAsync();

    // 2. Ensuite Extensions (Client)
    var extDb = scope.ServiceProvider.GetRequiredService<ExtensionsDbContext>();
    await extDb.Database.MigrateAsync();
}` })
    ] }),
    /* @__PURE__ */ t("section", { className: "card p-6", children: [
      /* @__PURE__ */ t("h2", { className: "text-xl font-bold mb-4 flex items-center gap-2", children: [
        /* @__PURE__ */ e(v, { className: "w-5 h-5" }),
        a("dualDbContextPage.efCoreCommands.title")
      ] }),
      /* @__PURE__ */ t("div", { className: "space-y-4", children: [
        /* @__PURE__ */ t("div", { children: [
          /* @__PURE__ */ e("h3", { className: "font-semibold mb-2", children: a("dualDbContextPage.efCoreCommands.coreMigrationsTitle") }),
          /* @__PURE__ */ e(s, { language: "bash", code: `# Creer une migration Core
dotnet ef migrations add core_v1.9.0_001_AddNewFeature --context CoreDbContext

# Appliquer
dotnet ef database update --context CoreDbContext

# Lister
dotnet ef migrations list --context CoreDbContext` })
        ] }),
        /* @__PURE__ */ t("div", { children: [
          /* @__PURE__ */ e("h3", { className: "font-semibold mb-2", children: a("dualDbContextPage.efCoreCommands.extensionsMigrationsTitle") }),
          /* @__PURE__ */ e(s, { language: "bash", code: `# Creer une migration Extensions
dotnet ef migrations add ext_v1.0.0_001_CreateOrders --context ExtensionsDbContext

# Appliquer
dotnet ef database update --context ExtensionsDbContext

# Lister
dotnet ef migrations list --context ExtensionsDbContext` })
        ] })
      ] })
    ] }),
    /* @__PURE__ */ t("div", { className: "flex justify-between pt-4 border-t border-[var(--border-color)]", children: [
      /* @__PURE__ */ t(
        o,
        {
          to: "/system/docs/developer/database",
          className: "flex items-center gap-2 text-[var(--color-primary-600)] hover:underline",
          children: [
            /* @__PURE__ */ e(i, { className: "w-4 h-4 rotate-180" }),
            a("dualDbContextPage.navigation.previous")
          ]
        }
      ),
      /* @__PURE__ */ t(
        o,
        {
          to: "/system/docs/developer/cross-schema-fk",
          className: "flex items-center gap-2 text-[var(--color-primary-600)] hover:underline",
          children: [
            a("dualDbContextPage.navigation.next"),
            /* @__PURE__ */ e(i, { className: "w-4 h-4" })
          ]
        }
      )
    ] })
  ] });
}
export {
  P as DualDbContextPage
};
//# sourceMappingURL=DualDbContextPage-CVBjCvGp.js.map
