require("./TreeView.css");
var $7a26131f6144af2b$exports = require("./ActionButtonGroup.cjs");
var $e5a758dd286599f2$exports = require("./ActionMenu.cjs");
var $e991cbcdf82ced71$exports = require("./CenterBaseline.cjs");
var $af04e099a53d3e85$exports = require("./Checkbox.cjs");
var $1df9f1c9262ce5df$exports = require("./Chevron.cjs");
var $bde97c91243ed164$exports = require("../icons/Icon.cjs");
var $4526404114e78c80$exports = require("./intlStrings.cjs");
var $1c116ea4b0d2d023$exports = require("./ProgressCircle.cjs");
var $6367bc87eb7d24ad$exports = require("./Content.cjs");
var $85bf454149fe9ddc$exports = require("./ActionBar.cjs");
var $ee7b4c497f520c08$exports = require("./utils.cjs");
var $6K4Mt$reactjsxruntime = require("react/jsx-runtime");
var $6K4Mt$reactariacomponents = require("react-aria-components");
var $6K4Mt$react = require("react");
var $6K4Mt$reactspectrumutils = require("@react-spectrum/utils");
var $6K4Mt$reactaria = require("react-aria");


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, "TreeView", () => $8a2a97a0cb171e69$export$6940b0d9c820eca7);
$parcel$export(module.exports, "TreeViewItem", () => $8a2a97a0cb171e69$export$6e77ea6719814e9c);
$parcel$export(module.exports, "TreeViewItemContent", () => $8a2a97a0cb171e69$export$9a5779ed3fade674);
$parcel$export(module.exports, "TreeViewLoadMoreItem", () => $8a2a97a0cb171e69$export$6ceebe2a029205c);
/*
 * 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 $8a2a97a0cb171e69$var$TreeRendererContext = /*#__PURE__*/ (0, $6K4Mt$react.createContext)({});
