import type { ZoneGazePluginId } from "@zonegaze/common/plugin-services";

export type ZoneGazeProductId = ZoneGazePluginId;
export type ZoneGazeProductKind = "core" | "plugin";
export type ZoneGazePlatformId = "macos" | "android" | "web" | "cli";
export type ZoneGazeProductStatusLabel = "Beta";
export type ZoneGazeMatrixModuleId =
	| "matrix-home"
	| ZoneGazeProductId
	| "matrix-devices"
	| "matrix-marketplace"
	| "matrix-settings";
export type ZoneGazeMatrixModulePackageMode = "skeleton" | "installable-plugin" | "downloadable-plugin";
export type ZoneGazeMatrixModuleSettingsMode = "always" | "when-installed" | "planned";
export type ZoneGazeProductRuntimeMode = "embedded" | "desktop-runtime" | "local-first" | "local-service";

export interface ZoneGazeProductResourceProfile {
	installerSizeMb: number;
	installedSizeMb: number;
	ramIdleMb: number;
	ramActiveMb: number;
}

export interface ZoneGazePlatformTarget {
	id: ZoneGazePlatformId;
	label: string;
	artifactLabel: string;
}

export interface ZoneGazeProductCatalogItem {
	id: ZoneGazeProductId;
	kind: ZoneGazeProductKind;
	name: string;
	publisher: string;
	priceLabel: string;
	statusLabel: ZoneGazeProductStatusLabel;
	category: string;
	runtimeMode: ZoneGazeProductRuntimeMode;
	shortDescription: string;
	longDescription: string;
	downloadUrl: string;
	sourcePath: string;
	capabilities: readonly string[];
	tags: readonly string[];
	resourceProfile: ZoneGazeProductResourceProfile;
	platforms: readonly ZoneGazePlatformTarget[];
}

export interface ZoneGazeMatrixModuleCatalogItem {
	id: ZoneGazeMatrixModuleId;
	productId?: ZoneGazeProductId;
	label: string;
	shortLabel: string;
	description: string;
	packageMode: ZoneGazeMatrixModulePackageMode;
	includedInSkeleton: boolean;
	defaultSidebarVisible: boolean;
	settingsMode: ZoneGazeMatrixModuleSettingsMode;
	settingsSections: readonly string[];
}

