require("./ActionButton.css");
var $7a26131f6144af2b$exports = require("./ActionButtonGroup.cjs");
var $38071d9ce246d4cf$exports = require("./Avatar.cjs");
var $e991cbcdf82ced71$exports = require("./CenterBaseline.cjs");
var $bde97c91243ed164$exports = require("../icons/Icon.cjs");
var $053b76ed3d29e13b$exports = require("./Image.cjs");
var $4526404114e78c80$exports = require("./intlStrings.cjs");
var $cd7301fb33ba8690$exports = require("./NotificationBadge.cjs");
var $2061c83559b50a66$exports = require("./pressScale.cjs");
var $1c116ea4b0d2d023$exports = require("./ProgressCircle.cjs");
var $5eb75e0c130e0669$exports = require("../icons/Skeleton.cjs");
var $6367bc87eb7d24ad$exports = require("./Content.cjs");
var $bfa4962d90c8af48$exports = require("./Form.cjs");
var $25d06cf8d4e72761$exports = require("./Button.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $9ZEgK$reactjsxruntime = require("react/jsx-runtime");
var $9ZEgK$reactariacomponents = require("react-aria-components");
var $9ZEgK$react = require("react");
var $9ZEgK$reactspectrumutils = require("@react-spectrum/utils");
var $9ZEgK$reactariai18n = require("@react-aria/i18n");


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}

function $parcel$export(e, n, v, s) {
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}

