/* global React */
// LPE Icon set — distilled from the live codebase Icon.tsx, plus a small set of
// LMS-specific glyphs (play, chapters, certificate, calendar…). 1.5px stroke,
// 16px viewBox, no fill, currentColor. Draw new glyphs into this file — never mix
// in an icon library.

const ICON_PATHS = {
  search: <path d="M11 11l4 4M7 12.5A5.5 5.5 0 1 1 12.5 7 5.5 5.5 0 0 1 7 12.5z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" />,
  bell: <path d="M5 13V8a3 3 0 1 1 6 0v5l1 2H4l1-2zM6.5 16h3" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  plus: <path d="M8 3v10M3 8h10" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />,
  chevDown: <path d="M3 6l5 4 5-4" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  chevRight: <path d="M6 3l5 5-5 5" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" />,
  chevLeft: <path d="M10 3L5 8l5 5" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  grid: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none">
      <rect x="2" y="2" width="5" height="5" />
      <rect x="9" y="2" width="5" height="5" />
      <rect x="2" y="9" width="5" height="5" />
      <rect x="9" y="9" width="5" height="5" />
    </g>
  ),
  list: <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round"><path d="M2 4h12M2 8h12M2 12h12" /></g>,
  pin: <path d="M8 1.5a4 4 0 0 1 4 4c0 3-4 8-4 8s-4-5-4-8a4 4 0 0 1 4-4zM8 5.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3z" stroke="currentColor" strokeWidth="1.3" fill="none" />,
  bookmark: <path d="M3.5 2h9v12l-4.5-3-4.5 3V2z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round" />,
  bookmarkFill: <path d="M3.5 2h9v12l-4.5-3-4.5 3V2z" fill="currentColor" />,
  download: <path d="M8 2v8m-3-3l3 3 3-3M3 13h10" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  paperclip: <path d="M11 4l-5 5a2 2 0 0 0 3 3l5-5a3.5 3.5 0 0 0-5-5L4 7a5 5 0 0 0 7 7" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  send: <path d="M14 2L1 8l5 2 2 5 6-13z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round" />,
  file: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round">
      <path d="M3 1.5h7l3 3V14H3V1.5z" /><path d="M10 1.5V5h3" />
    </g>
  ),
  user: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none">
      <circle cx="8" cy="6" r="2.5" /><path d="M3 14c0-2.8 2.2-5 5-5s5 2.2 5 5" />
    </g>
  ),
  home: <path d="M2 8l6-5 6 5v6h-4v-4H6v4H2V8z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round" />,
  market: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none">
      <rect x="2" y="3" width="12" height="10" /><path d="M2 6h12M6 13V6" />
    </g>
  ),
  folder: <path d="M2 4h4l1.5 1.5H14V13H2V4z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round" />,
  chat: <path d="M2 3h12v8H6l-3 3v-3H2V3z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round" />,
  chart: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round">
      <path d="M2 13h12" /><path d="M4 11V7M7 11V4M10 11V8M13 11V6" />
    </g>
  ),
  settings: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none">
      <circle cx="8" cy="8" r="2" /><path d="M8 1.5v2M8 12.5v2M14.5 8h-2M3.5 8h-2M12.6 3.4l-1.4 1.4M4.8 11.2l-1.4 1.4M12.6 12.6l-1.4-1.4M4.8 4.8L3.4 3.4" />
    </g>
  ),
  book: <path d="M2 3h5a2 2 0 0 1 2 2v8a2 2 0 0 0-2-2H2V3zM14 3H9a2 2 0 0 0-2 2v8a2 2 0 0 1 2-2h5V3z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round" />,
  arrowUp: <path d="M8 13V3m-4 4l4-4 4 4" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  arrowDown: <path d="M8 3v10m-4-4l4 4 4-4" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  arrowRight: <path d="M3 8h10m-4-4l4 4-4 4" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  clock: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none">
      <circle cx="8" cy="8" r="6" /><path d="M8 5v3l2 2" />
    </g>
  ),
  lock: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none">
      <rect x="3" y="7" width="10" height="7" /><path d="M5 7V5a3 3 0 0 1 6 0v2" />
    </g>
  ),
  mail: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round">
      <rect x="2" y="3.5" width="12" height="9" /><path d="M2.5 4.5L8 9l5.5-4.5" />
    </g>
  ),
  check: <path d="M3 8.5l3 3 7-7" stroke="currentColor" strokeWidth="1.8" fill="none" strokeLinecap="round" strokeLinejoin="round" />,
  x: <path d="M3 3l10 10M13 3L3 13" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />,
  eye: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none">
      <path d="M1 8s2.5-5 7-5 7 5 7 5-2.5 5-7 5-7-5-7-5z" /><circle cx="8" cy="8" r="2" />
    </g>
  ),
  sliders: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round">
      <path d="M3 4h10M3 8h10M3 12h10" />
      <circle cx="6" cy="4" r="1.5" fill="white" />
      <circle cx="10" cy="8" r="1.5" fill="white" />
      <circle cx="5" cy="12" r="1.5" fill="white" />
    </g>
  ),
  handshake: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round">
      <path d="M1.5 13l4.5-3" /><path d="M14.5 13l-4.5-3" />
      <rect x="5.5" y="8.5" width="5" height="3" rx="1.4" /><path d="M8 8.5v3" />
    </g>
  ),
  dollar: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="8" cy="8" r="6" /><path d="M8 4.5v7" />
      <path d="M10 6.3c0-.8-.9-1.4-2-1.4s-2 .6-2 1.4.9 1.3 2 1.5 2 .7 2 1.5-.9 1.4-2 1.4-2-.6-2-1.4" />
    </g>
  ),
  tag: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round">
      <path d="M2 9V2h7l5 5-7 7-5-5z" /><circle cx="5.5" cy="5.5" r="0.8" />
    </g>
  ),
  lifebuoy: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round">
      <circle cx="8" cy="8" r="6" /><circle cx="8" cy="8" r="2.5" />
      <path d="M8 2v3.5M8 10.5V14M2 8h3.5M10.5 8H14" />
    </g>
  ),
  menu: <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round"><path d="M2 4h12M2 8h12M2 12h12" /></g>,
  filter: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round">
      <path d="M2 4h12M4 8h8M6 12h4" />
    </g>
  ),
  info: (
    <g fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round">
      <circle cx="8" cy="8" r="6.4" /><path d="M8 7v4" />
      <circle cx="8" cy="5" r="0.4" fill="currentColor" stroke="none" />
    </g>
  ),
  logout: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round">
      <path d="M9 2H3v12h6" /><path d="M11 5l3 3-3 3" /><path d="M6 8h8" />
    </g>
  ),
  // ---- LMS-specific ----
  play: <path d="M4 2.5l9 5.5-9 5.5V2.5z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round" />,
  playFill: <path d="M4 2.5l9 5.5-9 5.5V2.5z" fill="currentColor" />,
  pause: <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round"><path d="M5.5 3v10M10.5 3v10" /></g>,
  video: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round">
      <rect x="1.5" y="4" width="9" height="8" /><path d="M10.5 7l4-2v6l-4-2z" />
    </g>
  ),
  webinar: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round">
      <rect x="1.5" y="2.5" width="13" height="9" /><path d="M5.5 14h5M8 11.5V14" />
      <path d="M6.5 5l3 2-3 2V5z" fill="currentColor" stroke="none" />
    </g>
  ),
  cap: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round">
      <path d="M8 2.5L15 6 8 9.5 1 6l7-3.5z" /><path d="M4 7.5V11c0 1 1.8 2 4 2s4-1 4-2V7.5" /><path d="M15 6v3.5" />
    </g>
  ),
  certificate: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round">
      <rect x="2" y="2" width="12" height="9" /><path d="M4.5 5h7M4.5 7.5h4" />
      <circle cx="8" cy="12" r="2" /><path d="M6.7 13.4L6 16l2-1 2 1-.7-2.6" strokeLinecap="round" />
    </g>
  ),
  award: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round">
      <circle cx="8" cy="6" r="4" /><path d="M5.5 9.2L4.5 15l3.5-2 3.5 2-1-5.8" strokeLinecap="round" />
    </g>
  ),
  calendar: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinejoin="round">
      <rect x="2" y="3" width="12" height="11" /><path d="M2 6h12M5 1.5v3M11 1.5v3" strokeLinecap="round" />
    </g>
  ),
  sparkle: (
    <path d="M8 1.5l1.4 4.1 4.1 1.4-4.1 1.4L8 12.5l-1.4-4.1L2.5 7l4.1-1.4L8 1.5z" stroke="currentColor" strokeWidth="1.3" fill="none" strokeLinejoin="round" />
  ),
  checkCircle: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="8" cy="8" r="6.2" /><path d="M5.3 8.2l2 2 3.4-4" />
    </g>
  ),
  rotate: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round">
      <path d="M13 4.5A6 6 0 1 0 14 8" /><path d="M13 1.5V5H9.5" />
    </g>
  ),
  globe: (
    <g stroke="currentColor" strokeWidth="1.5" fill="none">
      <circle cx="8" cy="8" r="6" /><path d="M2 8h12M8 2c1.8 1.6 2.8 3.8 2.8 6S9.8 14.4 8 16M8 2C6.2 3.6 5.2 5.8 5.2 8S6.2 14.4 8 16" />
    </g>
  ),
  refresh: (
    <path d="M13.65 4.75A6 6 0 1 0 14 8h-1.5a4.5 4.5 0 1 1-.3-1.65L10.5 8h4.5V3.5z" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />
  ),
  gridDots: (
    <g fill="currentColor">
      <circle cx="4" cy="4" r="1.2" /><circle cx="8" cy="4" r="1.2" /><circle cx="12" cy="4" r="1.2" />
      <circle cx="4" cy="8" r="1.2" /><circle cx="8" cy="8" r="1.2" /><circle cx="12" cy="8" r="1.2" />
    </g>
  ),
};

function Icon({ name, size = 16, ...rest }) {
  return (
    <svg width={size} height={size} viewBox="0 0 16 16" {...rest} aria-hidden="true">
      {ICON_PATHS[name] || null}
    </svg>
  );
}

Object.assign(window, { Icon, ICON_PATHS });
