@bazza-ui/react 0.1.0-canary.7 → 0.1.0-canary.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/chunk-23NDAOAL.js +2 -0
  2. package/dist/chunk-23NDAOAL.js.map +1 -0
  3. package/dist/chunk-IT372NHF.js +2 -0
  4. package/dist/chunk-IT372NHF.js.map +1 -0
  5. package/dist/chunk-KRMKZEK4.cjs +2 -0
  6. package/dist/{chunk-URLK26NV.cjs.map → chunk-KRMKZEK4.cjs.map} +1 -1
  7. package/dist/chunk-SCDHQZFI.cjs +2 -0
  8. package/dist/chunk-SCDHQZFI.cjs.map +1 -0
  9. package/dist/combobox/index.cjs +1 -1
  10. package/dist/combobox/index.cjs.map +1 -1
  11. package/dist/combobox/index.js +1 -1
  12. package/dist/combobox/index.js.map +1 -1
  13. package/dist/{context-Dhm4Zi3l.d.ts → context-ChPa-nD4.d.ts} +6 -0
  14. package/dist/{context-Drjy6Y10.d.cts → context-HN6UavqL.d.cts} +6 -0
  15. package/dist/context-menu/index.cjs +1 -1
  16. package/dist/context-menu/index.d.cts +2 -2
  17. package/dist/context-menu/index.d.ts +2 -2
  18. package/dist/context-menu/index.js +1 -1
  19. package/dist/dropdown-menu/index.cjs +1 -1
  20. package/dist/dropdown-menu/index.cjs.map +1 -1
  21. package/dist/dropdown-menu/index.d.cts +2 -2
  22. package/dist/dropdown-menu/index.d.ts +2 -2
  23. package/dist/dropdown-menu/index.js +1 -1
  24. package/dist/dropdown-menu/index.js.map +1 -1
  25. package/dist/internal/popup-menu/index.cjs +1 -1
  26. package/dist/internal/popup-menu/index.d.cts +2 -2
  27. package/dist/internal/popup-menu/index.d.ts +2 -2
  28. package/dist/internal/popup-menu/index.js +1 -1
  29. package/dist/select/index.cjs +1 -1
  30. package/dist/select/index.cjs.map +1 -1
  31. package/dist/select/index.d.cts +7 -0
  32. package/dist/select/index.d.ts +7 -0
  33. package/dist/select/index.js +1 -1
  34. package/dist/select/index.js.map +1 -1
  35. package/dist/video-player/index.cjs +2 -2
  36. package/dist/video-player/index.cjs.map +1 -1
  37. package/dist/video-player/index.js +2 -2
  38. package/dist/video-player/index.js.map +1 -1
  39. package/package.json +1 -1
  40. package/dist/chunk-2D2HREBK.js +0 -2
  41. package/dist/chunk-2D2HREBK.js.map +0 -1
  42. package/dist/chunk-URLK26NV.cjs +0 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","../../src/select/index.parts.ts","../../src/select/item/item.tsx","../../src/select/contexts/select-context.ts","../../src/select/item/item.data-attrs.ts","../../src/select/item/item-context.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","PopupMenuInput","SelectItem","SelectItemIndicator","SelectItemLabel","PopupMenuList","SelectPopup","PopupMenuPortal","SelectPositioner","SelectRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","SelectSurface","SelectTrigger","SelectValue","SelectContext","useSelectContext","context","useMaybeSelectContext","SelectItemDataAttributes","SelectItemContext","useSelectItemContext","useMaybeSelectItemContext","stateAttributesMapping","value","SelectItemImpl","props","forwardedRef","textValueProp","keywordsProp","disabled","onSelect","forceMount","render","className","style","onClick","onPointerDown","onPointerMove","children","rest","selectContext","serializedValue","stringifyAsValue","generatedItemId","listboxId"],"mappings":"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","file":"/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","sourcesContent":[null,"// ============================================================================\n// Select Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Select-specific\n// Root, Trigger, Value, Item, ItemLabel, and ItemIndicator components.\n\n// Re-export VirtualItem type from internal/listbox\nexport type { VirtualItem } from '../internal/listbox/index.js'\n\n// Re-export shared components from internal/popup-menu\nexport {\n PopupMenuArrow as Arrow,\n PopupMenuBackdrop as Backdrop,\n PopupMenuEmpty as Empty,\n // Structure\n PopupMenuGroup as Group,\n PopupMenuGroupLabel as GroupLabel,\n // Trigger components\n PopupMenuIcon as Icon,\n PopupMenuInput as Input,\n PopupMenuList as List,\n // Positioning & Container\n PopupMenuPortal as Portal,\n // Scroll indicators\n PopupMenuScrollDownArrow as ScrollDownArrow,\n PopupMenuScrollUpArrow as ScrollUpArrow,\n PopupMenuSeparator as Separator,\n} from '../internal/popup-menu/index.js'\nexport { SelectItem as Item } from './item/item.js'\nexport { SelectItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { SelectItemLabel as ItemLabel } from './item-label/item-label.js'\n// Select-specific Popup with alignItemWithTriggerActive state\nexport type { SelectPopupProps, SelectPopupState } from './popup/popup.js'\nexport { SelectPopup as Popup } from './popup/popup.js'\n// Custom Select Positioner with alignItemWithTrigger support\nexport { SelectPositioner as Positioner } from './positioner/positioner.js'\n// Select-specific components\nexport { SelectRoot as Root } from './root/root.js'\n// Select-specific Surface with alignItemWithTrigger auto-highlight support\nexport { SelectSurface as Surface } from './surface/surface.js'\nexport { SelectTrigger as Trigger } from './trigger/trigger.js'\nexport { SelectValue as Value } from './value/value.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { usePopupMenuItem } from '../../internal/popup-menu/index.js'\nimport {\n compareItemEquality,\n itemIncludes,\n removeItem,\n} from '../../utils/item-equality.js'\nimport { mergeKeywords, resolveItemFromItems } from '../../utils/items.js'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectItemDataAttributes } from './item.data-attrs.js'\nimport {\n SelectItemContext,\n type SelectItemContextValue,\n} from './item-context.js'\n\nexport { SelectItemDataAttributes }\n\nexport interface SelectItemState extends Record<string, unknown> {\n /**\n * Whether the item is highlighted (via keyboard or pointer).\n */\n highlighted: boolean\n /**\n * Whether the item is disabled.\n */\n disabled: boolean\n /**\n * Whether the item is currently selected.\n */\n selected: boolean\n}\n\nexport interface SelectItemProps<Value = unknown>\n extends ComponentProps<'div', SelectItem.State> {\n /**\n * The value of this item. Required and must be unique within the Select.\n * Can be a primitive or an object.\n *\n * Pass `null` to render a clearable item: selecting it clears the selection\n * and its label is used as the trigger placeholder (Base UI parity).\n */\n value: Value | null\n\n /**\n * Text value to use for display in Select.Value when this item is selected.\n * If not provided, the text content of the item will be used.\n * For object values, this can be auto-detected from `{ label }` shape.\n */\n textValue?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Callback when this item is selected.\n */\n onSelect?: () => void\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n}\n\nconst stateAttributesMapping = {\n highlighted: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.highlighted]: '' } : null,\n disabled: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.disabled]: '' } : null,\n selected: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.selected]: '' } : null,\n}\n\n/**\n * A selectable item in the select dropdown.\n * Renders a `<div>` element with role=\"option\".\n *\n * @template Value - The type of the item value (can be a primitive or object)\n */\nfunction SelectItemImpl<Value = unknown>(\n props: SelectItemProps<Value>,\n forwardedRef: React.ForwardedRef<HTMLDivElement>,\n) {\n const {\n value,\n textValue: textValueProp,\n keywords: keywordsProp,\n disabled = false,\n onSelect,\n forceMount = false,\n render,\n className,\n style,\n onClick,\n onPointerDown,\n onPointerMove,\n children,\n ...rest\n } = props\n\n const selectContext = useSelectContext<Value>()\n\n // Serialize value for registry key and internal lookups\n const serializedValue = React.useMemo(\n () => stringifyAsValue(value, selectContext.itemToStringValue),\n [value, selectContext.itemToStringValue],\n )\n\n // A null value serializes to '' which the listbox treats as \"no id\" and skips\n // registration. Give a clearable (null) item an explicit id so it still\n // registers and is selectable; its label still feeds filtering via keywords.\n const generatedItemId = React.useId()\n const listboxId =\n value === null ? `select-clear-${generatedItemId}` : undefined\n\n // Resolve the item entry (label + keywords) from the items prop, for\n // auto-populating textValue and filter keywords.\n const itemFromItems = React.useMemo(\n () => resolveItemFromItems(selectContext.items, serializedValue),\n [selectContext.items, serializedValue],\n )\n const labelFromItems = itemFromItems?.label\n\n // Auto-resolve label from object value shape { label }\n const labelFromObjectValue = React.useMemo(\n () => resolveLabel(value, selectContext.itemToStringLabel),\n [value, selectContext.itemToStringLabel],\n )\n\n // Auto-populate textValue: explicit prop > label from items (if string) > label from object > undefined\n const textValue = React.useMemo(() => {\n if (textValueProp !== undefined) return textValueProp\n if (typeof labelFromItems === 'string') return labelFromItems\n // For object values, use the resolved label\n if (labelFromObjectValue && labelFromObjectValue !== serializedValue) {\n return labelFromObjectValue\n }\n return undefined\n }, [textValueProp, labelFromItems, labelFromObjectValue, serializedValue])\n\n // Auto-add the label plus any items[].keywords to the filter keywords.\n const keywords = React.useMemo(() => {\n const labelStr =\n typeof labelFromItems === 'string'\n ? labelFromItems\n : labelFromObjectValue && labelFromObjectValue !== serializedValue\n ? labelFromObjectValue\n : undefined\n return mergeKeywords(keywordsProp, [\n labelStr,\n ...(itemFromItems?.keywords ?? []),\n ])\n }, [\n keywordsProp,\n labelFromItems,\n labelFromObjectValue,\n serializedValue,\n itemFromItems,\n ])\n\n const textRef = React.useRef<string | undefined>(textValue)\n\n // Track if this item is selected using custom equality.\n // A `null` item is selected when there is no selection; an empty string is\n // still treated as \"no selection\" and never matches an item.\n const selected = selectContext.multiple\n ? itemIncludes(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : selectContext.value !== '' &&\n compareItemEquality(\n selectContext.value,\n value,\n selectContext.isItemEqualToValue,\n )\n\n // Determine close behavior: single-select closes, multi-select stays open\n const closeOnClick = !selectContext.multiple\n\n const item = usePopupMenuItem({\n id: listboxId,\n value: serializedValue,\n keywords,\n disabled,\n forceMount,\n closeOnClick,\n children,\n })\n\n // Register the select handler that updates the value\n React.useEffect(() => {\n const handleSelect = () => {\n if (disabled) return\n\n if (selectContext.multiple) {\n // A null item clears all selections in multi-select mode.\n if (value == null) {\n selectContext.onValuesChange([])\n } else {\n // Toggle value in array using custom equality\n const newValues = selected\n ? removeItem(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : [...selectContext.values, value]\n selectContext.onValuesChange(newValues)\n }\n } else {\n // Set single value (null clears the selection)\n selectContext.onValueChange(value)\n }\n\n onSelect?.()\n }\n return item.registerSelect(handleSelect)\n }, [disabled, selectContext, value, selected, onSelect, item])\n\n // Register item text for Select.Value display\n React.useEffect(() => {\n // Use textValue if provided, otherwise extract from children\n const text = textRef.current\n if (text) {\n return selectContext.registerItemText(serializedValue, text)\n }\n }, [serializedValue, selectContext])\n\n // Update text ref when children might have changed (for extraction)\n React.useEffect(() => {\n if (!textValue && typeof children === 'string') {\n textRef.current = children\n selectContext.registerItemText(serializedValue, children)\n }\n }, [children, textValue, serializedValue, selectContext])\n\n const state: SelectItem.State = React.useMemo(\n () => ({\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.isHighlighted, disabled, selected],\n )\n\n const itemContextValue: SelectItemContextValue<Value> = React.useMemo(\n () => ({\n id: item.id,\n value,\n textValue,\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.id, value, textValue, item.isHighlighted, disabled, selected],\n )\n\n // Merge user-provided handlers with item handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onClick(event)\n }\n },\n [onClick, item.handlers],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n item.handlers.onPointerDown(event)\n onPointerDown?.(event)\n },\n [item.handlers, onPointerDown],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerMove?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onPointerMove(event)\n }\n },\n [onPointerMove, item.handlers],\n )\n\n const element = useRender({\n render,\n ref: [item.ref, forwardedRef],\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectItemDataAttributes.slot]: '',\n id: item.id,\n role: 'option',\n tabIndex: -1,\n 'aria-selected': selected,\n 'aria-disabled': disabled || undefined,\n className,\n style,\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n children,\n },\n enabled: item.isVisible,\n defaultTagName: 'div',\n })\n\n if (!item.isVisible) {\n return null\n }\n\n return (\n <SelectItemContext.Provider\n value={itemContextValue as SelectItemContextValue}\n >\n {element}\n </SelectItemContext.Provider>\n )\n}\n\nexport const SelectItem = React.forwardRef(SelectItemImpl) as <Value = unknown>(\n props: SelectItemProps<Value> & React.RefAttributes<HTMLDivElement>,\n) => React.ReactElement | null\n\nexport namespace SelectItem {\n export type State = SelectItemState\n export interface Props<Value = unknown> extends SelectItemProps<Value> {}\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ItemEqualityComparer } from '../../utils/item-equality.js'\nimport type { Items } from '../../utils/items.js'\n\n// ============================================================================\n// Select Context\n// ============================================================================\n// Provides value management and form integration for Select components.\n// Separate from PopupMenuContext to handle Select-specific concerns.\n\n/**\n * Item text registry for displaying selected values.\n * Maps serialized item value to its text content.\n */\nexport type ItemTextRegistry = Map<string, string>\n\n/**\n * Context value for Select components.\n * Provides value state, callbacks, and form integration.\n *\n * @template Value - The type of the select value (can be a primitive or object)\n */\nexport interface SelectContextValue<Value = unknown> {\n // ===== Selection State =====\n /** Whether multi-select mode is enabled */\n multiple: boolean\n /** Current selected value (single-select mode) */\n value: Value | null\n /** Current selected values (multi-select mode) */\n values: Value[]\n /** Callback when value changes (single-select mode; `null` clears it) */\n onValueChange: (value: Value | null) => void\n /** Callback when values change (multi-select mode) */\n onValuesChange: (values: Value[]) => void\n\n // ===== Object Value Support =====\n /**\n * Custom comparison logic used to determine if a select item value\n * matches the current selected value.\n * Useful when item values are objects without matching referentially.\n * Defaults to Object.is comparison.\n */\n isItemEqualToValue: ItemEqualityComparer<Value>\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for display in the trigger.\n * If the shape of the object is { value, label }, the label will be\n * used automatically without needing to specify this prop.\n */\n itemToStringLabel?: (itemValue: Value) => string\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for form submission.\n * If the shape of the object is { value, label }, the value will be\n * used automatically without needing to specify this prop.\n */\n itemToStringValue?: (itemValue: Value) => string\n\n // ===== Form Integration =====\n /** Form field name for submission */\n name?: string\n /** Associate with a form by ID */\n form?: string\n /** Whether this field is required */\n required?: boolean\n /** Whether the select is disabled */\n disabled: boolean\n /** Placeholder text when no value selected */\n placeholder: string\n\n // ===== Item Text Registry =====\n /** Registry of item values to their text content */\n itemTextRegistry: ItemTextRegistry\n /** Register an item's text content */\n registerItemText: (value: string, text: string) => () => void\n /**\n * Data structure of the items for label resolution.\n * Used to display labels before items mount (e.g., on initial render with defaultValue).\n * Can be a record mapping values to labels, or an array of\n * `{ value, label, keywords? }` objects.\n */\n items?: Items\n\n // ===== List ID for ARIA =====\n /** ID for the listbox element */\n listId: string\n\n // ===== Element Refs for Positioning =====\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Ref to the value display element (text in trigger) */\n valueRef: React.RefObject<HTMLElement | null>\n /** Ref to the selected item's text element */\n selectedItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Ref to the first item's text element (used when no selection for alignItemWithTrigger) */\n firstItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Callback to set the trigger element */\n setTriggerElement: (element: HTMLElement | null) => void\n /** Callback to set the value element */\n setValueElement: (element: HTMLElement | null) => void\n\n // ===== Positioner Callback Registration =====\n /** Register a callback to reset positioning state after close animation */\n registerResetPositioningCallback: (\n callback: (() => void) | null,\n ) => () => void\n}\n\nconst SelectContext = React.createContext<SelectContextValue<unknown> | null>(\n null,\n)\n\n/**\n * Hook to access the Select context.\n * Throws if used outside a Select.Root.\n */\nexport function useSelectContext<Value = unknown>(): SelectContextValue<Value> {\n const context = React.useContext(SelectContext)\n if (!context) {\n throw new Error('Select components must be used within a Select.Root')\n }\n return context as SelectContextValue<Value>\n}\n\n/**\n * Hook to optionally access the Select context.\n * Returns null if used outside a Select.Root.\n */\nexport function useMaybeSelectContext<\n Value = unknown,\n>(): SelectContextValue<Value> | null {\n return React.useContext(SelectContext) as SelectContextValue<Value> | null\n}\n\nexport { SelectContext }\n","export const SelectItemDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item'}\n */\n slot: 'bazzaui-select-item',\n /**\n * Present when the item is highlighted via keyboard or pointer.\n */\n highlighted: 'data-highlighted',\n /**\n * Present when the item is disabled.\n */\n disabled: 'data-disabled',\n /**\n * Present when the item is currently selected.\n */\n selected: 'data-selected',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Select Item Context\n// ============================================================================\n// Provides select-specific item state to child components.\n\nexport interface SelectItemContextValue<Value = unknown> {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** The value of this item (`null` for a clearable item) */\n value: Value | null\n /** The text value/label for this item */\n textValue: string | undefined\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Whether the item is selected */\n selected: boolean\n}\n\nconst SelectItemContext = React.createContext<SelectItemContextValue | null>(\n null,\n)\n\nexport function useSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> {\n const context = React.useContext(SelectItemContext)\n if (!context) {\n throw new Error(\n 'Select.Item child components must be used within a Select.Item',\n )\n }\n return context as SelectItemContextValue<Value>\n}\n\nexport function useMaybeSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> | null {\n return React.useContext(\n SelectItemContext,\n ) as SelectItemContextValue<Value> | null\n}\n\nexport { SelectItemContext }\n"]}