const $8a2a97a0cb171e69$var$treeViewWrapper = function anonymous(props, overrides) {
    let rules = " ";
    let minHeight = false;
    let minWidth = false;
    let position = 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] === "M") minHeight = true;
        if (p[1] === "N") minWidth = true;
        if (p[1] === "_P") position = true;
        rules += p[0];
    }
    if (!minHeight) rules += ' Ma12';
    if (!minWidth) rules += ' Na12';
    rules += ' sd12';
    rules += ' _Bb12';
    rules += ' __ca12';
    if (!position) rules += ' _Pc12';
    rules += ' _Nb12';
    rules += ' Pb12';
    return rules;
};
// TODO: the below is needed so the borders of the top and bottom row isn't cut off if the TreeView is wrapped within a container by always reserving the 2px needed for the
// keyboard focus ring. Perhaps find a different way of rendering the outlines since the top of the item doesn't
// scroll into view due to how the ring is offset. Alternatively, have the tree render the top/bottom outline like it does in Listview
const $8a2a97a0cb171e69$var$tree = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    rules += ' Oh12';
    rules += ' Olc12';
    rules += ' _Mc12';
    rules += ' _Kb12';
    rules += ' _4c12';
    rules += ' Ma12';
    rules += ' Na12';
    rules += ' Za12';
    rules += ' Fb12';
    rules += ' _Na12';
    rules += ' Pa12';
    rules += ' _oa12';
    if (props.isEmpty) rules += ' _Ca12';
    if (props.isEmpty) rules += ' eb12';
    rules += ' -lPUMEc-Zu12';
    return rules;
};
const $8a2a97a0cb171e69$export$6940b0d9c820eca7 = /*#__PURE__*/ (0, $6K4Mt$react.forwardRef)(function TreeView(props, ref) {
    let { children: children, UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style } = props;
    let scale = (0, $ee7b4c497f520c08$exports.useScale)();
    let renderer;
    if (typeof children === 'function') renderer = children;
    let domRef = (0, $6K4Mt$reactspectrumutils.useDOMRef)(ref);
    let scrollRef = (0, $6K4Mt$react.useRef)(null);
    let { selectedKeys: selectedKeys, onSelectionChange: onSelectionChange, actionBar: actionBar, actionBarHeight: actionBarHeight } = (0, $85bf454149fe9ddc$exports.useActionBarContainer)({
        ...props,
        scrollRef: scrollRef
    });
    let treeContent = /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.Virtualizer), {
        layout: (0, $6K4Mt$reactariacomponents.ListLayout),
        layoutOptions: {
            rowHeight: scale === 'large' ? 50 : 40
        },
        children: /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)($8a2a97a0cb171e69$var$TreeRendererContext.Provider, {
            value: {
                renderer: renderer
            },
            children: /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.Tree), {
                ...props,
                style: {
                    ...!props.renderActionBar ? UNSAFE_style : {},
                    paddingBottom: actionBarHeight > 0 ? actionBarHeight + 8 : 0,
                    scrollPaddingBottom: actionBarHeight > 0 ? actionBarHeight + 8 : 0
                },
                className: (renderProps)=>(!props.renderActionBar ? UNSAFE_className ?? '' : '') + $8a2a97a0cb171e69$var$tree({
                        ...renderProps
                    }),
                selectionBehavior: "toggle",
                selectedKeys: selectedKeys,
                defaultSelectedKeys: undefined,
                onSelectionChange: onSelectionChange,
                ref: props.renderActionBar ? scrollRef : domRef,
                children: props.children
            })
        })
    });
    if (props.renderActionBar) return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsxs)("div", {
        ref: domRef,
        className: (UNSAFE_className ?? '') + $8a2a97a0cb171e69$var$treeViewWrapper(null, props.styles),
        style: UNSAFE_style,
        children: [
            treeContent,
            actionBar
        ]
    });
    return treeContent;
});
const $8a2a97a0cb171e69$var$rowBackgroundColor = {
    default: '--s2-container-bg',
    isFocusVisibleWithin: "[color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(19, 19, 19), rgb(242, 242, 242)) 7%)]",
    isHovered: "[color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(19, 19, 19), rgb(242, 242, 242)) 7%)]",
    isPressed: "[color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(19, 19, 19), rgb(242, 242, 242)) 10%)]",
    isSelected: {
        default: "[color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(19, 19, 19), rgb(242, 242, 242)) 7%)]",
        isFocusVisibleWithin: "[color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(19, 19, 19), rgb(242, 242, 242)) 10%)]",
        isHovered: "[color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(19, 19, 19), rgb(242, 242, 242)) 10%)]",
        isPressed: "[color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(19, 19, 19), rgb(242, 242, 242)) 10%)]"
    },
    forcedColors: {
        default: 'Background'
    }
};
const $8a2a97a0cb171e69$var$treeRow = function anonymous(props) {
    let rules = " ";
    rules += ' _Pc12';
    rules += ' sd12';
    rules += ' Fv12';
    rules += ' Za12';
    rules += ' _oa12';
    rules += ' uk12';
    rules += ' ucJ9TBTb12';
    rules += ' ud3Euai12';
    rules += ' uea12';
    rules += ' ugb12';
    rules += ' uhd12';
    rules += ' uje12';
    rules += ' u2NhKxcl12';
    rules += ' uic12';
    rules += ' -_6BNtrc-c12';
    rules += ' vx12';
    rules += ' xb12';
    rules += ' _xa12';
    rules += ' _Fd12';
    rules += ' _FnuYUweb12';
    if (props.isSelected) {
        if (props.isPressed) rules += ' po12';
        else if (props.isFocusVisible) rules += ' po12';
        else if (props.isHovered) rules += ' po12';
        else rules += ' pt12';
    } else {
        if (props.isPressed) rules += ' pt12';
        else if (props.isFocusVisible) rules += ' pt12';
        else if (props.isHovered) rules += ' pt12';
        else rules += ' pv12';
    }
    rules += ' plb12';
    rules += ' _Le12';
    if (props.isLink) rules += ' ry12';
    else rules += ' ri12';
    if (props.isSelected) {
        if (props.isPressed) rules += ' -qH4xad-gRfT7e12';
        else if (props.isHovered) rules += ' -qH4xad-gRfT7e12';
        else if (props.isFocusVisibleWithin) rules += ' -qH4xad-gRfT7e12';
        else rules += ' -qH4xad-gj1B7i12';
    } else if (props.isPressed) rules += ' -qH4xad-gRfT7e12';
    else if (props.isHovered) rules += ' -qH4xad-gj1B7i12';
    else if (props.isFocusVisibleWithin) rules += ' -qH4xad-gj1B7i12';
    else rules += ' -qH4xad-gEzkoQe12';
    rules += ' -qH4xad-lga12';
    rules += ' -_34HbNb-Oh12';
    rules += ' -_34HbNb-lOc12';
    return rules;
};
const $8a2a97a0cb171e69$var$treeCellGrid = function anonymous(props) {
    let rules = " ";
    rules += ' se12';
    rules += ' Za12';
    rules += ' Fb12';
    rules += ' _oa12';
    rules += ' _cb12';
    rules += ' eb12';
    rules += ' Dw9uTxc12';
    rules += ' EM8Mfn12';
    rules += ' CgjMZ2c12';
    rules += ' gs9yXOb12';
    rules += ' Rp12';
    if (props.isDisabled) {
        rules += ' pp12';
        rules += ' plc12';
    }
    if (props.isFocusVisible) rules += ' -_7xg3bb-Oh12';
    else rules += ' -_7xg3bb-O8Izf8c12';
    rules += ' -_7xg3bb-lOc12';
    rules += ' -pKMv1c-Oh12';
    rules += ' -pKMv1c-lOc12';
    return rules;
};
const $8a2a97a0cb171e69$var$treeCheckbox = function anonymous(props) {
    let rules = " ";
    rules += ' zoRzcu12';
    rules += ' yoRzcu12';
    rules += ' BoRzcu12';
    rules += ' AoRzcu12';
    rules += ' Ix12';
    rules += ' Hy12';
    rules += ' Rd12';
    if (props.isDisabled) rules += ' _6b12';
    else rules += ' _6c12';
    return rules;
};
const $8a2a97a0cb171e69$var$treeIcon = " z2U5Crc12 y2U5Crc12 B2U5Crc12 A2U5Crc12 Ht12 Hsu12 -_8sjo0b-t5ZbAob12";
const $8a2a97a0cb171e69$var$treeContent = " zk52g2d12 yk52g2d12 Bk52g2d12 Ak52g2d12 _Yb12 _7c12 _Nc12 Pc12";
const $8a2a97a0cb171e69$var$treeActions = " zkG38H12 ykG38H12 BkG38H12 AkG38H12 Ir12 Hs12";
const $8a2a97a0cb171e69$var$treeActionMenu = " z6Nrfjc12 y6Nrfjc12 B6Nrfjc12 A6Nrfjc12";
const $8a2a97a0cb171e69$var$treeRowFocusIndicator = "tDhuzb";
const $8a2a97a0cb171e69$export$6e77ea6719814e9c = (props)=>{
    let { href: href } = props;
    return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.TreeItem), {
        ...props,
        className: (renderProps)=>$8a2a97a0cb171e69$var$treeRow({
                ...renderProps,
                isLink: !!href
            }) + (renderProps.isFocusVisible ? ' ' + $8a2a97a0cb171e69$var$treeRowFocusIndicator : '')
    });
};
const $8a2a97a0cb171e69$export$9a5779ed3fade674 = (props)=>{
    let { children: children } = props;
    let scale = (0, $ee7b4c497f520c08$exports.useScale)();
    return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.TreeItemContent), {
        children: ({ isExpanded: isExpanded, hasChildItems: hasChildItems, selectionMode: selectionMode, selectionBehavior: selectionBehavior, isDisabled: isDisabled, isSelected: isSelected, id: id, state: state })=>{
            let isNextSelected = false;
            let isNextFocused = false;
            let keyAfter = state.collection.getKeyAfter(id);
            if (keyAfter != null) isNextSelected = state.selectionManager.isSelected(keyAfter);
            let isFirst = state.collection.getFirstKey() === id;
            return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsxs)("div", {
                className: $8a2a97a0cb171e69$var$treeCellGrid({
                    isDisabled: isDisabled,
                    isNextSelected: isNextSelected,
                    isSelected: isSelected,
                    isFirst: isFirst,
                    isNextFocused: isNextFocused
                }),
                children: [
                    selectionMode !== 'none' && selectionBehavior === 'toggle' && // TODO: add transition?
                    /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)("div", {
                        className: $8a2a97a0cb171e69$var$treeCheckbox({
                            isDisabled: isDisabled || !state.selectionManager.canSelectItem(id) || state.disabledKeys.has(id)
                        }),
                        children: /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $af04e099a53d3e85$exports.Checkbox), {
                            slot: "selection"
                        })
                    }),
                    /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)("div", {
                        className: " z7fSmKc12 y7fSmKc12 B7fSmKc12 A7fSmKc12 ZecPNad12"
                    }),
                    /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)($8a2a97a0cb171e69$var$ExpandableRowChevron, {
                        isDisabled: isDisabled,
                        isExpanded: isExpanded,
                        scale: scale,
                        isHidden: !hasChildItems
                    }),
                    /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.Provider), {
                        values: [
                            [
                                (0, $6367bc87eb7d24ad$exports.TextContext),
                                {
                                    styles: $8a2a97a0cb171e69$var$treeContent
                                }
                            ],
                            [
                                (0, $bde97c91243ed164$exports.IconContext),
                                {
                                    render: (0, $e991cbcdf82ced71$exports.centerBaseline)({
                                        slot: 'icon',
                                        styles: $8a2a97a0cb171e69$var$treeIcon
                                    }),
                                    styles: " ZuUmpre12 FuUmpre12 _va12"
                                }
                            ],
                            [
                                (0, $7a26131f6144af2b$exports.ActionButtonGroupContext),
                                {
                                    styles: $8a2a97a0cb171e69$var$treeActions,
                                    isDisabled: isDisabled
                                }
                            ],
                            [
                                (0, $e5a758dd286599f2$exports.ActionMenuContext),
                                {
                                    styles: $8a2a97a0cb171e69$var$treeActionMenu,
                                    isQuiet: true,
                                    isDisabled: isDisabled
                                }
                            ]
                        ],
                        children: typeof children === 'string' ? /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
                            children: children
                        }) : children
                    })
                ]
            });
        }
    });
};
const $8a2a97a0cb171e69$var$centeredWrapper = " sd12 eb12 _Ca12 Za12 Fb12";
const $8a2a97a0cb171e69$export$6ceebe2a029205c = (props)=>{
    let { loadingState: loadingState, onLoadMore: onLoadMore } = props;
    let stringFormatter = (0, $6K4Mt$reactaria.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4526404114e78c80$exports))), '@react-spectrum/s2');
    let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
    return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.TreeLoadMoreItem), {
        isLoading: isLoading,
        onLoadMore: onLoadMore,
        className: " Za12 Js12 Gs12",
        children: ()=>{
            return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)("div", {
                className: $8a2a97a0cb171e69$var$centeredWrapper,
                children: /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $1c116ea4b0d2d023$exports.ProgressCircle), {
                    isIndeterminate: true,
                    "aria-label": stringFormatter.format('table.loadingMore')
                })
            });
        }
    });
};
const $8a2a97a0cb171e69$var$expandButton = function anonymous(props) {
    let rules = " ";
    rules += ' z8dW5Qb12';
    rules += ' y8dW5Qb12';
    rules += ' B8dW5Qb12';
    rules += ' A8dW5Qb12';
    if (props.isDisabled) {
        rules += ' pp12';
        rules += ' plc12';
    } else rules += ' p40ub4c12';
    rules += ' Fv12';
    rules += ' Zw12';
    rules += ' sd12';
    rules += ' _wb12';
    rules += ' _cb12';
    rules += ' _Ca12';
    rules += ' _Le12';
    rules += ' ri12';
    if (props.isExpanded) {
        if (props.isRTL) rules += ' _Za12';
        else rules += ' _Zb12';
    }
    rules += ' Td12';
    rules += ' Qd12';
    rules += ' Sd12';
    rules += ' Rd12';
    rules += ' Yd12';
    rules += ' Xb12';
    rules += ' _2b12';
    rules += ' g912';
    rules += ' _je12';
    rules += ' __ca12';
    if (props.isHidden) rules += ' _6b12';
    return rules;
};
function $8a2a97a0cb171e69$var$ExpandableRowChevron(props1) {
    let expandButtonRef = (0, $6K4Mt$react.useRef)(null);
    let [fullProps, ref] = (0, $6K4Mt$reactariacomponents.useContextProps)({
        ...props1,
        slot: 'chevron'
    }, expandButtonRef, (0, $6K4Mt$reactariacomponents.ButtonContext));
    let { isExpanded: isExpanded, scale: scale, isHidden: isHidden } = fullProps;
    let { direction: direction } = (0, $6K4Mt$reactaria.useLocale)();
    return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.Button), {
        ...props1,
        ref: ref,
        slot: "chevron",
        className: (renderProps)=>$8a2a97a0cb171e69$var$expandButton({
                ...renderProps,
                isExpanded: isExpanded,
                isRTL: direction === 'rtl',
                scale: scale,
                isHidden: isHidden
            }),
        children: /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $1df9f1c9262ce5df$exports.default), {
            className: function anonymous(props) {
                let rules = " ";
                if (props.direction === "rtl") {
                    rules += ' -Z4Pn4c-a12';
                    rules += ' __Ha12';
                } else if (props.direction === "ltr") {
                    rules += ' -Z4Pn4c-b12';
                    rules += ' __Ha12';
                }
                if (props.direction === "rtl") {
                    rules += ' -_04Pn4c-a12';
                    rules += ' __Ha12';
                } else if (props.direction === "ltr") {
                    rules += ' -_04Pn4c-b12';
                    rules += ' __Ha12';
                }
                rules += ' -_8sjo0b-t5ZbAob12';
                return rules;
            }({
                direction: direction
            })
        })
    });
}


//# sourceMappingURL=TreeView.cjs.map
