"use client";
import { jsx as e, jsxs as m } from "react/jsx-runtime";
import { CheckIcon as T, XIcon as C, CaretDownIcon as N } from "@phosphor-icons/react";
import { createContext as E, useContext as g, Fragment as V } from "react";
import { i as p, K as P } from "./input-ckl5misj0jd9cu5r.js";
import { F as j } from "./field-bmglk138wa8bf3ei.js";
import { u as F } from "./portal-provider-hwmkdmkpvct0cb76.js";
import { c as r } from "./vendor-styling-ofvnbcuht98q88oo.js";
import { a6 as G, a7 as h, a8 as x, a9 as f, aa as L, ab as M, ac as _, ad as A, ae as K, af as O, ag as b, ah as U, ai as W, aj as B, ak as D, al as H, am as X, an as q, ao as J, ap as Q } from "./vendor-base-ui-elpbzr8xeffrz4h2.js";
P.size;
const u = E({ size: "base", hasError: !1 });
function y({
  label: o,
  required: a,
  labelTooltip: i,
  description: s,
  error: t,
  children: n,
  size: d = "base",
  ...l
}) {
  const c = /* @__PURE__ */ e(u.Provider, { value: { size: d, hasError: !!t }, children: /* @__PURE__ */ e(M, { ...l, children: n }) });
  return o ? /* @__PURE__ */ e(
    j,
    {
      label: o,
      required: a,
      labelTooltip: i,
      description: s,
      error: t ? typeof t == "string" ? { message: t, match: !0 } : t : void 0,
      children: c
    }
  ) : c;
}
function k({
  children: o,
  className: a,
  align: i = "start",
  sideOffset: s = 4,
  alignOffset: t,
  side: n,
  container: d
}) {
  const l = F();
  return /* @__PURE__ */ e(q, { container: d ?? l ?? void 0, children: /* @__PURE__ */ e(
    J,
    {
      className: "",
      align: i,
      sideOffset: s,
      alignOffset: t,
      side: n,
      children: /* @__PURE__ */ e(
        Q,
        {
          className: r(
            "flex flex-col",
            // flexbox layout for sticky input + scrollable list
            "max-h-[min(var(--available-height),24rem)] max-w-(--available-width) min-w-(--anchor-width) py-1.5",
            "bg-kumo-base text-kumo-default",
            // background
            "rounded-lg shadow-lg ring ring-kumo-line",
            // border part
            a
          ),
          children: o
        }
      )
    }
  ) });
}
const Y = {
  xs: { padding: "pr-5", iconSize: 12, iconRight: "right-1" },
  sm: { padding: "pr-6", iconSize: 14, iconRight: "right-1.5" },
  base: { padding: "pr-8", iconSize: 16, iconRight: "right-2" },
  lg: { padding: "pr-10", iconSize: 18, iconRight: "right-3" }
};
function v({
  className: o,
  ...a
}) {
  const { size: i, hasError: s } = g(u), t = Y[i];
  return /* @__PURE__ */ m(
    f,
    {
      "data-kumo-component": "Combobox",
      "data-kumo-part": "trigger",
      className: r(
        p({ size: i, variant: s ? "error" : "default" }),
        "relative flex items-center",
        "data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed",
        "data-[placeholder]:text-kumo-placeholder",
        t.padding,
        o
      ),
      children: [
        /* @__PURE__ */ e(x, { ...a }),
        /* @__PURE__ */ e(
          h,
          {
            className: r(
              "absolute top-1/2 -translate-y-1/2 flex items-center text-kumo-subtle",
              t.iconRight
            ),
            children: /* @__PURE__ */ e(N, { size: t.iconSize, className: "fill-current" })
          }
        )
      ]
    }
  );
}
const Z = {
  xs: {
    padding: "pr-7",
    iconSize: 12,
    clearRight: "right-5",
    caretRight: "right-1"
  },
  sm: {
    padding: "pr-9",
    iconSize: 14,
    clearRight: "right-6",
    caretRight: "right-1.5"
  },
  base: {
    padding: "pr-12",
    iconSize: 16,
    clearRight: "right-8",
    caretRight: "right-2"
  },
  lg: {
    padding: "pr-14",
    iconSize: 18,
    clearRight: "right-9",
    caretRight: "right-3"
  }
};
function z({
  clearLabel: o = "Clear selection",
  showOptionsLabel: a = "Show options",
  ...i
}) {
  const { size: s, hasError: t } = g(u), n = Z[s];
  return /* @__PURE__ */ m(
    "div",
    {
      className: r(
        "relative inline-block w-full max-w-xs",
        "has-[:disabled]:opacity-50 has-[:disabled]:cursor-not-allowed",
        i.className
      ),
      children: [
        /* @__PURE__ */ e(
          b,
          {
            ...i,
            className: r(
              p({ size: s, variant: t ? "error" : "default" }),
              "w-full",
              n.padding,
              "disabled:cursor-not-allowed"
            )
          }
        ),
        /* @__PURE__ */ e(
          X,
          {
            "data-kumo-component": "Combobox",
            "data-kumo-part": "clear",
            "aria-label": o,
            className: r(
              "absolute top-1/2 flex -translate-y-1/2 cursor-pointer bg-transparent p-0",
              "data-[disabled]:pointer-events-none data-[disabled]:opacity-0",
              n.clearRight
            ),
            children: /* @__PURE__ */ e(C, { size: n.iconSize })
          }
        ),
        /* @__PURE__ */ e(
          f,
          {
            "data-kumo-component": "Combobox",
            "data-kumo-part": "trigger",
            "aria-label": a,
            className: r(
              "absolute top-1/2 -translate-y-1/2 flex items-center justify-center cursor-pointer text-kumo-subtle",
              "m-0 bg-transparent p-0",
              // Reset Stratus global button styles
              n.caretRight
            ),
            children: /* @__PURE__ */ e(h, { className: "flex items-center", children: /* @__PURE__ */ e(N, { size: n.iconSize, className: "fill-current" }) })
          }
        )
      ]
    }
  );
}
function R({
  children: o,
  className: a,
  ...i
}) {
  return /* @__PURE__ */ m(
    U,
    {
      "data-kumo-component": "Combobox",
      "data-kumo-part": "item",
      ...i,
      className: r(
        "group mx-1.5 grid grid-cols-[1fr_16px] gap-2 rounded px-2 py-1.5 text-base",
        "cursor-pointer data-highlighted:bg-kumo-tint",
        // Disabled rows: muted text, no pointer, suppress highlight bg even
        // when keyboard nav lands on them. Base UI sets `data-disabled` on
        // the element when the `disabled` prop is true.
        "data-[disabled]:cursor-not-allowed data-[disabled]:text-kumo-subtle data-[disabled]:opacity-60 data-[disabled]:data-highlighted:bg-transparent",
        a
      ),
      children: [
        /* @__PURE__ */ e("div", { className: "col-start-1", children: o }),
        /* @__PURE__ */ e(W, { className: "col-start-2 flex items-center", children: /* @__PURE__ */ e(T, {}) })
      ]
    }
  );
}
function $(o) {
  return /* @__PURE__ */ e(
    O,
    {
      ...o,
      className: r(
        "mx-1.5 shrink-0 px-4 py-2 text-[0.925rem] leading-4 text-kumo-subtle empty:m-0 empty:p-0"
      ),
      children: o.children ?? "No labels found."
    }
  );
}
function ee(o) {
  return /* @__PURE__ */ e(
    b,
    {
      ...o,
      className: r(
        p(),
        "mx-1.5 w-[calc(100%-0.75rem)] shrink-0 first:mb-2",
        o.className
      )
    }
  );
}
function oe({
  className: o,
  ...a
}) {
  return /* @__PURE__ */ e(
    _,
    {
      ...a,
      className: r(
        "min-h-0 flex-1 overflow-y-auto overscroll-contain scroll-pt-2 scroll-pb-2",
        o
      )
    }
  );
}
function ae(o) {
  return /* @__PURE__ */ e(
    K,
    {
      ...o,
      className: r(
        "mx-1.5 px-2 py-1.5 text-sm text-kumo-subtle",
        o.className
      )
    }
  );
}
function te(o) {
  return /* @__PURE__ */ e(
    A,
    {
      ...o,
      className: "border-t border-kumo-hairline mt-2 pt-2 first:border-t-0 first:mt-0 first:pt-0"
    }
  );
}
function w({
  removeLabel: o = "Remove",
  ...a
}) {
  return /* @__PURE__ */ m(
    B,
    {
      ...a,
      className: r(
        "flex items-center gap-2.5",
        // Layout
        "h-6 pl-2 pr-[3px]",
        // Dimensions
        "rounded-sm ring-1 ring-kumo-hairline",
        // Border
        "bg-kumo-overlay",
        // Background
        "text-sm"
        // Typography
      ),
      children: [
        a.children,
        /* @__PURE__ */ e(
          D,
          {
            "data-kumo-component": "Combobox",
            "data-kumo-part": "chip-remove",
            "aria-label": o,
            className: r(
              "cursor-pointer rounded-md p-1 hover:bg-kumo-fill-hover",
              "bg-transparent flex"
            ),
            children: /* @__PURE__ */ e(C, { size: 10 })
          }
        )
      ]
    }
  );
}
const re = {
  xs: "min-h-5",
  sm: "min-h-6.5",
  base: "min-h-9",
  lg: "min-h-10"
};
function I({
  placeholder: o,
  renderItem: a,
  className: i,
  inputSide: s = "right",
  value: t
}) {
  const { size: n, hasError: d } = g(u), l = t;
  return /* @__PURE__ */ m(
    H,
    {
      className: r(
        p({ size: n, variant: d ? "error" : "default" }),
        "flex flex-col",
        "gap-1 py-1 px-1.5",
        re[n],
        "h-auto",
        "data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed",
        i
      ),
      children: [
        s === "top" && /* @__PURE__ */ e(
          b,
          {
            placeholder: o,
            className: "w-full px-2 py-1 border-0 bg-inherit"
          }
        ),
        /* @__PURE__ */ m("div", { className: "flex items-center flex-wrap gap-1.5 flex-1", children: [
          l !== void 0 && l.length > 0 && l.map((c) => a(c)),
          /* @__PURE__ */ e(x, { children: (c) => l !== void 0 ? null : /* @__PURE__ */ e(V, { children: c.map((S) => a(S)) }) }),
          s === "right" && /* @__PURE__ */ e(
            b,
            {
              placeholder: o,
              className: "min-w-[100px] flex-1 px-2 py-1 border-0 bg-inherit"
            }
          )
        ] })
      ]
    }
  );
}
y.displayName = "Combobox.Root";
k.displayName = "Combobox.Content";
v.displayName = "Combobox.TriggerValue";
z.displayName = "Combobox.TriggerInput";
R.displayName = "Combobox.Item";
w.displayName = "Combobox.Chip";
I.displayName = "Combobox.TriggerMultipleWithInput";
const pe = Object.assign(y, {
  // Helper components
  Content: k,
  TriggerValue: v,
  TriggerInput: z,
  TriggerMultipleWithInput: I,
  // Slightly modified BaseUI
  Chip: w,
  Item: R,
  // Styled BaseUI
  Input: ee,
  Empty: $,
  GroupLabel: ae,
  Group: te,
  // Styled BaseUI
  List: oe,
  // BaseUI
  Collection: L,
  Trigger: f,
  Value: x,
  Icon: h,
  // Filtering
  useFilter: G
});
export {
  pe as C
};
//# sourceMappingURL=combobox-hc9wi9nwsyyli8ur.js.map
