// Live wins from the #wins Slack channel — rendered as Slack-style cards
// (instead of PNG screenshots) so the list scales without bundle bloat.
//
// Source: pulled from the Master Filmmaker Slack #wins channel on 2026-04-30.
// Filtered to closed deals, signed retainers, milestones, and meaningful
// pipeline updates. Conversational replies and emoji-only cheers excluded.

// userId → local avatar filename. Users without entries fall back to the
// colored-initials avatar (Mason Mantha, Shane Ruprecht, Andrew Breunig,
// Beau Pinto — these accounts don't expose a profile photo to the team
// directory search).
const SLACK_AVATARS = {
  U07JJD7QE87: 'U07JJD7QE87.png',  // Gage Gifford
  U09FAS96A0P: 'U09FAS96A0P.jpg',  // Julian Moran
  U0AC3S9BVTJ: 'U0AC3S9BVTJ.png',  // Josh Soledad
  U05E455TB2L: 'U05E455TB2L.png',  // Brandon Link
  U0A8X93S24V: 'U0A8X93S24V.jpg',  // Ryan Maloney
  U0572R9JCJD: 'U0572R9JCJD.png',  // Evan Andrews
  U0A71BCD05U: 'U0A71BCD05U.jpg',  // Maxwell Purrington
  U08UKPUJ4CR: 'U08UKPUJ4CR.jpg',  // Mace Sorensen
  U08GRHJK708: 'U08GRHJK708.jpg',  // Tony Gnau (gravatar)
  U0AK065D5G9: 'U0AK065D5G9.jpg',  // Max Fillmore
  U090Q6F41RS: 'U090Q6F41RS.jpg',  // Sebastian Cristancho
  U0ABH7M3HNH: 'U0ABH7M3HNH.jpg',  // Steven Barrientes
  U0AJFLG6109: 'U0AJFLG6109.jpg',  // Tristan Blais-Noël
  U0A77LNB6SF: 'U0A77LNB6SF.jpg',  // Mike Matthews
  U09S5B322HL: 'U09S5B322HL.png',  // Dante Pascarella
  U0AB5BBQA49: 'U0AB5BBQA49.jpg',  // Jacob Tucker
  U08G5NWTSGJ: 'U08G5NWTSGJ.jpg',  // Andy Perrott
  U09EX9F0B8V: 'U09EX9F0B8V.png',  // Mitch Parker
  U09KQ9CU9MG: 'U09KQ9CU9MG.png',  // Cameron Weber
  U09PCD51HJ8: 'U09PCD51HJ8.jpg',  // Ethan Fung
  U09MZ2539SM: 'U09MZ2539SM.png',  // Myles Bunker
  U09Q64KBPMF: 'U09Q64KBPMF.png',  // Nate Glass
  U089HTLKGBF: 'U089HTLKGBF.png',  // Frank Smoot Worthington IV
  U08NGEDDB5X: 'U08NGEDDB5X.png',  // Justin Bond
  U0A88JA1NQY: 'U0A88JA1NQY.png',  // Dario Nanni
  U080YUC65BR: 'U080YUC65BR.jpg',  // John Godwin
  U0A8CH6GM1B: 'U0A8CH6GM1B.jpg',  // Sebastian
  U06CPV2QBB4: 'U06CPV2QBB4.jpg',  // Brandon Raubenstine
  U0AN97UHM45: 'U0AN97UHM45.png',  // Tyler Graham
  U0ASGPD9AG0: 'U0ASGPD9AG0.png',  // Jonathan Galbraith
  U0B0K1F9HCH: 'U0B0K1F9HCH.png',  // Stephen Demmert
};

