"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 Notification
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivityMessagePopup = void 0;
require("./ActivityMessagePopup.scss");
const React = require("react");
const MessageManager_1 = require("../messages/MessageManager");
const ActivityMessage_1 = require("./ActivityMessage");
/** Activity Message Popup React component
 * @deprecated in 3.5. Activity messages are set-up automatically in a StatusBar.
 * @public
 */
function ActivityMessagePopup(props) {
    const [activityMessageInfo, setActivityMessageInfo] = React.useState(undefined);
    React.useEffect(() => {
        const handleActivityMessageUpdatedEvent = (args) => {
            setActivityMessageInfo(args);
        };
        return MessageManager_1.MessageManager.onActivityMessageUpdatedEvent.addListener(handleActivityMessageUpdatedEvent);
    }, []);
    React.useEffect(() => {
        const handleActivityMessageCancelledEvent = () => {
            setActivityMessageInfo(undefined);
        };
        return MessageManager_1.MessageManager.onActivityMessageCancelledEvent.addListener(handleActivityMessageCancelledEvent);
    }, []);
    const cancelActivityMessage = React.useCallback(() => {
        MessageManager_1.MessageManager.endActivityMessage(false);
        props.cancelActivityMessage && props.cancelActivityMessage();
    }, [props]);
    const dismissActivityMessage = React.useCallback(() => {
        props.dismissActivityMessage && props.dismissActivityMessage();
    }, [props]);
    (0, ActivityMessage_1.useActivityMessage)({ activityMessageInfo, cancelActivityMessage, dismissActivityMessage });
    return React.createElement(React.Fragment, null);
}
exports.ActivityMessagePopup = ActivityMessagePopup;
//# sourceMappingURL=ActivityMessagePopup.js.map