"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useTimelineRowHighlightBackground = exports.useTimelineRowContainsSelection = exports.useTimelineGuideSelection = exports.useTimelineEasingSelection = exports.useTimelineKeyframeSelection = exports.useTimelineRowSelection = exports.useTimelineFocusableItem = exports.useTimelineMarqueeSelectableItem = exports.useTimelineMarqueeSelection = exports.useCurrentTimelineSelectionStateAsRef = exports.TIMELINE_SCRUBBER_ATTR = exports.TIMELINE_MARQUEE_ITEM_ATTR = exports.useTimelineSelection = exports.TimelineSelectionProvider = exports.TimelineSelectableItemsProvider = exports.TimelineSelectAllKeybindings = exports.getTimelineSequenceSelectionKey = exports.getSelectableTimelineItems = exports.getSelectableTimelineSequenceSelections = exports.getTimelineSelectionKey = exports.getTimelineSelectionFromNodePathInfo = exports.TimelineSelectionOrderProvider = exports.getTimelineMarqueeSelection = exports.timelineMarqueeRectsIntersect = exports.getClampedTimelineMarqueePoint = exports.getNormalizedTimelineMarqueeRect = exports.getAvailableTimelineSelectionState = exports.getTimelineSelectionAfterInteraction = exports.EMPTY_TIMELINE_SELECTION_STATE = exports.shouldSelectTimelineRowOnPointerDown = exports.isTimelineSelectionModifierEvent = exports.TIMELINE_TICKS_BACKGROUND = exports.TIMELINE_BACKGROUND = exports.getTimelineRowHighlightBackground = exports.getTimelineSelectedTrackHighlightStyle = exports.getTimelineColor = exports.getTimelineSelectedLabelStyle = exports.TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING = exports.TIMELINE_SELECTED_LABEL_TEXT = exports.TIMELINE_SELECTED_LABEL_BACKGROUND = exports.TIMELINE_SELECTED_BACKGROUND = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const studio_shared_1 = require("@remotion/studio-shared");
const react_1 = require("react");
const remotion_1 = require("remotion");
const client_id_1 = require("../../helpers/client-id");
const colors_1 = require("../../helpers/colors");
const interactivity_enabled_1 = require("../../helpers/interactivity-enabled");
const timeline_layout_1 = require("../../helpers/timeline-layout");
const timeline_node_path_key_1 = require("../../helpers/timeline-node-path-key");
const use_keybinding_1 = require("../../helpers/use-keybinding");
const z_index_1 = require("../../state/z-index");
const ExpandedTracksProvider_1 = require("../ExpandedTracksProvider");
const options_sidebar_tabs_1 = require("../options-sidebar-tabs");
const get_node_keyframes_1 = require("./get-node-keyframes");
const get_timeline_easing_segments_1 = require("./get-timeline-easing-segments");
const timeline_expanded_filter_1 = require("./timeline-expanded-filter");
const timeline_refs_1 = require("./timeline-refs");
const TimelineClipboardKeybindings_1 = require("./TimelineClipboardKeybindings");
const TimelineDeleteKeybindings_1 = require("./TimelineDeleteKeybindings");
exports.TIMELINE_SELECTED_BACKGROUND = colors_1.TIMELINE_SELECTED_BACKGROUND_COLOR;
exports.TIMELINE_SELECTED_LABEL_BACKGROUND = colors_1.TIMELINE_SELECTED_LABEL_BACKGROUND_COLOR;
exports.TIMELINE_SELECTED_LABEL_TEXT = colors_1.BLACK;
exports.TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING = 2;
const getTimelineSelectedLabelStyle = (selected, subcategory) => {
    return {
        paddingLeft: exports.TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING,
        paddingRight: exports.TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING,
        ...(selected
            ? {
                backgroundColor: subcategory
                    ? colors_1.WHITE_ALPHA_10
                    : exports.TIMELINE_SELECTED_LABEL_BACKGROUND,
            }
            : {}),
    };
};
exports.getTimelineSelectedLabelStyle = getTimelineSelectedLabelStyle;
const getTimelineColor = (selected, subcategory) => {
    return selected && !subcategory
        ? exports.TIMELINE_SELECTED_LABEL_TEXT
        : colors_1.WHITE_ALPHA_80;
};
exports.getTimelineColor = getTimelineColor;
const getTimelineSelectedTrackHighlightStyle = (timelineWidth, backgroundColor = exports.TIMELINE_SELECTED_BACKGROUND) => ({
    backgroundColor,
    bottom: 0,
    left: -timeline_layout_1.TIMELINE_PADDING,
    pointerEvents: 'none',
    position: 'absolute',
    top: 0,
    width: timelineWidth,
});
exports.getTimelineSelectedTrackHighlightStyle = getTimelineSelectedTrackHighlightStyle;
const getTimelineRowHighlightBackground = ({ showSelectedBackground, selected, containsSelection, }) => {
    return showSelectedBackground && (selected || containsSelection)
        ? exports.TIMELINE_SELECTED_BACKGROUND
        : undefined;
};
exports.getTimelineRowHighlightBackground = getTimelineRowHighlightBackground;
exports.TIMELINE_BACKGROUND = colors_1.TIMELINE_BACKGROUND_COLOR;
exports.TIMELINE_TICKS_BACKGROUND = colors_1.BACKGROUND;
const isTimelineSelectionModifierEvent = ({ shiftKey, metaKey, ctrlKey, }) => {
    return shiftKey || metaKey || ctrlKey;
};
exports.isTimelineSelectionModifierEvent = isTimelineSelectionModifierEvent;
const shouldSelectTimelineRowOnPointerDown = ({ selected, shiftKey, metaKey, ctrlKey, }) => {
    return (!selected || (0, exports.isTimelineSelectionModifierEvent)({ shiftKey, metaKey, ctrlKey }));
};
exports.shouldSelectTimelineRowOnPointerDown = shouldSelectTimelineRowOnPointerDown;
exports.EMPTY_TIMELINE_SELECTION_STATE = {
    selectedItems: [],
    anchor: null,
};
const getTimelineSelectionType = (item) => item.type;
const areTimelineSelectionTypesCompatible = (firstType, secondType) => {
    if (firstType === secondType) {
        return true;
    }
    return ((firstType === 'sequence-prop' && secondType === 'sequence-effect-prop') ||
        (firstType === 'sequence-effect-prop' && secondType === 'sequence-prop') ||
        (firstType === 'keyframe' && secondType === 'easing') ||
        (firstType === 'easing' && secondType === 'keyframe'));
};
const isTimelineSelectionCompatibleWithType = (item, type) => areTimelineSelectionTypesCompatible(getTimelineSelectionType(item), type);
const getTimelineSelectionAnchor = (selectedItems, previousAnchor, targetType) => {
    if (previousAnchor &&
        getTimelineSelectionType(previousAnchor) === targetType) {
        return previousAnchor;
    }
    for (let i = selectedItems.length - 1; i >= 0; i--) {
        const candidate = selectedItems[i];
        if (getTimelineSelectionType(candidate) === targetType) {
            return candidate;
        }
    }
    return null;
};
const getRangeSelection = ({ anchor, clickedItem, allSelectableItems, }) => {
    const anchorKey = (0, exports.getTimelineSelectionKey)(anchor);
    const clickedKey = (0, exports.getTimelineSelectionKey)(clickedItem);
    const orderedOfType = allSelectableItems.filter((item) => getTimelineSelectionType(item) === clickedItem.type);
    const anchorIndex = orderedOfType.findIndex((item) => (0, exports.getTimelineSelectionKey)(item) === anchorKey);
    const clickedIndex = orderedOfType.findIndex((item) => (0, exports.getTimelineSelectionKey)(item) === clickedKey);
    if (anchorIndex === -1 || clickedIndex === -1) {
        return [clickedItem];
    }
    const [from, to] = anchorIndex < clickedIndex
        ? [anchorIndex, clickedIndex]
        : [clickedIndex, anchorIndex];
    return orderedOfType.slice(from, to + 1);
};
const getTimelineSelectionAfterInteraction = ({ currentState, clickedItem, interaction, allSelectableItems, }) => {
    const { selectedItems, anchor: previousAnchor } = currentState;
    const clickedType = getTimelineSelectionType(clickedItem);
    if (clickedType === 'guide') {
        return {
            selectedItems: [clickedItem],
            anchor: clickedItem,
        };
    }
    const nextAnchor = getTimelineSelectionAnchor(selectedItems, previousAnchor, clickedType);
    const clickedKey = (0, exports.getTimelineSelectionKey)(clickedItem);
    if (interaction.shiftKey && nextAnchor) {
        return {
            selectedItems: getRangeSelection({
                anchor: nextAnchor,
                clickedItem,
                allSelectableItems,
            }),
            anchor: nextAnchor,
        };
    }
    if (interaction.toggleKey) {
        const compatibleItems = selectedItems.filter((item) => isTimelineSelectionCompatibleWithType(item, clickedType));
        const existingKeySet = new Set(compatibleItems.map(exports.getTimelineSelectionKey));
        if (existingKeySet.has(clickedKey)) {
            const toggledSelection = compatibleItems.filter((item) => (0, exports.getTimelineSelectionKey)(item) !== clickedKey);
            return {
                selectedItems: toggledSelection,
                anchor: toggledSelection.length === 0 ? null : clickedItem,
            };
        }
        const selectableOrderMap = new Map(allSelectableItems
            .filter((item) => isTimelineSelectionCompatibleWithType(item, clickedType))
            .map((item, index) => [(0, exports.getTimelineSelectionKey)(item), index]));
        const extendedSelection = [...compatibleItems, clickedItem].sort((a, b) => {
            var _a, _b;
            return (((_a = selectableOrderMap.get((0, exports.getTimelineSelectionKey)(a))) !== null && _a !== void 0 ? _a : 0) -
                ((_b = selectableOrderMap.get((0, exports.getTimelineSelectionKey)(b))) !== null && _b !== void 0 ? _b : 0));
        });
        return {
            selectedItems: extendedSelection,
            anchor: clickedItem,
        };
    }
    return {
        selectedItems: [clickedItem],
        anchor: clickedItem,
    };
};
exports.getTimelineSelectionAfterInteraction = getTimelineSelectionAfterInteraction;
const getAvailableTimelineSelectionState = ({ availableKeys, availableItemsByKey, state, }) => {
    if (state.selectedItems.length === 0 && state.anchor === null) {
        return state;
    }
    const getCurrentSelectionItem = (item) => {
        var _a;
        const key = (0, exports.getTimelineSelectionKey)(item);
        if (!availableKeys.has(key)) {
            return null;
        }
        return (_a = availableItemsByKey === null || availableItemsByKey === void 0 ? void 0 : availableItemsByKey.get(key)) !== null && _a !== void 0 ? _a : item;
    };
    const selectedItems = state.selectedItems
        .map(getCurrentSelectionItem)
        .filter((item) => item !== null);
    const anchor = state.anchor ? getCurrentSelectionItem(state.anchor) : null;
    if (selectedItems.length === state.selectedItems.length &&
        anchor === state.anchor) {
        return state;
    }
    return {
        selectedItems,
        anchor,
    };
};
exports.getAvailableTimelineSelectionState = getAvailableTimelineSelectionState;
const getNormalizedTimelineMarqueeRect = ({ startX, startY, currentX, currentY, }) => ({
    left: Math.min(startX, currentX),
    top: Math.min(startY, currentY),
    right: Math.max(startX, currentX),
    bottom: Math.max(startY, currentY),
});
exports.getNormalizedTimelineMarqueeRect = getNormalizedTimelineMarqueeRect;
const getClampedTimelineMarqueePoint = ({ x, y, bounds, }) => ({
    x: Math.min(bounds.right, Math.max(bounds.left, x)),
    y: Math.min(bounds.bottom, Math.max(bounds.top, y)),
});
exports.getClampedTimelineMarqueePoint = getClampedTimelineMarqueePoint;
const timelineMarqueeRectsIntersect = (a, b) => a.left <= b.right &&
    a.right >= b.left &&
    a.top <= b.bottom &&
    a.bottom >= b.top;
