import './index2.css';export { DndSort, DndSortCard, DndSortZone } from './DndSort.js';
export { A as Alert } from './Alert-DmbqtMg_.js';
import { P as Popover } from './AiMark-B1-M3ZgP.js';
export { A as AiMark } from './AiMark-B1-M3ZgP.js';
export { A as Announcement } from './Announcement-_C5g2Lzm.js';
export { A as Avatar } from './Avatar-NbFc4Ovc.js';
export { A as AvatarGroup } from './Avatar-B4hRHku9.js';
export { B as Badge } from './Badge-C_wTvtnB.js';
export { B as Breadcrumbs } from './Breadcrumbs-CYmciJ1D.js';
import { B as Button } from './Button-Bnt8XUI7.js';
export { B as ButtonCompound } from './ButtonCompound-DsrK7G3q.js';
import { B as ButtonLink } from './ButtonLink-j3h_wRNi.js';
import { B as ButtonToggle } from './ButtonToggle-Ct9_5bhC.js';
export { a as Calendar, g as CalendarMonth, f as CalendarMonthButton, e as CalendarNext, b as CalendarNow, d as CalendarPrev, c as CalendarYearButton } from './Calendar-CaCMa_jq.js';
export { C as Card } from './Card-DSFuXUGk.js';
export { C as Checkbox } from './Checkbox-Ckl8EFpF.js';
export { C as Chip } from './Chip-CR5i8mQW.js';
export { C as Combobox, a as ComboboxElement, c as ComboboxList, b as ComboboxSelect } from './Combobox-BffGTugd.js';
export { u as useInfiniteCombobox } from './useInfiniteCombobox-WcRgC9p6.js';
export { D as DateFieldRange } from './DateFieldRange-DPTC3EZz.js';
export { D as DateFieldSingle } from './DateFieldSingle-w1G-zd9G.js';
export { D as DateFieldYearless } from './DateFieldYearless-DHNVc7Sd.js';
export { D as DateFieldYearlessRange } from './DateFieldYearlessRange-C5ktVUgG.js';
export { D as DaysOfTheWeek } from './DaysOfTheWeek-BubWkBZ0.js';
export { D as Details } from './Details-DYRJcLWL.js';
export { D as Dialog } from './Dialog-DGmF6qx3.js';
export { D as Divider } from './Divider-Ds3WKsKa.js';
export { D as Dnd } from './index-ByMdotWU.js';
export { D as Drawer } from './Drawer-iewBy1DW.js';
export { D as DrillDown, b as DrillDownContent, c as DrillDownFooter, a as DrillDownHeader, d as DrillDownNextButton, e as DrillDownPrevButton, u as useDrillDown } from './useDrilldown-D5WWJRU2.js';
export { E as EditCard } from './EditCard-D7-Ye7R0.js';
export { F as FieldLabel } from './FieldLabel-DZWu5dMp.js';
export { w as warnDeprecatedErrorUsage } from './utils-CM48ODEJ.js';
export { F as FieldMessage } from './FieldMessage-DzxfodaI.js';
import { F as Flex } from './Flex-DOUtHiPi.js';
export { G as Grid } from './Grid-B1VVssDD.js';
export { I as Icon } from './Icon-BMMbp40n.js';
export { I as InputMask } from './InputMask-EwEJlW-t.js';
export { L as Layout, b as LayoutElement, a as LayoutItem } from './Layout-C2Q2hyLG.js';
export { L as Link, u as useLinkStyles } from './Link-BUgivkGS.js';
export { L as LinkButton } from './LinkButton-CuHSdGdj.js';
export { L as List } from './List-BXyHWQ9e.js';
import { L as Listbox } from './Listbox-DDlxpVu9.js';
export { L as ListView, a as ListViewOption, b as ListViewOptionCell } from './ListView-DBO9Bl1H.js';
export { M as Menu } from './Menu-wpTyUDac.js';
export { N as NumberField } from './NumberField-DJbdyatF.js';
export { Overflow, OverflowText } from './Overflow.js';
export { P as Page } from './Page-Be1Blwme.js';
export { P as Pagination } from './Pagination-USDJM5vi.js';
export { P as Popover } from './Popover-CyB7yzSf.js';
export { P as ProgressBar } from './ProgressBar-DSrjgLTx.js';
export { R as Radio } from './Radio-CQaXJ72d.js';
export { S as SearchField } from './SearchField-CsRGYZx3.js';
export { S as SegmentedControl, a as SegmentedControlSegment } from './SegmentedControl-Chhqyyra.js';
export { S as SelectCard } from './SelectCard-CtXwY8FZ.js';
export { S as SelectTrigger } from './SelectTrigger-BWN3Tx43.js';
export { S as SideNav } from './SideNav-CZRVOSbt.js';
export { Skeleton, SkeletonCircle, SkeletonPill, SkeletonRectangle, SkeletonText } from './Skeleton.js';
export { S as Spinner } from './Spinner-lPMo68yW.js';
export { S as SrOnly } from './SrOnly-pnf8ajnh.js';
export { S as Stepper } from './Stepper-CYY64NU1.js';
export { S as Switch } from './Switch-DeBu4Ucg.js';
export { T as Tab } from './Tab-CewPzmuK.js';
export { T as Text } from './Text-J5YtSSXY.js';
export { T as Textarea } from './Textarea-CxXmr_Gx.js';
export { T as TextField } from './TextField-YlMkDHp-.js';
export { T as TimeField } from './TimeField-DTg0CE5L.js';
export { T as Toaster } from './Toaster-Dly3rfva.js';
export { t as toast } from './Toaster-Bq42x6Gx.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import { createContext, useContext, useId, useRef, useCallback, useEffect, forwardRef, useState, useMemo } from 'react';
import { c as cx } from './index-De1g9FRV.js';
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-CB_zHDbW.js';
import { u as useMergeRefs } from './useMergeRefs-Dfmtq9cI.js';
import { T as Tooltip } from './Tooltip-BlStOXN3.js';
export { u as useAccessibleColor } from './useAccessibleColor-BYKjkGRg.js';
export { u as useBreakpoint } from './useBreakpoint-CeaUyHxh.js';
export { u as usePrefersColorScheme } from './usePrefersColorScheme-_hT7dK7_.js';
export { u as usePrefersReducedMotion } from './usePrefersReducedMotion-DR9B_D6w.js';
export { u as useSwipe } from './useSwipe-Cp-CJxLU.js';
import { useTrackingId } from './useTrackingId.js';
export { A as AnvilProvider, a as AnvilProviderContext } from './AnvilProvider-JXEbeQjR.js';
export { L as LocalizationProvider } from './LocalizationProvider-CO8fQGqs.js';
export { L as LocalizationContext, u as useLocalizationContext } from './LocalizationContext-UsmB5mnR.js';
export { P as PortalProvider, a as PortalProviderContext } from './PortalProvider-Cj_y3gbC.js';
export { T as ThemeProvider } from './ThemeProvider-D4KdGCaP.js';
export { u as useTheme } from './useTheme-B4i6a3bM.js';
export { T as TrackingProvider } from './TrackingProvider-Co4lyoI9.js';
export { u as useTrackingContext } from './useTrackingContext-C522P4sv.js';
import { g as getKeyboardFocusableElements } from './getKeyboardFocusableElements-QqcABz0D.js';
import { u as useIntersectionObserver } from './useIntersectionObserver-BEmMDO3P.js';
import { S as SvgArrowDropDown } from './arrow_drop_down-ChAdBDux.js';
import { S as SvgMoreHoriz } from './more_horiz-DJgdQiy0.js';
import { S as SvgMoreVert } from './more_vert-C_lJSyxt.js';

