/* global React, window */
// =====================================================================
// V4 Soluciones — Icon set (Lucide-style, stroke 2 px, currentColor)
// 10 íconos por categoría + 5 íconos UI (search, clock, plug, x, arrow)
// =====================================================================

const _stroke = {
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 2,
  strokeLinecap: "round",
  strokeLinejoin: "round",
};

const _wrap = (children, size = 22) => (
  <svg width={size} height={size} viewBox="0 0 24 24" aria-hidden="true" {..._stroke}>
    {children}
  </svg>
);

window.IK_ICONS = {
  // ---- Category icons ----
  doorOpen: (s) => _wrap(<>
    <path d="M13 4h3a2 2 0 0 1 2 2v14"/>
    <path d="M2 20h20"/>
    <path d="M13 4v16l-7-2V6z"/>
    <circle cx="10" cy="12" r="0.6" fill="currentColor"/>
  </>, s),
  users: (s) => _wrap(<>
    <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
    <circle cx="9" cy="7" r="4"/>
    <path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
    <path d="M16 3.13a4 4 0 0 1 0 7.75"/>
  </>, s),
  truck: (s) => _wrap(<>
    <path d="M1 3h15v13H1z"/>
    <path d="M16 8h4l3 3v5h-7"/>
    <circle cx="5.5" cy="18.5" r="2.5"/>
    <circle cx="18.5" cy="18.5" r="2.5"/>
  </>, s),
  boxes: (s) => _wrap(<>
    <path d="M2.97 12.92A2 2 0 0 0 2 14.63V18a2 2 0 0 0 1 1.73l5 2.89a2 2 0 0 0 2 0l5-2.89a2 2 0 0 0 1-1.73v-3.37a2 2 0 0 0-.97-1.71l-5-2.89a2 2 0 0 0-2.06 0z"/>
    <path d="M7 16.5l-4.74-2.85"/>
    <path d="M7 16.5v5.17"/>
    <path d="M14 8 9.04 5.09a2 2 0 0 0-2.08 0L2 8v9l5 2.92"/>
  </>, s),
  factory: (s) => _wrap(<>
    <path d="M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4H4a2 2 0 0 0-2 2z"/>
    <path d="M17 18h1"/>
    <path d="M12 18h1"/>
    <path d="M7 18h1"/>
  </>, s),
  receipt: (s) => _wrap(<>
    <path d="M4 2v20l2-2 2 2 2-2 2 2 2-2 2 2 2-2 2 2V2l-2 2-2-2-2 2-2-2-2 2-2-2-2 2z"/>
    <path d="M16 8H8"/>
    <path d="M16 12H8"/>
    <path d="M13 16H8"/>
  </>, s),
  message: (s) => _wrap(<>
    <path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8z"/>
  </>, s),
  target: (s) => _wrap(<>
    <circle cx="12" cy="12" r="10"/>
    <circle cx="12" cy="12" r="6"/>
    <circle cx="12" cy="12" r="2"/>
  </>, s),
  graduation: (s) => _wrap(<>
    <path d="M22 10 12 5 2 10l10 5 10-5z"/>
    <path d="M6 12v5c3 3 9 3 12 0v-5"/>
  </>, s),
  wrench: (s) => _wrap(<>
    <path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>
  </>, s),

  // ---- UI icons ----
  search: (s) => _wrap(<>
    <circle cx="11" cy="11" r="7"/>
    <path d="m21 21-4.3-4.3"/>
  </>, s),
  clock: (s) => _wrap(<>
    <circle cx="12" cy="12" r="10"/>
    <path d="M12 6v6l4 2"/>
  </>, s),
  plug: (s) => _wrap(<>
    <path d="M9 2v6"/>
    <path d="M15 2v6"/>
    <path d="M6 8h12v4a6 6 0 0 1-6 6 6 6 0 0 1-6-6z"/>
    <path d="M12 18v4"/>
  </>, s),
  x: (s) => _wrap(<>
    <path d="M18 6 6 18"/>
    <path d="m6 6 12 12"/>
  </>, s),
  arrowRight: (s) => _wrap(<>
    <path d="M5 12h14"/>
    <path d="m12 5 7 7-7 7"/>
  </>, s),
  sparkles: (s) => _wrap(<>
    <path d="m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z"/>
  </>, s),
  check: (s) => _wrap(<>
    <path d="M20 6 9 17l-5-5"/>
  </>, s),
  plus: (s) => _wrap(<>
    <path d="M12 5v14"/>
    <path d="M5 12h14"/>
  </>, s),
};

window.IKIcon = function IKIcon({ name, size = 22 }) {
  const fn = window.IK_ICONS[name];
  if (!fn) return null;
  return fn(size);
};