$parcel$export(module.exports, "btnStyles", () => $6e265ff388155b91$export$446543cff2a0f496);
$parcel$export(module.exports, "ActionButtonContext", () => $6e265ff388155b91$export$2ff682723a46d413);
$parcel$export(module.exports, "ActionButton", () => $6e265ff388155b91$export$cfc7921d29ef7b80);
/*
 * 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 $6e265ff388155b91$var$iconOnly = ':has([slot=icon], [slot=avatar]):not(:has([data-rsp-slot=text]))';
const $6e265ff388155b91$var$avatarOnly = ':has([slot=avatar]):not(:has([slot=icon], [data-rsp-slot=text]))';
const $6e265ff388155b91$var$textOnly = ':has([data-rsp-slot=text]):not(:has([slot=icon], [slot=avatar]))';
const $6e265ff388155b91$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 $6e265ff388155b91$export$446543cff2a0f496 = function anonymous(props, overrides) {
    let rules = " ";
    let minWidth = false;
    let flexShrink = false;
    let flexGrow = false;
    let flexBasis = false;
    let width = false;
    let position = 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] === "_v") flexShrink = true;
        if (p[1] === "_u") flexGrow = true;
        if (p[1] === "_s") flexBasis = true;
        if (p[1] === "Z") width = true;
        if (p[1] === "_P") position = true;
        if (p[1] === "_9") zIndex = true;
        rules += p[0];
    }
    if (props.isFocusVisible) rules += ' _Lf1';
    else rules += ' _Le1';
    if (props.isStaticColor) rules += ' Oe1';
    else rules += ' Oh1';
    rules += ' Olc1';
    rules += ' _Mc1';
    rules += ' _Kd1';
    if (props.staticColor === "white") rules += ' -Ovbhqd-gcwrnr1';
    else if (props.staticColor === "black") rules += ' -Ovbhqd-g4hn3s1';
    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';
    }
    rules += ' xc1';
    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.isStaticColor) {
        if (props.isDisabled) rules += ' pi1';
        else if (props.isSelected) rules += ' ph1';
        else {
            if (props.isPressed) rules += ' pk1';
            else if (props.isFocusVisible) rules += ' pk1';
            else if (props.isHovered) rules += ' pk1';
            else rules += ' pj1';
        }
    } else if (props.isDisabled) rules += ' pp1';
    else if (props.isSelected) {
        if (props.isEmphasized) rules += ' px1';
        else rules += ' pr1';
    } else {
        if (props.isPressed) rules += ' po1';
        else if (props.isFocusVisible) rules += ' po1';
        else if (props.isHovered) rules += ' po1';
        else rules += ' pt1';
    }
    if (props.isDisabled) rules += ' plc1';
    else if (props.isSelected) rules += ' ple1';
    else rules += ' plb1';
    rules += ' se1';
    rules += ' eb1';
    rules += ' _oa1';
    rules += ' Sv1';
    rules += ' SgLWx3bd1';
    rules += ' SsAUsHd1';
    rules += ' Rv1';
    rules += ' RgLWx3bd1';
    rules += ' RsAUsHd1';
    if (props.size === "XL") {
        if (!minWidth) rules += ' Nl1';
    } else if (props.size === "L") {
        if (!minWidth) rules += ' Nj1';
    } else if (props.size === "S") {
        if (!minWidth) rules += ' Nf1';
    } else if (props.size === "XS") {
        if (!minWidth) rules += ' Ne1';
    } else if (!minWidth) rules += ' Nk1';
    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-ob1';
    if (props.density === "compact") {
        rules += ' od1';
        rules += ' obj1';
    } else rules += ' oj1';
    if (props.density === "compact") {
        if (props.orientation === "vertical") rules += ' nbj1';
        else if (props.orientation === "horizontal") rules += ' nkj1';
        else rules += ' nd1';
    } else rules += ' nj1';
    if (props.density === "compact") {
        if (props.orientation === "vertical") rules += ' kkj1';
        else if (props.orientation === "horizontal") rules += ' kbj1';
        else rules += ' kd1';
    } else rules += ' kj1';
    if (props.density === "compact") {
        rules += ' jd1';
        rules += ' jkj1';
    } else rules += ' jj1';
    rules += ' qc1';
    rules += ' qsd1';
    rules += ' -Qg41Lb-IAxCW0c1';
    rules += ' -Qg41Lb-y5UFLdIy1';
    rules += ' -Qg41Lb-sAUsHIy1';
    rules += ' FRuFGYc1';
    rules += ' _Ca1';
    if (props.isInGroup) {
        if (!flexShrink) rules += ' _va1';
    } else if (!flexShrink) rules += ' _vb1';
    if (props.isJustified) {
        if (!flexGrow) rules += ' _ub1';
    }
    if (props.isJustified) {
        if (!flexBasis) rules += ' _sb1';
    }
    if (!width) rules += ' ZJ1';
    rules += ' _4c1';
    rules += ' Yd1';
    rules += ' Xb1';
    rules += ' _2b1';
    rules += ' _yb1';
    if (!position) rules += ' _Pc1';
    rules += ' CjpxCZ1';
    rules += ' Cy5UFLd2sgPTb1';
    rules += ' CwAP22cUolIUb1';
    rules += ' DZQmDFe1';
    rules += ' Dy5UFLdQgYBrc1';
    rules += ' DwAP22cQgYBrc1';
    rules += ' gqMFGYc1';
    rules += ' -_8sjo0b-t5ZbAob1';
    rules += ' _je1';
    if (props.isFocusVisible) {
        if (!zIndex) rules += ' _9d1';
    }
    rules += ' __ca1';
    rules += ' -B5H9Ae-WXN7eQb1';
    rules += ' -B5H9Ae-wAP22cWr1';
    rules += ' -SqFa4c-ZuUmpre1';
    rules += ' -dcAs1c-ZaP94G1';
    rules += ' -dcAs1c-wAP22cZa1';
    if (props.size === "XL") rules += ' -F_-Fz1';
    else if (props.size === "L") rules += ' -F_-Fv1';
    else if (props.size === "S") rules += ' -F_-Fp1';
    else if (props.size === "XS") rules += ' -F_-Fn1';
    else rules += ' -F_-Fx1';
    if (props.isStaticColor) {
        if (props.isSelected) {
            if (props.isDisabled) {
                if (props.isQuiet) rules += ' -g_-g91';
                else rules += ' -g_-gf1';
            } else {
                if (props.isPressed) rules += ' -g_-gj1';
                else if (props.isFocusVisible) rules += ' -g_-gj1';
                else if (props.isHovered) rules += ' -g_-gj1';
                else rules += ' -g_-gi1';
            }
        } else if (props.isPressed) rules += ' -g_-gg1';
        else if (props.isFocusVisible) rules += ' -g_-gg1';
        else if (props.isHovered) rules += ' -g_-gg1';
        else if (props.isQuiet) rules += ' -g_-g91';
        else rules += ' -g_-gf1';
    } else if (props.isSelected) {
        if (props.isDisabled) {
            if (props.isQuiet) rules += ' -g_-g91';
            else rules += ' -g_-gH1';
        } else if (props.isEmphasized) {
            if (props.isFocusVisible) rules += ' -g_-gUgARdd1';
            else if (props.isPressed) rules += ' -g_-gUgARdd1';
            else if (props.isHovered) rules += ' -g_-gUgARdd1';
            else rules += ' -g_-g5qAiPc1';
        } else {
            if (props.isPressed) rules += ' -g_-gu1';
            else if (props.isFocusVisible) rules += ' -g_-gu1';
            else if (props.isHovered) rules += ' -g_-gu1';
            else rules += ' -g_-g01';
        }
    } else {
        if (props.isPressed) rules += ' -g_-gF1';
        else if (props.isFocusVisible) rules += ' -g_-gF1';
        else if (props.isHovered) rules += ' -g_-gF1';
        else if (props.isQuiet) rules += ' -g_-g91';
        else rules += ' -g_-gH1';
    }
    if (props.isSelected) {
        if (props.isDisabled) rules += ' -g_-lgb1';
        else rules += ' -g_-lge1';
    } else rules += ' -g_-lgb1';
    return rules;
};
// Matching icon sizes. TBD.
const $6e265ff388155b91$var$avatarSize = {
    XS: 14,
    S: 16,
    M: 20,
    L: 22,
    XL: 26
};
const $6e265ff388155b91$export$2ff682723a46d413 = /*#__PURE__*/ (0, $9ZEgK$react.createContext)(null);
const $6e265ff388155b91$export$cfc7921d29ef7b80 = /*#__PURE__*/ (0, $9ZEgK$react.forwardRef)(function ActionButton(props1, ref) {
    [props1, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props1, ref, $6e265ff388155b91$export$2ff682723a46d413);
    props1 = (0, $bfa4962d90c8af48$exports.useFormProps)(props1);
    let stringFormatter = (0, $9ZEgK$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4526404114e78c80$exports))), '@react-spectrum/s2');
    let { isPending: isPending = false } = props1;
    let domRef = (0, $9ZEgK$reactspectrumutils.useFocusableRef)(ref);
    let overlayTriggerState = (0, $9ZEgK$react.useContext)((0, $9ZEgK$reactariacomponents.OverlayTriggerStateContext));
    let ctx = (0, $9ZEgK$reactariacomponents.useSlottedContext)((0, $7a26131f6144af2b$exports.ActionButtonGroupContext));
    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', isDisabled: isDisabled } = ctx || {};
    let { isProgressVisible: isProgressVisible } = (0, $25d06cf8d4e72761$exports.usePendingState)(isPending);
    return /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsx)((0, $9ZEgK$reactariacomponents.Button), {
        ...props1,
        isDisabled: props1.isDisabled ?? isDisabled,
        ref: domRef,
        style: (0, $2061c83559b50a66$exports.pressScale)(domRef, props1.UNSAFE_style),
        className: (renderProps)=>(props1.UNSAFE_className || '') + $6e265ff388155b91$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, $9ZEgK$reactjsxruntime.jsx)((0, $9ZEgK$reactjsxruntime.Fragment), {
                children: /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsxs)((0, $9ZEgK$reactariacomponents.Provider), {
                    values: [
                        [
                            (0, $5eb75e0c130e0669$exports.SkeletonContext),
                            null
                        ],
                        [
                            (0, $6367bc87eb7d24ad$exports.TextContext),
                            {
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' zYoLErc1';
                                    rules += ' yYoLErc1';
                                    rules += ' BYoLErc1';
                                    rules += ' AYoLErc1';
                                    rules += ' _Nc1';
                                    rules += ' Pc1';
                                    rules += ' _Yb1';
                                    rules += ' _7c1';
                                    if (props.isProgressVisible) rules += ' _6b1';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $bde97c91243ed164$exports.IconContext),
                            {
                                render: (0, $e991cbcdf82ced71$exports.centerBaseline)({
                                    slot: 'icon',
                                    styles: " z2U5Crc1 y2U5Crc1 B2U5Crc1 A2U5Crc1"
                                }),
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' ZuUmpre1';
                                    rules += ' FuUmpre1';
                                    rules += ' I67logd1';
                                    if (props.isProgressVisible) rules += ' _6b1';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $38071d9ce246d4cf$exports.AvatarContext),
                            {
                                size: $6e265ff388155b91$var$avatarSize[size],
                                styles: " I67logd1 z2U5Crc1 y2U5Crc1 B2U5Crc1 A2U5Crc1"
                            }
                        ],
                        [
                            (0, $053b76ed3d29e13b$exports.ImageContext),
                            {
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    if (props.isProgressVisible) rules += ' _6b1';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $cd7301fb33ba8690$exports.NotificationBadgeContext),
                            {
                                staticColor: staticColor,
                                size: props1.size === 'XS' ? undefined : props1.size,
                                isDisabled: isDisabled,
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' _Pa1';
                                    rules += ' WtedXZc1';
                                    rules += ' JlZStSb1';
                                    rules += ' Ijgro3c1';
                                    rules += ' z2mU1';
                                    rules += ' _A1IiWH1';
                                    if (props.isProgressVisible) rules += ' _6b1';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ]
                    ],
                    children: [
                        typeof props1.children === 'string' ? /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
                            children: props1.children
                        }) : props1.children,
                        isPending && /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsx)("div", {
                            className: function anonymous(props) {
                                let rules = " ";
                                rules += ' _Pa1';
                                rules += ' WF1';
                                rules += ' _EF1';
                                rules += ' _Zc1';
                                if (props.isProgressVisible) rules += ' _6c1';
                                else rules += ' _6b1';
                                return rules;
                            }({
                                isProgressVisible: isProgressVisible,
                                isPending: isPending
                            }),
                            children: /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsx)((0, $1c116ea4b0d2d023$exports.ProgressCircle), {
                                isIndeterminate: true,
                                "aria-label": stringFormatter.format('button.pending'),
                                size: "S",
                                staticColor: staticColor,
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    if (props.size === "XL") rules += ' Zo1';
                                    else if (props.size === "L") rules += ' Zm1';
                                    else if (props.size === "M") rules += ' Zl1';
                                    else if (props.size === "S") rules += ' Zk1';
                                    else if (props.size === "XS") rules += ' Zj1';
                                    if (props.size === "XL") rules += ' Fp1';
                                    else if (props.size === "L") rules += ' Fn1';
                                    else if (props.size === "M") rules += ' Fm1';
                                    else if (props.size === "S") rules += ' Fl1';
                                    else if (props.size === "XS") rules += ' Fk1';
                                    return rules;
                                }({
                                    size: size
                                })
                            })
                        })
                    ]
                })
            })
    });
});


//# sourceMappingURL=ActionButton.cjs.map
