/*
 * 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 = ["M5.287 6.281a.98.98 0 0 1 1.373 0l2.059 2.04.066.073A.955.955 0 0 1 8.72 9.68l-2.06 2.039a.98.98 0 0 1-1.373 0 .955.955 0 0 1 0-1.36l.171-.17c-.66.104-1.262.246-1.773.422-.78.27-1.318.607-1.551.974a.73.73 0 0 0-.116.556q.058.277.347.544c.385.352 1.06.66 1.946.891s1.948.374 3.066.413a17 17 0 0 0 3.257-.191c1.01-.164 1.862-.42 2.458-.738a2.4 2.4 0 0 0 .681-.512.9.9 0 0 0 .216-.407l.014-.141a1 1 0 0 1 2 0c0 1.569-1.26 2.446-1.97 2.824-.862.46-1.95.764-3.078.947-1.15.188-2.41.26-3.647.217-1.234-.043-2.446-.202-3.501-.476-.997-.26-2.048-.67-2.791-1.35-.392-.359-.804-.89-.955-1.608a2.73 2.73 0 0 1 .385-2.042c.614-.965 1.71-1.488 2.585-1.79.815-.282 1.759-.478 2.747-.594l-.49-.487a.955.955 0 0 1 0-1.36m3.059-6a.98.98 0 0 1 1.373 0 .955.955 0 0 1 0 1.36l-.408.402c1.118.074 2.201.245 3.145.515.994.283 2.125.757 2.843 1.601.402.473.742 1.15.7 1.977-.041.81-.433 1.437-.84 1.86-.747.778-1.87 1.225-2.893 1.498a1 1 0 1 1-.516-1.932c.922-.246 1.606-.577 1.967-.952.18-.188.275-.383.285-.576q.016-.291-.227-.579c-.322-.379-.973-.718-1.869-.974a13 13 0 0 0-2.493-.424l.306.302a.955.955 0 0 1 0 1.36.98.98 0 0 1-1.373 0l-2.059-2.04a.955.955 0 0 1 0-1.359zm-5.4 2.47a1 1 0 0 1 .672 1.884c-.595.212-1.045.465-1.317.742-.278.283-.357.577-.256.86a1 1 0 0 1-1.884.67c-.435-1.22.081-2.288.714-2.931.576-.587 1.35-.967 2.071-1.225"] as readonly string[];

/** Path data for the 20px grid; matches {@link generate-icon-paths.mjs} / `<Icon />` from core. */
const PATHS_20 = ["M6.308 8.306a1.03 1.03 0 0 1 1.464 0l2.929 2.955.071.08c.332.41.308 1.015-.071 1.398l-2.929 2.955a1.03 1.03 0 0 1-1.464 0 1.05 1.05 0 0 1 0-1.478l1.067-1.077c-1.182.13-2.255.342-3.128.625-1.04.337-1.758.759-2.069 1.217q-.233.347-.154.694.078.348.464.681c.513.44 1.413.826 2.594 1.114s2.598.467 4.088.516 2.995-.034 4.342-.24c1.347-.205 2.483-.525 3.278-.922q.596-.3.905-.635c.206-.224.31-.457.31-.69a1 1 0 0 1 2 0c0 .876-.403 1.569-.837 2.042-.425.463-.958.809-1.484 1.072-1.053.526-2.415.888-3.87 1.11a26 26 0 0 1-4.709.262c-1.599-.052-3.157-.245-4.498-.572-1.28-.312-2.548-.79-3.421-1.54-.454-.389-.935-.966-1.113-1.758-.193-.855.036-1.647.45-2.257.708-1.044 1.99-1.635 3.106-1.996 1.154-.374 2.534-.625 3.99-.756l-1.31-1.322a1.05 1.05 0 0 1 0-1.478m4.929-8a1.03 1.03 0 0 1 1.464 0c.404.408.404 1.07 0 1.478l-1.245 1.255c1.428.076 2.808.265 4.01.563.784.195 1.516.443 2.146.75.604.293 1.253.708 1.726 1.307.52.657.843 1.577.565 2.586-.247.895-.872 1.504-1.416 1.89-1.08.768-2.665 1.249-4.31 1.53a1 1 0 0 1-.337-1.971c1.55-.265 2.776-.683 3.488-1.188.356-.254.572-.521.647-.791.074-.27.009-.546-.205-.816-.212-.268-.563-.521-1.033-.75-.471-.23-1.062-.435-1.753-.606-1.009-.251-2.191-.42-3.443-.496l1.16 1.17a1.05 1.05 0 0 1 0 1.477 1.03 1.03 0 0 1-1.464 0l-2.93-2.955a1.05 1.05 0 0 1-.071-1.399l.071-.079zM4.915 3.514a1 1 0 0 1 .436 1.952c-.761.17-1.415.38-1.937.617-.523.237-.915.503-1.15.786-.24.286-.31.577-.225.861.084.286.328.569.727.834A1.001 1.001 0 0 1 1.66 10.23C1.08 9.845.396 9.228.12 8.298c-.316-1.068.046-2.037.608-2.71.51-.61 1.207-1.03 1.858-1.326.681-.309 1.474-.557 2.329-.748"] as readonly string[];

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