import "./TableView.css";
import {ActionButton as $da878a05ab4a403e$export$cfc7921d29ef7b80, ActionButtonContext as $da878a05ab4a403e$export$2ff682723a46d413} from "./ActionButton.mjs";
import {Checkbox as $9b405e0f8095dce0$export$48513f6b9f8ce62d} from "./Checkbox.mjs";
import $4bb2fe02f5143bcc$export$2e2bcd8739ae039 from "../icons/Checkmark.mjs";
import $4b69f02ec06b9226$export$2e2bcd8739ae039 from "./Chevron.mjs";
import $11111a8204dcac81$export$2e2bcd8739ae039 from "../icons/Close.mjs";
import {IconContext as $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed} from "../icons/Icon.mjs";
import $auVFN$intlStringsmjs from "./intlStrings.mjs";
import {Menu as $13afb0ea5f0ed767$export$d9b273488cd8ce6f, MenuItem as $13afb0ea5f0ed767$export$2ce376c2cc3355c8, MenuSection as $13afb0ea5f0ed767$export$4b1545b4f2016d26, MenuTrigger as $13afb0ea5f0ed767$export$27d2ad3c5815583e} from "./Menu.mjs";
import $1bdd184cd8a3d21d$export$2e2bcd8739ae039 from "./S2_MoveHorizontalTableWidget.mjs";
import {ProgressCircle as $41ddd91dbbf0c389$export$c79b9d6b4cc92af7} from "./ProgressCircle.mjs";
import $5a632e895c21f138$export$2e2bcd8739ae039 from "../icons/SortDown.mjs";
import $415c33109ddcfc45$export$2e2bcd8739ae039 from "../icons/SortUp.mjs";
import {useActionBarContainer as $f21f2186348fbc5b$export$13f32e21845e01d0} from "./ActionBar.mjs";
import {useScale as $859432f3b3573fcb$export$a8d2043b2d807f4d} from "./utils.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
import {jsxs as $auVFN$jsxs, jsx as $auVFN$jsx, Fragment as $auVFN$Fragment} from "react/jsx-runtime";
import {Rect as $auVFN$Rect, TableLayout as $auVFN$TableLayout, ResizableTableContainer as $auVFN$ResizableTableContainer, Virtualizer as $auVFN$Virtualizer, Table as $auVFN$Table, TableLoadMoreItem as $auVFN$TableLoadMoreItem, Collection as $auVFN$Collection, TableBody as $auVFN$TableBody, Column as $auVFN$Column, Provider as $auVFN$Provider, Button as $auVFN$Button, ColumnResizer as $auVFN$ColumnResizer, useTableOptions as $auVFN$useTableOptions, TableHeader as $auVFN$TableHeader, useSlottedContext as $auVFN$useSlottedContext, CheckboxContext as $auVFN$CheckboxContext, Cell as $auVFN$Cell, ButtonContext as $auVFN$ButtonContext, DEFAULT_SLOT as $auVFN$DEFAULT_SLOT, Popover as $auVFN$Popover, OverlayTriggerStateContext as $auVFN$OverlayTriggerStateContext, Form as $auVFN$Form, Row as $auVFN$Row} from "react-aria-components";
import {useObjectRef as $auVFN$useObjectRef, useLayoutEffect as $auVFN$useLayoutEffect, getActiveElement as $auVFN$getActiveElement, getOwnerDocument as $auVFN$getOwnerDocument} from "@react-aria/utils";
import {createContext as $auVFN$createContext, forwardRef as $auVFN$forwardRef, useState as $auVFN$useState, useCallback as $auVFN$useCallback, useMemo as $auVFN$useMemo, useRef as $auVFN$useRef, useContext as $auVFN$useContext, useEffect as $auVFN$useEffect} from "react";
import {useDOMRef as $auVFN$useDOMRef} from "@react-spectrum/utils";
import {useLocalizedStringFormatter as $auVFN$useLocalizedStringFormatter} from "@react-aria/i18n";
import {VisuallyHidden as $auVFN$VisuallyHidden} from "react-aria";


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.
 */ 





















