"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const normalizeInterval = require("./_lib-normalizeInterval.cjs");
const add = require("./add.cjs");
const differenceInDays = require("./differenceInDays.cjs");
const differenceInHours = require("./differenceInHours.cjs");
const differenceInMinutes = require("./differenceInMinutes.cjs");
const differenceInMonths = require("./differenceInMonths.cjs");
const differenceInSeconds = require("./differenceInSeconds.cjs");
const differenceInYears = require("./differenceInYears.cjs");
function intervalToDuration(interval, options) {
  const { start, end } = normalizeInterval.normalizeInterval(options?.in, interval);
  const duration = {};
  const years = differenceInYears.differenceInYears(end, start);
  if (years) duration.years = years;
  const remainingMonths = add.add(start, { years: duration.years });
  const months = differenceInMonths.differenceInMonths(end, remainingMonths);
  if (months) duration.months = months;
  const remainingDays = add.add(remainingMonths, { months: duration.months });
  const days = differenceInDays.differenceInDays(end, remainingDays);
  if (days) duration.days = days;
  const remainingHours = add.add(remainingDays, { days: duration.days });
  const hours = differenceInHours.differenceInHours(end, remainingHours);
  if (hours) duration.hours = hours;
  const remainingMinutes = add.add(remainingHours, { hours: duration.hours });
  const minutes = differenceInMinutes.differenceInMinutes(end, remainingMinutes);
  if (minutes) duration.minutes = minutes;
  const remainingSeconds = add.add(remainingMinutes, { minutes: duration.minutes });
  const seconds = differenceInSeconds.differenceInSeconds(end, remainingSeconds);
  if (seconds) duration.seconds = seconds;
  return duration;
}
exports.default = intervalToDuration;
exports.intervalToDuration = intervalToDuration;
//# sourceMappingURL=intervalToDuration.cjs.map
