"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import * as SelectPrimitive from "@radix-ui/react-select";
import { Check, ChevronDown, ChevronUp } from "lucide-react";
import { cva } from "class-variance-authority";
import { cn } from "@open-mercato/shared/lib/utils";
const selectTriggerVariants = cva(
  "inline-flex w-full items-center justify-between gap-2 rounded-md border border-input bg-background shadow-xs transition-colors outline-none placeholder:text-muted-foreground hover:bg-muted/40 focus:outline-none focus-visible:outline-none focus-visible:shadow-focus focus-visible:border-foreground disabled:cursor-not-allowed disabled:bg-bg-disabled disabled:border-border-disabled disabled:shadow-none disabled:hover:bg-bg-disabled disabled:[&_svg]:opacity-60 aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-visible:border-destructive data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1 [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0",
  {
    variants: {
      size: {
        xs: "h-7 px-2 text-xs",
        sm: "h-8 px-2.5 text-xs",
        default: "h-9 px-3 text-sm",
        lg: "h-10 px-3 text-sm"
      }
    },
    defaultVariants: {
      size: "default"
    }
  }
);
const SelectTrigger = React.forwardRef(({ className, size, children, ...props }, ref) => /* @__PURE__ */ jsxs(
  SelectPrimitive.Trigger,
  {
    ref,
    className: cn(selectTriggerVariants({ size }), className),
    "data-slot": "select-trigger",
    ...props,
    children: [
      children,
      /* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "text-muted-foreground", "aria-hidden": "true" }) })
    ]
  }
));
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
const SelectTriggerLeading = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(
  "span",
  {
    ref,
    "data-slot": "select-trigger-leading",
    "aria-hidden": "true",
    className: cn(
      "flex shrink-0 items-center justify-center",
      "[&>svg]:size-4 [&>svg]:shrink-0 [&>img]:size-5 [&>img]:shrink-0",
      className
    ),
    ...props,
    children
  }
));
SelectTriggerLeading.displayName = "SelectTriggerLeading";
const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
  SelectPrimitive.ScrollUpButton,
  {
    ref,
    className: cn("flex cursor-default items-center justify-center py-1 text-muted-foreground", className),
    ...props,
    children: /* @__PURE__ */ jsx(ChevronUp, { className: "size-4", "aria-hidden": "true" })
  }
));
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
const SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
  SelectPrimitive.ScrollDownButton,
  {
    ref,
    className: cn("flex cursor-default items-center justify-center py-1 text-muted-foreground", className),
    ...props,
    children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4", "aria-hidden": "true" })
  }
));
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
const SelectContent = React.forwardRef(({ className, children, position = "popper", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
  SelectPrimitive.Content,
  {
    ref,
    position,
    sideOffset,
    className: cn(
      "relative z-popover min-w-[8rem] overflow-hidden rounded-md border border-input bg-popover text-popover-foreground shadow-md outline-none",
      "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
      position === "popper" && "w-full min-w-[var(--radix-select-trigger-width)]",
      className
    ),
    ...props,
    children: [
      /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
      /* @__PURE__ */ jsx(
        SelectPrimitive.Viewport,
        {
          className: cn(
            "p-2 max-h-[var(--radix-select-content-available-height)] overflow-y-auto",
            position === "popper" && "w-full min-w-[var(--radix-select-trigger-width)]"
          ),
          children
        }
      ),
      /* @__PURE__ */ jsx(SelectScrollDownButton, {})
    ]
  }
) }));
SelectContent.displayName = SelectPrimitive.Content.displayName;
const SelectLabel = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
  SelectPrimitive.Label,
  {
    ref,
    className: cn(
      "px-2 pt-2 pb-1 text-overline font-semibold uppercase tracking-wider text-muted-foreground/80",
      "select-none",
      className
    ),
    ...props
  }
));
SelectLabel.displayName = SelectPrimitive.Label.displayName;
const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
  SelectPrimitive.Item,
  {
    ref,
    className: cn(
      "relative flex w-full cursor-default select-none items-center gap-2 rounded-md p-2 text-sm outline-none transition-colors",
      "focus:bg-muted focus:text-foreground",
      "data-[state=checked]:bg-muted/70 data-[state=checked]:text-foreground",
      "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      "[&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0",
      className
    ),
    ...props,
    children: [
      /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "flex min-w-0 flex-1 items-center gap-2 truncate", children }) }),
      /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { className: "ml-auto flex shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx(Check, { className: "size-4 text-foreground", "aria-hidden": "true" }) })
    ]
  }
));
SelectItem.displayName = SelectPrimitive.Item.displayName;
const SelectItemLeading = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(
  "span",
  {
    ref,
    "data-slot": "select-item-leading",
    "aria-hidden": "true",
    className: cn(
      "flex shrink-0 items-center justify-center",
      "[&>svg]:size-4 [&>svg]:shrink-0 [&>img]:size-5 [&>img]:shrink-0",
      className
    ),
    ...props,
    children
  }
));
SelectItemLeading.displayName = "SelectItemLeading";
const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
  SelectPrimitive.Separator,
  {
    ref,
    className: cn("-mx-1 my-1 h-px bg-border", className),
    ...props
  }
));
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
const Select = React.forwardRef(({ value, defaultValue, onValueChange, ...props }, _ref) => {
  const isControlled = value !== void 0 || onValueChange !== void 0;
  if (!isControlled) {
    return /* @__PURE__ */ jsx(SelectPrimitive.Root, { defaultValue, ...props });
  }
  return /* @__PURE__ */ jsx(
    SelectPrimitive.Root,
    {
      value: value ?? "",
      onValueChange,
      ...props
    }
  );
});
Select.displayName = "Select";
const SelectGroup = SelectPrimitive.Group;
const SelectValue = SelectPrimitive.Value;
export {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectItemLeading,
  SelectLabel,
  SelectScrollDownButton,
  SelectScrollUpButton,
  SelectSeparator,
  SelectTrigger,
  SelectTriggerLeading,
  SelectValue,
  selectTriggerVariants
};
//# sourceMappingURL=select.js.map