const IANA_TIMEZONES = [
  "Pacific/Kiritimati",
  "Pacific/Apia",
  "Pacific/Enderbury",
  "Pacific/Fakaofo",
  "Pacific/Tongatapu",
  "Pacific/Chatham",
  "Antarctica/McMurdo",
  "Asia/Anadyr",
  "Asia/Kamchatka",
  "Pacific/Auckland",
  "Pacific/Fiji",
  "Pacific/Funafuti",
  "Pacific/Kwajalein",
  "Pacific/Majuro",
  "Pacific/Nauru",
  "Pacific/Tarawa",
  "Pacific/Wake",
  "Pacific/Wallis",
  "Antarctica/Casey",
  "Antarctica/Macquarie",
  "Asia/Magadan",
  "Asia/Sakhalin",
  "Asia/Srednekolymsk",
  "Pacific/Bougainville",
  "Pacific/Efate",
  "Pacific/Guadalcanal",
  "Pacific/Kosrae",
  "Pacific/Norfolk",
  "Pacific/Noumea",
  "Pacific/Pohnpei",
  "Australia/Lord_Howe",
  "Antarctica/DumontDUrville",
  "Asia/Ust-Nera",
  "Asia/Vladivostok",
  "Australia/Brisbane",
  "Australia/Currie",
  "Australia/Hobart",
  "Australia/Lindeman",
  "Australia/Melbourne",
  "Australia/Sydney",
  "Pacific/Chuuk",
  "Pacific/Guam",
  "Pacific/Port_Moresby",
  "Pacific/Saipan",
  "Australia/Adelaide",
  "Australia/Broken_Hill",
  "Australia/Darwin",
  "Asia/Chita",
  "Asia/Dili",
  "Asia/Jayapura",
  "Asia/Khandyga",
  "Asia/Seoul",
  "Asia/Tokyo",
  "Asia/Yakutsk",
  "Pacific/Palau",
  "Australia/Eucla",
  "Asia/Pyongyang",
  "Asia/Brunei",
  "Asia/Choibalsan",
  "Asia/Hong_Kong",
  "Asia/Irkutsk",
  "Asia/Kuala_Lumpur",
  "Asia/Kuching",
  "Asia/Macau",
  "Asia/Makassar",
  "Asia/Manila",
  "Asia/Shanghai",
  "Asia/Singapore",
  "Asia/Taipei",
  "Asia/Ulaanbaatar",
  "Australia/Perth",
  "Antarctica/Davis",
  "Asia/Bangkok",
  "Asia/Barnaul",
  "Asia/Ho_Chi_Minh",
  "Asia/Hovd",
  "Asia/Jakarta",
  "Asia/Krasnoyarsk",
  "Asia/Novokuznetsk",
  "Asia/Novosibirsk",
  "Asia/Phnom_Penh",
  "Asia/Pontianak",
  "Asia/Tomsk",
  "Asia/Vientiane",
  "Indian/Christmas",
  "Asia/Yangon",
  "Indian/Cocos",
  "Antarctica/Vostok",
  "Asia/Almaty",
  "Asia/Bishkek",
  "Asia/Dhaka",
  "Asia/Omsk",
  "Asia/Qyzylorda",
  "Asia/Thimphu",
  "Asia/Urumqi",
  "Indian/Chagos",
  "Asia/Kathmandu",
  "Asia/Colombo",
  "Asia/Kolkata",
  "Antarctica/Mawson",
  "Asia/Aqtau",
  "Asia/Aqtobe",
  "Asia/Ashgabat",
  "Asia/Atyrau",
  "Asia/Dushanbe",
  "Asia/Karachi",
  "Asia/Oral",
  "Asia/Samarkand",
  "Asia/Tashkent",
  "Asia/Yekaterinburg",
  "Indian/Kerguelen",
  "Indian/Maldives",
  "Asia/Kabul",
  "Asia/Tehran",
  "Asia/Baku",
  "Asia/Dubai",
  "Asia/Muscat",
  "Asia/Tbilisi",
  "Asia/Yerevan",
  "Europe/Astrakhan",
  "Europe/Samara",
  "Europe/Saratov",
  "Europe/Ulyanovsk",
  "Indian/Mahe",
  "Indian/Mauritius",
  "Indian/Reunion",
  "Africa/Addis_Ababa",
  "Africa/Asmara",
  "Africa/Dar_es_Salaam",
  "Africa/Djibouti",
  "Africa/Juba",
  "Africa/Kampala",
  "Africa/Khartoum",
  "Africa/Mogadishu",
  "Africa/Nairobi",
  "Antarctica/Syowa",
  "Asia/Aden",
  "Asia/Amman",
  "Asia/Baghdad",
  "Asia/Bahrain",
  "Asia/Beirut",
  "Asia/Damascus",
  "Asia/Famagusta",
  "Asia/Gaza",
  "Asia/Hebron",
  "Asia/Jerusalem",
  "Asia/Kuwait",
  "Asia/Nicosia",
  "Asia/Qatar",
  "Asia/Riyadh",
  "Europe/Athens",
  "Europe/Bucharest",
  "Europe/Chisinau",
  "Europe/Helsinki",
  "Europe/Istanbul",
  "Europe/Kiev",
  "Europe/Kirov",
  "Europe/Mariehamn",
  "Europe/Minsk",
  "Europe/Moscow",
  "Europe/Riga",
  "Europe/Simferopol",
  "Europe/Sofia",
  "Europe/Tallinn",
  "Europe/Uzhgorod",
  "Europe/Vilnius",
  "Europe/Volgograd",
  "Europe/Zaporozhye",
  "Indian/Antananarivo",
  "Indian/Comoro",
  "Indian/Mayotte",
  "Africa/Blantyre",
  "Africa/Bujumbura",
  "Africa/Cairo",
  "Africa/Ceuta",
  "Africa/Gaborone",
  "Africa/Harare",
  "Africa/Johannesburg",
  "Africa/Kigali",
  "Africa/Lubumbashi",
  "Africa/Lusaka",
  "Africa/Maputo",
  "Africa/Maseru",
  "Africa/Mbabane",
  "Africa/Tripoli",
  "Antarctica/Troll",
  "Arctic/Longyearbyen",
  "Europe/Amsterdam",
  "Europe/Andorra",
  "Europe/Belgrade",
  "Europe/Berlin",
  "Europe/Bratislava",
  "Europe/Brussels",
  "Europe/Budapest",
  "Europe/Busingen",
  "Europe/Copenhagen",
  "Europe/Gibraltar",
  "Europe/Kaliningrad",
  "Europe/Ljubljana",
  "Europe/Luxembourg",
  "Europe/Madrid",
  "Europe/Malta",
  "Europe/Monaco",
  "Europe/Oslo",
  "Europe/Paris",
  "Europe/Podgorica",
  "Europe/Prague",
  "Europe/Rome",
  "Europe/San_Marino",
  "Europe/Sarajevo",
  "Europe/Skopje",
  "Europe/Stockholm",
  "Europe/Tirane",
  "Europe/Vaduz",
  "Europe/Vatican",
  "Europe/Vienna",
  "Europe/Warsaw",
  "Europe/Zagreb",
  "Europe/Zurich",
  "Africa/Algiers",
  "Africa/Bangui",
  "Africa/Brazzaville",
  "Africa/Casablanca",
  "Africa/Douala",
  "Africa/El_Aaiun",
  "Africa/Kinshasa",
  "Africa/Lagos",
  "Africa/Libreville",
  "Africa/Luanda",
  "Africa/Malabo",
  "Africa/Ndjamena",
  "Africa/Niamey",
  "Africa/Porto-Novo",
  "Africa/Tunis",
  "Africa/Windhoek",
  "Atlantic/Canary",
  "Atlantic/Faroe",
  "Atlantic/Madeira",
  "Europe/Dublin",
  "Europe/Guernsey",
  "Europe/Isle_of_Man",
  "Europe/Jersey",
  "Europe/Lisbon",
  "Europe/London",
  "Africa/Abidjan",
  "Africa/Accra",
  "Africa/Bamako",
  "Africa/Banjul",
  "Africa/Bissau",
  "Africa/Conakry",
  "Africa/Dakar",
  "Africa/Freetown",
  "Africa/Lome",
  "Africa/Monrovia",
  "Africa/Nouakchott",
  "Africa/Ouagadougou",
  "Africa/Sao_Tome",
  "America/Danmarkshavn",
  "America/Scoresbysund",
  "Atlantic/Azores",
  "Atlantic/Reykjavik",
  "Atlantic/St_Helena",
  "UTC",
  "Atlantic/Cape_Verde",
  "America/Godthab",
  "America/Miquelon",
  "America/Noronha",
  "Atlantic/South_Georgia",
  "America/St_Johns",
  "America/Araguaina",
  "America/Argentina/Buenos_Aires",
  "America/Argentina/Catamarca",
  "America/Argentina/Cordoba",
  "America/Argentina/Jujuy",
  "America/Argentina/La_Rioja",
  "America/Argentina/Mendoza",
  "America/Argentina/Rio_Gallegos",
  "America/Argentina/Salta",
  "America/Argentina/San_Juan",
  "America/Argentina/San_Luis",
  "America/Argentina/Tucuman",
  "America/Argentina/Ushuaia",
  "America/Bahia",
  "America/Belem",
  "America/Cayenne",
  "America/Fortaleza",
  "America/Glace_Bay",
  "America/Goose_Bay",
  "America/Halifax",
  "America/Maceio",
  "America/Moncton",
  "America/Montevideo",
  "America/Paramaribo",
  "America/Punta_Arenas",
  "America/Recife",
  "America/Santarem",
  "America/Sao_Paulo",
  "America/Thule",
  "Antarctica/Palmer",
  "Antarctica/Rothera",
  "Atlantic/Bermuda",
  "Atlantic/Stanley",
  "America/Anguilla",
  "America/Antigua",
  "America/Aruba",
  "America/Asuncion",
  "America/Barbados",
  "America/Blanc-Sablon",
  "America/Boa_Vista",
  "America/Campo_Grande",
  "America/Caracas",
  "America/Cuiaba",
  "America/Curacao",
  "America/Detroit",
  "America/Dominica",
  "America/Grand_Turk",
  "America/Grenada",
  "America/Guadeloupe",
  "America/Guyana",
  "America/Havana",
  "America/Indiana/Indianapolis",
  "America/Indiana/Marengo",
  "America/Indiana/Petersburg",
  "America/Indiana/Vevay",
  "America/Indiana/Vincennes",
  "America/Indiana/Winamac",
  "America/Iqaluit",
  "America/Kentucky/Louisville",
  "America/Kentucky/Monticello",
  "America/Kralendijk",
  "America/La_Paz",
  "America/Lower_Princes",
  "America/Manaus",
  "America/Marigot",
  "America/Martinique",
  "America/Montserrat",
  "America/Nassau",
  "America/New_York",
  "America/Nipigon",
  "America/Pangnirtung",
  "America/Port-au-Prince",
  "America/Port_of_Spain",
  "America/Porto_Velho",
  "America/Puerto_Rico",
  "America/Santiago",
  "America/Santo_Domingo",
  "America/St_Barthelemy",
  "America/St_Kitts",
  "America/St_Lucia",
  "America/St_Thomas",
  "America/St_Vincent",
  "America/Thunder_Bay",
  "America/Toronto",
  "America/Tortola",
  // UTC-05:00
  "America/Atikokan",
  "America/Bahia_Banderas",
  "America/Bogota",
  "America/Cancun",
  "America/Cayman",
  "America/Chicago",
  "America/Eirunepe",
  "America/Guayaquil",
  "America/Indiana/Knox",
  "America/Indiana/Tell_City",
  "America/Jamaica",
  "America/Lima",
  "America/Matamoros",
  "America/Menominee",
  "America/Merida",
  "America/Mexico_City",
  "America/Monterrey",
  "America/North_Dakota/Beulah",
  "America/North_Dakota/Center",
  "America/North_Dakota/New_Salem",
  "America/Panama",
  "America/Rainy_River",
  "America/Rankin_Inlet",
  "America/Resolute",
  "America/Rio_Branco",
  "America/Winnipeg",
  "America/Belize",
  "America/Boise",
  "America/Cambridge_Bay",
  "America/Chihuahua",
  "America/Costa_Rica",
  "America/Denver",
  "America/Edmonton",
  "America/El_Salvador",
  "America/Guatemala",
  "America/Inuvik",
  "America/Managua",
  "America/Mazatlan",
  "America/Ojinaga",
  "America/Regina",
  "America/Swift_Current",
  "America/Tegucigalpa",
  "America/Yellowknife",
  "Pacific/Easter",
  "Pacific/Galapagos",
  "America/Creston",
  "America/Dawson",
  "America/Dawson_Creek",
  "America/Fort_Nelson",
  "America/Hermosillo",
  "America/Los_Angeles",
  "America/Phoenix",
  "America/Tijuana",
  "America/Vancouver",
  "America/Whitehorse",
  "America/Anchorage",
  "America/Juneau",
  "America/Metlakatla",
  "America/Nome",
  "America/Sitka",
  "America/Yakutat",
  "Pacific/Pitcairn",
  "America/Adak",
  "Pacific/Gambier",
  "Pacific/Marquesas",
  "Pacific/Honolulu",
  "Pacific/Rarotonga",
  "Pacific/Tahiti",
  "Pacific/Midway",
  "Pacific/Niue",
  "Pacific/Pago_Pago"
];