let $0fcd5fb617970a1d$var$InternalTableContext = /*#__PURE__*/ (0, $auVFN$createContext)({});
const $0fcd5fb617970a1d$var$tableWrapper = function anonymous(props, overrides) {
    let rules = " ";
    let minHeight = false;
    let minWidth = false;
    let position = 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] === "_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;
};
const $0fcd5fb617970a1d$var$table = function anonymous(props) {
    let rules = " ";
    rules += ' Za12';
    rules += ' Fb12';
    rules += ' _oa12';
    rules += ' _4c12';
    rules += ' Ma12';
    rules += ' Na12';
    rules += ' uk12';
    rules += ' uch12';
    rules += ' udi12';
    rules += ' uea12';
    rules += ' ugb12';
    rules += ' uhd12';
    rules += ' uje12';
    rules += ' u2NhKxcl12';
    rules += ' uic12';
    rules += ' wb12';
    rules += ' xb12';
    rules += ' _xa12';
    rules += ' _Na12';
    rules += ' Pa12';
    if (props.isQuiet) rules += ' g912';
    else rules += ' gX12';
    rules += ' gla12';
    rules += ' iq12';
    rules += ' _jf12';
    if (props.isQuiet) rules += ' _ka12';
    else rules += ' _kb12';
    if (props.isQuiet) rules += ' ha12';
    else rules += ' hb12';
    if (props.isQuiet) rules += ' ma12';
    else rules += ' mb12';
    if (props.isQuiet) rules += ' la12';
    else rules += ' lb12';
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    rules += ' Oh12';
    rules += ' _Mc12';
    rules += ' _Ka12';
    if (props.isQuiet) rules += ' od12';
    else rules += ' of12';
    if (props.isQuiet) rules += ' nd12';
    else rules += ' nf12';
    if (props.isQuiet) rules += ' kd12';
    else rules += ' kf12';
    if (props.isQuiet) rules += ' jd12';
    else rules += ' jf12';
    rules += ' _Um12';
    if (props.isCheckboxSelection) rules += ' _Tk12';
    return rules;
};
// component-height-100
const $0fcd5fb617970a1d$var$DEFAULT_HEADER_HEIGHT = {
    medium: 32,
    large: 40
};
const $0fcd5fb617970a1d$var$ROW_HEIGHTS = {
    compact: {
        medium: 32,
        large: 40
    },
    regular: {
        medium: 40,
        large: 50
    },
    spacious: {
        medium: 48,
        large: 60
    }
};
class $0fcd5fb617970a1d$export$4e03bdf0174fd602 extends (0, $auVFN$TableLayout) {
    isStickyColumn(node) {
        return node.props.isSticky;
    }
    buildCollection() {
        let [header, body] = super.buildCollection();
        if (!header) return [];
        let { layoutInfo: layoutInfo } = body;
        // TableLayout's buildCollection always sets the body width to the max width between the header width, but
        // we want the body to be sticky and only as wide as the table so it is always in view if loading/empty
        let isEmptyOrLoading = this.virtualizer?.collection.size === 0;
        if (isEmptyOrLoading) layoutInfo.rect.width = this.virtualizer.visibleRect.width - 80;
        return [
            header,
            body
        ];
    }
    buildLoader(node, x, y) {
        let layoutNode = super.buildLoader(node, x, y);
        let { layoutInfo: layoutInfo } = layoutNode;
        layoutInfo.allowOverflow = true;
        layoutInfo.rect.width = this.virtualizer.visibleRect.width;
        // If performing first load or empty, the body will be sticky so we don't want to apply sticky to the loader, otherwise it will
        // affect the positioning of the empty state renderer
        let collection = this.virtualizer.collection;
        let isEmptyOrLoading = collection?.size === 0;
        layoutInfo.isSticky = !isEmptyOrLoading;
        return layoutNode;
    }
    // y is the height of the headers
    buildBody(y) {
        let layoutNode = super.buildBody(y);
        let { layoutInfo: layoutInfo } = layoutNode;
        // Needs overflow for sticky loader
        layoutInfo.allowOverflow = true;
        // If loading or empty, we'll want the body to be sticky and centered
        let isEmptyOrLoading = this.virtualizer?.collection.size === 0;
        if (isEmptyOrLoading) {
            layoutInfo.rect = new (0, $auVFN$Rect)(40, 40, this.virtualizer.visibleRect.width - 80, this.virtualizer.visibleRect.height - 80);
            layoutInfo.isSticky = true;
        }
        return {
            ...layoutNode,
            layoutInfo: layoutInfo
        };
    }
    buildRow(node, x, y) {
        let layoutNode = super.buildRow(node, x, y);
        layoutNode.layoutInfo.allowOverflow = true;
        // Needs overflow for sticky selection/drag cells
        return layoutNode;
    }
    buildTableHeader() {
        let layoutNode = super.buildTableHeader();
        // Needs overflow for sticky selection/drag column
        layoutNode.layoutInfo.allowOverflow = true;
        return layoutNode;
    }
    buildColumn(node, x, y) {
        let layoutNode = super.buildColumn(node, x, y);
        // Needs overflow for the resize handle
        layoutNode.layoutInfo.allowOverflow = true;
        return layoutNode;
    }
}
const $0fcd5fb617970a1d$export$93e4b0b2cc49b648 = /*#__PURE__*/ (0, $auVFN$createContext)(null);
const $0fcd5fb617970a1d$export$b3c27e869d856b7 = /*#__PURE__*/ (0, $auVFN$forwardRef)(function TableView(props, ref) {
    [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $0fcd5fb617970a1d$export$93e4b0b2cc49b648);
    let { UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className, isQuiet: isQuiet = false, density: density = 'regular', overflowMode: overflowMode = 'truncate', styles: styles, loadingState: loadingState, onResize: propsOnResize, onResizeStart: propsOnResizeStart, onResizeEnd: propsOnResizeEnd, onAction: onAction, onLoadMore: onLoadMore, selectionMode: selectionMode = 'none', ...otherProps } = props;
    let domRef = (0, $auVFN$useDOMRef)(ref);
    let scale = (0, $859432f3b3573fcb$export$a8d2043b2d807f4d)();
    // Starts when the user selects resize from the menu, ends when resizing ends
    // used to control the visibility of the resizer Nubbin
    let [isInResizeMode, setIsInResizeMode] = (0, $auVFN$useState)(false);
    let onResizeStart = (0, $auVFN$useCallback)((widths)=>{
        propsOnResizeStart?.(widths);
    }, [
        propsOnResizeStart
    ]);
    let onResizeEnd = (0, $auVFN$useCallback)((widths)=>{
        setIsInResizeMode(false);
        propsOnResizeEnd?.(widths);
    }, [
        propsOnResizeEnd,
        setIsInResizeMode
    ]);
    let context = (0, $auVFN$useMemo)(()=>({
            isQuiet: isQuiet,
            density: density,
            overflowMode: overflowMode,
            loadingState: loadingState,
            onLoadMore: onLoadMore,
            isInResizeMode: isInResizeMode,
            setIsInResizeMode: setIsInResizeMode,
            selectionMode: selectionMode
        }), [
        isQuiet,
        density,
        overflowMode,
        loadingState,
        onLoadMore,
        isInResizeMode,
        setIsInResizeMode,
        selectionMode
    ]);
    let scrollRef = (0, $auVFN$useRef)(null);
    let isCheckboxSelection = selectionMode === 'multiple' || selectionMode === 'single';
    let { selectedKeys: selectedKeys, onSelectionChange: onSelectionChange, actionBar: actionBar, actionBarHeight: actionBarHeight } = (0, $f21f2186348fbc5b$export$13f32e21845e01d0)({
        ...props,
        scrollRef: scrollRef
    });
    return /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$ResizableTableContainer), {
        // TODO: perhaps this ref should be attached to the RACTable but it expects a table type ref which isn't true in the virtualized case
        ref: domRef,
        onResize: propsOnResize,
        onResizeEnd: onResizeEnd,
        onResizeStart: onResizeStart,
        className: (UNSAFE_className || '') + $0fcd5fb617970a1d$var$tableWrapper(null, styles),
        style: UNSAFE_style,
        children: [
            /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Virtualizer), {
                layout: $0fcd5fb617970a1d$export$4e03bdf0174fd602,
                layoutOptions: {
                    rowHeight: overflowMode === 'wrap' ? undefined : $0fcd5fb617970a1d$var$ROW_HEIGHTS[density][scale],
                    estimatedRowHeight: overflowMode === 'wrap' ? $0fcd5fb617970a1d$var$ROW_HEIGHTS[density][scale] : undefined,
                    // No need for estimated headingHeight since the headers aren't affected by overflow mode: wrap
                    headingHeight: $0fcd5fb617970a1d$var$DEFAULT_HEADER_HEIGHT[scale],
                    loaderHeight: 60
                },
                children: /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$InternalTableContext.Provider, {
                    value: context,
                    children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Table), {
                        ref: scrollRef,
                        style: {
                            // Fix webkit bug where scrollbars appear above the checkboxes/other table elements
                            WebkitTransform: 'translateZ(0)',
                            // Add padding at the bottom when the action bar is visible so users can scroll to the last items.
                            // Also add scroll padding so navigating with the keyboard doesn't go behind the action bar.
                            paddingBottom: actionBarHeight > 0 ? actionBarHeight + 8 : 0,
                            scrollPaddingBottom: actionBarHeight > 0 ? actionBarHeight + 8 : 0
                        },
                        className: (renderProps)=>$0fcd5fb617970a1d$var$table({
                                ...renderProps,
                                isCheckboxSelection: isCheckboxSelection,
                                isQuiet: isQuiet
                            }),
                        selectionBehavior: "toggle",
                        selectionMode: selectionMode,
                        onRowAction: onAction,
                        ...otherProps,
                        selectedKeys: selectedKeys,
                        defaultSelectedKeys: undefined,
                        onSelectionChange: onSelectionChange
                    })
                })
            }),
            actionBar
        ]
    });
});
const $0fcd5fb617970a1d$var$centeredWrapper = " sd12 eb12 _Ca12 Za12 Fb12";
const $0fcd5fb617970a1d$export$76ccd210b9029917 = /*#__PURE__*/ (0, $auVFN$forwardRef)(function TableBody(props, ref) {
    let { items: items, renderEmptyState: renderEmptyState, children: children, dependencies: dependencies = [] } = props;
    let domRef = (0, $auVFN$useDOMRef)(ref);
    let { loadingState: loadingState, onLoadMore: onLoadMore } = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
    let emptyRender;
    let renderer = children;
    let stringFormatter = (0, $auVFN$useLocalizedStringFormatter)((0, ($parcel$interopDefault($auVFN$intlStringsmjs))), '@react-spectrum/s2');
    // TODO: still is offset strangely if loadingMore when there aren't any items in the table, see http://localhost:6006/?path=/story/tableview--empty-state&args=loadingState:loadingMore
    // This is because we don't distinguish between loadingMore and loading in the layout, resulting in a different rect being used to build the body. Perhaps can be considered as a user error
    // if they pass loadingMore without having any other items in the table. Alternatively, could update the layout so it knows the current loading state.
    let loadMoreSpinner = /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$TableLoadMoreItem), {
        isLoading: loadingState === 'loadingMore',
        onLoadMore: onLoadMore,
        className: " Fb12 Za12",
        children: /*#__PURE__*/ (0, $auVFN$jsx)("div", {
            className: $0fcd5fb617970a1d$var$centeredWrapper,
            children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $41ddd91dbbf0c389$export$c79b9d6b4cc92af7), {
                isIndeterminate: true,
                "aria-label": stringFormatter.format('table.loadingMore')
            })
        })
    });
    // If the user is rendering their rows in dynamic fashion, wrap their render function in Collection so we can inject
    // the loader. Otherwise it is a static renderer and thus we can simply add the table loader after
    // TODO: this assumes that the user isn't providing their children in some wrapper though and/or isn't doing a map of children
    // (though I guess they wouldn't provide items then so the check for this is still valid in the latter case)...
    if (typeof children === 'function' && items) renderer = /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Fragment), {
        children: [
            /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Collection), {
                items: items,
                dependencies: dependencies,
                children: children
            }),
            loadMoreSpinner
        ]
    });
    else renderer = /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Fragment), {
        children: [
            children,
            loadMoreSpinner
        ]
    });
    if (renderEmptyState != null && !isLoading) emptyRender = (props)=>/*#__PURE__*/ (0, $auVFN$jsx)("div", {
            className: $0fcd5fb617970a1d$var$centeredWrapper,
            children: renderEmptyState(props)
        });
    else if (loadingState === 'loading') emptyRender = ()=>/*#__PURE__*/ (0, $auVFN$jsx)("div", {
            className: $0fcd5fb617970a1d$var$centeredWrapper,
            children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $41ddd91dbbf0c389$export$c79b9d6b4cc92af7), {
                isIndeterminate: true,
                "aria-label": stringFormatter.format('table.loading')
            })
        });
    return /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$TableBody), {
        // @ts-ignore
        ref: domRef,
        className: " Fb12",
        ...props,
        renderEmptyState: emptyRender,
        dependencies: [
            loadingState
        ],
        children: renderer
    });
});
const $0fcd5fb617970a1d$var$cellFocus = {
    outlineStyle: {
        default: 'none',
        isFocusVisible: 'solid'
    },
    outlineOffset: -2,
    outlineWidth: 2,
    outlineColor: 'focus-ring',
    borderRadius: '[6px]'
};
function $0fcd5fb617970a1d$var$CellFocusRing() {
    return /*#__PURE__*/ (0, $auVFN$jsx)("div", {
        role: "presentation",
        className: function anonymous(props) {
            let rules = " ";
            if (props.isFocusVisible) rules += ' _Lf12';
            else rules += ' _Le12';
            rules += ' _Kb12';
            rules += ' _Mc12';
            rules += ' Oh12';
            rules += ' of12';
            rules += ' nf12';
            rules += ' kf12';
            rules += ' jf12';
            rules += ' _Pa12';
            rules += ' Wr12';
            rules += ' _lr12';
            rules += ' _Ar12';
            rules += ' _zr12';
            rules += ' _Ob12';
            return rules;
        }({
            isFocusVisible: true
        })
    });
}
const $0fcd5fb617970a1d$var$columnStyles = function anonymous(props) {
    let rules = " ";
    rules += ' F40ub4c12';
    rules += ' _oa12';
    if (props.isPressed) rules += ' po12';
    else if (props.isFocusVisible) rules += ' po12';
    else if (props.isHovered) rules += ' po12';
    else rules += ' pt12';
    rules += ' plb12';
    if (props.isMenu) rules += ' Sd12';
    else rules += ' Sf12';
    if (props.isMenu) rules += ' Rd12';
    else rules += ' Rf12';
    if (props.align === "end") rules += ' _Wb12';
    else if (props.align === "center") rules += ' _Wa12';
    else if (props.align === "start") rules += ' _Wd12';
    rules += ' _Le12';
    rules += ' _Pc12';
    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 += ' uk12';
    rules += ' uch12';
    rules += ' udi12';
    rules += ' uea12';
    rules += ' ugb12';
    rules += ' uhd12';
    rules += ' uje12';
    rules += ' u2NhKxcl12';
    rules += ' uic12';
    rules += ' wd12';
    rules += ' xd12';
    rules += ' _xa12';
    rules += ' wX0cczbc12';
    rules += ' xX0cczbc12';
    rules += ' _xX0cczba12';
    rules += ' sd12';
    rules += ' iq12';
    rules += ' ila12';
    if (props.isQuiet) rules += ' _kb12';
    else rules += ' _ka12';
    rules += ' hb12';
    rules += ' ma12';
    if (props.isMenu) rules += ' lb12';
    else rules += ' la12';
    rules += ' _jf12';
    rules += ' _yb12';
    return rules;
};
const $0fcd5fb617970a1d$export$816b5d811295e6bc = /*#__PURE__*/ (0, $auVFN$forwardRef)(function Column(props, ref) {
    let { isQuiet: isQuiet } = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    let { allowsResizing: allowsResizing, children: children, align: align = 'start' } = props;
    let domRef = (0, $auVFN$useDOMRef)(ref);
    let isMenu = allowsResizing || !!props.menuItems;
    return /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Column), {
        ...props,
        ref: domRef,
        style: {
            borderInlineEndColor: 'transparent'
        },
        className: (renderProps)=>$0fcd5fb617970a1d$var$columnStyles({
                ...renderProps,
                isMenu: isMenu,
                align: align,
                isQuiet: isQuiet
            }),
        children: ({ allowsSorting: allowsSorting, sortDirection: sortDirection, isFocusVisible: isFocusVisible, sort: sort, startResize: startResize })=>/*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Fragment), {
                children: [
                    isFocusVisible && /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$CellFocusRing, {}),
                    isMenu ? /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$ColumnWithMenu, {
                        isColumnResizable: allowsResizing,
                        menuItems: props.menuItems,
                        allowsSorting: allowsSorting,
                        sortDirection: sortDirection,
                        sort: sort,
                        startResize: startResize,
                        align: align,
                        children: children
                    }) : /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$ColumnContents, {
                        allowsSorting: allowsSorting,
                        sortDirection: sortDirection,
                        children: children
                    })
                ]
            })
    });
});
const $0fcd5fb617970a1d$var$columnContentWrapper = " Na12 sd12 eb12 Za12";
const $0fcd5fb617970a1d$var$sortIcon = function anonymous(props) {
    let rules = " ";
    rules += ' ZXJkxGe12';
    rules += ' FXJkxGe12';
    rules += ' _va12';
    if (props.isButton) {
        rules += ' Ht12';
        rules += ' Hsu12';
    } else rules += ' Hv12';
    rules += ' _5b12';
    rules += ' -_8sjo0b-t5ZbAob12';
    return rules;
};
function $0fcd5fb617970a1d$var$ColumnContents(props) {
    let { allowsSorting: allowsSorting, sortDirection: sortDirection, children: children } = props;
    return /*#__PURE__*/ (0, $auVFN$jsxs)("div", {
        className: $0fcd5fb617970a1d$var$columnContentWrapper,
        children: [
            allowsSorting && /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Provider), {
                values: [
                    [
                        (0, $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed),
                        {
                            styles: $0fcd5fb617970a1d$var$sortIcon({})
                        }
                    ]
                ],
                children: sortDirection != null && (sortDirection === 'ascending' ? /*#__PURE__*/ (0, $auVFN$jsx)((0, $415c33109ddcfc45$export$2e2bcd8739ae039), {}) : /*#__PURE__*/ (0, $auVFN$jsx)((0, $5a632e895c21f138$export$2e2bcd8739ae039), {}))
            }),
            /*#__PURE__*/ (0, $auVFN$jsx)("span", {
                className: " _Nc12 Pc12 _Yb12 _7c12 Za12",
                children: children
            })
        ]
    });
}
const $0fcd5fb617970a1d$var$resizableMenuButtonWrapper = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    rules += ' _Kb12';
    rules += ' _Mc12';
    rules += ' Oh12';
    rules += ' of12';
    rules += ' nf12';
    rules += ' kf12';
    rules += ' jf12';
    rules += ' pt12';
    rules += ' Za12';
    rules += ' _Pc12';
    rules += ' sd12';
    rules += ' eb12';
    if (props.align === "end") rules += ' _Cb12';
    else if (props.align === "center") rules += ' _Ca12';
    else if (props.align === "default") rules += ' _Cg12';
    rules += ' Sf12';
    rules += ' Rf12';
    rules += ' g912';
    rules += ' _je12';
    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 += ' uk12';
    rules += ' uch12';
    rules += ' udi12';
    rules += ' uea12';
    rules += ' ugb12';
    rules += ' uhd12';
    rules += ' uje12';
    rules += ' u2NhKxcl12';
    rules += ' uic12';
    rules += ' wd12';
    rules += ' xd12';
    rules += ' _xa12';
    rules += ' wX0cczbc12';
    rules += ' xX0cczbc12';
    rules += ' _xX0cczba12';
    return rules;
};
const $0fcd5fb617970a1d$var$resizerHandleContainer = function anonymous(props) {
    let rules = " ";
    if (props.isInResizeMode) rules += ' sb12';
    else if (props.isResizing) rules += ' sb12';
    else rules += ' sjBAxlb12';
    rules += ' Zj12';
    rules += ' Fb12';
    rules += ' _Pa12';
    rules += ' Wr12';
    rules += ' _zdYbyj12';
    if (props.resizableDirection === "both") rules += ' rk12';
    else if (props.resizableDirection === "right") rules += ' rF12';
    else if (props.resizableDirection === "left") rules += ' rj12';
    else rules += ' rt12';
    return rules;
};
const $0fcd5fb617970a1d$var$resizerHandle = function anonymous(props) {
    let rules = " ";
    if (props.isResizing) rules += ' g5qAiPc12';
    else if (props.isFocusVisible) rules += ' g5qAiPc12';
    else rules += ' gE12';
    if (props.isResizing) rules += ' gle12';
    else if (props.isFocusVisible) rules += ' gle12';
    else rules += ' gla12';
    if (props.isResizing) rules += ' Fc12';
    else rules += ' Fb12';
    if (props.isResizing) rules += ' Zf12';
    else rules += ' Ze12';
    rules += ' _Pa12';
    rules += ' _AWJpoB12';
    return rules;
};
const $0fcd5fb617970a1d$var$columnHeaderText = " _Nc12 Pc12 _Yb12 _7c12 NXJkxGe12 _ua12 _vb12 _sd12";
const $0fcd5fb617970a1d$var$chevronIcon = " _Sd12 It12 Isu12 NXJkxGe12 _va12 -_8sjo0b-t5ZbAob12";
const $0fcd5fb617970a1d$var$nubbin = " _Pa12 Wr12 _AlhfIS12 ZXJkxGe12 FXJkxGe12 t5qAiPc12 tla12 -_8sjo0b-tw12 -_8sjo0b-lt8pvGJ12";
function $0fcd5fb617970a1d$var$ColumnWithMenu(props) {
    let { allowsSorting: allowsSorting, sortDirection: sortDirection, sort: sort, startResize: startResize, children: children, align: align, isColumnResizable: isColumnResizable, menuItems: menuItems } = props;
    let { setIsInResizeMode: setIsInResizeMode, isInResizeMode: isInResizeMode } = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    let stringFormatter = (0, $auVFN$useLocalizedStringFormatter)((0, ($parcel$interopDefault($auVFN$intlStringsmjs))), '@react-spectrum/s2');
    const onMenuSelect = (key)=>{
        switch(key){
            case 'sort-asc':
                sort('ascending');
                break;
            case 'sort-desc':
                sort('descending');
                break;
            case 'resize':
                setIsInResizeMode?.(true);
                startResize();
                break;
        }
    };
    let items = (0, $auVFN$useMemo)(()=>{
        let options = [];
        if (isColumnResizable) options = [
            {
                label: stringFormatter.format('table.resizeColumn'),
                id: 'resize'
            }
        ];
        if (allowsSorting) options = [
            {
                label: stringFormatter.format('table.sortAscending'),
                id: 'sort-asc'
            },
            {
                label: stringFormatter.format('table.sortDescending'),
                id: 'sort-desc'
            },
            ...options
        ];
        return options;
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [
        allowsSorting,
        isColumnResizable
    ]);
    let buttonAlignment = 'start';
    let menuAlign = 'start';
    if (align === 'center') buttonAlignment = 'center';
    else if (align === 'end') {
        buttonAlignment = 'end';
        menuAlign = 'end';
    }
    return /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Fragment), {
        children: [
            /*#__PURE__*/ (0, $auVFN$jsxs)((0, $13afb0ea5f0ed767$export$27d2ad3c5815583e), {
                align: menuAlign,
                children: [
                    /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Button), {
                        className: (renderProps)=>$0fcd5fb617970a1d$var$resizableMenuButtonWrapper({
                                ...renderProps,
                                align: buttonAlignment
                            }),
                        children: [
                            allowsSorting && /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Provider), {
                                values: [
                                    [
                                        (0, $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed),
                                        {
                                            styles: $0fcd5fb617970a1d$var$sortIcon({
                                                isButton: true
                                            })
                                        }
                                    ]
                                ],
                                children: sortDirection != null && (sortDirection === 'ascending' ? /*#__PURE__*/ (0, $auVFN$jsx)((0, $415c33109ddcfc45$export$2e2bcd8739ae039), {}) : /*#__PURE__*/ (0, $auVFN$jsx)((0, $5a632e895c21f138$export$2e2bcd8739ae039), {}))
                            }),
                            /*#__PURE__*/ (0, $auVFN$jsx)("div", {
                                className: $0fcd5fb617970a1d$var$columnHeaderText,
                                children: children
                            }),
                            /*#__PURE__*/ (0, $auVFN$jsx)((0, $4b69f02ec06b9226$export$2e2bcd8739ae039), {
                                size: "M",
                                className: $0fcd5fb617970a1d$var$chevronIcon
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, $auVFN$jsxs)((0, $13afb0ea5f0ed767$export$d9b273488cd8ce6f), {
                        onAction: onMenuSelect,
                        styles: " Nn12",
                        children: [
                            items.length > 0 && /*#__PURE__*/ (0, $auVFN$jsx)((0, $13afb0ea5f0ed767$export$4b1545b4f2016d26), {
                                children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Collection), {
                                    items: items,
                                    children: (item)=>/*#__PURE__*/ (0, $auVFN$jsx)((0, $13afb0ea5f0ed767$export$2ce376c2cc3355c8), {
                                            children: item?.label
                                        })
                                })
                            }),
                            menuItems
                        ]
                    })
                ]
            }),
            isColumnResizable && /*#__PURE__*/ (0, $auVFN$jsx)("div", {
                "data-react-aria-prevent-focus": "true",
                children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$ColumnResizer), {
                    "data-react-aria-prevent-focus": "true",
                    className: ({ resizableDirection: resizableDirection, isResizing: isResizing })=>$0fcd5fb617970a1d$var$resizerHandleContainer({
                            resizableDirection: resizableDirection,
                            isResizing: isResizing,
                            isInResizeMode: isInResizeMode
                        }),
                    children: ({ isFocusVisible: isFocusVisible, isResizing: isResizing })=>/*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Fragment), {
                            children: [
                                /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$ResizerIndicator, {
                                    isFocusVisible: isFocusVisible,
                                    isResizing: isResizing
                                }),
                                (isFocusVisible || isInResizeMode) && isResizing && /*#__PURE__*/ (0, $auVFN$jsx)("div", {
                                    className: $0fcd5fb617970a1d$var$nubbin,
                                    children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $1bdd184cd8a3d21d$export$2e2bcd8739ae039), {})
                                })
                            ]
                        })
                })
            })
        ]
    });
}
function $0fcd5fb617970a1d$var$ResizerIndicator({ isFocusVisible: isFocusVisible, isResizing: isResizing }) {
    return /*#__PURE__*/ (0, $auVFN$jsx)("div", {
        className: $0fcd5fb617970a1d$var$resizerHandle({
            isFocusVisible: isFocusVisible,
            isResizing: isResizing
        })
    });
}
const $0fcd5fb617970a1d$var$tableHeader = function anonymous(props) {
    let rules = " ";
    rules += ' Fb12';
    rules += ' Za12';
    rules += ' gL12';
    rules += ' JLPOtrc12';
    if (props.isHovered) rules += ' -xLp2wc-sb12';
    else rules += ' -xLp2wc-sk12';
    return rules;
};
const $0fcd5fb617970a1d$var$selectAllCheckbox = " IC12";
const $0fcd5fb617970a1d$var$selectAllCheckboxColumn = function anonymous(props) {
    let rules = " ";
    rules += ' Td12';
    rules += ' Qd12';
    rules += ' Sd12';
    rules += ' Rd12';
    rules += ' Fb12';
    rules += ' _oa12';
    rules += ' _Le12';
    rules += ' _Pc12';
    rules += ' _cb12';
    rules += ' iq12';
    rules += ' ila12';
    rules += ' ma12';
    rules += ' la12';
    if (props.isQuiet) rules += ' _kb12';
    else rules += ' _ka12';
    rules += ' hb12';
    rules += ' _jf12';
    rules += ' gL12';
    return rules;
};
const $0fcd5fb617970a1d$export$f850895b287ef28e = /*#__PURE__*/ (0, $auVFN$forwardRef)(function TableHeader({ columns: columns, dependencies: dependencies, children: children }, ref) {
    let scale = (0, $859432f3b3573fcb$export$a8d2043b2d807f4d)();
    let { selectionBehavior: selectionBehavior, selectionMode: selectionMode } = (0, $auVFN$useTableOptions)();
    let { isQuiet: isQuiet } = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    let domRef = (0, $auVFN$useDOMRef)(ref);
    return /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$TableHeader), {
        // @ts-ignore
        ref: domRef,
        className: $0fcd5fb617970a1d$var$tableHeader,
        children: [
            selectionBehavior === 'toggle' && // Also isSticky prop is applied just for the layout, will decide what the RAC api should be later
            // @ts-ignore
            /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Column), {
                isSticky: true,
                width: scale === 'medium' ? 40 : 52,
                minWidth: scale === 'medium' ? 40 : 52,
                className: $0fcd5fb617970a1d$var$selectAllCheckboxColumn({
                    isQuiet: isQuiet
                }),
                children: ({ isFocusVisible: isFocusVisible })=>/*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Fragment), {
                        children: [
                            selectionMode === 'single' && /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Fragment), {
                                children: [
                                    isFocusVisible && /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$CellFocusRing, {}),
                                    /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$VisuallyHiddenSelectAllLabel, {})
                                ]
                            }),
                            selectionMode === 'multiple' && /*#__PURE__*/ (0, $auVFN$jsx)((0, $9b405e0f8095dce0$export$48513f6b9f8ce62d), {
                                isEmphasized: true,
                                styles: $0fcd5fb617970a1d$var$selectAllCheckbox,
                                slot: "selection"
                            })
                        ]
                    })
            }),
            /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Collection), {
                items: columns,
                dependencies: dependencies,
                children: children
            })
        ]
    });
});
function $0fcd5fb617970a1d$var$VisuallyHiddenSelectAllLabel() {
    let checkboxProps = (0, $auVFN$useSlottedContext)((0, $auVFN$CheckboxContext), 'selection');
    return /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$VisuallyHidden), {
        children: checkboxProps?.['aria-label']
    });
}
const $0fcd5fb617970a1d$var$commonCellStyles = {
    borderColor: 'transparent',
    borderBottomWidth: 1,
    borderTopWidth: 0,
    borderXWidth: 0,
    borderStyle: 'solid',
    position: 'relative',
    color: {
        default: 'gray-800',
        forcedColors: 'ButtonText'
    },
    outlineStyle: 'none',
    paddingX: 16 // table-edge-to-content
};
const $0fcd5fb617970a1d$var$cell = function anonymous(props) {
    let rules = " ";
    rules += ' iq12';
    rules += ' ila12';
    rules += ' hXMFGYc12';
    rules += ' _kJ8iPYd12';
    rules += ' ma12';
    if (props.isDivider) rules += ' lb12';
    else rules += ' la12';
    if (props.isDivider) rules += ' _jf12';
    else rules += ' _je12';
    rules += ' _Pc12';
    if (props.isPressed) rules += ' po12';
    else if (props.isFocusVisible) rules += ' po12';
    else if (props.isHovered) rules += ' po12';
    else rules += ' pt12';
    rules += ' _Le12';
    rules += ' Sf12';
    rules += ' Rf12';
    rules += ' Tu7Fubd12';
    rules += ' Qu7Fubd12';
    rules += ' MAyFGYc12';
    rules += ' _oa12';
    rules += ' Fb12';
    rules += ' Za12';
    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 += ' eb12';
    rules += ' sd12';
    if (props.density === "spacious") rules += ' -M_-Mk12';
    else if (props.density === "compact") rules += ' -M_-Mi12';
    else rules += ' -M_-Mh12';
    rules += ' -_k_-_ka12';
    rules += ' -h_-hb12';
    return rules;
};
const $0fcd5fb617970a1d$var$stickyCell = {
    backgroundColor: 'gray-25'
};
const $0fcd5fb617970a1d$var$checkboxCellStyle = " iA12 ha12 _ka12 ma12 la12 _jf12 _Pc12 pt12 plb12 _Le12 Sf12 Rf12 gs9yXOb12 _cb12 FBJsHLe12";
const $0fcd5fb617970a1d$var$cellContent = function anonymous(props) {
    let rules = " ";
    rules += ' _Nc12';
    rules += ' Pc12';
    rules += ' _Yb12';
    if (props.overflowMode === "wrap") rules += ' _7b12';
    else rules += ' _7c12';
    if (props.align === "end") rules += ' _Wb12';
    else if (props.align === "center") rules += ' _Wa12';
    else if (props.align === "start") rules += ' _Wd12';
    rules += ' Za12';
    rules += ' _Bb12';
    if (props.isSticky) rules += ' Td12';
    else rules += ' Tp12';
    if (props.isSticky) rules += ' Qd12';
    else rules += ' Qp12';
    if (props.isSticky) rules += ' Sd12';
    else rules += ' Sp12';
    if (props.isSticky) rules += ' Rd12';
    else rules += ' Rp12';
    if (props.isSticky) rules += ' Jy12';
    else rules += ' Jb12';
    if (props.isSticky) rules += ' Gy12';
    else rules += ' Gb12';
    if (props.isSticky) rules += ' Iy12';
    else rules += ' Ib12';
    if (props.isSticky) rules += ' Hy12';
    else rules += ' Hb12';
    if (props.isSticky) rules += ' gs9yXOb12';
    else rules += ' g912';
    return rules;
};
const $0fcd5fb617970a1d$export$f6f0c3fe4ec306ea = /*#__PURE__*/ (0, $auVFN$forwardRef)(function Cell(props, ref) {
    let { children: children, isSticky: isSticky, showDivider: showDivider = false, align: align, textValue: textValue, ...otherProps } = props;
    let domRef = (0, $auVFN$useDOMRef)(ref);
    let tableVisualOptions = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    textValue ||= typeof children === 'string' ? children : undefined;
    return /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Cell), {
        ref: domRef,
        // Also isSticky prop is applied just for the layout, will decide what the RAC api should be later
        // @ts-ignore
        isSticky: isSticky,
        className: (renderProps)=>$0fcd5fb617970a1d$var$cell({
                ...renderProps,
                ...tableVisualOptions,
                isDivider: showDivider
            }),
        textValue: textValue,
        ...otherProps,
        children: ({ isFocusVisible: isFocusVisible })=>/*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Fragment), {
                children: [
                    /*#__PURE__*/ (0, $auVFN$jsx)("span", {
                        className: $0fcd5fb617970a1d$var$cellContent({
                            ...tableVisualOptions,
                            isSticky: isSticky,
                            align: align || 'start'
                        }),
                        children: children
                    }),
                    isFocusVisible && /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$CellFocusRing, {})
                ]
            })
    });
});
const $0fcd5fb617970a1d$var$editableCell = function anonymous(props) {
    let rules = " ";
    rules += ' iq12';
    rules += ' ila12';
    rules += ' hXMFGYc12';
    rules += ' _kJ8iPYd12';
    rules += ' ma12';
    if (props.isDivider) rules += ' lb12';
    else rules += ' la12';
    if (props.isDivider) rules += ' _jf12';
    else rules += ' _je12';
    rules += ' _Pc12';
    if (props.isSaving) {
        if (props.isPressed) rules += ' pt12';
        else if (props.isFocusVisible) rules += ' pt12';
        else if (props.isHovered) rules += ' pt12';
        else rules += ' pv12';
    } else {
        if (props.isPressed) rules += ' po12';
        else if (props.isFocusVisible) rules += ' po12';
        else if (props.isHovered) rules += ' po12';
        else rules += ' pt12';
    }
    rules += ' _Le12';
    rules += ' Sf12';
    rules += ' Rf12';
    rules += ' Tu7Fubd12';
    rules += ' Qu7Fubd12';
    rules += ' _oa12';
    rules += ' FBJsHLe12';
    rules += ' Za12';
    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 += ' eb12';
    rules += ' sd12';
    rules += ' g912';
    if (props.selectionMode === "multiple") rules += ' gf2iZndX12';
    else if (props.selectionMode === "single") rules += ' gf2iZndX12';
    else if (props.selectionMode === "none") rules += ' gf2iZndj1B7i12';
    rules += ' gDJ7W0cX12';
    rules += ' -_k_-_ka12';
    rules += ' -h_-hb12';
    return rules;
};
let $0fcd5fb617970a1d$var$editPopover = function anonymous(props, overrides) {
    let rules = " ";
    let minWidth = 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;
        rules += p[0];
    }
    if (props.colorScheme === "dark") rules += ' _pa12';
    else if (props.colorScheme === "light") rules += ' _pb12';
    else if (props.colorScheme === "light dark") rules += ' _pc12';
    else rules += ' _pN79Hzc12';
    rules += ' -Ovbhqd-g_g12';
    rules += ' gEzkoQe12';
    rules += ' kb12';
    rules += ' jb12';
    rules += ' _nLeasBb12';
    rules += ' _jf12';
    rules += ' _kb12';
    rules += ' hb12';
    rules += ' mb12';
    rules += ' lb12';
    rules += ' ir12';
    rules += ' ila12';
    rules += ' _ob12';
    rules += ' _Bb12';
    if (props.isExiting) rules += ' _Ob12';
    rules += ' _Le12';
    if (!minWidth) rules += ' NuHSBze12';
    rules += ' Tt12';
    rules += ' Qt12';
    rules += ' St12';
    rules += ' Rt12';
    rules += ' sd12';
    rules += ' eb12';
    return rules;
};
const $0fcd5fb617970a1d$export$d27c35c47f085992 = /*#__PURE__*/ (0, $auVFN$forwardRef)(function EditableCell(props, ref) {
    let { children: children, showDivider: showDivider = false, textValue: textValue, isSaving: isSaving, ...otherProps } = props;
    let tableVisualOptions = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    let domRef = (0, $auVFN$useObjectRef)(ref);
    textValue ||= typeof children === 'string' ? children : undefined;
    return /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Cell), {
        ref: domRef,
        className: (renderProps)=>$0fcd5fb617970a1d$var$editableCell({
                ...renderProps,
                ...tableVisualOptions,
                isDivider: showDivider,
                isSaving: isSaving
            }),
        textValue: textValue,
        ...otherProps,
        children: ({ isFocusVisible: isFocusVisible })=>/*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$EditableCellInner, {
                ...props,
                isFocusVisible: isFocusVisible,
                cellRef: domRef
            })
    });
});
const $0fcd5fb617970a1d$var$nonTextInputTypes = new Set([
    'checkbox',
    'radio',
    'range',
    'color',
    'file',
    'image',
    'button',
    'submit',
    'reset'
]);
function $0fcd5fb617970a1d$var$EditableCellInner(props1) {
    let { children: children, align: align, renderEditing: renderEditing, isSaving: isSaving, onSubmit: onSubmit, isFocusVisible: isFocusVisible, cellRef: cellRef } = props1;
    let [isOpen, setIsOpen] = (0, $auVFN$useState)(false);
    let popoverRef = (0, $auVFN$useRef)(null);
    let formRef = (0, $auVFN$useRef)(null);
    let [triggerWidth, setTriggerWidth] = (0, $auVFN$useState)(0);
    let [tableWidth, setTableWidth] = (0, $auVFN$useState)(0);
    let [verticalOffset, setVerticalOffset] = (0, $auVFN$useState)(0);
    let tableVisualOptions = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    let stringFormatter = (0, $auVFN$useLocalizedStringFormatter)((0, ($parcel$interopDefault($auVFN$intlStringsmjs))), '@react-spectrum/s2');
    let { density: density } = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    let size = 'M';
    if (density === 'compact') size = 'S';
    else if (density === 'spacious') size = 'L';
    // Popover positioning
    (0, $auVFN$useLayoutEffect)(()=>{
        if (!isOpen) return;
        let width = cellRef.current?.clientWidth || 0;
        let cell = cellRef.current;
        let boundingRect = cell?.parentElement?.getBoundingClientRect();
        let verticalOffset = (boundingRect?.top ?? 0) - (boundingRect?.bottom ?? 0);
        let tableWidth = cellRef.current?.closest('[role="grid"]')?.clientWidth || 0;
        setTriggerWidth(width);
        setVerticalOffset(verticalOffset);
        setTableWidth(tableWidth);
    }, [
        cellRef,
        density,
        isOpen
    ]);
    // Auto select the entire text range of the autofocused input on overlay opening
    // Maybe replace with FocusScope or one of those utilities
    (0, $auVFN$useEffect)(()=>{
        if (isOpen) {
            let activeElement = (0, $auVFN$getActiveElement)((0, $auVFN$getOwnerDocument)(formRef.current));
            if (activeElement && formRef.current?.contains(activeElement) && (activeElement instanceof HTMLInputElement && !$0fcd5fb617970a1d$var$nonTextInputTypes.has(activeElement.type) || activeElement instanceof HTMLTextAreaElement) && typeof activeElement.select === 'function') activeElement.select();
        }
    }, [
        isOpen
    ]);
    let cancel = ()=>{
        setIsOpen(false);
    };
    return /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Provider), {
        values: [
            [
                (0, $auVFN$ButtonContext),
                null
            ],
            [
                (0, $da878a05ab4a403e$export$2ff682723a46d413),
                {
                    slots: {
                        [(0, $auVFN$DEFAULT_SLOT)]: {},
                        edit: {
                            onPress: ()=>setIsOpen(true),
                            isPending: isSaving,
                            isQuiet: !isSaving,
                            size: size,
                            excludeFromTabOrder: true,
                            styles: function anonymous(props) {
                                let rules = " ";
                                if (props.isForcedVisible) rules += ' _6c12';
                                else rules += ' _6b12';
                                rules += ' _6JGzCfcc12';
                                rules += ' _6hcIDbbc12';
                                rules += ' _6sc12';
                                return rules;
                            }({
                                isForcedVisible: isOpen || !!isSaving
                            })
                        }
                    }
                }
            ]
        ],
        children: [
            /*#__PURE__*/ (0, $auVFN$jsx)("span", {
                className: $0fcd5fb617970a1d$var$cellContent({
                    ...tableVisualOptions,
                    align: align || 'start'
                }),
                children: children
            }),
            isFocusVisible && /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$var$CellFocusRing, {}),
            /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Provider), {
                values: [
                    [
                        (0, $da878a05ab4a403e$export$2ff682723a46d413),
                        null
                    ]
                ],
                children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Popover), {
                    isOpen: isOpen,
                    onOpenChange: setIsOpen,
                    ref: popoverRef,
                    shouldCloseOnInteractOutside: ()=>{
                        if (!popoverRef.current?.contains(document.activeElement)) return false;
                        formRef.current?.requestSubmit();
                        return false;
                    },
                    triggerRef: cellRef,
                    "aria-label": stringFormatter.format('table.editCell'),
                    offset: verticalOffset,
                    placement: "bottom start",
                    style: {
                        minWidth: `min(${triggerWidth}px, ${tableWidth}px)`,
                        maxWidth: `${tableWidth}px`,
                        // Override default z-index from useOverlayPosition. We use isolation: isolate instead.
                        zIndex: undefined
                    },
                    className: $0fcd5fb617970a1d$var$editPopover,
                    children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Provider), {
                        values: [
                            [
                                (0, $auVFN$OverlayTriggerStateContext),
                                null
                            ]
                        ],
                        children: /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Form), {
                            ref: formRef,
                            onSubmit: (e)=>{
                                e.preventDefault();
                                onSubmit();
                                setIsOpen(false);
                            },
                            className: " Za12 sd12 ed12 Ul12 ql12",
                            style: {
                                '--input-width': `calc(${triggerWidth}px - 32px)`
                            },
                            children: [
                                renderEditing(),
                                /*#__PURE__*/ (0, $auVFN$jsxs)("div", {
                                    className: " sd12 _tc12 ea12 _va12 _ua12",
                                    children: [
                                        /*#__PURE__*/ (0, $auVFN$jsx)((0, $da878a05ab4a403e$export$cfc7921d29ef7b80), {
                                            isQuiet: true,
                                            onPress: cancel,
                                            "aria-label": stringFormatter.format('table.cancel'),
                                            children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $11111a8204dcac81$export$2e2bcd8739ae039), {})
                                        }),
                                        /*#__PURE__*/ (0, $auVFN$jsx)((0, $da878a05ab4a403e$export$cfc7921d29ef7b80), {
                                            isQuiet: true,
                                            type: "submit",
                                            "aria-label": stringFormatter.format('table.save'),
                                            children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $4bb2fe02f5143bcc$export$2e2bcd8739ae039), {})
                                        })
                                    ]
                                })
                            ]
                        })
                    })
                })
            })
        ]
    });
}
// Use color-mix instead of transparency so sticky cells work correctly.
const $0fcd5fb617970a1d$var$selectedBackground = "[light-dark(color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(59, 99, 251), rgb(86, 129, 255)) 10%), color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(93, 137, 255), rgb(52, 91, 248)) 10%))]";
const $0fcd5fb617970a1d$var$selectedActiveBackground = "[light-dark(color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(59, 99, 251), rgb(86, 129, 255)) 15%), color-mix(in srgb, light-dark(rgb(255, 255, 255), rgb(17, 17, 17)), light-dark(rgb(93, 137, 255), rgb(52, 91, 248)) 15%))]";
const $0fcd5fb617970a1d$var$rowBackgroundColor = {
    default: {
        default: 'gray-25',
        isQuiet: '--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: $0fcd5fb617970a1d$var$selectedBackground,
        isFocusVisibleWithin: $0fcd5fb617970a1d$var$selectedActiveBackground,
        isHovered: $0fcd5fb617970a1d$var$selectedActiveBackground,
        isPressed: $0fcd5fb617970a1d$var$selectedActiveBackground // table-selected-row-background-color, opacity /15
    },
    forcedColors: {
        default: 'Background'
    }
};
const $0fcd5fb617970a1d$var$row = function anonymous(props) {
    let rules = " ";
    rules += ' Fb12';
    rules += ' _Pc12';
    rules += ' _oa12';
    rules += ' gs9yXOb12';
    if (props.isSelected) {
        if (props.isPressed) rules += ' -qH4xad-gT9rOHd12';
        else if (props.isHovered) rules += ' -qH4xad-gT9rOHd12';
        else if (props.isFocusVisibleWithin) rules += ' -qH4xad-gT9rOHd12';
        else rules += ' -qH4xad-gJpow3b12';
    } else if (props.isPressed) rules += ' -qH4xad-gRfT7e12';
    else if (props.isHovered) rules += ' -qH4xad-gj1B7i12';
    else if (props.isFocusVisibleWithin) rules += ' -qH4xad-gj1B7i12';
    else if (props.isQuiet) rules += ' -qH4xad-gEzkoQe12';
    else rules += ' -qH4xad-gX12';
    rules += ' -qH4xad-lga12';
    rules += ' -_34HbNb-Oh12';
    rules += ' -_34HbNb-lOc12';
    rules += ' _Le12';
    rules += ' _ka12';
    rules += ' hb12';
    rules += ' ma12';
    rules += ' la12';
    rules += ' _jf12';
    rules += ' iq12';
    rules += ' ila12';
    rules += ' _yb12';
    return rules;
};
const $0fcd5fb617970a1d$export$b59bdbef9ce70de2 = /*#__PURE__*/ (0, $auVFN$forwardRef)(function Row({ id: id, columns: columns, children: children, dependencies: dependencies = [], ...otherProps }, ref) {
    let { selectionBehavior: selectionBehavior, selectionMode: selectionMode } = (0, $auVFN$useTableOptions)();
    let tableVisualOptions = (0, $auVFN$useContext)($0fcd5fb617970a1d$var$InternalTableContext);
    let domRef = (0, $auVFN$useDOMRef)(ref);
    return /*#__PURE__*/ (0, $auVFN$jsxs)((0, $auVFN$Row), {
        // @ts-ignore
        ref: domRef,
        id: id,
        dependencies: [
            ...dependencies,
            columns
        ],
        className: (renderProps)=>$0fcd5fb617970a1d$var$row({
                ...renderProps,
                ...tableVisualOptions
            }) + (renderProps.isFocusVisible && " hFh6wc"),
        ...otherProps,
        children: [
            selectionMode !== 'none' && selectionBehavior === 'toggle' && /*#__PURE__*/ (0, $auVFN$jsx)($0fcd5fb617970a1d$export$f6f0c3fe4ec306ea, {
                isSticky: true,
                className: $0fcd5fb617970a1d$var$checkboxCellStyle,
                children: /*#__PURE__*/ (0, $auVFN$jsx)((0, $9b405e0f8095dce0$export$48513f6b9f8ce62d), {
                    isEmphasized: true,
                    slot: "selection"
                })
            }),
            /*#__PURE__*/ (0, $auVFN$jsx)((0, $auVFN$Collection), {
                items: columns,
                dependencies: [
                    ...dependencies,
                    columns
                ],
                children: children
            })
        ]
    });
});


export {$0fcd5fb617970a1d$export$4e03bdf0174fd602 as S2TableLayout, $0fcd5fb617970a1d$export$93e4b0b2cc49b648 as TableContext, $0fcd5fb617970a1d$export$b3c27e869d856b7 as TableView, $0fcd5fb617970a1d$export$76ccd210b9029917 as TableBody, $0fcd5fb617970a1d$export$816b5d811295e6bc as Column, $0fcd5fb617970a1d$export$f850895b287ef28e as TableHeader, $0fcd5fb617970a1d$export$f6f0c3fe4ec306ea as Cell, $0fcd5fb617970a1d$export$d27c35c47f085992 as EditableCell, $0fcd5fb617970a1d$export$b59bdbef9ce70de2 as Row};
//# sourceMappingURL=TableView.mjs.map