exports.timelineMarqueeRectsIntersect = timelineMarqueeRectsIntersect;
const getTimelineMarqueeSelectionKind = (item) => {
    if (item.type === 'sequence') {
        return 'sequence';
    }
    if (item.type === 'keyframe' || item.type === 'easing') {
        return 'keyframes-and-easings';
    }
    return null;
};
const isTimelineSelectionCompatibleWithMarqueeKind = (item, kind) => {
    if (kind === 'sequence') {
        return item.type === 'sequence';
    }
    return item.type === 'keyframe' || item.type === 'easing';
};
const getTimelineMarqueeSelection = ({ candidates, lockedSelectionKind, marqueeRect, }) => {
    const geometricallyIntersectingCandidates = candidates.filter((candidate) => {
        return (getTimelineMarqueeSelectionKind(candidate.item) !== null &&
            (0, exports.timelineMarqueeRectsIntersect)(candidate.rect, marqueeRect));
    });
    const intersectingKeyframes = new Set(geometricallyIntersectingCandidates.flatMap((candidate) => {
        if (candidate.item.type !== 'keyframe') {
            return [];
        }
        return [
            `${(0, timeline_node_path_key_1.timelineNodePathInfoToKey)(candidate.item.nodePathInfo)}.${candidate.item.frame}`,
        ];
    }));
    const intersectingCandidates = geometricallyIntersectingCandidates.filter((candidate) => {
        if (candidate.item.type !== 'easing') {
            return true;
        }
        const fieldKey = (0, timeline_node_path_key_1.timelineNodePathInfoToKey)(candidate.item.nodePathInfo);
        return (intersectingKeyframes.has(`${fieldKey}.${candidate.item.fromFrame}`) &&
            intersectingKeyframes.has(`${fieldKey}.${candidate.item.toFrame}`));
    });
    const getFirstIntersectingSelectionKind = () => intersectingCandidates.length === 0
        ? null
        : getTimelineMarqueeSelectionKind(intersectingCandidates[0].item);
    let nextLockedSelectionKind = lockedSelectionKind !== null && lockedSelectionKind !== void 0 ? lockedSelectionKind : getFirstIntersectingSelectionKind();
    const getSelectedItemsForKind = (kind) => intersectingCandidates
        .filter((candidate) => isTimelineSelectionCompatibleWithMarqueeKind(candidate.item, kind))
        .map((candidate) => candidate.item);
    if (nextLockedSelectionKind === null) {
        return { lockedSelectionKind: null, selectedItems: [] };
    }
    let selectedItems = getSelectedItemsForKind(nextLockedSelectionKind);
    if (lockedSelectionKind !== null && selectedItems.length === 0) {
        nextLockedSelectionKind = getFirstIntersectingSelectionKind();
        selectedItems =
            nextLockedSelectionKind === null
                ? []
                : getSelectedItemsForKind(nextLockedSelectionKind);
    }
    return {
        lockedSelectionKind: nextLockedSelectionKind,
        selectedItems,
    };
};
exports.getTimelineMarqueeSelection = getTimelineMarqueeSelection;
const defaultTimelineSelectionContextValue = {
    canSelect: false,
    selectedItems: [],
    isSelected: () => false,
    selectItem: () => undefined,
    selectItems: () => undefined,
    registerMarqueeSelectableItem: () => () => undefined,
    registerFocusableItem: () => () => undefined,
    getMarqueeSelection: () => ({
        lockedSelectionKind: null,
        selectedItems: [],
    }),
    containsSelection: () => false,
    clearSelection: () => undefined,
};
const TimelineSelectionContext = (0, react_1.createContext)(defaultTimelineSelectionContextValue);
const EMPTY_SELECTABLE_TIMELINE_ITEMS = [];
const SelectableTimelineItemsContext = (0, react_1.createContext)({ current: EMPTY_SELECTABLE_TIMELINE_ITEMS });
const TimelineSelectionOrderProvider = ({ children, items }) => {
    const itemsRef = (0, react_1.useRef)(items);
    itemsRef.current = items;
    return (jsx_runtime_1.jsx(SelectableTimelineItemsContext.Provider, { value: itemsRef, children: children }));
};
exports.TimelineSelectionOrderProvider = TimelineSelectionOrderProvider;
const CurrentTimelineSelectionContext = (0, react_1.createContext)(null);
const TIMELINE_SELECTION_REVEAL_RETRY_COUNT = 2;
const parseEffectIndex = (effectIndex) => {
    const parsed = Number(effectIndex);
    if (!Number.isInteger(parsed) || parsed < 0) {
        return null;
    }
    return parsed;
};
const getTimelineSelectionFromNodePathInfo = (nodePathInfo) => {
    if (nodePathInfo === null) {
        return null;
    }
    const { auxiliaryKeys } = nodePathInfo;
    if (auxiliaryKeys.length === 0) {
        return { type: 'sequence', nodePathInfo };
    }
    if (auxiliaryKeys.length === 2 && auxiliaryKeys[0] === 'controls') {
        return { type: 'sequence-prop', nodePathInfo, key: auxiliaryKeys[1] };
    }
    if (auxiliaryKeys.length === 1 && auxiliaryKeys[0] === 'effects') {
        return { type: 'sequence-all-effects', nodePathInfo };
    }
    if (auxiliaryKeys[0] === 'effects') {
        const effectIndex = parseEffectIndex(auxiliaryKeys[1]);
        if (effectIndex === null) {
            return null;
        }
        if (auxiliaryKeys.length === 2) {
            return { type: 'sequence-effect', nodePathInfo, i: effectIndex };
        }
        if (auxiliaryKeys.length === 3) {
            return {
                type: 'sequence-effect-prop',
                nodePathInfo,
                i: effectIndex,
                key: auxiliaryKeys[2],
            };
        }
    }
    return null;
};
exports.getTimelineSelectionFromNodePathInfo = getTimelineSelectionFromNodePathInfo;
const getTimelineSelectionKey = (item) => {
    switch (item.type) {
        case 'guide':
            return `guide.${item.guideId}`;
        case 'sequence':
            return `${(0, exports.getTimelineSequenceSelectionKey)(item.nodePathInfo)}.sequence`;
        case 'sequence-prop':
            return `${(0, exports.getTimelineSequenceSelectionKey)(item.nodePathInfo)}.sequence-prop.${item.key}`;
        case 'sequence-all-effects':
            return `${(0, exports.getTimelineSequenceSelectionKey)(item.nodePathInfo)}.sequence-all-effects`;
        case 'sequence-effect':
            return `${(0, exports.getTimelineSequenceSelectionKey)(item.nodePathInfo)}.sequence-effect.${item.i}`;
        case 'sequence-effect-prop':
            return `${(0, exports.getTimelineSequenceSelectionKey)(item.nodePathInfo)}.sequence-effect-prop.${item.i}.${item.key}`;
        case 'keyframe':
            return `${(0, timeline_node_path_key_1.timelineNodePathInfoToKey)(item.nodePathInfo)}.keyframe.${item.frame}`;
        case 'easing':
            return `${(0, timeline_node_path_key_1.timelineNodePathInfoToKey)(item.nodePathInfo)}.easing.${item.segmentIndex}`;
        default:
            throw new Error(`Unexpected timeline selection type: ${item}`);
    }
};
exports.getTimelineSelectionKey = getTimelineSelectionKey;
const nodePathDescendsFrom = (descendant, ancestor) => {
    if ((0, studio_shared_1.stringifySequenceExpandedRowKey)(descendant.sequenceSubscriptionKey) !==
        (0, studio_shared_1.stringifySequenceExpandedRowKey)(ancestor.sequenceSubscriptionKey)) {
        return false;
    }
    if (descendant.index !== ancestor.index) {
        return false;
    }
    // Must be strictly deeper than `ancestor` (i.e. a descendant), not the same row.
    if (descendant.auxiliaryKeys.length <= ancestor.auxiliaryKeys.length) {
        return false;
    }
    return ancestor.auxiliaryKeys.every((key, i) => descendant.auxiliaryKeys[i] === key);
};
const getSelectableTimelineSequenceSelections = (tracks) => {
    return tracks.flatMap((track) => {
        if (track.nodePathInfo === null ||
            track.nodePathInfo.auxiliaryKeys.length > 0) {
            return [];
        }
        return [{ type: 'sequence', nodePathInfo: track.nodePathInfo }];
    });
};
exports.getSelectableTimelineSequenceSelections = getSelectableTimelineSequenceSelections;
const getTimelineTreeNodeCanEditEasing = ({ node, nodePathInfo, propStatuses, }) => {
    var _a;
    if (node.kind !== 'field' || node.field === null) {
        return false;
    }
    if (node.field.kind === 'sequence-field') {
        const sequencePropStatus = (_a = remotion_1.Internals.getPropStatusesCtx(propStatuses, nodePathInfo.sequenceSubscriptionKey)) === null || _a === void 0 ? void 0 : _a[node.field.key];
        return ((sequencePropStatus === null || sequencePropStatus === void 0 ? void 0 : sequencePropStatus.status) === 'keyframed' &&
            (0, studio_shared_1.canEditEasingForInterpolationFunction)(sequencePropStatus.interpolationFunction));
    }
    const effectStatus = remotion_1.Internals.getEffectPropStatusesCtx({
        propStatuses,
        nodePath: nodePathInfo.sequenceSubscriptionKey,
        effectIndex: node.field.effectIndex,
    });
    const effectPropStatus = effectStatus.type === 'can-update-effect'
        ? effectStatus.props[node.field.key]
        : null;
    return ((effectPropStatus === null || effectPropStatus === void 0 ? void 0 : effectPropStatus.status) === 'keyframed' &&
        (0, studio_shared_1.canEditEasingForInterpolationFunction)(effectPropStatus.interpolationFunction));
};
const getSelectableTimelineItems = ({ getDragOverrides, getEffectDragOverrides, getIsExpanded, propStatuses, selectedItems, timeline, timelinePosition, }) => {
    const selectedRowKeys = (0, timeline_expanded_filter_1.getSelectedTimelineExpandedRowKeys)(selectedItems);
    return timeline.flatMap((track) => {
        const { nodePathInfo } = track;
        if (nodePathInfo === null) {
            return [];
        }
        const sequenceSelection = (0, exports.getTimelineSelectionFromNodePathInfo)(nodePathInfo);
        if (sequenceSelection === null) {
            return [];
        }
        if (!getIsExpanded(nodePathInfo)) {
            return [sequenceSelection];
        }
        const tree = (0, timeline_layout_1.buildTimelineTree)({
            sequence: track.sequence,
            nodePathInfo,
            getDragOverrides,
            getEffectDragOverrides,
            propStatuses,
            includeTextContent: false,
            includeSourceControls: false,
        });
        const filteredTree = (0, timeline_expanded_filter_1.filterTimelineExpandedTree)({
            nodes: tree,
            shouldShowNode: (node) => (0, timeline_expanded_filter_1.isTimelineExpandedNodeSelected)({
                nodePathInfo: node.nodePathInfo,
                selectedRowKeys,
            }) ||
                (0, get_node_keyframes_1.getNodeHasKeyframes)({
                    node,
                    nodePath: nodePathInfo.sequenceSubscriptionKey,
                    propStatuses,
                    getDragOverrides,
                    getEffectDragOverrides,
                }),
        });
        const visibleTreeRows = (0, timeline_layout_1.flattenVisibleTreeNodes)({
            nodes: filteredTree,
            getIsExpanded,
        });
        return [
            sequenceSelection,
            ...visibleTreeRows.flatMap(({ node }) => {
                const rowSelection = (0, exports.getTimelineSelectionFromNodePathInfo)(node.nodePathInfo);
                if (rowSelection === null) {
                    return [];
                }
                const keyframes = (0, get_node_keyframes_1.getNodeKeyframes)({
                    node,
                    nodePath: nodePathInfo.sequenceSubscriptionKey,
                    propStatuses,
                    keyframeDisplayOffset: track.keyframeDisplayOffset,
                    getDragOverrides,
                    getEffectDragOverrides,
                    timelinePosition,
                });
                const keyframeSelections = keyframes.map((keyframe) => ({
                    type: 'keyframe',
                    nodePathInfo: node.nodePathInfo,
                    frame: keyframe.frame,
                }));
                const easingSelections = getTimelineTreeNodeCanEditEasing({
                    node,
                    nodePathInfo,
                    propStatuses,
                })
                    ? (0, get_timeline_easing_segments_1.getTimelineEasingSegments)(keyframes).map((segment) => ({
                        type: 'easing',
                        nodePathInfo: node.nodePathInfo,
                        fromFrame: segment.fromFrame,
                        toFrame: segment.toFrame,
                        segmentIndex: segment.segmentIndex,
                    }))
                    : [];
                return [rowSelection, ...easingSelections, ...keyframeSelections];
            }),
        ];
    });
};
exports.getSelectableTimelineItems = getSelectableTimelineItems;
const getTimelineSequenceSelectionKey = (nodePathInfo) => (0, timeline_node_path_key_1.timelineNodePathInfoToKey)({ ...nodePathInfo, auxiliaryKeys: [] });
exports.getTimelineSequenceSelectionKey = getTimelineSequenceSelectionKey;
const TimelineSelectAllKeybindings = ({ timeline }) => {
    const keybindings = (0, use_keybinding_1.useKeybinding)();
    const { canSelect } = (0, exports.useTimelineSelection)();
    const currentSelection = (0, exports.useCurrentTimelineSelectionStateAsRef)();
    const selectableSequenceSelections = (0, react_1.useMemo)(() => (0, exports.getSelectableTimelineSequenceSelections)(timeline), [timeline]);
    const selectableSequenceSelectionsRef = (0, react_1.useRef)(selectableSequenceSelections);
    selectableSequenceSelectionsRef.current = selectableSequenceSelections;
    (0, react_1.useEffect)(() => {
        if (!canSelect) {
            return;
        }
        const selectAll = keybindings.registerKeybinding({
            event: 'keydown',
            key: 'a',
            callback: () => {
                const latestSelectableSequenceSelections = selectableSequenceSelectionsRef.current;
                if (latestSelectableSequenceSelections.length === 0) {
                    return;
                }
                currentSelection.current.selectItems(latestSelectableSequenceSelections);
            },
            commandCtrlKey: true,
            preventDefault: true,
            triggerIfInputFieldFocused: false,
            keepRegisteredWhenNotHighestContext: false,
        });
        return () => {
            selectAll.unregister();
        };
    }, [canSelect, currentSelection, keybindings]);
    return null;
};
exports.TimelineSelectAllKeybindings = TimelineSelectAllKeybindings;
const TimelineEscapeKeybindings = () => {
    const keybindings = (0, use_keybinding_1.useKeybinding)();
    const currentSelection = (0, exports.useCurrentTimelineSelectionStateAsRef)();
    (0, react_1.useEffect)(() => {
        const escape = keybindings.registerKeybinding({
            event: 'keydown',
            key: 'Escape',
            callback: (event) => {
                const { selectedItems, clearSelection } = currentSelection.current;
                if (selectedItems.length === 0) {
                    return;
                }
                clearSelection();
                event.preventDefault();
            },
            commandCtrlKey: false,
            preventDefault: false,
            triggerIfInputFieldFocused: false,
            keepRegisteredWhenNotHighestContext: false,
        });
        return () => {
            escape.unregister();
        };
    }, [currentSelection, keybindings]);
    return null;
};
const TimelineSelectableItemsProvider = ({ children, timeline }) => {
    const { getIsExpanded } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksGetterContext);
    const { propStatuses } = (0, react_1.useContext)(remotion_1.Internals.VisualModePropStatusesContext);
    const { getDragOverrides, getEffectDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeDragOverridesContext);
    const timelinePosition = remotion_1.Internals.Timeline.useTimelinePosition();
    const { selectedItems } = (0, exports.useTimelineSelection)();
    const selectableItems = (0, react_1.useMemo)(() => (0, exports.getSelectableTimelineItems)({
        getDragOverrides,
        getEffectDragOverrides,
        getIsExpanded,
        propStatuses,
        selectedItems,
        timeline,
        timelinePosition,
    }), [
        getDragOverrides,
        getEffectDragOverrides,
        getIsExpanded,
        propStatuses,
        selectedItems,
        timeline,
        timelinePosition,
    ]);
    return (jsx_runtime_1.jsx(exports.TimelineSelectionOrderProvider, { items: selectableItems, children: children }));
};
exports.TimelineSelectableItemsProvider = TimelineSelectableItemsProvider;
const TimelineSelectionProvider = ({ children }) => {
    const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
    const { canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
    const timelineSelectionScope = (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition' ? canvasContent.compositionId : null;
    const { expandParentTracks } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksSetterContext);
    const canSelect = interactivity_enabled_1.studioInteractivityEnabled &&
        previewServerState.type === 'connected' &&
        !window.remotion_isReadOnlyStudio;
    const [selectedItems, setSelectedItems] = (0, react_1.useState)([]);
    const selectionAnchor = (0, react_1.useRef)(null);
    const selectionScope = (0, react_1.useRef)(null);
    const marqueeSelectableItems = (0, react_1.useRef)(new Map());
    const marqueeRegistrationCounter = (0, react_1.useRef)(0);
    const focusableItems = (0, react_1.useRef)(new Map());
    const focusableRegistrationCounter = (0, react_1.useRef)(0);
    const [revealRequest, setRevealRequest] = (0, react_1.useState)(null);
    (0, react_1.useEffect)(() => {
        if (!canSelect) {
            selectionScope.current = null;
            selectionAnchor.current = null;
            setRevealRequest(null);
            setSelectedItems([]);
        }
    }, [canSelect]);
    const canSelectItem = (0, react_1.useCallback)((_item) => canSelect, [canSelect]);
    const getCurrentAvailableSelectionState = (0, react_1.useCallback)((currentSelectedItems) => {
        if (selectionScope.current !== timelineSelectionScope) {
            return exports.EMPTY_TIMELINE_SELECTION_STATE;
        }
        return {
            selectedItems: currentSelectedItems,
            anchor: selectionAnchor.current,
        };
    }, [timelineSelectionScope]);
    const availableSelectionState = getCurrentAvailableSelectionState(selectedItems);
    const availableSelectedItems = availableSelectionState.selectedItems;
    const revealSelectionKey = (0, react_1.useCallback)((selectedKey) => {
        let cancelled = false;
        let animationFrame = null;
        const reveal = (attempt) => {
            var _a;
            var _b;
            if (cancelled) {
                return;
            }
            const scrollParent = timeline_refs_1.timelineVerticalScroll.current;
            const focusableRegistrations = focusableItems.current.get(selectedKey);
            const focusableElement = scrollParent && focusableRegistrations
                ? [...focusableRegistrations.values()]
                    .sort((a, b) => a.order - b.order)
                    .map((registered) => registered.getElement())
                    .find((element) => element !== null && scrollParent.contains(element))
                : null;
            const rect = (_b = focusableElement === null || focusableElement === void 0 ? void 0 : focusableElement.getBoundingClientRect()) !== null && _b !== void 0 ? _b : (_a = marqueeSelectableItems.current.get(selectedKey)) === null || _a === void 0 ? void 0 : _a.getRect();
            if (!scrollParent || !rect) {
                if (attempt < TIMELINE_SELECTION_REVEAL_RETRY_COUNT) {
                    animationFrame = requestAnimationFrame(() => reveal(attempt + 1));
                }
                return;
            }
            const parentRect = scrollParent.getBoundingClientRect();
            if (rect.top >= parentRect.top && rect.bottom <= parentRect.bottom) {
                return;
            }
            const elementCenter = rect.top + rect.height / 2;
            const parentCenter = parentRect.top + parentRect.height / 2;
            scrollParent.scrollTop += elementCenter - parentCenter;
        };
        animationFrame = requestAnimationFrame(() => reveal(0));
        return () => {
            cancelled = true;
            if (animationFrame !== null) {
                cancelAnimationFrame(animationFrame);
            }
        };
    }, []);
    (0, react_1.useEffect)(() => {
        if (revealRequest === null) {
            return;
        }
        return revealSelectionKey(revealRequest.key);
    }, [revealRequest, revealSelectionKey]);
    const requestRevealSelectionItem = (0, react_1.useCallback)((item) => {
        const key = (0, exports.getTimelineSelectionKey)(item);
        setRevealRequest((previousRequest) => {
            var _a;
            return ({
                key,
                token: ((_a = previousRequest === null || previousRequest === void 0 ? void 0 : previousRequest.token) !== null && _a !== void 0 ? _a : 0) + 1,
            });
        });
    }, []);
    const expandParentsForSelectionItems = (0, react_1.useCallback)((items) => {
        for (const item of items) {
            if (item.type === 'guide') {
                continue;
            }
            expandParentTracks(item.nodePathInfo);
        }
    }, [expandParentTracks]);
    const expandParentsForSelectionItem = (0, react_1.useCallback)((item) => {
        if (item.type === 'guide') {
            return;
        }
        expandParentTracks(item.nodePathInfo);
    }, [expandParentTracks]);
    (0, react_1.useEffect)(() => {
        setSelectedItems((currentSelectedItems) => {
            const nextState = selectionScope.current === timelineSelectionScope
                ? {
                    selectedItems: currentSelectedItems,
                    anchor: selectionAnchor.current,
                }
                : exports.EMPTY_TIMELINE_SELECTION_STATE;
            selectionScope.current = timelineSelectionScope;
            selectionAnchor.current = nextState.anchor;
            if (nextState.selectedItems.length === currentSelectedItems.length &&
                nextState.selectedItems.every((item, index) => item === currentSelectedItems[index])) {
                return currentSelectedItems;
            }
            return nextState.selectedItems;
        });
    }, [timelineSelectionScope]);
    const selectedKeys = (0, react_1.useMemo)(() => new Set(availableSelectedItems.map(exports.getTimelineSelectionKey)), [availableSelectedItems]);
    const isSelected = (0, react_1.useCallback)((item) => {
        return selectedKeys.has((0, exports.getTimelineSelectionKey)(item));
    }, [selectedKeys]);
    const selectItem = (0, react_1.useCallback)((item, interaction = {
        shiftKey: false,
        toggleKey: false,
    }, allSelectableItems = [], options = {}) => {
        if (!canSelectItem(item)) {
            return;
        }
        (0, options_sidebar_tabs_1.selectOptionsSidebarInspectorPanel)();
        expandParentsForSelectionItem(item);
        if (options.reveal) {
            requestRevealSelectionItem(item);
        }
        setSelectedItems((currentSelectedItems) => {
            const currentSelectionState = getCurrentAvailableSelectionState(currentSelectedItems);
            const nextState = (0, exports.getTimelineSelectionAfterInteraction)({
                currentState: {
                    selectedItems: currentSelectionState.selectedItems,
                    anchor: currentSelectionState.anchor,
                },
                clickedItem: item,
                interaction,
                allSelectableItems,
            });
            selectionScope.current = timelineSelectionScope;
            selectionAnchor.current = nextState.anchor;
            return nextState.selectedItems;
        });
    }, [
        canSelectItem,
        expandParentsForSelectionItem,
        getCurrentAvailableSelectionState,
        requestRevealSelectionItem,
        timelineSelectionScope,
    ]);
    const selectItems = (0, react_1.useCallback)((items, options = {}) => {
        if (!items.every(canSelectItem)) {
            return;
        }
        if (items.length > 0) {
            (0, options_sidebar_tabs_1.selectOptionsSidebarInspectorPanel)();
        }
        selectionScope.current = timelineSelectionScope;
        selectionAnchor.current =
            items.length === 0 ? null : items[items.length - 1];
        expandParentsForSelectionItems(items);
        if (options.reveal && items.length === 1) {
            requestRevealSelectionItem(items[0]);
        }
        setSelectedItems(items);
    }, [
        canSelectItem,
        expandParentsForSelectionItems,
        requestRevealSelectionItem,
        timelineSelectionScope,
    ]);
    const registerMarqueeSelectableItem = (0, react_1.useCallback)((item, getRect) => {
        const key = (0, exports.getTimelineSelectionKey)(item);
        const registrationOrder = marqueeRegistrationCounter.current;
        marqueeRegistrationCounter.current += 1;
        marqueeSelectableItems.current.set(key, {
            getRect,
            item,
            order: registrationOrder,
        });
        return () => {
            marqueeSelectableItems.current.delete(key);
        };
    }, []);
    const registerFocusableItem = (0, react_1.useCallback)((item, getElement) => {
        var _a;
        const key = (0, exports.getTimelineSelectionKey)(item);
        const registrationOrder = focusableRegistrationCounter.current;
        focusableRegistrationCounter.current += 1;
        const registrations = (_a = focusableItems.current.get(key)) !== null && _a !== void 0 ? _a : new Map();
        registrations.set(registrationOrder, {
            getElement,
            order: registrationOrder,
        });
        focusableItems.current.set(key, registrations);
        return () => {
            const latestRegistrations = focusableItems.current.get(key);
            latestRegistrations === null || latestRegistrations === void 0 ? void 0 : latestRegistrations.delete(registrationOrder);
            if ((latestRegistrations === null || latestRegistrations === void 0 ? void 0 : latestRegistrations.size) === 0) {
                focusableItems.current.delete(key);
            }
        };
    }, []);
    const getMarqueeSelectionForRect = (0, react_1.useCallback)((marqueeRect, lockedSelectionKind) => {
        const candidates = [...marqueeSelectableItems.current.values()]
            .sort((a, b) => a.order - b.order)
            .flatMap((candidate) => {
            if (!canSelectItem(candidate.item)) {
                return [];
            }
            const rect = candidate.getRect();
            if (rect === null) {
                return [];
            }
            return [
                {
                    item: candidate.item,
                    rect: {
                        bottom: rect.bottom,
                        left: rect.left,
                        right: rect.right,
                        top: rect.top,
                    },
                },
            ];
        });
        return (0, exports.getTimelineMarqueeSelection)({
            candidates,
            lockedSelectionKind,
            marqueeRect,
        });
    }, [canSelectItem]);
    const clearSelection = (0, react_1.useCallback)(() => {
        selectionScope.current = null;
        selectionAnchor.current = null;
        setSelectedItems([]);
    }, []);
    const containsSelection = (0, react_1.useCallback)((nodePathInfo) => {
        return availableSelectedItems.some((selected) => selected.type !== 'guide' &&
            nodePathDescendsFrom(selected.nodePathInfo, nodePathInfo));
    }, [availableSelectedItems]);
    const value = (0, react_1.useMemo)(() => ({
        canSelect,
        selectedItems: availableSelectedItems,
        isSelected,
        selectItem,
        selectItems,
        registerMarqueeSelectableItem,
        registerFocusableItem,
        getMarqueeSelection: getMarqueeSelectionForRect,
        containsSelection,
        clearSelection,
    }), [
        canSelect,
        availableSelectedItems,
        isSelected,
        selectItem,
        selectItems,
        registerMarqueeSelectableItem,
        registerFocusableItem,
        getMarqueeSelectionForRect,
        containsSelection,
        clearSelection,
    ]);
    const currentSelection = (0, react_1.useRef)(value);
    currentSelection.current = value;
    return (jsx_runtime_1.jsx(CurrentTimelineSelectionContext.Provider, { value: currentSelection, children: jsx_runtime_1.jsxs(TimelineSelectionContext.Provider, { value: value, children: [children, jsx_runtime_1.jsx(TimelineEscapeKeybindings, {}), jsx_runtime_1.jsx(TimelineClipboardKeybindings_1.TimelineClipboardKeybindings, {}), jsx_runtime_1.jsx(TimelineDeleteKeybindings_1.TimelineDeleteKeybindings, {})
            ] }) }));
};
exports.TimelineSelectionProvider = TimelineSelectionProvider;
const useTimelineSelection = () => {
    return (0, react_1.useContext)(TimelineSelectionContext);
};
exports.useTimelineSelection = useTimelineSelection;
exports.TIMELINE_MARQUEE_ITEM_ATTR = 'data-timeline-marquee-item';
exports.TIMELINE_SCRUBBER_ATTR = 'data-timeline-scrubber';
const useCurrentTimelineSelectionStateAsRef = () => {
    const currentSelection = (0, react_1.useContext)(CurrentTimelineSelectionContext);
    if (currentSelection === null) {
        throw new Error('useCurrentTimelineSelectionStateAsRef must be used inside TimelineSelectionProvider');
    }
    return currentSelection;
};
exports.useCurrentTimelineSelectionStateAsRef = useCurrentTimelineSelectionStateAsRef;
const useTimelineMarqueeSelection = () => {
    const { canSelect, getMarqueeSelection, selectItems } = (0, exports.useTimelineSelection)();
    const { isHighestContext } = (0, z_index_1.useZIndex)();
    const [marqueeRect, setMarqueeRect] = (0, react_1.useState)(null);
    const onPointerDownCapture = (0, react_1.useCallback)((event) => {
        if (!isHighestContext) {
            return;
        }
        if (event.button !== 0 || !canSelect) {
            return;
        }
        if (event.shiftKey || event.metaKey || event.ctrlKey) {
            return;
        }
        if (!(event.target instanceof Element)) {
            return;
        }
        if (event.target.closest(`[${exports.TIMELINE_MARQUEE_ITEM_ATTR}]`) ||
            event.target.closest(`[${exports.TIMELINE_SCRUBBER_ATTR}]`)) {
            return;
        }
        const { currentTarget: target, pointerId } = event;
        if (target.setPointerCapture) {
            target.setPointerCapture(pointerId);
        }
        const initialBounds = target.getBoundingClientRect();
        const marqueeBounds = {
            bottom: initialBounds.bottom,
            left: initialBounds.left,
            right: initialBounds.right,
            top: initialBounds.top,
        };
        const start = (0, exports.getClampedTimelineMarqueePoint)({
            bounds: marqueeBounds,
            x: event.clientX,
            y: event.clientY,
        });
        const startX = start.x;
        const startY = start.y;
        const previousUserSelect = document.body.style.userSelect;
        const previousWebkitUserSelect = document.body.style.webkitUserSelect;
        document.body.style.userSelect = 'none';
        document.body.style.webkitUserSelect = 'none';
        let hasDragged = false;
        let lockedSelectionKind = null;
        const cleanup = () => {
            var _a;
            window.removeEventListener('pointermove', onPointerMove);
            window.removeEventListener('pointerup', onPointerUp);
            window.removeEventListener('pointercancel', onPointerCancel);
            if ((_a = target.hasPointerCapture) === null || _a === void 0 ? void 0 : _a.call(target, pointerId)) {
                target.releasePointerCapture(pointerId);
            }
            document.body.style.userSelect = previousUserSelect;
            document.body.style.webkitUserSelect = previousWebkitUserSelect;
            setMarqueeRect(null);
        };
        const updateSelection = (clientX, clientY) => {
            const current = (0, exports.getClampedTimelineMarqueePoint)({
                bounds: marqueeBounds,
                x: clientX,
                y: clientY,
            });
            if (!hasDragged &&
                Math.max(Math.abs(current.x - startX), Math.abs(current.y - startY)) <
                    3) {
                return;
            }
            hasDragged = true;
            const rect = (0, exports.getNormalizedTimelineMarqueeRect)({
                currentX: current.x,
                currentY: current.y,
                startX,
                startY,
            });
            const nextSelection = getMarqueeSelection(rect, lockedSelectionKind);
            lockedSelectionKind = nextSelection.lockedSelectionKind;
            setMarqueeRect(rect);
            selectItems(nextSelection.selectedItems);
        };
        const onPointerMove = (moveEvent) => {
            updateSelection(moveEvent.clientX, moveEvent.clientY);
        };
        const onPointerUp = (upEvent) => {
            updateSelection(upEvent.clientX, upEvent.clientY);
            cleanup();
        };
        const onPointerCancel = () => {
            cleanup();
        };
        window.addEventListener('pointermove', onPointerMove);
        window.addEventListener('pointerup', onPointerUp);
        window.addEventListener('pointercancel', onPointerCancel);
    }, [canSelect, getMarqueeSelection, isHighestContext, selectItems]);
    return { marqueeRect, onPointerDownCapture };
};
exports.useTimelineMarqueeSelection = useTimelineMarqueeSelection;
const useTimelineMarqueeSelectableItem = (item, ref) => {
    const { registerMarqueeSelectableItem } = (0, exports.useTimelineSelection)();
    (0, react_1.useEffect)(() => {
        if (item === null) {
            return;
        }
        return registerMarqueeSelectableItem(item, () => {
            var _a;
            var _b;
            return (_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) !== null && _b !== void 0 ? _b : null;
        });
    }, [item, ref, registerMarqueeSelectableItem]);
};
exports.useTimelineMarqueeSelectableItem = useTimelineMarqueeSelectableItem;
const useTimelineFocusableItem = (item, ref) => {
    const { registerFocusableItem } = (0, exports.useTimelineSelection)();
    (0, react_1.useEffect)(() => {
        if (item === null) {
            return;
        }
        return registerFocusableItem(item, () => ref.current);
    }, [item, ref, registerFocusableItem]);
};
exports.useTimelineFocusableItem = useTimelineFocusableItem;
const useTimelineRowSelection = (nodePathInfo) => {
    const { canSelect, isSelected, selectItem } = (0, exports.useTimelineSelection)();
    const selectableTimelineItemsRef = (0, react_1.useContext)(SelectableTimelineItemsContext);
    const selectionItem = (0, react_1.useMemo)(() => (0, exports.getTimelineSelectionFromNodePathInfo)(nodePathInfo), [nodePathInfo]);
    const selected = selectionItem === null ? false : isSelected(selectionItem);
    const onSelect = (0, react_1.useCallback)((interaction) => {
        if (selectionItem === null) {
            return;
        }
        selectItem(selectionItem, interaction, selectableTimelineItemsRef.current, { reveal: true });
    }, [selectItem, selectableTimelineItemsRef, selectionItem]);
    return {
        onSelect,
        selectable: canSelect && selectionItem !== null,
        selectionItem,
        selected,
    };
};
exports.useTimelineRowSelection = useTimelineRowSelection;
const useTimelineKeyframeSelection = (nodePathInfo, frame) => {
    const { canSelect, isSelected, selectItem } = (0, exports.useTimelineSelection)();
    const selectableTimelineItemsRef = (0, react_1.useContext)(SelectableTimelineItemsContext);
    const selectionItem = (0, react_1.useMemo)(() => ({
        type: 'keyframe',
        nodePathInfo,
        frame,
    }), [nodePathInfo, frame]);
    const selected = isSelected(selectionItem);
    const onSelect = (0, react_1.useCallback)((interaction) => {
        selectItem(selectionItem, interaction, selectableTimelineItemsRef.current);
    }, [selectItem, selectableTimelineItemsRef, selectionItem]);
    return {
        onSelect,
        selectable: canSelect,
        selectionItem,
        selected,
    };
};
exports.useTimelineKeyframeSelection = useTimelineKeyframeSelection;
const useTimelineEasingSelection = ({ nodePathInfo, fromFrame, toFrame, segmentIndex, }) => {
    const { canSelect, isSelected, selectItem } = (0, exports.useTimelineSelection)();
    const selectableTimelineItemsRef = (0, react_1.useContext)(SelectableTimelineItemsContext);
    const selectionItem = (0, react_1.useMemo)(() => ({
        type: 'easing',
        nodePathInfo,
        fromFrame,
        toFrame,
        segmentIndex,
    }), [nodePathInfo, fromFrame, segmentIndex, toFrame]);
    const selected = isSelected(selectionItem);
    const onSelect = (0, react_1.useCallback)((interaction) => {
        selectItem(selectionItem, interaction, selectableTimelineItemsRef.current);
    }, [selectItem, selectableTimelineItemsRef, selectionItem]);
    return {
        onSelect,
        selectable: canSelect,
        selected,
        selectionItem,
    };
};
exports.useTimelineEasingSelection = useTimelineEasingSelection;
const useTimelineGuideSelection = (guideId) => {
    const { canSelect, clearSelection, isSelected, selectItem } = (0, exports.useTimelineSelection)();
    const selectionItem = (0, react_1.useMemo)(() => ({
        type: 'guide',
        guideId,
    }), [guideId]);
    const selected = isSelected(selectionItem);
    const onSelect = (0, react_1.useCallback)(() => {
        selectItem(selectionItem);
    }, [selectItem, selectionItem]);
    return {
        clearSelection,
        onSelect,
        selectable: canSelect,
        selected,
        selectionItem,
    };
};
exports.useTimelineGuideSelection = useTimelineGuideSelection;
const useTimelineRowContainsSelection = (nodePathInfo) => {
    const { containsSelection } = (0, exports.useTimelineSelection)();
    if (nodePathInfo === null) {
        return false;
    }
    return containsSelection(nodePathInfo);
};
exports.useTimelineRowContainsSelection = useTimelineRowContainsSelection;
const useTimelineRowHighlightBackground = (nodePathInfo) => {
    const { selected } = (0, exports.useTimelineRowSelection)(nodePathInfo);
    const containsSelection = (0, exports.useTimelineRowContainsSelection)(nodePathInfo);
    return (0, exports.getTimelineRowHighlightBackground)({
        showSelectedBackground: true,
        selected,
        containsSelection,
    });
};
exports.useTimelineRowHighlightBackground = useTimelineRowHighlightBackground;