const OverflowItemContext = createContext({
  isInOverflowMenu: false
});
const useOverFlowItemContext = () => useContext(OverflowItemContext);

const ToolbarContext = createContext({
  overflowItems: [],
  addItem: () => {
    return;
  },
  removeItem: () => {
    return;
  },
  toolbarRef: { current: null },
  orderedIds: [],
  overflow: "wrap",
  size: "xsmall"
});
const useToolbarSize = () => useContext(ToolbarContext).size;

function getToolbarElements(toolbarElement) {
  const toolbarContent = toolbarElement.querySelector(
    '[data-anv="toolbar-content"]'
  );
  const mainItems = getKeyboardFocusableElements(toolbarContent).filter(
    (item) => {
      const isVisible = !item.closest('[aria-hidden="true"]');
      return isVisible;
    }
  );
  const overflowTrigger = toolbarElement.querySelector(
    '[data-anv="toolbar-overflow-trigger"]'
  );
  return overflowTrigger ? [...mainItems, overflowTrigger] : mainItems;
}
function updateToolbarItemsTabIndex(toolbarElement, activeItem) {
  if (!toolbarElement) return;
  const items = getToolbarElements(toolbarElement);
  if (!items.length) return;
  let activeIndex = 0;
  if (typeof activeItem === "number") {
    activeIndex = Math.max(0, Math.min(activeItem, items.length - 1));
  } else if (activeItem instanceof Element) {
    const foundIndex = items.indexOf(activeItem);
    if (foundIndex !== -1) {
      activeIndex = foundIndex;
    }
  }
  items.forEach((item, index) => {
    item.setAttribute("tabindex", index === activeIndex ? "0" : "-1");
  });
  return items[activeIndex];
}
function handleToolbarKeyDown(event, toolbarElement) {
  if (!toolbarElement || event.altKey || event.ctrlKey || event.metaKey) return;
  const items = getToolbarElements(toolbarElement);
  if (!items.length) return;
  const activeElement = event.target;
  if (!toolbarElement.contains(activeElement)) return;
  const activeItem = items.find(
    (item) => item === activeElement || Array.from(item.children).some((child) => child === activeElement)
  );
  const activeIndex = activeItem ? items.indexOf(activeItem) : -1;
  if (activeIndex === -1) return;
  let nextIndex = activeIndex;
  const isVertical = toolbarElement.getAttribute("aria-orientation") === "vertical";
  switch (event.key) {
    case "ArrowLeft":
    case "ArrowUp":
      event.preventDefault();
      if (isVertical && event.key === "ArrowUp" || !isVertical && event.key === "ArrowLeft") {
        nextIndex = activeIndex <= 0 ? items.length - 1 : activeIndex - 1;
      }
      break;
    case "ArrowRight":
    case "ArrowDown":
      event.preventDefault();
      if (isVertical && event.key === "ArrowDown" || !isVertical && event.key === "ArrowRight") {
        nextIndex = activeIndex >= items.length - 1 ? 0 : activeIndex + 1;
      }
      break;
    case "Home":
      event.preventDefault();
      nextIndex = 0;
      break;
    case "End":
      event.preventDefault();
      nextIndex = items.length - 1;
      break;
    default:
      return;
  }
  updateToolbarItemsTabIndex(toolbarElement, nextIndex);
  items[nextIndex]?.focus();
}
const handleMenuKeyboardNavigation = (event) => {
  const menuItems = Array.from(
    event.currentTarget.querySelectorAll('[role="menuitem"]')
  ).map((menuItem) => {
    return getKeyboardFocusableElements(menuItem)[0] || menuItem;
  });
  if (!menuItems.length) return;
  const currentIndex = menuItems.indexOf(document.activeElement);
  if (currentIndex === -1) return;
  let nextIndex = currentIndex;
  const isModifierKey = event.altKey || event.ctrlKey || event.metaKey;
  if (isModifierKey) return;
  switch (event.key) {
    case "ArrowDown":
    case "ArrowUp": {
      event.preventDefault();
      const direction = event.key === "ArrowDown" ? 1 : -1;
      nextIndex = (currentIndex + direction + menuItems.length) % menuItems.length;
      break;
    }
    case "Home":
      event.preventDefault();
      nextIndex = 0;
      break;
    case "End":
      event.preventDefault();
      nextIndex = menuItems.length - 1;
      break;
    default:
      return;
  }
  menuItems[nextIndex]?.focus();
};

