import { initRange } from "./init.js";
import continuous, { copy } from "./continuous.js";
import nice from "./nice.js";
import { second } from "../../d3-time/src/second.js";
import { timeMinute } from "../../d3-time/src/minute.js";
import { timeHour } from "../../d3-time/src/hour.js";
import { timeDay } from "../../d3-time/src/day.js";
import { timeSunday } from "../../d3-time/src/week.js";
import { timeMonth } from "../../d3-time/src/month.js";
import { timeYear } from "../../d3-time/src/year.js";
import { timeTickInterval, timeTicks } from "../../d3-time/src/ticks.js";
import { timeFormat } from "../../d3-time-format/src/defaultLocale.js";
function date(e) {
	return new Date(e);
}
function number(e) {
	return e instanceof Date ? +e : +/* @__PURE__ */ new Date(+e);
}
function calendar(e, s, c, l, u, d, f, p, m, h) {
	var g = continuous(), _ = g.invert, v = g.domain, y = h(".%L"), b = h(":%S"), x = h("%I:%M"), S = h("%I %p"), C = h("%a %d"), w = h("%b %d"), T = h("%B"), E = h("%Y");
	function D(e) {
		return (m(e) < e ? y : p(e) < e ? b : f(e) < e ? x : d(e) < e ? S : l(e) < e ? u(e) < e ? C : w : c(e) < e ? T : E)(e);
	}
	return g.invert = function(e) {
		return new Date(_(e));
	}, g.domain = function(e) {
		return arguments.length ? v(Array.from(e, number)) : v().map(date);
	}, g.ticks = function(a) {
		var o = v();
		return e(o[0], o[o.length - 1], a ?? 10);
	}, g.tickFormat = function(e, a) {
		return a == null ? D : h(a);
	}, g.nice = function(e) {
		var a = v();
		return (!e || typeof e.range != "function") && (e = s(a[0], a[a.length - 1], e ?? 10)), e ? v(nice(a, e)) : g;
	}, g.copy = function() {
		return copy(g, calendar(e, s, c, l, u, d, f, p, m, h));
	}, g;
}
function time() {
	return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute, second, timeFormat).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
export { time as default };
