/*
 * 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-.29a.98.98 0 0 0-.71-.3 1.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.86-9.45c-.09-.48-.26-.9-.5-1.28S12.8.58 12.4.35 11.49 0 10.86 0c-.43 0-.82.07-1.17.22q-.525.225-.9.6c-.25.25-.44.55-.58.89s-.2.71-.2 1.11c0 .31.05.61.15.91s.26.57.48.8c.23.24.52.43.85.58.33.14.68.21 1.03.21.4 0 .75-.07 1.05-.2s.57-.35.79-.66l.02.02c-.02.21-.05.45-.1.73-.05.27-.13.53-.25.76-.12.24-.27.44-.47.6-.19.16-.44.25-.75.25a.98.98 0 0 1-.72-.29c-.19-.18-.31-.4-.37-.66H8.15c.05.34.14.64.29.9s.34.49.57.67.5.32.8.41c.31.1.63.15.98.15.58 0 1.08-.12 1.48-.36q.6-.36.99-.93c.26-.39.44-.82.56-1.29Q14 4.7 14 3.98c0-.48-.05-.96-.14-1.44m-1.71.72c-.05.17-.14.32-.24.46-.11.13-.24.24-.41.31-.16.08-.36.12-.58.12-.21 0-.39-.04-.55-.13q-.24-.12-.39-.33c-.12-.14-.19-.29-.24-.46s-.08-.35-.08-.54c0-.18.03-.35.08-.52.06-.16.14-.31.25-.44s.24-.24.4-.32.33-.12.52-.12c.21 0 .4.04.56.12s.3.19.41.32c.11.14.2.29.26.46s.09.35.09.52c0 .2-.03.38-.08.55m-.46 7.31c-.12.15-.26.28-.44.37-.17.09-.37.16-.58.2-.22.04-.44.05-.67.05v.92h1.65v3.88h1.33V10h-1.06c-.03.23-.11.42-.23.57"] as readonly string[];

/** Path data for the 20px grid; matches {@link generate-icon-paths.mjs} / `<Icon />` from core. */
const PATHS_20 = ["M9 15c-.28 0-.53.11-.71.29L7 16.59v-5.58c0-.55-.45-1-1-1s-1 .45-1 1v5.58L3.71 15.3c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 0 0-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0 0 9 15m6.7-1.33a1.5 1.5 0 0 1-.44.43c-.17.11-.37.19-.58.23-.22.04-.44.06-.67.05v1.07h1.66V20H17v-6.99h-1.06q-.06.39-.24.66m3.15-10.3c-.11-.68-.29-1.26-.55-1.76S17.68.72 17.22.43C16.75.14 16.17 0 15.46 0c-.54 0-1.03.09-1.46.27s-.79.44-1.09.76c-.3.33-.52.71-.67 1.15-.16.44-.24.92-.24 1.43 0 .54.08 1.04.23 1.47.15.44.37.81.65 1.12s.61.55 1 .72.82.26 1.3.26q.69 0 1.26-.33c.38-.22.68-.53.9-.94l.03.03c-.03.35-.07.74-.12 1.16s-.15.81-.29 1.18-.35.68-.61.92c-.26.25-.62.37-1.06.37-.43 0-.77-.13-1.03-.4-.25-.27-.4-.62-.44-1.05h-1.64c.02.43.11.83.29 1.18.17.35.39.66.67.91a3.03 3.03 0 0 0 2.07.8c.71 0 1.3-.17 1.79-.5q.72-.495 1.17-1.29c.3-.53.51-1.12.64-1.76S19 6.18 19 5.54c.01-.77-.05-1.49-.15-2.17M17.1 4.44c-.08.27-.19.5-.34.71s-.34.37-.57.49-.5.18-.8.18-.56-.06-.78-.19-.4-.29-.55-.49c-.14-.2-.25-.44-.32-.7-.07-.27-.11-.55-.11-.84 0-.28.04-.55.11-.82.07-.26.18-.49.32-.7.14-.2.33-.36.55-.48s.48-.17.78-.17c.31 0 .57.06.8.18q.345.18.57.48c.15.2.26.43.34.69s.11.53.11.82-.04.57-.11.84"] as readonly string[];

export const SortNumericalDesc: 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-desc" ref={ref} {...props}>
            {paths.map((d, i) => (
                <path key={i} d={d} fillRule="evenodd" />
            ))}
        </SVGIconContainer>
    );
});
SortNumericalDesc.displayName = `Blueprint6.Icon.SortNumericalDesc`;
export default SortNumericalDesc;