const toolbar = "_toolbar_8m7of_1";
const styles = {
	toolbar: toolbar,
	"toolbar-content": "_toolbar-content_8m7of_5",
	"toolbar-overflow-content": "_toolbar-overflow-content_8m7of_9",
	"toolbar-button-item": "_toolbar-button-item_8m7of_17",
	"toolbar-button-toggle-item": "_toolbar-button-toggle-item_8m7of_26",
	"toolbar-overflow-trigger": "_toolbar-overflow-trigger_8m7of_49",
	"toolbar-item": "_toolbar-item_8m7of_60",
	"overflow-collapse": "_overflow-collapse_8m7of_66"
};

const ToolbarItemWrapper = ({
  item,
  children
}) => {
  const { addItem, removeItem, toolbarRef, overflow } = useContext(ToolbarContext);
  const itemId = useId();
  const elementRef = useRef(null);
  const prevIntersectingRef = useRef(true);
  const isCollapseMode = overflow === "collapse";
  const handleVisibilityChange = useCallback(
    (isVisible) => {
      if (!isCollapseMode || prevIntersectingRef.current === isVisible) return;
      const itemWithId = { ...item, id: itemId };
      if (isVisible) {
        removeItem(itemWithId);
      } else {
        addItem(itemWithId);
      }
      prevIntersectingRef.current = isVisible;
    },
    [isCollapseMode, item, itemId, addItem, removeItem]
  );
  const { isIntersecting, ref } = useIntersectionObserver({
    root: isCollapseMode ? toolbarRef.current : null,
    threshold: 1,
    initialIsIntersecting: false,
    onChange: handleVisibilityChange
  });
  const setRefCallback = useCallback(
    (node) => {
      elementRef.current = node;
      if (isCollapseMode) {
        ref(node);
      }
    },
    [ref, isCollapseMode]
  );
  const handleFocusOrClick = useCallback(() => {
    if (!toolbarRef.current || !elementRef.current) return;
    const currentElement = elementRef.current.querySelector("button, a, input");
    if (!currentElement) return;
    updateToolbarItemsTabIndex(toolbarRef.current, currentElement);
  }, [toolbarRef]);
  useEffect(() => {
    const interactiveEl = elementRef.current?.querySelector("button, a, input");
    if (!interactiveEl) return;
    interactiveEl.addEventListener("focus", handleFocusOrClick);
    interactiveEl.addEventListener("click", handleFocusOrClick);
    return () => {
      interactiveEl.removeEventListener("focus", handleFocusOrClick);
      interactiveEl.removeEventListener("click", handleFocusOrClick);
    };
  }, [handleFocusOrClick]);
  useEffect(() => {
    if (isCollapseMode) {
      prevIntersectingRef.current = true;
    }
  }, [isCollapseMode]);
  const isHidden = isCollapseMode && !isIntersecting;
  return /* @__PURE__ */ jsx(
    "div",
    {
      ref: setRefCallback,
      className: styles["toolbar-item"],
      style: { visibility: isHidden ? "hidden" : "visible" },
      "aria-hidden": isHidden,
      ...{ inert: isHidden ? "" : void 0 },
      "data-id": itemId,
      "data-anv": "toolbar-item",
      children
    }
  );
};

