/**
* The merge direction (git4idea's `MergeDirectionComponentFactory`): two link-style
* dropdowns, the base and the head, joined by "←". The base lists the branches of the
* connected repository's remote; the head lists the local branches and the branches of
* the chosen repository (the project's GitHub remotes and forks).
*/
import { useMemo, useState, type KeyboardEvent } from "react";
import { HighlightedText, Icon, List, Popup, SearchField, Select, T, fuzzyMatch, listNavigate } from "@/ui";
import { useTx } from "@/platform/i18n";
import { nameWithOwner, sameRepository, useGhRepository, type GHRemote } from "../data/repository";
import { ChooserPopup } from "../ui/ChooserPopup";
import {
baseText,
headBranchName,
headText,
localBranchesOf,
remoteBranchesOf,
sameHead,
type HeadBranch,
type RemoteBranchRef,
} from "./model";
import { setBaseBranch, setHead, useCreatePr } from "./store";
import styles from "./Create.module.css";
function DropDownLink(props: { text: string | null; label: string; onClick: (el: HTMLElement) => void }) {
const tx = useTx();
return (
);
}
export function DirectionSelector() {
const direction = useCreatePr((s) => s.direction);
const branches = useCreatePr((s) => s.branches);
const [open, setOpen] = useState<{ which: "base" | "head"; anchor: HTMLElement } | null>(null);
const baseBranches = useMemo(
() => (direction ? remoteBranchesOf(branches, direction.baseRepo.remote) : []),
[branches, direction],
);
if (!direction) return null;
return (