import { useMemo } from "react";
var __read = globalThis && globalThis.__read || function(o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m)
    return o;
  var i = m.call(o), r, ar = [], e;
  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
      ar.push(r.value);
  } catch (error) {
    e = { error };
  } finally {
    try {
      if (r && !r.done && (m = i["return"]))
        m.call(i);
    } finally {
      if (e)
        throw e.error;
    }
  }
  return ar;
};
var __spreadArray = globalThis && globalThis.__spreadArray || function(to, from, pack) {
  if (pack || arguments.length === 2)
    for (var i = 0, l = from.length, ar; i < l; i++) {
      if (ar || !(i in from)) {
        if (!ar)
          ar = Array.prototype.slice.call(from, 0, i);
        ar[i] = from[i];
      }
    }
  return to.concat(ar || Array.prototype.slice.call(from));
};
function useStickyOffsets(columns) {
  var colWidths = columns.map(function(c) {
    return c.width;
  });
  var colFixed = columns.map(function(c) {
    return c.fixed;
  });
  var stickyOffsets = useMemo(function() {
    return columns.map(function(column) {
      var offset = 0;
      if (column.fixed === "left") {
        columns.some(function(col) {
          if (col.fixed === "left") {
            if (col.key === column.key) {
              return true;
            }
            var colWidth = col.$$isOperation ? col.width || 40 : col.width;
            offset += colWidth;
            return false;
          }
          return false;
        });
      }
      if (column.fixed === "right") {
        __spreadArray([], __read(columns), false).reverse().some(function(col) {
          if (col.fixed === "right") {
            if (col.key === column.key) {
              return true;
            }
            var colWidth = col.$$isOperation ? col.width || 40 : col.width;
            offset += colWidth;
            return false;
          }
          return false;
        });
      }
      return offset;
    });
  }, [colWidths.join("-"), colFixed.join("-")]);
  return stickyOffsets;
}
export {
  useStickyOffsets as default
};
//# sourceMappingURL=useStickyOffsets.js.map
