"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/utils/index.ts
var utils_exports = {};
__export(utils_exports, {
  getCellAlign: () => getCellAlign,
  getColumnMeta: () => getColumnMeta,
  getTimeOption: () => getTimeOption,
  getTimeOptions: () => getTimeOptions,
  parseTimeOption: () => parseTimeOption,
  scrollTo: () => scrollTo
});
module.exports = __toCommonJS(utils_exports);

// src/utils/get-cell-align.ts
var getCellAlign = (type) => {
  switch (type) {
    case "number":
    case "date":
    case "time":
      return "right";
    case "string":
    case "button":
      return "left";
    default:
      return type;
  }
};

// src/utils/get-column-meta.ts
var getColumnMeta = (meta) => {
  return __spreadProps(__spreadValues({}, meta), {
    align: getCellAlign(meta.align || "left")
  });
};

// src/utils/scroll-to.ts
function scrollTo(element, targetPosition, duration) {
  const startPosition = element.scrollTop;
  const distance = targetPosition - startPosition;
  let startTime = null;
  function animation(currentTime) {
    if (startTime === null)
      startTime = currentTime;
    const timeElapsed = currentTime - startTime;
    const run = ease(timeElapsed, startPosition, distance, duration);
    element.scrollTop = run;
    if (timeElapsed < duration) {
      requestAnimationFrame(animation);
    }
  }
  function ease(t, b, c, d) {
    let [t2] = [t];
    const [b2, c2, d2] = [b, c, d];
    t2 /= d2 / 2;
    if (t2 < 1)
      return c2 / 2 * t2 * t2 + b2;
    t2--;
    return -c2 / 2 * (t2 * (t2 - 2) - 1) + b2;
  }
  requestAnimationFrame(animation);
}

// src/utils/get-time-options.ts
var getTimeOptions = () => {
  const timeOptions = [];
  for (let i = 0; i < 24; i++) {
    for (let j = 0; j < 60; j += 10) {
      timeOptions.push(`${i < 10 ? `0${i}` : i}:${j < 10 ? `0${j}` : j}`);
    }
  }
  return timeOptions;
};
var parseTimeOption = (time) => {
  if (!time)
    return { hour: 0, minute: 0 };
  const [hour, minute] = time.split(":").map((t) => parseInt(t, 10));
  return { hour, minute };
};
var getTimeOption = (time) => {
  const hour = time.getHours();
  const minute = time.getMinutes();
  return `${hour < 10 ? `0${hour}` : hour}:${minute < 10 ? `0${minute}` : minute}`;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getCellAlign,
  getColumnMeta,
  getTimeOption,
  getTimeOptions,
  parseTimeOption,
  scrollTo
});
//# sourceMappingURL=index.cjs.map