/*---------------------------------------------------------------------------------------------
 * 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 { useProximityToMouse, WidgetElementSet, WidgetOpacityContext, } from "@itwin/core-react/internal";
import * as React from "react";
import { ToolsArea } from "../layout/widget/ToolsArea.js";
import { UiFramework } from "../UiFramework.js";
/**
 * ToolWidget component that supports use of ToolbarComposer-based Toolbars. The ToolWidget is shown in the top left of the content area
 * and typically holds tools to manipulate or interrogate content. The horizontal toolbar often includes context specific tools based on
 * selected items. The vertical toolbar typically contains a more fixed list of tools.
 * @public
 */
// eslint-disable-next-line deprecation/deprecation
export function ToolWidgetComposer(props) {
    const { cornerItem, horizontalToolbar, verticalToolbar, ...otherProps } = props;
    const [elementSet] = React.useState(new WidgetElementSet());
    const proximityScale = useProximityToMouse(elementSet, UiFramework.visibility.snapWidgetOpacity);
    const addRef = React.useCallback((ref) => {
        elementSet.add(ref);
    }, [elementSet]);
    const removeRef = React.useCallback((ref) => {
        elementSet.delete(ref);
    }, [elementSet]);
    return (React.createElement(WidgetOpacityContext.Provider, { value: {
            addRef,
            removeRef,
            proximityScale,
        } },
        React.createElement(ToolsArea, { button: cornerItem, horizontalToolbar: horizontalToolbar, verticalToolbar: verticalToolbar, ...otherProps, onMouseEnter: UiFramework.visibility.handleWidgetMouseEnter })));
}
//# sourceMappingURL=ToolWidgetComposer.js.map