"use client";
import { jsx as e, jsxs as p, Fragment as E } from "react/jsx-runtime";
import { forwardRef as K, useContext as N, createContext as v, useCallback as b, useRef as T } from "react";
import { CaretRightIcon as M, ArrowSquareOutIcon as H, ArrowRightIcon as _, MagnifyingGlassIcon as F } from "@phosphor-icons/react";
import { S as G } from "./surface-dhshylwccuaz91d1.js";
import { L as j } from "./loader-m5wfmqwgucrr4i5v.js";
import { c as m } from "./cn-ct4n7r74mh8y0f48.js";
import { a5 as U, a7 as O, aa as V, ac as w, a9 as $, a8 as q, ab as z, bk as B, ap as S, au as J, av as Q, aw as W } from "./vendor-base-ui-ccr5l0ynrievzzv3.js";
const C = v({});
function I({
  open: t,
  onOpenChange: n,
  onBackdropClick: a,
  children: l
}) {
  const s = (u) => {
    a ? a(u) : n(!1);
  }, c = b(() => {
    n(!1);
  }, [n]);
  return /* @__PURE__ */ e(S, { open: t, onOpenChange: n, modal: !0, children: /* @__PURE__ */ p(J, { children: [
    /* @__PURE__ */ e(
      Q,
      {
        className: "fixed inset-0 bg-kumo-overlay opacity-80 transition-all duration-150 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0",
        onClick: s
      }
    ),
    /* @__PURE__ */ e(
      G,
      {
        as: W,
        className: m(
          "fixed top-[10vh] left-1/2 w-full max-w-2xl -translate-x-1/2",
          "overflow-hidden rounded-lg",
          "duration-150 data-[ending-style]:scale-90 data-[ending-style]:opacity-0 data-[starting-style]:scale-90 data-[starting-style]:opacity-0"
        ),
        style: {
          transitionProperty: "scale, opacity",
          transitionTimingFunction: "var(--default-transition-timing-function)"
        },
        children: /* @__PURE__ */ e(C.Provider, { value: { onClose: c }, children: l })
      }
    )
  ] }) });
}
function X({
  open: t,
  onOpenChange: n,
  onBackdropClick: a,
  children: l,
  items: s,
  value: c,
  onValueChange: u,
  onItemHighlighted: i,
  itemToStringValue: o,
  filter: d,
  onSelect: r,
  getSelectableItems: f
}) {
  return /* @__PURE__ */ e(
    I,
    {
      open: t,
      onOpenChange: n,
      onBackdropClick: a,
      children: /* @__PURE__ */ e(
        L,
        {
          items: s,
          value: c,
          onValueChange: u,
          onItemHighlighted: i,
          itemToStringValue: o,
          filter: d,
          open: t,
          onSelect: r,
          getSelectableItems: f,
          children: l
        }
      )
    }
  );
}
function Y({
  children: t,
  leading: n,
  trailing: a
}) {
  return /* @__PURE__ */ p("div", { className: "flex items-center gap-3 bg-kumo-base px-4 py-3", children: [
    n ?? /* @__PURE__ */ e(
      F,
      {
        className: "h-4 w-4 text-kumo-subtle",
        weight: "bold"
      }
    ),
    t,
    a
  ] });
}
const D = K(function({ children: n, className: a }, l) {
  return /* @__PURE__ */ e(
    "div",
    {
      ref: l,
      className: m(
        "min-h-0 flex-1 overflow-y-auto rounded-b-lg bg-kumo-base px-2 py-2 ring-1 ring-kumo-line",
        a
      ),
      children: n
    }
  );
});
D.displayName = "CommandPalette.List";
function Z({
  children: t,
  className: n,
  ...a
}) {
  return /* @__PURE__ */ e(q, { className: m("space-y-0.5", n), ...a, children: t });
}
function ee({
  children: t,
  className: n
}) {
  return /* @__PURE__ */ e(
    $,
    {
      className: m(
        "mb-2 px-2 pt-1 text-xs font-semibold text-kumo-strong",
        n
      ),
      children: t
    }
  );
}
function te({
  value: t,
  disabled: n,
  children: a,
  className: l,
  onClick: s
}) {
  return /* @__PURE__ */ e(
    w,
    {
      value: t,
      disabled: n,
      onClick: s,
      className: m(
        "group flex w-full items-center gap-3 px-2 py-1.5 text-left text-base transition-colors",
        "cursor-pointer data-[highlighted]:bg-kumo-overlay",
        "rounded-lg",
        n && "cursor-default opacity-50",
        l
      ),
      children: a
    }
  );
}
function ne({ children: t }) {
  return /* @__PURE__ */ e(V, { children: /* @__PURE__ */ e("div", { className: "p-8 text-center", children: /* @__PURE__ */ e("p", { className: "text-kumo-strong", children: t ?? "No results found" }) }) });
}
function ae({ children: t }) {
  return /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: t ?? /* @__PURE__ */ e(j, { size: 24 }) });
}
function oe({ children: t }) {
  return /* @__PURE__ */ e("div", { className: "flex items-center justify-between rounded-b-lg bg-kumo-elevated px-4 py-3 text-xs text-kumo-strong", children: t });
}
function y({
  text: t,
  highlights: n,
  className: a
}) {
  if (!n || n.length === 0)
    return /* @__PURE__ */ e("span", { className: a, children: t });
  const l = [...n].sort((i, o) => i[0] - o[0]), s = [];
  for (const i of l) {
    const o = s[s.length - 1];
    o && i[0] <= o[1] + 1 ? o[1] = Math.max(o[1], i[1]) : s.push([...i]);
  }
  const c = [];
  let u = 0;
  return s.forEach((i, o) => {
    const [d, r] = i;
    d > u && c.push(/* @__PURE__ */ e("span", { children: t.slice(u, d) }, `text-${o}`)), c.push(
      /* @__PURE__ */ e(
        "mark",
        {
          className: "rounded-sm bg-kumo-warning/50 text-kumo-default",
          children: t.slice(d, r + 1)
        },
        `highlight-${o}`
      )
    ), u = r + 1;
  }), u < t.length && c.push(/* @__PURE__ */ e("span", { children: t.slice(u) }, "text-end")), /* @__PURE__ */ e("span", { className: a, children: c });
}
function se({
  title: t,
  breadcrumbs: n,
  titleHighlights: a,
  breadcrumbHighlights: l,
  description: s,
  icon: c,
  value: u,
  onClick: i,
  showArrow: o = !0,
  external: d = !1,
  nonInteractive: r = !1
}) {
  return /* @__PURE__ */ p(
    w,
    {
      value: u,
      onClick: r ? void 0 : (f) => i(f),
      className: m(
        "group flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition-colors",
        r ? "cursor-default" : "cursor-pointer data-[highlighted]:bg-kumo-overlay"
      ),
      children: [
        c && /* @__PURE__ */ e("div", { className: "flex flex-shrink-0 items-center text-kumo-subtle", children: c }),
        /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ p("div", { className: "flex items-center gap-2 truncate", children: [
          n?.map((f, g) => /* @__PURE__ */ p("span", { className: "flex items-center gap-2", children: [
            /* @__PURE__ */ e(
              y,
              {
                text: f,
                highlights: l?.[g],
                className: "text-base text-kumo-default"
              }
            ),
            /* @__PURE__ */ e(
              M,
              {
                className: "h-3 w-3 flex-shrink-0 text-kumo-subtle",
                weight: "bold"
              }
            )
          ] }, g)),
          /* @__PURE__ */ e(
            y,
            {
              text: t,
              highlights: a,
              className: "text-base text-kumo-default"
            }
          ),
          d && /* @__PURE__ */ e(H, { className: "h-3.5 w-3.5 flex-shrink-0 text-kumo-subtle" }),
          s && /* @__PURE__ */ p(E, { children: [
            /* @__PURE__ */ e("span", { className: "text-kumo-strong", children: "—" }),
            /* @__PURE__ */ e("span", { className: "truncate text-sm text-kumo-strong", children: s })
          ] })
        ] }) }),
        o && !d && !r && /* @__PURE__ */ e(_, { className: "h-4 w-4 flex-shrink-0 text-kumo-subtle opacity-0 transition-opacity group-data-[highlighted]:opacity-100" })
      ]
    }
  );
}
function re({
  children: t,
  className: n
}) {
  return /* @__PURE__ */ e(
    "div",
    {
      className: m(
        "flex max-h-[60vh] flex-col overflow-hidden rounded-lg bg-kumo-elevated",
        n
      ),
      children: t
    }
  );
}
const A = v({}), le = () => !0;
function L({
  children: t,
  items: n,
  value: a,
  onValueChange: l,
  onItemHighlighted: s,
  itemToStringValue: c,
  filter: u = le,
  open: i = !0,
  className: o,
  onSelect: d,
  getSelectableItems: r
}) {
  const f = T(-1), g = b(
    (h, x) => {
      f.current = x.index, s?.(h, x);
    },
    [s]
  ), P = b(
    (h) => {
      const x = h.key === "Enter", R = h.metaKey || h.ctrlKey;
      if (x && R && d && r) {
        const k = r(n)[f.current];
        k !== void 0 && (h.preventDefault(), d(k, { newTab: !0 }));
      }
    },
    [n, d, r]
  );
  return /* @__PURE__ */ e(re, { className: o, children: /* @__PURE__ */ e(
    B,
    {
      items: n,
      value: a,
      onValueChange: l,
      onItemHighlighted: g,
      itemToStringValue: c,
      filter: u,
      autoHighlight: "always",
      keepHighlight: !0,
      open: i,
      children: /* @__PURE__ */ e(A.Provider, { value: { onInputKeyDown: P }, children: t })
    }
  ) });
}
function ie({
  autoFocus: t = !0,
  placeholder: n,
  className: a,
  onKeyDown: l,
  leading: s,
  trailing: c,
  ...u
}) {
  const { onInputKeyDown: i } = N(A), { onClose: o } = N(C), d = b(
    (r) => {
      if (l?.(r), !r.defaultPrevented) {
        if (r.key === "Escape" && o) {
          r.preventDefault(), o();
          return;
        }
        i?.(r);
      }
    },
    [i, l, o]
  );
  return /* @__PURE__ */ e(Y, { leading: s, trailing: c, children: /* @__PURE__ */ e(
    z,
    {
      placeholder: n,
      className: m(
        "flex-1 border-none bg-transparent text-base kumo-input-placeholder",
        "outline-none focus-visible:outline-none",
        a
      ),
      onKeyDown: d,
      autoFocus: t,
      ...u
    }
  ) });
}
function ce({
  children: t,
  className: n
}) {
  return /* @__PURE__ */ e(O, { className: m("space-y-3", n), children: t });
}
const ue = U, ye = {}, ke = {}, Ne = {
  /** Modal dialog wrapper - use with Panel for content that can swap */
  Dialog: I,
  /** Dialog + Panel combined - for simple single-view command palettes */
  Root: X,
  /** Autocomplete panel without dialog - use inside Dialog for swappable content */
  Panel: L,
  /** Input for use inside Panel */
  Input: ie,
  /** Scrollable results container */
  List: D,
  /** Category grouping */
  Group: Z,
  /** Section header text */
  GroupLabel: ee,
  /** Basic item */
  Item: te,
  /** Rich item with breadcrumbs, highlights, icons */
  ResultItem: se,
  /** Text with highlighted portions */
  HighlightedText: y,
  /** Empty state */
  Empty: ne,
  /** Loading state */
  Loading: ae,
  /** Footer for keyboard hints */
  Footer: oe,
  /** Render prop iterator for groups */
  Results: ce,
  /** Render prop iterator for items within a group */
  Items: ue
};
export {
  Ne as C,
  ye as K,
  ke as a
};
//# sourceMappingURL=command-palette-b31nq4wk7o7gx4sa.js.map
