/* hermon-icons.jsx — icon set, avatar generator, shared data */

const S = (p) => ({ width: 24, height: 24, viewBox: "0 0 24 24", fill: "none",
  stroke: "currentColor", strokeWidth: 1.9, strokeLinecap: "round", strokeLinejoin: "round", ...p });

const Icon = {
  arrow:    (p)=> <svg {...S(p)}><path d="M5 12h14M13 6l6 6-6 6"/></svg>,
  arrowUR:  (p)=> <svg {...S(p)}><path d="M7 17 17 7M8 7h9v9"/></svg>,
  check:    (p)=> <svg {...S(p)}><path d="M20 6 9 17l-5-5"/></svg>,
  checkCircle:(p)=> <svg {...S(p)}><circle cx="12" cy="12" r="9"/><path d="M8.5 12.5l2.5 2.5 4.5-5"/></svg>,
  lock:     (p)=> <svg {...S({strokeWidth:2,...p})}><rect x="5" y="11" width="14" height="9" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg>,
  plus:     (p)=> <svg {...S(p)}><path d="M12 5v14M5 12h14"/></svg>,
  zap:      (p)=> <svg {...S(p)}><path d="M13 2 4 14h7l-1 8 9-12h-7l1-8z"/></svg>,
  sync:     (p)=> <svg {...S(p)}><path d="M3 12a9 9 0 0 1 15-6.7L21 8M21 3v5h-5M21 12a9 9 0 0 1-15 6.7L3 16M3 21v-5h5"/></svg>,
  bell:     (p)=> <svg {...S(p)}><path d="M18 8a6 6 0 1 0-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.7 21a2 2 0 0 1-3.4 0"/></svg>,
  trophy:   (p)=> <svg {...S(p)}><path d="M7 4h10v5a5 5 0 0 1-10 0V4zM7 6H4v1a3 3 0 0 0 3 3M17 6h3v1a3 3 0 0 1-3 3M9 18h6M10 18l.5-3.5h3L14 18M8 21h8"/></svg>,
  bars:     (p)=> <svg {...S(p)}><path d="M4 20V10M10 20V4M16 20v-7M22 20H2"/></svg>,
  dollar:   (p)=> <svg {...S(p)}><path d="M12 2v20M17 6.5C17 4.6 14.8 4 12 4S7 4.8 7 7s2.2 3 5 3.5 5 1.3 5 3.5-2.2 3-5 3-5-.7-5-2.5"/></svg>,
  users:    (p)=> <svg {...S(p)}><circle cx="9" cy="8" r="3.2"/><path d="M3 20a6 6 0 0 1 12 0M16 5.5a3 3 0 0 1 0 5.6M21 20a5.4 5.4 0 0 0-4-5.2"/></svg>,
  calendar: (p)=> <svg {...S(p)}><rect x="3" y="5" width="18" height="16" rx="2.5"/><path d="M3 9h18M8 3v4M16 3v4"/></svg>,
  contract: (p)=> <svg {...S(p)}><path d="M6 2h8l4 4v14a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1z"/><path d="M14 2v5h4M8.5 14l2 2 4-4.5"/></svg>,
  card:     (p)=> <svg {...S(p)}><rect x="2.5" y="5" width="19" height="14" rx="2.5"/><path d="M2.5 10h19M6 15h4"/></svg>,
  target:   (p)=> <svg {...S(p)}><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.2" fill="currentColor"/></svg>,
  flag:     (p)=> <svg {...S(p)}><path d="M5 21V4M5 4h11l-2 4 2 4H5"/></svg>,
  alert:    (p)=> <svg {...S(p)}><path d="M12 9v4M12 17h.01M10.3 3.9 2.4 18a2 2 0 0 0 1.7 3h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z"/></svg>,
  ghost:    (p)=> <svg {...S(p)}><path d="M9 9h.01M15 9h.01M5 21V9a7 7 0 0 1 14 0v12l-2.5-2-2.5 2-2.5-2L9 21l-2-2-2 2z"/></svg>,
  split:    (p)=> <svg {...S(p)}><path d="M6 3v6a3 3 0 0 0 3 3h6a3 3 0 0 1 3 3v6M18 3v3M6 21v-3"/><circle cx="6" cy="18" r="0"/></svg>,
  unplug:   (p)=> <svg {...S(p)}><path d="M19 5 15 9M9 15l-4 4M14 4l6 6-3 3-6-6 3-3zM10 14 4 8l3-3 6 6-3 3z"/></svg>,
  link:     (p)=> <svg {...S(p)}><path d="M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1"/></svg>,
  sparkle:  (p)=> <svg {...S(p)}><path d="M12 3v4M12 17v4M3 12h4M17 12h4M6 6l2 2M16 16l2 2M18 6l-2 2M8 16l-2 2"/></svg>,
  search:   (p)=> <svg {...S(p)}><circle cx="11" cy="11" r="7"/><path d="m21 21-4-4"/></svg>,
  filter:   (p)=> <svg {...S(p)}><path d="M3 5h18l-7 8v6l-4-2v-4L3 5z"/></svg>,
  play:     (p)=> <svg {...S({fill:"currentColor",stroke:"none",...p})}><path d="M7 5v14l12-7z"/></svg>,
  grid:     (p)=> <svg {...S(p)}><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg>,
  layers:   (p)=> <svg {...S(p)}><path d="m12 3 9 5-9 5-9-5 9-5zM3 14l9 5 9-5M3 11l9 5 9-5"/></svg>,
  message:  (p)=> <svg {...S(p)}><path d="M21 12a8 8 0 0 1-11.4 7.2L3 21l1.8-6.6A8 8 0 1 1 21 12z"/></svg>,
  clock:    (p)=> <svg {...S(p)}><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>,
  up:       (p)=> <svg {...S({strokeWidth:2.4,...p})}><path d="M6 14l6-6 6 6"/></svg>,
  down:     (p)=> <svg {...S({strokeWidth:2.4,...p})}><path d="M6 10l6 6 6-6"/></svg>,
  trendUp:  (p)=> <svg {...S(p)}><path d="M3 17 9 11l4 4 8-8M16 7h5v5"/></svg>,
  shield:   (p)=> <svg {...S(p)}><path d="M12 3 5 6v5c0 4.5 3 8 7 10 4-2 7-5.5 7-10V6l-7-3z"/><path d="m9 12 2 2 4-4"/></svg>,
  percent:  (p)=> <svg {...S(p)}><path d="M19 5 5 19M8.5 8.5a2 2 0 1 1-3 0 2 2 0 0 1 3 0zM18.5 15.5a2 2 0 1 1-3 0 2 2 0 0 1 3 0z"/></svg>,
  phone:    (p)=> <svg {...S(p)}><rect x="7" y="2" width="10" height="20" rx="2.5"/><path d="M11 19h2"/></svg>,
  pen:      (p)=> <svg {...S(p)}><path d="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"/></svg>,
  x:        (p)=> <svg {...S(p)}><path d="M18 6 6 18M6 6l12 12"/></svg>,
  twitter:  (p)=> <svg {...S({strokeWidth:0,fill:"currentColor",...p})}><path d="M17 3h3l-7 8 8 10h-6l-5-6-5 6H2l7-9L2 3h6l4 5 5-5z"/></svg>,
  linkedin: (p)=> <svg {...S({strokeWidth:0,fill:"currentColor",...p})}><path d="M4 4a2 2 0 1 1 0 4 2 2 0 0 1 0-4zM3 9h2v11H3V9zM8 9h2v1.6c.5-.9 1.6-1.8 3.3-1.8 2.6 0 3.7 1.7 3.7 4.4V20h-2v-5.4c0-1.6-.6-2.6-2-2.6s-2.3 1-2.3 2.6V20H8V9z"/></svg>,
  youtube:  (p)=> <svg {...S({strokeWidth:0,fill:"currentColor",...p})}><path d="M22 8.2a3 3 0 0 0-2-2C18 5.7 12 5.7 12 5.7s-6 0-8 .5a3 3 0 0 0-2 2C1.5 10 1.5 12 1.5 12s0 2 .5 3.8a3 3 0 0 0 2 2c2 .5 8 .5 8 .5s6 0 8-.5a3 3 0 0 0 2-2c.5-1.8.5-3.8.5-3.8s0-2-.5-3.8zM10 15V9l5 3-5 3z"/></svg>,
  gear:     (p)=> <svg {...S(p)}><circle cx="12" cy="12" r="3.2"/><path d="M19.4 13.5a1.6 1.6 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-2.7 1.1v.2a2 2 0 1 1-4 0v-.1a1.6 1.6 0 0 0-2.7-1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.6 1.6 0 0 0-1.1-2.7H1.6a2 2 0 1 1 0-4h.1A1.6 1.6 0 0 0 3 5.6l-.1-.1A2 2 0 1 1 5.7 2.7l.1.1a1.6 1.6 0 0 0 1.8.3H7.7a1.6 1.6 0 0 0 1-1.5v-.2a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 2.7 1.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.8v.1a1.6 1.6 0 0 0 1.5 1h.2a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.4 1z"/></svg>,
  chevDown: (p)=> <svg {...S({strokeWidth:2.2,...p})}><path d="M6 9l6 6 6-6"/></svg>,
  chevR:    (p)=> <svg {...S({strokeWidth:2.2,...p})}><path d="M9 6l6 6-6 6"/></svg>,
  chevUpDown:(p)=> <svg {...S({strokeWidth:2,...p})}><path d="M8 9l4-4 4 4M8 15l4 4 4-4"/></svg>,
  angleL:   (p)=> <svg {...S({strokeWidth:2.2,...p})}><path d="M15 6l-6 6 6 6"/></svg>,
  angleR:   (p)=> <svg {...S({strokeWidth:2.2,...p})}><path d="M9 6l6 6-6 6"/></svg>,
  dangleL:  (p)=> <svg {...S({strokeWidth:2.2,...p})}><path d="M18 6l-6 6 6 6M11 6l-6 6 6 6"/></svg>,
  dangleR:  (p)=> <svg {...S({strokeWidth:2.2,...p})}><path d="M6 6l6 6-6 6M13 6l6 6-6 6"/></svg>,
  panelLeft:(p)=> <svg {...S(p)}><rect x="3" y="4" width="18" height="16" rx="2.5"/><path d="M9 4v16"/></svg>,
  external: (p)=> <svg {...S({strokeWidth:2,...p})}><path d="M14 4h6v6M20 4l-8 8M18 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h5"/></svg>,
  video:    (p)=> <svg {...S(p)}><rect x="2.5" y="6" width="13" height="12" rx="2.5"/><path d="M15.5 10l6-3v10l-6-3z"/></svg>,
  star:     (p)=> <svg {...S(p)}><path d="M12 3l2.6 5.3 5.9.9-4.2 4.1 1 5.8L12 16.9 6.7 19.2l1-5.8L3.5 9.2l5.9-.9L12 3z"/></svg>,
  eye:      (p)=> <svg {...S(p)}><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/></svg>,
  columns:  (p)=> <svg {...S(p)}><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 4v16M15 4v16"/></svg>,
  bookmark: (p)=> <svg {...S(p)}><path d="M6 3h12a1 1 0 0 1 1 1v17l-7-4-7 4V4a1 1 0 0 1 1-1z"/></svg>,
  flame:    (p)=> <svg {...S(p)}><path d="M12 3c.5 3-2 4.5-2 7a2 2 0 0 0 4 0c0-.6-.2-1.1-.4-1.6 2 1 3.4 3.1 3.4 5.6a5 5 0 0 1-10 0c0-3.6 2.8-5.6 5-11z"/></svg>,
  phoneCall:(p)=> <svg {...S(p)}><path d="M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L20 13l-1 4a2 2 0 0 1-2 1.5A15 15 0 0 1 3.5 6 2 2 0 0 1 5 4z"/></svg>,
  code:     (p)=> <svg {...S(p)}><path d="M8 7l-5 5 5 5M16 7l5 5-5 5"/></svg>,
  webhook:  (p)=> <svg {...S(p)}><path d="M9 7a3 3 0 1 1 4.5 2.6l2.2 4M15 18a3 3 0 1 1-.6-1.8L17 12M6 13a3 3 0 1 0 3 3h5"/></svg>,
};

