"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 ContentView
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultViewOverlay = void 0;
require("./DefaultViewOverlay.scss");
const React = require("react");
const imodel_components_react_1 = require("@itwin/imodel-components-react");
const useScheduleAnimationDataProvider_1 = require("../hooks/useScheduleAnimationDataProvider");
const useActiveViewport_1 = require("../hooks/useActiveViewport");
const useSolarDataProvider_1 = require("../hooks/useSolarDataProvider");
const useAnalysisAnimationDataProvider_1 = require("../hooks/useAnalysisAnimationDataProvider");
/**
 * Default viewport overlay that examines ViewState of the active view for a schedule script, analysis data, or solar data. If one of these is detected, the corresponding
 * data provider is attached to the TimelineComponent and the overlay is made visible.
 * @public
 */
// istanbul ignore next
function DefaultViewOverlay({ viewport, onPlayPause, featureOptions, }) {
    var _a, _b, _c;
    const solarDataTimelineProvider = (0, useSolarDataProvider_1.useSolarDataProvider)(viewport);
    const analysisAnimationTimelineDataProvider = (0, useAnalysisAnimationDataProvider_1.useAnalysisAnimationDataProvider)(viewport);
    const scheduleTimelineDataProvider = (0, useScheduleAnimationDataProvider_1.useScheduleAnimationDataProvider)(viewport);
    const currentViewport = (0, useActiveViewport_1.useActiveViewport)();
    if (!currentViewport)
        return null;
    // Solar gets first shot
    if (solarDataTimelineProvider &&
        !!((_a = featureOptions === null || featureOptions === void 0 ? void 0 : featureOptions.defaultViewOverlay) === null || _a === void 0 ? void 0 : _a.enableSolarTimelineViewOverlay)) {
        return (React.createElement("div", { className: "uifw-view-overlay" },
            React.createElement("div", { className: "uifw-animation-overlay" },
                React.createElement(imodel_components_react_1.SolarTimeline, { dataProvider: solarDataTimelineProvider }))));
    }
    if (analysisAnimationTimelineDataProvider &&
        !!((_b = featureOptions === null || featureOptions === void 0 ? void 0 : featureOptions.defaultViewOverlay) === null || _b === void 0 ? void 0 : _b.enableAnalysisTimelineViewOverlay)) {
        return (React.createElement("div", { className: "uifw-view-overlay" },
            React.createElement("div", { className: "uifw-animation-overlay" },
                React.createElement(imodel_components_react_1.TimelineComponent, { startDate: analysisAnimationTimelineDataProvider.start, endDate: analysisAnimationTimelineDataProvider.end, initialDuration: analysisAnimationTimelineDataProvider.initialDuration, totalDuration: analysisAnimationTimelineDataProvider.duration, minimized: true, onChange: analysisAnimationTimelineDataProvider.onAnimationFractionChanged, onPlayPause: onPlayPause }))));
    }
    if (scheduleTimelineDataProvider &&
        !!((_c = featureOptions === null || featureOptions === void 0 ? void 0 : featureOptions.defaultViewOverlay) === null || _c === void 0 ? void 0 : _c.enableScheduleAnimationViewOverlay)) {
        return (React.createElement("div", { className: "uifw-view-overlay" },
            React.createElement("div", { className: "uifw-animation-overlay" },
                React.createElement(imodel_components_react_1.TimelineComponent, { startDate: scheduleTimelineDataProvider.start, endDate: scheduleTimelineDataProvider.end, initialDuration: scheduleTimelineDataProvider.initialDuration, totalDuration: scheduleTimelineDataProvider.duration, minimized: true, onChange: scheduleTimelineDataProvider.onAnimationFractionChanged, onPlayPause: onPlayPause }))));
    }
    return null;
}
exports.DefaultViewOverlay = DefaultViewOverlay;
//# sourceMappingURL=DefaultViewOverlay.js.map