import { C as A, L as D, g as M, h as N, i as T, s as O } from "./aggregator-BpQMir30.js";
import { J as P, K as C, A as _, E as v, o as H, H as B, L as K, B as L, k as w, N as z, O as F, Q as R, R as U, M as V, U as X, f as I, W, G as Z, F as $, V as G, X as J } from "./Toggle-3WohopP9.js";
import { K as Q } from "./Keyboard-BpXlLck_.js";
import { j as t } from "./jsx-runtime-B6kdoens.js";
import { useState as q, useEffect as Y, useCallback as ee } from "react";
import { P as g } from "./Pack-l3j3YWpE.js";
import { A as se } from "./Animated-BRUqvVsW.js";
import { C as y } from "./css-CiSR0WsA.js";
import { L as te } from "./List-BI_89AyO.js";
const le = [], ne = ({
  data: e,
  emptyContent: s,
  value: l,
  onChange: n,
  allowMultiple: i,
  allowNone: c,
  hideColumnHeader: r = !1,
  columns: h = le,
  visible: m,
  itemHeight: u = C.itemHeight,
  listItem: f = B(C.Item),
  replaceOnSingle: o,
  omit: b,
  autoSelectOnNone: S,
  trigger: k,
  extraDialogContent: j,
  variant: d = "connected",
  ...x
}) => {
  let p = /* @__PURE__ */ t.jsxs(P, { disabled: !m, children: [
    j,
    /* @__PURE__ */ t.jsx(
      C.Header,
      {
        hide: r || f != null,
        columns: h,
        children: /* @__PURE__ */ t.jsx(_.Virtual, { itemHeight: u, children: f })
      }
    )
  ] });
  return d !== "connected" && (p = /* @__PURE__ */ t.jsx(
    g,
    {
      direction: "y",
      borderShade: 4,
      className: y.B("select-dialog-content"),
      children: p
    }
  )), /* @__PURE__ */ t.jsx(te, { data: e, emptyContent: s, omit: b, children: /* @__PURE__ */ t.jsx(
    v,
    {
      value: l,
      onChange: n,
      allowMultiple: i,
      allowNone: c,
      replaceOnSingle: o,
      autoSelectOnNone: S,
      children: /* @__PURE__ */ t.jsxs(
        H,
        {
          visible: m,
          className: y.B("select"),
          keepMounted: !1,
          variant: d,
          ...x,
          children: [
            k,
            p
          ]
        }
      )
    }
  ) });
}, oe = ({
  children: e = re,
  value: s,
  onChange: l,
  entryRenderKey: n = "key",
  allowNone: i = !1,
  allowMultiple: c = !1,
  data: r,
  replaceOnSingle: h,
  className: m,
  ...u
}) => {
  const { onSelect: f } = K({
    allowMultiple: c,
    allowNone: i,
    replaceOnSingle: h,
    data: r,
    value: s,
    onChange: l
  });
  return /* @__PURE__ */ t.jsx(
    g,
    {
      borderShade: 4,
      className: y(y.B("select-button"), m),
      ...u,
      children: r.map((o) => e({
        key: o.key,
        onClick: () => f(o.key),
        selected: o.key === s,
        entry: o,
        title: o[n]
      }))
    }
  );
}, re = ({
  entry: e,
  onClick: s,
  selected: l,
  title: n
}) => /* @__PURE__ */ t.jsx(
  L,
  {
    onClick: s,
    variant: l ? "filled" : "outlined",
    children: n
  },
  e.key
), ae = ({
  selected: e,
  renderKey: s,
  toggle: l,
  visible: n,
  children: i,
  ...c
}) => /* @__PURE__ */ t.jsx(
  L,
  {
    className: y.B("select-dropdown-button"),
    onClick: l,
    variant: "outlined",
    endIcon: /* @__PURE__ */ t.jsx(se, { enabledLoc: "bottom", disabledLoc: "left", enabled: n }),
    ...c,
    children: i ?? (e == null ? void 0 : e[s])
  }
), ie = B(ae), xe = ({
  data: e,
  value: s,
  columns: l = [],
  children: n = ie,
  entryRenderKey: i = "key",
  allowNone: c = !1,
  onChange: r,
  disabled: h,
  hideColumnHeader: m = !0,
  variant: u,
  dropdownVariant: f,
  ...o
}) => {
  const { close: b, visible: S, toggle: k } = w(), [j, d] = q(
    (e == null ? void 0 : e.find((a) => a.key === s)) ?? null
  );
  Y(() => {
    d((e == null ? void 0 : e.find((a) => a.key === s)) ?? null);
  }, [e, s]);
  const x = ee(
    (a, E) => {
      if (!(Array.isArray(a) || a === null)) {
        if (b(), a == null)
          return d(null), r(s);
        d(E.entries[0]), r(a);
      }
    },
    [r, s, b, d]
  ), p = {
    selected: j,
    renderKey: i,
    toggle: k,
    visible: S
  };
  return u != null && (p.variant = u), /* @__PURE__ */ t.jsx(
    ne,
    {
      close: b,
      data: e,
      visible: S,
      value: s,
      onChange: x,
      allowMultiple: !1,
      allowNone: c,
      columns: l,
      hideColumnHeader: m,
      variant: f,
      trigger: /* @__PURE__ */ t.jsx(t.Fragment, { children: n(p) }),
      ...o
    }
  );
}, ce = [
  {
    key: "h2",
    label: "XL"
  },
  {
    key: "h3",
    label: "L"
  },
  {
    key: "h4",
    label: "M"
  },
  {
    key: "p",
    label: "S"
  },
  {
    key: "small",
    label: "XS"
  }
], de = ({
  key: e,
  entry: s,
  onClick: l,
  selected: n
}) => /* @__PURE__ */ t.jsx(
  L,
  {
    variant: n ? "filled" : "outlined",
    onClick: l,
    children: s.label
  },
  e
), me = ({
  children: e = de,
  ...s
}) => /* @__PURE__ */ t.jsx(oe, { ...s, data: ce, children: e }), Ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  ComponentSizeLevels: A,
  CoreDateTime: z,
  DateTime: F,
  Editable: R,
  Keyboard: Q,
  LEVELS: D,
  LevelComponentSizes: M,
  Link: U,
  MaybeEditable: V,
  SelectLevel: me,
  Symbols: X,
  Text: I,
  WithIcon: W,
  asyncEdit: Z,
  dimensions: N,
  edit: $,
  evalColor: G,
  formatChildren: J,
  levelZ: T,
  specZ: O
}, Symbol.toStringTag, { value: "Module" }));
export {
  oe as B,
  ne as C,
  xe as D,
  me as S,
  ae as a,
  ie as d,
  Ce as e
};
