/* ============================================================================
   TALYA SMART — PLATFORM INVENTORY (data only)
   Functional public names ONLY. No internal codenames ever reach this file.
   The surface NEVER renders the full list — only: 6 discovery starting points,
   search-filtered results, 1–3 "Built on:" names per solution card, and the
   platform(s) cited in the report. Hard rule: ≤12 platform names visible at once.

   Count: 151 canonical functional platforms + Personal AI Training · Private
   Operator Model = 152. (Operator AI · Private GPU is canonical #14.)
   Labs span all 12 transformation labs; cross-cutting factory layer has no lab.
   ============================================================================ */

/* raw rows: n=name t=tagline lab=labKey grp=groupKey cat=category m=modes feat=featured */
const _P = [
  /* ---- TELECOM & INFRASTRUCTURE LAB (group telecom-infra) ---- */
  ["Distributed Inference Fabric", "Low-VRAM edge LLM inference across consumer-grade hardware.", "telecom", "telecom-infra", "infra", ["white-label", "venture"]],
  ["Edge AI Deployment Mesh", "Multi-tenant GPU node orchestration with controlled deploys.", "telecom", "telecom-infra", "infra", ["white-label"]],
  ["GPU Cloud & Inference Marketplace", "Managed GPU servers and spot inference capacity.", "telecom", "telecom-infra", "marketplace", ["saas", "venture"]],
  ["Carrier-Grade AI Network Operations", "Autonomous NOC: incident detection, fault routing, capacity planning.", "telecom", "telecom-infra", "infra", ["white-label"]],
  ["Self-Hosted Backend-as-a-Service", "Multi-tenant Postgres + identity BaaS, customer-owned data plane.", "telecom", "telecom-infra", "infra", ["saas", "white-label"]],
  ["AI Drive & File Platform", "File bytes + metadata + auth as one product.", "telecom", "telecom-infra", "infra", ["white-label"]],
  ["Notification & Object Storage Platform", "Multi-protocol notification + S3-compatible storage.", "telecom", "telecom-infra", "infra", ["saas"]],
  ["Unified Secrets Platform", "Open-source secrets management for the deploy stack.", "telecom", "telecom-infra", "infra", ["saas"]],
  ["Remote AI Machine Access", "Secure tunnel to a GPU box; share inference without exposing the network.", "telecom", "telecom-infra", "infra", ["saas"]],
  ["Sovereign AI Marketplace", "Region-specific SaaS catalog with subscription and discovery.", "telecom", "telecom-infra", "marketplace", ["venture"]],
  ["Multi-Cloud B2B Marketplace", "Unified procurement across major clouds and regional telecom.", "telecom", "telecom-infra", "marketplace", ["venture"]],
  ["Voice AI Assistant Platform", "Native voice-first assistant with deep OS integration.", "telecom", "telecom-infra", "ai", ["white-label", "saas"]],
  ["AI Orchestrator", "The engine that runs every platform on the stack.", "telecom", "telecom-infra", "ai", ["factory"]],
  ["Operator AI · Private GPU", "Dedicated GPU node + private-mesh access for your business AI agents: email, voice, docs, dispatch, finance — never on the public internet.", "telecom", "telecom-infra", "ai", ["white-label", "saas", "venture"], true],
  ["Agent Operations & Governance Plane", "Observability, cost, policy, and human-in-the-loop control for AI agents.", "telecom", "telecom-infra", "infra", ["saas"]],
  ["Auto-Update Control Plane", "Desktop app distribution and update gating.", "telecom", "telecom-infra", "infra", ["saas"]],
  ["Operational Intelligence Corpus", "Curated operations corpus and adapter family for vertical AI.", "telecom", "telecom-infra", "data", ["factory", "venture"]],
  ["AI Research Automation", "Autonomous frontier research pipelines.", "telecom", "telecom-infra", "ai", ["factory"]],
  ["Notebook AI", "Research workspace with an agentic notebook UX.", "telecom", "telecom-infra", "ai", ["saas"]],
  ["B2B Knowledge Graph Platform", "Graph-based market intelligence.", "telecom", "telecom-infra", "data", ["saas", "venture"]],
  ["Self-Hosted Analytics SDK", "Privacy-first analytics SDK across the network.", "telecom", "telecom-infra", "data", ["factory"]],

  /* ---- SOFTWARE & AI DEVELOPMENT LAB (group software) ---- */
  ["AI-Native Code Editor", "Editor with chat ops and integrated comms for AI-native teams.", "software", "software", "ai", ["saas"]],
  ["AI Coding Cowork Platform", "Multi-agent collaborative coding.", "software", "software", "ai", ["saas"]],
  ["Design OS for Coding Agents", "Production-grade design pipeline: brief → IA → tokens → build → review.", "software", "software", "factory", ["saas"]],
  ["Persistent Memory for Coding Agents", "Cross-session, cross-project memory layer.", "software", "software", "ai", ["saas"]],
  ["Skills & Methodology Layer for Coding Agents", "Composable skills + governance for AI dev teams.", "software", "software", "factory", ["saas"]],

  /* ---- COMMERCE LAB · Ecommerce (group commerce) ---- */
  ["Halal Commerce Discovery & Marketplace OS", "Certified products, flyer deals, store locator for North America.", "ecommerce", "commerce", "marketplace", ["white-label", "venture"]],
  ["Kosher Commerce Discovery & Marketplace OS", "Restaurant + product discovery and trust platform.", "ecommerce", "commerce", "marketplace", ["white-label", "venture"]],
  ["Channel Intelligence & Listing AI", "Marketplace listing, optimization, and reprice.", "ecommerce", "commerce", "ops", ["saas"]],
  ["Affiliate & Loyalty Attribution Platform", "Affiliate → commission → reward closed loop.", "ecommerce", "commerce", "ops", ["white-label"]],
  ["Loyalty & Referral Platform", "Points, miles, referrals as a service.", "ecommerce", "commerce", "ops", ["white-label"]],
  ["Stock & AI Photo Marketplace", "Curated stock library with AI micropayments and aggregation.", "ecommerce", "commerce", "marketplace", ["saas"]],
  ["Ecommerce Storefront Platform", "DTC storefront for specialty and import brands.", "ecommerce", "commerce", "marketplace", ["white-label"]],
  ["Multi-Carrier Shipping Intelligence", "Rate-shop, label, and lane optimization for retail shipping.", "ecommerce", "commerce", "ops", ["white-label", "venture"]],
  ["Crypto Payment Service Provider", "Merchant crypto payments with fiat settlement.", "ecommerce", "commerce", "ops", ["saas"]],
  ["Unified Payment Gateway", "Type-safe payment SDK across major processors.", "ecommerce", "commerce", "infra", ["saas", "factory"]],
  ["Cloud Payment Gateway", "Regional payment provider mesh.", "ecommerce", "commerce", "infra", ["saas"]],
  ["Marketing Automation Platform", "Multi-channel campaign management.", "ecommerce", "commerce", "ops", ["saas"]],
  ["Campaign Operations Platform", "Campaign builder, attribution, and budget control.", "ecommerce", "commerce", "ops", ["saas"]],
  ["Loyalty Wash & Subscription Operations", "Recurring-service subscription engine.", "ecommerce", "commerce", "ops", ["white-label"]],

  /* ---- COMMERCE LAB · Retail (group commerce) ---- */
  ["Stationery & Specialty Retail OS", "POS, ops, and online for small retail chains.", "retail", "commerce", "ops", ["white-label"]],
  ["Retail Multi-Store Management", "Multi-location ops, reviews, staff performance.", "retail", "commerce", "ops", ["white-label"]],
  ["Marketing Site Builder for Retail Brands", "Astro-first marketing stack with shared component library.", "retail", "commerce", "factory", ["factory"]],
  ["POS-Linked Cash Operations", "Cash-flow and reconciliation for cash-heavy retail.", "retail", "commerce", "ai", ["saas"]],
  ["Restaurant Brand Marketing Site Engine", "Repeatable marketing + ordering site per location.", "retail", "commerce", "factory", ["white-label"]],
  ["Catering Operations Management", "Production-grade catering ops platform.", "retail", "commerce", "ops", ["white-label"]],

  /* ---- OPERATIONS LAB · Logistics (group operations) ---- */
  ["Freight Visibility & Intelligence Platform", "Container schedules, vessel tracking, ocean rates, emissions analytics.", "logistics", "operations", "data", ["saas", "venture"]],
  ["Freight Forwarder OS", "End-to-end forwarder platform: bookings, docs, customs.", "logistics", "operations", "ops", ["white-label"]],
  ["Freight Broker Copilot", "Quote, source, and book in seconds.", "logistics", "operations", "ops", ["saas"]],
  ["Customs & Compliance AI", "Classification, documentation, clearance copilot.", "logistics", "operations", "ai", ["saas"]],
  ["Logistics CRM & AR Cash Collection", "Receivables and collections for freight businesses.", "logistics", "operations", "ops", ["white-label"]],
  ["Mobile Field App for Freight Operators", "Driver / operator field workflow.", "logistics", "operations", "ops", ["white-label"]],
  ["Fleet Routing AI", "Last-mile route optimization for distributors.", "logistics", "operations", "ai", ["white-label"]],
  ["Multi-Tenant Route Optimization Platform", "Tenant-isolated route optimization.", "logistics", "operations", "ai", ["saas", "white-label"]],
  ["Container & Asset Ops", "Container lifecycle and asset tracking.", "logistics", "operations", "ops", ["white-label"]],
  ["Transport & Logistics Integration API", "Integration backbone for transport and logistics.", "logistics", "operations", "infra", ["factory"]],

  /* ---- OPERATIONS LAB · Distribution (group operations) ---- */
  ["Warehouse-Space Marketplace", "Warehouse-as-a-service marketplace.", "distribution", "operations", "marketplace", ["venture"]],
  ["B2B Distributor Operating System", "Distributor OS with accounting and inventory integrations.", "distribution", "operations", "ops", ["white-label"]],
  ["Food Distribution OS", "Distributor-grade demand, ordering, ops for specialty food.", "distribution", "operations", "ops", ["venture", "white-label"]],
  ["Accounting Multi-Tenant Integration Platform", "Accounting-as-a-platform for distributor verticals.", "distribution", "operations", "infra", ["factory"]],
  ["Accounting Automation Backend", "Accounting API automation and reconciliation.", "distribution", "operations", "infra", ["factory"]],
  ["Cash & Reconciliation Dashboard", "Cash visibility for distributors.", "distribution", "operations", "ai", ["white-label"]],
  ["BI Dashboard Platform", "Sales, planning, forecasting, commission management.", "distribution", "operations", "data", ["saas"]],
  ["Distributor Procurement & Supplier Intelligence", "Supplier scoring + auto-PO.", "distribution", "operations", "ai", ["saas"]],
  ["Sales Pipeline & Demand Forecasting", "Distributor-grade demand modeling.", "distribution", "operations", "ai", ["saas"]],
  ["Procurement Workflow Engine", "Purchasing and supplier ops automation.", "distribution", "operations", "ai", ["saas"]],

  /* ---- SERVICE BUSINESS LAB (group service) ---- */
  ["Beauty Service OS", "Salons, barbershops, beauty chains: local SEO, booking, reputation.", "service", "service", "ai", ["white-label", "venture"]],
  ["Dry Cleaning Service OS", "Orders, routes, customer voice AI for cleaning chains.", "service", "service", "ai", ["white-label"]],
  ["Home Services Dispatch AI", "HVAC, plumbing, electrical, handyman dispatch and scheduling.", "service", "service", "ai", ["white-label"]],
  ["Smart-Home Design & Quote Platform", "Modern smart-home design + pricing experience.", "service", "service", "ai", ["white-label"]],
  ["Smart-Home Shop & Service Request", "Customer-facing service request, quote, and payment.", "service", "service", "ops", ["white-label"]],
  ["EV Smart-Home Adjacency Platform", "EV-aware home and charging design and ops.", "service", "service", "ai", ["white-label"]],
  ["EV Fleet & Charging Operations", "Fleet electrification and charge management.", "service", "service", "ai", ["saas"]],
  ["Restaurant Operations AI", "Kitchen + front-of-house operations.", "service", "service", "ai", ["white-label"]],
  ["Restaurant Marketing & Ordering Site", "Per-restaurant marketing + online ordering.", "service", "service", "ops", ["white-label"]],
  ["Multi-Restaurant Catalog Platform", "Multi-brand restaurant ops + review tracking.", "service", "service", "ops", ["white-label"]],
  ["Hospitality Guest Portal", "Luxury guest portal for marinas, charters, hotels.", "service", "service", "ai", ["white-label"]],
  ["Yacht & Charter Management Platform", "Bookings, ops, fleet for yacht charters.", "service", "service", "ops", ["white-label"]],
  ["Charter Discovery & Marketplace", "Multi-operator charter marketplace.", "service", "service", "marketplace", ["venture"]],
  ["Marina Guest Portal", "Marina-specific guest experience.", "service", "service", "ai", ["white-label"]],
  ["Wellness & Studio Booking Platform", "Studio / venue reservation OS.", "service", "service", "ai", ["white-label"]],
  ["Local Services Scheduling AI", "Appointment-driven service businesses.", "service", "service", "ai", ["saas"]],
  ["Field Service Mobile App", "Operator mobile companion.", "service", "service", "ops", ["white-label"]],
  ["DTC Brand Site Engine", "DTC product brand marketing + commerce stack.", "service", "service", "factory", ["factory"]],
  ["Multi-Store Restaurant Chain Management", "Fast-casual chain ops + reviews.", "service", "service", "ops", ["white-label"]],
  ["Hospitality Welcome / Onboarding Platform", "Guest onboarding for hospitality brands.", "service", "service", "ai", ["white-label"]],
  ["Single-Brand Chain Operations", "Multi-platform review + staff performance for single-brand chains.", "service", "service", "ops", ["white-label"]],

  /* ---- INDUSTRIAL LAB · Manufacturing (group industrial) ---- */
  ["Manufacturing Vision QA", "Line-speed defect detection with vision AI.", "manufacturing", "industrial", "ai", ["white-label"]],
  ["Quality Management System", "Full-stack QMS for manufacturers (web + mobile + API).", "manufacturing", "industrial", "ai", ["white-label"]],
  ["Industrial Asset Intelligence", "Asset register + predictive maintenance.", "manufacturing", "industrial", "ai", ["white-label"]],
  ["Production Planning AI", "Schedule against real demand, not last quarter's.", "manufacturing", "industrial", "ai", ["saas"]],
  ["Industrial Incentive Intelligence", "Government incentive matching for manufacturers.", "manufacturing", "industrial", "data", ["venture"]],
  ["Tender / RFP Legal AI", "Public-tender legal application assistant.", "manufacturing", "industrial", "ai", ["saas", "white-label"]],
  ["Smart Office & Asset Management", "Office space + asset workflows.", "manufacturing", "industrial", "ops", ["saas"]],
  ["HR Management Platform", "Workforce planning and HR ops.", "manufacturing", "industrial", "ai", ["saas"]],
  ["Multi-Location Workforce Activity Tracking", "Operational dashboard for founding teams.", "manufacturing", "industrial", "ai", ["white-label"]],

  /* ---- INDUSTRIAL LAB · Real Estate + Marine (group industrial) ---- */
  ["Real-Estate Zoning & Leasing AI", "Entitlement + leasing copilot.", "realestate", "industrial", "ai", ["white-label"]],
  ["Property Management Platform", "Property + cadastral information system.", "realestate", "industrial", "ai", ["white-label"]],
  ["Resort Investment Marketing Platform", "Destination-investment marketing site engine.", "realestate", "industrial", "ops", ["white-label"]],
  ["Alternative Investment Platform", "Curated real-estate, yacht, and alternative investments.", "realestate", "industrial", "marketplace", ["venture"]],
  ["Solar Investment Platform", "Multi-language solar investment origination.", "realestate", "industrial", "marketplace", ["venture"]],
  ["Solar Project Intelligence", "Solar origination through O&M.", "realestate", "industrial", "ai", ["white-label"]],
  ["Grid & Power Intelligence", "Energy operations and grid analytics.", "realestate", "industrial", "ai", ["white-label"]],
  ["Country-Branded Real-Estate Marketing", "Luxury real-estate marketing site stack.", "realestate", "industrial", "ops", ["white-label"]],
  ["Custom-Automotive & Yacht Customization Marketing", "Premium customization brand site engine.", "realestate", "industrial", "factory", ["factory"]],
  ["Marina Operations Platform", "Comprehensive marina business management.", "realestate", "industrial", "ops", ["white-label"]],
  ["Marine Marketplace", "Yacht sales, accessories, services, spare parts, bookings.", "realestate", "industrial", "marketplace", ["venture"]],
  ["Marine Technical RAG Assistant", "Boat-tech document Q&A via chat.", "realestate", "industrial", "ai", ["white-label"]],
  ["Marine Search Engine", "Region-wide marine product search engine.", "realestate", "industrial", "marketplace", ["venture"]],
  ["Marine Marketing Platform", "Marine brand marketing site stack.", "realestate", "industrial", "factory", ["factory"]],

  /* ---- CONSTRUCTION & BUILT WORLD LAB (group construction) ---- */
  ["Industrial Cost Management", "Construction and production cost modeling.", "construction", "construction", "ai", ["white-label"]],
  ["3D Model & Building Approval Platform", "Title application with 3D site plans.", "construction", "construction", "ai", ["venture"]],
  ["Construction Quality & Inspection AI", "Construction-side QA companion.", "construction", "construction", "ai", ["white-label"]],
  ["Cost & Construction Management Platform", "Construction cost ledger and approvals.", "construction", "construction", "ai", ["white-label"]],

  /* ---- TRADE & CROSS-BORDER LAB (group trade) ---- */
  ["Country-of-Origin Commerce Engine", "Diaspora and specialty trade marketplace platform.", "trade", "trade", "marketplace", ["white-label", "venture"]],
  ["Importer-Network Marketplace", "Country-of-origin importer directory and trade workflow.", "trade", "trade", "marketplace", ["venture"]],
  ["B2B Wholesale Marketplace", "Verified suppliers + buyers, global wholesale workflow.", "trade", "trade", "marketplace", ["venture"]],
  ["Global Trade Marketplace", "Verified suppliers, buyers, and cross-border trade flows.", "trade", "trade", "marketplace", ["venture"]],
  ["Auto Import / Export Logistics", "Vehicle cross-border ops with marketing and backend.", "trade", "trade", "ops", ["white-label"]],

  /* ---- PERSONAL AI TRAINING LAB (group personal-ai) ---- */
  ["Personal AI Training · Private Operator Model", "A private AI model and coaching layer trained on your documents, workflows, writing style, decisions, and company context.", "personal-ai", "personal-ai", "ai", ["white-label", "saas", "venture"], true],

  /* ---- CROSS-CUTTING SAAS FACTORY LAYER (group factory, no lab) ---- */
  ["AI Orchestrator Core", "The spine that runs every vertical.", null, "factory", "factory", ["factory"]],
  ["Vertical Deploy Stack", "Repeatable deploy of any vertical under any brand.", null, "factory", "factory", ["factory"]],
  ["One-Click Deploy PaaS", "Self-hosted deploy plane.", null, "factory", "factory", ["factory"]],
  ["Identity & Access Layer", "Multi-tenant identity + RBAC + SSO.", null, "factory", "factory", ["factory"]],
  ["Auth-as-a-Service for App Providers", "Turnkey auth for partner-built apps.", null, "factory", "factory", ["factory"]],
  ["Compliance AI", "Sector-specific regulatory copilot.", null, "factory", "factory", ["factory"]],
  ["Legal & Contract AI", "Drafting, review, redline.", null, "factory", "factory", ["factory"]],
  ["Document Processing & Archive Platform", "Enterprise-grade regulated document management.", null, "factory", "factory", ["factory"]],
  ["Document Upload & Onboarding Pipeline", "Multi-step document collection for regulated workflows.", null, "factory", "factory", ["factory"]],
  ["PDF Statement Parser", "Bank-statement / financial-document parser-as-a-service.", null, "factory", "factory", ["factory"]],
  ["Contact / CRM Layer", "Base contact management for vertical platforms.", null, "factory", "factory", ["factory"]],
  ["VC / Family-Office Marketing Stack", "Venture firm site + portfolio surface.", null, "factory", "factory", ["factory"]],
  ["Personal-Brand & Operator Marketing Stack", "Founder / operator bio-site stack.", null, "factory", "factory", ["factory"]],
  ["Education Platform", "Vertical online learning platform.", null, "factory", "factory", ["factory"]],
  ["Startup Evaluation & Investor Matching", "AI-graded startup pipeline + investor matching.", null, "factory", "factory", ["factory"]],
  ["Trade & Sentiment Intelligence", "Market-sentiment AI for retail equities.", null, "factory", "data", ["saas"]],
  ["Insurance Management Platform", "Broker / agency insurance ops.", null, "factory", "ai", ["white-label"]],
  ["Insurance Vertical", "Regional-market insurance ops.", null, "factory", "ai", ["white-label"]],
  ["Crypto Coin Ecosystem & Oracle", "Token + oracle + chain listener + frontends.", null, "factory", "infra", ["venture"]],
  ["Alternative Financing Platform", "Asset-backed financing platform.", null, "factory", "ai", ["venture"]],
  ["Investor Assistance Platform", "Immigration-investment workflow + matching.", null, "factory", "ai", ["venture"]],
  ["Country-Branded Marketing Sites", "Destination and brand site engine for regional operators.", null, "factory", "factory", ["white-label"]],
  ["Regional Budget Dashboards", "Sovereign / regional budget management platform.", null, "factory", "ops", ["white-label"]],
  ["Translation & Trade Localization Layer", "Multilingual ops + content.", null, "factory", "infra", ["factory"]],
  ["Internal Operational Documentation Engine", "Company-knowledge graph and docs system.", null, "factory", "factory", ["factory"]],
  ["Equities AI Sentiment", "Sentiment + buy/sell signals for regional equities.", null, "factory", "data", ["saas"]],
  ["Brand-Symbol Marketing Engine", "Heritage brand marketing stack.", null, "factory", "factory", ["factory"]],
  ["Investment Manager Console", "Investor portfolio console.", null, "factory", "ai", ["white-label"]],
  ["Backend Backup / Migration Tooling", "Backend backup and migration utility platform.", null, "factory", "factory", ["factory"]],
  ["Migration / Visa Workflow", "Migration workflow platform.", null, "factory", "ai", ["venture"]],
  ["Document-Parsed Banking Pipeline", "Bank statement parsing → BI.", null, "factory", "ai", ["factory"]],
  ["Universal Web Starter", "TypeScript + Postgres + auth scaffold used across every vertical.", null, "factory", "factory", ["factory"]],
];

