import { ak as i, ac as a, b6 as s } from "./index-691eb34d.js";
import { isArray as u, isPlainObject as l, isBoolean as f, isFunction as d } from "lodash-es";
function O(t) {
  const e = {};
  if (t && t.authorization) {
    const { mode: n, value: o } = t.authorization;
    if (n)
      switch (e.headers = {}, n) {
        case "bearer":
          e.headers.Authorization = `Bearer ${o || "not defined"}`;
          break;
        case "{bearer}":
          i.accessToken ? e.headers.Authorization = `Bearer ${i.accessToken || "not defined"}` : console.warn("Must define an accessToken in kapixContext");
          break;
      }
  }
  return e;
}
function j(t, e) {
  const n = g(t, e), o = {
    color: C(t, e),
    background: k(t, e),
    ...h(t, e)
  };
  return {
    ...t,
    label: n,
    value: m(t, e),
    normalizedLabel: n && n.toString().toLowerCase(),
    prependIcon: b(t, e),
    prependComponent: I(t, e),
    icon: x(t, e),
    iconClass: P(t, e),
    className: T(t, e),
    subtitle: S(t, e),
    disabled: v(t, e),
    tooltip: y(t, e),
    style: Object.entries(o).filter(([, c]) => c !== void 0).length ? o : void 0
  };
}
function g(t, e) {
  const { itemText: n = "label" } = e;
  if (n)
    if (u(n)) {
      let o;
      return n.forEach((c) => {
        o == null && (o = r(t, c));
      }), o;
    } else
      return r(t, n);
  return t;
}
function m(t, e) {
  const { itemValue: n = "value", returnObject: o } = e;
  return n && !o ? r(t, n) : t;
}
function b(t, e) {
  const { itemPrependIcon: n } = e;
  return r(t, n);
}
function I(t, e) {
  const { itemPrependComponent: n } = e;
  return r(t, n);
}
function C(t, e) {
  const { itemColor: n = "color" } = e;
  return r(t, n);
}
function k(t, e) {
  const { itemBackgroundColor: n = "background" } = e, o = r(t, n);
  return o && a(o);
}
function x(t, e) {
  const { itemIcon: n = "icon" } = e;
  return r(t, n);
}
function P(t, e) {
  const { itemIconClass: n } = e;
  return r(t, n);
}
function T(t, e) {
  const { itemClass: n } = e;
  return r(t, n);
}
function h(t, e) {
  const { itemStyle: n = "style" } = e;
  return r(t, n);
}
function v(t, e) {
  const { itemDisabled: n } = e;
  return r(t, n);
}
function y(t, e) {
  const { itemTooltip: n = "tooltip" } = e, o = r(t, n);
  return o && (l(o) ? o : { content: o, placement: "left" });
}
function S(t, e) {
  const { itemSubtitle: n = "description" } = e;
  return r(t, n);
}
function r(t, e) {
  if (e)
    return f(e) ? e : d(e) ? e(t) : s(t, e);
}
export {
  r as a,
  O as e,
  m as g,
  j as t
};
