import { isNumber as w, isArray as p } from "lodash-unified";
function b(...t) {
  return t.reduce((n, r) => ({ ...n, ...r }), {});
}
function R(t, n = 0) {
  if (!t)
    return n;
  if (typeof t == "number")
    return t;
  const r = t.match(/^(-?\d+(?:\.\d+)?)px$/);
  if (!r)
    return n;
  const o = parseFloat(r[1]);
  return o > 0 ? o : n;
}
function S(t) {
  return w(t) ? String(t) : t;
}
let d = 0;
function E(t) {
  return `_${p(t) ? t.join("_") : String(t)}_${d++}`;
}
async function N(t, n, ...r) {
  for (const o of t) {
    const e = n(o);
    e && await e(...r);
  }
}
async function D(t, n, r, ...o) {
  let e = n;
  for (const c of t) {
    const s = r(c);
    if (s)
      try {
        const i = await s(e, ...o);
        i !== void 0 && (e = i);
      } catch {
      }
  }
  return e;
}
function m(t, n, r) {
  let o = {};
  if (!t.length)
    return o;
  for (const e of t)
    if (e.children?.length)
      o = {
        ...o,
        ...m(e.children, n)
      };
    else {
      const c = e.key;
      c && (o[c] = e[n] ?? r);
    }
  return o;
}
function x(t) {
  const n = [];
  for (const r of t)
    r.children?.length ? n.push(...x(r.children)) : n.push(r);
  return n;
}
const y = {
  rowDragEntireRow: !1,
  suppressMoveWhenRowDragging: !1
};
function j(t) {
  return t ? {
    ...y,
    ...t
  } : {};
}
async function k(t) {
  return typeof t == "string" ? await (await fetch(t)).arrayBuffer() : await t.arrayBuffer();
}
async function B(t, n) {
  const r = await k(t), o = await import("exceljs").catch(() => {
    throw new Error(
      `[AgGrid] exportToExcel requires exceljs.
Run: npm install exceljs`
    );
  }), e = new o.Workbook();
  await e.xlsx.load(r);
  const c = e.worksheets[0];
  if (!c) return [];
  const s = /* @__PURE__ */ new Map();
  c.getRow(1).eachCell((u, f) => {
    const a = u.address.replace(/\d+/g, ""), l = n[a];
    l && s.set(f, l);
  });
  const i = [];
  for (let u = 2; u <= c.rowCount; u++) {
    const f = c.getRow(u);
    if (f.cellCount === 0) continue;
    const a = {};
    s.forEach((l, g) => {
      const h = f.getCell(g);
      a[l] = h.value;
    }), i.push(a);
  }
  return i;
}
export {
  B as excelToDataSource,
  x as flatColumnConfig,
  j as getRowDragConfig,
  E as getShadowName,
  S as getStringKey,
  b as mergeProps,
  m as pickColumnConfig,
  R as pxToNumber,
  N as runEffectHooks,
  D as runPipelineHooks
};
