import { DropdownItem, DropdownHeader, } from '@/features/ui/components/bootstrap-5/dropdown-menu' import { IdeLayout, IdeView, useLayoutContext, } from '@/shared/context/layout-context' import React, { useCallback } from 'react' import { useTranslation } from 'react-i18next' import * as eventTracking from '../../../../infrastructure/event-tracking' import useEventListener from '@/shared/hooks/use-event-listener' import { DetachRole } from '@/shared/context/detach-context' import { Spinner } from 'react-bootstrap-5' type LayoutOption = 'sideBySide' | 'editorOnly' | 'pdfOnly' | 'detachedPdf' const getActiveLayoutOption = ({ pdfLayout, view, detachRole, }: { pdfLayout: IdeLayout view: IdeView | null detachRole?: DetachRole }): LayoutOption | null => { if (view === 'history') { return null } if (detachRole === 'detacher') { return 'detachedPdf' } if (pdfLayout === 'flat' && (view === 'editor' || view === 'file')) { return 'editorOnly' } if (pdfLayout === 'flat' && view === 'pdf') { return 'pdfOnly' } if (pdfLayout === 'sideBySide') { return 'sideBySide' } return null } const LayoutDropdownItem = ({ active, disabled = false, processing = false, leadingIcon, onClick, children, }: { active: boolean leadingIcon: string onClick: () => void children: React.ReactNode processing?: boolean disabled?: boolean }) => { let trailingIcon: string | React.ReactNode | null = null if (processing) { trailingIcon = (