require("./Popover.css");
var $914a06b3a1c679bc$exports = require("./Provider.cjs");
var $308b180f49d82d28$exports = require("../icons/runtime.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $16fRD$reactjsxruntime = require("react/jsx-runtime");
var $16fRD$reactariacomponents = require("react-aria-components");
var $16fRD$react = require("react");
var $16fRD$reactariautils = require("@react-aria/utils");
var $16fRD$reactspectrumutils = require("@react-spectrum/utils");


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

$parcel$export(module.exports, "PopoverContext", () => $493371ef39bf7a55$export$9b9a0cd73afb7ca4);
$parcel$export(module.exports, "InPopoverContext", () => $493371ef39bf7a55$export$60dfb2c3202ad27d);
$parcel$export(module.exports, "Popover", () => $493371ef39bf7a55$export$5b6b19405a83ff9d);
/*
 * 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.
 */ 







let $493371ef39bf7a55$var$popover = function anonymous(props, overrides) {
    let rules = " ";
    let width = false;
    let maxWidth = false;
    let matches = String(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] === "Z") width = true;
        if (p[1] === "L") maxWidth = true;
        rules += p[0];
    }
    if (props.colorScheme === "dark") rules += ' _pa11';
    else if (props.colorScheme === "light") rules += ' _pb11';
    else if (props.colorScheme === "light dark") rules += ' _pc11';
    else rules += ' _pN79Hzc11';
    rules += ' -Ovbhqd-g_g11';
    rules += ' -Ovbhqd-lga11';
    rules += ' gEzkoQe11';
    rules += ' oc11';
    rules += ' nc11';
    rules += ' kc11';
    rules += ' jc11';
    if (props.isArrowShown) rules += ' _rgr5H3d11';
    if (props.isArrowShown) rules += ' _nd11';
    else rules += ' _nLeasBb11';
    rules += ' _Lf11';
    rules += ' _Mb11';
    rules += ' Oye39g11';
    rules += ' Ola11';
    if (props.size === "L") {
        if (!width) rules += ' ZE11';
    } else if (props.size === "M") {
        if (!width) rules += ' ZB11';
    } else if (props.size === "S") {
        if (!width) rules += ' Zz11';
    }
    if (!maxWidth) rules += ' LEmL1Zb11';
    rules += ' _oa11';
    rules += ' sd11';
    if (props.isExiting) rules += ' _Ia11';
    else if (props.isEntering) rules += ' _Ia11';
    if (props.isSubmenu) {
        rules += ' -_8PloMd-s11';
        rules += ' __Ya11';
    } else if (props.placement === "bottom") {
        if (props.isExiting) {
            rules += ' -_8PloMd-l11';
            rules += ' __Ya11';
        } else if (props.isEntering) {
            rules += ' -_8PloMd-l11';
            rules += ' __Ya11';
        }
    } else if (props.placement === "top") {
        if (props.isExiting) {
            rules += ' -_8PloMd-F11';
            rules += ' __Ya11';
        } else if (props.isEntering) {
            rules += ' -_8PloMd-F11';
            rules += ' __Ya11';
        }
    }
    if (props.isSubmenu) {
        rules += ' -_7PloMd-s11';
        rules += ' __Ya11';
    } else if (props.placement === "right") {
        if (props.isExiting) {
            rules += ' -_7PloMd-m11';
            rules += ' __Ya11';
        } else if (props.isEntering) {
            rules += ' -_7PloMd-m11';
            rules += ' __Ya11';
        }
    } else if (props.placement === "left") {
        if (props.isExiting) {
            rules += ' -_7PloMd-G11';
            rules += ' __Ya11';
        } else if (props.isEntering) {
            rules += ' -_7PloMd-G11';
            rules += ' __Ya11';
        }
    }
    rules += ' YmenWad11';
    rules += ' Xc11';
    if (props.isExiting) rules += ' _2c11';
    rules += ' _Bb11';
    if (props.isExiting) rules += ' _Ob11';
    return rules;
};
// TODO: animations and real Popover Arrow
let $493371ef39bf7a55$var$arrow = function anonymous(props) {
    let rules = " ";
    rules += ' sb11';
    rules += ' tEzkoQe11';
    rules += ' Zl11';
    rules += ' Fh11';
    if (props.placement === "right") rules += ' _Sd11';
    else if (props.placement === "left") rules += ' _Sa11';
    else if (props.placement === "bottom") rules += ' _Sc11';
    else if (props.placement === "top") rules += ' _Sb11';
    else rules += ' _Sc11';
    if (props.placement === "right") {
        rules += ' -_7PloMd-y11';
        rules += ' __Ya11';
    } else if (props.placement === "left") {
        rules += ' -_7PloMd-e11';
        rules += ' __Ya11';
    }
    rules += ' _Vb11';
    rules += ' Vye39g11';
    rules += ' Vlb11';
    return rules;
};
const $493371ef39bf7a55$export$9b9a0cd73afb7ca4 = /*#__PURE__*/ (0, $16fRD$react.createContext)(null);
const $493371ef39bf7a55$export$60dfb2c3202ad27d = /*#__PURE__*/ (0, $16fRD$react.createContext)(false);
const $493371ef39bf7a55$export$fde1b04c590741a3 = /*#__PURE__*/ (0, $16fRD$react.forwardRef)(function PopoverBase(props, ref) {
    let { hideArrow: hideArrow = false, UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles, size: size } = props;
    let colorScheme = (0, $16fRD$react.useContext)((0, $914a06b3a1c679bc$exports.ColorSchemeContext));
    let { locale: locale, direction: direction } = (0, $16fRD$reactariacomponents.useLocale)();
    // TODO: should we pass through lang and dir props in RAC?
    let popoverRef = (0, $16fRD$react.useCallback)((el)=>{
        if (el) {
            el.lang = locale;
            el.dir = direction;
        }
    }, [
        locale,
        direction
    ]);
    // Memoed so it doesn't break ComboBox/Picker scrolling
    let mergedRef = (0, $16fRD$react.useMemo)(()=>(0, $16fRD$reactariautils.mergeRefs)(popoverRef, ref), [
        ref,
        popoverRef
    ]);
    // On small devices, show a modal (or eventually a tray) instead of a popover.
    // TODO: reverted this until we have trays.
    // let isMobile = useIsMobileDevice();
    // if (isMobile && process.env.NODE_ENV !== 'test') {
    //   let mappedChildren = typeof children === 'function'
    //     ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})
    //     : children;
    //   return (
    //     <Modal size={size} isDismissable>
    //       {composeRenderProps(mappedChildren, (children, {state}) => (
    //         <>
    //           {children}
    //           {/* Add additional dismiss button at the end to match popovers. */}
    //           <DismissButton onDismiss={state.close} />
    //         </>
    //       ))}
    //     </Modal>
    //   );
    // }
    // TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results
    // containerPadding not working as expected
    return /*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)((0, $16fRD$reactariacomponents.Popover), {
        ...props,
        offset: (props.offset ?? 8) + (hideArrow ? 0 : 8),
        ref: mergedRef,
        style: {
            ...UNSAFE_style,
            // Override default z-index from useOverlayPosition. We use isolation: isolate instead.
            zIndex: undefined
        },
        className: (renderProps)=>UNSAFE_className + (0, $308b180f49d82d28$exports.mergeStyles)($493371ef39bf7a55$var$popover({
                ...renderProps,
                size: size,
                isArrowShown: !hideArrow,
                colorScheme: colorScheme,
                isSubmenu: renderProps.trigger === 'SubmenuTrigger'
            }), styles),
        children: (0, $16fRD$reactariacomponents.composeRenderProps)(props.children, (children, renderProps)=>/*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsxs)((0, $16fRD$reactjsxruntime.Fragment), {
                children: [
                    !hideArrow && /*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)((0, $16fRD$reactariacomponents.OverlayArrow), {
                        className: "",
                        children: /*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)("svg", {
                            viewBox: "0 0 18 10",
                            className: $493371ef39bf7a55$var$arrow(renderProps),
                            children: /*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)("path", {
                                transform: "translate(0 -1)",
                                d: "M1 1L7.93799 8.52588C8.07224 8.67448 8.23607 8.79362 8.41895 8.87524C8.60182 8.95687 8.79973 8.9993 9 9C9.19984 8.99882 9.39724 8.95606 9.57959 8.87427C9.76193 8.79248 9.9253 8.67336 10.0591 8.5249L17 1"
                            })
                        })
                    }),
                    /*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)($493371ef39bf7a55$export$60dfb2c3202ad27d.Provider, {
                        value: true,
                        children: children
                    })
                ]
            }))
    });
});
const $493371ef39bf7a55$var$innerDivStyle = function anonymous(props, overrides) {
    let rules = " ";
    let position = false;
    let width = false;
    let maxWidth = false;
    let maxHeight = false;
    let matches = String(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|F|M|K)[^\s]+/g);
    for (let p of matches){
        if (p[1] === "_P") position = true;
        if (p[1] === "Z") width = true;
        if (p[1] === "L") maxWidth = true;
        if (p[1] === "K") maxHeight = true;
        rules += p[0];
    }
    if (props.padding === "none") rules += ' Td11';
    else if (props.padding === "default") rules += ' Tt11';
    if (props.padding === "none") rules += ' Qd11';
    else if (props.padding === "default") rules += ' Qt11';
    if (props.padding === "none") rules += ' Sd11';
    else if (props.padding === "default") rules += ' St11';
    if (props.padding === "none") rules += ' Rd11';
    else if (props.padding === "default") rules += ' Rt11';
    rules += ' _oa11';
    rules += ' _Le11';
    rules += ' oi11';
    rules += ' ni11';
    rules += ' ki11';
    rules += ' ji11';
    rules += ' _Na11';
    rules += ' Pa11';
    if (!position) rules += ' _Pc11';
    if (!width) rules += ' Za11';
    if (!maxWidth) rules += ' L40ub4c11';
    if (!maxHeight) rules += ' K40ub4c11';
    return rules;
};
const $493371ef39bf7a55$export$5b6b19405a83ff9d = /*#__PURE__*/ (0, $16fRD$react.forwardRef)(function Popover(props, ref) {
    [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $493371ef39bf7a55$export$9b9a0cd73afb7ca4);
    let domRef = (0, $16fRD$reactspectrumutils.useDOMRef)(ref);
    let { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, styles: styles, padding: padding = 'default', ...otherProps } = props;
    return /*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)($493371ef39bf7a55$export$fde1b04c590741a3, {
        ...otherProps,
        ref: domRef,
        children: (0, $16fRD$reactariacomponents.composeRenderProps)(props.children, (children)=>/*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)("div", {
                style: UNSAFE_style,
                className: (UNSAFE_className || '') + $493371ef39bf7a55$var$innerDivStyle({
                    padding: padding
                }, styles),
                children: /*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)((0, $16fRD$reactariacomponents.OverlayTriggerStateContext).Provider, {
                    value: null,
                    children: children
                })
            }))
    });
});


//# sourceMappingURL=Popover.cjs.map
