import { CONTEXT_ITEM_CATEGORY_DEPENDENCY, CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_LOCAL_GIT, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST } from './constants';

/**
 * This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
 *
 * Please use the corresponding component in Duo-UI going forward.
 * All future development and maintenance for Duo components should take place in Duo-UI.
 *
 * For more details, see the migration epic: https://gitlab.com/groups/gitlab-org/-/epics/15344 or reach out to the Duo-Chat team in #g_duo_chat.
 */
const MOCK_CATEGORIES = [{
  label: 'Files',
  value: CONTEXT_ITEM_CATEGORY_FILE,
  icon: 'document'
}, {
  label: 'Local Git',
  value: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
  icon: 'git'
}, {
  label: 'Issues',
  value: CONTEXT_ITEM_CATEGORY_ISSUE,
  icon: 'issues'
}, {
  label: 'Merge Requests',
  value: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
  icon: 'merge-request'
}, {
  label: 'Dependencies',
  value: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
  icon: 'package'
}];
function getMockCategory(categoryValue) {
  return MOCK_CATEGORIES.find(cat => cat.value === categoryValue);
}
const MOCK_CONTEXT_FILE_CONTENT = `export function waterPlants() {
    console.log('sprinkle');
}`;
const MOCK_CONTEXT_FILE_DIFF_CONTENT = `diff --git a/src/plants/strawberry.ts b/src/plants/strawberry.ts
index 1234567..8901234 100644
--- a/src/plants/strawberry.ts
+++ b/src/plants/strawberry.ts
@@ -1,4 +1,4 @@
 export const strawberry = {
   name: 'Strawberry',
-  waterNeeds: 'moderate',
+  waterNeeds: 'high',
 };`;