/* deterministic hue from string */
function hueFor(name){ let h=0; for(let i=0;i<name.length;i++) h=(h*31+name.charCodeAt(i))%360; return h; }
function initials(name){ const p=name.trim().split(/\s+/); return ((p[0]?.[0]||"")+(p[1]?.[0]||"")).toUpperCase(); }

/* SVG initials avatar -> data URI (premium gradient circle) */
function avatarURI(name, hue){
  const h = hue ?? hueFor(name);
  const c1 = `hsl(${h} 62% 58%)`, c2 = `hsl(${(h+34)%360} 64% 46%)`;
  const txt = initials(name);
  const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='96' height='96'>
    <defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'>
    <stop offset='0' stop-color='${c1}'/><stop offset='1' stop-color='${c2}'/></linearGradient></defs>
    <rect width='96' height='96' rx='48' fill='url(#g)'/>
    <text x='50%' y='52%' dy='.36em' text-anchor='middle' font-family='Plus Jakarta Sans, sans-serif'
      font-size='38' font-weight='700' fill='white' fill-opacity='.95'>${txt}</text></svg>`;
  return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
}
function Avatar({ name, hue, className }) {
  return <img className={className} src={avatarURI(name, hue)} alt={name} />;
}

/* ---------------- shared data ---------------- */
const PEOPLE = [
  { name: "Jordan Reyes",  role: "Senior Closer",  hue: 262 },
  { name: "Mia Castellano", role: "Closer",        hue: 330 },
  { name: "Devin Wright",  role: "Closer",         hue: 155 },
  { name: "Priya Anand",   role: "Setter → Closer",hue: 28  },
  { name: "Marcus Bell",   role: "Closer",         hue: 205 },
  { name: "Sofia Lindqvist", role: "Closer",       hue: 290 },
];

const INTEGRATIONS = [
  { name: "Calendly",     cat: "Scheduling",     mono: "Cal", color: "#0A6CFF", sync: true },
  { name: "Stripe",       cat: "Payments",       mono: "S",   color: "#635BFF", sync: true },
  { name: "Mollie",       cat: "Payments",       mono: "M",   color: "#1A1A1A", sync: true },
  { name: "Whop",         cat: "Checkout",       mono: "W", color: "#FF6231", sync: true },
  { name: "eSignatures",  cat: "Contracts",      icon: "pen", color: "#1F9D6B", sync: true },
  { name: "Meta Ads",     cat: "Lead source",    mono: "Ad",  color: "#0A77F2", sync: true },
  { name: "Fathom",       cat: "Call recordings",icon: "video", color: "#2A6FDB", sync: true },
  { name: "Slack",        cat: "Notifications",  icon: "message", color: "#4A154B", sync: true },
];

const WEBHOOK_EVENTS = [
  "lead.created", "appointment.booked", "appointment.no_show",
  "contract.sent", "contract.signed", "payment.succeeded",
  "payment.failed", "deal.closed", "outcome.logged",
];

const BRANDS = [
  { nm: "CashSwipe",            c: "#6D4AE6", g: "CS", cat: "Coaching" },
  { nm: "Wealth Kings",         c: "#1F9D6B", g: "WK", cat: "Coaching" },
  { nm: "Millionaire Commerce", c: "#D6457E", g: "MC", cat: "Course creator" },
  { nm: "Rocket Leads",         c: "#3B73D6", g: "RL", cat: "Agency" },
  { nm: "ZTH Capital",          c: "#C98A1E", g: "ZC", cat: "Consulting" },
  { nm: "Founder Download",     c: "#7C5CFF", g: "FD", cat: "Coaching" },
  { nm: "Faceless Education",   c: "#2F9E72", g: "FE", cat: "Agency" },
  { nm: "The Bitcoin Family",   c: "#C2417E", g: "BF", cat: "Consulting" },
];

Object.assign(window, { Icon, Avatar, avatarURI, hueFor, initials, PEOPLE, INTEGRATIONS, WEBHOOK_EVENTS, BRANDS });
