// Human-friendly display names and icons for all MCP app IDs
// Used by McpAppToolbar and anywhere we need pretty names

export const APP_DISPLAY_NAMES: Record<string, { name: string; icon: string }> = {
  // ═══════════════════════════════════════════
  // n8n Apps
  // ═══════════════════════════════════════════
  "n8n-workflow-builder": { name: "Workflow Builder", icon: "⚡" },
  "n8n-execution-monitor": { name: "Executions", icon: "📊" },
  "n8n-workflow-templates": { name: "Templates", icon: "📋" },
  "n8n-node-config": { name: "Node Explorer", icon: "🔧" },
  "n8n-health-monitor": { name: "Health Monitor", icon: "💚" },
  "n8n-webhook-tester": { name: "Webhook Tester", icon: "🔗" },
  "n8n-workflow-detail": { name: "Workflow Detail", icon: "📝" },

  // ═══════════════════════════════════════════
  // GoHighLevel (GHL) Apps — All 65
  // ═══════════════════════════════════════════

  // --- Contacts & Leads ---
  "ghl-contact-grid": { name: "Contacts", icon: "👥" },
  "ghl-contact-card": { name: "Contact Card", icon: "👤" },
  "ghl-contact-creator": { name: "New Contact", icon: "➕" },
  "ghl-contact-timeline": { name: "Timeline", icon: "📅" },
  "ghl-duplicate-checker": { name: "Duplicates", icon: "🔍" },
  "ghl-smartlist-viewer": { name: "Smart Lists", icon: "📋" },
  "ghl-tags-manager": { name: "Tags", icon: "🏷️" },
  "ghl-custom-fields-manager": { name: "Custom Fields", icon: "📝" },

  // --- Companies ---
  "ghl-company-list": { name: "Companies", icon: "🏢" },
  "ghl-company-detail": { name: "Company Detail", icon: "🏛️" },

  // --- Pipeline & Opportunities ---
  "ghl-pipeline-kanban": { name: "Pipeline", icon: "📊" },
  "ghl-pipeline-analytics": { name: "Pipeline Analytics", icon: "📈" },
  "ghl-pipeline-funnel": { name: "Pipeline Funnel", icon: "🔽" },
  "ghl-opportunity-card": { name: "Opportunity", icon: "💰" },
  "ghl-opportunity-editor": { name: "Edit Opportunity", icon: "✏️" },

  // --- Calendar & Appointments ---
  "ghl-calendar-view": { name: "Calendar", icon: "📆" },
  "ghl-calendar-resources": { name: "Resources", icon: "🗂️" },
  "ghl-appointment-booker": { name: "Book Appt", icon: "📅" },
  "ghl-appointment-detail": { name: "Appt Detail", icon: "📋" },
  "ghl-free-slots-finder": { name: "Free Slots", icon: "🕐" },

  // --- Messaging & Communication ---
  "ghl-conversation-list": { name: "Conversations", icon: "💬" },
  "ghl-conversation-thread": { name: "Thread", icon: "🧵" },
  "ghl-message-composer": { name: "Compose", icon: "✉️" },
  "ghl-message-detail": { name: "Message", icon: "📩" },
  "ghl-email-template-preview": { name: "Email Templates", icon: "📧" },
  "ghl-template-library": { name: "Templates", icon: "📚" },

  // --- Calls ---
  "ghl-call-log": { name: "Call Log", icon: "📞" },
  "ghl-call-detail": { name: "Call Detail", icon: "📲" },

  // --- Campaigns ---
  "ghl-campaign-stats": { name: "Campaigns", icon: "📣" },

  // --- Invoicing & Payments ---
  "ghl-invoice-builder": { name: "Invoice Builder", icon: "🧾" },
  "ghl-invoice-list": { name: "Invoices", icon: "📃" },
  "ghl-invoice-preview": { name: "Invoice Preview", icon: "👁️" },
  "ghl-estimate-builder": { name: "Estimate Builder", icon: "📐" },
  "ghl-estimate-preview": { name: "Estimate Preview", icon: "📄" },
  "ghl-transaction-list": { name: "Transactions", icon: "💳" },
  "ghl-revenue-dashboard": { name: "Revenue", icon: "💵" },
  "ghl-subscription-manager": { name: "Subscriptions", icon: "🔄" },
  "ghl-coupon-manager": { name: "Coupons", icon: "🎟️" },

  // --- Orders & Products ---
  "ghl-order-list": { name: "Orders", icon: "📦" },
  "ghl-order-detail": { name: "Order Detail", icon: "🧾" },
  "ghl-product-catalog": { name: "Products", icon: "🛍️" },
  "ghl-product-detail": { name: "Product Detail", icon: "📋" },
  "ghl-inventory-dashboard": { name: "Inventory", icon: "📊" },

  // --- Funnels & Forms ---
  "ghl-funnel-list": { name: "Funnels", icon: "🔗" },
  "ghl-funnel-detail": { name: "Funnel Detail", icon: "🔍" },
  "ghl-form-list": { name: "Forms", icon: "📝" },
  "ghl-form-submissions": { name: "Submissions", icon: "📥" },

  // --- Surveys ---
  "ghl-survey-list": { name: "Surveys", icon: "📊" },
  "ghl-survey-submissions": { name: "Survey Results", icon: "📈" },

  // --- Social Media ---
  "ghl-social-accounts": { name: "Social Accounts", icon: "🌐" },
  "ghl-social-calendar": { name: "Social Calendar", icon: "📅" },
  "ghl-social-post-composer": { name: "Social Post", icon: "📱" },

  // --- Courses & Memberships ---
  "ghl-course-catalog": { name: "Courses", icon: "🎓" },
  "ghl-course-detail": { name: "Course Detail", icon: "📖" },

  // --- Blog ---
  "ghl-blog-manager": { name: "Blog", icon: "✍️" },

  // --- Media ---
  "ghl-media-library": { name: "Media Library", icon: "🖼️" },

  // --- Workflows & Automation ---
  "ghl-workflow-status": { name: "Workflows", icon: "⚙️" },
  "ghl-workflow-detail": { name: "Workflow Detail", icon: "🔧" },

  // --- Team & Tasks ---
  "ghl-task-board": { name: "Tasks", icon: "✅" },
  "ghl-team-management": { name: "Team", icon: "👥" },
  "ghl-user-detail": { name: "User Detail", icon: "👤" },
  "ghl-agent-stats": { name: "Agent Stats", icon: "📊" },

  // --- Reviews & Reputation ---
  "ghl-reviews-dashboard": { name: "Reviews", icon: "⭐" },

  // --- Affiliate ---
  "ghl-affiliate-dashboard": { name: "Affiliates", icon: "🤝" },

  // --- Location / Account ---
  "ghl-location-dashboard": { name: "Location", icon: "📍" },

  // --- Legacy aliases (old IDs that still appear) ---
  "ghl-pipeline-board": { name: "Pipeline", icon: "📊" },
  "ghl-quick-book": { name: "Quick Book", icon: "📅" },

  // ═══════════════════════════════════════════
  // Google Ads Apps
  // ═══════════════════════════════════════════
  "google-ads-campaign-dashboard": { name: "Campaigns", icon: "📊" },
  "google-ads-performance-overview": { name: "Performance", icon: "📈" },
  "google-ads-keyword-analyzer": { name: "Keywords", icon: "🔑" },
  "google-ads-budget-optimizer": { name: "Budget", icon: "💰" },
  "google-ads-search-terms": { name: "Search Terms", icon: "🔎" },
  "google-ads-campaign-detail": { name: "Campaign Detail", icon: "📋" },
  "google-ads-recommendations": { name: "Recommendations", icon: "💡" },

  // ═══════════════════════════════════════════
  // Meta Ads Apps
  // ═══════════════════════════════════════════
  "meta-ads-campaign-dashboard": { name: "Campaigns", icon: "📊" },
  "meta-ads-performance-heatmap": { name: "Heatmap", icon: "🔥" },
  "meta-ads-audience-builder": { name: "Audiences", icon: "🎯" },
  "meta-ads-creative-preview": { name: "Creatives", icon: "🎨" },
  "meta-ads-funnel-analyzer": { name: "Funnel", icon: "🔽" },
  "meta-ads-spend-tracker": { name: "Spend", icon: "💸" },
  "meta-ads-ad-performance-grid": { name: "Ad Grid", icon: "📊" },
  "meta-ads-ab-test-results": { name: "A/B Tests", icon: "🧪" },
  "meta-ads-account-health": { name: "Account Health", icon: "💚" },
  "meta-ads-campaign-builder": { name: "Builder", icon: "🏗️" },
  "meta-ads-ad-library-browser": { name: "Ad Library", icon: "📚" },

  // ═══════════════════════════════════════════
  // Google Search Console Apps
  // ═══════════════════════════════════════════
  "gsc-performance-dashboard": { name: "Performance", icon: "📊" },
  "gsc-quick-wins-board": { name: "Quick Wins", icon: "🏆" },
  "gsc-url-health-inspector": { name: "URL Health", icon: "🔗" },
  "gsc-cannibalization-map": { name: "Cannibalization", icon: "🗺️" },
  "gsc-content-decay-tracker": { name: "Content Decay", icon: "📉" },

  // ═══════════════════════════════════════════
  // Twilio Apps
  // ═══════════════════════════════════════════
  "twilio-dashboard": { name: "Dashboard", icon: "📞" },
  "twilio-campaign-live": { name: "Campaigns", icon: "📣" },
  "twilio-conversation-thread": { name: "Conversation", icon: "💬" },
  "twilio-message-log": { name: "Messages", icon: "📨" },
  "twilio-call-analytics": { name: "Call Analytics", icon: "📊" },
  "twilio-deep-scan-report": { name: "Deep Scan", icon: "🔬" },
  "twilio-batch-validate": { name: "Batch Validate", icon: "✅" },
  "twilio-number-hunt": { name: "Number Hunt", icon: "🔎" },
  "twilio-number-inventory": { name: "Numbers", icon: "📱" },
  "twilio-flow-diagram": { name: "Flow Diagram", icon: "🔀" },
  "twilio-flow-list": { name: "Flows", icon: "📋" },
  "twilio-agent-status": { name: "Agents", icon: "🧑‍💼" },
  "twilio-queue-manager": { name: "Queues", icon: "📥" },
  "twilio-inbox": { name: "Inbox", icon: "📬" },
  "twilio-cost-report": { name: "Costs", icon: "💰" },
  "twilio-health-check": { name: "Health", icon: "💚" },
  "twilio-error-log": { name: "Errors", icon: "🔴" },
  "twilio-deploy-status": { name: "Deploy", icon: "🚀" },
  "twilio-compliance-check": { name: "Compliance", icon: "🛡️" },

  // ═══════════════════════════════════════════
  // Reonomy Apps
  // ═══════════════════════════════════════════
  "reonomy-search-builder": { name: "Search Builder", icon: "🔍" },
  "reonomy-results-viewer": { name: "Results", icon: "📋" },
  "reonomy-dashboard": { name: "Dashboard", icon: "📊" },

  // ═══════════════════════════════════════════
  // Competitor Research Apps
  // ═══════════════════════════════════════════
  "competitor-intake-form": { name: "Intake Form", icon: "📝" },
  "competitor-dashboard": { name: "Dashboard", icon: "📊" },
};

// Helper to get display info for an app ID, with fallback
export function getAppDisplayName(appId: string): { name: string; icon: string } {
  if (APP_DISPLAY_NAMES[appId]) {
    return APP_DISPLAY_NAMES[appId];
  }
  // Fallback: strip prefix, title-case the rest
  const name = appId
    .replace(/^(ghl|n8n|google-ads|meta-ads|gsc|twilio|competitor)-/, "")
    .split("-")
    .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
    .join(" ");
  return { name, icon: "📦" };
}