export const ZONEGAZE_PRODUCT_CATALOG: readonly ZoneGazeProductCatalogItem[] = [
	{
		id: "zonegaze-flow",
		kind: "plugin",
		name: "ZoneGaze Flow",
		publisher: "ZoneGaze",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Workflow",
		runtimeMode: "embedded",
		shortDescription: "Agent orchestration board, task worktrees, terminal sessions, Git review, and shipping.",
		longDescription:
			"Plan, run, review, and ship coding work from a project board designed for agent-supervised development. Flow keeps task state, worktrees, terminal sessions, Git history, and review decisions in one local workspace.",
		downloadUrl: "https://zonegaze.com/downloads",
		sourcePath: "flow/",
		capabilities: ["Coordinate coding agents", "Review diffs and Git history", "Ship commits and PRs"],
		tags: ["agents", "kanban", "git", "terminal", "projects"],
		resourceProfile: { installerSizeMb: 38, installedSizeMb: 180, ramIdleMb: 160, ramActiveMb: 420 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Mac app" },
			{ id: "android", label: "Android", artifactLabel: "Android app" },
			{ id: "cli", label: "CLI", artifactLabel: "Node runtime" },
		],
	},
	{
		id: "zonegaze-whispr",
		kind: "plugin",
		name: "ZoneGaze Whispr",
		publisher: "ZoneGaze",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Voice",
		runtimeMode: "desktop-runtime",
		shortDescription: "Local-first voice dictation for prompts, chat messages, review comments, notes, and history.",
		longDescription:
			"Dictate into Matrix surfaces with a local-first voice workflow. Whispr is most useful for long prompts, review comments, note capture, and hands-free coding sessions when paired with Flow, Code, Chat, or Joplin.",
		downloadUrl: "https://zonegaze.com/downloads",
		sourcePath: "plugins/whispr/",
		capabilities: ["Dictate into Flow", "Run as a Mac app", "Run as an Android app"],
		tags: ["dictation", "voice", "transcription", "notes", "accessibility"],
		resourceProfile: { installerSizeMb: 85, installedSizeMb: 260, ramIdleMb: 180, ramActiveMb: 950 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Mac app" },
			{ id: "android", label: "Android", artifactLabel: "Android app" },
			{ id: "web", label: "Web", artifactLabel: "Web renderer" },
		],
	},
	{
		id: "zonegaze-chat",
		kind: "plugin",
		name: "ZoneGaze Chat",
		publisher: "ZoneGaze",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Communication",
		runtimeMode: "local-first",
		shortDescription: "Project-aware chat module for prompts, agent context, and future shared conversations.",
		longDescription:
			"Keep project conversations next to the work they reference. Chat stores local conversation history, can attach Flow project context, accepts Whispr dictation, and exposes the real Flow Agent panel when a project agent is available.",
		downloadUrl: "https://zonegaze.com/downloads",
		sourcePath: "plugins/chat/",
		capabilities: ["Chat in the Matrix window", "Share project context", "Use joined settings"],
		tags: ["chat", "project context", "agent", "conversation", "export"],
		resourceProfile: { installerSizeMb: 6, installedSizeMb: 24, ramIdleMb: 55, ramActiveMb: 120 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Mac app module" },
			{ id: "android", label: "Android", artifactLabel: "Android app module" },
			{ id: "web", label: "Web", artifactLabel: "Web chat surface" },
		],
	},
	{
		id: "zonegaze-joplin",
		kind: "plugin",
		name: "ZoneGaze Joplin",
		publisher: "ZoneGaze",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Notes",
		runtimeMode: "local-first",
		shortDescription: "Notes and knowledge workspace module for project docs, research, and handoff context.",
		longDescription:
			"Write local notebooks and project notes without leaving Matrix. Joplin supports markdown drafting, project links, quick dictation inserts, import/export, and handoff-friendly knowledge capture.",
		downloadUrl: "https://zonegaze.com/downloads",
		sourcePath: "plugins/joplin/",
		capabilities: ["Keep project notes", "Use markdown knowledge", "Attach handoff context"],
		tags: ["notes", "markdown", "knowledge", "handoff", "projects"],
		resourceProfile: { installerSizeMb: 12, installedSizeMb: 48, ramIdleMb: 70, ramActiveMb: 150 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Mac app module" },
			{ id: "android", label: "Android", artifactLabel: "Android app module" },
			{ id: "web", label: "Web", artifactLabel: "Web notes surface" },
		],
	},
	{
		id: "zonegaze-code",
		kind: "plugin",
		name: "ZoneGaze Code",
		publisher: "ZoneGaze",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Development",
		runtimeMode: "desktop-runtime",
		shortDescription: "Workspace IDE for editing project files from Matrix on Mac and Android.",
		longDescription:
			"Open a project workspace in a full IDE surface while Matrix remains the control layer. Code pairs naturally with Flow tasks and Whispr dictation for implementation, search, terminal commands, and review notes.",
		downloadUrl: "https://zonegaze.com/downloads",
		sourcePath: "plugins/code/",
		capabilities: ["Open project workspaces", "Run ZoneGaze Code on Mac", "Run code-server on Android"],
		tags: ["ide", "code", "workspace", "terminal", "development"],
		resourceProfile: { installerSizeMb: 180, installedSizeMb: 620, ramIdleMb: 420, ramActiveMb: 1400 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Mac app" },
			{ id: "android", label: "Android", artifactLabel: "Android Termux adapter" },
			{ id: "web", label: "Web", artifactLabel: "Browser IDE surface" },
		],
	},
	{
		id: "zonegaze-git",
		kind: "plugin",
		name: "ZoneGaze Git",
		publisher: "ZoneGaze",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Development",
		runtimeMode: "local-first",
		shortDescription: "Device Git setup, repository status, history, and project Git actions for Matrix.",
		longDescription:
			"Configure Git identity, credential helpers, SSH keys, repository status, history, and sync actions from Matrix. Git connects project state across Flow, Code, Chat, Joplin, Design, and Research without adding a second Git engine.",
		downloadUrl: "https://zonegaze.com/downloads",
		sourcePath: "plugins/git/",
		capabilities: ["Configure device Git", "Review repository history", "Sync project repositories"],
		tags: ["git", "version control", "repository", "history", "projects"],
		resourceProfile: { installerSizeMb: 6, installedSizeMb: 26, ramIdleMb: 55, ramActiveMb: 160 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Mac app module" },
			{ id: "web", label: "Web", artifactLabel: "Web Git surface" },
			{ id: "cli", label: "CLI", artifactLabel: "Flow runtime bridge" },
		],
	},
	{
		id: "open-design",
		kind: "plugin",
		name: "Open Design",
		publisher: "nexu-io",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Design",
		runtimeMode: "local-first",
		shortDescription: "Design workspace for prototypes, automations, design systems, plugins, and exports.",
		longDescription:
			"Start a local design workspace inside Matrix with Home, Automation, Design System, plugin registry, Integrations, and Studio surfaces for project-scoped design work.",
		downloadUrl: "https://github.com/nexu-io/open-design",
		sourcePath: "plugins/open-design/",
		capabilities: ["Use Studio", "Run design automations", "Manage plugins and integrations"],
		tags: ["design", "artifacts", "prototype", "automation", "export"],
		resourceProfile: { installerSizeMb: 280, installedSizeMb: 420, ramIdleMb: 220, ramActiveMb: 900 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Desktop runtime adapter" },
			{ id: "android", label: "Android", artifactLabel: "Android Matrix workspace" },
			{ id: "web", label: "Web", artifactLabel: "Embedded design workspace" },
		],
	},
	{
		id: "exo",
		kind: "plugin",
		name: "Exo",
		publisher: "exo-explore",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "AI Runtime",
		runtimeMode: "local-service",
		shortDescription: "Local frontier AI runtime that connects devices into an AI cluster.",
		longDescription:
			"Start and monitor a local model runtime dashboard from Matrix. Exo is intended for users who want local model visibility next to Flow, Code, and project orchestration workflows.",
		downloadUrl: "https://github.com/exo-explore/exo",
		sourcePath: "plugins/exo/",
		capabilities: ["Run frontier AI locally", "Coordinate device clusters", "Use compatible local model APIs"],
		tags: ["ai runtime", "models", "local service", "cluster", "dashboard"],
		resourceProfile: { installerSizeMb: 320, installedSizeMb: 1800, ramIdleMb: 350, ramActiveMb: 4096 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "macOS app" },
			{ id: "android", label: "Android", artifactLabel: "Android endpoint adapter" },
			{ id: "web", label: "Web", artifactLabel: "Cluster dashboard" },
			{ id: "cli", label: "CLI", artifactLabel: "Local runtime" },
		],
	},
	{
		id: "zonegaze-research",
		kind: "plugin",
		name: "ZoneGaze Research",
		publisher: "ZoneGaze",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Research",
		runtimeMode: "local-service",
		shortDescription: "Shared Deep Research capability for chats, agents, projects, and Matrix modules.",
		longDescription:
			"Run local-first web research through a reusable Matrix capability. Research sessions collect sources, citations, findings, and reports that can be reused by chats, project tools, agents, automations, and future modules.",
		downloadUrl: "https://zonegaze.com/downloads",
		sourcePath: "plugins/research/",
		capabilities: ["Run cited web research", "Reuse research artifacts", "Attach evidence to projects"],
		tags: ["research", "citations", "web", "agents", "knowledge"],
		resourceProfile: { installerSizeMb: 24, installedSizeMb: 110, ramIdleMb: 90, ramActiveMb: 650 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Mac app module" },
			{ id: "android", label: "Android", artifactLabel: "Android Flow runtime module" },
			{ id: "web", label: "Web", artifactLabel: "Web research surface" },
			{ id: "cli", label: "CLI", artifactLabel: "Local service bridge" },
		],
	},
	{
		id: "zonegaze-social-studio",
		kind: "plugin",
		name: "ZoneGaze Social Studio",
		publisher: "ZoneGaze",
		priceLabel: "Free",
		statusLabel: "Beta",
		category: "Marketing",
		runtimeMode: "local-first",
		shortDescription:
			"Local-first social-media workspace for asset intake, research, planning, publishing, analytics, and automation.",
		longDescription:
			"Coordinate social-media work from a modular Matrix plugin that keeps connectors, assets, research, post planning, publishing, analytics, and automation behind reusable local-first boundaries. Social Studio is designed to pair with BYO model and platform connectors instead of hard-coding paid services into the shell.",
		downloadUrl: "https://zonegaze.com/downloads",
		sourcePath: "plugins/social-studio/",
		capabilities: [
			"Manage social content workflows",
			"Bring your own AI and platform connectors",
			"Reuse research, assets, and publishing plans",
		],
		tags: ["social", "marketing", "content", "publishing", "analytics"],
		resourceProfile: { installerSizeMb: 14, installedSizeMb: 62, ramIdleMb: 90, ramActiveMb: 220 },
		platforms: [
			{ id: "macos", label: "Mac", artifactLabel: "Mac app module" },
			{ id: "android", label: "Android", artifactLabel: "Android app module" },
			{ id: "web", label: "Web", artifactLabel: "Web social workspace" },
		],
	},
];