1
+ {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","../../src/select/index.parts.ts","../../src/select/item/item.tsx","../../src/select/contexts/select-context.ts","../../src/select/item/item.data-attrs.ts","../../src/select/item/item-context.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","PopupMenuInput","SelectItem","SelectItemIndicator","SelectItemLabel","PopupMenuList","SelectPopup","PopupMenuPortal","SelectPositioner","SelectRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","SelectSurface","SelectTrigger","SelectValue","SelectContext","useSelectContext","context","useMaybeSelectContext","SelectItemDataAttributes","SelectItemContext","useSelectItemContext","useMaybeSelectItemContext","stateAttributesMapping","value","SelectItemImpl","props","forwardedRef","textValueProp","keywordsProp","disabled","onSelect","forceMount","render","className","style","onClick","onPointerDown","onPointerMove","children","rest","selectContext","serializedValue","stringifyAsValue","generatedItemId","listboxId"],"mappings":"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","file":"/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","sourcesContent":[null,"// ============================================================================\n// Select Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Select-specific\n// Root, Trigger, Value, Item, ItemLabel, and ItemIndicator components.\n\n// Re-export VirtualItem type from internal/listbox\nexport type { VirtualItem } from '../internal/listbox/index.js'\n\n// Re-export shared components from internal/popup-menu\nexport {\n PopupMenuArrow as Arrow,\n PopupMenuBackdrop as Backdrop,\n PopupMenuEmpty as Empty,\n // Structure\n PopupMenuGroup as Group,\n PopupMenuGroupLabel as GroupLabel,\n // Trigger components\n PopupMenuIcon as Icon,\n PopupMenuInput as Input,\n PopupMenuList as List,\n // Positioning & Container\n PopupMenuPortal as Portal,\n // Scroll indicators\n PopupMenuScrollDownArrow as ScrollDownArrow,\n PopupMenuScrollUpArrow as ScrollUpArrow,\n PopupMenuSeparator as Separator,\n} from '../internal/popup-menu/index.js'\nexport { SelectItem as Item } from './item/item.js'\nexport { SelectItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { SelectItemLabel as ItemLabel } from './item-label/item-label.js'\n// Select-specific Popup with alignItemWithTriggerActive state\nexport type { SelectPopupProps, SelectPopupState } from './popup/popup.js'\nexport { SelectPopup as Popup } from './popup/popup.js'\n// Custom Select Positioner with alignItemWithTrigger support\nexport { SelectPositioner as Positioner } from './positioner/positioner.js'\n// Select-specific components\nexport { SelectRoot as Root } from './root/root.js'\n// Select-specific Surface with alignItemWithTrigger auto-highlight support\nexport { SelectSurface as Surface } from './surface/surface.js'\nexport { SelectTrigger as Trigger } from './trigger/trigger.js'\nexport { SelectValue as Value } from './value/value.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { usePopupMenuItem } from '../../internal/popup-menu/index.js'\nimport {\n compareItemEquality,\n itemIncludes,\n removeItem,\n} from '../../utils/item-equality.js'\nimport { mergeKeywords, resolveItemFromItems } from '../../utils/items.js'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectItemDataAttributes } from './item.data-attrs.js'\nimport {\n SelectItemContext,\n type SelectItemContextValue,\n} from './item-context.js'\n\nexport { SelectItemDataAttributes }\n\nexport interface SelectItemState extends Record<string, unknown> {\n /**\n * Whether the item is highlighted (via keyboard or pointer).\n */\n highlighted: boolean\n /**\n * Whether the item is disabled.\n */\n disabled: boolean\n /**\n * Whether the item is currently selected.\n */\n selected: boolean\n}\n\nexport interface SelectItemProps<Value = unknown>\n extends ComponentProps<'div', SelectItem.State> {\n /**\n * The value of this item. Required and must be unique within the Select.\n * Can be a primitive or an object.\n *\n * Pass `null` to render a clearable item: selecting it clears the selection\n * and its label is used as the trigger placeholder (Base UI parity).\n */\n value: Value | null\n\n /**\n * Text value to use for display in Select.Value when this item is selected.\n * If not provided, the text content of the item will be used.\n * For object values, this can be auto-detected from `{ label }` shape.\n */\n textValue?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Callback when this item is selected.\n */\n onSelect?: () => void\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n}\n\nconst stateAttributesMapping = {\n highlighted: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.highlighted]: '' } : null,\n disabled: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.disabled]: '' } : null,\n selected: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.selected]: '' } : null,\n}\n\n/**\n * A selectable item in the select dropdown.\n * Renders a `<div>` element with role=\"option\".\n *\n * @template Value - The type of the item value (can be a primitive or object)\n */\nfunction SelectItemImpl<Value = unknown>(\n props: SelectItemProps<Value>,\n forwardedRef: React.ForwardedRef<HTMLDivElement>,\n) {\n const {\n value,\n textValue: textValueProp,\n keywords: keywordsProp,\n disabled = false,\n onSelect,\n forceMount = false,\n render,\n className,\n style,\n onClick,\n onPointerDown,\n onPointerMove,\n children,\n ...rest\n } = props\n\n const selectContext = useSelectContext<Value>()\n\n // Serialize value for registry key and internal lookups\n const serializedValue = React.useMemo(\n () => stringifyAsValue(value, selectContext.itemToStringValue),\n [value, selectContext.itemToStringValue],\n )\n\n // A null value serializes to '' which the listbox treats as \"no id\" and skips\n // registration. Give a clearable (null) item an explicit id so it still\n // registers and is selectable; its label still feeds filtering via keywords.\n const generatedItemId = React.useId()\n const listboxId =\n value === null ? `select-clear-${generatedItemId}` : undefined\n\n // Resolve the item entry (label + keywords) from the items prop, for\n // auto-populating textValue and filter keywords.\n const itemFromItems = React.useMemo(\n () => resolveItemFromItems(selectContext.items, serializedValue),\n [selectContext.items, serializedValue],\n )\n const labelFromItems = itemFromItems?.label\n\n // Auto-resolve label from object value shape { label }\n const labelFromObjectValue = React.useMemo(\n () => resolveLabel(value, selectContext.itemToStringLabel),\n [value, selectContext.itemToStringLabel],\n )\n\n // Auto-populate textValue: explicit prop > label from items (if string) > label from object > undefined\n const textValue = React.useMemo(() => {\n if (textValueProp !== undefined) return textValueProp\n if (typeof labelFromItems === 'string') return labelFromItems\n // For object values, use the resolved label\n if (labelFromObjectValue && labelFromObjectValue !== serializedValue) {\n return labelFromObjectValue\n }\n return undefined\n }, [textValueProp, labelFromItems, labelFromObjectValue, serializedValue])\n\n // Auto-add the label plus any items[].keywords to the filter keywords.\n const keywords = React.useMemo(() => {\n const labelStr =\n typeof labelFromItems === 'string'\n ? labelFromItems\n : labelFromObjectValue && labelFromObjectValue !== serializedValue\n ? labelFromObjectValue\n : undefined\n return mergeKeywords(keywordsProp, [\n labelStr,\n ...(itemFromItems?.keywords ?? []),\n ])\n }, [\n keywordsProp,\n labelFromItems,\n labelFromObjectValue,\n serializedValue,\n itemFromItems,\n ])\n\n const textRef = React.useRef<string | undefined>(textValue)\n\n // Track if this item is selected using custom equality.\n // A `null` item is selected when there is no selection; an empty string is\n // still treated as \"no selection\" and never matches an item.\n const selected = selectContext.multiple\n ? itemIncludes(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : selectContext.value !== '' &&\n compareItemEquality(\n selectContext.value,\n value,\n selectContext.isItemEqualToValue,\n )\n\n // Determine close behavior: single-select closes, multi-select stays open\n const closeOnClick = !selectContext.multiple\n\n const item = usePopupMenuItem({\n id: listboxId,\n value: serializedValue,\n keywords,\n disabled,\n forceMount,\n closeOnClick,\n children,\n })\n\n // Register the select handler that updates the value\n React.useEffect(() => {\n const handleSelect = () => {\n if (disabled) return\n\n if (selectContext.multiple) {\n // A null item clears all selections in multi-select mode.\n if (value == null) {\n selectContext.onValuesChange([])\n } else {\n // Toggle value in array using custom equality\n const newValues = selected\n ? removeItem(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : [...selectContext.values, value]\n selectContext.onValuesChange(newValues)\n }\n } else {\n // Set single value (null clears the selection)\n selectContext.onValueChange(value)\n }\n\n onSelect?.()\n }\n return item.registerSelect(handleSelect)\n }, [disabled, selectContext, value, selected, onSelect, item])\n\n // Register item text for Select.Value display\n React.useEffect(() => {\n // Use textValue if provided, otherwise extract from children\n const text = textRef.current\n if (text) {\n return selectContext.registerItemText(serializedValue, text)\n }\n }, [serializedValue, selectContext])\n\n // Update text ref when children might have changed (for extraction)\n React.useEffect(() => {\n if (!textValue && typeof children === 'string') {\n textRef.current = children\n selectContext.registerItemText(serializedValue, children)\n }\n }, [children, textValue, serializedValue, selectContext])\n\n const state: SelectItem.State = React.useMemo(\n () => ({\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.isHighlighted, disabled, selected],\n )\n\n const itemContextValue: SelectItemContextValue<Value> = React.useMemo(\n () => ({\n id: item.id,\n value,\n textValue,\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.id, value, textValue, item.isHighlighted, disabled, selected],\n )\n\n // Merge user-provided handlers with item handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onClick(event)\n }\n },\n [onClick, item.handlers],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n item.handlers.onPointerDown(event)\n onPointerDown?.(event)\n },\n [item.handlers, onPointerDown],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerMove?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onPointerMove(event)\n }\n },\n [onPointerMove, item.handlers],\n )\n\n const element = useRender({\n render,\n ref: [item.ref, forwardedRef],\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectItemDataAttributes.slot]: '',\n id: item.id,\n role: 'option',\n tabIndex: -1,\n 'aria-selected': selected,\n 'aria-disabled': disabled || undefined,\n className,\n style,\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n children,\n },\n enabled: item.isVisible,\n defaultTagName: 'div',\n })\n\n if (!item.isVisible) {\n return null\n }\n\n return (\n <SelectItemContext.Provider\n value={itemContextValue as SelectItemContextValue}\n >\n {element}\n </SelectItemContext.Provider>\n )\n}\n\nexport const SelectItem = React.forwardRef(SelectItemImpl) as <Value = unknown>(\n props: SelectItemProps<Value> & React.RefAttributes<HTMLDivElement>,\n) => React.ReactElement | null\n\nexport namespace SelectItem {\n export type State = SelectItemState\n export interface Props<Value = unknown> extends SelectItemProps<Value> {}\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ItemEqualityComparer } from '../../utils/item-equality.js'\nimport type { Items } from '../../utils/items.js'\n\n// ============================================================================\n// Select Context\n// ============================================================================\n// Provides value management and form integration for Select components.\n// Separate from PopupMenuContext to handle Select-specific concerns.\n\n/**\n * Item text registry for displaying selected values.\n * Maps serialized item value to its text content.\n */\nexport type ItemTextRegistry = Map<string, string>\n\n/**\n * Context value for Select components.\n * Provides value state, callbacks, and form integration.\n *\n * @template Value - The type of the select value (can be a primitive or object)\n */\nexport interface SelectContextValue<Value = unknown> {\n // ===== Selection State =====\n /** Whether multi-select mode is enabled */\n multiple: boolean\n /** Current selected value (single-select mode) */\n value: Value | null\n /** Current selected values (multi-select mode) */\n values: Value[]\n /** Callback when value changes (single-select mode; `null` clears it) */\n onValueChange: (value: Value | null) => void\n /** Callback when values change (multi-select mode) */\n onValuesChange: (values: Value[]) => void\n\n // ===== Object Value Support =====\n /**\n * Custom comparison logic used to determine if a select item value\n * matches the current selected value.\n * Useful when item values are objects without matching referentially.\n * Defaults to Object.is comparison.\n */\n isItemEqualToValue: ItemEqualityComparer<Value>\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for display in the trigger.\n * If the shape of the object is { value, label }, the label will be\n * used automatically without needing to specify this prop.\n */\n itemToStringLabel?: (itemValue: Value) => string\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for form submission.\n * If the shape of the object is { value, label }, the value will be\n * used automatically without needing to specify this prop.\n */\n itemToStringValue?: (itemValue: Value) => string\n\n // ===== Form Integration =====\n /** Form field name for submission */\n name?: string\n /** Associate with a form by ID */\n form?: string\n /** Whether this field is required */\n required?: boolean\n /** Whether the select is disabled */\n disabled: boolean\n /** Placeholder text when no value selected */\n placeholder: string\n\n // ===== Item Text Registry =====\n /** Registry of item values to their text content */\n itemTextRegistry: ItemTextRegistry\n /** Register an item's text content */\n registerItemText: (value: string, text: string) => () => void\n /**\n * Data structure of the items for label resolution.\n * Used to display labels before items mount (e.g., on initial render with defaultValue).\n * Can be a record mapping values to labels, or an array of\n * `{ value, label, keywords? }` objects.\n */\n items?: Items\n\n // ===== List ID for ARIA =====\n /** ID for the listbox element */\n listId: string\n\n // ===== Element Refs for Positioning =====\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Ref to the value display element (text in trigger) */\n valueRef: React.RefObject<HTMLElement | null>\n /** Ref to the selected item's text element */\n selectedItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Ref to the first item's text element (used when no selection for alignItemWithTrigger) */\n firstItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Callback to set the trigger element */\n setTriggerElement: (element: HTMLElement | null) => void\n /** Callback to set the value element */\n setValueElement: (element: HTMLElement | null) => void\n\n // ===== Positioner Callback Registration =====\n /** Register a callback to reset positioning state after close animation */\n registerResetPositioningCallback: (\n callback: (() => void) | null,\n ) => () => void\n}\n\nconst SelectContext = React.createContext<SelectContextValue<unknown> | null>(\n null,\n)\n\n/**\n * Hook to access the Select context.\n * Throws if used outside a Select.Root.\n */\nexport function useSelectContext<Value = unknown>(): SelectContextValue<Value> {\n const context = React.useContext(SelectContext)\n if (!context) {\n throw new Error('Select components must be used within a Select.Root')\n }\n return context as SelectContextValue<Value>\n}\n\n/**\n * Hook to optionally access the Select context.\n * Returns null if used outside a Select.Root.\n */\nexport function useMaybeSelectContext<\n Value = unknown,\n>(): SelectContextValue<Value> | null {\n return React.useContext(SelectContext) as SelectContextValue<Value> | null\n}\n\nexport { SelectContext }\n","export const SelectItemDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item'}\n */\n slot: 'bazzaui-select-item',\n /**\n * Present when the item is highlighted via keyboard or pointer.\n */\n highlighted: 'data-highlighted',\n /**\n * Present when the item is disabled.\n */\n disabled: 'data-disabled',\n /**\n * Present when the item is currently selected.\n */\n selected: 'data-selected',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Select Item Context\n// ============================================================================\n// Provides select-specific item state to child components.\n\nexport interface SelectItemContextValue<Value = unknown> {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** The value of this item (`null` for a clearable item) */\n value: Value | null\n /** The text value/label for this item */\n textValue: string | undefined\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Whether the item is selected */\n selected: boolean\n}\n\nconst SelectItemContext = React.createContext<SelectItemContextValue | null>(\n null,\n)\n\nexport function useSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> {\n const context = React.useContext(SelectItemContext)\n if (!context) {\n throw new Error(\n 'Select.Item child components must be used within a Select.Item',\n )\n }\n return context as SelectItemContextValue<Value>\n}\n\nexport function useMaybeSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> | null {\n return React.useContext(\n SelectItemContext,\n ) as SelectItemContextValue<Value> | null\n}\n\nexport { SelectItemContext }\n"]}
@@ -440,6 +440,13 @@ interface SelectRootProps<Value = unknown, Multiple extends boolean | undefined
440
440
  * @default true
441
441
  */
442
442
  modal?: boolean | 'trap-focus';
443
+ /**
444
+ * When to close the select on outside interactions.
445
+ * - 'pointerdown': Close immediately when pointer is pressed outside (default)
446
+ * - 'click': Close when a full click (pointerdown + pointerup) occurs outside
447
+ * @default 'pointerdown'
448
+ */
449
+ closeOnOutsidePress?: 'click' | 'pointerdown';
443
450
  /**
444
451
  * Whether virtualization mode is enabled.
445
452
  * When true, items should provide an explicit `index` prop and
@@ -440,6 +440,13 @@ interface SelectRootProps<Value = unknown, Multiple extends boolean | undefined
440
440
  * @default true
441
441
  */
442
442
  modal?: boolean | 'trap-focus';
443
+ /**
444
+ * When to close the select on outside interactions.
445
+ * - 'pointerdown': Close immediately when pointer is pressed outside (default)
446
+ * - 'click': Close when a full click (pointerdown + pointerup) occurs outside
447
+ * @default 'pointerdown'
448
+ */
449
+ closeOnOutsidePress?: 'click' | 'pointerdown';
443
450
  /**
444
451
  * Whether virtualization mode is enabled.
445
452
  * When true, items should provide an explicit `index` prop and
@@ -1,2 +1,2 @@
1
- import{a as ht,b as xt,c as bt,d as Pt,e as Rt,f as Pe,g as It}from"../chunk-KO3DXT3Y.js";import{Ab as St,L as et,La as nt,Ma as rt,N as tt,Na as to,P as ot,Qa as lt,Ra as at,Ua as ge,Va as Se,Wa as F,Xa as it,Ya as st,Za as ut,_a as oo,ab as ct,eb as pt,fb as mt,gb as dt,l as ye,yb as ft,zb as gt}from"../chunk-2D2HREBK.js";import{a as Qe,p as Kt,q as Jt,w as Zt,x as Qt,y as eo}from"../chunk-ZPRKUVIC.js";import{a as $t}from"../chunk-4C666HHU.js";var Dt={};$t(Dt,{Arrow:()=>tt,Backdrop:()=>ot,Empty:()=>st,Group:()=>ft,GroupLabel:()=>gt,Icon:()=>it,Input:()=>ut,Item:()=>De,ItemIndicator:()=>Oe,ItemLabel:()=>Ne,List:()=>ct,Popup:()=>Fe,Portal:()=>rt,Positioner:()=>_e,Root:()=>qe,ScrollDownArrow:()=>mt,ScrollUpArrow:()=>pt,Separator:()=>St,Surface:()=>Ue,Trigger:()=>Ye,Value:()=>Xe});import{useRender as lo}from"@base-ui/react/use-render";import*as y from"react";import*as Re from"react";var Ee=Re.createContext(null);function D(){let n=Re.useContext(Ee);if(!n)throw new Error("Select components must be used within a Select.Root");return n}function no(){return Re.useContext(Ee)}var he={slot:"bazzaui-select-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected"};import*as Ie from"react";var we=Ie.createContext(null);function Ce(){let n=Ie.useContext(we);if(!n)throw new Error("Select.Item child components must be used within a Select.Item");return n}function ro(){return Ie.useContext(we)}import{jsx as so}from"react/jsx-runtime";var ao={highlighted:n=>n?{[he.highlighted]:""}:null,disabled:n=>n?{[he.disabled]:""}:null,selected:n=>n?{[he.selected]:""}:null};function io(n,t){let{value:o,textValue:l,keywords:i,disabled:r=!1,onSelect:u,forceMount:h=!1,render:e,className:a,style:I,onClick:d,onPointerDown:p,onPointerMove:P,children:f,...s}=n,c=D(),g=y.useMemo(()=>F(o,c.itemToStringValue),[o,c.itemToStringValue]),T=y.useId(),L=o===null?`select-clear-${T}`:void 0,S=y.useMemo(()=>Rt(c.items,g),[c.items,g]),M=S?.label,w=y.useMemo(()=>Se(o,c.itemToStringLabel),[o,c.itemToStringLabel]),v=y.useMemo(()=>{if(l!==void 0)return l;if(typeof M=="string")return M;if(w&&w!==g)return w},[l,M,w,g]),Z=y.useMemo(()=>It(i,[typeof M=="string"?M:w&&w!==g?w:void 0,...S?.keywords??[]]),[i,M,w,g,S]),k=y.useRef(v),O=c.multiple?bt(c.values,o,c.isItemEqualToValue):c.value!==""&&xt(c.value,o,c.isItemEqualToValue),le=!c.multiple,x=at({id:L,value:g,keywords:Z,disabled:r,forceMount:h,closeOnClick:le,children:f});y.useEffect(()=>{let V=()=>{if(!r){if(c.multiple)if(o==null)c.onValuesChange([]);else{let J=O?Pt(c.values,o,c.isItemEqualToValue):[...c.values,o];c.onValuesChange(J)}else c.onValueChange(o);u?.()}};return x.registerSelect(V)},[r,c,o,O,u,x]),y.useEffect(()=>{let V=k.current;if(V)return c.registerItemText(g,V)},[g,c]),y.useEffect(()=>{!v&&typeof f=="string"&&(k.current=f,c.registerItemText(g,f))},[f,v,g,c]);let G=y.useMemo(()=>({highlighted:x.isHighlighted,disabled:r,selected:O}),[x.isHighlighted,r,O]),_=y.useMemo(()=>({id:x.id,value:o,textValue:v,highlighted:x.isHighlighted,disabled:r,selected:O}),[x.id,o,v,x.isHighlighted,r,O]),j=y.useCallback(V=>{d?.(V),V.defaultPrevented||x.handlers.onClick(V)},[d,x.handlers]),K=y.useCallback(V=>{x.handlers.onPointerDown(V),p?.(V)},[x.handlers,p]),q=y.useCallback(V=>{P?.(V),V.defaultPrevented||x.handlers.onPointerMove(V)},[P,x.handlers]),B=lo({render:e,ref:[x.ref,t],state:G,stateAttributesMapping:ao,props:{...s,[he.slot]:"",id:x.id,role:"option",tabIndex:-1,"aria-selected":O,"aria-disabled":r||void 0,className:a,style:I,onClick:j,onPointerMove:q,onPointerDown:K,children:f},enabled:x.isVisible,defaultTagName:"div"});return x.isVisible?so(we.Provider,{value:_,children:B}):null}var De=y.forwardRef(io);import{useRender as uo}from"@base-ui/react/use-render";import*as He from"react";var Ve={slot:"bazzaui-select-item-indicator",selected:"data-selected",highlighted:"data-highlighted"};var co={selected:n=>n?{[Ve.selected]:""}:null,highlighted:n=>n?{[Ve.highlighted]:""}:null},Oe=He.forwardRef(function(t,o){let{render:l,className:i,style:r,forceMount:u=!1,keepMounted:h=!1,children:e,...a}=t,I=Ce(),d=I.selected,p=I.highlighted,P=He.useMemo(()=>({selected:d,highlighted:p}),[d,p]),f=u||h||d,s=typeof e=="function"?e(P):h&&!d?null:e,c=uo({render:l,ref:o,state:P,stateAttributesMapping:co,props:{...a,[Ve.slot]:"","aria-hidden":!0,className:i,style:r,children:s},defaultTagName:"span"});return f?c:null});import{useRender as po}from"@base-ui/react/use-render";import*as W from"react";var Ct={slot:"bazzaui-select-item-label"};var Ne=W.forwardRef(function(t,o){let{render:l,className:i,style:r,children:u,...h}=t,e=D(),a=Ce(),I=W.useRef(null),d=F(a.value,e.itemToStringValue),p=W.useMemo(()=>{if(u!==void 0)return u;let s=Pe(e.items,d);return s!==void 0?s:a.textValue!==void 0?a.textValue:d},[u,e.items,d,a.textValue]),P=W.useMemo(()=>({value:d,selected:a.selected,highlighted:a.highlighted,disabled:a.disabled}),[d,a.selected,a.highlighted,a.disabled]);W.useEffect(()=>{if(typeof p=="string")return e.registerItemText(d,p)},[p,e,d]);let f=W.useCallback(s=>{I.current=s,a.selected&&s&&(e.selectedItemTextRef.current=s),s&&!a.disabled&&(e.firstItemTextRef.current||(e.firstItemTextRef.current=s))},[a.selected,a.disabled,e]);return po({render:l,ref:o,state:P,props:{...h,[Ct.slot]:"",ref:f,className:i,style:r,children:p},defaultTagName:"span"})});import"@base-ui/react/popover";import*as ue from"react";import*as Le from"react";var ze=Le.createContext(null);function Te(){return Le.useContext(ze)}import{jsx as mo}from"react/jsx-runtime";var Fe=ue.forwardRef(function(t,o){let{className:l,render:i,...r}=t,u=Te(),h=u?.alignItemWithTriggerActive??!1,e=u?.align,a=ue.useCallback(p=>({...p,side:h?"none":p.side,alignItemWithTriggerActive:h}),[h]),I=ue.useMemo(()=>typeof l=="function"?p=>l(a(p)):l,[l,a]),d=ue.useMemo(()=>typeof i=="function"?(p,P)=>i(p,a(P)):i,[i,a]);return mo(nt,{ref:o,className:I,render:d,"data-align-item-with-trigger":h?"":void 0,...h?{"data-side":"none","data-align":e}:{},...r})});import{useDirection as fo}from"@base-ui/react/internals/direction-context";import{Popover as go}from"@base-ui/react/popover";import*as R from"react";function ce(n,t,o){return n<t?t:n>o?o:n}function Ge(n){let t=n.getBoundingClientRect(),{offsetWidth:o,offsetHeight:l}=n,i=o>0?Math.round(t.width)/o:1,r=l>0?Math.round(t.height)/l:1;return(!Number.isFinite(i)||i===0)&&(i=1),(!Number.isFinite(r)||r===0)&&(r=1),{x:i,y:r}}function Vt(n,t,o){return n/o[t]}function Me(n,t){let o=n.x/t.x,l=n.y/t.y,i=n.width/t.x,r=n.height/t.y;return{x:o,y:l,width:i,height:r,top:l,left:o,right:o+i,bottom:l+r}}var $=1;function xe(n,t){return Math.max(0,n-t)}var Tt=5,Mt=20,je=10,vt=100;function yt(n){let{triggerRect:t,positionerRect:o,valueRect:l,textRect:i,scrollHeight:r,documentClientHeight:u,documentClientWidth:h,marginTop:e,marginBottom:a,minHeight:I,maxPopupHeight:d,borderBottom:p,direction:P}=n,f=()=>({fallback:!0,left:0,isTopPositioned:!1,top:0,height:0,scrollTop:0,marginTop:e,marginBottom:a,reachedMaxHeight:!1,transformOrigin:null}),s=u-e-a,c=h,g=t.height,T=s-t.bottom+g,L=P==="rtl"?t.right-o.width:t.left,S=0,M=null;if(i&&l){L=o.left+(P==="rtl"?l.right-i.right:l.left-i.left);let U=l.top-t.top+l.height/2;S=i.top-o.top+i.height/2-U,M=i.top+i.height/2}let w=T+S+a+p,v=Math.min(s,w),Z=s-e-a,k=w-v,O=c-Tt,le=ce(L,Tt,O-o.width),x=xe(r,v),G=k>=x-$;if(G&&(v=Math.min(s,o.height)-(k-x)),t.top<Mt||t.bottom>s-Mt||Math.ceil(v)+$<Math.min(r,I))return f();let j=Math.max(I,v),K=a+p-e,q=0,B=k;if(G){let U=Math.max(0,s-w);q=o.height>=Z?0:Math.max(0,U+K),B=x}else B=Math.max(0,k-K);let V=null;if(M!=null){let U=o.top,A=o.height,m=A>0?(M-U)/A*100:50;V=`50% ${ce(m,0,100)}%`}let J=j===s||v>=d;return{fallback:!1,left:le,isTopPositioned:G,top:q,height:v,scrollTop:B,marginTop:e,marginBottom:a,reachedMaxHeight:J,transformOrigin:V}}function Et(n){let{isTopPositioned:t,currentHeight:o,scrollTop:l,maxScrollTop:i,maxAvailableHeight:r}=n,u=t?i-l:l;if(u<=$){let d=ce(u,0,r-o),p=o+d;return{height:d>0?p:null,scroll:{kind:"set",value:t?i:0},reachedMaxHeight:r-p<=$}}let h=Math.min(o+u,r),e={kind:"none"},a=!1;if(r-h>$)e=t?{kind:"max"}:{kind:"clamp",value:0};else if(a=!0,!t&&l<i){let d=o+u-r;e={kind:"clamp",value:l-(u-d)}}let I=Math.ceil(h);return{height:I,scroll:e,reachedMaxHeight:a||I>=r-$}}var Be={slot:"bazzaui-select-positioner"};import{jsx as Lt}from"react/jsx-runtime";var _e=R.forwardRef(function(t,o){let{alignItemWithTrigger:l=!0,side:i="bottom",align:r="start",sideOffset:u=0,className:h,style:e,children:a,...I}=t,d=ye(),p=D(),P=fo()==="rtl"?"rtl":"ltr",f=d.store,s=f.useState("open"),c=f.useState("openMethod"),g=f.useState("hasInput"),[T,L]=R.useState(l),S=T&&c!=="touch"&&!g,[M,w]=R.useState(!1),[v,Z]=R.useState(null),k=R.useRef(null),O=R.useRef(null),le=R.useRef(null),x=R.useRef(!1),G=R.useRef(!1),_=R.useCallback(()=>{let m=k.current,C=f.context.refs.popupRef.current;m&&(m.style.height=""),C&&(C.style.height="",C.style.removeProperty("--transform-origin")),x.current=!1,G.current=!1},[f]),j=R.useCallback(()=>{_(),L(l),w(!1),Z(null)},[l,_]);R.useEffect(()=>p.registerResetPositioningCallback(j),[p,j]);let K=R.useCallback(()=>{if(f.state.hasInput)return;let m=k.current,C=p.triggerRef.current,N=f.context.refs.popupRef.current,Y=f.context.refs.listRef.current;if(!m||!C||!N||!Y)return;let Q=p.selectedItemTextRef.current;if(!Q?.isConnected){let z=p.firstItemTextRef.current;Q=z?.isConnected?z:null}let ee=p.valueRef.current,ae=ho(N),H;try{let z=We(m),ie=m.ownerDocument,te=Ge(C),se=z.getComputedStyle(m),X=z.getComputedStyle(N);H=yt({triggerRect:Me(C.getBoundingClientRect(),te),positionerRect:Me(m.getBoundingClientRect(),te),valueRect:ee?Me(ee.getBoundingClientRect(),te):null,textRect:Q?Me(Q.getBoundingClientRect(),te):null,scrollHeight:Y.scrollHeight,documentClientHeight:ie.documentElement.clientHeight,documentClientWidth:ie.documentElement.clientWidth,marginTop:Number.parseFloat(se.marginTop)||je,marginBottom:Number.parseFloat(se.marginBottom)||je,minHeight:Number.parseFloat(se.minHeight)||vt,maxPopupHeight:wt(X),borderBottom:Number.parseFloat(X.borderBottomWidth)||0,direction:P});let me=(z.visualViewport?.scale??1)!==1&&So(z);if(H.fallback||me){L(!1),w(!0);return}m.style.height=`${H.height}px`,N.style.height="100%",H.transformOrigin&&N.style.setProperty("--transform-origin",H.transformOrigin),Y.scrollTop=H.scrollTop,x.current=H.reachedMaxHeight,G.current=!0}finally{ae()}Z({left:H.left,top:H.isTopPositioned?H.top:null,bottom:H.isTopPositioned?null:0,marginTop:H.marginTop,marginBottom:H.marginBottom}),w(!0)},[f,p,P]);R.useEffect(()=>{!s||!S||M||K()},[s,S,M,K]),R.useEffect(()=>{s&&!S&&_()},[s,S,_]),R.useEffect(()=>{if(!s||!S)return;let m=k.current,C=m?We(m):window,N=Y=>{f.setOpen(!1,Qe.none,Y)};return C.addEventListener("resize",N),()=>{C.removeEventListener("resize",N)}},[s,S,f]);let q=R.useCallback(m=>{let C=k.current,N=f.context.refs.popupRef.current;if(!C||!N||!G.current||x.current||!S)return;let Y=C.style.top==="0px",Q=C.style.bottom==="0px";if(!Y&&!Q)return;let ee=We(C),ae=C.ownerDocument,H=Ge(C),z=Vt(C.getBoundingClientRect().height,"y",H),ie=ee.getComputedStyle(C),te=Number.parseFloat(ie.marginTop)||0,se=Number.parseFloat(ie.marginBottom)||0,X=wt(ee.getComputedStyle(N)),me=Math.min(ae.documentElement.clientHeight-te-se,X),oe=Et({isTopPositioned:Y,currentHeight:z,scrollTop:m.scrollTop,maxScrollTop:xe(m.scrollHeight,m.clientHeight),maxAvailableHeight:me});switch(oe.height!=null&&(C.style.height=`${oe.height}px`),oe.scroll.kind){case"set":m.scrollTop=oe.scroll.value;break;case"max":{let de=xe(m.scrollHeight,m.clientHeight);Math.abs(m.scrollTop-de)>$&&(m.scrollTop=de);break}case"clamp":{let de=xe(m.scrollHeight,m.clientHeight),ne=ce(oe.scroll.value,0,de);Math.abs(m.scrollTop-ne)>$&&(m.scrollTop=ne);break}default:break}oe.reachedMaxHeight&&(x.current=!0)},[f,S]);R.useEffect(()=>{if(!s||!S||!M)return;let m=f.context.refs.listRef.current;if(!m)return;let C=()=>q(m);return m.addEventListener("scroll",C,{passive:!0}),()=>{m.removeEventListener("scroll",C)}},[s,S,M,q,f]);let B=S?"none":i,V=R.useMemo(()=>({alignItemWithTriggerActive:S,side:B,align:r,scrollUpArrowRef:O,scrollDownArrowRef:le,setAlignItemWithTriggerActive:L,resetPositioningState:j}),[S,B,r,j]),J=R.useCallback(m=>{k.current=m,typeof o=="function"?o(m):o&&(o.current=m)},[o]),U=s&&S&&!M,A=S&&v?{position:"fixed",transform:"none",left:v.left,top:v.top??"auto",bottom:v.bottom??"auto",marginTop:v.marginTop,marginBottom:v.marginBottom,maxHeight:"none"}:{};return Lt(ze.Provider,{value:V,children:Lt(go.Positioner,{ref:J,side:S?void 0:i,align:S?void 0:r,sideOffset:S?0:u,disableAnchorTracking:S||void 0,className:h,style:{...e,...A,...U?{visibility:"hidden"}:{}},...S?{"data-side":"none","data-align":r}:{},[Be.slot]:"",...I,children:a})})});function We(n){return n.ownerDocument?.defaultView??window}function wt(n){let t=n.maxHeight||"";return t.endsWith("px")&&Number.parseFloat(t)||Number.POSITIVE_INFINITY}function So(n){let t=n.navigator;return t?/AppleWebKit/.test(t.userAgent)&&!/Chrome|Chromium|Edg|OPR/.test(t.userAgent):!1}var Ht=[["transform","none"],["scale","1"],["translate","0 0"]];function ho(n){let{style:t}=n,o={};for(let[l,i]of Ht)o[l]=t.getPropertyValue(l),t.setProperty(l,i,"important");return()=>{for(let[l]of Ht){let i=o[l];i?t.setProperty(l,i):t.removeProperty(l)}}}import{Popover as xo}from"@base-ui/react/popover";import*as b from"react";import{jsx as ve,jsxs as bo}from"react/jsx-runtime";function qe(n){let{open:t,onOpenChange:o,onOpenChangeComplete:l,actionsRef:i,defaultOpen:r=!1,value:u,defaultValue:h,onValueChange:e,multiple:a=!1,values:I,defaultValues:d,onValuesChange:p,isItemEqualToValue:P=ht,itemToStringLabel:f,itemToStringValue:s,name:c,form:g,required:T,disabled:L=!1,placeholder:S="Select...",items:M,modal:w=!0,virtualized:v=!1,virtualItems:Z,onHighlightChange:k,debug:O,children:le,...x}=n,G=b.useId(),_=b.useRef(null),j=b.useRef(null),K=b.useRef(null),q=b.useRef(null),B=b.useCallback(E=>{_.current=E},[]),V=b.useCallback(E=>{j.current=E},[]),J=b.useRef(null),U=b.useCallback(E=>(J.current=E,()=>{J.current=null}),[]),{store:A,focusOwnerStore:m,openChainStore:C,registerSurface:N,closeAll:Y,virtualization:Q,handleOpenChange:ee,disabled:ae,setDisabled:H}=et({onOpenChange:o,defaultOpen:r,virtualized:v,items:Z,onHighlightChange:k,disabled:L}),z=b.useRef(null);b.useImperativeHandle(i,()=>({close:()=>{z.current?.close()},unmount:()=>{z.current?.unmount()},setDisabled:H}),[H]),A.useControlledProp("openProp",t);let ie=A.useState("open"),[te,se]=b.useState(h!==void 0?h:null),X=u!==void 0?u:te,me=b.useCallback(E=>{u===void 0&&se(E),e?.(E)},[u,e]),[oe,de]=b.useState(d??[]),ne=I!==void 0?I:oe,$e=b.useCallback(E=>{I===void 0&&de(E),p?.(E)},[I,p]),Ke=b.useRef(new Map),Je=b.useCallback((E,fe)=>(Ke.current.set(E,fe),()=>{}),[]),qt=b.useMemo(()=>({multiple:a,value:X,values:ne,onValueChange:me,onValuesChange:$e,isItemEqualToValue:P,itemToStringLabel:f,itemToStringValue:s,name:c,form:g,required:T,disabled:ae,placeholder:S,items:M,itemTextRegistry:Ke.current,registerItemText:Je,listId:G,triggerRef:_,valueRef:j,selectedItemTextRef:K,firstItemTextRef:q,setTriggerElement:B,setValueElement:V,registerResetPositioningCallback:U}),[a,X,ne,me,$e,P,f,s,c,g,T,ae,S,M,Je,G,B,V,U]),Ut=b.useMemo(()=>c?a?ne.length>0?ne.map((E,fe)=>{let Ze=F(E,s);return ve("input",{type:"hidden",name:c,value:Ze,form:g,required:T&&fe===0},Ze)}):ve("input",{type:"hidden",name:c,value:"",form:g,required:T}):ve("input",{type:"hidden",name:c,value:X!=null?F(X,s):"",form:g,required:T}):null,[c,g,T,a,X,ne,s]),Yt=b.useCallback((E,fe)=>{ee(E,fe.reason,fe.event)},[ee]),Xt=b.useCallback(E=>{!E&&A.context.clearSearchOnClose==="after-exit"&&(A.clearSearch(),A.setInputActive(!1)),E||(A.clearHighlight(),J.current?.(),q.current=null),l?.(E)},[A,l]);return ve(Ee.Provider,{value:qt,children:bo(lt,{store:A,focusOwnerStore:m,openChainStore:C,disabled:ae,depth:0,closeAll:Y,registerSurface:N,virtualization:Q,menuType:"dropdown",componentName:"select",debug:O,children:[Ut,ve(xo.Root,{...x,open:ie,onOpenChange:Yt,onOpenChangeComplete:Xt,modal:w,actionsRef:i?z:void 0,children:le})]})})}import*as ke from"react";var kt={slot:"bazzaui-select-surface"};import{jsx as Po}from"react/jsx-runtime";var Ue=ke.forwardRef(function(t,o){let{autoHighlightFirst:l,...i}=t,r=D(),u=Te(),h=ke.useMemo(()=>{let e=a=>ge(a)?!0:F(a,r.itemToStringValue);if(l==="selected"){let a=r.multiple?r.values[0]:r.value;return e(a)}if(l!==void 0)return l;if(u?.alignItemWithTriggerActive){let a=r.multiple?r.values[0]:r.value;return e(a)}return!0},[l,u?.alignItemWithTriggerActive,r.multiple,r.value,r.values,r.itemToStringValue]);return Po(dt,{ref:o,autoHighlightFirst:h,[kt.slot]:"",...i})});import{Popover as Ro}from"@base-ui/react/popover";import{useRender as Io}from"@base-ui/react/use-render";import*as pe from"react";var be={slot:"bazzaui-select-trigger",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};import{jsx as At}from"react/jsx-runtime";var Co={open:n=>n?{[be.open]:""}:null,disabled:n=>n?{[be.disabled]:""}:null,placeholder:n=>n?{[be.placeholder]:""}:null},Vo=pe.forwardRef(function(t,o){let{render:l,children:i,disabled:r,className:u,style:h,triggerProps:e,triggerState:a,...I}=t,d=D(),p=r??d.disabled,P=d.multiple?d.values.length>0:!ge(d.value),f=pe.useMemo(()=>({open:a.open,disabled:p,placeholder:!P}),[a.open,p,P]),s=pe.useCallback(c=>{d.setTriggerElement(c)},[d]);return Io({render:l,ref:o,state:f,stateAttributesMapping:Co,props:{...e,...I,[be.slot]:"",ref:s,role:"combobox","aria-haspopup":"listbox","aria-controls":d.listId,className:u,style:h,children:i},defaultTagName:"button"})}),Ye=pe.forwardRef(function(t,o){let{disabled:l,...i}=t,r=D(),u=ye(),h=(l??r.disabled)||u.disabled;return At(Ro.Trigger,{ref:o,disabled:h,render:(e,a)=>At(Vo,{...i,disabled:h,triggerProps:e,triggerState:a,ref:e.ref})})});import{useRender as To}from"@base-ui/react/use-render";import*as re from"react";var Ae={slot:"bazzaui-select-value",placeholder:"data-placeholder",multiple:"data-multiple"};var Mo={hasValue:n=>n?null:{[Ae.placeholder]:""},multiple:n=>n?{[Ae.multiple]:""}:null,getValueText:()=>null};function vo(n,t){let{render:o,className:l,style:i,placeholder:r,children:u,...h}=n,e=D(),a=r??e.placeholder,I=re.useMemo(()=>Pe(e.items,""),[e.items]),d=r??I??a,p=e.multiple?e.values.length>0:!ge(e.value),P=re.useCallback(g=>{let T=F(g,e.itemToStringValue),L=e.itemTextRegistry.get(T);if(L!==void 0)return L;let S=Pe(e.items,T);if(S!==void 0)return S;let M=Se(g,e.itemToStringLabel);if(M&&M!==T)return M},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),f=re.useMemo(()=>({value:e.value,values:e.values,multiple:e.multiple,hasValue:p,placeholder:a,getValueText:P}),[e.value,e.values,e.multiple,p,a,P]),s;if(typeof u=="function")s=u(f);else if(u!==void 0)s=u;else if(!p)s=d;else if(e.multiple){let g=e.values.map(T=>{let L=P(T);return L!==void 0?L:Se(T,e.itemToStringLabel)||F(T,e.itemToStringValue)}).filter(Boolean);s=g.length>2?`${g.length} selected`:g.join(", ")}else{let g=e.value;if(g!=null){let T=P(g);T!==void 0?s=T:s=Se(g,e.itemToStringLabel)||F(g,e.itemToStringValue)}}let c=re.useCallback(g=>{e.setValueElement(g)},[e]);return To({render:o,ref:t,state:f,stateAttributesMapping:Mo,props:{...h,[Ae.slot]:"",ref:c,className:l,style:i,children:s},defaultTagName:"span"})}var Xe=re.forwardRef(vo);var Ot=(u=>(u.slot="bazzaui-select-arrow",u.open="data-open",u.closed="data-closed",u.side="data-side",u.align="data-align",u.uncentered="data-uncentered",u))(Ot||{});var Nt=(r=>(r.slot="bazzaui-select-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Nt||{});var zt=(t=>(t.slot="bazzaui-select-empty",t))(zt||{});var Ft=(t=>(t.slot="bazzaui-select-group",t))(Ft||{});var Gt=(t=>(t.slot="bazzaui-select-group-label",t))(Gt||{});var yo={slot:"bazzaui-select-icon",open:"data-popup-open"};var jt=(l=>(l.slot="bazzaui-select-input",l.open="data-open",l.closed="data-closed",l))(jt||{});var Bt=(o=>(o.slot="bazzaui-select-list",o.list="data-popup-menu-list",o))(Bt||{});var Wt=(t=>(t.alignItemWithTrigger="data-align-item-with-trigger",t))(Wt||{});var Eo={slotUp:"bazzaui-select-scroll-up-arrow",slotDown:"bazzaui-select-scroll-down-arrow",direction:"data-direction",side:"data-side"};var _t=(t=>(t.slot="bazzaui-select-separator",t))(_t||{});export{Dt as Select,Ot as SelectArrowDataAttributes,Nt as SelectBackdropDataAttributes,zt as SelectEmptyDataAttributes,Ft as SelectGroupDataAttributes,Gt as SelectGroupLabelDataAttributes,yo as SelectIconDataAttributes,jt as SelectInputDataAttributes,De as SelectItem,he as SelectItemDataAttributes,Oe as SelectItemIndicator,Ve as SelectItemIndicatorDataAttributes,Ne as SelectItemLabel,oo as SelectListCssVars,Bt as SelectListDataAttributes,Fe as SelectPopup,Wt as SelectPopupDataAttributes,_e as SelectPositioner,to as SelectPositionerCssVars,Be as SelectPositionerDataAttributes,qe as SelectRoot,Eo as SelectScrollArrowDataAttributes,_t as SelectSeparatorDataAttributes,eo as SelectStore,Ue as SelectSurface,Ye as SelectTrigger,be as SelectTriggerDataAttributes,Xe as SelectValue,Zt as commandScore,Qt as defaultFilter,no as useMaybeSelectContext,ro as useMaybeSelectItemContext,Jt as useMaybeSurfaceContext,D as useSelectContext,Ce as useSelectItemContext,Te as useSelectPositionerContext,Kt as useSurfaceContext};
1
+ import{a as xt}from"../chunk-IT372NHF.js";import{a as bt,b as Pt,c as Rt,d as It,e as Ct,f as Pe,g as Tt}from"../chunk-KO3DXT3Y.js";import{Ab as ht,L as tt,La as rt,Ma as lt,N as ot,Na as no,P as nt,Qa as at,Ra as it,Ua as fe,Va as ge,Wa as N,Xa as st,Ya as ut,Za as ct,_a as ro,ab as pt,eb as mt,fb as dt,gb as ft,l as Ee,yb as gt,zb as St}from"../chunk-23NDAOAL.js";import{a as we,p as Zt,q as Qt,w as eo,x as to,y as oo}from"../chunk-ZPRKUVIC.js";import{a as Jt}from"../chunk-4C666HHU.js";var Nt={};Jt(Nt,{Arrow:()=>ot,Backdrop:()=>nt,Empty:()=>ut,Group:()=>gt,GroupLabel:()=>St,Icon:()=>st,Input:()=>ct,Item:()=>Ne,ItemIndicator:()=>ze,ItemLabel:()=>Fe,List:()=>pt,Popup:()=>Be,Portal:()=>lt,Positioner:()=>Ue,Root:()=>Ye,ScrollDownArrow:()=>dt,ScrollUpArrow:()=>mt,Separator:()=>ht,Surface:()=>Xe,Trigger:()=>$e,Value:()=>Ke});import{useRender as io}from"@base-ui/react/use-render";import*as y from"react";import*as Re from"react";var Le=Re.createContext(null);function A(){let n=Re.useContext(Le);if(!n)throw new Error("Select components must be used within a Select.Root");return n}function lo(){return Re.useContext(Le)}var Se={slot:"bazzaui-select-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected"};import*as Ie from"react";var He=Ie.createContext(null);function Ce(){let n=Ie.useContext(He);if(!n)throw new Error("Select.Item child components must be used within a Select.Item");return n}function ao(){return Ie.useContext(He)}import{jsx as co}from"react/jsx-runtime";var so={highlighted:n=>n?{[Se.highlighted]:""}:null,disabled:n=>n?{[Se.disabled]:""}:null,selected:n=>n?{[Se.selected]:""}:null};function uo(n,o){let{value:e,textValue:l,keywords:s,disabled:r=!1,onSelect:c,forceMount:h=!1,render:t,className:a,style:b,onClick:f,onPointerDown:d,onPointerMove:P,children:u,...i}=n,m=A(),g=y.useMemo(()=>N(e,m.itemToStringValue),[e,m.itemToStringValue]),M=y.useId(),H=e===null?`select-clear-${M}`:void 0,S=y.useMemo(()=>Ct(m.items,g),[m.items,g]),V=S?.label,L=y.useMemo(()=>ge(e,m.itemToStringLabel),[e,m.itemToStringLabel]),v=y.useMemo(()=>{if(l!==void 0)return l;if(typeof V=="string")return V;if(L&&L!==g)return L},[l,V,L,g]),Q=y.useMemo(()=>Tt(s,[typeof V=="string"?V:L&&L!==g?L:void 0,...S?.keywords??[]]),[s,V,L,g,S]),k=y.useRef(v),O=m.multiple?Rt(m.values,e,m.isItemEqualToValue):m.value!==""&&Pt(m.value,e,m.isItemEqualToValue),le=!m.multiple,x=it({id:H,value:g,keywords:Q,disabled:r,forceMount:h,closeOnClick:le,children:u});y.useEffect(()=>{let T=()=>{if(!r){if(m.multiple)if(e==null)m.onValuesChange([]);else{let ee=O?It(m.values,e,m.isItemEqualToValue):[...m.values,e];m.onValuesChange(ee)}else m.onValueChange(e);c?.()}};return x.registerSelect(T)},[r,m,e,O,c,x]),y.useEffect(()=>{let T=k.current;if(T)return m.registerItemText(g,T)},[g,m]),y.useEffect(()=>{!v&&typeof u=="string"&&(k.current=u,m.registerItemText(g,u))},[u,v,g,m]);let G=y.useMemo(()=>({highlighted:x.isHighlighted,disabled:r,selected:O}),[x.isHighlighted,r,O]),q=y.useMemo(()=>({id:x.id,value:e,textValue:v,highlighted:x.isHighlighted,disabled:r,selected:O}),[x.id,e,v,x.isHighlighted,r,O]),B=y.useCallback(T=>{f?.(T),T.defaultPrevented||x.handlers.onClick(T)},[f,x.handlers]),U=y.useCallback(T=>{x.handlers.onPointerDown(T),d?.(T)},[x.handlers,d]),$=y.useCallback(T=>{P?.(T),T.defaultPrevented||x.handlers.onPointerMove(T)},[P,x.handlers]),j=io({render:t,ref:[x.ref,o],state:G,stateAttributesMapping:so,props:{...i,[Se.slot]:"",id:x.id,role:"option",tabIndex:-1,"aria-selected":O,"aria-disabled":r||void 0,className:a,style:b,onClick:B,onPointerMove:$,onPointerDown:U,children:u},enabled:x.isVisible,defaultTagName:"div"});return x.isVisible?co(He.Provider,{value:q,children:j}):null}var Ne=y.forwardRef(uo);import{useRender as po}from"@base-ui/react/use-render";import*as ke from"react";var Te={slot:"bazzaui-select-item-indicator",selected:"data-selected",highlighted:"data-highlighted"};var mo={selected:n=>n?{[Te.selected]:""}:null,highlighted:n=>n?{[Te.highlighted]:""}:null},ze=ke.forwardRef(function(o,e){let{render:l,className:s,style:r,forceMount:c=!1,keepMounted:h=!1,children:t,...a}=o,b=Ce(),f=b.selected,d=b.highlighted,P=ke.useMemo(()=>({selected:f,highlighted:d}),[f,d]),u=c||h||f,i=typeof t=="function"?t(P):h&&!f?null:t,m=po({render:l,ref:e,state:P,stateAttributesMapping:mo,props:{...a,[Te.slot]:"","aria-hidden":!0,className:s,style:r,children:i},defaultTagName:"span"});return u?m:null});import{useRender as fo}from"@base-ui/react/use-render";import*as _ from"react";var Mt={slot:"bazzaui-select-item-label"};var Fe=_.forwardRef(function(o,e){let{render:l,className:s,style:r,children:c,...h}=o,t=A(),a=Ce(),b=_.useRef(null),f=N(a.value,t.itemToStringValue),d=_.useMemo(()=>{if(c!==void 0)return c;let i=Pe(t.items,f);return i!==void 0?i:a.textValue!==void 0?a.textValue:f},[c,t.items,f,a.textValue]),P=_.useMemo(()=>({value:f,selected:a.selected,highlighted:a.highlighted,disabled:a.disabled}),[f,a.selected,a.highlighted,a.disabled]);_.useEffect(()=>{if(typeof d=="string")return t.registerItemText(f,d)},[d,t,f]);let u=_.useCallback(i=>{b.current=i,a.selected&&i&&(t.selectedItemTextRef.current=i),i&&!a.disabled&&(t.firstItemTextRef.current||(t.firstItemTextRef.current=i))},[a.selected,a.disabled,t]);return fo({render:l,ref:e,state:P,props:{...h,[Mt.slot]:"",ref:u,className:s,style:r,children:d},defaultTagName:"span"})});import"@base-ui/react/popover";import*as se from"react";import*as Ae from"react";var Ge=Ae.createContext(null);function Me(){return Ae.useContext(Ge)}import{jsx as go}from"react/jsx-runtime";var Be=se.forwardRef(function(o,e){let{className:l,render:s,...r}=o,c=Me(),h=c?.alignItemWithTriggerActive??!1,t=c?.align,a=se.useCallback(d=>({...d,side:h?"none":d.side,alignItemWithTriggerActive:h}),[h]),b=se.useMemo(()=>typeof l=="function"?d=>l(a(d)):l,[l,a]),f=se.useMemo(()=>typeof s=="function"?(d,P)=>s(d,a(P)):s,[s,a]);return go(rt,{ref:e,className:b,render:f,"data-align-item-with-trigger":h?"":void 0,...h?{"data-side":"none","data-align":t}:{},...r})});import{useDirection as So}from"@base-ui/react/internals/direction-context";import{Popover as ho}from"@base-ui/react/popover";import*as I from"react";function ue(n,o,e){return n<o?o:n>e?e:n}function je(n){let o=n.getBoundingClientRect(),{offsetWidth:e,offsetHeight:l}=n,s=e>0?Math.round(o.width)/e:1,r=l>0?Math.round(o.height)/l:1;return(!Number.isFinite(s)||s===0)&&(s=1),(!Number.isFinite(r)||r===0)&&(r=1),{x:s,y:r}}function Vt(n,o,e){return n/e[o]}function Ve(n,o){let e=n.x/o.x,l=n.y/o.y,s=n.width/o.x,r=n.height/o.y;return{x:e,y:l,width:s,height:r,top:l,left:e,right:e+s,bottom:l+r}}var X=1;function he(n,o){return Math.max(0,n-o)}var vt=5,yt=20,We=10,Et=100;function wt(n){let{triggerRect:o,positionerRect:e,valueRect:l,textRect:s,scrollHeight:r,documentClientHeight:c,documentClientWidth:h,marginTop:t,marginBottom:a,minHeight:b,maxPopupHeight:f,borderBottom:d,direction:P}=n,u=()=>({fallback:!0,left:0,isTopPositioned:!1,top:0,height:0,scrollTop:0,marginTop:t,marginBottom:a,reachedMaxHeight:!1,transformOrigin:null}),i=c-t-a,m=h,g=o.height,M=i-o.bottom+g,H=P==="rtl"?o.right-e.width:o.left,S=0,V=null;if(s&&l){H=e.left+(P==="rtl"?l.right-s.right:l.left-s.left);let W=l.top-o.top+l.height/2;S=s.top-e.top+s.height/2-W,V=s.top+s.height/2}let L=M+S+a+d,v=Math.min(i,L),Q=i-t-a,k=L-v,O=m-vt,le=ue(H,vt,O-e.width),x=he(r,v),G=k>=x-X;if(G&&(v=Math.min(i,e.height)-(k-x)),o.top<yt||o.bottom>i-yt||Math.ceil(v)+X<Math.min(r,b))return u();let B=Math.max(b,v),U=a+d-t,$=0,j=k;if(G){let W=Math.max(0,i-L);$=e.height>=Q?0:Math.max(0,W+U),j=x}else j=Math.max(0,k-U);let T=null;if(V!=null){let W=e.top,te=e.height,p=te>0?(V-W)/te*100:50;T=`50% ${ue(p,0,100)}%`}let ee=B===i||v>=f;return{fallback:!1,left:le,isTopPositioned:G,top:$,height:v,scrollTop:j,marginTop:t,marginBottom:a,reachedMaxHeight:ee,transformOrigin:T}}function Lt(n){let{isTopPositioned:o,currentHeight:e,scrollTop:l,maxScrollTop:s,maxAvailableHeight:r}=n,c=o?s-l:l;if(c<=X){let f=ue(c,0,r-e),d=e+f;return{height:f>0?d:null,scroll:{kind:"set",value:o?s:0},reachedMaxHeight:r-d<=X}}let h=Math.min(e+c,r),t={kind:"none"},a=!1;if(r-h>X)t=o?{kind:"max"}:{kind:"clamp",value:0};else if(a=!0,!o&&l<s){let f=e+c-r;t={kind:"clamp",value:l-(c-f)}}let b=Math.ceil(h);return{height:b,scroll:t,reachedMaxHeight:a||b>=r-X}}var _e={slot:"bazzaui-select-positioner"};import{jsx as At}from"react/jsx-runtime";var Ue=I.forwardRef(function(o,e){let{alignItemWithTrigger:l=!0,side:s="bottom",align:r="start",sideOffset:c=0,className:h,style:t,children:a,...b}=o,f=Ee(),d=A(),P=So()==="rtl"?"rtl":"ltr",u=f.store,i=u.useState("open"),m=u.useState("openMethod"),g=u.useState("hasInput"),[M,H]=I.useState(l),S=M&&m!=="touch"&&!g,[V,L]=I.useState(!1),[v,Q]=I.useState(null),k=I.useRef(null),O=I.useRef(null),le=I.useRef(null),x=I.useRef(!1),G=I.useRef(!1),q=I.useCallback(()=>{let p=k.current,C=u.context.refs.popupRef.current;p&&(p.style.height=""),C&&(C.style.height="",C.style.removeProperty("--transform-origin")),x.current=!1,G.current=!1},[u]),B=I.useCallback(()=>{q(),H(l),L(!1),Q(null)},[l,q]);I.useEffect(()=>d.registerResetPositioningCallback(B),[d,B]);let U=I.useCallback(()=>{if(u.state.hasInput)return;let p=k.current,C=d.triggerRef.current,D=u.context.refs.popupRef.current,Y=u.context.refs.listRef.current;if(!p||!C||!D||!Y)return;let oe=d.selectedItemTextRef.current;if(!oe?.isConnected){let z=d.firstItemTextRef.current;oe=z?.isConnected?z:null}let ae=d.valueRef.current,ce=bo(D),w;try{let z=qe(p),K=p.ownerDocument,ne=je(C),ie=z.getComputedStyle(p),pe=z.getComputedStyle(D);w=wt({triggerRect:Ve(C.getBoundingClientRect(),ne),positionerRect:Ve(p.getBoundingClientRect(),ne),valueRect:ae?Ve(ae.getBoundingClientRect(),ne):null,textRect:oe?Ve(oe.getBoundingClientRect(),ne):null,scrollHeight:Y.scrollHeight,documentClientHeight:K.documentElement.clientHeight,documentClientWidth:K.documentElement.clientWidth,marginTop:Number.parseFloat(ie.marginTop)||We,marginBottom:Number.parseFloat(ie.marginBottom)||We,minHeight:Number.parseFloat(ie.minHeight)||Et,maxPopupHeight:Ht(pe),borderBottom:Number.parseFloat(pe.borderBottomWidth)||0,direction:P});let J=(z.visualViewport?.scale??1)!==1&&xo(z);if(w.fallback||J){H(!1),L(!0);return}p.style.height=`${w.height}px`,D.style.height="100%",w.transformOrigin&&D.style.setProperty("--transform-origin",w.transformOrigin),Y.scrollTop=w.scrollTop,x.current=w.reachedMaxHeight,G.current=!0}finally{ce()}Q({left:w.left,top:w.isTopPositioned?w.top:null,bottom:w.isTopPositioned?null:0,marginTop:w.marginTop,marginBottom:w.marginBottom}),L(!0)},[u,d,P]);I.useEffect(()=>{!i||!S||V||U()},[i,S,V,U]),I.useEffect(()=>{i&&!S&&q()},[i,S,q]),I.useEffect(()=>{if(!i||!S)return;let p=k.current,C=p?qe(p):window,D=Y=>{u.setOpen(!1,we.none,Y)};return C.addEventListener("resize",D),()=>{C.removeEventListener("resize",D)}},[i,S,u]);let $=I.useCallback(p=>{let C=k.current,D=u.context.refs.popupRef.current;if(!C||!D||!G.current||x.current||!S)return;let Y=C.style.top==="0px",oe=C.style.bottom==="0px";if(!Y&&!oe)return;let ae=qe(C),ce=C.ownerDocument,w=je(C),z=Vt(C.getBoundingClientRect().height,"y",w),K=ae.getComputedStyle(C),ne=Number.parseFloat(K.marginTop)||0,ie=Number.parseFloat(K.marginBottom)||0,pe=Ht(ae.getComputedStyle(D)),J=Math.min(ce.documentElement.clientHeight-ne-ie,pe),Z=Lt({isTopPositioned:Y,currentHeight:z,scrollTop:p.scrollTop,maxScrollTop:he(p.scrollHeight,p.clientHeight),maxAvailableHeight:J});switch(Z.height!=null&&(C.style.height=`${Z.height}px`),Z.scroll.kind){case"set":p.scrollTop=Z.scroll.value;break;case"max":{let me=he(p.scrollHeight,p.clientHeight);Math.abs(p.scrollTop-me)>X&&(p.scrollTop=me);break}case"clamp":{let me=he(p.scrollHeight,p.clientHeight),ye=ue(Z.scroll.value,0,me);Math.abs(p.scrollTop-ye)>X&&(p.scrollTop=ye);break}default:break}Z.reachedMaxHeight&&(x.current=!0)},[u,S]);I.useEffect(()=>{if(!i||!S||!V)return;let p=u.context.refs.listRef.current;if(!p)return;let C=()=>$(p);return p.addEventListener("scroll",C,{passive:!0}),()=>{p.removeEventListener("scroll",C)}},[i,S,V,$,u]);let j=S?"none":s,T=I.useMemo(()=>({alignItemWithTriggerActive:S,side:j,align:r,scrollUpArrowRef:O,scrollDownArrowRef:le,setAlignItemWithTriggerActive:H,resetPositioningState:B}),[S,j,r,B]),ee=I.useCallback(p=>{k.current=p,typeof e=="function"?e(p):e&&(e.current=p)},[e]),W=i&&S&&!V,te=S&&v?{position:"fixed",transform:"none",left:v.left,top:v.top??"auto",bottom:v.bottom??"auto",marginTop:v.marginTop,marginBottom:v.marginBottom,maxHeight:"none"}:{};return At(Ge.Provider,{value:T,children:At(ho.Positioner,{ref:ee,side:S?void 0:s,align:S?void 0:r,sideOffset:S?0:c,disableAnchorTracking:S||void 0,className:h,style:{...t,...te,...W?{visibility:"hidden"}:{}},...S?{"data-side":"none","data-align":r}:{},[_e.slot]:"",...b,children:a})})});function qe(n){return n.ownerDocument?.defaultView??window}function Ht(n){let o=n.maxHeight||"";return o.endsWith("px")&&Number.parseFloat(o)||Number.POSITIVE_INFINITY}function xo(n){let o=n.navigator;return o?/AppleWebKit/.test(o.userAgent)&&!/Chrome|Chromium|Edg|OPR/.test(o.userAgent):!1}var kt=[["transform","none"],["scale","1"],["translate","0 0"]];function bo(n){let{style:o}=n,e={};for(let[l,s]of kt)e[l]=o.getPropertyValue(l),o.setProperty(l,s,"important");return()=>{for(let[l]of kt){let s=e[l];s?o.setProperty(l,s):o.removeProperty(l)}}}import{Popover as Po}from"@base-ui/react/popover";import*as R from"react";import{jsx as ve,jsxs as Ro}from"react/jsx-runtime";function Ye(n){let{open:o,onOpenChange:e,onOpenChangeComplete:l,actionsRef:s,defaultOpen:r=!1,value:c,defaultValue:h,onValueChange:t,multiple:a=!1,values:b,defaultValues:f,onValuesChange:d,isItemEqualToValue:P=bt,itemToStringLabel:u,itemToStringValue:i,name:m,form:g,required:M,disabled:H=!1,placeholder:S="Select...",items:V,modal:L=!0,closeOnOutsidePress:v="pointerdown",virtualized:Q=!1,virtualItems:k,onHighlightChange:O,debug:le,children:x,...G}=n,q=R.useId(),B=R.useRef(null),U=R.useRef(null),$=R.useRef(null),j=R.useRef(null),T=R.useCallback(E=>{B.current=E},[]),ee=R.useCallback(E=>{U.current=E},[]),W=R.useRef(null),te=R.useCallback(E=>(W.current=E,()=>{W.current=null}),[]),{store:p,focusOwnerStore:C,openChainStore:D,registerSurface:Y,closeAll:oe,virtualization:ae,handleOpenChange:ce,disabled:w,setDisabled:z}=tt({onOpenChange:e,defaultOpen:r,virtualized:Q,items:k,onHighlightChange:O,closeOnOutsidePress:v,disabled:H}),K=R.useRef(null);R.useImperativeHandle(s,()=>({close:()=>{K.current?.close()},unmount:()=>{K.current?.unmount()},setDisabled:z}),[z]),p.useControlledProp("openProp",o);let ne=p.useState("open"),[ie,pe]=R.useState(h!==void 0?h:null),J=c!==void 0?c:ie,Z=R.useCallback(E=>{c===void 0&&pe(E),t?.(E)},[c,t]),[me,ye]=R.useState(f??[]),be=b!==void 0?b:me,Je=R.useCallback(E=>{b===void 0&&ye(E),d?.(E)},[b,d]),Ze=R.useRef(new Map),Qe=R.useCallback((E,de)=>(Ze.current.set(E,de),()=>{}),[]),Yt=R.useMemo(()=>({multiple:a,value:J,values:be,onValueChange:Z,onValuesChange:Je,isItemEqualToValue:P,itemToStringLabel:u,itemToStringValue:i,name:m,form:g,required:M,disabled:w,placeholder:S,items:V,itemTextRegistry:Ze.current,registerItemText:Qe,listId:q,triggerRef:B,valueRef:U,selectedItemTextRef:$,firstItemTextRef:j,setTriggerElement:T,setValueElement:ee,registerResetPositioningCallback:te}),[a,J,be,Z,Je,P,u,i,m,g,M,w,S,V,Qe,q,T,ee,te]),Xt=R.useMemo(()=>m?a?be.length>0?be.map((E,de)=>{let et=N(E,i);return ve("input",{type:"hidden",name:m,value:et,form:g,required:M&&de===0},et)}):ve("input",{type:"hidden",name:m,value:"",form:g,required:M}):ve("input",{type:"hidden",name:m,value:J!=null?N(J,i):"",form:g,required:M}):null,[m,g,M,a,J,be,i]),$t=R.useCallback((E,de)=>{ce(E,de.reason,de.event)},[ce]),Kt=R.useCallback(E=>{!E&&p.context.clearSearchOnClose==="after-exit"&&(p.clearSearch(),p.setInputActive(!1)),E||(p.clearHighlight(),W.current?.(),j.current=null),l?.(E)},[p,l]);return ve(Le.Provider,{value:Yt,children:Ro(at,{store:p,focusOwnerStore:C,openChainStore:D,disabled:w,depth:0,closeAll:oe,registerSurface:Y,virtualization:ae,menuType:"dropdown",closeOnOutsidePress:v,componentName:"select",debug:le,children:[Xt,ve(Po.Root,{...G,open:ne,onOpenChange:$t,onOpenChangeComplete:Kt,modal:L,actionsRef:s?K:void 0,children:x})]})})}import*as Oe from"react";var Ot={slot:"bazzaui-select-surface"};import{jsx as Io}from"react/jsx-runtime";var Xe=Oe.forwardRef(function(o,e){let{autoHighlightFirst:l,...s}=o,r=A(),c=Me(),h=Oe.useMemo(()=>{let t=a=>fe(a)?!0:N(a,r.itemToStringValue);if(l==="selected"){let a=r.multiple?r.values[0]:r.value;return t(a)}if(l!==void 0)return l;if(c?.alignItemWithTriggerActive){let a=r.multiple?r.values[0]:r.value;return t(a)}return!0},[l,c?.alignItemWithTriggerActive,r.multiple,r.value,r.values,r.itemToStringValue]);return Io(ft,{ref:e,autoHighlightFirst:h,[Ot.slot]:"",...s})});import{Popover as Co}from"@base-ui/react/popover";import{useRender as To}from"@base-ui/react/use-render";import*as F from"react";var xe={slot:"bazzaui-select-trigger",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};import{jsx as Dt}from"react/jsx-runtime";var Mo={open:n=>n?{[xe.open]:""}:null,disabled:n=>n?{[xe.disabled]:""}:null,placeholder:n=>n?{[xe.placeholder]:""}:null},Vo=F.forwardRef(function(o,e){let{render:l,children:s,disabled:r,className:c,style:h,triggerProps:t,triggerState:a,...b}=o,f=A(),d=r??f.disabled,P=f.multiple?f.values.length>0:!fe(f.value),u=F.useMemo(()=>({open:a.open,disabled:d,placeholder:!P}),[a.open,d,P]),i=F.useCallback(m=>{f.setTriggerElement(m)},[f]);return To({render:l,ref:e,state:u,stateAttributesMapping:Mo,props:{...xt(t,{...b,className:c,style:h,children:s}),[xe.slot]:"",ref:i,role:"combobox","aria-haspopup":"listbox","aria-controls":f.listId},defaultTagName:"button"})}),$e=F.forwardRef(function(o,e){let{disabled:l,...s}=o,r=A(),c=Ee(),{store:h,closeAll:t,closeOnOutsidePress:a}=c,b=(l??r.disabled)||c.disabled,f=h.useState("open"),d=F.useRef(null),P=F.useCallback(u=>{d.current=u,typeof e=="function"?e(u):e&&(e.current=u)},[e]);return F.useEffect(()=>{let u=d.current;if(!u||a!=="pointerdown")return;let i=m=>{f&&(t(we.triggerPress,m),u.addEventListener("click",g=>{g.stopPropagation(),g.preventDefault()},{once:!0,capture:!0}))};return u.addEventListener("pointerdown",i,!0),()=>{u.removeEventListener("pointerdown",i,!0)}},[f,t,a]),Dt(Co.Trigger,{ref:P,disabled:b,render:(u,i)=>Dt(Vo,{...s,disabled:b,triggerProps:u,triggerState:i,ref:u.ref})})});import{useRender as vo}from"@base-ui/react/use-render";import*as re from"react";var De={slot:"bazzaui-select-value",placeholder:"data-placeholder",multiple:"data-multiple"};var yo={hasValue:n=>n?null:{[De.placeholder]:""},multiple:n=>n?{[De.multiple]:""}:null,getValueText:()=>null};function Eo(n,o){let{render:e,className:l,style:s,placeholder:r,children:c,...h}=n,t=A(),a=r??t.placeholder,b=re.useMemo(()=>Pe(t.items,""),[t.items]),f=r??b??a,d=t.multiple?t.values.length>0:!fe(t.value),P=re.useCallback(g=>{let M=N(g,t.itemToStringValue),H=t.itemTextRegistry.get(M);if(H!==void 0)return H;let S=Pe(t.items,M);if(S!==void 0)return S;let V=ge(g,t.itemToStringLabel);if(V&&V!==M)return V},[t.itemTextRegistry,t.items,t.itemToStringLabel,t.itemToStringValue]),u=re.useMemo(()=>({value:t.value,values:t.values,multiple:t.multiple,hasValue:d,placeholder:a,getValueText:P}),[t.value,t.values,t.multiple,d,a,P]),i;if(typeof c=="function")i=c(u);else if(c!==void 0)i=c;else if(!d)i=f;else if(t.multiple){let g=t.values.map(M=>{let H=P(M);return H!==void 0?H:ge(M,t.itemToStringLabel)||N(M,t.itemToStringValue)}).filter(Boolean);i=g.length>2?`${g.length} selected`:g.join(", ")}else{let g=t.value;if(g!=null){let M=P(g);M!==void 0?i=M:i=ge(g,t.itemToStringLabel)||N(g,t.itemToStringValue)}}let m=re.useCallback(g=>{t.setValueElement(g)},[t]);return vo({render:e,ref:o,state:u,stateAttributesMapping:yo,props:{...h,[De.slot]:"",ref:m,className:l,style:s,children:i},defaultTagName:"span"})}var Ke=re.forwardRef(Eo);var zt=(c=>(c.slot="bazzaui-select-arrow",c.open="data-open",c.closed="data-closed",c.side="data-side",c.align="data-align",c.uncentered="data-uncentered",c))(zt||{});var Ft=(r=>(r.slot="bazzaui-select-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Ft||{});var Gt=(o=>(o.slot="bazzaui-select-empty",o))(Gt||{});var Bt=(o=>(o.slot="bazzaui-select-group",o))(Bt||{});var jt=(o=>(o.slot="bazzaui-select-group-label",o))(jt||{});var wo={slot:"bazzaui-select-icon",open:"data-popup-open"};var Wt=(l=>(l.slot="bazzaui-select-input",l.open="data-open",l.closed="data-closed",l))(Wt||{});var _t=(e=>(e.slot="bazzaui-select-list",e.list="data-popup-menu-list",e))(_t||{});var qt=(o=>(o.alignItemWithTrigger="data-align-item-with-trigger",o))(qt||{});var Lo={slotUp:"bazzaui-select-scroll-up-arrow",slotDown:"bazzaui-select-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Ut=(o=>(o.slot="bazzaui-select-separator",o))(Ut||{});export{Nt as Select,zt as SelectArrowDataAttributes,Ft as SelectBackdropDataAttributes,Gt as SelectEmptyDataAttributes,Bt as SelectGroupDataAttributes,jt as SelectGroupLabelDataAttributes,wo as SelectIconDataAttributes,Wt as SelectInputDataAttributes,Ne as SelectItem,Se as SelectItemDataAttributes,ze as SelectItemIndicator,Te as SelectItemIndicatorDataAttributes,Fe as SelectItemLabel,ro as SelectListCssVars,_t as SelectListDataAttributes,Be as SelectPopup,qt as SelectPopupDataAttributes,Ue as SelectPositioner,no as SelectPositionerCssVars,_e as SelectPositionerDataAttributes,Ye as SelectRoot,Lo as SelectScrollArrowDataAttributes,Ut as SelectSeparatorDataAttributes,oo as SelectStore,Xe as SelectSurface,$e as SelectTrigger,xe as SelectTriggerDataAttributes,Ke as SelectValue,eo as commandScore,to as defaultFilter,lo as useMaybeSelectContext,ao as useMaybeSelectItemContext,Qt as useMaybeSurfaceContext,A as useSelectContext,Ce as useSelectItemContext,Me as useSelectPositionerContext,Zt as useSurfaceContext};
2
2
  //# sourceMappingURL=index.js.map