const ToolbarButton = forwardRef(
  (props, ref) => {
    const { appearance = "ghost", className, children, ...rest } = props;
    const { isInOverflowMenu = false } = useOverFlowItemContext?.() || {};
    const size = useToolbarSize();
    const trackingId = useTrackingId({
      name: "ToolbarButton",
      data: {
        disabled: props.disabled,
        "aria-label": props["aria-label"],
        children: props.children
      },
      hasOverride: !!props["data-tracking-id"]
    });
    const buttonClassNames = cx(className, styles["toolbar-button-item"]);
    const item = children ? /* @__PURE__ */ jsx(
      Button,
      {
        ref,
        "data-tracking-id": trackingId,
        appearance,
        size,
        "data-anv": "toolbar-button",
        className: buttonClassNames,
        ...rest,
        children
      }
    ) : /* @__PURE__ */ jsxs(Tooltip, { children: [
      /* @__PURE__ */ jsx(Tooltip.Trigger, { children: /* @__PURE__ */ jsx(
        Button,
        {
          ref,
          "data-tracking-id": trackingId,
          appearance,
          size,
          "data-anv": "toolbar-button",
          className: buttonClassNames,
          ...rest
        }
      ) }),
      /* @__PURE__ */ jsx(Tooltip.Content, { children: rest["aria-label"] })
    ] });
    if (isInOverflowMenu) {
      return item;
    }
    return /* @__PURE__ */ jsx(ToolbarItemWrapper, { item: { itemProps: props, itemType: "button" }, children: item });
  }
);
ToolbarButton.displayName = "ToolbarButton";

