<commit_before>import * as React from "react";
import * as Constants from "../constants";
import { PlaceholderComponent, DefaultComponentNames } from "../api/registry/component";
import { DEFAULT_TOOLBAR_SIZE, TOOLBAR_BACKGROUND_COLOR } from "../components/toolbar";
import ToolbarContainer from "../containers/toolbar";
import FlyoutRegionContainer from "../containers/flyout-region";
import ViewerApiShim from "../containers/viewer-shim";
import ModalLauncher from "../containers/modal-launcher";
import { RuntimeMap } from "../api/contracts/runtime-map";
import { connect } from "react-redux";
import {
    getRuntimeMap,
    ReduxDispatch,
    IApplicationState,
    IConfigurationReducerState,
    IViewerCapabilities
} from "../api/common";
import InitWarningDisplay from "../containers/init-warning-display";
import { DEFAULT_LOCALE } from "../api/i18n";

const SIDEBAR_WIDTH = 250;
const LEGEND_HEIGHT = 350;

export interface IAjaxViewerLayoutState {
    map: RuntimeMap;
    config: IConfigurationReducerState;
    capabilities: IViewerCapabilities;
    initWarnings: string[];
}

function mapStateToProps(state: Readonly<IApplicationState>): Partial<IAjaxViewerLayoutState> {
    return {
        config: state.config,
        map: getRuntimeMap(state),
        capabilities: state.config.capabilities,
        initWarnings: state.initError.warnings
    };
}

function mapDispatchToProps(dispatch: ReduxDispatch) {
    return {

    };
}

export type AjaxViewerLayoutProps = Partial<IAjaxViewerLayoutState>;

