import * as React from 'react';
import { Link } from 'react-router-dom';
/**
 *  Returns the friendly display form of the repository path (e.g., removing "github.com/").
 */
export function displayRepoPath(repoPath) {
    let parts = repoPath.split('/');
    if (parts.length >= 3 && parts[0].includes('.')) {
        parts = parts.slice(1); // remove hostname from repo path (reduce visual noise)
    }
    return parts.join('/');
}
/**
 * Splits the repository path into the dir and base components.
 */
export function splitPath(path) {
    const components = path.split('/');
    return [components.slice(0, -1).join('/'), components[components.length - 1]];
}
/**
 * A link to a repository or a file within a repository, formatted as "repo" or "repo > file". Unless you
 * absolutely need breadcrumb-like behavior, use this instead of FilePathBreadcrumb.
 */
export const RepoFileLink = ({ repoPath, repoURL, filePath, fileURL }) => {
    const [fileBase, fileName] = splitPath(filePath);
    return (React.createElement(React.Fragment, null,
        React.createElement(Link, { to: repoURL }, displayRepoPath(repoPath)),
        " \u203A",
        ' ',
        React.createElement(Link, { to: fileURL },
            fileBase ? `${fileBase}/` : null,
            React.createElement("strong", null, fileName))));
};
//# sourceMappingURL=RepoFileLink.js.map