const ToolbarButtonToggle = forwardRef((props, _ref) => {
  const { className, children, ...rest } = props;
  const { isInOverflowMenu = false } = useOverFlowItemContext?.() || {};
  const size = useToolbarSize();
  const trackingId = useTrackingId({
    name: "ToolbarButtonToggle",
    data: {
      checked: props.checked,
      disabled: props.disabled,
      "aria-label": props["aria-label"],
      children: props.children
    },
    hasOverride: !!props["data-tracking-id"]
  });
  const buttonToggleClassNames = cx(
    className,
    styles["toolbar-button-item"],
    styles["toolbar-button-toggle-item"]
  );
  const item = children ? /* @__PURE__ */ jsx(
    ButtonToggle,
    {
      "data-tracking-id": trackingId,
      size,
      "data-anv": "toolbar-button-toggle",
      className: buttonToggleClassNames,
      ...rest,
      children
    }
  ) : /* @__PURE__ */ jsxs(Tooltip, { children: [
    /* @__PURE__ */ jsx(Tooltip.Trigger, { children: /* @__PURE__ */ jsx(
      ButtonToggle,
      {
        "data-tracking-id": trackingId,
        size,
        "data-anv": "toolbar-button-toggle",
        className: buttonToggleClassNames,
        ...rest
      }
    ) }),
    /* @__PURE__ */ jsx(Tooltip.Content, { children: rest["aria-label"] })
  ] });
  if (isInOverflowMenu) {
    return item;
  }
  return /* @__PURE__ */ jsx(ToolbarItemWrapper, { item: { itemProps: props, itemType: "buttonToggle" }, children: item });
});
ToolbarButtonToggle.displayName = "ToolbarButtonToggle";

const ToolbarButtonLink = forwardRef((props, _ref) => {
  const { appearance = "ghost", className, children, icon, ...rest } = props;
  const { isInOverflowMenu = false } = useOverFlowItemContext?.() || {};
  const size = useToolbarSize();
  const trackingId = useTrackingId({
    name: "ToolbarButtonLink",
    data: {
      href: props.href,
      disabled: props.disabled,
      "aria-label": props["aria-label"],
      children: props.children,
      target: props.target
    },
    hasOverride: !!props["data-tracking-id"]
  });
  const buttonLinkClassNames = cx(className, styles["toolbar-button-item"]);
  const item = children ? /* @__PURE__ */ jsx(
    ButtonLink,
    {
      "data-tracking-id": trackingId,
      appearance,
      size,
      icon,
      "data-anv": "toolbar-button-link",
      className: buttonLinkClassNames,
      ...rest,
      children
    }
  ) : /* @__PURE__ */ jsxs(Tooltip, { children: [
    /* @__PURE__ */ jsx(Tooltip.Trigger, { children: /* @__PURE__ */ jsx(
      ButtonLink,
      {
        "data-tracking-id": trackingId,
        appearance,
        size,
        icon,
        "data-anv": "toolbar-button-link",
        className: buttonLinkClassNames,
        ...rest,
        children
      }
    ) }),
    /* @__PURE__ */ jsx(Tooltip.Content, { children: rest["aria-label"] })
  ] });
  if (isInOverflowMenu) {
    return item;
  }
  return /* @__PURE__ */ jsx(ToolbarItemWrapper, { item: { itemProps: props, itemType: "buttonLink" }, children: item });
});
ToolbarButtonLink.displayName = "ToolbarButtonLink";

