@storm-software/config-tools
Version:
A package containing various utilities to support custom workspace configurations and environment management for Storm Software projects, including configuration file handling, environment variable management, and logging utilities.
944 lines (886 loc) • 32.7 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
var _chunkL4YHJZ6Qcjs = require('./chunk-L4YHJZ6Q.cjs');
var _chunkLOY6ICHZcjs = require('./chunk-LOY6ICHZ.cjs');
var _chunkEC2KPWRGcjs = require('./chunk-EC2KPWRG.cjs');
var _chunkBN6MEGGYcjs = require('./chunk-BN6MEGGY.cjs');
var _chunkJWLDCEBZcjs = require('./chunk-JWLDCEBZ.cjs');
var _chunk7QBTVNMRcjs = require('./chunk-7QBTVNMR.cjs');
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constants.js
var daysInYear = 365.2425;
var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
var minTime = -maxTime;
var minutesInMonth = 43200;
var minutesInDay = 1440;
var secondsInHour = 3600;
var secondsInDay = secondsInHour * 24;
var secondsInWeek = secondsInDay * 7;
var secondsInYear = secondsInDay * daysInYear;
var secondsInMonth = secondsInYear / 12;
var secondsInQuarter = secondsInMonth * 3;
var constructFromSymbol = Symbol.for("constructDateFrom");
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constructFrom.js
function constructFrom(date, value) {
if (typeof date === "function") return date(value);
if (date && typeof date === "object" && constructFromSymbol in date)
return date[constructFromSymbol](value);
if (date instanceof Date) return new date.constructor(value);
return new Date(value);
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constructNow.js
function constructNow(date) {
return constructFrom(date, Date.now());
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
var formatDistanceLocale = {
lessThanXSeconds: {
one: "less than a second",
other: "less than {{count}} seconds"
},
xSeconds: {
one: "1 second",
other: "{{count}} seconds"
},
halfAMinute: "half a minute",
lessThanXMinutes: {
one: "less than a minute",
other: "less than {{count}} minutes"
},
xMinutes: {
one: "1 minute",
other: "{{count}} minutes"
},
aboutXHours: {
one: "about 1 hour",
other: "about {{count}} hours"
},
xHours: {
one: "1 hour",
other: "{{count}} hours"
},
xDays: {
one: "1 day",
other: "{{count}} days"
},
aboutXWeeks: {
one: "about 1 week",
other: "about {{count}} weeks"
},
xWeeks: {
one: "1 week",
other: "{{count}} weeks"
},
aboutXMonths: {
one: "about 1 month",
other: "about {{count}} months"
},
xMonths: {
one: "1 month",
other: "{{count}} months"
},
aboutXYears: {
one: "about 1 year",
other: "about {{count}} years"
},
xYears: {
one: "1 year",
other: "{{count}} years"
},
overXYears: {
one: "over 1 year",
other: "over {{count}} years"
},
almostXYears: {
one: "almost 1 year",
other: "almost {{count}} years"
}
};
var formatDistance = (token, count, options) => {
let result;
const tokenValue = formatDistanceLocale[token];
if (typeof tokenValue === "string") {
result = tokenValue;
} else if (count === 1) {
result = tokenValue.one;
} else {
result = tokenValue.other.replace("{{count}}", count.toString());
}
if (_optionalChain([options, 'optionalAccess', _2 => _2.addSuffix])) {
if (options.comparison && options.comparison > 0) {
return "in " + result;
} else {
return result + " ago";
}
}
return result;
};
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
function buildFormatLongFn(args) {
return (options = {}) => {
const width = options.width ? String(options.width) : args.defaultWidth;
const format = args.formats[width] || args.formats[args.defaultWidth];
return format;
};
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/formatLong.js
var dateFormats = {
full: "EEEE, MMMM do, y",
long: "MMMM do, y",
medium: "MMM d, y",
short: "MM/dd/yyyy"
};
var timeFormats = {
full: "h:mm:ss a zzzz",
long: "h:mm:ss a z",
medium: "h:mm:ss a",
short: "h:mm a"
};
var dateTimeFormats = {
full: "{{date}} 'at' {{time}}",
long: "{{date}} 'at' {{time}}",
medium: "{{date}}, {{time}}",
short: "{{date}}, {{time}}"
};
var formatLong = {
date: buildFormatLongFn({
formats: dateFormats,
defaultWidth: "full"
}),
time: buildFormatLongFn({
formats: timeFormats,
defaultWidth: "full"
}),
dateTime: buildFormatLongFn({
formats: dateTimeFormats,
defaultWidth: "full"
})
};
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
var formatRelativeLocale = {
lastWeek: "'last' eeee 'at' p",
yesterday: "'yesterday at' p",
today: "'today at' p",
tomorrow: "'tomorrow at' p",
nextWeek: "eeee 'at' p",
other: "P"
};
var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
function buildLocalizeFn(args) {
return (value, options) => {
const context = _optionalChain([options, 'optionalAccess', _3 => _3.context]) ? String(options.context) : "standalone";
let valuesArray;
if (context === "formatting" && args.formattingValues) {
const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
const width = _optionalChain([options, 'optionalAccess', _4 => _4.width]) ? String(options.width) : defaultWidth;
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
} else {
const defaultWidth = args.defaultWidth;
const width = _optionalChain([options, 'optionalAccess', _5 => _5.width]) ? String(options.width) : args.defaultWidth;
valuesArray = args.values[width] || args.values[defaultWidth];
}
const index = args.argumentCallback ? args.argumentCallback(value) : value;
return valuesArray[index];
};
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/localize.js
var eraValues = {
narrow: ["B", "A"],
abbreviated: ["BC", "AD"],
wide: ["Before Christ", "Anno Domini"]
};
var quarterValues = {
narrow: ["1", "2", "3", "4"],
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
};
var monthValues = {
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
abbreviated: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
wide: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
};
var dayValues = {
narrow: ["S", "M", "T", "W", "T", "F", "S"],
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
wide: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
};
var dayPeriodValues = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}
};
var formattingDayPeriodValues = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
}
};
var ordinalNumber = (dirtyNumber, _options) => {
const number = Number(dirtyNumber);
const rem100 = number % 100;
if (rem100 > 20 || rem100 < 10) {
switch (rem100 % 10) {
case 1:
return number + "st";
case 2:
return number + "nd";
case 3:
return number + "rd";
}
}
return number + "th";
};
var localize = {
ordinalNumber,
era: buildLocalizeFn({
values: eraValues,
defaultWidth: "wide"
}),
quarter: buildLocalizeFn({
values: quarterValues,
defaultWidth: "wide",
argumentCallback: (quarter) => quarter - 1
}),
month: buildLocalizeFn({
values: monthValues,
defaultWidth: "wide"
}),
day: buildLocalizeFn({
values: dayValues,
defaultWidth: "wide"
}),
dayPeriod: buildLocalizeFn({
values: dayPeriodValues,
defaultWidth: "wide",
formattingValues: formattingDayPeriodValues,
defaultFormattingWidth: "wide"
})
};
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildMatchFn.js
function buildMatchFn(args) {
return (string, options = {}) => {
const width = options.width;
const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
const matchResult = string.match(matchPattern);
if (!matchResult) {
return null;
}
const matchedString = matchResult[0];
const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
// [TODO] -- I challenge you to fix the type
findKey(parsePatterns, (pattern) => pattern.test(matchedString))
);
let value;
value = args.valueCallback ? args.valueCallback(key) : key;
value = options.valueCallback ? (
// [TODO] -- I challenge you to fix the type
options.valueCallback(value)
) : value;
const rest = string.slice(matchedString.length);
return { value, rest };
};
}
function findKey(object, predicate) {
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
return key;
}
}
return void 0;
}
function findIndex(array, predicate) {
for (let key = 0; key < array.length; key++) {
if (predicate(array[key])) {
return key;
}
}
return void 0;
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
function buildMatchPatternFn(args) {
return (string, options = {}) => {
const matchResult = string.match(args.matchPattern);
if (!matchResult) return null;
const matchedString = matchResult[0];
const parseResult = string.match(args.parsePattern);
if (!parseResult) return null;
let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
value = options.valueCallback ? options.valueCallback(value) : value;
const rest = string.slice(matchedString.length);
return { value, rest };
};
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US/_lib/match.js
var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
var parseOrdinalNumberPattern = /\d+/i;
var matchEraPatterns = {
narrow: /^(b|a)/i,
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
wide: /^(before christ|before common era|anno domini|common era)/i
};
var parseEraPatterns = {
any: [/^b/i, /^(a|c)/i]
};
var matchQuarterPatterns = {
narrow: /^[1234]/i,
abbreviated: /^q[1234]/i,
wide: /^[1234](th|st|nd|rd)? quarter/i
};
var parseQuarterPatterns = {
any: [/1/i, /2/i, /3/i, /4/i]
};
var matchMonthPatterns = {
narrow: /^[jfmasond]/i,
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
};
var parseMonthPatterns = {
narrow: [
/^j/i,
/^f/i,
/^m/i,
/^a/i,
/^m/i,
/^j/i,
/^j/i,
/^a/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
],
any: [
/^ja/i,
/^f/i,
/^mar/i,
/^ap/i,
/^may/i,
/^jun/i,
/^jul/i,
/^au/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
]
};
var matchDayPatterns = {
narrow: /^[smtwf]/i,
short: /^(su|mo|tu|we|th|fr|sa)/i,
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
};
var parseDayPatterns = {
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
};
var matchDayPeriodPatterns = {
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
};
var parseDayPeriodPatterns = {
any: {
am: /^a/i,
pm: /^p/i,
midnight: /^mi/i,
noon: /^no/i,
morning: /morning/i,
afternoon: /afternoon/i,
evening: /evening/i,
night: /night/i
}
};
var match = {
ordinalNumber: buildMatchPatternFn({
matchPattern: matchOrdinalNumberPattern,
parsePattern: parseOrdinalNumberPattern,
valueCallback: (value) => parseInt(value, 10)
}),
era: buildMatchFn({
matchPatterns: matchEraPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseEraPatterns,
defaultParseWidth: "any"
}),
quarter: buildMatchFn({
matchPatterns: matchQuarterPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseQuarterPatterns,
defaultParseWidth: "any",
valueCallback: (index) => index + 1
}),
month: buildMatchFn({
matchPatterns: matchMonthPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseMonthPatterns,
defaultParseWidth: "any"
}),
day: buildMatchFn({
matchPatterns: matchDayPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseDayPatterns,
defaultParseWidth: "any"
}),
dayPeriod: buildMatchFn({
matchPatterns: matchDayPeriodPatterns,
defaultMatchWidth: "any",
parsePatterns: parseDayPeriodPatterns,
defaultParseWidth: "any"
})
};
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/en-US.js
var enUS = {
code: "en-US",
formatDistance,
formatLong,
formatRelative,
localize,
match,
options: {
weekStartsOn: 0,
firstWeekContainsDate: 1
}
};
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/defaultOptions.js
var defaultOptions = {};
function getDefaultOptions() {
return defaultOptions;
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/toDate.js
function toDate(argument, context) {
return constructFrom(context || argument, argument);
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
function getTimezoneOffsetInMilliseconds(date) {
const _date = toDate(date);
const utcDate = new Date(
Date.UTC(
_date.getFullYear(),
_date.getMonth(),
_date.getDate(),
_date.getHours(),
_date.getMinutes(),
_date.getSeconds(),
_date.getMilliseconds()
)
);
utcDate.setUTCFullYear(_date.getFullYear());
return +date - +utcDate;
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/normalizeDates.js
function normalizeDates(context, ...dates) {
const normalize = constructFrom.bind(
null,
context || dates.find((date) => typeof date === "object")
);
return dates.map(normalize);
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/compareAsc.js
function compareAsc(dateLeft, dateRight) {
const diff = +toDate(dateLeft) - +toDate(dateRight);
if (diff < 0) return -1;
else if (diff > 0) return 1;
return diff;
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInCalendarMonths.js
function differenceInCalendarMonths(laterDate, earlierDate, options) {
const [laterDate_, earlierDate_] = normalizeDates(
_optionalChain([options, 'optionalAccess', _6 => _6.in]),
laterDate,
earlierDate
);
const yearsDiff = laterDate_.getFullYear() - earlierDate_.getFullYear();
const monthsDiff = laterDate_.getMonth() - earlierDate_.getMonth();
return yearsDiff * 12 + monthsDiff;
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfDay.js
function endOfDay(date, options) {
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _7 => _7.in]));
_date.setHours(23, 59, 59, 999);
return _date;
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfMonth.js
function endOfMonth(date, options) {
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _8 => _8.in]));
const month = _date.getMonth();
_date.setFullYear(_date.getFullYear(), month + 1, 0);
_date.setHours(23, 59, 59, 999);
return _date;
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isLastDayOfMonth.js
function isLastDayOfMonth(date, options) {
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _9 => _9.in]));
return +endOfDay(_date, options) === +endOfMonth(_date, options);
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInMonths.js
function differenceInMonths(laterDate, earlierDate, options) {
const [laterDate_, workingLaterDate, earlierDate_] = normalizeDates(
_optionalChain([options, 'optionalAccess', _10 => _10.in]),
laterDate,
laterDate,
earlierDate
);
const sign = compareAsc(workingLaterDate, earlierDate_);
const difference = Math.abs(
differenceInCalendarMonths(workingLaterDate, earlierDate_)
);
if (difference < 1) return 0;
if (workingLaterDate.getMonth() === 1 && workingLaterDate.getDate() > 27)
workingLaterDate.setDate(30);
workingLaterDate.setMonth(workingLaterDate.getMonth() - sign * difference);
let isLastMonthNotFull = compareAsc(workingLaterDate, earlierDate_) === -sign;
if (isLastDayOfMonth(laterDate_) && difference === 1 && compareAsc(laterDate_, earlierDate_) === 1) {
isLastMonthNotFull = false;
}
const result = sign * (difference - +isLastMonthNotFull);
return result === 0 ? 0 : result;
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/getRoundingMethod.js
function getRoundingMethod(method) {
return (number) => {
const round = method ? Math[method] : Math.trunc;
const result = round(number);
return result === 0 ? 0 : result;
};
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInMilliseconds.js
function differenceInMilliseconds(laterDate, earlierDate) {
return +toDate(laterDate) - +toDate(earlierDate);
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInSeconds.js
function differenceInSeconds(laterDate, earlierDate, options) {
const diff = differenceInMilliseconds(laterDate, earlierDate) / 1e3;
return getRoundingMethod(_optionalChain([options, 'optionalAccess', _11 => _11.roundingMethod]))(diff);
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/formatDistance.js
function formatDistance2(laterDate, earlierDate, options) {
const defaultOptions2 = getDefaultOptions();
const locale = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _12 => _12.locale]), () => ( defaultOptions2.locale)), () => ( enUS));
const minutesInAlmostTwoDays = 2520;
const comparison = compareAsc(laterDate, earlierDate);
if (isNaN(comparison)) throw new RangeError("Invalid time value");
const localizeOptions = Object.assign({}, options, {
addSuffix: _optionalChain([options, 'optionalAccess', _13 => _13.addSuffix]),
comparison
});
const [laterDate_, earlierDate_] = normalizeDates(
_optionalChain([options, 'optionalAccess', _14 => _14.in]),
...comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]
);
const seconds = differenceInSeconds(earlierDate_, laterDate_);
const offsetInSeconds = (getTimezoneOffsetInMilliseconds(earlierDate_) - getTimezoneOffsetInMilliseconds(laterDate_)) / 1e3;
const minutes = Math.round((seconds - offsetInSeconds) / 60);
let months;
if (minutes < 2) {
if (_optionalChain([options, 'optionalAccess', _15 => _15.includeSeconds])) {
if (seconds < 5) {
return locale.formatDistance("lessThanXSeconds", 5, localizeOptions);
} else if (seconds < 10) {
return locale.formatDistance("lessThanXSeconds", 10, localizeOptions);
} else if (seconds < 20) {
return locale.formatDistance("lessThanXSeconds", 20, localizeOptions);
} else if (seconds < 40) {
return locale.formatDistance("halfAMinute", 0, localizeOptions);
} else if (seconds < 60) {
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
} else {
return locale.formatDistance("xMinutes", 1, localizeOptions);
}
} else {
if (minutes === 0) {
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
} else {
return locale.formatDistance("xMinutes", minutes, localizeOptions);
}
}
} else if (minutes < 45) {
return locale.formatDistance("xMinutes", minutes, localizeOptions);
} else if (minutes < 90) {
return locale.formatDistance("aboutXHours", 1, localizeOptions);
} else if (minutes < minutesInDay) {
const hours = Math.round(minutes / 60);
return locale.formatDistance("aboutXHours", hours, localizeOptions);
} else if (minutes < minutesInAlmostTwoDays) {
return locale.formatDistance("xDays", 1, localizeOptions);
} else if (minutes < minutesInMonth) {
const days = Math.round(minutes / minutesInDay);
return locale.formatDistance("xDays", days, localizeOptions);
} else if (minutes < minutesInMonth * 2) {
months = Math.round(minutes / minutesInMonth);
return locale.formatDistance("aboutXMonths", months, localizeOptions);
}
months = differenceInMonths(earlierDate_, laterDate_);
if (months < 12) {
const nearestMonth = Math.round(minutes / minutesInMonth);
return locale.formatDistance("xMonths", nearestMonth, localizeOptions);
} else {
const monthsSinceStartOfYear = months % 12;
const years = Math.trunc(months / 12);
if (monthsSinceStartOfYear < 3) {
return locale.formatDistance("aboutXYears", years, localizeOptions);
} else if (monthsSinceStartOfYear < 9) {
return locale.formatDistance("overXYears", years, localizeOptions);
} else {
return locale.formatDistance("almostXYears", years + 1, localizeOptions);
}
}
}
// ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/formatDistanceToNow.js
function formatDistanceToNow(date, options) {
return formatDistance2(date, constructNow(date), options);
}
// src/logger/console.ts
var getLogFn = (logLevel = _chunk7QBTVNMRcjs.LogLevel.INFO, config = {}, _chalk = _chunkLOY6ICHZcjs.getChalk.call(void 0, )) => {
const colors = !_optionalChain([config, 'access', _16 => _16.colors, 'optionalAccess', _17 => _17.dark]) && !_optionalChain([config, 'access', _18 => _18.colors, 'optionalAccess', _19 => _19["base"]]) && !_optionalChain([config, 'access', _20 => _20.colors, 'optionalAccess', _21 => _21["base"], 'optionalAccess', _22 => _22.dark]) ? _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG : _optionalChain([config, 'access', _23 => _23.colors, 'optionalAccess', _24 => _24.dark]) && typeof config.colors.dark === "string" ? config.colors : _optionalChain([config, 'access', _25 => _25.colors, 'optionalAccess', _26 => _26["base"], 'optionalAccess', _27 => _27.dark]) && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : _optionalChain([config, 'access', _28 => _28.colors, 'optionalAccess', _29 => _29["base"]]) ? _optionalChain([config, 'access', _30 => _30.colors, 'optionalAccess', _31 => _31["base"]]) : _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG;
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || _chunk7QBTVNMRcjs.LogLevelLabel.INFO;
if (logLevel > _chunkJWLDCEBZcjs.getLogLevel.call(void 0, configLogLevel) || logLevel <= _chunk7QBTVNMRcjs.LogLevel.SILENT || _chunkJWLDCEBZcjs.getLogLevel.call(void 0, configLogLevel) <= _chunk7QBTVNMRcjs.LogLevel.SILENT) {
return (_) => {
};
}
if (typeof logLevel === "number" && _chunk7QBTVNMRcjs.LogLevel.FATAL >= logLevel) {
return (message) => {
console.error(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(
_nullishCoalesce(colors.fatal, () => ( _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG.dark.fatal))
)(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.FATAL]} Fatal] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
}
if (typeof logLevel === "number" && _chunk7QBTVNMRcjs.LogLevel.ERROR >= logLevel) {
return (message) => {
console.error(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(
_nullishCoalesce(colors.danger, () => ( _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG.dark.danger))
)(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.ERROR]} Error] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
}
if (typeof logLevel === "number" && _chunk7QBTVNMRcjs.LogLevel.WARN >= logLevel) {
return (message) => {
console.warn(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(
_nullishCoalesce(colors.warning, () => ( _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG.dark.warning))
)(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.WARN]} Warn] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
}
if (typeof logLevel === "number" && _chunk7QBTVNMRcjs.LogLevel.SUCCESS >= logLevel) {
return (message) => {
console.info(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(
_nullishCoalesce(colors.success, () => ( _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG.dark.success))
)(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.SUCCESS]} Success] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
}
if (typeof logLevel === "number" && _chunk7QBTVNMRcjs.LogLevel.INFO >= logLevel) {
return (message) => {
console.info(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(
_nullishCoalesce(colors.info, () => ( _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG.dark.info))
)(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.INFO]} Info] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
}
if (typeof logLevel === "number" && _chunk7QBTVNMRcjs.LogLevel.PERFORMANCE >= logLevel) {
return (message) => {
console.debug(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(
_nullishCoalesce(colors.performance, () => ( _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG.dark.performance))
)(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.PERFORMANCE]} Performance] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
}
if (typeof logLevel === "number" && _chunk7QBTVNMRcjs.LogLevel.DEBUG >= logLevel) {
return (message) => {
console.debug(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(
_nullishCoalesce(colors.debug, () => ( _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG.dark.debug))
)(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.DEBUG]} Debug] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
}
if (typeof logLevel === "number" && _chunk7QBTVNMRcjs.LogLevel.TRACE >= logLevel) {
return (message) => {
console.debug(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex("#bbbbbb")(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.TRACE]} Trace] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
}
return (message) => {
console.log(
`
${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(
_nullishCoalesce(colors.brand, () => ( _chunkL4YHJZ6Qcjs.DEFAULT_COLOR_CONFIG.dark.brand))
)(
`[${_chunkEC2KPWRGcjs.CONSOLE_ICONS[_chunk7QBTVNMRcjs.LogLevelLabel.ALL]} System] `
)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`
);
};
};
var writeFatal = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.FATAL, config)(message);
var writeError = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.ERROR, config)(message);
var writeWarning = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.WARN, config)(message);
var writeInfo = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.INFO, config)(message);
var writeSuccess = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.SUCCESS, config)(message);
var writePerformance = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.PERFORMANCE, config)(message);
var writeDebug = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.DEBUG, config)(message);
var writeTrace = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.TRACE, config)(message);
var writeSystem = (message, config) => getLogFn(_chunk7QBTVNMRcjs.LogLevel.ALL, config)(message);
var getStopwatch = (name) => {
const start = /* @__PURE__ */ new Date();
return () => {
writePerformance(
`The${name ? ` ${name}` : ""} process took ${formatDistanceToNow(start, {
includeSeconds: true
})} to complete`
);
};
};
var MAX_DEPTH = 6;
var formatLogMessage = (message, options = {}, depth = 0) => {
if (depth > MAX_DEPTH) {
return "<max depth>";
}
const prefix = _nullishCoalesce(options.prefix, () => ( "-"));
const skip = _nullishCoalesce(options.skip, () => ( []));
return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth + 1)}`).join("\n")}` : typeof message === "object" ? `
${Object.keys(message).filter((key) => !skip.includes(key)).map(
(key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
message[key],
{ prefix: `${prefix}-`, skip },
depth + 1
) : message[key]}`
).join("\n")}` : message;
};
var _isFunction = (value) => {
try {
return value instanceof Function || typeof value === "function" || !!(_optionalChain([value, 'optionalAccess', _32 => _32.constructor]) && _optionalChain([value, 'optionalAccess', _33 => _33.call]) && _optionalChain([value, 'optionalAccess', _34 => _34.apply]));
} catch (e) {
return false;
}
};
var brandIcon = (config = {}, _chalk = _chunkLOY6ICHZcjs.getChalk.call(void 0, )) => _chalk.hex(_chunkL4YHJZ6Qcjs.getColor.call(void 0, "brand", config))("\u{1F5F2}");
exports.getLogFn = getLogFn; exports.writeFatal = writeFatal; exports.writeError = writeError; exports.writeWarning = writeWarning; exports.writeInfo = writeInfo; exports.writeSuccess = writeSuccess; exports.writePerformance = writePerformance; exports.writeDebug = writeDebug; exports.writeTrace = writeTrace; exports.writeSystem = writeSystem; exports.getStopwatch = getStopwatch; exports.formatLogMessage = formatLogMessage; exports.brandIcon = brandIcon;