function _slug(s) {
  return s.toLowerCase().replace(/·/g, " ").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
}

const PLATFORMS = _P.map((r) => ({
  key: _slug(r[0]),
  name: r[0],
  tagline: r[1],
  labKey: r[2],
  groupKey: r[3],
  category: r[4],
  modes: r[5],
  featured: r[6] || false,
}));

/* ---- helpers (all return capped lists; surface never shows >12) ---- */
function platformsForLab(labKey, limit) {
  const list = PLATFORMS.filter((p) => p.labKey === labKey);
  return limit ? list.slice(0, limit) : list;
}

function platformByName(name) {
  return PLATFORMS.find((p) => p.name === name) || null;
}

/* "Built on:" — 1–3 platforms per solution card. Seeds with the elevated
   featured platforms when a lab is thin, then fills from the lab's own list. */
function builtOnFor(labKey, solutionIndex, opts = {}) {
  const pool = platformsForLab(labKey);
  const picks = [];
  if (opts.elevateName && solutionIndex === 0) {
    const f = platformByName(opts.elevateName);
    if (f) picks.push(f);
  }
  for (const p of pool) {
    if (picks.length >= 3) break;
    // stride through the pool so each card shows different platforms
    if (!picks.includes(p)) picks.push(p);
  }
  // rotate by solutionIndex so the 4 cards don't repeat the same names
  const rotated = pool.length
    ? pool.slice((solutionIndex * 1) % pool.length).concat(pool.slice(0, (solutionIndex * 1) % pool.length))
    : [];
  const out = [];
  if (opts.elevateName && solutionIndex === 0) {
    const f = platformByName(opts.elevateName);
    if (f) out.push(f);
  }
  for (const p of rotated) {
    if (out.length >= 3) break;
    if (!out.find((x) => x.key === p.key)) out.push(p);
  }
  return out.slice(0, 3);
}

