<commit_before>import * as React from 'react';
import sortedUniqBy from 'lodash/sortedUniqBy';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import VersionsContext from 'docs/src/pages/versions/VersionsContext';
import { demos, docs, demoComponents } from 'docs/src/pages/versions/versions.md?@mui/markdown';

export default function Page(props) {
  const { versions } = props;
  return (
    <VersionsContext.Provider value={versions}>
      <MarkdownDocs demos={demos} docs={docs} demoComponents={demoComponents} />
    </VersionsContext.Provider>
  );
}

function formatVersion(version) {
  return version
    .replace('v', '')
    .split('.')
    .map((n) => +n + 1000)
    .join('.');
}

async function getBranches() {
  const githubAuthorizationToken = process.env.GITHUB_AUTH || '';

  const result = await fetch('https://api.github.com/repos/mui-org/material-ui-docs/branches', {
    headers: {
      Authorization: `Basic ${Buffer.from(githubAuthorizationToken).toString('base64')}`,
    },
  });
  const text = await result.text();

  if (result.status !== 200) {
    throw new Error(text);
  }

  return JSON.parse(text);
}

Page.getInitialProps = async () => {
  const FILTERED_BRANCHES = ['latest', 'l10n', 'next', 'material-ui.com'];

  const branches = await getBranches();
  /**
   * @type {import('docs/src/pages/versions/VersionsContext').VersionsContextValue}
   */
  const versions = [];
  branches.forEach((branch) => {
    if (FILTERED_BRANCHES.indexOf(branch.name) === -1) {
      const version = branch.name;
      versions.push({
        version,
        // Replace dot with dashes for Netlify branch subdomains
        url: `https://${version.replace(/\./g, '-')}.mui.com`,
      });
    }
  });
  // Current version.
  versions.push({
    version: `v${process.env.LIB_VERSION}`,
    url: 'https://mui.com',
  });
  // Legacy documentation.
  versions.push({
    version: 'v0',
    url: 'https://v0.mui.com',
  });
  versions.sort((a, b) => formatVersion(b.version).localeCompare(formatVersion(a.version)));

  if (
    branches.find((branch) => branch.name === 'next') &&<commit_msg>[docs] Remove migration from the releases page (#30863)<commit_after>import * as React from 'react';
import sortedUniqBy from 'lodash/sortedUniqBy';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import VersionsContext from 'docs/src/pages/versions/VersionsContext';
import { demos, docs, demoComponents } from 'docs/src/pages/versions/versions.md?@mui/markdown';

export default function Page(props) {
  const { versions } = props;
  return (
    <VersionsContext.Provider value={versions}>
      <MarkdownDocs demos={demos} docs={docs} demoComponents={demoComponents} />
    </VersionsContext.Provider>
  );
}

function formatVersion(version) {
  return version
    .replace('v', '')
    .split('.')
    .map((n) => +n + 1000)
    .join('.');
}

async function getBranches() {
  const githubAuthorizationToken = process.env.GITHUB_AUTH || '';

  const result = await fetch('https://api.github.com/repos/mui-org/material-ui-docs/branches', {
    headers: {
      Authorization: `Basic ${Buffer.from(githubAuthorizationToken).toString('base64')}`,
    },
  });
  const text = await result.text();

  if (result.status !== 200) {
    throw new Error(text);
  }

  return JSON.parse(text);
}

Page.getInitialProps = async () => {
  const FILTERED_BRANCHES = ['latest', 'l10n', 'next', 'migration', 'material-ui.com'];

  const branches = await getBranches();
  /**
   * @type {import('docs/src/pages/versions/VersionsContext').VersionsContextValue}
   */
  const versions = [];
  branches.forEach((branch) => {
    if (FILTERED_BRANCHES.indexOf(branch.name) === -1) {
      const version = branch.name;
      versions.push({
        version,
        // Replace dot with dashes for Netlify branch subdomains
        url: `https://${version.replace(/\./g, '-')}.mui.com`,
      });
    }
  });
  // Current version.
  versions.push({
    version: `v${process.env.LIB_VERSION}`,
    url: 'https://mui.com',
  });
  // Legacy documentation.
  versions.push({
    version: 'v0',
    url: 'https://v0.mui.com',
  });
  versions.sort((a, b) => formatVersion(b.version).localeCompare(formatVersion(a.version)));

  if (
    branches.find((branch) => branch.name === 'next') &&
{'fraction_non_alphanumeric': 0.17218236519324231, 'fraction_numerical': 0.007637121036797038, 'mean_word_length': 3.5929861849096705, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1421683', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1390, 'n_words': 270}