"use client";
import { jsxs, jsx } from "react/jsx-runtime";
import * as React from "react";
import { cn } from "../../lib/utils.js";
import { Button } from "./button.js";
import { InputGroup, InputGroupInput, InputGroupAddon, InputGroupButton } from "./input-group.js";
import Check from "../../node_modules/lucide-react/dist/esm/icons/check.js";
import X from "../../node_modules/lucide-react/dist/esm/icons/x.js";
import ChevronDown from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
import { ComboboxRoot } from "../../node_modules/@base-ui/react/esm/combobox/root/ComboboxRoot.js";
import { ComboboxInput as ComboboxInput$1 } from "../../node_modules/@base-ui/react/esm/combobox/input/ComboboxInput.js";
import { ComboboxPortal } from "../../node_modules/@base-ui/react/esm/combobox/portal/ComboboxPortal.js";
import { ComboboxPositioner } from "../../node_modules/@base-ui/react/esm/combobox/positioner/ComboboxPositioner.js";
import { ComboboxPopup } from "../../node_modules/@base-ui/react/esm/combobox/popup/ComboboxPopup.js";
import { ComboboxList as ComboboxList$1 } from "../../node_modules/@base-ui/react/esm/combobox/list/ComboboxList.js";
import { ComboboxItem as ComboboxItem$1 } from "../../node_modules/@base-ui/react/esm/combobox/item/ComboboxItem.js";
import { ComboboxItemIndicator } from "../../node_modules/@base-ui/react/esm/combobox/item-indicator/ComboboxItemIndicator.js";
import { ComboboxGroup as ComboboxGroup$1 } from "../../node_modules/@base-ui/react/esm/combobox/group/ComboboxGroup.js";
import { ComboboxGroupLabel } from "../../node_modules/@base-ui/react/esm/combobox/group-label/ComboboxGroupLabel.js";
import { ComboboxCollection as ComboboxCollection$1 } from "../../node_modules/@base-ui/react/esm/combobox/collection/ComboboxCollection.js";
import { ComboboxEmpty as ComboboxEmpty$1 } from "../../node_modules/@base-ui/react/esm/combobox/empty/ComboboxEmpty.js";
import { Separator } from "../../node_modules/@base-ui/react/esm/separator/Separator.js";
import { ComboboxChips as ComboboxChips$1 } from "../../node_modules/@base-ui/react/esm/combobox/chips/ComboboxChips.js";
import { ComboboxChip as ComboboxChip$1 } from "../../node_modules/@base-ui/react/esm/combobox/chip/ComboboxChip.js";
import { ComboboxChipRemove } from "../../node_modules/@base-ui/react/esm/combobox/chip-remove/ComboboxChipRemove.js";
import { ComboboxTrigger as ComboboxTrigger$1 } from "../../node_modules/@base-ui/react/esm/combobox/trigger/ComboboxTrigger.js";
import { ComboboxValue as ComboboxValue$1 } from "../../node_modules/@base-ui/react/esm/combobox/value/ComboboxValue.js";
import { ComboboxClear as ComboboxClear$1 } from "../../node_modules/@base-ui/react/esm/combobox/clear/ComboboxClear.js";
const Combobox = ComboboxRoot;
function ComboboxValue({ ...props }) {
  return /* @__PURE__ */ jsx(ComboboxValue$1, { "data-slot": "combobox-value", ...props });
}
function ComboboxTrigger({
  className,
  children,
  ...props
}) {
  return /* @__PURE__ */ jsxs(
    ComboboxTrigger$1,
    {
      "data-slot": "combobox-trigger",
      className: cn("[&_svg:not([class*='size-'])]:size-4", className),
      ...props,
      children: [
        children,
        /* @__PURE__ */ jsx(ChevronDown, { className: "text-muted-foreground size-4 pointer-events-none" })
      ]
    }
  );
}
function ComboboxClear({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    ComboboxClear$1,
    {
      "data-slot": "combobox-clear",
      render: /* @__PURE__ */ jsx(InputGroupButton, { variant: "ghost", size: "icon-xs" }),
      className: cn(className),
      ...props,
      children: /* @__PURE__ */ jsx(X, { className: "pointer-events-none" })
    }
  );
}
function ComboboxInput({
  className,
  children,
  disabled = false,
  showTrigger = true,
  showClear = false,
  ...props
}) {
  return /* @__PURE__ */ jsxs(InputGroup, { className: cn("w-auto", className), children: [
    /* @__PURE__ */ jsx(
      ComboboxInput$1,
      {
        render: /* @__PURE__ */ jsx(InputGroupInput, { disabled }),
        ...props
      }
    ),
    /* @__PURE__ */ jsxs(InputGroupAddon, { align: "inline-end", children: [
      showTrigger && /* @__PURE__ */ jsx(
        InputGroupButton,
        {
          size: "icon-xs",
          variant: "ghost",
          render: /* @__PURE__ */ jsx(ComboboxTrigger, {}),
          "data-slot": "input-group-button",
          className: "group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent",
          disabled
        }
      ),
      showClear && /* @__PURE__ */ jsx(ComboboxClear, { disabled })
    ] }),
    children
  ] });
}
function ComboboxContent({
  className,
  side = "bottom",
  sideOffset = 6,
  align = "start",
  alignOffset = 0,
  anchor,
  ...props
}) {
  return /* @__PURE__ */ jsx(ComboboxPortal, { children: /* @__PURE__ */ jsx(
    ComboboxPositioner,
    {
      side,
      sideOffset,
      align,
      alignOffset,
      anchor,
      className: "isolate z-50",
      children: /* @__PURE__ */ jsx(
        ComboboxPopup,
        {
          "data-slot": "combobox-content",
          "data-chips": !!anchor,
          className: cn(
            "bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-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 ring-foreground/10 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:border-input/30 max-h-72 min-w-36 overflow-hidden rounded-md shadow-md ring-1 duration-100 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:shadow-none group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) data-[chips=true]:min-w-(--anchor-width)",
            className
          ),
          ...props
        }
      )
    }
  ) });
}
function ComboboxList({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    ComboboxList$1,
    {
      "data-slot": "combobox-list",
      className: cn(
        "no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto p-1 data-empty:p-0 overflow-y-auto overscroll-contain",
        className
      ),
      ...props
    }
  );
}
function ComboboxItem({ className, children, ...props }) {
  return /* @__PURE__ */ jsxs(
    ComboboxItem$1,
    {
      "data-slot": "combobox-item",
      className: cn(
        "data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm [&_svg:not([class*='size-'])]:size-4 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
        className
      ),
      ...props,
      children: [
        children,
        /* @__PURE__ */ jsx(
          ComboboxItemIndicator,
          {
            render: /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center" }),
            children: /* @__PURE__ */ jsx(Check, { className: "pointer-events-none" })
          }
        )
      ]
    }
  );
}
function ComboboxGroup({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    ComboboxGroup$1,
    {
      "data-slot": "combobox-group",
      className: cn(className),
      ...props
    }
  );
}
function ComboboxLabel({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    ComboboxGroupLabel,
    {
      "data-slot": "combobox-label",
      className: cn("text-muted-foreground px-2 py-1.5 text-xs", className),
      ...props
    }
  );
}
function ComboboxCollection({ ...props }) {
  return /* @__PURE__ */ jsx(ComboboxCollection$1, { "data-slot": "combobox-collection", ...props });
}
function ComboboxEmpty({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    ComboboxEmpty$1,
    {
      "data-slot": "combobox-empty",
      className: cn(
        "text-muted-foreground hidden w-full justify-center py-2 text-center text-sm group-data-empty/combobox-content:flex",
        className
      ),
      ...props
    }
  );
}
function ComboboxSeparator({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    Separator,
    {
      "data-slot": "combobox-separator",
      className: cn("bg-border -mx-1 my-1 h-px", className),
      ...props
    }
  );
}
function ComboboxChips({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    ComboboxChips$1,
    {
      "data-slot": "combobox-chips",
      className: cn(
        "dark:bg-input/30 border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive dark:has-aria-invalid:border-destructive/50 flex min-h-9 flex-wrap items-center gap-1.5 rounded-md border bg-transparent bg-clip-padding px-2.5 py-1.5 text-sm shadow-xs transition-[color,box-shadow] focus-within:ring-[3px] has-aria-invalid:ring-[3px] has-data-[slot=combobox-chip]:px-1.5",
        className
      ),
      ...props
    }
  );
}
function ComboboxChip({
  className,
  children,
  showRemove = true,
  ...props
}) {
  return /* @__PURE__ */ jsxs(
    ComboboxChip$1,
    {
      "data-slot": "combobox-chip",
      className: cn(
        "bg-muted text-foreground flex h-[calc(--spacing(5.5))] w-fit items-center justify-center gap-1 rounded-sm px-1.5 text-xs font-medium whitespace-nowrap has-data-[slot=combobox-chip-remove]:pr-0 has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50",
        className
      ),
      ...props,
      children: [
        children,
        showRemove && /* @__PURE__ */ jsx(
          ComboboxChipRemove,
          {
            render: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon-xs" }),
            className: "-ml-1 opacity-50 hover:opacity-100",
            "data-slot": "combobox-chip-remove",
            children: /* @__PURE__ */ jsx(X, { className: "pointer-events-none" })
          }
        )
      ]
    }
  );
}
function ComboboxChipsInput({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    ComboboxInput$1,
    {
      "data-slot": "combobox-chip-input",
      className: cn("min-w-16 flex-1 outline-none", className),
      ...props
    }
  );
}
function useComboboxAnchor() {
  return React.useRef(null);
}
export {
  Combobox,
  ComboboxChip,
  ComboboxChips,
  ComboboxChipsInput,
  ComboboxCollection,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxGroup,
  ComboboxInput,
  ComboboxItem,
  ComboboxLabel,
  ComboboxList,
  ComboboxSeparator,
  ComboboxTrigger,
  ComboboxValue,
  useComboboxAnchor
};
//# sourceMappingURL=combobox.js.map