export const ZONEGAZE_MATRIX_MODULE_CATALOG: readonly ZoneGazeMatrixModuleCatalogItem[] = [
	{
		id: "matrix-home",
		label: "Matrix Home",
		shortLabel: "Home",
		description:
			"The lightweight shell users download first: marketplace, plugin install state, and dashboard routing.",
		packageMode: "skeleton",
		includedInSkeleton: true,
		defaultSidebarVisible: false,
		settingsMode: "always",
		settingsSections: ["Marketplace", "Plugin install state", "Dashboard routing"],
	},
	{
		id: "zonegaze-flow",
		productId: "zonegaze-flow",
		label: "ZoneGaze Flow",
		shortLabel: "Flow",
		description: "Installable project board, task hierarchy, agent sessions, Git review, and release workflow.",
		packageMode: "installable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Agents", "Git prompts", "Project context", "Appearance"],
	},
	{
		id: "zonegaze-chat",
		productId: "zonegaze-chat",
		label: "ZoneGaze Chat",
		shortLabel: "Chat",
		description: "Installable same-window chat tab that can host project-aware shared conversations.",
		packageMode: "installable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Agent defaults", "Project context", "Conversation memory"],
	},
	{
		id: "zonegaze-joplin",
		productId: "zonegaze-joplin",
		label: "ZoneGaze Joplin",
		shortLabel: "Joplin",
		description: "Installable notes and knowledge workspace for project docs, research, and handoff context.",
		packageMode: "installable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Notes workspace", "Knowledge sync", "Project context"],
	},
	{
		id: "zonegaze-code",
		productId: "zonegaze-code",
		label: "ZoneGaze Code",
		shortLabel: "Code",
		description: "Workspace IDE module distributed as an optional plugin for Mac, Android, and web surfaces.",
		packageMode: "downloadable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Installed app", "Workspace launch", "IDE bridge"],
	},
	{
		id: "zonegaze-git",
		productId: "zonegaze-git",
		label: "ZoneGaze Git",
		shortLabel: "Git",
		description: "Git setup, repository status, history, and sync actions shared across Matrix plugins.",
		packageMode: "installable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Device setup", "Repository defaults", "Advanced Git UI"],
	},
	{
		id: "zonegaze-whispr",
		productId: "zonegaze-whispr",
		label: "ZoneGaze Whispr",
		shortLabel: "Whispr",
		description:
			"Voice dictation module distributed as an optional plugin for prompts, chat, notes, and review text.",
		packageMode: "downloadable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Installed app", "Dictation target", "Voice input"],
	},
	{
		id: "open-design",
		productId: "open-design",
		label: "Open Design",
		shortLabel: "Design",
		description: "Design workspace for Studio, automations, systems, plugins, and exports.",
		packageMode: "installable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Workspace", "Artifact history", "Agent integrations"],
	},
	{
		id: "exo",
		productId: "exo",
		label: "Exo",
		shortLabel: "Exo",
		description: "Local AI runtime dashboard for users who want model visibility beside Matrix workflows.",
		packageMode: "installable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Cluster runtime", "Local model APIs"],
	},
	{
		id: "zonegaze-research",
		productId: "zonegaze-research",
		label: "ZoneGaze Research",
		shortLabel: "Research",
		description: "Shared Deep Research capability for cited web research and reusable evidence artifacts.",
		packageMode: "installable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Research services", "Model providers", "Artifact library"],
	},
	{
		id: "zonegaze-social-studio",
		productId: "zonegaze-social-studio",
		label: "ZoneGaze Social Studio",
		shortLabel: "Social",
		description:
			"Installable social-media workspace for modular asset intake, research, planning, publishing, analytics, and automation.",
		packageMode: "installable-plugin",
		includedInSkeleton: false,
		defaultSidebarVisible: false,
		settingsMode: "when-installed",
		settingsSections: ["Workspace", "Connectors", "Publishing adapters", "Analytics adapters", "Automation"],
	},
	{
		id: "matrix-devices",
		label: "Linked Devices",
		shortLabel: "Devices",
		description: "Secure MacBook and Android device pairing, direct connection status, and user-owned relay setup.",
		packageMode: "skeleton",
		includedInSkeleton: true,
		defaultSidebarVisible: true,
		settingsMode: "always",
		settingsSections: ["Pairing", "Device trust", "User-owned relay", "Capabilities"],
	},
	{
		id: "matrix-marketplace",
		label: "Marketplace",
		shortLabel: "Market",
		description: "Same-window catalog for installing or opening optional ZoneGaze modules.",
		packageMode: "skeleton",
		includedInSkeleton: true,
		defaultSidebarVisible: true,
		settingsMode: "always",
		settingsSections: ["Downloads", "Donation support", "Module status"],
	},
	{
		id: "matrix-settings",
		label: "Joined Settings",
		shortLabel: "Settings",
		description: "One settings surface with core controls and plugin-only sections revealed after installation.",
		packageMode: "skeleton",
		includedInSkeleton: true,
		defaultSidebarVisible: false,
		settingsMode: "always",
		settingsSections: ["Core", "Flow", "Chat", "Installed plugins"],
	},
];

export function getZoneGazeProductCatalogItem(id: string): ZoneGazeProductCatalogItem | null {
	return ZONEGAZE_PRODUCT_CATALOG.find((item) => item.id === id) ?? null;
}

export function getZoneGazeMatrixModuleCatalogItem(id: string): ZoneGazeMatrixModuleCatalogItem | null {
	return ZONEGAZE_MATRIX_MODULE_CATALOG.find((item) => item.id === id) ?? null;
}
