/*
 * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as React from "react";
import type { SVGIconProps } from "../../svgIconProps";
import { IconSize } from "../../iconTypes";
import { SVGIconContainer } from "../../svgIconContainer";

/** Path data for the 16px grid; matches {@link generate-icon-paths.mjs} / `<Icon />` from core. */
const PATHS_16 = ["M6 11.99c-.28 0-.53.11-.71.29l-.29.3V8.99c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 0 0-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 0 0 6 11.99m7.91-.08q-.09-.54-.33-.96c-.16-.28-.37-.51-.64-.69-.27-.17-.61-.26-1.03-.26-.28 0-.54.06-.78.17q-.345.165-.6.45c-.17.19-.3.41-.39.67a2.5 2.5 0 0 0-.04 1.52 1.62 1.62 0 0 0 .89 1.03c.22.11.45.16.68.16.26 0 .5-.05.7-.15s.38-.26.53-.5l.02.02c-.01.16-.03.34-.07.54-.03.2-.09.4-.17.57-.08.18-.18.33-.31.45s-.29.19-.5.19a.63.63 0 0 1-.48-.21c-.13-.14-.21-.31-.25-.5H10.1c.03.25.1.48.19.68.1.2.22.37.38.5.16.14.33.24.54.31s.42.1.65.1q.585 0 .99-.27c.27-.18.49-.41.66-.7s.29-.61.37-.97.12-.72.12-1.07q0-.54-.09-1.08m-1.14.54c-.04.13-.09.24-.16.34a.8.8 0 0 1-.27.24q-.165.09-.39.09a.75.75 0 0 1-.37-.09.8.8 0 0 1-.26-.25c-.07-.1-.12-.22-.15-.35s-.05-.26-.05-.4c0-.13.02-.26.05-.39.04-.13.09-.24.16-.34s.16-.18.26-.24.22-.09.35-.09c.14 0 .26.03.37.09s.2.14.28.24a1.3 1.3 0 0 1 .23.74c0 .15-.02.28-.05.41m-1.56-4.47H13V0h-1.42c-.05.3-.16.56-.31.76-.16.21-.35.37-.58.5s-.49.21-.78.26c-.3.05-.6.07-.91.06V2.8h2.21z"] as readonly string[];

/** Path data for the 20px grid; matches {@link generate-icon-paths.mjs} / `<Icon />` from core. */
const PATHS_20 = ["M9 14.99c-.28 0-.53.11-.71.29L7 16.58v-5.59c0-.55-.45-1-1-1s-1 .45-1 1v5.59l-1.29-1.29a.97.97 0 0 0-.71-.3 1.003 1.003 0 0 0-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3c.18-.18.29-.43.29-.71a.99.99 0 0 0-1-1m8.88.23c-.08-.42-.22-.79-.42-1.12s-.47-.6-.8-.8-.76-.3-1.28-.3a2.33 2.33 0 0 0-1.72.71c-.21.22-.37.48-.49.78-.11.3-.17.62-.17.97 0 .27.04.54.13.8.08.26.22.5.4.7.19.21.43.38.71.5a2.14 2.14 0 0 0 1.72.02c.25-.12.47-.31.66-.58l.02.02c-.01.19-.04.4-.08.63-.04.24-.11.46-.21.67s-.23.38-.39.53a.92.92 0 0 1-.62.22c-.24 0-.44-.08-.6-.25s-.27-.36-.31-.59h-1.31c.04.29.12.56.24.79s.28.43.48.59c.19.16.42.28.67.36s.52.12.82.12c.49 0 .9-.1 1.23-.31.34-.21.61-.48.82-.82s.37-.71.47-1.13.15-.83.15-1.25q0-.645-.12-1.26m-1.42.63c-.05.15-.11.28-.2.4s-.2.21-.34.27-.3.1-.49.1c-.17 0-.33-.04-.46-.11s-.24-.17-.33-.29c-.08-.12-.15-.25-.19-.4s-.06-.31-.06-.47c0-.15.02-.3.07-.45s.11-.28.2-.39c.09-.12.2-.21.33-.28s.27-.11.44-.11.33.04.47.11.25.17.34.28a1.4 1.4 0 0 1 .28.86c.01.17-.02.33-.06.48M15.32 11H17V0h-1.25c-.05.34-.17.62-.34.85s-.39.42-.63.57c-.25.15-.52.25-.83.31-.3.06-.62.09-.94.09v1.41h2.31z"] as readonly string[];

export const SortNumerical: React.FC<SVGIconProps> = React.forwardRef<any, SVGIconProps>((props, ref) => {
    const isLarge = (props.size ?? IconSize.STANDARD) >= IconSize.LARGE;
    const paths = isLarge ? PATHS_20 : PATHS_16;
    return (
        <SVGIconContainer iconName="sort-numerical" ref={ref} {...props}>
            {paths.map((d, i) => (
                <path key={i} d={d} fillRule="evenodd" />
            ))}
        </SVGIconContainer>
    );
});
SortNumerical.displayName = `Blueprint6.Icon.SortNumerical`;
export default SortNumerical;
