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 $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)({});
// 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, overrides) {
    let rules = " ";
    let minHeight = false;
    let minWidth = false;
    let width = false;
    let height = 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|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] === "Z") width = true;
        if (p[1] === "F") height = true;
        rules += p[0];
    }
    if (props.isFocusVisible) rules += ' _Lf1';
    else rules += ' _Le1';
    rules += ' Oh1';
    rules += ' Olc1';
    rules += ' _Mc1';
    rules += ' _Kb1';
    rules += ' _4c1';
    if (!minHeight) rules += ' Ma1';
    if (!minWidth) rules += ' Na1';
    if (!width) rules += ' Za1';
    if (!height) rules += ' Fb1';
    rules += ' _Na1';
    rules += ' Pa1';
    rules += ' _oa1';
    if (props.isEmpty) rules += ' _Ca1';
    if (props.isEmpty) rules += ' eb1';
    rules += ' -lPUMEc-Zu1';
    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);
    return /*#__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: UNSAFE_style,
                className: (renderProps)=>(UNSAFE_className ?? '') + $8a2a97a0cb171e69$var$tree({
                        ...renderProps
                    }, props.styles),
                selectionBehavior: "toggle",
                ref: domRef,
                children: props.children
            })
        })
    });
});
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 += ' _Pc1';
    rules += ' sd1';
    rules += ' Fv1';
    rules += ' Za1';
    rules += ' _oa1';
    rules += ' uk1';
    rules += ' ucJ9TBTb1';
    rules += ' ud3Euai1';
    rules += ' uea1';
    rules += ' ugb1';
    rules += ' uhd1';
    rules += ' uje1';
    rules += ' u2NhKxcl1';
    rules += ' uic1';
    rules += ' -_6BNtrc-c1';
    rules += ' vx1';
    rules += ' xb1';
    rules += ' _xa1';
    rules += ' _Fd1';
    rules += ' _FnuYUweb1';
    if (props.isSelected) {
        if (props.isPressed) rules += ' po1';
        else if (props.isFocusVisible) rules += ' po1';
        else if (props.isHovered) rules += ' po1';
        else rules += ' pt1';
    } else {
        if (props.isPressed) rules += ' pt1';
        else if (props.isFocusVisible) rules += ' pt1';
        else if (props.isHovered) rules += ' pt1';
        else rules += ' pv1';
    }
    rules += ' plb1';
    rules += ' _Le1';
    if (props.isLink) rules += ' ry1';
    else rules += ' ri1';
    if (props.isSelected) {
        if (props.isPressed) rules += ' -qH4xad-gRfT7e1';
        else if (props.isHovered) rules += ' -qH4xad-gRfT7e1';
        else if (props.isFocusVisibleWithin) rules += ' -qH4xad-gRfT7e1';
        else rules += ' -qH4xad-gj1B7i1';
    } else if (props.isPressed) rules += ' -qH4xad-gRfT7e1';
    else if (props.isHovered) rules += ' -qH4xad-gj1B7i1';
    else if (props.isFocusVisibleWithin) rules += ' -qH4xad-gj1B7i1';
    else rules += ' -qH4xad-gEzkoQe1';
    rules += ' -qH4xad-lga1';
    rules += ' -_34HbNb-Oh1';
    rules += ' -_34HbNb-lOc1';
    return rules;
};
const $8a2a97a0cb171e69$var$treeCellGrid = function anonymous(props) {
    let rules = " ";
    rules += ' se1';
    rules += ' Za1';
    rules += ' Fb1';
    rules += ' _oa1';
    rules += ' _cb1';
    rules += ' eb1';
    rules += ' Dw9uTxc1';
    rules += ' EM8Mfn1';
    rules += ' CgjMZ2c1';
    rules += ' gs9yXOb1';
    rules += ' Rp1';
    if (props.isDisabled) {
        rules += ' pp1';
        rules += ' plc1';
    }
    if (props.isFocusVisible) rules += ' -_7xg3bb-Oh1';
    else rules += ' -_7xg3bb-O8Izf8c1';
    rules += ' -_7xg3bb-lOc1';
    rules += ' -pKMv1c-Oh1';
    rules += ' -pKMv1c-lOc1';
    return rules;
};
const $8a2a97a0cb171e69$var$treeCheckbox = " zoRzcu1 yoRzcu1 BoRzcu1 AoRzcu1 Ix1 Hy1 Rd1";
const $8a2a97a0cb171e69$var$treeIcon = " z2U5Crc1 y2U5Crc1 B2U5Crc1 A2U5Crc1 Ht1 Hsu1 -_8sjo0b-t5ZbAob1";
const $8a2a97a0cb171e69$var$treeContent = " zk52g2d1 yk52g2d1 Bk52g2d1 Ak52g2d1 _Yb1 _7c1 _Nc1 Pc1";
const $8a2a97a0cb171e69$var$treeActions = " zkG38H1 ykG38H1 BkG38H1 AkG38H1 Ir1 Hs1";
const $8a2a97a0cb171e69$var$treeActionMenu = " z6Nrfjc1 y6Nrfjc1 B6Nrfjc1 A6Nrfjc1";
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,
                        children: /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $af04e099a53d3e85$exports.Checkbox), {
                            slot: "selection"
                        })
                    }),
                    /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)("div", {
                        className: " z7fSmKc1 y7fSmKc1 B7fSmKc1 A7fSmKc1 ZecPNad1"
                    }),
                    /*#__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: " ZuUmpre1 FuUmpre1 _va1"
                                }
                            ],
                            [
                                (0, $7a26131f6144af2b$exports.ActionButtonGroupContext),
                                {
                                    styles: $8a2a97a0cb171e69$var$treeActions
                                }
                            ],
                            [
                                (0, $e5a758dd286599f2$exports.ActionMenuContext),
                                {
                                    styles: $8a2a97a0cb171e69$var$treeActionMenu,
                                    isQuiet: true
                                }
                            ]
                        ],
                        children: typeof children === 'string' ? /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
                            children: children
                        }) : children
                    })
                ]
            });
        }
    });
};
const $8a2a97a0cb171e69$var$centeredWrapper = " sd1 eb1 _Ca1 Za1 Fb1";
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: " Za1 Js1 Gs1",
        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 += ' z8dW5Qb1';
    rules += ' y8dW5Qb1';
    rules += ' B8dW5Qb1';
    rules += ' A8dW5Qb1';
    if (props.isDisabled) {
        rules += ' pp1';
        rules += ' plc1';
    } else rules += ' p40ub4c1';
    rules += ' Fv1';
    rules += ' Zw1';
    rules += ' sd1';
    rules += ' _wb1';
    rules += ' _cb1';
    rules += ' _Ca1';
    rules += ' _Le1';
    rules += ' ri1';
    if (props.isExpanded) {
        if (props.isRTL) rules += ' _Za1';
        else rules += ' _Zb1';
    }
    rules += ' Td1';
    rules += ' Qd1';
    rules += ' Sd1';
    rules += ' Rd1';
    rules += ' Yd1';
    rules += ' Xb1';
    rules += ' _2b1';
    rules += ' g91';
    rules += ' _je1';
    rules += ' __ca1';
    if (props.isHidden) rules += ' _6b1';
    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-a1';
                    rules += ' __Ha1';
                } else if (props.direction === "ltr") {
                    rules += ' -Z4Pn4c-b1';
                    rules += ' __Ha1';
                }
                if (props.direction === "rtl") {
                    rules += ' -_04Pn4c-a1';
                    rules += ' __Ha1';
                } else if (props.direction === "ltr") {
                    rules += ' -_04Pn4c-b1';
                    rules += ' __Ha1';
                }
                rules += ' -_8sjo0b-t5ZbAob1';
                return rules;
            }({
                direction: direction
            })
        })
    });
}


//# sourceMappingURL=TreeView.cjs.map
