import "./ActionButton.css";
import {ActionButtonGroupContext as $10401bdc118cbc90$export$33f5f2f2cb85d743} from "./ActionButtonGroup.mjs";
import {AvatarContext as $3ffa2cd930156220$export$a20dad690e1279e2} from "./Avatar.mjs";
import {centerBaseline as $1f4b04be3f24aae3$export$9d7e2342a7e53afa} from "./CenterBaseline.mjs";
import {IconContext as $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed} from "../icons/Icon.mjs";
import {ImageContext as $dbd6f0b2503b938c$export$8151eb379fcf2442} from "./Image.mjs";
import $hl1Zj$intlStringsmjs from "./intlStrings.mjs";
import {NotificationBadgeContext as $bfb270fb056fefc5$export$9ab75c96ebaa396c} from "./NotificationBadge.mjs";
import {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressScale.mjs";
import {ProgressCircle as $41ddd91dbbf0c389$export$c79b9d6b4cc92af7} from "./ProgressCircle.mjs";
import {SkeletonContext as $5ad421ec19460c48$export$74e166679b1f49ee} from "../icons/Skeleton.mjs";
import {Text as $8e847109a6ab556d$export$5f1af8db9871e1d6, TextContext as $8e847109a6ab556d$export$9afb8bc826b033ea} from "./Content.mjs";
import {useFormProps as $9b916426527cebe7$export$a6b5be5c6b451665} from "./Form.mjs";
import {usePendingState as $067ea9f64ccd4e8e$export$edc9ced5c3e5ff00} from "./Button.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
import {jsx as $hl1Zj$jsx, Fragment as $hl1Zj$Fragment, jsxs as $hl1Zj$jsxs} from "react/jsx-runtime";
import {OverlayTriggerStateContext as $hl1Zj$OverlayTriggerStateContext, useSlottedContext as $hl1Zj$useSlottedContext, Button as $hl1Zj$Button, Provider as $hl1Zj$Provider} from "react-aria-components";
import {createContext as $hl1Zj$createContext, forwardRef as $hl1Zj$forwardRef, useContext as $hl1Zj$useContext} from "react";
import {useFocusableRef as $hl1Zj$useFocusableRef} from "@react-spectrum/utils";
import {useLocalizedStringFormatter as $hl1Zj$useLocalizedStringFormatter} from "@react-aria/i18n";


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}
/*
 * 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.
 */ 


















