/**
 * Models Feature Screen Registry
 * Define all screens in the models feature module
 */

import type { KbxScreenDefinition } from '@shared/contracts/kbx-types'

export const modelsListScreen: KbxScreenDefinition = {
  screenId: 'model-ops.models.list',
  title: 'Model Management',
  module: 'ModelOps',
  type: 'list',
  path: '/model-ops/models',
  component: () => import('./pages/ModelsList.vue'),
  permissions: ['model.read'],
  description: 'Manage trading models across their complete lifecycle',

  help: {
    title: 'Model Lifecycle',
    sections: [
      {
        title: 'Phases',
        content:
          'Models progress: Freeze → Mature → Score → Diagnose → Hypothesis → Challenger → Validate → Review → Manual Activation',
      },
      {
        title: 'Getting Started',
        content: 'Click "New" to create a model, or select an existing one to view details and manage transitions.',
      },
    ],
    relatedScreens: ['model-ops.shadow-run.list'],
  },

  grid: {
    columnDefs: [
      { field: 'modelId', header: 'Model ID', type: 'link', width: 150, pinned: 'left' },
      { field: 'name', header: 'Name', width: 200 },
      { field: 'phase', header: 'Phase', type: 'status', width: 120 },
      { field: 'active', header: 'Active', type: 'text', width: 80 },
      { field: 'lastValidation', header: 'Last Validation', type: 'datetime', width: 150 },
      { field: 'pbo', header: 'PBO', type: 'percentage', width: 80 },
      { field: 'dsr', header: 'DSR', type: 'percentage', width: 80 },
      { field: 'returnMtd', header: 'Return (YTD)', type: 'money', width: 120 },
      { field: 'createdAt', header: 'Created', type: 'datetime', width: 150 },
    ],
    pageSize: 50,
    serverSideDatasource: true,
  },

  shortcuts: [
    { key: 'F3', label: 'Search', action: 'search' },
    { key: 'Ctrl+N', label: 'New Model', action: 'new' },
  ],

  telemetry: { enabled: true },
}

export const modelsDetailScreen: KbxScreenDefinition = {
  screenId: 'model-ops.models.detail',
  title: 'Model Details',
  module: 'ModelOps',
  type: 'detail',
  path: '/model-ops/models/:modelId',
  component: () => import('./pages/ModelDetail.vue'),
  permissions: ['model.read'],
  description: 'View and manage model configuration, validation history, and phase transitions',

  help: {
    title: 'Model Management',
    sections: [
      {
        title: 'Activation Requirements',
        content:
          'Before activating a model: 252+ trading-day shadow run, PBO < 20%, DSR > 0.5, OOS < 2.5%, plus maker-checker approval.',
      },
      {
        title: 'Phase Transitions',
        content:
          'Models cannot auto-promote. Each phase requires explicit review and approval. Check phase breakdown for regime-specific performance.',
      },
    ],
    relatedScreens: ['model-ops.models.list', 'model-ops.shadow-run.list'],
  },

  shortcuts: [
    { key: 'Escape', label: 'Back to List', action: 'back' },
    { key: 'Ctrl+E', label: 'Export Report', action: 'export' },
  ],

  telemetry: { enabled: true },
}

/**
 * All screens in models module
 */
export const modelScreens: KbxScreenDefinition[] = [modelsListScreen, modelsDetailScreen]