function SlackChatWins() {
  // Avatar color picked deterministically from the name so the same person
  // always gets the same color across cards — feels like a real channel.
  const avatarColors = [
    '#3F2A4A', '#1A4A3F', '#4A1F2A', '#2A4A6E', '#6E4A2A',
    '#4A4A6E', '#6E2A4A', '#2A6E4A', '#4A2A6E', '#6E6E2A',
  ];
  const colorFor = (name) => {
    let h = 0;
    for (let i = 0; i < name.length; i++) h = (h * 31 + name.charCodeAt(i)) | 0;
    return avatarColors[Math.abs(h) % avatarColors.length];
  };
  const initials = (name) => name.split(/\s+/).map(s => s[0]).slice(0, 2).join('').toUpperCase();
  // 8:42 PM style
  const fmtTime = (iso) => {
    const d = new Date(iso);
    let h = d.getHours();
    const m = d.getMinutes().toString().padStart(2, '0');
    const ap = h >= 12 ? 'PM' : 'AM';
    h = h % 12 || 12;
    return `${h}:${m} ${ap}`;
  };
  // Apr 24 style; "Today" if same day
  const fmtDate = (iso) => {
    const d = new Date(iso);
    const today = new Date();
    if (d.toDateString() === today.toDateString()) return 'Today';
    return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
  };

  // ─────────────────────────────────────────────────────────────────────────
  // The wins. Order = newest first (matches how Slack displays a channel
  // top-to-bottom with newest at the bottom — but we present newest first
  // because the masonry has no natural reading order anyway).
  // ─────────────────────────────────────────────────────────────────────────
  const wins = [
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',        ts: '2026-05-26T16:02:27-04:00', text: '24k deal signed today! 12k upfront 🔥', reactions: [['🔥', 4]] },
    { uid: 'U093Z3U81B8', name: 'Sarah Peacock',       ts: '2026-05-26T13:58:32-04:00', text: '$6K deal closed today on a flagship case study for a pediatrician on personal brand.', reactions: [['🔥', 5]] },
    { uid: 'U0B0K1F9HCH', name: 'Stephen Demmert',     ts: '2026-05-15T22:37:15-04:00', text: '3 month 10K contract signed with a landscape architect! 2 for 2 on reactivation strategy clients so far!', reactions: [['🔥', 4], ['❤️‍🔥', 2]] },
    { uid: 'U09S5B322HL', name: 'Dante Pascarella',    ts: '2026-05-15T10:55:46-04:00', text: '6 month 27k contract signed and paid! Organic content for a Roofing company', reactions: [['🔥', 7]] },
    { uid: 'U0AP6AH1WQL', name: 'Cristina Glassman',   ts: '2026-05-12T09:54:14-04:00', text: 'Just booked our first call with an incredible lead! Let’s go!', reactions: [['🔥', 2], ['❤️', 2]] },
    { uid: 'U0A8X93S24V', name: 'Ryan Maloney',        ts: '2026-05-11T14:33:14-04:00', text: '$8k 3 month closed — back pain doctor (mentioned before I was trying to close). Got a different, dormant client to respond and confirm they are still interested by using the "where do we go from here?" text. Credit Eric Deeran.', reactions: [['🔥', 9], ['💪', 1]] },
    { uid: 'U0572R9JCJD', name: 'Evan Andrews',        ts: '2026-05-07T18:27:23-04:00', text: 'Closed a little 15k 4 month just now', reactions: [['🔥', 5], ['💪', 2]] },
    { uid: 'U05E455TB2L', name: 'Brandon Link',        ts: '2026-05-06T17:32:42-04:00', text: '12 Month 24k with a local roofer. 5k Cash Collected.\n\nCouple more hot follow ups on the calendar. Upping prices moving forward ✅\n\nOh and moved into our office studio last Friday!', reactions: [['🔥', 3]] },
    { uid: 'U0A71BCD05U', name: 'Maxwell Purrington', ts: '2026-05-06T17:27:29-04:00', text: 'The spots from my free case study group are now officially full! We’re locking in with some coaches and I’m super excited to get some case study testimonials', reactions: [['🔥', 1]] },
    { uid: 'U0B0K1F9HCH', name: 'Stephen Demmert',     ts: '2026-05-06T14:13:45-04:00', text: 'Just signed my first retainer client to a 3 month $7,500 contract! This was part of a reactivation strategy from a roofing company I had talked to a year ago! Potential for a 12 month contract and me taking over their social media strategies after the first 2 months', reactions: [['❤️', 4], ['🔥', 4]] },
    { uid: 'U0ASGPD9AG0', name: 'Jonathan Galbraith',  ts: '2026-05-05T17:04:05-04:00', text: 'Boom 💥 — pretty good day today.\n\nClosed a $46.5K deal and a $12.5K deal, both from reactivations of old clients from pre-Covid days. Both are one-off projects, but they are both pretty interested in packages going forward. 🕺', reactions: [['🔥', 6], ['💪', 3], ['💰', 2]] },
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',        ts: '2026-05-04T18:01:28-04:00', text: 'Closed a 30k — 12 month package. Less work for less money. 7.5k down 🔥', reactions: [['🔥', 4], ['💰', 2]] },
    { uid: 'U09S5B322HL', name: 'Dante Pascarella',    ts: '2026-05-04T15:52:22-04:00', text: 'Closed a 12-month, $24k deal! Organic content only. About damn time 😂', reactions: [['🔥', 3], ['👏', 2]] },
    { uid: 'U0AN97UHM45', name: 'Tyler Graham',        ts: '2026-05-02T11:17:58-04:00', text: 'Last week closed 12 month 60k deal with Construction Company!', reactions: [['🔥', 4], ['❤️‍🔥', 2]] },
    { uid: 'U06CPV2QBB4', name: 'Brandon Raubenstine', ts: '2026-05-01T17:33:06-04:00', text: '8k for 6 months closed for a short-term property rental management company!', reactions: [['🔥', 1], ['❤️‍🔥', 1]] },
    { uid: 'U09FAS96A0P', name: 'Julian Moran',     ts: '2026-04-30T09:19:36-04:00', text: '$7k for 3 month closed! The agreement has been signed (he had some minor notes we needed to address). Custom Lighting studio that does installations for hotels, corporate offices and major restaurants with 1x shoot and ads. Onboarding call tomorrow!', reactions: [['🔥', 6], ['🤝', 2]] },
    { uid: 'U0AC3S9BVTJ', name: 'Josh Soledad',     ts: '2026-04-29T14:50:02-04:00', text: 'Just closed a 3-month, $12K deal with an ecom brand. Content only', reactions: [['🔥', 5], ['💯', 2]] },
    { uid: 'U05E455TB2L', name: 'Brandon Link',     ts: '2026-04-29T09:11:57-04:00', text: '4 qualified self-booked appointments in the last 8 hours', reactions: [['🚀', 4]] },
    { uid: 'U0572R9JCJD', name: 'Evan Andrews',     ts: '2026-04-27T15:29:36-04:00', text: 'So after a whirlwind first week with a new client, I refunded them this morning, BUT closed a love it or leave it with another school today. So yeah..', reactions: [['💪', 3]] },
    { uid: 'U09FAS96A0P', name: 'Julian Moran',     ts: '2026-04-27T12:39:29-04:00', text: 'This week I have:\n\n4 Discovery Calls\n3 sales calls\n+ Onboarding a new client.\n\nI also have about 17 leads I am chasing down as well.\n\nFunnily enough, I actually ran into one of my leads on the street ahead of our sales call which was a pretty sweet coincidence and he said he’s looking to move forward. Gonna try to close on the phone tomorrow!', reactions: [['🔥', 4]] },
    { uid: 'U0A71BCD05U', name: 'Maxwell Purrington', ts: '2026-04-24T18:30:57-04:00', text: 'Super small win but closed a trial client on a 15 reel love it or leave it', reactions: [['🎉', 3]] },
    { uid: 'U09FAS96A0P', name: 'Julian Moran',     ts: '2026-04-24T15:50:38-04:00', text: '10k for 3 month closed, signed and paid! Custom Furniture Business who also owns an Architecture and Interior Design business so if I deliver for the furniture business, could potentially be 2 clients!', reactions: [['🔥', 7], ['💰', 3]] },
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',     ts: '2026-04-22T21:01:28-04:00', text: '42k for 12 months signed with 10.5k cash collected upfront 🔥💪🏼 last call of the day clutch', reactions: [['🔥', 9], ['💪🏼', 4]] },
    { uid: 'U08UKPUJ4CR', name: 'Mace Sorensen',    ts: '2026-04-22T14:40:35-04:00', text: 'Just signed another 6 month retainer client today at $12k! Total monthly revenue now at $45,250!', reactions: [['🔥', 8], ['🚀', 3]] },
    { uid: 'U0572R9JCJD', name: 'Evan Andrews',     ts: '2026-04-21T22:47:16-04:00', text: '6k for 4 months closed today. 9 ad videos in total and campaign implementation. Not huge but this small Jewish day school didn’t even have a FB page.', reactions: [['🔥', 4]] },
    { uid: 'U08GRHJK708', name: 'Tony Gnau',        ts: '2026-04-20T17:27:14-04:00', text: 'Two strategy evaluations booked for this week after a short drought.', reactions: [['💪', 2]] },
    { uid: 'U05E455TB2L', name: 'Brandon Link',     ts: '2026-04-20T16:48:20-04:00', text: '15k deal closed, 5k cash collected — local roofer.\n\nThey came as a referral this time last year and they said my price was too high. They said they got burned twice since then and have been seeing my ads. I got a text from them saying they’re ready. Had a zoom call to collect payment and set call for onboarding.', reactions: [['🔥', 6], ['🙌', 2]] },
    { uid: 'U0A8X93S24V', name: 'Ryan Maloney',     ts: '2026-04-18T11:10:00-04:00', text: 'Very close to closing an $8k 3-month starter package. Throwing in $1k of ad spend. (Anything to get early clients under the belt). She ended the call with "let’s do this baby!"', reactions: [['🤝', 3]] },
    { uid: 'U0AK065D5G9', name: 'Max Fillmore',     ts: '2026-04-16T13:58:36-04:00', text: 'Just closed a 12 month 40k deal with a dentist out of Michigan 🙌🏻', reactions: [['🔥', 11], ['💰', 4]] },
    { uid: 'U0AK065D5G9', name: 'Max Fillmore',     ts: '2026-04-15T19:12:37-04:00', text: 'Just closed a 39k 12 month deal with a dentist down in Nashville who works with Luke Combs, Chris Stapleton, Ella Langley and Nate Bargatze and a lot of other big country artists 🔥 gonna be a crazy status client for us. Huge get.', reactions: [['🔥', 14], ['🤯', 5]] },
    { uid: 'U090Q6F41RS', name: 'Sebastian Cristancho', ts: '2026-04-15T13:03:56-04:00', text: 'Just had such an epic discovery call with a quality medical practice looking for leads and booked a strategy session for Friday!', reactions: [['🔥', 4]] },
    { uid: 'U0A8X93S24V', name: 'Ryan Maloney',     ts: '2026-04-13T20:06:34-04:00', text: 'Small win: booked a call w/ a doctor who submitted a form at night. I was calling during the day, couldn’t get any response. Eric pointed out the obvious to call at night and it worked.', reactions: [['💡', 5]] },
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',     ts: '2026-04-10T10:08:33-04:00', text: 'Just closed a 12 month / 40k deal with 10k upfront 🔥', reactions: [['🔥', 12], ['💰', 4]] },
    { uid: 'U0AK065D5G9', name: 'Max Fillmore',     ts: '2026-04-09T15:28:09-04:00', text: 'We just closed a 46k 12 month, 11.5k down payment!!', reactions: [['🔥', 10], ['🚀', 3]] },
    { uid: 'U0ABH7M3HNH', name: 'Steven Barrientes', ts: '2026-04-08T22:17:22-04:00', text: 'I closed my first two sales in the same day! One at 3k/month for 3 months and another for 2k/month for 3 months!\nBoth have never done advertising before, so they felt more comfortable just testing the waters first. So in total, 15k!!\nAnd I’m sure I may have another on the way for a 4k/month for 6 months here soon! $24k here I come! 💪🔥', reactions: [['🔥', 8], ['🎉', 4]] },
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',     ts: '2026-04-08T17:15:35-04:00', text: 'Month-to-month package closed at 1.5k/month (3k collected for the shoot fee).\n\n"I feel like god sent me an angel today thank you for taking me on as a client!"', reactions: [['❤️', 6], ['🙏', 3]] },
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',     ts: '2026-04-07T13:32:14-04:00', text: '12 month package / 35k closed today… 8.75k collected upfront. Super cool client that will be fun to work with!', reactions: [['🔥', 9]] },
    { uid: 'U0ABH7M3HNH', name: 'Steven Barrientes', ts: '2026-04-07T09:26:17-04:00', text: 'Today, I have the most meetings/calls I’ve ever stacked up in a single day! I have 6! 4 discovery calls and 2 that I’m meeting for the 2nd time to hopefully close! Both are high-ticket clients already making 2.5 million in their business looking to scale to 4 million with no prior marketing. Sales calls are becoming a breeze. Wish me luck!', reactions: [['💪', 5], ['🔥', 3]] },
    { uid: 'U0AJFLG6109', name: 'Tristan Blais-Noel', ts: '2026-04-06T16:30:20-04:00', text: 'Hey guys, been a while since I’ve been on here! So first up, I finished recording my ads and VSL this weekend and getting on editing. In the meantime, I’ve closed another 19K$ in deals. In total, I’m up 57K$ since coming into the program 6 weeks ago 🚀', reactions: [['🚀', 8], ['🔥', 3]] },
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',     ts: '2026-04-03T17:53:55-04:00', text: 'We’ve officially collected over 100k in less than a week 🔥', reactions: [['🔥', 18], ['💰', 7], ['🤯', 3]] },
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',     ts: '2026-04-03T17:50:33-04:00', text: 'Hopped on a sales call this morning with a prospect! He invited his wife in on the call because she owns her own practice… ended up closing them both for a 60k contract (15k collected) 🔥', reactions: [['🔥', 12], ['🤯', 4]] },
    { uid: 'U0ABH7M3HNH', name: 'Steven Barrientes', ts: '2026-04-03T09:54:54-04:00', text: 'Hey guys quick little update, this is crazy!! I’ve never had so many qualified leads and meetings in the entire life of my business ever! I’ve had what feels like numerous discovery calls one of which was with a HVAC business that makes 4 million a year and basically has ZERO content marketing strategy! First meeting with them went very smooth — he’s super interested.', reactions: [['🔥', 5]] },
    { uid: 'U07JJD7QE87', name: 'Gage Gifford',     ts: '2026-04-02T13:32:38-04:00', text: 'In the past week, I have heard on three separate occasions, different prospects saying… "within the past couple weeks I have seen your guys’s ads so aggressively that it made me wonder what you guys are all about."\n\nA few weeks ago was when we onboarded and got all the advice to change how we were running ads! Huge win for us 🙌🏼', reactions: [['🙌🏼', 7]] },
    { uid: 'U09FAS96A0P', name: 'Julian Moran',     ts: '2026-04-01T11:35:18-04:00', text: 'Turned the ads back on on Monday and so far got 3 leads and have two Discovery Calls booked for tomorrow!', reactions: [['🔥', 3]] },
    { uid: 'U0AK065D5G9', name: 'Max Fillmore',     ts: '2026-03-31T21:46:04-04:00', text: 'Just closed a $40,000 12-month PIF. First PIF we’ve ever done 🔥', reactions: [['🔥', 16], ['💰', 6]] },
    { uid: 'U0ABH7M3HNH', name: 'Steven Barrientes', ts: '2026-03-30T16:41:28-04:00', text: 'Just launched my first campaign ever and got my first self-booked call today within a few hours already! 🙌 Things are happening fast 😁', reactions: [['🚀', 6]] },
    { uid: 'U09PCD51HJ8', name: 'Ethan Fung',       ts: '2026-03-30T15:14:11-04:00', text: 'My client got their first sale through the ads system we set up! It’s a small sale but proof that the system works.\n\nI also was able to stand my ground against a client who was aggressive. I didn’t budge and he fell in line with our procedures when he didn’t want to pay.', reactions: [['💪', 5]] },
    { uid: 'U09S5B322HL', name: 'Dante Pascarella', ts: '2026-03-28T11:14:12-04:00', text: 'Booked 8 calls within the past couple days and 5 of them self booked!', reactions: [['🔥', 7]] },
    { uid: 'U08GRHJK708', name: 'Tony Gnau',        ts: '2026-03-25T16:28:54-04:00', text: 'Just got a qualified lead, but he didn’t book an appointment. Called him within an hour, got through, and got him booked for Friday. 👊🏼', reactions: [['💪🏼', 4]] },
    { uid: 'U0AD6FJGYSV', name: 'Mason Mantha',     ts: '2026-03-23T20:21:48-04:00', text: 'I just put up some new ad creatives on a lead form campaign and so far have about 11 new leads in the last few days.', reactions: [['🔥', 4]] },
    { uid: 'U0AJFLG6109', name: 'Tristan Blais-Noel', ts: '2026-03-19T12:03:19-04:00', text: 'Hey guys, quick update on my end, y’all already know some of the wins I’ve had recently. I just had another client closed today for a total of 38k$ in new sales since the joining the program! We’re making progress slowly but surely 🚀', reactions: [['🚀', 6]] },
    { uid: 'U0A77LNB6SF', name: 'Mike Matthews',    ts: '2026-03-18T15:24:50-04:00', text: 'Hey Filmmaker family! Our team just booked an educational video series package — $57K over the next five months.', reactions: [['🔥', 9], ['💰', 3]] },
    { uid: 'U09S5B322HL', name: 'Dante Pascarella', ts: '2026-03-18T09:52:05-04:00', text: 'Just booked my first legit discovery call from my ads. About time lol. Hopefully I can land this one 🙏🏼', reactions: [['🤞', 5]] },
    { uid: 'U0AJFLG6109', name: 'Tristan Blais-Noel', ts: '2026-03-17T14:34:47-04:00', text: 'Hey everyone, just signed a 25K$ agreement with one of my previous clients with my new proposal for construction companies, collecting a monthly payment of 2.5K$ per month until the end of the year!', reactions: [['🔥', 7], ['💰', 3]] },
    { uid: 'U0AD6FJGYSV', name: 'Mason Mantha',     ts: '2026-03-17T12:25:45-04:00', text: 'Just signed and collected payment for a $57k 6 month Contract! Collected the first Monthly invoice of $9500 + HST', reactions: [['🔥', 11], ['💰', 5]] },
    { uid: 'U0A71BCD05U', name: 'Maxwell Purrington', ts: '2026-03-16T17:00:27-04:00', text: 'Just closed my first deal — made $3,600 on split month-to-month payments', reactions: [['🎉', 8], ['🥂', 3]] },
    { uid: 'U0A8CH6GM1B', name: 'Sebastian',        ts: '2026-03-13T15:53:49-04:00', text: 'First call booked — second day of running ads! Let’s get it', reactions: [['🚀', 4]] },
    { uid: 'U0AB5BBQA49', name: 'Jacob Tucker',     ts: '2026-03-13T15:04:16-04:00', text: 'Had a video I made for my retainer client go viral. Over 200k views and doubled his follower count!', reactions: [['🔥', 8], ['🤯', 3]] },
    { uid: 'U0991SGAFQV', name: 'Shane Ruprecht',   ts: '2026-03-12T11:37:47-04:00', text: 'Closed my first deal — $6000 for 4 months. $1500 cash collected. Running Meta ads for a local Hearing Aid Clinic!!! 🚀', reactions: [['🚀', 9], ['🔥', 4]] },
    { uid: 'U0AK065D5G9', name: 'Max Fillmore',     ts: '2026-03-11T19:39:48-04:00', text: 'Made some ad tweaks and saw 8 scheduled sales calls at $14 per call just in the last day 🔥', reactions: [['🔥', 7]] },
    { uid: 'U08G5NWTSGJ', name: 'Andy Perrott',     ts: '2026-03-09T14:11:49-04:00', text: 'I landed my first client who came entirely through the ads process — booked a triage meeting, did a discovery meeting, then a 30 minute presentation was all it took. Closed 12 month for $36k.', reactions: [['🔥', 13], ['🙌', 4]] },
    { uid: 'U09EX9F0B8V', name: 'Mitch Parker',     ts: '2026-03-08T20:50:30-05:00', text: 'Small win, but good win! Was going on paternity leave so I dropped my spend to $1.50 per day. Just converted 6-7 leads from that spend over a 40 day period and closed an ads-only deal yesterday for $2,450 per month (month-to-month).\n\nShould be getting an answer tomorrow for a 6-month contract for my full package valued at $30K.', reactions: [['🔥', 4], ['💪', 2]] },
    { uid: 'U09KQ9CU9MG', name: 'Cameron Weber',    ts: '2026-03-06T17:01:28-05:00', text: 'Sold a Newsletter Agent today on a monthly retainer!', reactions: [['🎉', 5]] },
    { uid: 'U0AJFLG6109', name: 'Tristan Blais-Noel', ts: '2026-03-05T13:05:02-05:00', text: 'Contacted one of my past clients using the reactivation strategy and landed a 5k deal 🤝', reactions: [['🤝', 6]] },
    { uid: 'U0AD6FJGYSV', name: 'Mason Mantha',     ts: '2026-03-05T12:32:37-05:00', text: 'Construction Company wants to move forward on a 6 mo $57K Deal!!! Have a call next week to sign contract and collect payment. I don’t wanna screw this up but they seem very keen to sign. Just an FYI for everyone out there, I got this deal from cold calling companies.', reactions: [['🔥', 9], ['📞', 4]] },
    { uid: 'U08KEM61EHM', name: 'Andrew',           ts: '2026-03-04T11:06:34-05:00', text: 'Just closed a 12k deal — no video, just SEO/Google ranking. Definitely good start.', reactions: [['🔥', 4]] },
    { uid: 'U08G5NWTSGJ', name: 'Andy Perrott',     ts: '2026-03-03T20:35:03-05:00', text: 'Had a great in person meeting today with my hottest lead from ads. Eric was dead on in his advice on how to approach and it went very well. Have my follow up on Friday to close the deal but I think it’s already sold through the discovery process.', reactions: [['🤝', 5]] },
    { uid: 'U0AD6FJGYSV', name: 'Mason Mantha',     ts: '2026-03-03T14:30:59-05:00', text: 'Had a solid meeting with a big construction company and I think I may have closed a deal on a 10k per month, 6 mo contract. That’s about 120k for the year. If I can deliver, it would be a multi-year long-term partnership.', reactions: [['🔥', 11], ['💰', 4]] },
    { uid: 'U0A77LNB6SF', name: 'Mike Matthews',    ts: '2026-03-02T10:42:10-05:00', text: 'Good morning team. Starting Monday strong… one of our retainer projects didn’t materialize exactly the way we wanted, but the good news is we locked in 7 new video projects from March to October, representing about 57K in income.', reactions: [['🔥', 6]] },
    { uid: 'U09PCD51HJ8', name: 'Ethan Fung',       ts: '2026-02-27T15:45:56-05:00', text: 'Closed a 2k 2-month pilot with a mechanic shop! I even took the payment on the call 🙂', reactions: [['🎉', 5], ['💸', 2]] },
    { uid: 'U08GRHJK708', name: 'Tony Gnau',        ts: '2026-02-25T15:53:07-05:00', text: 'Just sold a 3 month, $15K retainer. He’s just dipping his toes in, but I think once he gets a taste… he’ll go in for longer.', reactions: [['🔥', 8], ['💰', 3]] },
    { uid: 'U0A8X93S24V', name: 'Ryan Maloney',     ts: '2026-02-24T11:57:07-05:00', text: 'Closed a $12k deal. Client is opening a new practice. Was going to turn her away but she didn’t baulk at my price range in the triage.', reactions: [['🔥', 6]] },
    { uid: 'U0A8X93S24V', name: 'Ryan Maloney',     ts: '2026-02-24T08:46:29-05:00', text: 'Closed my first deal (agreement pending). $5k, plastic surgeon with multiple medical businesses in the family. Had to reduce rate/deliverables since I don’t have proof yet. 2 discovery calls with new clients today/tomorrow. Aiming to get 1% better on every call because lord knows the first ones were sloppy 🙂', reactions: [['🎉', 7], ['💪', 3]] },
    { uid: 'U0AD6FJGYSV', name: 'Mason Mantha',     ts: '2026-02-23T09:14:16-05:00', text: 'Booked a discovery call after less than 24 hours of my ad being live!', reactions: [['🚀', 4]] },
    { uid: 'U09MZ2539SM', name: 'Myles Bunker',     ts: '2026-02-21T11:34:50-05:00', text: 'Closed another $180k in contracts today 🚀', reactions: [['🔥', 22], ['💰', 8], ['🚀', 5]] },
    { uid: 'U0AD6FJGYSV', name: 'Mason Mantha',     ts: '2026-02-20T15:35:47-05:00', text: 'Booked two discovery calls today (1 custom home builder, 1 home service business) off cold emails/DM from a few weeks ago. They both reached out this morning asking for social content and marketing services.', reactions: [['🔥', 4]] },
    { uid: 'U09Q64KBPMF', name: 'Nate Glass',       ts: '2026-02-12T18:19:52-05:00', text: '2026 is off to a killer start. $122k in payments, $89k outstanding in accounts receivable, and we just landed another job today that will finalize north of $75k.', reactions: [['🔥', 17], ['💰', 6]] },
    { uid: 'U08GRHJK708', name: 'Tony Gnau',        ts: '2026-02-11T15:09:24-05:00', text: 'Just closed my first retainer client from ads. BOOM! $28K for six months. I’ve been at this a while, and it’s finally paying off.', reactions: [['🔥', 13], ['🙌', 5]] },
    { uid: 'U08G5NWTSGJ', name: 'Andy Perrott',     ts: '2026-02-11T14:46:02-05:00', text: 'Booked a discovery call from only 5 days of ads running too.', reactions: [['🚀', 4]] },
    { uid: 'U09FAS96A0P', name: 'Julian Moran',     ts: '2026-02-09T16:31:07-05:00', text: 'Just called a lead who actually just happens to work in the same office as me! Just had my first in-person triage call!', reactions: [['🤝', 3]] },
    { uid: 'U08NGEDDB5X', name: 'Justin Bond',      ts: '2026-02-09T10:14:41-05:00', text: 'Just booked a disco call with new ads only running for 5 days!', reactions: [['🚀', 4]] },
    { uid: 'U08G5NWTSGJ', name: 'Andy Perrott',     ts: '2026-02-06T20:45:07-05:00', text: 'Two things. Working on a $48k 12 month contract and also launched ads — leads are coming in!', reactions: [['🔥', 5]] },
    { uid: 'U090Q6F41RS', name: 'Sebastian Cristancho', ts: '2026-02-06T17:03:17-05:00', text: 'Had a great discovery call with a super qualified medical practice lead! Follow-up call on Monday, super engaged on social media.', reactions: [['🔥', 3]] },
    { uid: 'U0A88JA1NQY', name: 'Dario Nanni',      ts: '2026-02-06T15:14:39-05:00', text: 'Just picked up my 6th Emmy award!! 🏆', reactions: [['🏆', 14], ['🤯', 6], ['👏', 4]] },
    { uid: 'U080YUC65BR', name: 'John Godwin',      ts: '2026-02-04T06:59:52-05:00', text: 'I landed a $9k deal from a referral yesterday!', reactions: [['🔥', 6]] },
    { uid: 'U09SVBA7YGL', name: 'Beau Pinto',       ts: '2026-02-02T08:37:25-05:00', text: 'Just got my first retainer client! Woot woot!!!', reactions: [['🎉', 9], ['🚀', 4]] },
  ];

  // Tag each win with categories so the SlackWins filter bar can include
  // chat cards in the same buckets the case studies use.
  const tagged = wins.map((w, i) => {
    const text = w.text.toLowerCase();
    // Pull dollar amount: matches $7k, $40,000, 12k, 180k, $122k etc.
    let amount = 0;
    const matches = text.match(/\$?(\d+(?:[\.,]\d+)?)\s*(k|K|m|M)?\b/g) || [];
    for (const m of matches) {
      const mm = m.match(/(\d+(?:[\.,]\d+)?)\s*(k|K|m|M)?/);
      if (!mm) continue;
      const n = parseFloat(mm[1].replace(/,/g, ''));
      const mult = mm[2] && /[Mm]/.test(mm[2]) ? 1000000 : (mm[2] && /[Kk]/.test(mm[2]) ? 1000 : (n < 1000 ? 1 : 1));
      const v = n * mult;
      if (v > amount) amount = v;
    }
    const cats = new Set();
    if (amount >= 20000) cats.add('big');
    if (/retainer|month\s*pkg|month\s*package|\/mo\b|\/month\b|monthly\s*retainer|recurring/.test(text)) cats.add('retainer');
    if (/first\s*(deal|sale|client|retainer|campaign|call|legit|in[-\s]person|self-booked)/.test(text)) cats.add('first');
    if (/\$|\bk\b|\bk\/|\bk!\b|\bk[\.,]/.test(text) && amount > 0) cats.add('closed');
    return { ...w, _idx: i, _cats: Array.from(cats), _amount: amount };
  });

  return {
    wins: tagged,
    Card: (w, key) => (
      <SlackMessageCard key={key || `chat-${w._idx}`} win={w} colorFor={colorFor} initials={initials} fmtTime={fmtTime} fmtDate={fmtDate}/>
    ),
  };
}
window.SlackChatWins = SlackChatWins;