const ToolbarSelect = forwardRef(
  (props, _ref) => {
    const {
      appearance = "ghost",
      onChange,
      selected: selectedItemId,
      accessibleLabel,
      className,
      items,
      ...rest
    } = props;
    const selectId = useId();
    const [isPopoverOpen, setIsPopoverOpen] = useState(false);
    const defaultId = items.length > 0 ? items[0].id : "";
    const [internalSelectedId, setInternalSelectedId] = useState(defaultId);
    const selectedId = selectedItemId ?? internalSelectedId;
    const selectedItem = items.find((item2) => item2.id === selectedId) || items.find((item2) => item2.id === defaultId);
    useEffect(() => {
      if (!selectedItemId && items.length > 0 && !items.some((item2) => item2.id === internalSelectedId)) {
        setInternalSelectedId(items[0].id);
      }
    }, [items, selectedItemId, internalSelectedId]);
    const handleSelectionChange = (selected) => {
      if (selected?.id) {
        if (selectedItemId === void 0) {
          setInternalSelectedId(selected.id);
        }
        onChange?.(selected.id);
        setIsPopoverOpen(false);
      }
    };
    const { isInOverflowMenu = false } = useOverFlowItemContext?.() || {};
    const toolbarSize = useToolbarSize();
    const trackingId = useTrackingId({
      name: "ToolbarSelect",
      data: {
        selected: props.selected,
        disabled: props.disabled,
        "aria-label": props["aria-label"],
        items: props.items
      },
      hasOverride: !!props["data-tracking-id"]
    });
    const buttonClassNames = cx(className, styles["toolbar-button-item"]);
    const item = /* @__PURE__ */ jsxs(
      Popover,
      {
        noPadding: true,
        open: isPopoverOpen,
        onClickOutside: () => {
          setIsPopoverOpen(false);
        },
        onClose: () => {
          setIsPopoverOpen(false);
        },
        children: [
          /* @__PURE__ */ jsx(
            Popover.Button,
            {
              "data-tracking-id": trackingId,
              appearance,
              size: toolbarSize,
              icon: { after: SvgArrowDropDown },
              className: buttonClassNames,
              id: selectId,
              "data-anv": "toolbar-select",
              onClick: () => {
                setIsPopoverOpen(!isPopoverOpen);
              },
              ...rest,
              children: selectedItem?.label
            }
          ),
          /* @__PURE__ */ jsx(
            Popover.Content,
            {
              className: styles["toolbar-select-content"],
              "aria-label": accessibleLabel,
              children: /* @__PURE__ */ jsx(
                Listbox,
                {
                  selected: selectedItem,
                  onSelectionChange: handleSelectionChange,
                  items,
                  "aria-labelledby": selectId,
                  disableAutoSelectOnFocus: true,
                  children: ({ items: items2 }) => items2.map((item2) => /* @__PURE__ */ jsx(Listbox.Option, { item: item2, children: item2.label }, item2.label))
                }
              )
            }
          )
        ]
      }
    );
    if (isInOverflowMenu) {
      return item;
    }
    return /* @__PURE__ */ jsx(ToolbarItemWrapper, { item: { itemProps: props, itemType: "select" }, children: item });
  }
);
ToolbarSelect.displayName = "ToolbarSelect";

const OverflowItem = ({ itemType, itemProps }) => {
  switch (itemType) {
    case "button":
      return /* @__PURE__ */ jsx(ToolbarButton, { ...itemProps });
    case "buttonToggle":
      return /* @__PURE__ */ jsx(ToolbarButtonToggle, { ...itemProps });
    case "buttonLink":
      return /* @__PURE__ */ jsx(ToolbarButtonLink, { ...itemProps });
    case "select":
      return /* @__PURE__ */ jsx(ToolbarSelect, { ...itemProps });
    default:
      return null;
  }
};
const ToolbarOverflowMenu = ({
  additionalItems,
  direction
}) => {
  const { overflowItems, orderedIds } = useContext(ToolbarContext);
  const menuTriggerId = useId();
  const size = useToolbarSize();
  const orderedItems = useMemo(() => {
    const allElements = orderedIds?.map((id) => {
      return overflowItems.find((item) => item.id === id);
    });
    return allElements?.filter((item) => item !== void 0) || [];
  }, [orderedIds, overflowItems]);
  const popoverButtonClassNames = cx(
    styles["toolbar-button-item"],
    styles["toolbar-overflow-trigger"]
  );
  const overflowIcon = direction === "horizontal" ? SvgMoreHoriz : SvgMoreVert;
  return /* @__PURE__ */ jsxs(Popover, { noPadding: true, children: [
    /* @__PURE__ */ jsx(
      Popover.Button,
      {
        size,
        appearance: "ghost",
        id: menuTriggerId,
        className: popoverButtonClassNames,
        "data-anv": "toolbar-overflow-trigger",
        "aria-label": "Additional toolbar options",
        icon: overflowIcon
      }
    ),
    /* @__PURE__ */ jsx(Popover.Content, { children: /* @__PURE__ */ jsx(OverflowItemContext.Provider, { value: { isInOverflowMenu: true }, children: /* @__PURE__ */ jsxs(
      "ul",
      {
        role: "menu",
        className: styles["toolbar-overflow-content"],
        "data-anv": "toolbar-overflow-menu",
        "aria-labelledby": menuTriggerId,
        onKeyDown: handleMenuKeyboardNavigation,
        children: [
          orderedItems.map((item) => {
            const { itemType, itemProps, id } = item;
            return /* @__PURE__ */ jsx(
              "li",
              {
                role: "menuitem",
                "data-anv": "toolbar-overflow-item",
                children: /* @__PURE__ */ jsx(
                  OverflowItem,
                  {
                    itemType,
                    itemProps,
                    id
                  }
                )
              },
              `${itemType}-${id}`
            );
          }),
          additionalItems?.map((item, index) => /* @__PURE__ */ jsx(
            "li",
            {
              role: "menuitem",
              "data-anv": "toolbar-overflow-item",
              children: item
            },
            `additional-item-${index}`
          ))
        ]
      }
    ) }) })
  ] });
};