// These styles handle both ActionButton and ToggleButton
const $da878a05ab4a403e$var$iconOnly = ':has([slot=icon], [slot=avatar]):not(:has([data-rsp-slot=text]))';
const $da878a05ab4a403e$var$avatarOnly = ':has([slot=avatar]):not(:has([slot=icon], [data-rsp-slot=text]))';
const $da878a05ab4a403e$var$textOnly = ':has([data-rsp-slot=text]):not(:has([slot=icon], [slot=avatar]))';
const $da878a05ab4a403e$var$controlStyle = {
    font: {
        "default": "ui",
        size: {
            XS: "ui-xs",
            S: "ui-sm",
            L: "ui-lg",
            XL: "ui-xl"
        }
    },
    display: "flex",
    alignItems: "center",
    boxSizing: "border-box",
    paddingX: {
        "default": "edge-to-text",
        ":has([slot=icon]):not(:has([data-rsp-slot=text]))": 0
    },
    minWidth: {
        "default": 32,
        size: {
            XS: 20,
            S: 24,
            L: 40,
            XL: 48
        }
    },
    "--size": {
        type: "order",
        value: {
            "default": 1,
            size: {
                XS: 0.7901234567901234,
                S: 0.8888888888888888,
                L: 1.125,
                XL: 1.265625
            }
        }
    },
    "--radius": {
        type: "borderTopStartRadius",
        value: "default"
    },
    borderRadius: "round(var(--radius) * var(--size), 1px)",
    columnGap: "text-to-visual",
    "--iconMargin": {
        type: "marginStart",
        value: {
            "default": "[-0.14285714285714285em]",
            ":has([slot=icon]):not(:has([data-rsp-slot=text]))": 0
        }
    },
    height: {
        "default": 32,
        size: {
            XS: 20,
            S: 24,
            L: 40,
            XL: 48
        }
    }
};
const $da878a05ab4a403e$export$446543cff2a0f496 = function anonymous(props, overrides) {
    let rules = " ";
    let minWidth = false;
    let position = false;
    let flexShrink = false;
    let flexGrow = false;
    let flexBasis = false;
    let zIndex = 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] === "N") minWidth = true;
        if (p[1] === "_P") position = true;
        if (p[1] === "_v") flexShrink = true;
        if (p[1] === "_u") flexGrow = true;
        if (p[1] === "_s") flexBasis = true;
        if (p[1] === "_9") zIndex = true;
        rules += p[0];
    }
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    if (props.isStaticColor) rules += ' Oe12';
    else rules += ' Oh12';
    rules += ' Olc12';
    rules += ' _Mc12';
    rules += ' _Kd12';
    if (props.staticColor === "white") rules += ' -Ovbhqd-gcwrnr12';
    else if (props.staticColor === "black") rules += ' -Ovbhqd-g4hn3s12';
    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';
    }
    rules += ' xc12';
    rules += ' _xa12';
    rules += ' xezxGHbg12';
    rules += ' _xezxGHba12';
    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.isStaticColor) {
        if (props.isDisabled) rules += ' pi12';
        else if (props.isSelected) rules += ' ph12';
        else {
            if (props.isPressed) rules += ' pk12';
            else if (props.isFocusVisible) rules += ' pk12';
            else if (props.isHovered) rules += ' pk12';
            else rules += ' pj12';
        }
    } else if (props.isDisabled) rules += ' pp12';
    else if (props.isSelected) {
        if (props.isEmphasized) rules += ' px12';
        else rules += ' pr12';
    } else {
        if (props.isPressed) rules += ' po12';
        else if (props.isFocusVisible) rules += ' po12';
        else if (props.isHovered) rules += ' po12';
        else rules += ' pt12';
    }
    if (props.isDisabled) rules += ' plc12';
    else if (props.isSelected) rules += ' ple12';
    else rules += ' plb12';
    rules += ' sd12';
    rules += ' eb12';
    rules += ' _oa12';
    rules += ' SMBFGYc12';
    rules += ' Rv12';
    rules += ' RgLWx3bd12';
    rules += ' RsAUsHd12';
    if (!minWidth) rules += ' N7yFGYc12';
    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-ob12';
    if (props.density === "compact") {
        rules += ' od12';
        rules += ' obj12';
    } else rules += ' oj12';
    if (props.density === "compact") {
        if (props.orientation === "vertical") rules += ' nbj12';
        else if (props.orientation === "horizontal") rules += ' nkj12';
        else rules += ' nd12';
    } else rules += ' nj12';
    if (props.density === "compact") {
        if (props.orientation === "vertical") rules += ' kkj12';
        else if (props.orientation === "horizontal") rules += ' kbj12';
        else rules += ' kd12';
    } else rules += ' kj12';
    if (props.density === "compact") {
        rules += ' jd12';
        rules += ' jkj12';
    } else rules += ' jj12';
    rules += ' qc12';
    rules += ' qsd12';
    rules += ' -Qg41Lb-IAxCW0c12';
    rules += ' -Qg41Lb-y5UFLdIy12';
    rules += ' -Qg41Lb-sAUsHIy12';
    rules += ' FRuFGYc12';
    if (!position) rules += ' _Pc12';
    rules += ' _Ca12';
    if (props.isInGroup) {
        if (!flexShrink) rules += ' _va12';
    } else if (!flexShrink) rules += ' _vb12';
    if (props.isJustified) {
        if (!flexGrow) rules += ' _ub12';
    }
    if (props.isJustified) {
        if (!flexBasis) rules += ' _sb12';
    }
    rules += ' _4c12';
    rules += ' Yd12';
    rules += ' Xb12';
    rules += ' _2b12';
    rules += ' _yb12';
    rules += ' gqMFGYc12';
    rules += ' -_8sjo0b-t5ZbAob12';
    rules += ' _je12';
    if (props.isFocusVisible) {
        if (!zIndex) rules += ' _9d12';
    }
    rules += ' __ca12';
    rules += ' -B5H9Ae-WXN7eQb12';
    rules += ' -B5H9Ae-wAP22cWr12';
    rules += ' -SqFa4c-ZuUmpre12';
    rules += ' -dcAs1c-ZaYffXd12';
    rules += ' -dcAs1c-y5UFLdZt9HF512';
    rules += ' -dcAs1c-wAP22cZa12';
    if (props.size === "XL") rules += ' -F_-Fz12';
    else if (props.size === "L") rules += ' -F_-Fv12';
    else if (props.size === "S") rules += ' -F_-Fp12';
    else if (props.size === "XS") rules += ' -F_-Fn12';
    else rules += ' -F_-Fx12';
    if (props.isStaticColor) {
        if (props.isSelected) {
            if (props.isDisabled) {
                if (props.isQuiet) rules += ' -g_-g912';
                else rules += ' -g_-gf12';
            } else {
                if (props.isPressed) rules += ' -g_-gj12';
                else if (props.isFocusVisible) rules += ' -g_-gj12';
                else if (props.isHovered) rules += ' -g_-gj12';
                else rules += ' -g_-gi12';
            }
        } else if (props.isPressed) rules += ' -g_-gg12';
        else if (props.isFocusVisible) rules += ' -g_-gg12';
        else if (props.isHovered) rules += ' -g_-gg12';
        else if (props.isQuiet) rules += ' -g_-g912';
        else rules += ' -g_-gf12';
    } else if (props.isSelected) {
        if (props.isDisabled) {
            if (props.isQuiet) rules += ' -g_-g912';
            else rules += ' -g_-gH12';
        } else if (props.isEmphasized) {
            if (props.isFocusVisible) rules += ' -g_-gUgARdd12';
            else if (props.isPressed) rules += ' -g_-gUgARdd12';
            else if (props.isHovered) rules += ' -g_-gUgARdd12';
            else rules += ' -g_-g5qAiPc12';
        } else {
            if (props.isPressed) rules += ' -g_-gu12';
            else if (props.isFocusVisible) rules += ' -g_-gu12';
            else if (props.isHovered) rules += ' -g_-gu12';
            else rules += ' -g_-g012';
        }
    } else {
        if (props.isPressed) rules += ' -g_-gF12';
        else if (props.isFocusVisible) rules += ' -g_-gF12';
        else if (props.isHovered) rules += ' -g_-gF12';
        else if (props.isQuiet) rules += ' -g_-g912';
        else rules += ' -g_-gH12';
    }
    if (props.isSelected) {
        if (props.isDisabled) rules += ' -g_-lgb12';
        else rules += ' -g_-lge12';
    } else rules += ' -g_-lgb12';
    rules += ' -S_-Sv12';
    rules += ' -S_-gLWx3bSd12';
    rules += ' -S_-sAUsHSd12';
    if (props.size === "XL") rules += ' -N_-Nl12';
    else if (props.size === "L") rules += ' -N_-Nj12';
    else if (props.size === "S") rules += ' -N_-Nf12';
    else if (props.size === "XS") rules += ' -N_-Ne12';
    else rules += ' -N_-Nk12';
    return rules;
};
// Matching icon sizes. TBD.
const $da878a05ab4a403e$var$avatarSize = {
    XS: 14,
    S: 16,
    M: 20,
    L: 22,
    XL: 26
};
const $da878a05ab4a403e$export$2ff682723a46d413 = /*#__PURE__*/ (0, $hl1Zj$createContext)(null);
const $da878a05ab4a403e$export$cfc7921d29ef7b80 = /*#__PURE__*/ (0, $hl1Zj$forwardRef)(function ActionButton(props1, ref) {
    [props1, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props1, ref, $da878a05ab4a403e$export$2ff682723a46d413);
    props1 = (0, $9b916426527cebe7$export$a6b5be5c6b451665)(props1);
    let stringFormatter = (0, $hl1Zj$useLocalizedStringFormatter)((0, ($parcel$interopDefault($hl1Zj$intlStringsmjs))), '@react-spectrum/s2');
    let { isPending: isPending = false } = props1;
    let domRef = (0, $hl1Zj$useFocusableRef)(ref);
    let overlayTriggerState = (0, $hl1Zj$useContext)((0, $hl1Zj$OverlayTriggerStateContext));
    let ctx = (0, $hl1Zj$useSlottedContext)((0, $10401bdc118cbc90$export$33f5f2f2cb85d743));
    let isInGroup = !!ctx;
    let { density: density = 'regular', isJustified: isJustified, orientation: orientation = 'horizontal', staticColor: staticColor = props1.staticColor, isQuiet: isQuiet = props1.isQuiet, size: size = props1.size || 'M' } = ctx || {};
    let { isProgressVisible: isProgressVisible } = (0, $067ea9f64ccd4e8e$export$edc9ced5c3e5ff00)(isPending);
    return /*#__PURE__*/ (0, $hl1Zj$jsx)((0, $hl1Zj$Button), {
        ...props1,
        ref: domRef,
        style: (0, $10ea7662e51a285b$export$56e8cba416805d8d)(domRef, props1.UNSAFE_style),
        className: (renderProps)=>(props1.UNSAFE_className || '') + $da878a05ab4a403e$export$446543cff2a0f496({
                ...renderProps,
                // Retain hover styles when an overlay is open.
                isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,
                isDisabled: renderProps.isDisabled || isProgressVisible,
                staticColor: staticColor,
                isStaticColor: !!staticColor,
                size: size,
                isQuiet: isQuiet,
                density: density,
                isJustified: isJustified,
                orientation: orientation,
                isInGroup: isInGroup
            }, props1.styles),
        children: ({ isDisabled: isDisabled })=>/*#__PURE__*/ (0, $hl1Zj$jsx)((0, $hl1Zj$Fragment), {
                children: /*#__PURE__*/ (0, $hl1Zj$jsxs)((0, $hl1Zj$Provider), {
                    values: [
                        [
                            (0, $5ad421ec19460c48$export$74e166679b1f49ee),
                            null
                        ],
                        [
                            (0, $8e847109a6ab556d$export$9afb8bc826b033ea),
                            {
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' _Jb12';
                                    rules += ' _Nc12';
                                    rules += ' Pc12';
                                    rules += ' _Yb12';
                                    rules += ' _7c12';
                                    if (props.isProgressVisible) rules += ' _6b12';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed),
                            {
                                render: (0, $1f4b04be3f24aae3$export$9d7e2342a7e53afa)({
                                    slot: 'icon',
                                    styles: " _Ja12"
                                }),
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' ZuUmpre12';
                                    rules += ' FuUmpre12';
                                    rules += ' I67logd12';
                                    rules += ' _va12';
                                    if (props.isProgressVisible) rules += ' _6b12';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $3ffa2cd930156220$export$a20dad690e1279e2),
                            {
                                size: $da878a05ab4a403e$var$avatarSize[size],
                                styles: " I67logd12 _va12 _Ja12"
                            }
                        ],
                        [
                            (0, $dbd6f0b2503b938c$export$8151eb379fcf2442),
                            {
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    if (props.isProgressVisible) rules += ' _6b12';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $bfb270fb056fefc5$export$9ab75c96ebaa396c),
                            {
                                staticColor: staticColor,
                                size: props1.size === 'XS' ? undefined : props1.size,
                                isDisabled: isDisabled,
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' _Pa12';
                                    rules += ' WtedXZc12';
                                    rules += ' _A1IiWH12';
                                    rules += ' JlZStSb12';
                                    rules += ' IlZStSb12';
                                    if (props.isProgressVisible) rules += ' _6b12';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ]
                    ],
                    children: [
                        typeof props1.children === 'string' ? /*#__PURE__*/ (0, $hl1Zj$jsx)((0, $8e847109a6ab556d$export$5f1af8db9871e1d6), {
                            children: props1.children
                        }) : props1.children,
                        isPending && /*#__PURE__*/ (0, $hl1Zj$jsx)("div", {
                            className: function anonymous(props) {
                                let rules = " ";
                                rules += ' _Pa12';
                                rules += ' WF12';
                                rules += ' _EF12';
                                rules += ' _Zc12';
                                if (props.isProgressVisible) rules += ' _6c12';
                                else rules += ' _6b12';
                                return rules;
                            }({
                                isProgressVisible: isProgressVisible,
                                isPending: isPending
                            }),
                            children: /*#__PURE__*/ (0, $hl1Zj$jsx)((0, $41ddd91dbbf0c389$export$c79b9d6b4cc92af7), {
                                isIndeterminate: true,
                                "aria-label": stringFormatter.format('button.pending'),
                                size: "S",
                                staticColor: staticColor,
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    if (props.size === "XL") rules += ' Zo12';
                                    else if (props.size === "L") rules += ' Zm12';
                                    else if (props.size === "M") rules += ' Zl12';
                                    else if (props.size === "S") rules += ' Zk12';
                                    else if (props.size === "XS") rules += ' Zj12';
                                    if (props.size === "XL") rules += ' Fp12';
                                    else if (props.size === "L") rules += ' Fn12';
                                    else if (props.size === "M") rules += ' Fm12';
                                    else if (props.size === "S") rules += ' Fl12';
                                    else if (props.size === "XS") rules += ' Fk12';
                                    return rules;
                                }({
                                    size: size
                                })
                            })
                        })
                    ]
                })
            })
    });
});


export {$da878a05ab4a403e$export$446543cff2a0f496 as btnStyles, $da878a05ab4a403e$export$2ff682723a46d413 as ActionButtonContext, $da878a05ab4a403e$export$cfc7921d29ef7b80 as ActionButton};
//# sourceMappingURL=ActionButton.mjs.map
