"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const duration = require("./src-duration.cjs");
const millisecond = require("./src-millisecond.cjs");
const second = require("./src-second.cjs");
const minute = require("./src-minute.cjs");
const hour = require("./src-hour.cjs");
const day = require("./src-day.cjs");
const week = require("./src-week.cjs");
const month = require("./src-month.cjs");
const year = require("./src-year.cjs");
const bisector = require("../d3-array/src-bisector.cjs");
const ticks = require("../d3-array/src-ticks.cjs");
function ticker(year2, month2, week2, day2, hour2, minute2) {
  const tickIntervals = [
    [second.second, 1, duration.durationSecond],
    [second.second, 5, 5 * duration.durationSecond],
    [second.second, 15, 15 * duration.durationSecond],
    [second.second, 30, 30 * duration.durationSecond],
    [minute2, 1, duration.durationMinute],
    [minute2, 5, 5 * duration.durationMinute],
    [minute2, 15, 15 * duration.durationMinute],
    [minute2, 30, 30 * duration.durationMinute],
    [hour2, 1, duration.durationHour],
    [hour2, 3, 3 * duration.durationHour],
    [hour2, 6, 6 * duration.durationHour],
    [hour2, 12, 12 * duration.durationHour],
    [day2, 1, duration.durationDay],
    [day2, 2, 2 * duration.durationDay],
    [week2, 1, duration.durationWeek],
    [month2, 1, duration.durationMonth],
    [month2, 3, 3 * duration.durationMonth],
    [year2, 1, duration.durationYear]
  ];
  function ticks$1(start, stop, count) {
    const reverse = stop < start;
    if (reverse) [start, stop] = [stop, start];
    const interval = count && typeof count.range === "function" ? count : tickInterval(start, stop, count);
    const ticks2 = interval ? interval.range(start, +stop + 1) : [];
    return reverse ? ticks2.reverse() : ticks2;
  }
  function tickInterval(start, stop, count) {
    const target = Math.abs(stop - start) / count;
    const i = bisector.default(([, , step2]) => step2).right(tickIntervals, target);
    if (i === tickIntervals.length) return year2.every(ticks.tickStep(start / duration.durationYear, stop / duration.durationYear, count));
    if (i === 0) return millisecond.millisecond.every(Math.max(ticks.tickStep(start, stop, count), 1));
    const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];
    return t.every(step);
  }
  return [ticks$1, tickInterval];
}
const [timeTicks, timeTickInterval] = ticker(year.timeYear, month.timeMonth, week.timeSunday, day.timeDay, hour.timeHour, minute.timeMinute);
exports.timeTickInterval = timeTickInterval;
exports.timeTicks = timeTicks;
//# sourceMappingURL=src-ticks.cjs.map
