import * as Cookie from 'js-cookie';

// Readme Libs
import supportedLanguages from '@readme/oas-to-snippet/src/supportedLanguages';
import { uppercase } from '@readme/syntax-highlighter';

const defaultLanguage = () => {
  const language = Cookie.get('readme_language');

  if (language && supportedLanguages[language]) {
    return {
      code: '',
      language,
      highlightedSyntax: supportedLanguages[language].highlight,
      name: uppercase(language),
    };
  }

  return {
    code: '',
    language: 'c',
    highlightedSyntax: 'text/x-csrc',
    name: 'C',
  };
};

const DEFAULT_ENDPOINT = {
  method: '',
  slug: '',
  title: '',
};

const DEFAULT_SNIPPET = {
  endpoint: DEFAULT_ENDPOINT,
  codeOptions: [defaultLanguage()],
};

const DEFAULT_STEP = {
  title: '',
  body: '',
  isOpen: true,
  lineNumbers: [''],
};

const DEFAULT_TUTORIAL = {
  backgroundColor: '#018FF4',
  emoji: '🦉',
  response: '{"success":true}',
  referenceDisplay: [],
  steps: [DEFAULT_STEP],
  snippet: DEFAULT_SNIPPET,
  title: 'Recipe Title',
  description: 'Recipe Description',
};

export { DEFAULT_ENDPOINT, DEFAULT_SNIPPET, DEFAULT_STEP, DEFAULT_TUTORIAL, defaultLanguage };
