/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Widget
 */
import "./MergeTarget.scss";
import classnames from "classnames";
import * as React from "react";
import { DraggedWidgetIdContext, useTarget } from "../base/DragManager";
import { CursorTypeContext } from "../base/NineZone";
import { getCursorClassName } from "../widget-panels/CursorOverlay";
import { useAllowedWidgetTarget } from "./useAllowedWidgetTarget";
import { useLayout } from "../base/LayoutStore";
/** @internal */
export function MergeTarget(props) {
    const { widgetId } = props;
    const cursorType = React.useContext(CursorTypeContext);
    const draggedWidgetId = React.useContext(DraggedWidgetIdContext);
    const draggedTab = useLayout((state) => !!state.draggedTab);
    const [ref, targeted] = useTarget(useTargetArgs(widgetId));
    const allowedTarget = useAllowedWidgetTarget(widgetId);
    const hidden = !allowedTarget ||
        (!draggedTab && !draggedWidgetId) ||
        draggedWidgetId === widgetId;
    const className = classnames("nz-target-mergeTarget", targeted && "nz-targeted", hidden && "nz-hidden", cursorType && getCursorClassName(cursorType));
    return React.createElement("div", { className: className, ref: ref });
}
function useTargetArgs(widgetId) {
    return React.useMemo(() => {
        return {
            type: "widget",
            widgetId,
        };
    }, [widgetId]);
}
//# sourceMappingURL=MergeTarget.js.map