"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 IModelComponents
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.VisibilityTreeNoFilteredData = exports.useVisibilityTreeFiltering = exports.visibilityTreeNodeCheckboxRenderer = exports.createVisibilityTreeNodeRenderer = exports.useVisibilityTreeRenderer = void 0;
/* eslint-disable deprecation/deprecation */
const React = require("react");
const presentation_components_1 = require("@itwin/presentation-components");
const components_react_1 = require("@itwin/components-react");
const core_react_1 = require("@itwin/core-react");
/**
 * Creates Visibility tree renderer which renders nodes with eye checkbox.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
const useVisibilityTreeRenderer = (iconsEnabled, descriptionsEnabled) => {
    // eslint-disable-next-line react-hooks/exhaustive-deps
    const nodeRenderer = React.useCallback((0, exports.createVisibilityTreeNodeRenderer)(iconsEnabled, descriptionsEnabled), [iconsEnabled, descriptionsEnabled]);
    return React.useCallback((props) => (React.createElement(components_react_1.TreeRenderer, { ...props, nodeRenderer: nodeRenderer })), [nodeRenderer]);
};
exports.useVisibilityTreeRenderer = useVisibilityTreeRenderer;
const imageLoader = new components_react_1.TreeImageLoader();
/**
 * Creates node renderer which renders node with eye checkbox.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
const createVisibilityTreeNodeRenderer = (iconsEnabled, descriptionEnabled) => {
    return (props) => ( // eslint-disable-line react/display-name
    React.createElement(components_react_1.TreeNodeRenderer, { ...props, checkboxRenderer: exports.visibilityTreeNodeCheckboxRenderer, descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: "with-checkbox" }));
};
exports.createVisibilityTreeNodeRenderer = createVisibilityTreeNodeRenderer;
/**
 * Checkbox renderer that renders an eye.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
const visibilityTreeNodeCheckboxRenderer = (props) => (React.createElement(core_react_1.ImageCheckBox, { checked: props.checked, disabled: props.disabled, imageOn: "icon-visibility", imageOff: "icon-visibility-hide-2", onClick: props.onChange, tooltip: props.title }));
exports.visibilityTreeNodeCheckboxRenderer = visibilityTreeNodeCheckboxRenderer;
/**
 * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
const useVisibilityTreeFiltering = (nodeLoader, filterInfo, onFilterApplied) => {
    const { filter, activeMatchIndex } = filterInfo !== null && filterInfo !== void 0 ? filterInfo : { filter: undefined, activeMatchIndex: undefined };
    const { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps, } = (0, presentation_components_1.useControlledPresentationTreeFiltering)({ nodeLoader, filter, activeMatchIndex });
    React.useEffect(() => {
        if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader)
            onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);
    }, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);
    return { filteredNodeLoader, isFiltering, nodeHighlightingProps };
};
exports.useVisibilityTreeFiltering = useVisibilityTreeFiltering;
/**
 * Renders message that no nodes was found for filter.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
function VisibilityTreeNoFilteredData(props) {
    return (React.createElement("div", { className: "components-tree-errormessage" },
        React.createElement("span", { className: "errormessage-header" }, props.title),
        React.createElement("span", { className: "errormessage-body" }, props.message)));
}
exports.VisibilityTreeNoFilteredData = VisibilityTreeNoFilteredData;
//# sourceMappingURL=VisibilityTreeRenderer.js.map