// AXLU — seed data.
// Real entities are empty: the app starts vierge, ready to be fed by
// supplier connectors and other backend wiring. Only static metadata
// (status labels, emoji maps, role catalogue) and a single bootstrap admin
// remain — the latter so somebody can actually log in on first launch.

const SUPPLIERS = [];
const CATEGORIES_AXLU = [];
const CATEGORIES_PF = [];
const PRODUCTS = [];
const SYNCS = [];
const SYNC_ERRORS = [];
// Marking-based pricing model.
// MARKING_GRIDS: one grid per (markingType + format), each with quantity tiers.
// MODIFIERS_*: multiplicative coefficients applied on top of grid prices.
// PRICING_COSTS: shared cost & margin parameters (base coef, marking coef).
// SHIPPING_TIERS: cart-amount-based shipping fee billed to the customer.
const MARKING_GRIDS = [];
const MODIFIERS_CATEGORY = [];   // [{ id, name, key (categoryId), coef, enabled }]
const MODIFIERS_CLIENT = [];     // [{ id, name, key (clientType), coef, enabled }]
const MODIFIERS_ORDER = [];      // [{ id, name, from, to, coef, enabled }]
const PRICING_COSTS = {
  baseCoef: 2.5,
  markingCoef: 2.0, // multiplier applied to PF marking costs → marking sell price
};
// Cart-total shipping fee. Each tier covers a cart-total range [from ; to[
// (to = null → "and above") and bills a flat shipping fee. fee 0 → free.
const SHIPPING_TIERS = [
  { from: 0,   to: 50,   fee: 6.90 },
  { from: 50,  to: 150,  fee: 4.90 },
  { from: 150, to: null, fee: 0 },
];
const CLIENT_TYPES = [
  { id: "particulier", label: "Particulier" },
  { id: "pro",         label: "Professionnel" },
  { id: "b2b",         label: "B2B / Revendeur" },
];
// Supplier reference data imported from feeds (not editable, refreshed on sync).
const PF_ATTRIBUTES = [];   // [{ code, description, tooltip }] — attribute label dictionary
const PF_PRINT_PRICES = []; // [{ printCode, method, ltmCharge, priceDependence, priceMatrix }]
// Per-technique marking coefficient override: { [printCode]: coef }. When a
// printCode is present, its coef overrides PRICING_COSTS.markingCoef globally.
const MARKING_COEFS = {};
const AUDIT_LOG = [];
const PUBLICATIONS_QUEUE = [];
const PUBLICATIONS_ERRORS = [];

// Bootstrap admin — owner account.
const USERS = [
  {
    id: "u-bootstrap",
    name: "Admin",
    email: "admin@example.com",
    role: "admin",
    // Placeholder only — this seed runs on a FRESH install to create the owner
    // account; set a real password on first login. Never commit a real one.
    password: "changeme",
    lastLogin: null,
    active: true,
    pendingKey: null,
  },
];

// Static metadata — status definitions, emoji catalogues, gamification defaults.

const PRODUCT_STATUSES = {
  to_review:  { label: "À vérifier",  tone: "warning", emoji: "👀" },
  approved:   { label: "Approuvé",    tone: "info",    emoji: "✅" },
  blocked:    { label: "Bloqué",      tone: "danger",  emoji: "🚫" },
  archived:   { label: "Archivé",     tone: "muted",   emoji: "🗄️" },
};

const SYNC_STATUSES = {
  success:         { label: "Succès",         tone: "success", emoji: "✨" },
  partial_success: { label: "Succès partiel", tone: "warning", emoji: "⚠️" },
  failed:          { label: "Échec",          tone: "danger",  emoji: "💥" },
  running:         { label: "En cours",       tone: "info",    emoji: "⏳" },
  interrupted:     { label: "Interrompue",    tone: "warning", emoji: "⏹️" },
};

const FLOW_EMOJI = {
  products: "📦",
  products_usb: "📦",
  prices:   "💰",
  stocks:   "📊",
  marking:  "🎨",
  images:   "🖼️",
};

const CATEGORY_EMOJI = {
  writing:    "✏️",
  drinkware:  "🍼",
  bags:       "🎒",
  tech:       "🔌",
  outdoor:    "⛱️",
  office:     "📒",
  textile:    "👕",
};

const ROLES = {
  admin:    { label: "Administrateur", desc: "Tous les droits, gestion utilisateurs et suppression." },
  operator: { label: "Opérateur",      desc: "Lecture & édition, sans suppression ni gestion des utilisateurs." },
  viewer:   { label: "Lecture seule",  desc: "Consultation du tableau de bord uniquement." },
};

const GAMIFICATION = {
  streakDays: 0,
  level: 1,
  levelName: "Débutant",
  xp: 0,
  xpForNext: 500,
  xpToday: 0,
  rank: null,
  totalUsers: 1,
  badges: [
    { id: "first-sync",     emoji: "🏁", name: "Première synchro",       earned: false, date: null },
    { id: "clean-week",     emoji: "✨",       name: "Semaine sans erreur",    earned: false, date: null },
    { id: "published-100",  emoji: "🚀", name: "100 produits publiés",   earned: false, date: null },
    { id: "published-1000", emoji: "👑", name: "1 000 produits publiés", earned: false, date: null },
    { id: "streak-7",       emoji: "🔥", name: "Streak 7 jours",         earned: false, date: null },
    { id: "streak-30",      emoji: "☄️", name: "Streak 30 jours",        earned: false, date: null },
    { id: "mapping-master", emoji: "🧭", name: "Mapping 100% complet",   earned: false, date: null },
    { id: "price-perfect",  emoji: "💸", name: "Marges optimisées",      earned: false, date: null },
  ],
  leaderboard: [],
};

window.AxluData = {
  SUPPLIERS,
  CATEGORIES_AXLU,
  CATEGORIES_PF,
  CATEGORY_EMOJI,
  FLOW_EMOJI,
  GAMIFICATION,
  PRODUCTS,
  PRODUCT_STATUSES,
  SYNC_STATUSES,
  SYNCS,
  SYNC_ERRORS,
  MARKING_GRIDS,
  MODIFIERS_CATEGORY,
  MODIFIERS_CLIENT,
  MODIFIERS_ORDER,
  PRICING_COSTS,
  SHIPPING_TIERS,
  CLIENT_TYPES,
  PF_ATTRIBUTES,
  PF_PRINT_PRICES,
  MARKING_COEFS,
  USERS,
  ROLES,
  AUDIT_LOG,
  PUBLICATIONS_QUEUE,
  PUBLICATIONS_ERRORS,
};
