/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Settings
 */
import * as React from "react";
import { UiFramework } from "../../UiFramework";
import { Select } from "@itwin/itwinui-react";
/** Select control to set the "active" Presentation Unit System. This setting determine what units are display for quantity values (i.e. foot vs meter).
 * @alpha
 */
export function UnitSystemSelector(props) {
    const label = React.useRef(UiFramework.translate("presentationUnitSystem.selector-label"));
    const { selectedUnitSystemKey, onUnitSystemSelected, availableUnitSystems } = props;
    const handleUnitSystemSelected = React.useCallback((newValue) => {
        onUnitSystemSelected && onUnitSystemSelected(newValue);
    }, [onUnitSystemSelected]);
    const displayUnitSystems = [
        ...availableUnitSystems.values(),
    ].map((sys) => {
        switch (sys) {
            case "imperial":
                return {
                    value: "imperial",
                    label: UiFramework.translate("presentationUnitSystem.BritishImperial"),
                };
            case "usCustomary":
                return {
                    value: "usCustomary",
                    label: UiFramework.translate("presentationUnitSystem.USCustomary"),
                };
            case "usSurvey":
                return {
                    value: "usSurvey",
                    label: UiFramework.translate("presentationUnitSystem.USSurvey"),
                };
            case "metric":
            default:
                return {
                    value: "metric",
                    label: UiFramework.translate("presentationUnitSystem.Metric"),
                };
        }
    });
    const unitSystemKey = availableUnitSystems.has(selectedUnitSystemKey)
        ? selectedUnitSystemKey
        : displayUnitSystems[0].value;
    return (React.createElement("div", { className: "quantity-unit-system-selector-container" },
        React.createElement("span", { className: "uicore-label" }, label.current),
        React.createElement(Select, { "data-testid": "unitSystemSelector", value: unitSystemKey, options: displayUnitSystems, onChange: handleUnitSystemSelected, size: "small" })));
}
//# sourceMappingURL=UnitSystemSelector.js.map