/*
 * 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 = ["M11 10a1.003 1.003 0 0 0 1.71.71l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71l-2-2a1.003 1.003 0 0 0-1.42 1.42L12.59 8 11.3 9.29c-.19.18-.3.43-.3.71M1 5c.55 0 1-.45 1-1V2h2c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v3c0 .55.45 1 1 1m4 1a1.003 1.003 0 0 0-1.71-.71l-2 2C1.11 7.47 1 7.72 1 8s.11.53.29.71l2 2a1.003 1.003 0 0 0 1.42-1.42L3.41 8 4.7 6.71c.19-.18.3-.43.3-.71m1-1c.28 0 .53-.11.71-.29L8 3.41 9.29 4.7c.18.19.43.3.71.3a1.003 1.003 0 0 0 .71-1.71l-2-2C8.53 1.11 8.28 1 8 1s-.53.11-.71.29l-2 2A1.003 1.003 0 0 0 6 5m9 6c-.55 0-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1m0-11h-3c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1M4 14H2v-2c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1m6-3c-.28 0-.53.11-.71.29L8 12.59 6.71 11.3A.97.97 0 0 0 6 11a1.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 10 11"] as readonly string[];

/** Path data for the 20px grid; matches {@link generate-icon-paths.mjs} / `<Icon />` from core. */
const PATHS_20 = ["M1 7c.55 0 1-.45 1-1V2h4c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v5c0 .55.45 1 1 1m5 1a1.003 1.003 0 0 0-1.71-.71l-2 2c-.18.18-.29.43-.29.71s.11.53.29.71l2 2a1.003 1.003 0 0 0 1.42-1.42L4.41 10 5.7 8.71c.19-.18.3-.43.3-.71m2-2c.28 0 .53-.11.71-.29L10 4.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 0 0 .71-1.71l-2-2C10.53 2.11 10.28 2 10 2s-.53.11-.71.29l-2 2A1.003 1.003 0 0 0 8 6M6 18H2v-4c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1m8-6a1.003 1.003 0 0 0 1.71.71l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71l-2-2a1.003 1.003 0 0 0-1.42 1.42l1.3 1.29-1.29 1.29c-.19.18-.3.43-.3.71m5-12h-5c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1m-7 14c-.28 0-.53.11-.71.29L10 15.59 8.71 14.3A.97.97 0 0 0 8 14a1.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 12 14m7-1c-.55 0-1 .45-1 1v4h-4c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1"] as readonly string[];

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