import { o as $cc38e7bd3fc7b213$export$2bb74740c4e19def, p as $feb5ffebff200149$export$c3d8340acf92597f, k as $ae20dd8cbca75726$export$d6daf82dcd84e87c, q as $c5a24bc478652b5f$export$1005530eda016c13, d as $e1995378a142960e$export$18af5c7a9e9b3664, r as $23b9f4fcf0fe224b$export$5ae2504e948afce5, m as $23b9f4fcf0fe224b$export$d68d59712b04d9d1 } from "./SelectionManager-CabSdgMq.js";
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "./context-DMOmz986.js";
import React__default, { useMemo, createContext } from "react";
import { a as $64fa3d84918910a7$export$29f1550f4b0d4415, b as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "./utils-cvK1vxO7.js";
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "./filterDOMProps-D2C6R0DK.js";
function $62d8ded9296f3872$export$cfa2225e87938781(node, checkForOverflow) {
  let scrollableNode = node;
  if ($cc38e7bd3fc7b213$export$2bb74740c4e19def(scrollableNode, checkForOverflow)) scrollableNode = scrollableNode.parentElement;
  while (scrollableNode && !$cc38e7bd3fc7b213$export$2bb74740c4e19def(scrollableNode, checkForOverflow)) scrollableNode = scrollableNode.parentElement;
  return scrollableNode || document.scrollingElement || document.documentElement;
}
let $325a3faab7a68acd$var$cache = /* @__PURE__ */ new Map();
function $325a3faab7a68acd$export$a16aca283550c30d(options) {
  let { locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
  let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : "");
  if ($325a3faab7a68acd$var$cache.has(cacheKey)) return $325a3faab7a68acd$var$cache.get(cacheKey);
  let formatter = new Intl.Collator(locale, options);
  $325a3faab7a68acd$var$cache.set(cacheKey, formatter);
  return formatter;
}
class $657e4dc4a6e88df0$export$8f5ed9ff9f511381 {
  getItemRect(key) {
    let container = this.ref.current;
    if (!container) return null;
    let item = key != null ? $feb5ffebff200149$export$c3d8340acf92597f(this.ref, key) : null;
    if (!item) return null;
    let containerRect = container.getBoundingClientRect();
    let itemRect = item.getBoundingClientRect();
    return {
      x: itemRect.left - containerRect.left + container.scrollLeft,
      y: itemRect.top - containerRect.top + container.scrollTop,
      width: itemRect.width,
      height: itemRect.height
    };
  }
  getContentSize() {
    let container = this.ref.current;
    var _container_scrollWidth, _container_scrollHeight;
    return {
      width: (_container_scrollWidth = container === null || container === void 0 ? void 0 : container.scrollWidth) !== null && _container_scrollWidth !== void 0 ? _container_scrollWidth : 0,
      height: (_container_scrollHeight = container === null || container === void 0 ? void 0 : container.scrollHeight) !== null && _container_scrollHeight !== void 0 ? _container_scrollHeight : 0
    };
  }
  getVisibleRect() {
    let container = this.ref.current;
    var _container_scrollLeft, _container_scrollTop, _container_offsetWidth, _container_offsetHeight;
    return {
      x: (_container_scrollLeft = container === null || container === void 0 ? void 0 : container.scrollLeft) !== null && _container_scrollLeft !== void 0 ? _container_scrollLeft : 0,
      y: (_container_scrollTop = container === null || container === void 0 ? void 0 : container.scrollTop) !== null && _container_scrollTop !== void 0 ? _container_scrollTop : 0,
      width: (_container_offsetWidth = container === null || container === void 0 ? void 0 : container.offsetWidth) !== null && _container_offsetWidth !== void 0 ? _container_offsetWidth : 0,
      height: (_container_offsetHeight = container === null || container === void 0 ? void 0 : container.offsetHeight) !== null && _container_offsetHeight !== void 0 ? _container_offsetHeight : 0
    };
  }
  constructor(ref) {
    this.ref = ref;
  }
}
class $2a25aae57d74318e$export$a05409b8bb224a5a {
  isDisabled(item) {
    var _item_props;
    return this.disabledBehavior === "all" && (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || this.disabledKeys.has(item.key));
  }
  findNextNonDisabled(key, getNext) {
    let nextKey = key;
    while (nextKey != null) {
      let item = this.collection.getItem(nextKey);
      if ((item === null || item === void 0 ? void 0 : item.type) === "item" && !this.isDisabled(item)) return nextKey;
      nextKey = getNext(nextKey);
    }
    return null;
  }
  getNextKey(key) {
    let nextKey = key;
    nextKey = this.collection.getKeyAfter(nextKey);
    return this.findNextNonDisabled(nextKey, (key2) => this.collection.getKeyAfter(key2));
  }
  getPreviousKey(key) {
    let nextKey = key;
    nextKey = this.collection.getKeyBefore(nextKey);
    return this.findNextNonDisabled(nextKey, (key2) => this.collection.getKeyBefore(key2));
  }
  findKey(key, nextKey, shouldSkip) {
    let tempKey = key;
    let itemRect = this.layoutDelegate.getItemRect(tempKey);
    if (!itemRect || tempKey == null) return null;
    let prevRect = itemRect;
    do {
      tempKey = nextKey(tempKey);
      if (tempKey == null) break;
      itemRect = this.layoutDelegate.getItemRect(tempKey);
    } while (itemRect && shouldSkip(prevRect, itemRect) && tempKey != null);
    return tempKey;
  }
  isSameRow(prevRect, itemRect) {
    return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
  }
  isSameColumn(prevRect, itemRect) {
    return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;
  }
  getKeyBelow(key) {
    if (this.layout === "grid" && this.orientation === "vertical") return this.findKey(key, (key2) => this.getNextKey(key2), this.isSameRow);
    else return this.getNextKey(key);
  }
  getKeyAbove(key) {
    if (this.layout === "grid" && this.orientation === "vertical") return this.findKey(key, (key2) => this.getPreviousKey(key2), this.isSameRow);
    else return this.getPreviousKey(key);
  }
  getNextColumn(key, right) {
    return right ? this.getPreviousKey(key) : this.getNextKey(key);
  }
  getKeyRightOf(key) {
    let layoutDelegateMethod = this.direction === "ltr" ? "getKeyRightOf" : "getKeyLeftOf";
    if (this.layoutDelegate[layoutDelegateMethod]) {
      key = this.layoutDelegate[layoutDelegateMethod](key);
      return this.findNextNonDisabled(key, (key2) => this.layoutDelegate[layoutDelegateMethod](key2));
    }
    if (this.layout === "grid") {
      if (this.orientation === "vertical") return this.getNextColumn(key, this.direction === "rtl");
      else return this.findKey(key, (key2) => this.getNextColumn(key2, this.direction === "rtl"), this.isSameColumn);
    } else if (this.orientation === "horizontal") return this.getNextColumn(key, this.direction === "rtl");
    return null;
  }
  getKeyLeftOf(key) {
    let layoutDelegateMethod = this.direction === "ltr" ? "getKeyLeftOf" : "getKeyRightOf";
    if (this.layoutDelegate[layoutDelegateMethod]) {
      key = this.layoutDelegate[layoutDelegateMethod](key);
      return this.findNextNonDisabled(key, (key2) => this.layoutDelegate[layoutDelegateMethod](key2));
    }
    if (this.layout === "grid") {
      if (this.orientation === "vertical") return this.getNextColumn(key, this.direction === "ltr");
      else return this.findKey(key, (key2) => this.getNextColumn(key2, this.direction === "ltr"), this.isSameColumn);
    } else if (this.orientation === "horizontal") return this.getNextColumn(key, this.direction === "ltr");
    return null;
  }
  getFirstKey() {
    let key = this.collection.getFirstKey();
    return this.findNextNonDisabled(key, (key2) => this.collection.getKeyAfter(key2));
  }
  getLastKey() {
    let key = this.collection.getLastKey();
    return this.findNextNonDisabled(key, (key2) => this.collection.getKeyBefore(key2));
  }
  getKeyPageAbove(key) {
    let menu = this.ref.current;
    let itemRect = this.layoutDelegate.getItemRect(key);
    if (!itemRect) return null;
    if (menu && !$cc38e7bd3fc7b213$export$2bb74740c4e19def(menu)) return this.getFirstKey();
    let nextKey = key;
    if (this.orientation === "horizontal") {
      let pageX = Math.max(0, itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width);
      while (itemRect && itemRect.x > pageX && nextKey != null) {
        nextKey = this.getKeyAbove(nextKey);
        itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
      }
    } else {
      let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
      while (itemRect && itemRect.y > pageY && nextKey != null) {
        nextKey = this.getKeyAbove(nextKey);
        itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
      }
    }
    return nextKey !== null && nextKey !== void 0 ? nextKey : this.getFirstKey();
  }
  getKeyPageBelow(key) {
    let menu = this.ref.current;
    let itemRect = this.layoutDelegate.getItemRect(key);
    if (!itemRect) return null;
    if (menu && !$cc38e7bd3fc7b213$export$2bb74740c4e19def(menu)) return this.getLastKey();
    let nextKey = key;
    if (this.orientation === "horizontal") {
      let pageX = Math.min(this.layoutDelegate.getContentSize().width, itemRect.y - itemRect.width + this.layoutDelegate.getVisibleRect().width);
      while (itemRect && itemRect.x < pageX && nextKey != null) {
        nextKey = this.getKeyBelow(nextKey);
        itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
      }
    } else {
      let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height);
      while (itemRect && itemRect.y < pageY && nextKey != null) {
        nextKey = this.getKeyBelow(nextKey);
        itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
      }
    }
    return nextKey !== null && nextKey !== void 0 ? nextKey : this.getLastKey();
  }
  getKeyForSearch(search, fromKey) {
    if (!this.collator) return null;
    let collection = this.collection;
    let key = fromKey || this.getFirstKey();
    while (key != null) {
      let item = collection.getItem(key);
      if (!item) return null;
      let substring = item.textValue.slice(0, search.length);
      if (item.textValue && this.collator.compare(substring, search) === 0) return key;
      key = this.getNextKey(key);
    }
    return null;
  }
  constructor(...args) {
    if (args.length === 1) {
      let opts = args[0];
      this.collection = opts.collection;
      this.ref = opts.ref;
      this.collator = opts.collator;
      this.disabledKeys = opts.disabledKeys || /* @__PURE__ */ new Set();
      this.disabledBehavior = opts.disabledBehavior || "all";
      this.orientation = opts.orientation || "vertical";
      this.direction = opts.direction;
      this.layout = opts.layout || "stack";
      this.layoutDelegate = opts.layoutDelegate || new $657e4dc4a6e88df0$export$8f5ed9ff9f511381(opts.ref);
    } else {
      this.collection = args[0];
      this.disabledKeys = args[1];
      this.ref = args[2];
      this.collator = args[3];
      this.layout = "stack";
      this.orientation = "vertical";
      this.disabledBehavior = "all";
      this.layoutDelegate = new $657e4dc4a6e88df0$export$8f5ed9ff9f511381(this.ref);
    }
    if (this.layout === "stack" && this.orientation === "vertical") {
      this.getKeyLeftOf = void 0;
      this.getKeyRightOf = void 0;
    }
  }
}
function $982254629710d113$export$b95089534ab7c1fd(props) {
  let { selectionManager, collection, disabledKeys, ref, keyboardDelegate, layoutDelegate } = props;
  let collator = $325a3faab7a68acd$export$a16aca283550c30d({
    usage: "search",
    sensitivity: "base"
  });
  let disabledBehavior = selectionManager.disabledBehavior;
  let delegate = useMemo(() => keyboardDelegate || new $2a25aae57d74318e$export$a05409b8bb224a5a({
    collection,
    disabledKeys,
    disabledBehavior,
    ref,
    collator,
    layoutDelegate
  }), [
    keyboardDelegate,
    layoutDelegate,
    collection,
    disabledKeys,
    ref,
    collator,
    disabledBehavior
  ]);
  let { collectionProps } = $ae20dd8cbca75726$export$d6daf82dcd84e87c({
    ...props,
    ref,
    selectionManager,
    keyboardDelegate: delegate
  });
  return {
    listProps: collectionProps
  };
}
const $453cc9f0df89c0a5$var$cache = /* @__PURE__ */ new WeakMap();
function $453cc9f0df89c0a5$export$77d5aafae4e095b2(collection) {
  let count = $453cc9f0df89c0a5$var$cache.get(collection);
  if (count != null) return count;
  let counter = 0;
  let countItems = (items) => {
    for (let item of items) {
      if (item.type === "section") countItems($c5a24bc478652b5f$export$1005530eda016c13(item, collection));
      else if (item.type === "item") counter++;
    }
  };
  countItems(collection);
  $453cc9f0df89c0a5$var$cache.set(collection, counter);
  return counter;
}
function $f4b273590fab9f93$export$52210f68a14655d0(props) {
  let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
    labelable: true
  });
  let ariaOrientation;
  if (props.orientation === "vertical") ariaOrientation = "vertical";
  if (props.elementType !== "hr") return {
    separatorProps: {
      ...domProps,
      role: "separator",
      "aria-orientation": ariaOrientation
    }
  };
  return {
    separatorProps: domProps
  };
}
const $72a5793c14baf454$export$e0e4026c12a8bdbb = /* @__PURE__ */ createContext({});
const $72a5793c14baf454$export$8b251419efc915eb = /* @__PURE__ */ $e1995378a142960e$export$18af5c7a9e9b3664($23b9f4fcf0fe224b$export$5ae2504e948afce5, function Header(props, ref) {
  [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $72a5793c14baf454$export$e0e4026c12a8bdbb);
  return /* @__PURE__ */ React__default.createElement("header", {
    className: "react-aria-Header",
    ...props,
    ref
  }, props.children);
});
const $431f98aba6844401$export$6615d83f6de245ce = /* @__PURE__ */ createContext({});
class $431f98aba6844401$export$7750289ca694c0b5 extends $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
  filter(collection, newCollection) {
    let prevItem = newCollection.getItem(this.prevKey);
    if (prevItem && prevItem.type !== "separator") {
      let clone = this.clone();
      newCollection.addDescendants(clone, collection);
      return clone;
    }
    return null;
  }
}
$431f98aba6844401$export$7750289ca694c0b5.type = "separator";
const $431f98aba6844401$export$1ff3c3f08ae963c0 = /* @__PURE__ */ $e1995378a142960e$export$18af5c7a9e9b3664($431f98aba6844401$export$7750289ca694c0b5, function Separator(props, ref) {
  [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $431f98aba6844401$export$6615d83f6de245ce);
  let { elementType, orientation, style, className, slot, ...otherProps } = props;
  let Element = elementType || "hr";
  if (Element === "hr" && orientation === "vertical") Element = "div";
  let { separatorProps } = $f4b273590fab9f93$export$52210f68a14655d0({
    ...otherProps,
    elementType,
    orientation
  });
  let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
    global: true
  });
  return /* @__PURE__ */ React__default.createElement(Element, {
    ...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, separatorProps),
    style,
    className: className !== null && className !== void 0 ? className : "react-aria-Separator",
    ref,
    slot: slot || void 0
  });
});
export {
  $72a5793c14baf454$export$8b251419efc915eb as $,
  $431f98aba6844401$export$1ff3c3f08ae963c0 as a,
  $325a3faab7a68acd$export$a16aca283550c30d as b,
  $62d8ded9296f3872$export$cfa2225e87938781 as c,
  $982254629710d113$export$b95089534ab7c1fd as d,
  $453cc9f0df89c0a5$export$77d5aafae4e095b2 as e,
  $2a25aae57d74318e$export$a05409b8bb224a5a as f,
  $431f98aba6844401$export$6615d83f6de245ce as g,
  $72a5793c14baf454$export$e0e4026c12a8bdbb as h
};