/* Search across name + tagline + category + lab; capped at 12 results. */
function searchPlatforms(query, opts = {}) {
  const q = (query || "").trim().toLowerCase();
  let list = PLATFORMS;
  if (opts.size) {
    const sizeModes = {
      SME: ["white-label", "saas"],
      "Mid-market": ["white-label", "saas", "venture"],
      Enterprise: ["white-label", "venture", "factory"],
      Hyperscaler: ["factory", "infra", "venture"],
    }[opts.size];
    if (sizeModes) list = list.filter((p) => p.modes.some((m) => sizeModes.includes(m)) || p.category === "infra");
  }
  if (q) {
    list = list.filter(
      (p) =>
        p.name.toLowerCase().includes(q) ||
        p.tagline.toLowerCase().includes(q) ||
        p.category.includes(q) ||
        (p.labKey || "").includes(q) ||
        (p.groupKey || "").includes(q)
    );
  }
  return list.slice(0, 12);
}

/* 6 discovery starting points sampled across the lab groups. */
function discoveryStartingPoints() {
  const wanted = ["telecom-infra", "commerce", "operations", "service", "industrial", "personal-ai"];
  return wanted.map((g) => PLATFORMS.find((p) => p.groupKey === g && p.labKey)).filter(Boolean).slice(0, 6);
}

/* archetype label for the discovery "operator" column (derived, not stored) */
function archetypeFor(p) {
  const byCat = {
    marketplace: "Marketplaces & networks",
    ops: "Multi-location operators",
    data: "Data & intelligence teams",
    infra: "Platform & infra teams",
    ai: "AI-forward operators",
    factory: "Platform builders",
  };
  return byCat[p.category] || "Operators";
}

window.TALYA_PLATFORMS = {
  PLATFORMS,
  platformsForLab,
  platformByName,
  builtOnFor,
  searchPlatforms,
  discoveryStartingPoints,
  archetypeFor,
};