export class AjaxViewerLayout extends React.Component<AjaxViewerLayoutProps, any> {
    constructor(props: AjaxViewerLayoutProps) {
        super(props);
    }
    private getLocale(): string {
        return this.props.config ? this.props.config.locale : DEFAULT_LOCALE;
    }
    render(): JSX.Element {
        const { capabilities } = this.props;
        let hasToolbar = false;
        let hasTaskPane = false;
        let hasTaskBar = false;
        let hasStatusBar = false;
        let hasNavigator = false;
        let hasSelectionPanel = false;
        let hasLegend = false;
        let hasViewSize = false;
        if (capabilities) {
            hasToolbar = capabilities.hasToolbar;
            hasTaskPane = capabilities.hasTaskPane;
            hasTaskBar = capabilities.hasTaskBar;
            hasStatusBar = capabilities.hasStatusBar;
            hasNavigator = capabilities.hasNavigator;
            hasSelectionPanel = capabilities.hasSelectionPanel;
            hasLegend = capabilities.hasLegend;
            hasViewSize = capabilities.hasViewSize;
        }
        const locale = this.getLocale();
        let sbWidth = SIDEBAR_WIDTH;
        let tpWidth = SIDEBAR_WIDTH;
        return <div style={{ width: "100%", height: "100%" }}>
            {(() => {
                const lgStyle: React.CSSProperties = { position: "absolute", left: 0, top: 0, bottom: 0, right: 0, overflowY: "auto" };
                const selStyle: React.CSSProperties = { position: "absolute", left: 0, bottom: 0, right: 0 };
                if (hasLegend) {
                    if (hasSelectionPanel) {
                        lgStyle.height = LEGEND_HEIGHT;
                    }
                }
                if (hasSelectionPanel) {
                    if (hasLegend) {
                        selStyle.top = LEGEND_HEIGHT;
                    } else {
                        selStyle.top = 0;
                    }
                }
                if (hasLegend || hasSelectionPanel) {
                    return <div style={{ position: "absolute", left: 0, top: 0, bottom: 0, width: sbWidth }}>
                        {(() => {
                            if (hasLegend) {
                                return <div style={lgStyle}>
                                    <PlaceholderComponent id={DefaultComponentNames.Legend} locale={locale} componentProps={{ inlineBaseLayerSwitcher: true }} />
                                </div>;
                            }
                        })()}
                        {(() => {
                            if (hasSelectionPanel) {
                                return <div style={selStyle}>
                                    <PlaceholderComponent id={DefaultComponentNames.SelectionPanel} locale={locale} />
                                </div>;
                            }
                        })()}
                    </div>;
                }
            })()}
            {(() => {
                let left = 0;
                let right = 0;
                if (hasLegend || hasSelectionPanel) {
                    left = sbWidth;
                }
                if (hasTaskPane) {
                    right = tpWidth;
                }
                const TB_Z_INDEX = 0;
                return <div style={{ position: "absolute", left: left, top: 0, bottom: 0, right: right }}>
                    {(() => {
                        if (hasToolbar) {
                            return <ToolbarContainer id={Constants.WEBLAYOUT_TOOLBAR} containerStyle={{ position: "absolute", left: 10, top: 10, zIndex: TB_Z_INDEX, backgroundColor: TOOLBAR_BACKGROUND_COLOR }} />;
                        }<commit_msg>Fix bad AJAX viewer toolbar positioning.<commit_after>import * as React from "react";
import * as Constants from "../constants";
import { PlaceholderComponent, DefaultComponentNames } from "../api/registry/component";
import { DEFAULT_TOOLBAR_SIZE, TOOLBAR_BACKGROUND_COLOR } from "../components/toolbar";
import ToolbarContainer from "../containers/toolbar";
import FlyoutRegionContainer from "../containers/flyout-region";
import ViewerApiShim from "../containers/viewer-shim";
import ModalLauncher from "../containers/modal-launcher";
import { RuntimeMap } from "../api/contracts/runtime-map";
import { connect } from "react-redux";
import {
    getRuntimeMap,
    ReduxDispatch,
    IApplicationState,
    IConfigurationReducerState,
    IViewerCapabilities
} from "../api/common";
import InitWarningDisplay from "../containers/init-warning-display";
import { DEFAULT_LOCALE } from "../api/i18n";

const SIDEBAR_WIDTH = 250;
const LEGEND_HEIGHT = 350;

export interface IAjaxViewerLayoutState {
    map: RuntimeMap;
    config: IConfigurationReducerState;
    capabilities: IViewerCapabilities;
    initWarnings: string[];
}

function mapStateToProps(state: Readonly<IApplicationState>): Partial<IAjaxViewerLayoutState> {
    return {
        config: state.config,
        map: getRuntimeMap(state),
        capabilities: state.config.capabilities,
        initWarnings: state.initError.warnings
    };
}

function mapDispatchToProps(dispatch: ReduxDispatch) {
    return {

    };
}

export type AjaxViewerLayoutProps = Partial<IAjaxViewerLayoutState>;

export class AjaxViewerLayout extends React.Component<AjaxViewerLayoutProps, any> {
    constructor(props: AjaxViewerLayoutProps) {
        super(props);
    }
    private getLocale(): string {
        return this.props.config ? this.props.config.locale : DEFAULT_LOCALE;
    }
    render(): JSX.Element {
        const { capabilities } = this.props;
        let hasToolbar = false;
        let hasTaskPane = false;
        let hasTaskBar = false;
        let hasStatusBar = false;
        let hasNavigator = false;
        let hasSelectionPanel = false;
        let hasLegend = false;
        let hasViewSize = false;
        if (capabilities) {
            hasToolbar = capabilities.hasToolbar;
            hasTaskPane = capabilities.hasTaskPane;
            hasTaskBar = capabilities.hasTaskBar;
            hasStatusBar = capabilities.hasStatusBar;
            hasNavigator = capabilities.hasNavigator;
            hasSelectionPanel = capabilities.hasSelectionPanel;
            hasLegend = capabilities.hasLegend;
            hasViewSize = capabilities.hasViewSize;
        }
        const locale = this.getLocale();
        let sbWidth = SIDEBAR_WIDTH;
        let tpWidth = SIDEBAR_WIDTH;
        return <div style={{ width: "100%", height: "100%" }}>
            {(() => {
                const lgStyle: React.CSSProperties = { position: "absolute", left: 0, top: 0, bottom: 0, right: 0, overflowY: "auto" };
                const selStyle: React.CSSProperties = { position: "absolute", left: 0, bottom: 0, right: 0 };
                if (hasLegend) {
                    if (hasSelectionPanel) {
                        lgStyle.height = LEGEND_HEIGHT;
                    }
                }
                if (hasSelectionPanel) {
                    if (hasLegend) {
                        selStyle.top = LEGEND_HEIGHT;
                    } else {
                        selStyle.top = 0;
                    }
                }
                if (hasLegend || hasSelectionPanel) {
                    return <div style={{ position: "absolute", left: 0, top: 0, bottom: 0, width: sbWidth }}>
                        {(() => {
                            if (hasLegend) {
                                return <div style={lgStyle}>
                                    <PlaceholderComponent id={DefaultComponentNames.Legend} locale={locale} componentProps={{ inlineBaseLayerSwitcher: true }} />
                                </div>;
                            }
                        })()}
                        {(() => {
                            if (hasSelectionPanel) {
                                return <div style={selStyle}>
                                    <PlaceholderComponent id={DefaultComponentNames.SelectionPanel} locale={locale} />
                                </div>;
                            }
                        })()}
                    </div>;
                }
            })()}
            {(() => {
                let left = 0;
                let right = 0;
                if (hasLegend || hasSelectionPanel) {
                    left = sbWidth;
                }
                if (hasTaskPane) {
                    right = tpWidth;
                }
                const TB_Z_INDEX = 10;
                return <div style={{ position: "absolute", left: left, top: 0, bottom: 0, right: right }}>
                    {(() => {
                        if (hasToolbar) {
                            return <ToolbarContainer id={Constants.WEBLAYOUT_TOOLBAR} containerStyle={{ position: "absolute", left: 10, top: 10, right: 70, zIndex: TB_Z_INDEX, backgroundColor: TOOLBAR_BACKGROUND_COLOR }} />;
                        }
{'fraction_non_alphanumeric': 0.10218908326163846, 'fraction_numerical': 0.006787114042634547, 'mean_word_length': 1.7408959916164528, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1525202', 'n_tokens_mistral': 2784, 'n_tokens_neox': 2629, 'n_words': 613}