From 6926a3bd0e651496a49cfd09450f153f53279cb2 Mon Sep 17 00:00:00 2001 From: TIOBE <123092508+it-tiobe@users.noreply.github.com> Date: Fri, 9 Aug 2024 06:25:14 +0000 Subject: [PATCH] Build dist after push to main --- dist/index.js | 1163 ++++++++++++++++++++++++++++--------------------- 1 file changed, 678 insertions(+), 485 deletions(-) diff --git a/dist/index.js b/dist/index.js index 473d76e3..37f5612b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13493,15 +13493,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.InstallTics = exports.getBaseUrl = void 0; +exports.InstallTics = void 0; +exports.getBaseUrl = getBaseUrl; const os = __importStar(__nccwpck_require__(22037)); -const http_client_1 = __importDefault(__nccwpck_require__(14824)); +const http_client_1 = __importDefault(__nccwpck_require__(5098)); var Platform; (function (Platform) { Platform["aix"] = "aix"; Platform["android"] = "android"; Platform["cygwin"] = "cygwin"; - Platform["darwin"] = "darwin"; + Platform["darwin"] = "macos"; Platform["freebsd"] = "freebsd"; Platform["haiku"] = "haiku"; Platform["linux"] = "linux"; @@ -13529,7 +13530,6 @@ function getBaseUrl(url) { } throw Error('Incorrect TICS Viewer url was given.'); } -exports.getBaseUrl = getBaseUrl; class InstallTics { /** * @param ci If this http client is used in a ci environment. @@ -13553,9 +13553,9 @@ class InstallTics { const platform = Platform[os.platform()]; const installTicsUrl = yield this.getInstallTicsUrl(url, platform); switch (platform) { - case 'linux': + case Platform.linux: return this.linuxInstall(installTicsUrl); - case 'windows': + case Platform.win32: return this.windowsInstall(installTicsUrl); default: throw Error(`No install command found for platform: ${platform}.`); @@ -13617,6 +13617,199 @@ exports.InstallTics = InstallTics; /***/ }), +/***/ 5098: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const node_fetch_1 = __importStar(__nccwpck_require__(80467)); +const retry_1 = __importStar(__nccwpck_require__(38480)); +class HttpClient { + /** + * @param ci If this http client is used in a ci environment. + * @param options (Optional) options to use for the HttpClient. + * @param agent (Optional) agent to be set when using proxy. + */ + constructor(ci, options, agent) { + this.ci = ci; + this.agent = agent; + this.defaultHeaders = new node_fetch_1.Headers(); + if (options === null || options === void 0 ? void 0 : options.authToken) { + this.defaultHeaders.set('authorization', `Basic ${options.authToken}`); + } + if (options === null || options === void 0 ? void 0 : options.xRequestWithTics) { + this.defaultHeaders.set('x-requested-with', 'TICS'); + } + this.customFetch = (0, retry_1.default)(node_fetch_1.default, options === null || options === void 0 ? void 0 : options.retry); + } + /** + * Executes a GET request to the given url. + * @param url api url to perform a GET request for. + */ + get(url, headers) { + return __awaiter(this, void 0, void 0, function* () { + let fixedHeaders = this.defaultHeaders; + headers === null || headers === void 0 ? void 0 : headers.forEach((value, key) => { + fixedHeaders.append(key, value); + }); + const requestInit = { + agent: this.agent, + headers: fixedHeaders + }; + const response = yield this.customFetch(url, requestInit); + switch (response.status) { + case 200: + const text = yield response.text(); + try { + const result = { + status: response.status, + retryCount: response.retryCount, + data: JSON.parse(text) + }; + return result; + } + catch (error) { + throw new retry_1.RequestError(`${error}: ${text}`, response.status, response.retryCount); + } + case 302: + throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. Please check if the given ticsConfiguration is correct.`, response.status, response.retryCount); + case 400: + throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. ${(yield response.json()).alertMessages[0].header}`, response.status, response.retryCount); + case 401: + let authUrl = url.split('/api/')[0]; + authUrl += this.ci ? '/Administration.html#page=authToken' : '/UserSettings.html#page=authToken'; + throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. Please provide a valid TICS authentication token. See ${authUrl}`, response.status, response.retryCount); + case 403: + throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. Forbidden call: ${url}`, response.status, response.retryCount); + case 404: + throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. Please check if the given ticsConfiguration is correct.`, response.status, response.retryCount); + default: + throw new retry_1.RequestError(`HTTP request failed with status ${response.status}: ${response.statusText}`, response.status, response.retryCount); + } + }); + } +} +exports["default"] = HttpClient; +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 38480: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.RequestError = void 0; +exports.fetchBuilder = fetchBuilder; +class RequestError extends Error { + constructor(message, status, retryCount) { + super(message); + this.name = 'RequestError'; + this.status = status; + this.retryCount = retryCount; + } +} +exports.RequestError = RequestError; +function sanitize(params, defaults) { + const result = Object.assign(Object.assign({}, defaults), params); + if (typeof result.retries === 'undefined') { + result.retries = defaults.retries; + } + if (typeof result.retryDelay === 'undefined') { + result.retryDelay = defaults.retryDelay; + } + if (typeof result.retryOn === 'undefined') { + result.retryOn = defaults.retryOn; + } + return result; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function fetchBuilder(fetchFunc, params = {}) { + const defaults = sanitize(params, { retries: 3, retryDelay: 500, retryOn: [419, 503, 504] }); + return function (input, init) { + const frp = sanitize({ + // TICS -no-unsafe-assignment + retries: init === null || init === void 0 ? void 0 : init.retries, + retryDelay: init === null || init === void 0 ? void 0 : init.retryDelay, + retryOn: init === null || init === void 0 ? void 0 : init.retryOn + // TICS +no-unsafe-assignment + }, defaults); + const retryDelayFn = typeof frp.retryDelay === 'function' ? frp.retryDelay : () => frp.retryDelay; + const retryOnFn = typeof frp.retryOn === 'function' + ? frp.retryOn + : (attempt, retries, error, response) => (!!error || !response || frp.retryOn.indexOf(response.status) !== -1) && attempt < retries; + return new Promise(function (resolve, reject) { + const extendedFetch = function (attempt) { + fetchFunc(input, init) + .then(function (response) { + if (retryOnFn(attempt, frp.retries, null, response)) { + // eslint-disable-next-line @typescript-eslint/no-use-before-define + retry(attempt, null, response); + } + else { + const responseWithRetryCount = response; + responseWithRetryCount.retryCount = attempt; + resolve(responseWithRetryCount); + } + }) + .catch(function (error) { + if (retryOnFn(attempt, frp.retries, error, null)) { + // eslint-disable-next-line @typescript-eslint/no-use-before-define + retry(attempt, error, null); + } + else { + reject(new RequestError(error.message, 0, attempt)); + } + }); + }; + function retry(attempt, error, response) { + setTimeout(function () { + extendedFetch(++attempt); + }, retryDelayFn(attempt, error, response)); + } + extendedFetch(0); + }); + }; +} +exports["default"] = fetchBuilder; +//# sourceMappingURL=retry.js.map + +/***/ }), + /***/ 40068: /***/ ((__unused_webpack_module, exports) => { @@ -41078,526 +41271,154 @@ function cleanEscapedString(input) { /***/ }), -/***/ 93822: +/***/ 5619: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -exports.parseISO = parseISO; -var _index = __nccwpck_require__(17818); - -/** - * The {@link parseISO} function options. - */ +exports.Parser = void 0; +var _Setter = __nccwpck_require__(75665); -/** - * @name parseISO - * @category Common Helpers - * @summary Parse ISO string - * - * @description - * Parse the given string in ISO 8601 format and return an instance of Date. - * - * Function accepts complete ISO 8601 formats as well as partial implementations. - * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601 - * - * If the argument isn't a string, the function cannot parse the string or - * the values are invalid, it returns Invalid Date. - * - * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). - * - * @param argument - The value to convert - * @param options - An object with options - * - * @returns The parsed date in the local time zone - * - * @example - * // Convert string '2014-02-11T11:30:30' to date: - * const result = parseISO('2014-02-11T11:30:30') - * //=> Tue Feb 11 2014 11:30:30 - * - * @example - * // Convert string '+02014101' to date, - * // if the additional number of digits in the extended year format is 1: - * const result = parseISO('+02014101', { additionalDigits: 1 }) - * //=> Fri Apr 11 2014 00:00:00 - */ -function parseISO(argument, options) { - const additionalDigits = options?.additionalDigits ?? 2; - const dateStrings = splitDateString(argument); +class Parser { + run(dateString, token, match, options) { + const result = this.parse(dateString, token, match, options); + if (!result) { + return null; + } - let date; - if (dateStrings.date) { - const parseYearResult = parseYear(dateStrings.date, additionalDigits); - date = parseDate(parseYearResult.restDateString, parseYearResult.year); + return { + setter: new _Setter.ValueSetter( + result.value, + this.validate, + this.set, + this.priority, + this.subPriority, + ), + rest: result.rest, + }; } - if (!date || isNaN(date.getTime())) { - return new Date(NaN); + validate(_utcDate, _value, _options) { + return true; } +} +exports.Parser = Parser; - const timestamp = date.getTime(); - let time = 0; - let offset; - if (dateStrings.time) { - time = parseTime(dateStrings.time); - if (isNaN(time)) { - return new Date(NaN); - } - } - - if (dateStrings.timezone) { - offset = parseTimezone(dateStrings.timezone); - if (isNaN(offset)) { - return new Date(NaN); - } - } else { - const dirtyDate = new Date(timestamp + time); - // JS parsed string assuming it's in UTC timezone - // but we need it to be parsed in our timezone - // so we use utc values to build date in our timezone. - // Year values from 0 to 99 map to the years 1900 to 1999 - // so set year explicitly with setFullYear. - const result = new Date(0); - result.setFullYear( - dirtyDate.getUTCFullYear(), - dirtyDate.getUTCMonth(), - dirtyDate.getUTCDate(), - ); - result.setHours( - dirtyDate.getUTCHours(), - dirtyDate.getUTCMinutes(), - dirtyDate.getUTCSeconds(), - dirtyDate.getUTCMilliseconds(), - ); - return result; - } - - return new Date(timestamp + time + offset); -} +/***/ }), -const patterns = { - dateTimeDelimiter: /[T ]/, - timeZoneDelimiter: /[Z ]/i, - timezone: /([Z+-].*)$/, -}; +/***/ 75665: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -const dateRegex = - /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/; -const timeRegex = - /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/; -const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/; +"use strict"; -function splitDateString(dateString) { - const dateStrings = {}; - const array = dateString.split(patterns.dateTimeDelimiter); - let timeString; +exports.ValueSetter = + exports.Setter = + exports.DateToSystemTimezoneSetter = + void 0; +var _index = __nccwpck_require__(71881); +var _index2 = __nccwpck_require__(92736); - // The regex match should only return at maximum two array elements. - // [date], [time], or [date, time]. - if (array.length > 2) { - return dateStrings; - } +const TIMEZONE_UNIT_PRIORITY = 10; - if (/:/.test(array[0])) { - timeString = array[0]; - } else { - dateStrings.date = array[0]; - timeString = array[1]; - if (patterns.timeZoneDelimiter.test(dateStrings.date)) { - dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0]; - timeString = dateString.substr( - dateStrings.date.length, - dateString.length, - ); - } - } +class Setter { + subPriority = 0; - if (timeString) { - const token = patterns.timezone.exec(timeString); - if (token) { - dateStrings.time = timeString.replace(token[1], ""); - dateStrings.timezone = token[1]; - } else { - dateStrings.time = timeString; - } + validate(_utcDate, _options) { + return true; } - - return dateStrings; } +exports.Setter = Setter; -function parseYear(dateString, additionalDigits) { - const regex = new RegExp( - "^(?:(\\d{4}|[+-]\\d{" + - (4 + additionalDigits) + - "})|(\\d{2}|[+-]\\d{" + - (2 + additionalDigits) + - "})$)", - ); - - const captures = dateString.match(regex); - // Invalid ISO-formatted year - if (!captures) return { year: NaN, restDateString: "" }; - - const year = captures[1] ? parseInt(captures[1]) : null; - const century = captures[2] ? parseInt(captures[2]) : null; +class ValueSetter extends Setter { + constructor( + value, - // either year or century is null, not both - return { - year: century === null ? year : century * 100, - restDateString: dateString.slice((captures[1] || captures[2]).length), - }; -} + validateValue, -function parseDate(dateString, year) { - // Invalid ISO-formatted year - if (year === null) return new Date(NaN); + setValue, - const captures = dateString.match(dateRegex); - // Invalid ISO-formatted string - if (!captures) return new Date(NaN); + priority, + subPriority, + ) { + super(); + this.value = value; + this.validateValue = validateValue; + this.setValue = setValue; + this.priority = priority; + if (subPriority) { + this.subPriority = subPriority; + } + } - const isWeekDate = !!captures[4]; - const dayOfYear = parseDateUnit(captures[1]); - const month = parseDateUnit(captures[2]) - 1; - const day = parseDateUnit(captures[3]); - const week = parseDateUnit(captures[4]); - const dayOfWeek = parseDateUnit(captures[5]) - 1; + validate(date, options) { + return this.validateValue(date, this.value, options); + } - if (isWeekDate) { - if (!validateWeekDate(year, week, dayOfWeek)) { - return new Date(NaN); - } - return dayOfISOWeekYear(year, week, dayOfWeek); - } else { - const date = new Date(0); - if ( - !validateDate(year, month, day) || - !validateDayOfYearDate(year, dayOfYear) - ) { - return new Date(NaN); - } - date.setUTCFullYear(year, month, Math.max(dayOfYear, day)); - return date; + set(date, flags, options) { + return this.setValue(date, flags, this.value, options); } } +exports.ValueSetter = ValueSetter; -function parseDateUnit(value) { - return value ? parseInt(value) : 1; +class DateToSystemTimezoneSetter extends Setter { + priority = TIMEZONE_UNIT_PRIORITY; + subPriority = -1; + set(date, flags) { + if (flags.timestampIsSet) return date; + return (0, _index2.constructFrom)(date, (0, _index.transpose)(date, Date)); + } } +exports.DateToSystemTimezoneSetter = DateToSystemTimezoneSetter; -function parseTime(timeString) { - const captures = timeString.match(timeRegex); - if (!captures) return NaN; // Invalid ISO-formatted time - const hours = parseTimeUnit(captures[1]); - const minutes = parseTimeUnit(captures[2]); - const seconds = parseTimeUnit(captures[3]); +/***/ }), - if (!validateTime(hours, minutes, seconds)) { - return NaN; - } +/***/ 30463: +/***/ ((__unused_webpack_module, exports) => { - return ( - hours * _index.millisecondsInHour + - minutes * _index.millisecondsInMinute + - seconds * 1000 - ); -} +"use strict"; -function parseTimeUnit(value) { - return (value && parseFloat(value.replace(",", "."))) || 0; -} +exports.timezonePatterns = exports.numericPatterns = void 0; +const numericPatterns = (exports.numericPatterns = { + month: /^(1[0-2]|0?\d)/, // 0 to 12 + date: /^(3[0-1]|[0-2]?\d)/, // 0 to 31 + dayOfYear: /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/, // 0 to 366 + week: /^(5[0-3]|[0-4]?\d)/, // 0 to 53 + hour23h: /^(2[0-3]|[0-1]?\d)/, // 0 to 23 + hour24h: /^(2[0-4]|[0-1]?\d)/, // 0 to 24 + hour11h: /^(1[0-1]|0?\d)/, // 0 to 11 + hour12h: /^(1[0-2]|0?\d)/, // 0 to 12 + minute: /^[0-5]?\d/, // 0 to 59 + second: /^[0-5]?\d/, // 0 to 59 -function parseTimezone(timezoneString) { - if (timezoneString === "Z") return 0; + singleDigit: /^\d/, // 0 to 9 + twoDigits: /^\d{1,2}/, // 0 to 99 + threeDigits: /^\d{1,3}/, // 0 to 999 + fourDigits: /^\d{1,4}/, // 0 to 9999 - const captures = timezoneString.match(timezoneRegex); - if (!captures) return 0; + anyDigitsSigned: /^-?\d+/, + singleDigitSigned: /^-?\d/, // 0 to 9, -0 to -9 + twoDigitsSigned: /^-?\d{1,2}/, // 0 to 99, -0 to -99 + threeDigitsSigned: /^-?\d{1,3}/, // 0 to 999, -0 to -999 + fourDigitsSigned: /^-?\d{1,4}/, // 0 to 9999, -0 to -9999 +}); - const sign = captures[1] === "+" ? -1 : 1; - const hours = parseInt(captures[2]); - const minutes = (captures[3] && parseInt(captures[3])) || 0; +const timezonePatterns = (exports.timezonePatterns = { + basicOptionalMinutes: /^([+-])(\d{2})(\d{2})?|Z/, + basic: /^([+-])(\d{2})(\d{2})|Z/, + basicOptionalSeconds: /^([+-])(\d{2})(\d{2})((\d{2}))?|Z/, + extended: /^([+-])(\d{2}):(\d{2})|Z/, + extendedOptionalSeconds: /^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/, +}); - if (!validateTimezone(hours, minutes)) { - return NaN; - } - return ( - sign * - (hours * _index.millisecondsInHour + minutes * _index.millisecondsInMinute) - ); -} +/***/ }), -function dayOfISOWeekYear(isoWeekYear, week, day) { - const date = new Date(0); - date.setUTCFullYear(isoWeekYear, 0, 4); - const fourthOfJanuaryDay = date.getUTCDay() || 7; - const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay; - date.setUTCDate(date.getUTCDate() + diff); - return date; -} +/***/ 96874: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -// Validation functions - -// February is null to handle the leap year (using ||) -const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - -function isLeapYearIndex(year) { - return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0); -} - -function validateDate(year, month, date) { - return ( - month >= 0 && - month <= 11 && - date >= 1 && - date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28)) - ); -} - -function validateDayOfYearDate(year, dayOfYear) { - return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365); -} - -function validateWeekDate(_year, week, day) { - return week >= 1 && week <= 53 && day >= 0 && day <= 6; -} - -function validateTime(hours, minutes, seconds) { - if (hours === 24) { - return minutes === 0 && seconds === 0; - } - - return ( - seconds >= 0 && - seconds < 60 && - minutes >= 0 && - minutes < 60 && - hours >= 0 && - hours < 25 - ); -} - -function validateTimezone(_hours, minutes) { - return minutes >= 0 && minutes <= 59; -} - - -/***/ }), - -/***/ 50135: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -exports.parseJSON = parseJSON; /** - * @name parseJSON - * @category Common Helpers - * @summary Parse a JSON date string - * - * @description - * Converts a complete ISO date string in UTC time, the typical format for transmitting - * a date in JSON, to a JavaScript `Date` instance. - * - * This is a minimal implementation for converting dates retrieved from a JSON API to - * a `Date` instance which can be used with other functions in the `date-fns` library. - * The following formats are supported: - * - * - `2000-03-15T05:20:10.123Z`: The output of `.toISOString()` and `JSON.stringify(new Date())` - * - `2000-03-15T05:20:10Z`: Without milliseconds - * - `2000-03-15T05:20:10+00:00`: With a zero offset, the default JSON encoded format in some other languages - * - `2000-03-15T05:20:10+05:45`: With a positive or negative offset, the default JSON encoded format in some other languages - * - `2000-03-15T05:20:10+0000`: With a zero offset without a colon - * - `2000-03-15T05:20:10`: Without a trailing 'Z' symbol - * - `2000-03-15T05:20:10.1234567`: Up to 7 digits in milliseconds field. Only first 3 are taken into account since JS does not allow fractional milliseconds - * - `2000-03-15 05:20:10`: With a space instead of a 'T' separator for APIs returning a SQL date without reformatting - * - * For convenience and ease of use these other input types are also supported - * via [toDate](https://date-fns.org/docs/toDate): - * - * - A `Date` instance will be cloned - * - A `number` will be treated as a timestamp - * - * Any other input type or invalid date strings will return an `Invalid Date`. - * - * @param dateStr - A fully formed ISO8601 date string to convert - * - * @returns The parsed date in the local time zone - */ -function parseJSON(dateStr) { - const parts = dateStr.match( - /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/, - ); - if (parts) { - // Group 8 matches the sign - return new Date( - Date.UTC( - +parts[1], - +parts[2] - 1, - +parts[3], - +parts[4] - (+parts[9] || 0) * (parts[8] == "-" ? -1 : 1), - +parts[5] - (+parts[10] || 0) * (parts[8] == "-" ? -1 : 1), - +parts[6], - +((parts[7] || "0") + "00").substring(0, 3), - ), - ); - } - return new Date(NaN); -} - - -/***/ }), - -/***/ 5619: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -exports.Parser = void 0; -var _Setter = __nccwpck_require__(75665); - -class Parser { - run(dateString, token, match, options) { - const result = this.parse(dateString, token, match, options); - if (!result) { - return null; - } - - return { - setter: new _Setter.ValueSetter( - result.value, - this.validate, - this.set, - this.priority, - this.subPriority, - ), - rest: result.rest, - }; - } - - validate(_utcDate, _value, _options) { - return true; - } -} -exports.Parser = Parser; - - -/***/ }), - -/***/ 75665: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -exports.ValueSetter = - exports.Setter = - exports.DateToSystemTimezoneSetter = - void 0; -var _index = __nccwpck_require__(71881); -var _index2 = __nccwpck_require__(92736); - -const TIMEZONE_UNIT_PRIORITY = 10; - -class Setter { - subPriority = 0; - - validate(_utcDate, _options) { - return true; - } -} -exports.Setter = Setter; - -class ValueSetter extends Setter { - constructor( - value, - - validateValue, - - setValue, - - priority, - subPriority, - ) { - super(); - this.value = value; - this.validateValue = validateValue; - this.setValue = setValue; - this.priority = priority; - if (subPriority) { - this.subPriority = subPriority; - } - } - - validate(date, options) { - return this.validateValue(date, this.value, options); - } - - set(date, flags, options) { - return this.setValue(date, flags, this.value, options); - } -} -exports.ValueSetter = ValueSetter; - -class DateToSystemTimezoneSetter extends Setter { - priority = TIMEZONE_UNIT_PRIORITY; - subPriority = -1; - set(date, flags) { - if (flags.timestampIsSet) return date; - return (0, _index2.constructFrom)(date, (0, _index.transpose)(date, Date)); - } -} -exports.DateToSystemTimezoneSetter = DateToSystemTimezoneSetter; - - -/***/ }), - -/***/ 30463: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -exports.timezonePatterns = exports.numericPatterns = void 0; -const numericPatterns = (exports.numericPatterns = { - month: /^(1[0-2]|0?\d)/, // 0 to 12 - date: /^(3[0-1]|[0-2]?\d)/, // 0 to 31 - dayOfYear: /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/, // 0 to 366 - week: /^(5[0-3]|[0-4]?\d)/, // 0 to 53 - hour23h: /^(2[0-3]|[0-1]?\d)/, // 0 to 23 - hour24h: /^(2[0-4]|[0-1]?\d)/, // 0 to 24 - hour11h: /^(1[0-1]|0?\d)/, // 0 to 11 - hour12h: /^(1[0-2]|0?\d)/, // 0 to 12 - minute: /^[0-5]?\d/, // 0 to 59 - second: /^[0-5]?\d/, // 0 to 59 - - singleDigit: /^\d/, // 0 to 9 - twoDigits: /^\d{1,2}/, // 0 to 99 - threeDigits: /^\d{1,3}/, // 0 to 999 - fourDigits: /^\d{1,4}/, // 0 to 9999 - - anyDigitsSigned: /^-?\d+/, - singleDigitSigned: /^-?\d/, // 0 to 9, -0 to -9 - twoDigitsSigned: /^-?\d{1,2}/, // 0 to 99, -0 to -99 - threeDigitsSigned: /^-?\d{1,3}/, // 0 to 999, -0 to -999 - fourDigitsSigned: /^-?\d{1,4}/, // 0 to 9999, -0 to -9999 -}); - -const timezonePatterns = (exports.timezonePatterns = { - basicOptionalMinutes: /^([+-])(\d{2})(\d{2})?|Z/, - basic: /^([+-])(\d{2})(\d{2})|Z/, - basicOptionalSeconds: /^([+-])(\d{2})(\d{2})((\d{2}))?|Z/, - extended: /^([+-])(\d{2}):(\d{2})|Z/, - extendedOptionalSeconds: /^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/, -}); - - -/***/ }), - -/***/ 96874: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; +"use strict"; exports.parsers = void 0; var _EraParser = __nccwpck_require__(36309); @@ -43974,6 +43795,378 @@ function isLeapYearIndex(year) { } +/***/ }), + +/***/ 93822: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.parseISO = parseISO; +var _index = __nccwpck_require__(17818); + +/** + * The {@link parseISO} function options. + */ + +/** + * @name parseISO + * @category Common Helpers + * @summary Parse ISO string + * + * @description + * Parse the given string in ISO 8601 format and return an instance of Date. + * + * Function accepts complete ISO 8601 formats as well as partial implementations. + * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601 + * + * If the argument isn't a string, the function cannot parse the string or + * the values are invalid, it returns Invalid Date. + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * + * @param argument - The value to convert + * @param options - An object with options + * + * @returns The parsed date in the local time zone + * + * @example + * // Convert string '2014-02-11T11:30:30' to date: + * const result = parseISO('2014-02-11T11:30:30') + * //=> Tue Feb 11 2014 11:30:30 + * + * @example + * // Convert string '+02014101' to date, + * // if the additional number of digits in the extended year format is 1: + * const result = parseISO('+02014101', { additionalDigits: 1 }) + * //=> Fri Apr 11 2014 00:00:00 + */ +function parseISO(argument, options) { + const additionalDigits = options?.additionalDigits ?? 2; + const dateStrings = splitDateString(argument); + + let date; + if (dateStrings.date) { + const parseYearResult = parseYear(dateStrings.date, additionalDigits); + date = parseDate(parseYearResult.restDateString, parseYearResult.year); + } + + if (!date || isNaN(date.getTime())) { + return new Date(NaN); + } + + const timestamp = date.getTime(); + let time = 0; + let offset; + + if (dateStrings.time) { + time = parseTime(dateStrings.time); + if (isNaN(time)) { + return new Date(NaN); + } + } + + if (dateStrings.timezone) { + offset = parseTimezone(dateStrings.timezone); + if (isNaN(offset)) { + return new Date(NaN); + } + } else { + const dirtyDate = new Date(timestamp + time); + // JS parsed string assuming it's in UTC timezone + // but we need it to be parsed in our timezone + // so we use utc values to build date in our timezone. + // Year values from 0 to 99 map to the years 1900 to 1999 + // so set year explicitly with setFullYear. + const result = new Date(0); + result.setFullYear( + dirtyDate.getUTCFullYear(), + dirtyDate.getUTCMonth(), + dirtyDate.getUTCDate(), + ); + result.setHours( + dirtyDate.getUTCHours(), + dirtyDate.getUTCMinutes(), + dirtyDate.getUTCSeconds(), + dirtyDate.getUTCMilliseconds(), + ); + return result; + } + + return new Date(timestamp + time + offset); +} + +const patterns = { + dateTimeDelimiter: /[T ]/, + timeZoneDelimiter: /[Z ]/i, + timezone: /([Z+-].*)$/, +}; + +const dateRegex = + /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/; +const timeRegex = + /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/; +const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/; + +function splitDateString(dateString) { + const dateStrings = {}; + const array = dateString.split(patterns.dateTimeDelimiter); + let timeString; + + // The regex match should only return at maximum two array elements. + // [date], [time], or [date, time]. + if (array.length > 2) { + return dateStrings; + } + + if (/:/.test(array[0])) { + timeString = array[0]; + } else { + dateStrings.date = array[0]; + timeString = array[1]; + if (patterns.timeZoneDelimiter.test(dateStrings.date)) { + dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0]; + timeString = dateString.substr( + dateStrings.date.length, + dateString.length, + ); + } + } + + if (timeString) { + const token = patterns.timezone.exec(timeString); + if (token) { + dateStrings.time = timeString.replace(token[1], ""); + dateStrings.timezone = token[1]; + } else { + dateStrings.time = timeString; + } + } + + return dateStrings; +} + +function parseYear(dateString, additionalDigits) { + const regex = new RegExp( + "^(?:(\\d{4}|[+-]\\d{" + + (4 + additionalDigits) + + "})|(\\d{2}|[+-]\\d{" + + (2 + additionalDigits) + + "})$)", + ); + + const captures = dateString.match(regex); + // Invalid ISO-formatted year + if (!captures) return { year: NaN, restDateString: "" }; + + const year = captures[1] ? parseInt(captures[1]) : null; + const century = captures[2] ? parseInt(captures[2]) : null; + + // either year or century is null, not both + return { + year: century === null ? year : century * 100, + restDateString: dateString.slice((captures[1] || captures[2]).length), + }; +} + +function parseDate(dateString, year) { + // Invalid ISO-formatted year + if (year === null) return new Date(NaN); + + const captures = dateString.match(dateRegex); + // Invalid ISO-formatted string + if (!captures) return new Date(NaN); + + const isWeekDate = !!captures[4]; + const dayOfYear = parseDateUnit(captures[1]); + const month = parseDateUnit(captures[2]) - 1; + const day = parseDateUnit(captures[3]); + const week = parseDateUnit(captures[4]); + const dayOfWeek = parseDateUnit(captures[5]) - 1; + + if (isWeekDate) { + if (!validateWeekDate(year, week, dayOfWeek)) { + return new Date(NaN); + } + return dayOfISOWeekYear(year, week, dayOfWeek); + } else { + const date = new Date(0); + if ( + !validateDate(year, month, day) || + !validateDayOfYearDate(year, dayOfYear) + ) { + return new Date(NaN); + } + date.setUTCFullYear(year, month, Math.max(dayOfYear, day)); + return date; + } +} + +function parseDateUnit(value) { + return value ? parseInt(value) : 1; +} + +function parseTime(timeString) { + const captures = timeString.match(timeRegex); + if (!captures) return NaN; // Invalid ISO-formatted time + + const hours = parseTimeUnit(captures[1]); + const minutes = parseTimeUnit(captures[2]); + const seconds = parseTimeUnit(captures[3]); + + if (!validateTime(hours, minutes, seconds)) { + return NaN; + } + + return ( + hours * _index.millisecondsInHour + + minutes * _index.millisecondsInMinute + + seconds * 1000 + ); +} + +function parseTimeUnit(value) { + return (value && parseFloat(value.replace(",", "."))) || 0; +} + +function parseTimezone(timezoneString) { + if (timezoneString === "Z") return 0; + + const captures = timezoneString.match(timezoneRegex); + if (!captures) return 0; + + const sign = captures[1] === "+" ? -1 : 1; + const hours = parseInt(captures[2]); + const minutes = (captures[3] && parseInt(captures[3])) || 0; + + if (!validateTimezone(hours, minutes)) { + return NaN; + } + + return ( + sign * + (hours * _index.millisecondsInHour + minutes * _index.millisecondsInMinute) + ); +} + +function dayOfISOWeekYear(isoWeekYear, week, day) { + const date = new Date(0); + date.setUTCFullYear(isoWeekYear, 0, 4); + const fourthOfJanuaryDay = date.getUTCDay() || 7; + const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay; + date.setUTCDate(date.getUTCDate() + diff); + return date; +} + +// Validation functions + +// February is null to handle the leap year (using ||) +const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +function isLeapYearIndex(year) { + return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0); +} + +function validateDate(year, month, date) { + return ( + month >= 0 && + month <= 11 && + date >= 1 && + date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28)) + ); +} + +function validateDayOfYearDate(year, dayOfYear) { + return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365); +} + +function validateWeekDate(_year, week, day) { + return week >= 1 && week <= 53 && day >= 0 && day <= 6; +} + +function validateTime(hours, minutes, seconds) { + if (hours === 24) { + return minutes === 0 && seconds === 0; + } + + return ( + seconds >= 0 && + seconds < 60 && + minutes >= 0 && + minutes < 60 && + hours >= 0 && + hours < 25 + ); +} + +function validateTimezone(_hours, minutes) { + return minutes >= 0 && minutes <= 59; +} + + +/***/ }), + +/***/ 50135: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +exports.parseJSON = parseJSON; /** + * @name parseJSON + * @category Common Helpers + * @summary Parse a JSON date string + * + * @description + * Converts a complete ISO date string in UTC time, the typical format for transmitting + * a date in JSON, to a JavaScript `Date` instance. + * + * This is a minimal implementation for converting dates retrieved from a JSON API to + * a `Date` instance which can be used with other functions in the `date-fns` library. + * The following formats are supported: + * + * - `2000-03-15T05:20:10.123Z`: The output of `.toISOString()` and `JSON.stringify(new Date())` + * - `2000-03-15T05:20:10Z`: Without milliseconds + * - `2000-03-15T05:20:10+00:00`: With a zero offset, the default JSON encoded format in some other languages + * - `2000-03-15T05:20:10+05:45`: With a positive or negative offset, the default JSON encoded format in some other languages + * - `2000-03-15T05:20:10+0000`: With a zero offset without a colon + * - `2000-03-15T05:20:10`: Without a trailing 'Z' symbol + * - `2000-03-15T05:20:10.1234567`: Up to 7 digits in milliseconds field. Only first 3 are taken into account since JS does not allow fractional milliseconds + * - `2000-03-15 05:20:10`: With a space instead of a 'T' separator for APIs returning a SQL date without reformatting + * + * For convenience and ease of use these other input types are also supported + * via [toDate](https://date-fns.org/docs/toDate): + * + * - A `Date` instance will be cloned + * - A `number` will be treated as a timestamp + * + * Any other input type or invalid date strings will return an `Invalid Date`. + * + * @param dateStr - A fully formed ISO8601 date string to convert + * + * @returns The parsed date in the local time zone + */ +function parseJSON(dateStr) { + const parts = dateStr.match( + /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/, + ); + if (parts) { + // Group 8 matches the sign + return new Date( + Date.UTC( + +parts[1], + +parts[2] - 1, + +parts[3], + +parts[4] - (+parts[9] || 0) * (parts[8] == "-" ? -1 : 1), + +parts[5] - (+parts[10] || 0) * (parts[8] == "-" ? -1 : 1), + +parts[6], + +((parts[7] || "0") + "00").substring(0, 3), + ), + ); + } + return new Date(NaN); +} + + /***/ }), /***/ 456: