import "./Checkbox.css";
import {CenterBaseline as $1f4b04be3f24aae3$export$768dac55bb57081d} from "./CenterBaseline.mjs";
import $81cf3d4588736e7d$export$2e2bcd8739ae039 from "./Checkmark.mjs";
import $f17037051ff08dc2$export$2e2bcd8739ae039 from "./Dash.mjs";
import {FormContext as $9b916426527cebe7$export$c24727297075ec6a, useFormProps as $9b916426527cebe7$export$a6b5be5c6b451665} from "./Form.mjs";
import {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressScale.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
import {jsx as $5oFhd$jsx, jsxs as $5oFhd$jsxs, Fragment as $5oFhd$Fragment} from "react/jsx-runtime";
import {CheckboxGroupStateContext as $5oFhd$CheckboxGroupStateContext, useSlottedContext as $5oFhd$useSlottedContext, Checkbox as $5oFhd$Checkbox} from "react-aria-components";
import {createContext as $5oFhd$createContext, forwardRef as $5oFhd$forwardRef, useRef as $5oFhd$useRef, useContext as $5oFhd$useContext} from "react";
import {useFocusableRef as $5oFhd$useFocusableRef} from "@react-spectrum/utils";

/*
 * Copyright 2024 Adobe. All rights reserved.
 * This file is licensed to you 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 REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */ 









const $9b405e0f8095dce0$export$b085522c77523c51 = /*#__PURE__*/ (0, $5oFhd$createContext)(null);
const $9b405e0f8095dce0$var$wrapper = function anonymous(props, overrides) {
    let rules = " ";
    let position = false;
    let width = false;
    let gridColumnStart = false;
    let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g);
    for (let p of matches){
        if (p[1] === "_P") position = true;
        if (p[1] === "Z") width = true;
        if (p[1] === "z") gridColumnStart = true;
        rules += p[0];
    }
    rules += ' sd12';
    if (!position) rules += ' _Pc12';
    rules += ' qf12';
    rules += ' ea12';
    if (!width) rules += ' ZJ12';
    if (props.size === "XL") {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "L") {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "S") {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "XS") {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    }
    if (props.size === "XL") {
        rules += ' -_6BNtrc-e12';
        rules += ' vx12';
    } else if (props.size === "L") {
        rules += ' -_6BNtrc-d12';
        rules += ' vx12';
    } else if (props.size === "S") {
        rules += ' -_6BNtrc-b12';
        rules += ' vx12';
    } else if (props.size === "XS") {
        rules += ' -_6BNtrc-a12';
        rules += ' vx12';
    } else {
        rules += ' -_6BNtrc-c12';
        rules += ' vx12';
    }
    if (props.size === "XL") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "L") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "S") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "XS") {
        rules += ' xb12';
        rules += ' _xa12';
    } else {
        rules += ' xb12';
        rules += ' _xa12';
    }
    if (props.size === "XL") {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "L") {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "S") {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "XS") {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    } else {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    }
    if (props.isDisabled) {
        rules += ' pp12';
        rules += ' plc12';
    } else {
        if (props.isPressed) rules += ' po12';
        else if (props.isFocusVisible) rules += ' po12';
        else if (props.isHovered) rules += ' po12';
        else rules += ' pt12';
    }
    rules += ' Yc12';
    rules += ' Xb12';
    rules += ' _2b12';
    if (props.isInForm) {
        if (!gridColumnStart) rules += ' zhJUGr12';
    }
    rules += ' __ca12';
    return rules;
};
const $9b405e0f8095dce0$export$827f4ee28efc37 = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    rules += ' Oh12';
    rules += ' _Mc12';
    rules += ' _Kd12';
    if (props.size === "XL") rules += ' -SFnbic-_JaP8ec12';
    else if (props.size === "L") rules += ' -SFnbic-_J0K2hn12';
    else if (props.size === "S") rules += ' -SFnbic-_JJOW22b12';
    else if (props.size === "XS") rules += ' -SFnbic-_JICefdd12';
    else rules += ' -SFnbic-_Jb12';
    rules += ' -Bu7z1c-oa12';
    rules += ' oj12';
    rules += ' nj12';
    rules += ' kj12';
    rules += ' jj12';
    if (props.size === "XL") rules += ' Zm12';
    else if (props.size === "L") rules += ' Zl12';
    else if (props.size === "S") rules += ' Zk12';
    else rules += ' Zu12';
    if (props.size === "XL") rules += ' Fn12';
    else if (props.size === "L") rules += ' Fm12';
    else if (props.size === "S") rules += ' Fl12';
    else rules += ' Ft12';
    rules += ' _va12';
    rules += ' sd12';
    rules += ' eb12';
    rules += ' _Ca12';
    rules += ' _k7m7Gv12';
    rules += ' h7m7Gv12';
    rules += ' m7m7Gv12';
    rules += ' l7m7Gv12';
    rules += ' _oa12';
    rules += ' _jf12';
    rules += ' Yd12';
    rules += ' Xb12';
    rules += ' _2b12';
    rules += ' _yb12';
    if (props.isSelected) {
        if (props.isDisabled) {
            rules += ' gw12';
            rules += ' gld12';
        } else if (props.isInvalid) {
            if (props.isPressed) rules += ' gt12';
            else if (props.isFocusVisible) rules += ' gt12';
            else if (props.isHovered) rules += ' gt12';
            else rules += ' g_d12';
            rules += ' gl_b12';
        } else {
            if (props.isEmphasized) {
                if (props.isPressed) rules += ' gY12';
                else if (props.isFocusVisible) rules += ' gY12';
                else if (props.isHovered) rules += ' gY12';
                else rules += ' g312';
            } else {
                if (props.isPressed) rules += ' gu12';
                else if (props.isFocusVisible) rules += ' gu12';
                else if (props.isHovered) rules += ' gu12';
                else rules += ' g012';
            }
            rules += ' gle12';
        }
    } else {
        rules += ' gX12';
        rules += ' gla12';
    }
    if (props.isSelected) rules += ' iA12';
    else if (props.isDisabled) {
        rules += ' io12';
        rules += ' ilc12';
    } else if (props.isInvalid) {
        if (props.isPressed) rules += ' im12';
        else if (props.isFocusVisible) rules += ' im12';
        else if (props.isHovered) rules += ' im12';
        else rules += ' ip12';
        rules += ' ile12';
    } else {
        if (props.isPressed) rules += ' in12';
        else if (props.isFocusVisible) rules += ' in12';
        else if (props.isHovered) rules += ' in12';
        else rules += ' iv12';
        rules += ' ila12';
    }
    return rules;
};
const $9b405e0f8095dce0$export$2c99b98b77550cb4 = " -_8sjo0b-txpP0Sb12 -_8sjo0b-lt8pvGJ12";
const $9b405e0f8095dce0$var$iconSize = {
    S: 'XS',
    M: 'S',
    L: 'M',
    XL: 'L'
};
const $9b405e0f8095dce0$export$48513f6b9f8ce62d = /*#__PURE__*/ (0, $5oFhd$forwardRef)(function Checkbox({ children: children, ...props }, ref) {
    [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $9b405e0f8095dce0$export$b085522c77523c51);
    let boxRef = (0, $5oFhd$useRef)(null);
    let inputRef = (0, $5oFhd$useRef)(null);
    let domRef = (0, $5oFhd$useFocusableRef)(ref, inputRef);
    let isInForm = !!(0, $5oFhd$useContext)((0, $9b916426527cebe7$export$c24727297075ec6a));
    props = (0, $9b916426527cebe7$export$a6b5be5c6b451665)(props);
    let isInCheckboxGroup = !!(0, $5oFhd$useContext)((0, $5oFhd$CheckboxGroupStateContext));
    let ctx = (0, $5oFhd$useSlottedContext)($9b405e0f8095dce0$export$b085522c77523c51, props.slot);
    return /*#__PURE__*/ (0, $5oFhd$jsx)((0, $5oFhd$Checkbox), {
        ...props,
        ref: domRef,
        inputRef: inputRef,
        style: props.UNSAFE_style,
        className: (renderProps)=>(props.UNSAFE_className || '') + $9b405e0f8095dce0$var$wrapper({
                ...renderProps,
                isInForm: isInForm,
                size: props.size || 'M'
            }, props.styles),
        children: (renderProps)=>{
            let checkbox = /*#__PURE__*/ (0, $5oFhd$jsxs)("div", {
                ref: boxRef,
                style: (0, $10ea7662e51a285b$export$56e8cba416805d8d)(boxRef)(renderProps),
                className: $9b405e0f8095dce0$export$827f4ee28efc37({
                    ...renderProps,
                    isSelected: renderProps.isSelected || renderProps.isIndeterminate,
                    size: props.size || 'M',
                    isEmphasized: isInCheckboxGroup ? ctx?.isEmphasized : props.isEmphasized
                }),
                children: [
                    renderProps.isIndeterminate && /*#__PURE__*/ (0, $5oFhd$jsx)((0, $f17037051ff08dc2$export$2e2bcd8739ae039), {
                        size: $9b405e0f8095dce0$var$iconSize[props.size || 'M'],
                        className: $9b405e0f8095dce0$export$2c99b98b77550cb4
                    }),
                    renderProps.isSelected && !renderProps.isIndeterminate && /*#__PURE__*/ (0, $5oFhd$jsx)((0, $81cf3d4588736e7d$export$2e2bcd8739ae039), {
                        size: $9b405e0f8095dce0$var$iconSize[props.size || 'M'],
                        className: $9b405e0f8095dce0$export$2c99b98b77550cb4
                    })
                ]
            });
            // Only render checkbox without center baseline if no label.
            // This avoids expanding the checkbox height to the font's line height.
            if (!children) return checkbox;
            return /*#__PURE__*/ (0, $5oFhd$jsxs)((0, $5oFhd$Fragment), {
                children: [
                    /*#__PURE__*/ (0, $5oFhd$jsx)((0, $1f4b04be3f24aae3$export$768dac55bb57081d), {
                        children: checkbox
                    }),
                    children
                ]
            });
        }
    });
});


export {$9b405e0f8095dce0$export$b085522c77523c51 as CheckboxContext, $9b405e0f8095dce0$export$827f4ee28efc37 as box, $9b405e0f8095dce0$export$2c99b98b77550cb4 as iconStyles, $9b405e0f8095dce0$export$48513f6b9f8ce62d as Checkbox};
//# sourceMappingURL=Checkbox.mjs.map