const Toolbar = Object.assign(
  forwardRef(function ToolbarInner(props, ref) {
    const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
    const {
      associatedContent,
      className,
      children,
      style,
      direction = "horizontal",
      overflow = "wrap",
      onKeyDown,
      additionalItems,
      size = "xsmall",
      ...rest
    } = componentProps;
    const [overflowItems, setOverflowItems] = useState([]);
    const toolbarItemsRef = useRef(null);
    const toolbarRef = useRef(null);
    const [orderedIds, setOrderedIds] = useState([]);
    useEffect(() => {
      const newOrderedIds = Array.from(
        toolbarItemsRef.current?.querySelectorAll("[data-id]") || []
      ).map((el) => {
        return el.getAttribute("data-id");
      });
      setOrderedIds(newOrderedIds);
    }, [children]);
    const addItem = useCallback((item) => {
      setOverflowItems((prev) => [...prev, item]);
    }, []);
    const removeItem = useCallback((item) => {
      setOverflowItems(
        (prev) => prev.filter((component) => component.id !== item.id)
      );
    }, []);
    useEffect(() => {
      if (toolbarRef.current) {
        updateToolbarItemsTabIndex(toolbarRef.current);
      }
    }, [children]);
    const handleKeyDown = useCallback(
      (event) => {
        if (toolbarRef.current) {
          handleToolbarKeyDown(event, toolbarRef.current);
        }
        onKeyDown?.(event);
      },
      [onKeyDown]
    );
    const showOverflowMenu = overflow === "collapse" && overflowItems.length > 0 || !!additionalItems;
    const value = useMemo(
      () => ({
        overflowItems,
        addItem,
        removeItem,
        toolbarRef,
        orderedIds,
        overflow,
        size
      }),
      [
        overflowItems,
        addItem,
        removeItem,
        toolbarRef,
        orderedIds,
        overflow,
        size
      ]
    );
    const styleCombined = {
      ...style,
      ...layoutStyles
    };
    const toolbarClassNames = cx(styles["toolbar"], className);
    const toolbarContentClassNames = cx(styles["toolbar-content"], {
      [styles[`overflow-${overflow}`]]: overflow
    });
    return /* @__PURE__ */ jsx(ToolbarContext.Provider, { value, children: /* @__PURE__ */ jsxs(
      Flex,
      {
        direction: direction === "horizontal" ? "row" : "column",
        wrap: overflow === "wrap" ? "wrap" : "nowrap",
        alignItems: "center",
        className: toolbarClassNames,
        style: styleCombined,
        ref: useMergeRefs([toolbarRef, ref]),
        role: "toolbar",
        "data-anv": "toolbar",
        "aria-orientation": direction,
        "aria-label": `Toolbar for ${associatedContent}. Use arrow keys to navigate through toolbar controls.`,
        onKeyDown: handleKeyDown,
        ...rest,
        children: [
          /* @__PURE__ */ jsx(
            Flex,
            {
              ref: useMergeRefs([toolbarItemsRef, ref]),
              className: toolbarContentClassNames,
              direction: direction === "horizontal" ? "row" : "column",
              wrap: overflow === "wrap" ? "wrap" : "nowrap",
              alignItems: "center",
              grow: 1,
              "data-anv": "toolbar-content",
              children
            }
          ),
          showOverflowMenu && /* @__PURE__ */ jsx(
            ToolbarOverflowMenu,
            {
              direction,
              additionalItems
            }
          )
        ]
      }
    ) });
  }),
  {
    /**
     * ToolbarButton component for standard clickable actions within a toolbar with anvil2 tracking.
     *
     * Features:
     * - Designed specifically for toolbar integration
     * - Consistent styling with other toolbar items
     * - Automatic tooltip for icon-only buttons
     * - Overflow menu support
     * - Accessibility enforcement for aria-labels
     * - Ghost and primary appearance options
     * - Automatic tracking ID generation for analytics
     *
     * @example
     * <Toolbar.Button icon={BoldIcon} aria-label="Bold text" />
     *
     * @example
     * <Toolbar.Button appearance="primary">
     *   Save
     * </Toolbar.Button>
     */
    Button: ToolbarButton,
    /**
     * ToolbarButtonToggle component for toggleable actions within a toolbar with anvil2 tracking.
     *
     * Features:
     * - Toggle state management
     * - Designed specifically for toolbar integration
     * - Consistent styling with other toolbar items
     * - Overflow menu support
     * - Accessibility enforcement for aria-labels
     * - Ghost and primary appearance options
     * - Automatic tracking ID generation for analytics
     *
     * @example
     * <Toolbar.ButtonToggle icon={BoldIcon} aria-label="Bold" checked={isBold} />
     */
    ButtonToggle: ToolbarButtonToggle,
    /**
     * ToolbarButtonLink component for link actions within a toolbar with anvil2 tracking.
     *
     * Features:
     * - Link functionality with href support
     * - Designed specifically for toolbar integration
     * - Consistent styling with other toolbar items
     * - Overflow menu support
     * - Accessibility enforcement for aria-labels
     * - Ghost and primary appearance options
     * - Automatic tracking ID generation for analytics
     *
     * @example
     * <Toolbar.ButtonLink href="/help">
     *   Help
     * </Toolbar.ButtonLink>
     */
    ButtonLink: ToolbarButtonLink,
    /**
     * ToolbarSelect component provides a dropdown selector within a toolbar with anvil2 tracking.
     *
     * Features:
     * - Dropdown menu with selectable options
     * - Controlled and uncontrolled usage patterns
     * - Automatic overflow menu integration
     * - Accessibility support with proper ARIA labels
     * - Ghost and primary appearance options
     * - Dropdown arrow icon indicator
     * - Listbox integration for keyboard navigation
     * - Automatic tracking ID generation for analytics
     *
     * @example
     * <Toolbar.Select
     *   items={fontOptions}
     *   selected="arial"
     *   accessibleLabel="Font family"
     *   onChange={(id) => setFont(id)}
     * />
     */
    Select: ToolbarSelect
  }
);
Toolbar.displayName = "Toolbar";

export { Button, ButtonLink, ButtonToggle, Flex, IANA_TIMEZONES, Listbox, Toolbar, Tooltip, useMergeRefs, useTrackingId };
//# sourceMappingURL=index.js.map