function SlackMessageCard({ win, colorFor, initials, fmtTime, fmtDate }) {
  return (
    <div style={{
      breakInside: 'avoid',
      marginBottom: 14,
      borderRadius: 12,
      overflow: 'hidden',
      border: '1px solid rgba(255,255,255,0.08)',
      background: '#fff',
      transition: 'transform 200ms ease, border-color 200ms ease, box-shadow 200ms ease',
      display: 'block',
    }}
      onMouseEnter={e => {
        e.currentTarget.style.transform = 'translateY(-2px)';
        e.currentTarget.style.borderColor = 'rgba(232,18,60,0.5)';
        e.currentTarget.style.boxShadow = '0 12px 32px rgba(0,0,0,0.5)';
      }}
      onMouseLeave={e => {
        e.currentTarget.style.transform = 'translateY(0)';
        e.currentTarget.style.borderColor = 'rgba(255,255,255,0.08)';
        e.currentTarget.style.boxShadow = 'none';
      }}
    >
      {/* Channel header strip */}
      <div style={{
        padding: '8px 14px 6px',
        borderBottom: '1px solid #eee',
        display: 'flex', alignItems: 'center', gap: 8,
        fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
        fontSize: 13, fontWeight: 700, color: '#1d1c1d',
      }}>
        <span style={{ color: '#616061' }}>#</span>
        <span>wins</span>
        <span style={{ color: '#616061', fontWeight: 400, fontSize: 11, marginLeft: 'auto' }}>
          {fmtDate(win.ts)}
        </span>
      </div>

      {/* Message body */}
      <div style={{
        padding: '12px 14px 14px',
        display: 'flex', gap: 10,
        fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
      }}>
        {/* Avatar — real Slack profile photo if we have one, otherwise
            colored initials. Falls through to initials on image load failure
            (in case the file is missing or 404s). */}
        {(typeof SLACK_AVATARS !== 'undefined' && SLACK_AVATARS[win.uid]) ? (
          <img
            src={`./assets/slack-avatars/${SLACK_AVATARS[win.uid]}`}
            alt={win.name}
            width={36} height={36}
            loading="lazy" decoding="async"
            style={{
              width: 36, height: 36, borderRadius: 6,
              flexShrink: 0, display: 'block', objectFit: 'cover',
              background: colorFor(win.name),
            }}
            onError={(e) => {
              const fallback = document.createElement('div');
              fallback.textContent = initials(win.name);
              Object.assign(fallback.style, {
                width: '36px', height: '36px', borderRadius: '6px',
                background: colorFor(win.name),
                color: '#fff', flexShrink: '0',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                fontSize: '13px', fontWeight: '700', letterSpacing: '0.02em',
              });
              e.currentTarget.replaceWith(fallback);
            }}
          />
        ) : (
          <div style={{
            width: 36, height: 36, borderRadius: 6,
            background: colorFor(win.name),
            color: '#fff', flexShrink: 0,
            display: 'flex', alignItems: 'center', justifyContent: 'center',
            fontSize: 13, fontWeight: 700, letterSpacing: '0.02em',
          }}>{initials(win.name)}</div>
        )}

        {/* Content */}
        <div style={{ flex: 1, minWidth: 0 }}>
          <div style={{ display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 3 }}>
            <span style={{ fontSize: 14, fontWeight: 700, color: '#1d1c1d' }}>{win.name}</span>
            <span style={{ fontSize: 11, color: '#616061' }}>{fmtTime(win.ts)}</span>
          </div>
          <div style={{
            fontSize: 14, lineHeight: 1.45,
            color: '#1d1c1d',
            whiteSpace: 'pre-wrap',
            wordBreak: 'break-word',
          }}>{win.text}</div>

          {/* Reactions */}
          {win.reactions && win.reactions.length > 0 && (
            <div style={{
              marginTop: 8,
              display: 'flex', flexWrap: 'wrap', gap: 4,
            }}>
              {win.reactions.map(([emoji, count], i) => (
                <div key={i} style={{
                  display: 'inline-flex', alignItems: 'center', gap: 4,
                  padding: '2px 8px',
                  background: '#e8f5fa',
                  border: '1px solid #1d9bd1',
                  borderRadius: 12,
                  fontSize: 12, fontWeight: 700,
                  color: '#1264a3',
                  lineHeight: 1.3,
                }}>
                  <span style={{ fontSize: 14 }}>{emoji}</span>
                  <span>{count}</span>
                </div>
              ))}
            </div>
          )}
        </div>
      </div>
    </div>
  );
}
window.SlackMessageCard = SlackMessageCard;
