"use strict";
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module WidgetPanels
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.PanelTarget = void 0;
require("./PanelTarget.scss");
const classnames_1 = require("classnames");
const React = require("react");
const DragManager_1 = require("../base/DragManager");
const NineZone_1 = require("../base/NineZone");
const CursorOverlay_1 = require("../widget-panels/CursorOverlay");
const Panel_1 = require("../widget-panels/Panel");
const useAllowedPanelTarget_1 = require("./useAllowedPanelTarget");
const LayoutStore_1 = require("../base/LayoutStore");
/** @internal */
function PanelTarget(props) {
    const { side } = props;
    const cursorType = React.useContext(NineZone_1.CursorTypeContext);
    const draggedWidgetId = React.useContext(DragManager_1.DraggedWidgetIdContext);
    const draggedTab = (0, LayoutStore_1.useLayout)((state) => !!state.draggedTab);
    const allowedTarget = (0, useAllowedPanelTarget_1.useAllowedPanelTarget)();
    const newWidgetId = React.useMemo(() => (0, NineZone_1.getUniqueId)(), []);
    const [ref, targeted] = (0, DragManager_1.usePanelTarget)({
        side,
        newWidgetId,
    });
    const visible = (draggedTab || !!draggedWidgetId) && allowedTarget;
    const isHorizontal = (0, Panel_1.isHorizontalPanelSide)(side);
    const className = (0, classnames_1.default)("nz-target-panelTarget", isHorizontal ? "nz-horizontal" : "nz-vertical", targeted && "nz-targeted", !visible && "nz-hidden", cursorType && (0, CursorOverlay_1.getCursorClassName)(cursorType));
    return React.createElement("div", { className: className, ref: ref });
}
exports.PanelTarget = PanelTarget;
//# sourceMappingURL=PanelTarget.js.map