import type {
  BrowserPanelTab,
  BrowserWebTab,
} from '~/store/browser-panel'

import type {
  BrowserAddressSuggestion,
} from '../browser-panel.logic'

export const browserWebTabFixture = {
  kind: 'browser',
  id: 'browser-cradle',
  url: 'https://cradle.dev/docs',
  title: 'Cradle documentation',
  status: 'live',
  isLoading: false,
  canGoBack: true,
  canGoForward: false,
  faviconUrl: '/icon.png',
  lastCommittedUrl: 'https://cradle.dev/docs',
  lastError: null,
  sessionId: 'session-current',
  sessionTitle: 'Architecture review',
  scriptIds: [],
  customScripts: [],
  loading: false,
  favicon: null,
} satisfies BrowserWebTab

export const browserLoadingTabFixture = {
  ...browserWebTabFixture,
  id: 'browser-loading',
  title: 'Loading reference',
  url: 'https://developer.mozilla.org',
  isLoading: true,
  loading: true,
  faviconUrl: null,
} satisfies BrowserWebTab

export const browserPanelTabFixtures = [
  browserWebTabFixture,
  {
    ...browserWebTabFixture,
    id: 'browser-research',
    title: 'Runtime research',
    url: 'https://example.com/research',
    lastCommittedUrl: 'https://example.com/research',
    sessionId: 'session-research',
    sessionTitle: 'Research thread',
    faviconUrl: null,
  },
  {
    kind: 'workspace-file',
    id: 'file-readme',
    workspaceId: 'workspace-cradle',
    path: 'README.md',
    view: 'preview',
    title: 'README.md',
    loading: false,
    favicon: null,
  },
  {
    kind: 'workspace-diff',
    id: 'diff-browser',
    workspaceId: 'workspace-cradle',
    repositoryPath: '/workspace/cradle',
    paths: ['apps/web/src/features/browser/browser-panel.tsx'],
    title: 'Browser changes',
    loading: false,
    favicon: null,
  },
  {
    kind: 'pull-request',
    id: 'pull-request-71',
    owner: 'wibus-wee',
    repo: 'cradle-app',
    number: 71,
    workId: 'work-storybook',
    sessionId: 'session-current',
    title: 'PR #71',
    loading: false,
    favicon: null,
  },
  {
    kind: 'subagent',
    id: 'subagent-review',
    sessionId: 'session-current',
    threadId: 'thread-review',
    agentName: 'Reviewer',
    agentRole: 'Code review',
    title: 'Review agent',
    loading: false,
    favicon: null,
  },
  {
    kind: 'workflow',
    id: 'workflow-release',
    sessionId: 'session-current',
    toolCallId: 'tool-workflow',
    title: 'Release workflow',
    surface: {
      workflowName: 'Release',
      description: 'Verify and publish the desktop release.',
      status: 'running',
      taskId: 'task-release',
      taskType: 'release',
      runId: 'run-release',
      scriptPath: null,
      transcriptDir: null,
      sessionUrl: null,
      warning: null,
      error: null,
      phases: [],
      input: null,
      output: null,
      lifecycle: [],
      runtime: null,
    },
    loading: false,
    favicon: null,
  },
  {
    kind: 'side-conversation',
    id: 'side-conversation',
    parentSessionId: 'session-current',
    sideConversationId: 'side-review',
    providerSessionId: null,
    title: 'Implementation note',
    loading: false,
    favicon: null,
  },
  {
    kind: 'context-usage-report',
    id: 'context-usage',
    sessionId: 'session-current',
    sessionTitle: 'Architecture review',
    title: 'Context usage',
    loading: false,
    favicon: null,
  },
  {
    kind: 'launcher',
    id: 'launcher',
    title: 'New panel',
    loading: false,
    favicon: null,
  },
  {
    kind: 'tui',
    id: 'terminal',
    ptyId: 'pty-fixture',
    cwd: '/workspace/cradle',
    title: 'pnpm typecheck',
    loading: false,
    favicon: null,
  },
  {
    kind: 'plan-document',
    id: 'plan-document',
    sessionId: 'session-current',
    toolCallId: 'tool-plan',
    title: 'Implementation plan',
    text: '# Plan',
    loading: false,
    favicon: null,
  },
  {
    kind: 'plan-refine',
    id: 'plan-refine',
    sessionId: 'session-current',
    requestId: 'request-plan',
    title: 'Refine plan',
    text: '# Refine plan',
    loading: false,
    favicon: null,
  },
] satisfies BrowserPanelTab[]

export const browserAddressSuggestionFixtures = [
  {
    id: 'navigate:storybook',
    kind: 'navigate',
    title: 'Open storybook.js.org',
    detail: 'https://storybook.js.org/',
    url: 'https://storybook.js.org/',
  },
  {
    id: 'tab:runtime',
    kind: 'tab',
    title: 'Runtime research',
    detail: 'https://example.com/research',
    url: 'https://example.com/research',
    tabId: 'browser-research',
    faviconUrl: '/icon.png',
  },
  {
    id: 'history:component-story-format',
    kind: 'history',
    title: 'Component Story Format',
    detail: 'https://storybook.js.org/docs/api/csf',
    url: 'https://storybook.js.org/docs/api/csf',
  },
] satisfies BrowserAddressSuggestion[]
