import { c as P } from "./index-C0QCq-hK.js";
import { aX as s, aT as c, r as l } from "./start-CE9SawgU.js";
import "vue";
import "vue-i18n";
import "pinia";
import "./header-Bn1EKnBE.js";
import { E as u } from "./constants-3JiawOc1.js";
const A = ({
  tableOptions: e,
  data: r,
  readonly: n,
  createTitle: t,
  tableName: o,
  t: i
}) => ({
  ...e,
  readonly: n,
  tableName: o || i(e.tableName),
  columns: e.columns.map((a) => ({
    ...a,
    header: i(a.header)
  })),
  data: r ?? [],
  createActions: [{ title: i(t), icon: "lucide:plus" }]
}), T = (e) => {
  const r = P(e ?? {});
  return {
    ...r,
    bulkAndPromotionPrices: (r.bulkAndPromotionPrices ?? []).map(
      ({ validFrom: n, validTo: t, ...o }) => ({
        ...o,
        validFrom: s(n),
        validTo: s(t)
      })
    )
  };
}, k = (e) => {
  const r = P(e ?? {});
  return {
    ...r,
    bulkAndPromotionPrices: (r.bulkAndPromotionPrices ?? []).map(
      ({ validFrom: n, validTo: t, ...o }) => ({
        ...o,
        validFrom: c(`${n} 00:00:00`),
        validTo: c(`${t} 23:59:59`)
      })
    )
  };
}, p = (e, r) => {
  let n = !0;
  return [
    { startQuantity: 0, price: e.basePrice },
    ...e.bulkAndPromotionPrices.filter(({ validFrom: t, validTo: o }) => !t || t <= r && o >= r ? (n = n && !t, !0) : !1).filter(({ validFrom: t }) => n || t)
  ];
}, d = (e, r = l({ hour: 0 }).valueOf() / 1e3) => {
  const n = p(e, r);
  return n.length ? n.reduce(
    ([t, o], { price: { price: i } }) => [
      Math.min(t, i),
      Math.max(o, i)
    ],
    [1 / 0, -1 / 0]
  ) : [-1, 0];
}, m = (e, r = 2) => typeof e != "number" ? u : e.toFixed(r), R = (e, r, n) => {
  const [t, o] = d(e, n);
  return t < 0 ? "-" : `${m(t, r)} - ${m(o, r)}`;
};
export {
  A as a,
  k as b,
  T as c,
  p as g,
  m as p,
  R as s
};
