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 += ' sd1';
    if (!position) rules += ' _Pc1';
    rules += ' qf1';
    rules += ' ea1';
    if (!width) rules += ' ZJ1';
    if (props.size === "XL") {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    } else if (props.size === "L") {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    } else if (props.size === "S") {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    } else if (props.size === "XS") {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    } else {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    }
    if (props.size === "XL") {
        rules += ' -_6BNtrc-e1';
        rules += ' vx1';
    } else if (props.size === "L") {
        rules += ' -_6BNtrc-d1';
        rules += ' vx1';
    } else if (props.size === "S") {
        rules += ' -_6BNtrc-b1';
        rules += ' vx1';
    } else if (props.size === "XS") {
        rules += ' -_6BNtrc-a1';
        rules += ' vx1';
    } else {
        rules += ' -_6BNtrc-c1';
        rules += ' vx1';
    }
    if (props.size === "XL") {
        rules += ' xb1';
        rules += ' _xa1';
    } else if (props.size === "L") {
        rules += ' xb1';
        rules += ' _xa1';
    } else if (props.size === "S") {
        rules += ' xb1';
        rules += ' _xa1';
    } else if (props.size === "XS") {
        rules += ' xb1';
        rules += ' _xa1';
    } else {
        rules += ' xb1';
        rules += ' _xa1';
    }
    if (props.size === "XL") {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    } else if (props.size === "L") {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    } else if (props.size === "S") {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    } else if (props.size === "XS") {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    } else {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    }
    if (props.isDisabled) {
        rules += ' pp1';
        rules += ' plc1';
    } else {
        if (props.isPressed) rules += ' po1';
        else if (props.isFocusVisible) rules += ' po1';
        else if (props.isHovered) rules += ' po1';
        else rules += ' pt1';
    }
    rules += ' Yc1';
    rules += ' Xb1';
    rules += ' _2b1';
    if (props.isInForm) {
        if (!gridColumnStart) rules += ' zhJUGr1';
    }
    rules += ' __ca1';
    return rules;
};
const $9b405e0f8095dce0$export$827f4ee28efc37 = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf1';
    else rules += ' _Le1';
    rules += ' Oh1';
    rules += ' Olc1';
    rules += ' _Mc1';
    rules += ' _Kd1';
    if (props.size === "XL") rules += ' -SFnbic-_JaP8ec1';
    else if (props.size === "L") rules += ' -SFnbic-_J0K2hn1';
    else if (props.size === "S") rules += ' -SFnbic-_JJOW22b1';
    else if (props.size === "XS") rules += ' -SFnbic-_JICefdd1';
    else rules += ' -SFnbic-_Jb1';
    rules += ' -Bu7z1c-oa1';
    rules += ' oj1';
    rules += ' nj1';
    rules += ' kj1';
    rules += ' jj1';
    if (props.size === "XL") rules += ' Zm1';
    else if (props.size === "L") rules += ' Zl1';
    else if (props.size === "S") rules += ' Zk1';
    else rules += ' Zu1';
    if (props.size === "XL") rules += ' Fn1';
    else if (props.size === "L") rules += ' Fm1';
    else if (props.size === "S") rules += ' Fl1';
    else rules += ' Ft1';
    rules += ' _va1';
    rules += ' sd1';
    rules += ' eb1';
    rules += ' _Ca1';
    rules += ' _k7m7Gv1';
    rules += ' h7m7Gv1';
    rules += ' m7m7Gv1';
    rules += ' l7m7Gv1';
    rules += ' _oa1';
    rules += ' _jf1';
    rules += ' Yd1';
    rules += ' Xb1';
    rules += ' _2b1';
    rules += ' _yb1';
    if (props.isSelected) {
        if (props.isDisabled) {
            rules += ' gw1';
            rules += ' gld1';
        } else if (props.isInvalid) {
            if (props.isPressed) rules += ' gt1';
            else if (props.isFocusVisible) rules += ' gt1';
            else if (props.isHovered) rules += ' gt1';
            else rules += ' g_d1';
            rules += ' gl_b1';
        } else {
            if (props.isEmphasized) {
                if (props.isPressed) rules += ' gY1';
                else if (props.isFocusVisible) rules += ' gY1';
                else if (props.isHovered) rules += ' gY1';
                else rules += ' g31';
            } else {
                if (props.isPressed) rules += ' gu1';
                else if (props.isFocusVisible) rules += ' gu1';
                else if (props.isHovered) rules += ' gu1';
                else rules += ' g01';
            }
            rules += ' gle1';
        }
    } else {
        rules += ' gX1';
        rules += ' gla1';
    }
    if (props.isSelected) rules += ' iA1';
    else if (props.isDisabled) {
        rules += ' io1';
        rules += ' ilc1';
    } else if (props.isInvalid) {
        if (props.isPressed) rules += ' im1';
        else if (props.isFocusVisible) rules += ' im1';
        else if (props.isHovered) rules += ' im1';
        else rules += ' ip1';
        rules += ' ile1';
    } else {
        if (props.isPressed) rules += ' in1';
        else if (props.isFocusVisible) rules += ' in1';
        else if (props.isHovered) rules += ' in1';
        else rules += ' iv1';
        rules += ' ila1';
    }
    return rules;
};
const $9b405e0f8095dce0$export$2c99b98b77550cb4 = " -_8sjo0b-txpP0Sb1 -_8sjo0b-lt8pvGJ1";
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