const MOCK_CONTEXT_ITEM_FILE = {
  id: '123e4567-e89b-12d3-a456-426614174000',
  category: CONTEXT_ITEM_CATEGORY_FILE,
  metadata: {
    enabled: true,
    title: 'strawberry.ts',
    secondaryText: 'src/plants/strawberry.ts',
    subTypeLabel: 'Project file',
    icon: 'document',
    project: 'example/garden',
    relativePath: 'src/plants/strawberry.ts'
  }
};
const MOCK_CONTEXT_ITEM_FILE_DISABLED = {
  id: '323e4567-e89b-12d3-a456-426614174002',
  category: CONTEXT_ITEM_CATEGORY_FILE,
  metadata: {
    enabled: false,
    title: 'motorbike.cs',
    secondaryText: '/src/VehicleFoo/motorbike.cs',
    subTypeLabel: 'Project file',
    icon: 'document',
    project: 'example/vehicles',
    relativePath: '/src/VehicleFoo/motorbike.cs'
  }
};
const mockFiles = [MOCK_CONTEXT_ITEM_FILE, {
  id: '223e4567-e89b-12d3-a456-426614174001',
  category: CONTEXT_ITEM_CATEGORY_FILE,
  metadata: {
    enabled: true,
    title: 'potato.ts',
    secondaryText: '/src/plants/potato.ts',
    subTypeLabel: 'Project file',
    icon: 'document',
    project: 'example/garden',
    relativePath: '/src/plants/potato.ts'
  }
}, MOCK_CONTEXT_ITEM_FILE_DISABLED];
const MOCK_CONTEXT_ITEM_ISSUE = {
  id: '423e4567-e89b-12d3-a456-426614174003',
  category: CONTEXT_ITEM_CATEGORY_ISSUE,
  metadata: {
    enabled: true,
    title: 'Implement watering schedule',
    secondaryText: 'example/garden#1234',
    subTypeLabel: 'Issue',
    icon: 'issues',
    iid: 1234
  }
};
const MOCK_CONTEXT_ITEM_ISSUE_DISABLED = {
  id: 'c463fb31-2a4c-4f8e-a609-97230ac48ae5',
  category: CONTEXT_ITEM_CATEGORY_ISSUE,
  metadata: {
    enabled: false,
    disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
    title: `Fix vehicle colours and make them look real nice and colourful won't that be wonderful wow this issue title is really long I sure hope it's gonna wrap OK`,
    secondaryText: 'example/vehicle#91011',
    subTypeLabel: 'Issue',
    icon: 'issues',
    iid: 91011
  }
};
const mockIssues = [MOCK_CONTEXT_ITEM_ISSUE, {
  id: '523e4567-e89b-12d3-a456-426614174004',
  category: CONTEXT_ITEM_CATEGORY_ISSUE,
  metadata: {
    enabled: true,
    title: 'Refactor plant growth rates',
    secondaryText: 'example/garden#5678',
    subTypeLabel: 'Issue',
    icon: 'issues',
    iid: 5678
  }
}, MOCK_CONTEXT_ITEM_ISSUE_DISABLED];
const MOCK_CONTEXT_ITEM_MERGE_REQUEST = {
  id: '623e4567-e89b-12d3-a456-426614174005',
  category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
  metadata: {
    enabled: true,
    title: 'Improve database performance',
    secondaryText: 'example/garden!1122',
    subTypeLabel: 'Merge request',
    icon: 'merge-request',
    iid: 1122
  }
};
const MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED = {
  id: '4eb665fc-e5e1-49b0-9789-2a16964e461a',
  category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
  metadata: {
    enabled: false,
    disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
    title: 'Fix broken layout at small viewports',
    secondaryText: 'example/vehicle!5566',
    subTypeLabel: 'Merge request',
    icon: 'merge-request',
    iid: 5566
  }
};
const mockMergeRequests = [MOCK_CONTEXT_ITEM_MERGE_REQUEST, {
  id: '723e4567-e89b-12d3-a456-426614174006',
  category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
  metadata: {
    enabled: false,
    disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
    title: 'Add vehicle registration details',
    secondaryText: 'example/vehicle!3344',
    subTypeLabel: 'Merge request',
    icon: 'merge-request',
    iid: 3344
  }
}, MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED];
const MOCK_CONTEXT_ITEM_GIT_DIFF = {
  id: '6d88b466-0c38-48d6-b271-deda47f97cee',
  category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
  metadata: {
    enabled: true,
    title: 'Current working changes',
    secondaryText: 'main',
    subType: 'local_git',
    subTypeLabel: 'Local Git repository diff',
    icon: 'comparison',
    commitId: 'main',
    repositoryName: 'example/garden',
    gitType: 'diff'
  }
};
const MOCK_CONTEXT_ITEM_GIT_COMMIT = {
  id: '20f8caf94cb8f5e5f9dbd1a9ac32702321de201b',
  category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
  metadata: {
    enabled: true,
    title: 'fix: some bug fix commit',
    secondaryText: '20f8caf94cb8f5e5f9dbd1a9ac32702321de201b',
    subType: 'local_git',
    subTypeLabel: 'Local Git repository commit',
    icon: 'commit',
    commitId: '20f8caf94cb8f5e5f9dbd1a9ac32702321de201b',
    repositoryName: 'example/garden',
    gitType: 'commit'
  }
};
const mockGitItems = [MOCK_CONTEXT_ITEM_GIT_DIFF, {
  id: 'diff-example/garden',
  category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
  metadata: {
    enabled: true,
    title: 'Diff from default branch',
    secondaryText: 'main',
    subTypeLabel: 'Local Git repository diff',
    icon: 'comparison',
    commitId: 'main',
    repositoryName: 'example/garden',
    gitType: 'diff'
  }
}, MOCK_CONTEXT_ITEM_GIT_COMMIT, {
  id: '32b9b56b6de75b32909986755fbc470f20fb6fc0',
  category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
  metadata: {
    enabled: true,
    title: 'feat: add cool new feature',
    secondaryText: '32b9b56b6de75b32909986755fbc470f20fb6fc0',
    subTypeLabel: 'Local Git repository commit',
    icon: 'commit',
    commitId: '32b9b56b6de75b32909986755fbc470f20fb6fc0',
    repositoryName: 'example/garden',
    gitType: 'commit'
  }
}, {
  id: '775d7efdce25c1af48c55abcadbefd1f181b92ce',
  category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
  metadata: {
    enabled: true,
    title: 'fix: stop foo from bar when baz because customers ding',
    secondaryText: '775d7efdce25c1af48c55abcadbefd1f181b92ce',
    subTypeLabel: 'Local Git repository commit',
    icon: 'commit',
    commitId: '775d7efdce25c1af48c55abcadbefd1f181b92ce',
    repositoryName: 'example/garden',
    gitType: 'commit'
  }
}];
const MOCK_CONTEXT_ITEM_DEPENDENCY = {
  id: '823e4567-e89b-12d3-a456-426614174007',
  category: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
  content: JSON.stringify([{
    javascript: ['@types/node@16.11.7', '@vue/compiler-sfc@3.2.37', 'typescript@4.5.5', 'vue@3.2.37']
  }]),
  metadata: {
    enabled: true,
    title: 'example/garden',
    secondaryText: 'package.json',
    icon: 'package',
    subType: 'dependency',
    subTypeLabel: 'Project dependencies',
    project: 'example/garden'
  }
};
const MOCK_CONTEXT_ITEM_DEPENDENCY_DISABLED = {
  id: '923e4567-e89b-12d3-a456-426614174008',
  category: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
  content: JSON.stringify([{
    javascript: ['@types/node@16.11.7', '@vue/compiler-sfc@3.2.37', 'typescript@4.5.5', 'vue@3.2.37'],
    csharp: ['newtonsoft.json@13.0.1', 'microsoft.net.test.sdk@16.11.0']
  }]),
  metadata: {
    enabled: false,
    disabledReasons: ['Dependencies are not available for this project', 'Access restricted'],
    title: 'example/vehicle',
    secondaryText: 'package.json, vehicle.csproj',
    icon: 'package',
    subType: 'dependency',
    subTypeLabel: 'Project dependencies',
    project: 'example/vehicle'
  }
};
const mockDependencies = [MOCK_CONTEXT_ITEM_DEPENDENCY, MOCK_CONTEXT_ITEM_DEPENDENCY_DISABLED, {
  id: 'b23e4567-e89b-12d3-a456-426614174010',
  category: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
  content: JSON.stringify([{
    python: ['django@3.2.9', 'djangorestframework@3.12.4', 'psycopg2@2.9.2', 'celery@5.2.1'],
    csharp: ['newtonsoft.json@13.0.1', 'microsoft.net.test.sdk@16.11.0']
  }]),
  metadata: {
    enabled: true,
    title: 'example/backend',
    secondaryText: 'requirements.txt, some.backend.csproj',
    icon: 'package',
    subType: 'dependency',
    subTypeLabel: 'Project dependencies',
    project: 'example/backend'
  }
}, {
  id: 'c23e4567-e89b-12d3-a456-426614174011',
  category: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
  content: JSON.stringify([{
    javascript: ['jquery@3.5.1', 'backbone@1.4.0', 'underscore@1.13.1', 'moment@2.29.1']
  }]),
  metadata: {
    enabled: false,
    disabledReasons: ['Project is archived'],
    title: 'example/legacy',
    secondaryText: 'bower.json',
    icon: 'package',
    subType: 'dependency',
    subTypeLabel: 'Project dependencies',
    project: 'example/legacy'
  }
}];
const getMockContextItems = () => {
  const allItems = [...mockFiles, ...mockGitItems, ...mockIssues, ...mockMergeRequests, ...mockDependencies];

  // put disabled items in the back
  const disabledItems = allItems.filter(item => !item.metadata.enabled);
  const enabledItems = allItems.filter(item => item.metadata.enabled);
  return [...enabledItems, ...disabledItems];
};

export { MOCK_CATEGORIES, MOCK_CONTEXT_FILE_CONTENT, MOCK_CONTEXT_FILE_DIFF_CONTENT, MOCK_CONTEXT_ITEM_DEPENDENCY, MOCK_CONTEXT_ITEM_DEPENDENCY_DISABLED, MOCK_CONTEXT_ITEM_FILE, MOCK_CONTEXT_ITEM_FILE_DISABLED, MOCK_CONTEXT_ITEM_GIT_COMMIT, MOCK_CONTEXT_ITEM_GIT_DIFF, MOCK_CONTEXT_ITEM_ISSUE, MOCK_CONTEXT_ITEM_ISSUE_DISABLED, MOCK_CONTEXT_ITEM_MERGE_REQUEST, MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED, getMockCategory, getMockContextItems };
