11697 lines
2.6 MiB
JavaScript
11697 lines
2.6 MiB
JavaScript
|
/*
|
|||
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|||
|
if you want to view the source, please visit the github repository of this plugin
|
|||
|
*/
|
|||
|
|
|||
|
"use strict";
|
|||
|
var __create = Object.create;
|
|||
|
var __defProp = Object.defineProperty;
|
|||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|||
|
var __getProtoOf = Object.getPrototypeOf;
|
|||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|||
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|||
|
var __commonJS = (cb, mod) => function __require() {
|
|||
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|||
|
};
|
|||
|
var __export = (target, all) => {
|
|||
|
for (var name in all)
|
|||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|||
|
};
|
|||
|
var __copyProps = (to, from, except, desc) => {
|
|||
|
if (from && typeof from === "object" || typeof from === "function") {
|
|||
|
for (let key of __getOwnPropNames(from))
|
|||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|||
|
}
|
|||
|
return to;
|
|||
|
};
|
|||
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|||
|
// If the importer is in node compatibility mode or this is not an ESM
|
|||
|
// file that has been converted to a CommonJS file using a Babel-
|
|||
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|||
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|||
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|||
|
mod
|
|||
|
));
|
|||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|||
|
var __publicField = (obj, key, value) => {
|
|||
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|||
|
return value;
|
|||
|
};
|
|||
|
|
|||
|
// node_modules/obsidian-dataview/lib/index.js
|
|||
|
var require_lib = __commonJS({
|
|||
|
"node_modules/obsidian-dataview/lib/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
require("obsidian");
|
|||
|
var LuxonError = class extends Error {
|
|||
|
};
|
|||
|
var InvalidDateTimeError = class extends LuxonError {
|
|||
|
constructor(reason) {
|
|||
|
super(`Invalid DateTime: ${reason.toMessage()}`);
|
|||
|
}
|
|||
|
};
|
|||
|
var InvalidIntervalError = class extends LuxonError {
|
|||
|
constructor(reason) {
|
|||
|
super(`Invalid Interval: ${reason.toMessage()}`);
|
|||
|
}
|
|||
|
};
|
|||
|
var InvalidDurationError = class extends LuxonError {
|
|||
|
constructor(reason) {
|
|||
|
super(`Invalid Duration: ${reason.toMessage()}`);
|
|||
|
}
|
|||
|
};
|
|||
|
var ConflictingSpecificationError = class extends LuxonError {
|
|||
|
};
|
|||
|
var InvalidUnitError = class extends LuxonError {
|
|||
|
constructor(unit) {
|
|||
|
super(`Invalid unit ${unit}`);
|
|||
|
}
|
|||
|
};
|
|||
|
var InvalidArgumentError = class extends LuxonError {
|
|||
|
};
|
|||
|
var ZoneIsAbstractError = class extends LuxonError {
|
|||
|
constructor() {
|
|||
|
super("Zone is an abstract class");
|
|||
|
}
|
|||
|
};
|
|||
|
var n = "numeric";
|
|||
|
var s = "short";
|
|||
|
var l = "long";
|
|||
|
var DATE_SHORT = {
|
|||
|
year: n,
|
|||
|
month: n,
|
|||
|
day: n
|
|||
|
};
|
|||
|
var DATE_MED = {
|
|||
|
year: n,
|
|||
|
month: s,
|
|||
|
day: n
|
|||
|
};
|
|||
|
var DATE_MED_WITH_WEEKDAY = {
|
|||
|
year: n,
|
|||
|
month: s,
|
|||
|
day: n,
|
|||
|
weekday: s
|
|||
|
};
|
|||
|
var DATE_FULL = {
|
|||
|
year: n,
|
|||
|
month: l,
|
|||
|
day: n
|
|||
|
};
|
|||
|
var DATE_HUGE = {
|
|||
|
year: n,
|
|||
|
month: l,
|
|||
|
day: n,
|
|||
|
weekday: l
|
|||
|
};
|
|||
|
var TIME_SIMPLE = {
|
|||
|
hour: n,
|
|||
|
minute: n
|
|||
|
};
|
|||
|
var TIME_WITH_SECONDS = {
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n
|
|||
|
};
|
|||
|
var TIME_WITH_SHORT_OFFSET = {
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n,
|
|||
|
timeZoneName: s
|
|||
|
};
|
|||
|
var TIME_WITH_LONG_OFFSET = {
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n,
|
|||
|
timeZoneName: l
|
|||
|
};
|
|||
|
var TIME_24_SIMPLE = {
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
hourCycle: "h23"
|
|||
|
};
|
|||
|
var TIME_24_WITH_SECONDS = {
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n,
|
|||
|
hourCycle: "h23"
|
|||
|
};
|
|||
|
var TIME_24_WITH_SHORT_OFFSET = {
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n,
|
|||
|
hourCycle: "h23",
|
|||
|
timeZoneName: s
|
|||
|
};
|
|||
|
var TIME_24_WITH_LONG_OFFSET = {
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n,
|
|||
|
hourCycle: "h23",
|
|||
|
timeZoneName: l
|
|||
|
};
|
|||
|
var DATETIME_SHORT = {
|
|||
|
year: n,
|
|||
|
month: n,
|
|||
|
day: n,
|
|||
|
hour: n,
|
|||
|
minute: n
|
|||
|
};
|
|||
|
var DATETIME_SHORT_WITH_SECONDS = {
|
|||
|
year: n,
|
|||
|
month: n,
|
|||
|
day: n,
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n
|
|||
|
};
|
|||
|
var DATETIME_MED = {
|
|||
|
year: n,
|
|||
|
month: s,
|
|||
|
day: n,
|
|||
|
hour: n,
|
|||
|
minute: n
|
|||
|
};
|
|||
|
var DATETIME_MED_WITH_SECONDS = {
|
|||
|
year: n,
|
|||
|
month: s,
|
|||
|
day: n,
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n
|
|||
|
};
|
|||
|
var DATETIME_MED_WITH_WEEKDAY = {
|
|||
|
year: n,
|
|||
|
month: s,
|
|||
|
day: n,
|
|||
|
weekday: s,
|
|||
|
hour: n,
|
|||
|
minute: n
|
|||
|
};
|
|||
|
var DATETIME_FULL = {
|
|||
|
year: n,
|
|||
|
month: l,
|
|||
|
day: n,
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
timeZoneName: s
|
|||
|
};
|
|||
|
var DATETIME_FULL_WITH_SECONDS = {
|
|||
|
year: n,
|
|||
|
month: l,
|
|||
|
day: n,
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n,
|
|||
|
timeZoneName: s
|
|||
|
};
|
|||
|
var DATETIME_HUGE = {
|
|||
|
year: n,
|
|||
|
month: l,
|
|||
|
day: n,
|
|||
|
weekday: l,
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
timeZoneName: l
|
|||
|
};
|
|||
|
var DATETIME_HUGE_WITH_SECONDS = {
|
|||
|
year: n,
|
|||
|
month: l,
|
|||
|
day: n,
|
|||
|
weekday: l,
|
|||
|
hour: n,
|
|||
|
minute: n,
|
|||
|
second: n,
|
|||
|
timeZoneName: l
|
|||
|
};
|
|||
|
var Zone = class {
|
|||
|
/**
|
|||
|
* The type of zone
|
|||
|
* @abstract
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get type() {
|
|||
|
throw new ZoneIsAbstractError();
|
|||
|
}
|
|||
|
/**
|
|||
|
* The name of this zone.
|
|||
|
* @abstract
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get name() {
|
|||
|
throw new ZoneIsAbstractError();
|
|||
|
}
|
|||
|
get ianaName() {
|
|||
|
return this.name;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns whether the offset is known to be fixed for the whole year.
|
|||
|
* @abstract
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
get isUniversal() {
|
|||
|
throw new ZoneIsAbstractError();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the offset's common name (such as EST) at the specified timestamp
|
|||
|
* @abstract
|
|||
|
* @param {number} ts - Epoch milliseconds for which to get the name
|
|||
|
* @param {Object} opts - Options to affect the format
|
|||
|
* @param {string} opts.format - What style of offset to return. Accepts 'long' or 'short'.
|
|||
|
* @param {string} opts.locale - What locale to return the offset name in.
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
offsetName(ts, opts) {
|
|||
|
throw new ZoneIsAbstractError();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the offset's value as a string
|
|||
|
* @abstract
|
|||
|
* @param {number} ts - Epoch milliseconds for which to get the offset
|
|||
|
* @param {string} format - What style of offset to return.
|
|||
|
* Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
formatOffset(ts, format) {
|
|||
|
throw new ZoneIsAbstractError();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return the offset in minutes for this zone at the specified timestamp.
|
|||
|
* @abstract
|
|||
|
* @param {number} ts - Epoch milliseconds for which to compute the offset
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
offset(ts) {
|
|||
|
throw new ZoneIsAbstractError();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Zone is equal to another zone
|
|||
|
* @abstract
|
|||
|
* @param {Zone} otherZone - the zone to compare
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
equals(otherZone) {
|
|||
|
throw new ZoneIsAbstractError();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Zone is valid.
|
|||
|
* @abstract
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
get isValid() {
|
|||
|
throw new ZoneIsAbstractError();
|
|||
|
}
|
|||
|
};
|
|||
|
var singleton$1 = null;
|
|||
|
var SystemZone = class extends Zone {
|
|||
|
/**
|
|||
|
* Get a singleton instance of the local zone
|
|||
|
* @return {SystemZone}
|
|||
|
*/
|
|||
|
static get instance() {
|
|||
|
if (singleton$1 === null) {
|
|||
|
singleton$1 = new SystemZone();
|
|||
|
}
|
|||
|
return singleton$1;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get type() {
|
|||
|
return "system";
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get name() {
|
|||
|
return new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get isUniversal() {
|
|||
|
return false;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
offsetName(ts, { format, locale }) {
|
|||
|
return parseZoneInfo(ts, format, locale);
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
formatOffset(ts, format) {
|
|||
|
return formatOffset(this.offset(ts), format);
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
offset(ts) {
|
|||
|
return -new Date(ts).getTimezoneOffset();
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
equals(otherZone) {
|
|||
|
return otherZone.type === "system";
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get isValid() {
|
|||
|
return true;
|
|||
|
}
|
|||
|
};
|
|||
|
var dtfCache = {};
|
|||
|
function makeDTF(zone) {
|
|||
|
if (!dtfCache[zone]) {
|
|||
|
dtfCache[zone] = new Intl.DateTimeFormat("en-US", {
|
|||
|
hour12: false,
|
|||
|
timeZone: zone,
|
|||
|
year: "numeric",
|
|||
|
month: "2-digit",
|
|||
|
day: "2-digit",
|
|||
|
hour: "2-digit",
|
|||
|
minute: "2-digit",
|
|||
|
second: "2-digit",
|
|||
|
era: "short"
|
|||
|
});
|
|||
|
}
|
|||
|
return dtfCache[zone];
|
|||
|
}
|
|||
|
var typeToPos = {
|
|||
|
year: 0,
|
|||
|
month: 1,
|
|||
|
day: 2,
|
|||
|
era: 3,
|
|||
|
hour: 4,
|
|||
|
minute: 5,
|
|||
|
second: 6
|
|||
|
};
|
|||
|
function hackyOffset(dtf, date) {
|
|||
|
const formatted = dtf.format(date).replace(/\u200E/g, ""), parsed = /(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(formatted), [, fMonth, fDay, fYear, fadOrBc, fHour, fMinute, fSecond] = parsed;
|
|||
|
return [fYear, fMonth, fDay, fadOrBc, fHour, fMinute, fSecond];
|
|||
|
}
|
|||
|
function partsOffset(dtf, date) {
|
|||
|
const formatted = dtf.formatToParts(date);
|
|||
|
const filled = [];
|
|||
|
for (let i = 0; i < formatted.length; i++) {
|
|||
|
const { type, value } = formatted[i];
|
|||
|
const pos = typeToPos[type];
|
|||
|
if (type === "era") {
|
|||
|
filled[pos] = value;
|
|||
|
} else if (!isUndefined(pos)) {
|
|||
|
filled[pos] = parseInt(value, 10);
|
|||
|
}
|
|||
|
}
|
|||
|
return filled;
|
|||
|
}
|
|||
|
var ianaZoneCache = {};
|
|||
|
var IANAZone = class extends Zone {
|
|||
|
/**
|
|||
|
* @param {string} name - Zone name
|
|||
|
* @return {IANAZone}
|
|||
|
*/
|
|||
|
static create(name) {
|
|||
|
if (!ianaZoneCache[name]) {
|
|||
|
ianaZoneCache[name] = new IANAZone(name);
|
|||
|
}
|
|||
|
return ianaZoneCache[name];
|
|||
|
}
|
|||
|
/**
|
|||
|
* Reset local caches. Should only be necessary in testing scenarios.
|
|||
|
* @return {void}
|
|||
|
*/
|
|||
|
static resetCache() {
|
|||
|
ianaZoneCache = {};
|
|||
|
dtfCache = {};
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns whether the provided string is a valid specifier. This only checks the string's format, not that the specifier identifies a known zone; see isValidZone for that.
|
|||
|
* @param {string} s - The string to check validity on
|
|||
|
* @example IANAZone.isValidSpecifier("America/New_York") //=> true
|
|||
|
* @example IANAZone.isValidSpecifier("Sport~~blorp") //=> false
|
|||
|
* @deprecated This method returns false for some valid IANA names. Use isValidZone instead.
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
static isValidSpecifier(s2) {
|
|||
|
return this.isValidZone(s2);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns whether the provided string identifies a real zone
|
|||
|
* @param {string} zone - The string to check
|
|||
|
* @example IANAZone.isValidZone("America/New_York") //=> true
|
|||
|
* @example IANAZone.isValidZone("Fantasia/Castle") //=> false
|
|||
|
* @example IANAZone.isValidZone("Sport~~blorp") //=> false
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
static isValidZone(zone) {
|
|||
|
if (!zone) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
try {
|
|||
|
new Intl.DateTimeFormat("en-US", { timeZone: zone }).format();
|
|||
|
return true;
|
|||
|
} catch (e) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
constructor(name) {
|
|||
|
super();
|
|||
|
this.zoneName = name;
|
|||
|
this.valid = IANAZone.isValidZone(name);
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get type() {
|
|||
|
return "iana";
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get name() {
|
|||
|
return this.zoneName;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get isUniversal() {
|
|||
|
return false;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
offsetName(ts, { format, locale }) {
|
|||
|
return parseZoneInfo(ts, format, locale, this.name);
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
formatOffset(ts, format) {
|
|||
|
return formatOffset(this.offset(ts), format);
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
offset(ts) {
|
|||
|
const date = new Date(ts);
|
|||
|
if (isNaN(date))
|
|||
|
return NaN;
|
|||
|
const dtf = makeDTF(this.name);
|
|||
|
let [year, month, day, adOrBc, hour, minute, second] = dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date);
|
|||
|
if (adOrBc === "BC") {
|
|||
|
year = -Math.abs(year) + 1;
|
|||
|
}
|
|||
|
const adjustedHour = hour === 24 ? 0 : hour;
|
|||
|
const asUTC = objToLocalTS({
|
|||
|
year,
|
|||
|
month,
|
|||
|
day,
|
|||
|
hour: adjustedHour,
|
|||
|
minute,
|
|||
|
second,
|
|||
|
millisecond: 0
|
|||
|
});
|
|||
|
let asTS = +date;
|
|||
|
const over = asTS % 1e3;
|
|||
|
asTS -= over >= 0 ? over : 1e3 + over;
|
|||
|
return (asUTC - asTS) / (60 * 1e3);
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
equals(otherZone) {
|
|||
|
return otherZone.type === "iana" && otherZone.name === this.name;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get isValid() {
|
|||
|
return this.valid;
|
|||
|
}
|
|||
|
};
|
|||
|
var intlLFCache = {};
|
|||
|
function getCachedLF(locString, opts = {}) {
|
|||
|
const key = JSON.stringify([locString, opts]);
|
|||
|
let dtf = intlLFCache[key];
|
|||
|
if (!dtf) {
|
|||
|
dtf = new Intl.ListFormat(locString, opts);
|
|||
|
intlLFCache[key] = dtf;
|
|||
|
}
|
|||
|
return dtf;
|
|||
|
}
|
|||
|
var intlDTCache = {};
|
|||
|
function getCachedDTF(locString, opts = {}) {
|
|||
|
const key = JSON.stringify([locString, opts]);
|
|||
|
let dtf = intlDTCache[key];
|
|||
|
if (!dtf) {
|
|||
|
dtf = new Intl.DateTimeFormat(locString, opts);
|
|||
|
intlDTCache[key] = dtf;
|
|||
|
}
|
|||
|
return dtf;
|
|||
|
}
|
|||
|
var intlNumCache = {};
|
|||
|
function getCachedINF(locString, opts = {}) {
|
|||
|
const key = JSON.stringify([locString, opts]);
|
|||
|
let inf = intlNumCache[key];
|
|||
|
if (!inf) {
|
|||
|
inf = new Intl.NumberFormat(locString, opts);
|
|||
|
intlNumCache[key] = inf;
|
|||
|
}
|
|||
|
return inf;
|
|||
|
}
|
|||
|
var intlRelCache = {};
|
|||
|
function getCachedRTF(locString, opts = {}) {
|
|||
|
const { base, ...cacheKeyOpts } = opts;
|
|||
|
const key = JSON.stringify([locString, cacheKeyOpts]);
|
|||
|
let inf = intlRelCache[key];
|
|||
|
if (!inf) {
|
|||
|
inf = new Intl.RelativeTimeFormat(locString, opts);
|
|||
|
intlRelCache[key] = inf;
|
|||
|
}
|
|||
|
return inf;
|
|||
|
}
|
|||
|
var sysLocaleCache = null;
|
|||
|
function systemLocale() {
|
|||
|
if (sysLocaleCache) {
|
|||
|
return sysLocaleCache;
|
|||
|
} else {
|
|||
|
sysLocaleCache = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|||
|
return sysLocaleCache;
|
|||
|
}
|
|||
|
}
|
|||
|
function parseLocaleString(localeStr) {
|
|||
|
const xIndex = localeStr.indexOf("-x-");
|
|||
|
if (xIndex !== -1) {
|
|||
|
localeStr = localeStr.substring(0, xIndex);
|
|||
|
}
|
|||
|
const uIndex = localeStr.indexOf("-u-");
|
|||
|
if (uIndex === -1) {
|
|||
|
return [localeStr];
|
|||
|
} else {
|
|||
|
let options;
|
|||
|
let selectedStr;
|
|||
|
try {
|
|||
|
options = getCachedDTF(localeStr).resolvedOptions();
|
|||
|
selectedStr = localeStr;
|
|||
|
} catch (e) {
|
|||
|
const smaller = localeStr.substring(0, uIndex);
|
|||
|
options = getCachedDTF(smaller).resolvedOptions();
|
|||
|
selectedStr = smaller;
|
|||
|
}
|
|||
|
const { numberingSystem, calendar } = options;
|
|||
|
return [selectedStr, numberingSystem, calendar];
|
|||
|
}
|
|||
|
}
|
|||
|
function intlConfigString(localeStr, numberingSystem, outputCalendar) {
|
|||
|
if (outputCalendar || numberingSystem) {
|
|||
|
if (!localeStr.includes("-u-")) {
|
|||
|
localeStr += "-u";
|
|||
|
}
|
|||
|
if (outputCalendar) {
|
|||
|
localeStr += `-ca-${outputCalendar}`;
|
|||
|
}
|
|||
|
if (numberingSystem) {
|
|||
|
localeStr += `-nu-${numberingSystem}`;
|
|||
|
}
|
|||
|
return localeStr;
|
|||
|
} else {
|
|||
|
return localeStr;
|
|||
|
}
|
|||
|
}
|
|||
|
function mapMonths(f) {
|
|||
|
const ms = [];
|
|||
|
for (let i = 1; i <= 12; i++) {
|
|||
|
const dt = DateTime.utc(2016, i, 1);
|
|||
|
ms.push(f(dt));
|
|||
|
}
|
|||
|
return ms;
|
|||
|
}
|
|||
|
function mapWeekdays(f) {
|
|||
|
const ms = [];
|
|||
|
for (let i = 1; i <= 7; i++) {
|
|||
|
const dt = DateTime.utc(2016, 11, 13 + i);
|
|||
|
ms.push(f(dt));
|
|||
|
}
|
|||
|
return ms;
|
|||
|
}
|
|||
|
function listStuff(loc, length, defaultOK, englishFn, intlFn) {
|
|||
|
const mode = loc.listingMode(defaultOK);
|
|||
|
if (mode === "error") {
|
|||
|
return null;
|
|||
|
} else if (mode === "en") {
|
|||
|
return englishFn(length);
|
|||
|
} else {
|
|||
|
return intlFn(length);
|
|||
|
}
|
|||
|
}
|
|||
|
function supportsFastNumbers(loc) {
|
|||
|
if (loc.numberingSystem && loc.numberingSystem !== "latn") {
|
|||
|
return false;
|
|||
|
} else {
|
|||
|
return loc.numberingSystem === "latn" || !loc.locale || loc.locale.startsWith("en") || new Intl.DateTimeFormat(loc.intl).resolvedOptions().numberingSystem === "latn";
|
|||
|
}
|
|||
|
}
|
|||
|
var PolyNumberFormatter = class {
|
|||
|
constructor(intl, forceSimple, opts) {
|
|||
|
this.padTo = opts.padTo || 0;
|
|||
|
this.floor = opts.floor || false;
|
|||
|
const { padTo, floor, ...otherOpts } = opts;
|
|||
|
if (!forceSimple || Object.keys(otherOpts).length > 0) {
|
|||
|
const intlOpts = { useGrouping: false, ...opts };
|
|||
|
if (opts.padTo > 0)
|
|||
|
intlOpts.minimumIntegerDigits = opts.padTo;
|
|||
|
this.inf = getCachedINF(intl, intlOpts);
|
|||
|
}
|
|||
|
}
|
|||
|
format(i) {
|
|||
|
if (this.inf) {
|
|||
|
const fixed = this.floor ? Math.floor(i) : i;
|
|||
|
return this.inf.format(fixed);
|
|||
|
} else {
|
|||
|
const fixed = this.floor ? Math.floor(i) : roundTo(i, 3);
|
|||
|
return padStart(fixed, this.padTo);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
var PolyDateFormatter = class {
|
|||
|
constructor(dt, intl, opts) {
|
|||
|
this.opts = opts;
|
|||
|
let z = void 0;
|
|||
|
if (dt.zone.isUniversal) {
|
|||
|
const gmtOffset = -1 * (dt.offset / 60);
|
|||
|
const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
|
|||
|
if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
|
|||
|
z = offsetZ;
|
|||
|
this.dt = dt;
|
|||
|
} else {
|
|||
|
z = "UTC";
|
|||
|
if (opts.timeZoneName) {
|
|||
|
this.dt = dt;
|
|||
|
} else {
|
|||
|
this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1e3);
|
|||
|
}
|
|||
|
}
|
|||
|
} else if (dt.zone.type === "system") {
|
|||
|
this.dt = dt;
|
|||
|
} else {
|
|||
|
this.dt = dt;
|
|||
|
z = dt.zone.name;
|
|||
|
}
|
|||
|
const intlOpts = { ...this.opts };
|
|||
|
intlOpts.timeZone = intlOpts.timeZone || z;
|
|||
|
this.dtf = getCachedDTF(intl, intlOpts);
|
|||
|
}
|
|||
|
format() {
|
|||
|
return this.dtf.format(this.dt.toJSDate());
|
|||
|
}
|
|||
|
formatToParts() {
|
|||
|
return this.dtf.formatToParts(this.dt.toJSDate());
|
|||
|
}
|
|||
|
resolvedOptions() {
|
|||
|
return this.dtf.resolvedOptions();
|
|||
|
}
|
|||
|
};
|
|||
|
var PolyRelFormatter = class {
|
|||
|
constructor(intl, isEnglish, opts) {
|
|||
|
this.opts = { style: "long", ...opts };
|
|||
|
if (!isEnglish && hasRelative()) {
|
|||
|
this.rtf = getCachedRTF(intl, opts);
|
|||
|
}
|
|||
|
}
|
|||
|
format(count, unit) {
|
|||
|
if (this.rtf) {
|
|||
|
return this.rtf.format(count, unit);
|
|||
|
} else {
|
|||
|
return formatRelativeTime(unit, count, this.opts.numeric, this.opts.style !== "long");
|
|||
|
}
|
|||
|
}
|
|||
|
formatToParts(count, unit) {
|
|||
|
if (this.rtf) {
|
|||
|
return this.rtf.formatToParts(count, unit);
|
|||
|
} else {
|
|||
|
return [];
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
var Locale = class {
|
|||
|
static fromOpts(opts) {
|
|||
|
return Locale.create(opts.locale, opts.numberingSystem, opts.outputCalendar, opts.defaultToEN);
|
|||
|
}
|
|||
|
static create(locale, numberingSystem, outputCalendar, defaultToEN = false) {
|
|||
|
const specifiedLocale = locale || Settings2.defaultLocale;
|
|||
|
const localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale());
|
|||
|
const numberingSystemR = numberingSystem || Settings2.defaultNumberingSystem;
|
|||
|
const outputCalendarR = outputCalendar || Settings2.defaultOutputCalendar;
|
|||
|
return new Locale(localeR, numberingSystemR, outputCalendarR, specifiedLocale);
|
|||
|
}
|
|||
|
static resetCache() {
|
|||
|
sysLocaleCache = null;
|
|||
|
intlDTCache = {};
|
|||
|
intlNumCache = {};
|
|||
|
intlRelCache = {};
|
|||
|
}
|
|||
|
static fromObject({ locale, numberingSystem, outputCalendar } = {}) {
|
|||
|
return Locale.create(locale, numberingSystem, outputCalendar);
|
|||
|
}
|
|||
|
constructor(locale, numbering, outputCalendar, specifiedLocale) {
|
|||
|
const [parsedLocale, parsedNumberingSystem, parsedOutputCalendar] = parseLocaleString(locale);
|
|||
|
this.locale = parsedLocale;
|
|||
|
this.numberingSystem = numbering || parsedNumberingSystem || null;
|
|||
|
this.outputCalendar = outputCalendar || parsedOutputCalendar || null;
|
|||
|
this.intl = intlConfigString(this.locale, this.numberingSystem, this.outputCalendar);
|
|||
|
this.weekdaysCache = { format: {}, standalone: {} };
|
|||
|
this.monthsCache = { format: {}, standalone: {} };
|
|||
|
this.meridiemCache = null;
|
|||
|
this.eraCache = {};
|
|||
|
this.specifiedLocale = specifiedLocale;
|
|||
|
this.fastNumbersCached = null;
|
|||
|
}
|
|||
|
get fastNumbers() {
|
|||
|
if (this.fastNumbersCached == null) {
|
|||
|
this.fastNumbersCached = supportsFastNumbers(this);
|
|||
|
}
|
|||
|
return this.fastNumbersCached;
|
|||
|
}
|
|||
|
listingMode() {
|
|||
|
const isActuallyEn = this.isEnglish();
|
|||
|
const hasNoWeirdness = (this.numberingSystem === null || this.numberingSystem === "latn") && (this.outputCalendar === null || this.outputCalendar === "gregory");
|
|||
|
return isActuallyEn && hasNoWeirdness ? "en" : "intl";
|
|||
|
}
|
|||
|
clone(alts) {
|
|||
|
if (!alts || Object.getOwnPropertyNames(alts).length === 0) {
|
|||
|
return this;
|
|||
|
} else {
|
|||
|
return Locale.create(
|
|||
|
alts.locale || this.specifiedLocale,
|
|||
|
alts.numberingSystem || this.numberingSystem,
|
|||
|
alts.outputCalendar || this.outputCalendar,
|
|||
|
alts.defaultToEN || false
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
redefaultToEN(alts = {}) {
|
|||
|
return this.clone({ ...alts, defaultToEN: true });
|
|||
|
}
|
|||
|
redefaultToSystem(alts = {}) {
|
|||
|
return this.clone({ ...alts, defaultToEN: false });
|
|||
|
}
|
|||
|
months(length, format = false, defaultOK = true) {
|
|||
|
return listStuff(this, length, defaultOK, months, () => {
|
|||
|
const intl = format ? { month: length, day: "numeric" } : { month: length }, formatStr = format ? "format" : "standalone";
|
|||
|
if (!this.monthsCache[formatStr][length]) {
|
|||
|
this.monthsCache[formatStr][length] = mapMonths((dt) => this.extract(dt, intl, "month"));
|
|||
|
}
|
|||
|
return this.monthsCache[formatStr][length];
|
|||
|
});
|
|||
|
}
|
|||
|
weekdays(length, format = false, defaultOK = true) {
|
|||
|
return listStuff(this, length, defaultOK, weekdays, () => {
|
|||
|
const intl = format ? { weekday: length, year: "numeric", month: "long", day: "numeric" } : { weekday: length }, formatStr = format ? "format" : "standalone";
|
|||
|
if (!this.weekdaysCache[formatStr][length]) {
|
|||
|
this.weekdaysCache[formatStr][length] = mapWeekdays(
|
|||
|
(dt) => this.extract(dt, intl, "weekday")
|
|||
|
);
|
|||
|
}
|
|||
|
return this.weekdaysCache[formatStr][length];
|
|||
|
});
|
|||
|
}
|
|||
|
meridiems(defaultOK = true) {
|
|||
|
return listStuff(
|
|||
|
this,
|
|||
|
void 0,
|
|||
|
defaultOK,
|
|||
|
() => meridiems,
|
|||
|
() => {
|
|||
|
if (!this.meridiemCache) {
|
|||
|
const intl = { hour: "numeric", hourCycle: "h12" };
|
|||
|
this.meridiemCache = [DateTime.utc(2016, 11, 13, 9), DateTime.utc(2016, 11, 13, 19)].map(
|
|||
|
(dt) => this.extract(dt, intl, "dayperiod")
|
|||
|
);
|
|||
|
}
|
|||
|
return this.meridiemCache;
|
|||
|
}
|
|||
|
);
|
|||
|
}
|
|||
|
eras(length, defaultOK = true) {
|
|||
|
return listStuff(this, length, defaultOK, eras, () => {
|
|||
|
const intl = { era: length };
|
|||
|
if (!this.eraCache[length]) {
|
|||
|
this.eraCache[length] = [DateTime.utc(-40, 1, 1), DateTime.utc(2017, 1, 1)].map(
|
|||
|
(dt) => this.extract(dt, intl, "era")
|
|||
|
);
|
|||
|
}
|
|||
|
return this.eraCache[length];
|
|||
|
});
|
|||
|
}
|
|||
|
extract(dt, intlOpts, field) {
|
|||
|
const df = this.dtFormatter(dt, intlOpts), results = df.formatToParts(), matching = results.find((m) => m.type.toLowerCase() === field);
|
|||
|
return matching ? matching.value : null;
|
|||
|
}
|
|||
|
numberFormatter(opts = {}) {
|
|||
|
return new PolyNumberFormatter(this.intl, opts.forceSimple || this.fastNumbers, opts);
|
|||
|
}
|
|||
|
dtFormatter(dt, intlOpts = {}) {
|
|||
|
return new PolyDateFormatter(dt, this.intl, intlOpts);
|
|||
|
}
|
|||
|
relFormatter(opts = {}) {
|
|||
|
return new PolyRelFormatter(this.intl, this.isEnglish(), opts);
|
|||
|
}
|
|||
|
listFormatter(opts = {}) {
|
|||
|
return getCachedLF(this.intl, opts);
|
|||
|
}
|
|||
|
isEnglish() {
|
|||
|
return this.locale === "en" || this.locale.toLowerCase() === "en-us" || new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us");
|
|||
|
}
|
|||
|
equals(other) {
|
|||
|
return this.locale === other.locale && this.numberingSystem === other.numberingSystem && this.outputCalendar === other.outputCalendar;
|
|||
|
}
|
|||
|
};
|
|||
|
var singleton = null;
|
|||
|
var FixedOffsetZone = class extends Zone {
|
|||
|
/**
|
|||
|
* Get a singleton instance of UTC
|
|||
|
* @return {FixedOffsetZone}
|
|||
|
*/
|
|||
|
static get utcInstance() {
|
|||
|
if (singleton === null) {
|
|||
|
singleton = new FixedOffsetZone(0);
|
|||
|
}
|
|||
|
return singleton;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get an instance with a specified offset
|
|||
|
* @param {number} offset - The offset in minutes
|
|||
|
* @return {FixedOffsetZone}
|
|||
|
*/
|
|||
|
static instance(offset2) {
|
|||
|
return offset2 === 0 ? FixedOffsetZone.utcInstance : new FixedOffsetZone(offset2);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get an instance of FixedOffsetZone from a UTC offset string, like "UTC+6"
|
|||
|
* @param {string} s - The offset string to parse
|
|||
|
* @example FixedOffsetZone.parseSpecifier("UTC+6")
|
|||
|
* @example FixedOffsetZone.parseSpecifier("UTC+06")
|
|||
|
* @example FixedOffsetZone.parseSpecifier("UTC-6:00")
|
|||
|
* @return {FixedOffsetZone}
|
|||
|
*/
|
|||
|
static parseSpecifier(s2) {
|
|||
|
if (s2) {
|
|||
|
const r = s2.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);
|
|||
|
if (r) {
|
|||
|
return new FixedOffsetZone(signedOffset(r[1], r[2]));
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
constructor(offset2) {
|
|||
|
super();
|
|||
|
this.fixed = offset2;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get type() {
|
|||
|
return "fixed";
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get name() {
|
|||
|
return this.fixed === 0 ? "UTC" : `UTC${formatOffset(this.fixed, "narrow")}`;
|
|||
|
}
|
|||
|
get ianaName() {
|
|||
|
if (this.fixed === 0) {
|
|||
|
return "Etc/UTC";
|
|||
|
} else {
|
|||
|
return `Etc/GMT${formatOffset(-this.fixed, "narrow")}`;
|
|||
|
}
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
offsetName() {
|
|||
|
return this.name;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
formatOffset(ts, format) {
|
|||
|
return formatOffset(this.fixed, format);
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get isUniversal() {
|
|||
|
return true;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
offset() {
|
|||
|
return this.fixed;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
equals(otherZone) {
|
|||
|
return otherZone.type === "fixed" && otherZone.fixed === this.fixed;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get isValid() {
|
|||
|
return true;
|
|||
|
}
|
|||
|
};
|
|||
|
var InvalidZone = class extends Zone {
|
|||
|
constructor(zoneName) {
|
|||
|
super();
|
|||
|
this.zoneName = zoneName;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get type() {
|
|||
|
return "invalid";
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get name() {
|
|||
|
return this.zoneName;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get isUniversal() {
|
|||
|
return false;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
offsetName() {
|
|||
|
return null;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
formatOffset() {
|
|||
|
return "";
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
offset() {
|
|||
|
return NaN;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
equals() {
|
|||
|
return false;
|
|||
|
}
|
|||
|
/** @override **/
|
|||
|
get isValid() {
|
|||
|
return false;
|
|||
|
}
|
|||
|
};
|
|||
|
function normalizeZone(input, defaultZone2) {
|
|||
|
if (isUndefined(input) || input === null) {
|
|||
|
return defaultZone2;
|
|||
|
} else if (input instanceof Zone) {
|
|||
|
return input;
|
|||
|
} else if (isString(input)) {
|
|||
|
const lowered = input.toLowerCase();
|
|||
|
if (lowered === "default")
|
|||
|
return defaultZone2;
|
|||
|
else if (lowered === "local" || lowered === "system")
|
|||
|
return SystemZone.instance;
|
|||
|
else if (lowered === "utc" || lowered === "gmt")
|
|||
|
return FixedOffsetZone.utcInstance;
|
|||
|
else
|
|||
|
return FixedOffsetZone.parseSpecifier(lowered) || IANAZone.create(input);
|
|||
|
} else if (isNumber(input)) {
|
|||
|
return FixedOffsetZone.instance(input);
|
|||
|
} else if (typeof input === "object" && input.offset && typeof input.offset === "number") {
|
|||
|
return input;
|
|||
|
} else {
|
|||
|
return new InvalidZone(input);
|
|||
|
}
|
|||
|
}
|
|||
|
var now2 = () => Date.now();
|
|||
|
var defaultZone = "system";
|
|||
|
var defaultLocale = null;
|
|||
|
var defaultNumberingSystem = null;
|
|||
|
var defaultOutputCalendar = null;
|
|||
|
var twoDigitCutoffYear = 60;
|
|||
|
var throwOnInvalid;
|
|||
|
var Settings2 = class {
|
|||
|
/**
|
|||
|
* Get the callback for returning the current timestamp.
|
|||
|
* @type {function}
|
|||
|
*/
|
|||
|
static get now() {
|
|||
|
return now2;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Set the callback for returning the current timestamp.
|
|||
|
* The function should return a number, which will be interpreted as an Epoch millisecond count
|
|||
|
* @type {function}
|
|||
|
* @example Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future
|
|||
|
* @example Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time
|
|||
|
*/
|
|||
|
static set now(n2) {
|
|||
|
now2 = n2;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Set the default time zone to create DateTimes in. Does not affect existing instances.
|
|||
|
* Use the value "system" to reset this value to the system's time zone.
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
static set defaultZone(zone) {
|
|||
|
defaultZone = zone;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the default time zone object currently used to create DateTimes. Does not affect existing instances.
|
|||
|
* The default value is the system's time zone (the one set on the machine that runs this code).
|
|||
|
* @type {Zone}
|
|||
|
*/
|
|||
|
static get defaultZone() {
|
|||
|
return normalizeZone(defaultZone, SystemZone.instance);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the default locale to create DateTimes with. Does not affect existing instances.
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
static get defaultLocale() {
|
|||
|
return defaultLocale;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Set the default locale to create DateTimes with. Does not affect existing instances.
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
static set defaultLocale(locale) {
|
|||
|
defaultLocale = locale;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the default numbering system to create DateTimes with. Does not affect existing instances.
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
static get defaultNumberingSystem() {
|
|||
|
return defaultNumberingSystem;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Set the default numbering system to create DateTimes with. Does not affect existing instances.
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
static set defaultNumberingSystem(numberingSystem) {
|
|||
|
defaultNumberingSystem = numberingSystem;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the default output calendar to create DateTimes with. Does not affect existing instances.
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
static get defaultOutputCalendar() {
|
|||
|
return defaultOutputCalendar;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Set the default output calendar to create DateTimes with. Does not affect existing instances.
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
static set defaultOutputCalendar(outputCalendar) {
|
|||
|
defaultOutputCalendar = outputCalendar;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the cutoff year after which a string encoding a year as two digits is interpreted to occur in the current century.
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
static get twoDigitCutoffYear() {
|
|||
|
return twoDigitCutoffYear;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Set the cutoff year after which a string encoding a year as two digits is interpreted to occur in the current century.
|
|||
|
* @type {number}
|
|||
|
* @example Settings.twoDigitCutoffYear = 0 // cut-off year is 0, so all 'yy' are interpretted as current century
|
|||
|
* @example Settings.twoDigitCutoffYear = 50 // '49' -> 1949; '50' -> 2050
|
|||
|
* @example Settings.twoDigitCutoffYear = 1950 // interpretted as 50
|
|||
|
* @example Settings.twoDigitCutoffYear = 2050 // ALSO interpretted as 50
|
|||
|
*/
|
|||
|
static set twoDigitCutoffYear(cutoffYear) {
|
|||
|
twoDigitCutoffYear = cutoffYear % 100;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
static get throwOnInvalid() {
|
|||
|
return throwOnInvalid;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
static set throwOnInvalid(t) {
|
|||
|
throwOnInvalid = t;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Reset Luxon's global caches. Should only be necessary in testing scenarios.
|
|||
|
* @return {void}
|
|||
|
*/
|
|||
|
static resetCaches() {
|
|||
|
Locale.resetCache();
|
|||
|
IANAZone.resetCache();
|
|||
|
}
|
|||
|
};
|
|||
|
function isUndefined(o) {
|
|||
|
return typeof o === "undefined";
|
|||
|
}
|
|||
|
function isNumber(o) {
|
|||
|
return typeof o === "number";
|
|||
|
}
|
|||
|
function isInteger(o) {
|
|||
|
return typeof o === "number" && o % 1 === 0;
|
|||
|
}
|
|||
|
function isString(o) {
|
|||
|
return typeof o === "string";
|
|||
|
}
|
|||
|
function isDate(o) {
|
|||
|
return Object.prototype.toString.call(o) === "[object Date]";
|
|||
|
}
|
|||
|
function hasRelative() {
|
|||
|
try {
|
|||
|
return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat;
|
|||
|
} catch (e) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
function maybeArray(thing) {
|
|||
|
return Array.isArray(thing) ? thing : [thing];
|
|||
|
}
|
|||
|
function bestBy(arr, by, compare) {
|
|||
|
if (arr.length === 0) {
|
|||
|
return void 0;
|
|||
|
}
|
|||
|
return arr.reduce((best, next) => {
|
|||
|
const pair = [by(next), next];
|
|||
|
if (!best) {
|
|||
|
return pair;
|
|||
|
} else if (compare(best[0], pair[0]) === best[0]) {
|
|||
|
return best;
|
|||
|
} else {
|
|||
|
return pair;
|
|||
|
}
|
|||
|
}, null)[1];
|
|||
|
}
|
|||
|
function pick(obj, keys) {
|
|||
|
return keys.reduce((a, k) => {
|
|||
|
a[k] = obj[k];
|
|||
|
return a;
|
|||
|
}, {});
|
|||
|
}
|
|||
|
function hasOwnProperty(obj, prop) {
|
|||
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|||
|
}
|
|||
|
function integerBetween(thing, bottom, top) {
|
|||
|
return isInteger(thing) && thing >= bottom && thing <= top;
|
|||
|
}
|
|||
|
function floorMod(x, n2) {
|
|||
|
return x - n2 * Math.floor(x / n2);
|
|||
|
}
|
|||
|
function padStart(input, n2 = 2) {
|
|||
|
const isNeg = input < 0;
|
|||
|
let padded;
|
|||
|
if (isNeg) {
|
|||
|
padded = "-" + ("" + -input).padStart(n2, "0");
|
|||
|
} else {
|
|||
|
padded = ("" + input).padStart(n2, "0");
|
|||
|
}
|
|||
|
return padded;
|
|||
|
}
|
|||
|
function parseInteger(string) {
|
|||
|
if (isUndefined(string) || string === null || string === "") {
|
|||
|
return void 0;
|
|||
|
} else {
|
|||
|
return parseInt(string, 10);
|
|||
|
}
|
|||
|
}
|
|||
|
function parseFloating(string) {
|
|||
|
if (isUndefined(string) || string === null || string === "") {
|
|||
|
return void 0;
|
|||
|
} else {
|
|||
|
return parseFloat(string);
|
|||
|
}
|
|||
|
}
|
|||
|
function parseMillis(fraction) {
|
|||
|
if (isUndefined(fraction) || fraction === null || fraction === "") {
|
|||
|
return void 0;
|
|||
|
} else {
|
|||
|
const f = parseFloat("0." + fraction) * 1e3;
|
|||
|
return Math.floor(f);
|
|||
|
}
|
|||
|
}
|
|||
|
function roundTo(number, digits, towardZero = false) {
|
|||
|
const factor = 10 ** digits, rounder = towardZero ? Math.trunc : Math.round;
|
|||
|
return rounder(number * factor) / factor;
|
|||
|
}
|
|||
|
function isLeapYear(year) {
|
|||
|
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|||
|
}
|
|||
|
function daysInYear(year) {
|
|||
|
return isLeapYear(year) ? 366 : 365;
|
|||
|
}
|
|||
|
function daysInMonth(year, month) {
|
|||
|
const modMonth = floorMod(month - 1, 12) + 1, modYear = year + (month - modMonth) / 12;
|
|||
|
if (modMonth === 2) {
|
|||
|
return isLeapYear(modYear) ? 29 : 28;
|
|||
|
} else {
|
|||
|
return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1];
|
|||
|
}
|
|||
|
}
|
|||
|
function objToLocalTS(obj) {
|
|||
|
let d = Date.UTC(
|
|||
|
obj.year,
|
|||
|
obj.month - 1,
|
|||
|
obj.day,
|
|||
|
obj.hour,
|
|||
|
obj.minute,
|
|||
|
obj.second,
|
|||
|
obj.millisecond
|
|||
|
);
|
|||
|
if (obj.year < 100 && obj.year >= 0) {
|
|||
|
d = new Date(d);
|
|||
|
d.setUTCFullYear(d.getUTCFullYear() - 1900);
|
|||
|
}
|
|||
|
return +d;
|
|||
|
}
|
|||
|
function weeksInWeekYear(weekYear) {
|
|||
|
const p1 = (weekYear + Math.floor(weekYear / 4) - Math.floor(weekYear / 100) + Math.floor(weekYear / 400)) % 7, last = weekYear - 1, p2 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7;
|
|||
|
return p1 === 4 || p2 === 3 ? 53 : 52;
|
|||
|
}
|
|||
|
function untruncateYear(year) {
|
|||
|
if (year > 99) {
|
|||
|
return year;
|
|||
|
} else
|
|||
|
return year > Settings2.twoDigitCutoffYear ? 1900 + year : 2e3 + year;
|
|||
|
}
|
|||
|
function parseZoneInfo(ts, offsetFormat, locale, timeZone = null) {
|
|||
|
const date = new Date(ts), intlOpts = {
|
|||
|
hourCycle: "h23",
|
|||
|
year: "numeric",
|
|||
|
month: "2-digit",
|
|||
|
day: "2-digit",
|
|||
|
hour: "2-digit",
|
|||
|
minute: "2-digit"
|
|||
|
};
|
|||
|
if (timeZone) {
|
|||
|
intlOpts.timeZone = timeZone;
|
|||
|
}
|
|||
|
const modified = { timeZoneName: offsetFormat, ...intlOpts };
|
|||
|
const parsed = new Intl.DateTimeFormat(locale, modified).formatToParts(date).find((m) => m.type.toLowerCase() === "timezonename");
|
|||
|
return parsed ? parsed.value : null;
|
|||
|
}
|
|||
|
function signedOffset(offHourStr, offMinuteStr) {
|
|||
|
let offHour = parseInt(offHourStr, 10);
|
|||
|
if (Number.isNaN(offHour)) {
|
|||
|
offHour = 0;
|
|||
|
}
|
|||
|
const offMin = parseInt(offMinuteStr, 10) || 0, offMinSigned = offHour < 0 || Object.is(offHour, -0) ? -offMin : offMin;
|
|||
|
return offHour * 60 + offMinSigned;
|
|||
|
}
|
|||
|
function asNumber(value) {
|
|||
|
const numericValue = Number(value);
|
|||
|
if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue))
|
|||
|
throw new InvalidArgumentError(`Invalid unit value ${value}`);
|
|||
|
return numericValue;
|
|||
|
}
|
|||
|
function normalizeObject(obj, normalizer) {
|
|||
|
const normalized = {};
|
|||
|
for (const u in obj) {
|
|||
|
if (hasOwnProperty(obj, u)) {
|
|||
|
const v = obj[u];
|
|||
|
if (v === void 0 || v === null)
|
|||
|
continue;
|
|||
|
normalized[normalizer(u)] = asNumber(v);
|
|||
|
}
|
|||
|
}
|
|||
|
return normalized;
|
|||
|
}
|
|||
|
function formatOffset(offset2, format) {
|
|||
|
const hours = Math.trunc(Math.abs(offset2 / 60)), minutes = Math.trunc(Math.abs(offset2 % 60)), sign = offset2 >= 0 ? "+" : "-";
|
|||
|
switch (format) {
|
|||
|
case "short":
|
|||
|
return `${sign}${padStart(hours, 2)}:${padStart(minutes, 2)}`;
|
|||
|
case "narrow":
|
|||
|
return `${sign}${hours}${minutes > 0 ? `:${minutes}` : ""}`;
|
|||
|
case "techie":
|
|||
|
return `${sign}${padStart(hours, 2)}${padStart(minutes, 2)}`;
|
|||
|
default:
|
|||
|
throw new RangeError(`Value format ${format} is out of range for property format`);
|
|||
|
}
|
|||
|
}
|
|||
|
function timeObject(obj) {
|
|||
|
return pick(obj, ["hour", "minute", "second", "millisecond"]);
|
|||
|
}
|
|||
|
var monthsLong = [
|
|||
|
"January",
|
|||
|
"February",
|
|||
|
"March",
|
|||
|
"April",
|
|||
|
"May",
|
|||
|
"June",
|
|||
|
"July",
|
|||
|
"August",
|
|||
|
"September",
|
|||
|
"October",
|
|||
|
"November",
|
|||
|
"December"
|
|||
|
];
|
|||
|
var monthsShort = [
|
|||
|
"Jan",
|
|||
|
"Feb",
|
|||
|
"Mar",
|
|||
|
"Apr",
|
|||
|
"May",
|
|||
|
"Jun",
|
|||
|
"Jul",
|
|||
|
"Aug",
|
|||
|
"Sep",
|
|||
|
"Oct",
|
|||
|
"Nov",
|
|||
|
"Dec"
|
|||
|
];
|
|||
|
var monthsNarrow = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"];
|
|||
|
function months(length) {
|
|||
|
switch (length) {
|
|||
|
case "narrow":
|
|||
|
return [...monthsNarrow];
|
|||
|
case "short":
|
|||
|
return [...monthsShort];
|
|||
|
case "long":
|
|||
|
return [...monthsLong];
|
|||
|
case "numeric":
|
|||
|
return ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
|
|||
|
case "2-digit":
|
|||
|
return ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
|
|||
|
default:
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
var weekdaysLong = [
|
|||
|
"Monday",
|
|||
|
"Tuesday",
|
|||
|
"Wednesday",
|
|||
|
"Thursday",
|
|||
|
"Friday",
|
|||
|
"Saturday",
|
|||
|
"Sunday"
|
|||
|
];
|
|||
|
var weekdaysShort = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|||
|
var weekdaysNarrow = ["M", "T", "W", "T", "F", "S", "S"];
|
|||
|
function weekdays(length) {
|
|||
|
switch (length) {
|
|||
|
case "narrow":
|
|||
|
return [...weekdaysNarrow];
|
|||
|
case "short":
|
|||
|
return [...weekdaysShort];
|
|||
|
case "long":
|
|||
|
return [...weekdaysLong];
|
|||
|
case "numeric":
|
|||
|
return ["1", "2", "3", "4", "5", "6", "7"];
|
|||
|
default:
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
var meridiems = ["AM", "PM"];
|
|||
|
var erasLong = ["Before Christ", "Anno Domini"];
|
|||
|
var erasShort = ["BC", "AD"];
|
|||
|
var erasNarrow = ["B", "A"];
|
|||
|
function eras(length) {
|
|||
|
switch (length) {
|
|||
|
case "narrow":
|
|||
|
return [...erasNarrow];
|
|||
|
case "short":
|
|||
|
return [...erasShort];
|
|||
|
case "long":
|
|||
|
return [...erasLong];
|
|||
|
default:
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
function meridiemForDateTime(dt) {
|
|||
|
return meridiems[dt.hour < 12 ? 0 : 1];
|
|||
|
}
|
|||
|
function weekdayForDateTime(dt, length) {
|
|||
|
return weekdays(length)[dt.weekday - 1];
|
|||
|
}
|
|||
|
function monthForDateTime(dt, length) {
|
|||
|
return months(length)[dt.month - 1];
|
|||
|
}
|
|||
|
function eraForDateTime(dt, length) {
|
|||
|
return eras(length)[dt.year < 0 ? 0 : 1];
|
|||
|
}
|
|||
|
function formatRelativeTime(unit, count, numeric = "always", narrow = false) {
|
|||
|
const units = {
|
|||
|
years: ["year", "yr."],
|
|||
|
quarters: ["quarter", "qtr."],
|
|||
|
months: ["month", "mo."],
|
|||
|
weeks: ["week", "wk."],
|
|||
|
days: ["day", "day", "days"],
|
|||
|
hours: ["hour", "hr."],
|
|||
|
minutes: ["minute", "min."],
|
|||
|
seconds: ["second", "sec."]
|
|||
|
};
|
|||
|
const lastable = ["hours", "minutes", "seconds"].indexOf(unit) === -1;
|
|||
|
if (numeric === "auto" && lastable) {
|
|||
|
const isDay = unit === "days";
|
|||
|
switch (count) {
|
|||
|
case 1:
|
|||
|
return isDay ? "tomorrow" : `next ${units[unit][0]}`;
|
|||
|
case -1:
|
|||
|
return isDay ? "yesterday" : `last ${units[unit][0]}`;
|
|||
|
case 0:
|
|||
|
return isDay ? "today" : `this ${units[unit][0]}`;
|
|||
|
}
|
|||
|
}
|
|||
|
const isInPast = Object.is(count, -0) || count < 0, fmtValue = Math.abs(count), singular = fmtValue === 1, lilUnits = units[unit], fmtUnit = narrow ? singular ? lilUnits[1] : lilUnits[2] || lilUnits[1] : singular ? units[unit][0] : unit;
|
|||
|
return isInPast ? `${fmtValue} ${fmtUnit} ago` : `in ${fmtValue} ${fmtUnit}`;
|
|||
|
}
|
|||
|
function stringifyTokens(splits, tokenToString) {
|
|||
|
let s2 = "";
|
|||
|
for (const token of splits) {
|
|||
|
if (token.literal) {
|
|||
|
s2 += token.val;
|
|||
|
} else {
|
|||
|
s2 += tokenToString(token.val);
|
|||
|
}
|
|||
|
}
|
|||
|
return s2;
|
|||
|
}
|
|||
|
var macroTokenToFormatOpts = {
|
|||
|
D: DATE_SHORT,
|
|||
|
DD: DATE_MED,
|
|||
|
DDD: DATE_FULL,
|
|||
|
DDDD: DATE_HUGE,
|
|||
|
t: TIME_SIMPLE,
|
|||
|
tt: TIME_WITH_SECONDS,
|
|||
|
ttt: TIME_WITH_SHORT_OFFSET,
|
|||
|
tttt: TIME_WITH_LONG_OFFSET,
|
|||
|
T: TIME_24_SIMPLE,
|
|||
|
TT: TIME_24_WITH_SECONDS,
|
|||
|
TTT: TIME_24_WITH_SHORT_OFFSET,
|
|||
|
TTTT: TIME_24_WITH_LONG_OFFSET,
|
|||
|
f: DATETIME_SHORT,
|
|||
|
ff: DATETIME_MED,
|
|||
|
fff: DATETIME_FULL,
|
|||
|
ffff: DATETIME_HUGE,
|
|||
|
F: DATETIME_SHORT_WITH_SECONDS,
|
|||
|
FF: DATETIME_MED_WITH_SECONDS,
|
|||
|
FFF: DATETIME_FULL_WITH_SECONDS,
|
|||
|
FFFF: DATETIME_HUGE_WITH_SECONDS
|
|||
|
};
|
|||
|
var Formatter = class {
|
|||
|
static create(locale, opts = {}) {
|
|||
|
return new Formatter(locale, opts);
|
|||
|
}
|
|||
|
static parseFormat(fmt) {
|
|||
|
let current = null, currentFull = "", bracketed = false;
|
|||
|
const splits = [];
|
|||
|
for (let i = 0; i < fmt.length; i++) {
|
|||
|
const c = fmt.charAt(i);
|
|||
|
if (c === "'") {
|
|||
|
if (currentFull.length > 0) {
|
|||
|
splits.push({ literal: bracketed, val: currentFull });
|
|||
|
}
|
|||
|
current = null;
|
|||
|
currentFull = "";
|
|||
|
bracketed = !bracketed;
|
|||
|
} else if (bracketed) {
|
|||
|
currentFull += c;
|
|||
|
} else if (c === current) {
|
|||
|
currentFull += c;
|
|||
|
} else {
|
|||
|
if (currentFull.length > 0) {
|
|||
|
splits.push({ literal: false, val: currentFull });
|
|||
|
}
|
|||
|
currentFull = c;
|
|||
|
current = c;
|
|||
|
}
|
|||
|
}
|
|||
|
if (currentFull.length > 0) {
|
|||
|
splits.push({ literal: bracketed, val: currentFull });
|
|||
|
}
|
|||
|
return splits;
|
|||
|
}
|
|||
|
static macroTokenToFormatOpts(token) {
|
|||
|
return macroTokenToFormatOpts[token];
|
|||
|
}
|
|||
|
constructor(locale, formatOpts) {
|
|||
|
this.opts = formatOpts;
|
|||
|
this.loc = locale;
|
|||
|
this.systemLoc = null;
|
|||
|
}
|
|||
|
formatWithSystemDefault(dt, opts) {
|
|||
|
if (this.systemLoc === null) {
|
|||
|
this.systemLoc = this.loc.redefaultToSystem();
|
|||
|
}
|
|||
|
const df = this.systemLoc.dtFormatter(dt, { ...this.opts, ...opts });
|
|||
|
return df.format();
|
|||
|
}
|
|||
|
formatDateTime(dt, opts = {}) {
|
|||
|
const df = this.loc.dtFormatter(dt, { ...this.opts, ...opts });
|
|||
|
return df.format();
|
|||
|
}
|
|||
|
formatDateTimeParts(dt, opts = {}) {
|
|||
|
const df = this.loc.dtFormatter(dt, { ...this.opts, ...opts });
|
|||
|
return df.formatToParts();
|
|||
|
}
|
|||
|
formatInterval(interval, opts = {}) {
|
|||
|
const df = this.loc.dtFormatter(interval.start, { ...this.opts, ...opts });
|
|||
|
return df.dtf.formatRange(interval.start.toJSDate(), interval.end.toJSDate());
|
|||
|
}
|
|||
|
resolvedOptions(dt, opts = {}) {
|
|||
|
const df = this.loc.dtFormatter(dt, { ...this.opts, ...opts });
|
|||
|
return df.resolvedOptions();
|
|||
|
}
|
|||
|
num(n2, p = 0) {
|
|||
|
if (this.opts.forceSimple) {
|
|||
|
return padStart(n2, p);
|
|||
|
}
|
|||
|
const opts = { ...this.opts };
|
|||
|
if (p > 0) {
|
|||
|
opts.padTo = p;
|
|||
|
}
|
|||
|
return this.loc.numberFormatter(opts).format(n2);
|
|||
|
}
|
|||
|
formatDateTimeFromString(dt, fmt) {
|
|||
|
const knownEnglish = this.loc.listingMode() === "en", useDateTimeFormatter = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory", string = (opts, extract) => this.loc.extract(dt, opts, extract), formatOffset2 = (opts) => {
|
|||
|
if (dt.isOffsetFixed && dt.offset === 0 && opts.allowZ) {
|
|||
|
return "Z";
|
|||
|
}
|
|||
|
return dt.isValid ? dt.zone.formatOffset(dt.ts, opts.format) : "";
|
|||
|
}, meridiem = () => knownEnglish ? meridiemForDateTime(dt) : string({ hour: "numeric", hourCycle: "h12" }, "dayperiod"), month = (length, standalone) => knownEnglish ? monthForDateTime(dt, length) : string(standalone ? { month: length } : { month: length, day: "numeric" }, "month"), weekday = (length, standalone) => knownEnglish ? weekdayForDateTime(dt, length) : string(
|
|||
|
standalone ? { weekday: length } : { weekday: length, month: "long", day: "numeric" },
|
|||
|
"weekday"
|
|||
|
), maybeMacro = (token) => {
|
|||
|
const formatOpts = Formatter.macroTokenToFormatOpts(token);
|
|||
|
if (formatOpts) {
|
|||
|
return this.formatWithSystemDefault(dt, formatOpts);
|
|||
|
} else {
|
|||
|
return token;
|
|||
|
}
|
|||
|
}, era = (length) => knownEnglish ? eraForDateTime(dt, length) : string({ era: length }, "era"), tokenToString = (token) => {
|
|||
|
switch (token) {
|
|||
|
case "S":
|
|||
|
return this.num(dt.millisecond);
|
|||
|
case "u":
|
|||
|
case "SSS":
|
|||
|
return this.num(dt.millisecond, 3);
|
|||
|
case "s":
|
|||
|
return this.num(dt.second);
|
|||
|
case "ss":
|
|||
|
return this.num(dt.second, 2);
|
|||
|
case "uu":
|
|||
|
return this.num(Math.floor(dt.millisecond / 10), 2);
|
|||
|
case "uuu":
|
|||
|
return this.num(Math.floor(dt.millisecond / 100));
|
|||
|
case "m":
|
|||
|
return this.num(dt.minute);
|
|||
|
case "mm":
|
|||
|
return this.num(dt.minute, 2);
|
|||
|
case "h":
|
|||
|
return this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12);
|
|||
|
case "hh":
|
|||
|
return this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12, 2);
|
|||
|
case "H":
|
|||
|
return this.num(dt.hour);
|
|||
|
case "HH":
|
|||
|
return this.num(dt.hour, 2);
|
|||
|
case "Z":
|
|||
|
return formatOffset2({ format: "narrow", allowZ: this.opts.allowZ });
|
|||
|
case "ZZ":
|
|||
|
return formatOffset2({ format: "short", allowZ: this.opts.allowZ });
|
|||
|
case "ZZZ":
|
|||
|
return formatOffset2({ format: "techie", allowZ: this.opts.allowZ });
|
|||
|
case "ZZZZ":
|
|||
|
return dt.zone.offsetName(dt.ts, { format: "short", locale: this.loc.locale });
|
|||
|
case "ZZZZZ":
|
|||
|
return dt.zone.offsetName(dt.ts, { format: "long", locale: this.loc.locale });
|
|||
|
case "z":
|
|||
|
return dt.zoneName;
|
|||
|
case "a":
|
|||
|
return meridiem();
|
|||
|
case "d":
|
|||
|
return useDateTimeFormatter ? string({ day: "numeric" }, "day") : this.num(dt.day);
|
|||
|
case "dd":
|
|||
|
return useDateTimeFormatter ? string({ day: "2-digit" }, "day") : this.num(dt.day, 2);
|
|||
|
case "c":
|
|||
|
return this.num(dt.weekday);
|
|||
|
case "ccc":
|
|||
|
return weekday("short", true);
|
|||
|
case "cccc":
|
|||
|
return weekday("long", true);
|
|||
|
case "ccccc":
|
|||
|
return weekday("narrow", true);
|
|||
|
case "E":
|
|||
|
return this.num(dt.weekday);
|
|||
|
case "EEE":
|
|||
|
return weekday("short", false);
|
|||
|
case "EEEE":
|
|||
|
return weekday("long", false);
|
|||
|
case "EEEEE":
|
|||
|
return weekday("narrow", false);
|
|||
|
case "L":
|
|||
|
return useDateTimeFormatter ? string({ month: "numeric", day: "numeric" }, "month") : this.num(dt.month);
|
|||
|
case "LL":
|
|||
|
return useDateTimeFormatter ? string({ month: "2-digit", day: "numeric" }, "month") : this.num(dt.month, 2);
|
|||
|
case "LLL":
|
|||
|
return month("short", true);
|
|||
|
case "LLLL":
|
|||
|
return month("long", true);
|
|||
|
case "LLLLL":
|
|||
|
return month("narrow", true);
|
|||
|
case "M":
|
|||
|
return useDateTimeFormatter ? string({ month: "numeric" }, "month") : this.num(dt.month);
|
|||
|
case "MM":
|
|||
|
return useDateTimeFormatter ? string({ month: "2-digit" }, "month") : this.num(dt.month, 2);
|
|||
|
case "MMM":
|
|||
|
return month("short", false);
|
|||
|
case "MMMM":
|
|||
|
return month("long", false);
|
|||
|
case "MMMMM":
|
|||
|
return month("narrow", false);
|
|||
|
case "y":
|
|||
|
return useDateTimeFormatter ? string({ year: "numeric" }, "year") : this.num(dt.year);
|
|||
|
case "yy":
|
|||
|
return useDateTimeFormatter ? string({ year: "2-digit" }, "year") : this.num(dt.year.toString().slice(-2), 2);
|
|||
|
case "yyyy":
|
|||
|
return useDateTimeFormatter ? string({ year: "numeric" }, "year") : this.num(dt.year, 4);
|
|||
|
case "yyyyyy":
|
|||
|
return useDateTimeFormatter ? string({ year: "numeric" }, "year") : this.num(dt.year, 6);
|
|||
|
case "G":
|
|||
|
return era("short");
|
|||
|
case "GG":
|
|||
|
return era("long");
|
|||
|
case "GGGGG":
|
|||
|
return era("narrow");
|
|||
|
case "kk":
|
|||
|
return this.num(dt.weekYear.toString().slice(-2), 2);
|
|||
|
case "kkkk":
|
|||
|
return this.num(dt.weekYear, 4);
|
|||
|
case "W":
|
|||
|
return this.num(dt.weekNumber);
|
|||
|
case "WW":
|
|||
|
return this.num(dt.weekNumber, 2);
|
|||
|
case "o":
|
|||
|
return this.num(dt.ordinal);
|
|||
|
case "ooo":
|
|||
|
return this.num(dt.ordinal, 3);
|
|||
|
case "q":
|
|||
|
return this.num(dt.quarter);
|
|||
|
case "qq":
|
|||
|
return this.num(dt.quarter, 2);
|
|||
|
case "X":
|
|||
|
return this.num(Math.floor(dt.ts / 1e3));
|
|||
|
case "x":
|
|||
|
return this.num(dt.ts);
|
|||
|
default:
|
|||
|
return maybeMacro(token);
|
|||
|
}
|
|||
|
};
|
|||
|
return stringifyTokens(Formatter.parseFormat(fmt), tokenToString);
|
|||
|
}
|
|||
|
formatDurationFromString(dur, fmt) {
|
|||
|
const tokenToField = (token) => {
|
|||
|
switch (token[0]) {
|
|||
|
case "S":
|
|||
|
return "millisecond";
|
|||
|
case "s":
|
|||
|
return "second";
|
|||
|
case "m":
|
|||
|
return "minute";
|
|||
|
case "h":
|
|||
|
return "hour";
|
|||
|
case "d":
|
|||
|
return "day";
|
|||
|
case "w":
|
|||
|
return "week";
|
|||
|
case "M":
|
|||
|
return "month";
|
|||
|
case "y":
|
|||
|
return "year";
|
|||
|
default:
|
|||
|
return null;
|
|||
|
}
|
|||
|
}, tokenToString = (lildur) => (token) => {
|
|||
|
const mapped = tokenToField(token);
|
|||
|
if (mapped) {
|
|||
|
return this.num(lildur.get(mapped), token.length);
|
|||
|
} else {
|
|||
|
return token;
|
|||
|
}
|
|||
|
}, tokens = Formatter.parseFormat(fmt), realTokens = tokens.reduce(
|
|||
|
(found, { literal, val }) => literal ? found : found.concat(val),
|
|||
|
[]
|
|||
|
), collapsed = dur.shiftTo(...realTokens.map(tokenToField).filter((t) => t));
|
|||
|
return stringifyTokens(tokens, tokenToString(collapsed));
|
|||
|
}
|
|||
|
};
|
|||
|
var Invalid = class {
|
|||
|
constructor(reason, explanation) {
|
|||
|
this.reason = reason;
|
|||
|
this.explanation = explanation;
|
|||
|
}
|
|||
|
toMessage() {
|
|||
|
if (this.explanation) {
|
|||
|
return `${this.reason}: ${this.explanation}`;
|
|||
|
} else {
|
|||
|
return this.reason;
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
var ianaRegex = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
|
|||
|
function combineRegexes(...regexes) {
|
|||
|
const full = regexes.reduce((f, r) => f + r.source, "");
|
|||
|
return RegExp(`^${full}$`);
|
|||
|
}
|
|||
|
function combineExtractors(...extractors) {
|
|||
|
return (m) => extractors.reduce(
|
|||
|
([mergedVals, mergedZone, cursor], ex) => {
|
|||
|
const [val, zone, next] = ex(m, cursor);
|
|||
|
return [{ ...mergedVals, ...val }, zone || mergedZone, next];
|
|||
|
},
|
|||
|
[{}, null, 1]
|
|||
|
).slice(0, 2);
|
|||
|
}
|
|||
|
function parse(s2, ...patterns) {
|
|||
|
if (s2 == null) {
|
|||
|
return [null, null];
|
|||
|
}
|
|||
|
for (const [regex, extractor] of patterns) {
|
|||
|
const m = regex.exec(s2);
|
|||
|
if (m) {
|
|||
|
return extractor(m);
|
|||
|
}
|
|||
|
}
|
|||
|
return [null, null];
|
|||
|
}
|
|||
|
function simpleParse(...keys) {
|
|||
|
return (match2, cursor) => {
|
|||
|
const ret = {};
|
|||
|
let i;
|
|||
|
for (i = 0; i < keys.length; i++) {
|
|||
|
ret[keys[i]] = parseInteger(match2[cursor + i]);
|
|||
|
}
|
|||
|
return [ret, null, cursor + i];
|
|||
|
};
|
|||
|
}
|
|||
|
var offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/;
|
|||
|
var isoExtendedZone = `(?:${offsetRegex.source}?(?:\\[(${ianaRegex.source})\\])?)?`;
|
|||
|
var isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/;
|
|||
|
var isoTimeRegex = RegExp(`${isoTimeBaseRegex.source}${isoExtendedZone}`);
|
|||
|
var isoTimeExtensionRegex = RegExp(`(?:T${isoTimeRegex.source})?`);
|
|||
|
var isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/;
|
|||
|
var isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/;
|
|||
|
var isoOrdinalRegex = /(\d{4})-?(\d{3})/;
|
|||
|
var extractISOWeekData = simpleParse("weekYear", "weekNumber", "weekDay");
|
|||
|
var extractISOOrdinalData = simpleParse("year", "ordinal");
|
|||
|
var sqlYmdRegex = /(\d{4})-(\d\d)-(\d\d)/;
|
|||
|
var sqlTimeRegex = RegExp(
|
|||
|
`${isoTimeBaseRegex.source} ?(?:${offsetRegex.source}|(${ianaRegex.source}))?`
|
|||
|
);
|
|||
|
var sqlTimeExtensionRegex = RegExp(`(?: ${sqlTimeRegex.source})?`);
|
|||
|
function int(match2, pos, fallback) {
|
|||
|
const m = match2[pos];
|
|||
|
return isUndefined(m) ? fallback : parseInteger(m);
|
|||
|
}
|
|||
|
function extractISOYmd(match2, cursor) {
|
|||
|
const item = {
|
|||
|
year: int(match2, cursor),
|
|||
|
month: int(match2, cursor + 1, 1),
|
|||
|
day: int(match2, cursor + 2, 1)
|
|||
|
};
|
|||
|
return [item, null, cursor + 3];
|
|||
|
}
|
|||
|
function extractISOTime(match2, cursor) {
|
|||
|
const item = {
|
|||
|
hours: int(match2, cursor, 0),
|
|||
|
minutes: int(match2, cursor + 1, 0),
|
|||
|
seconds: int(match2, cursor + 2, 0),
|
|||
|
milliseconds: parseMillis(match2[cursor + 3])
|
|||
|
};
|
|||
|
return [item, null, cursor + 4];
|
|||
|
}
|
|||
|
function extractISOOffset(match2, cursor) {
|
|||
|
const local = !match2[cursor] && !match2[cursor + 1], fullOffset = signedOffset(match2[cursor + 1], match2[cursor + 2]), zone = local ? null : FixedOffsetZone.instance(fullOffset);
|
|||
|
return [{}, zone, cursor + 3];
|
|||
|
}
|
|||
|
function extractIANAZone(match2, cursor) {
|
|||
|
const zone = match2[cursor] ? IANAZone.create(match2[cursor]) : null;
|
|||
|
return [{}, zone, cursor + 1];
|
|||
|
}
|
|||
|
var isoTimeOnly = RegExp(`^T?${isoTimeBaseRegex.source}$`);
|
|||
|
var isoDuration = /^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;
|
|||
|
function extractISODuration(match2) {
|
|||
|
const [s2, yearStr, monthStr, weekStr, dayStr, hourStr, minuteStr, secondStr, millisecondsStr] = match2;
|
|||
|
const hasNegativePrefix = s2[0] === "-";
|
|||
|
const negativeSeconds = secondStr && secondStr[0] === "-";
|
|||
|
const maybeNegate = (num, force = false) => num !== void 0 && (force || num && hasNegativePrefix) ? -num : num;
|
|||
|
return [
|
|||
|
{
|
|||
|
years: maybeNegate(parseFloating(yearStr)),
|
|||
|
months: maybeNegate(parseFloating(monthStr)),
|
|||
|
weeks: maybeNegate(parseFloating(weekStr)),
|
|||
|
days: maybeNegate(parseFloating(dayStr)),
|
|||
|
hours: maybeNegate(parseFloating(hourStr)),
|
|||
|
minutes: maybeNegate(parseFloating(minuteStr)),
|
|||
|
seconds: maybeNegate(parseFloating(secondStr), secondStr === "-0"),
|
|||
|
milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds)
|
|||
|
}
|
|||
|
];
|
|||
|
}
|
|||
|
var obsOffsets = {
|
|||
|
GMT: 0,
|
|||
|
EDT: -4 * 60,
|
|||
|
EST: -5 * 60,
|
|||
|
CDT: -5 * 60,
|
|||
|
CST: -6 * 60,
|
|||
|
MDT: -6 * 60,
|
|||
|
MST: -7 * 60,
|
|||
|
PDT: -7 * 60,
|
|||
|
PST: -8 * 60
|
|||
|
};
|
|||
|
function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
|||
|
const result = {
|
|||
|
year: yearStr.length === 2 ? untruncateYear(parseInteger(yearStr)) : parseInteger(yearStr),
|
|||
|
month: monthsShort.indexOf(monthStr) + 1,
|
|||
|
day: parseInteger(dayStr),
|
|||
|
hour: parseInteger(hourStr),
|
|||
|
minute: parseInteger(minuteStr)
|
|||
|
};
|
|||
|
if (secondStr)
|
|||
|
result.second = parseInteger(secondStr);
|
|||
|
if (weekdayStr) {
|
|||
|
result.weekday = weekdayStr.length > 3 ? weekdaysLong.indexOf(weekdayStr) + 1 : weekdaysShort.indexOf(weekdayStr) + 1;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;
|
|||
|
function extractRFC2822(match2) {
|
|||
|
const [
|
|||
|
,
|
|||
|
weekdayStr,
|
|||
|
dayStr,
|
|||
|
monthStr,
|
|||
|
yearStr,
|
|||
|
hourStr,
|
|||
|
minuteStr,
|
|||
|
secondStr,
|
|||
|
obsOffset,
|
|||
|
milOffset,
|
|||
|
offHourStr,
|
|||
|
offMinuteStr
|
|||
|
] = match2, result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
|||
|
let offset2;
|
|||
|
if (obsOffset) {
|
|||
|
offset2 = obsOffsets[obsOffset];
|
|||
|
} else if (milOffset) {
|
|||
|
offset2 = 0;
|
|||
|
} else {
|
|||
|
offset2 = signedOffset(offHourStr, offMinuteStr);
|
|||
|
}
|
|||
|
return [result, new FixedOffsetZone(offset2)];
|
|||
|
}
|
|||
|
function preprocessRFC2822(s2) {
|
|||
|
return s2.replace(/\([^()]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
|
|||
|
}
|
|||
|
var rfc1123 = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/;
|
|||
|
var rfc850 = /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/;
|
|||
|
var ascii = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;
|
|||
|
function extractRFC1123Or850(match2) {
|
|||
|
const [, weekdayStr, dayStr, monthStr, yearStr, hourStr, minuteStr, secondStr] = match2, result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
|||
|
return [result, FixedOffsetZone.utcInstance];
|
|||
|
}
|
|||
|
function extractASCII(match2) {
|
|||
|
const [, weekdayStr, monthStr, dayStr, hourStr, minuteStr, secondStr, yearStr] = match2, result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
|||
|
return [result, FixedOffsetZone.utcInstance];
|
|||
|
}
|
|||
|
var isoYmdWithTimeExtensionRegex = combineRegexes(isoYmdRegex, isoTimeExtensionRegex);
|
|||
|
var isoWeekWithTimeExtensionRegex = combineRegexes(isoWeekRegex, isoTimeExtensionRegex);
|
|||
|
var isoOrdinalWithTimeExtensionRegex = combineRegexes(isoOrdinalRegex, isoTimeExtensionRegex);
|
|||
|
var isoTimeCombinedRegex = combineRegexes(isoTimeRegex);
|
|||
|
var extractISOYmdTimeAndOffset = combineExtractors(
|
|||
|
extractISOYmd,
|
|||
|
extractISOTime,
|
|||
|
extractISOOffset,
|
|||
|
extractIANAZone
|
|||
|
);
|
|||
|
var extractISOWeekTimeAndOffset = combineExtractors(
|
|||
|
extractISOWeekData,
|
|||
|
extractISOTime,
|
|||
|
extractISOOffset,
|
|||
|
extractIANAZone
|
|||
|
);
|
|||
|
var extractISOOrdinalDateAndTime = combineExtractors(
|
|||
|
extractISOOrdinalData,
|
|||
|
extractISOTime,
|
|||
|
extractISOOffset,
|
|||
|
extractIANAZone
|
|||
|
);
|
|||
|
var extractISOTimeAndOffset = combineExtractors(
|
|||
|
extractISOTime,
|
|||
|
extractISOOffset,
|
|||
|
extractIANAZone
|
|||
|
);
|
|||
|
function parseISODate(s2) {
|
|||
|
return parse(
|
|||
|
s2,
|
|||
|
[isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset],
|
|||
|
[isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset],
|
|||
|
[isoOrdinalWithTimeExtensionRegex, extractISOOrdinalDateAndTime],
|
|||
|
[isoTimeCombinedRegex, extractISOTimeAndOffset]
|
|||
|
);
|
|||
|
}
|
|||
|
function parseRFC2822Date(s2) {
|
|||
|
return parse(preprocessRFC2822(s2), [rfc2822, extractRFC2822]);
|
|||
|
}
|
|||
|
function parseHTTPDate(s2) {
|
|||
|
return parse(
|
|||
|
s2,
|
|||
|
[rfc1123, extractRFC1123Or850],
|
|||
|
[rfc850, extractRFC1123Or850],
|
|||
|
[ascii, extractASCII]
|
|||
|
);
|
|||
|
}
|
|||
|
function parseISODuration(s2) {
|
|||
|
return parse(s2, [isoDuration, extractISODuration]);
|
|||
|
}
|
|||
|
var extractISOTimeOnly = combineExtractors(extractISOTime);
|
|||
|
function parseISOTimeOnly(s2) {
|
|||
|
return parse(s2, [isoTimeOnly, extractISOTimeOnly]);
|
|||
|
}
|
|||
|
var sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex);
|
|||
|
var sqlTimeCombinedRegex = combineRegexes(sqlTimeRegex);
|
|||
|
var extractISOTimeOffsetAndIANAZone = combineExtractors(
|
|||
|
extractISOTime,
|
|||
|
extractISOOffset,
|
|||
|
extractIANAZone
|
|||
|
);
|
|||
|
function parseSQL(s2) {
|
|||
|
return parse(
|
|||
|
s2,
|
|||
|
[sqlYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset],
|
|||
|
[sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone]
|
|||
|
);
|
|||
|
}
|
|||
|
var INVALID$2 = "Invalid Duration";
|
|||
|
var lowOrderMatrix = {
|
|||
|
weeks: {
|
|||
|
days: 7,
|
|||
|
hours: 7 * 24,
|
|||
|
minutes: 7 * 24 * 60,
|
|||
|
seconds: 7 * 24 * 60 * 60,
|
|||
|
milliseconds: 7 * 24 * 60 * 60 * 1e3
|
|||
|
},
|
|||
|
days: {
|
|||
|
hours: 24,
|
|||
|
minutes: 24 * 60,
|
|||
|
seconds: 24 * 60 * 60,
|
|||
|
milliseconds: 24 * 60 * 60 * 1e3
|
|||
|
},
|
|||
|
hours: { minutes: 60, seconds: 60 * 60, milliseconds: 60 * 60 * 1e3 },
|
|||
|
minutes: { seconds: 60, milliseconds: 60 * 1e3 },
|
|||
|
seconds: { milliseconds: 1e3 }
|
|||
|
};
|
|||
|
var casualMatrix = {
|
|||
|
years: {
|
|||
|
quarters: 4,
|
|||
|
months: 12,
|
|||
|
weeks: 52,
|
|||
|
days: 365,
|
|||
|
hours: 365 * 24,
|
|||
|
minutes: 365 * 24 * 60,
|
|||
|
seconds: 365 * 24 * 60 * 60,
|
|||
|
milliseconds: 365 * 24 * 60 * 60 * 1e3
|
|||
|
},
|
|||
|
quarters: {
|
|||
|
months: 3,
|
|||
|
weeks: 13,
|
|||
|
days: 91,
|
|||
|
hours: 91 * 24,
|
|||
|
minutes: 91 * 24 * 60,
|
|||
|
seconds: 91 * 24 * 60 * 60,
|
|||
|
milliseconds: 91 * 24 * 60 * 60 * 1e3
|
|||
|
},
|
|||
|
months: {
|
|||
|
weeks: 4,
|
|||
|
days: 30,
|
|||
|
hours: 30 * 24,
|
|||
|
minutes: 30 * 24 * 60,
|
|||
|
seconds: 30 * 24 * 60 * 60,
|
|||
|
milliseconds: 30 * 24 * 60 * 60 * 1e3
|
|||
|
},
|
|||
|
...lowOrderMatrix
|
|||
|
};
|
|||
|
var daysInYearAccurate = 146097 / 400;
|
|||
|
var daysInMonthAccurate = 146097 / 4800;
|
|||
|
var accurateMatrix = {
|
|||
|
years: {
|
|||
|
quarters: 4,
|
|||
|
months: 12,
|
|||
|
weeks: daysInYearAccurate / 7,
|
|||
|
days: daysInYearAccurate,
|
|||
|
hours: daysInYearAccurate * 24,
|
|||
|
minutes: daysInYearAccurate * 24 * 60,
|
|||
|
seconds: daysInYearAccurate * 24 * 60 * 60,
|
|||
|
milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1e3
|
|||
|
},
|
|||
|
quarters: {
|
|||
|
months: 3,
|
|||
|
weeks: daysInYearAccurate / 28,
|
|||
|
days: daysInYearAccurate / 4,
|
|||
|
hours: daysInYearAccurate * 24 / 4,
|
|||
|
minutes: daysInYearAccurate * 24 * 60 / 4,
|
|||
|
seconds: daysInYearAccurate * 24 * 60 * 60 / 4,
|
|||
|
milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1e3 / 4
|
|||
|
},
|
|||
|
months: {
|
|||
|
weeks: daysInMonthAccurate / 7,
|
|||
|
days: daysInMonthAccurate,
|
|||
|
hours: daysInMonthAccurate * 24,
|
|||
|
minutes: daysInMonthAccurate * 24 * 60,
|
|||
|
seconds: daysInMonthAccurate * 24 * 60 * 60,
|
|||
|
milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1e3
|
|||
|
},
|
|||
|
...lowOrderMatrix
|
|||
|
};
|
|||
|
var orderedUnits$1 = [
|
|||
|
"years",
|
|||
|
"quarters",
|
|||
|
"months",
|
|||
|
"weeks",
|
|||
|
"days",
|
|||
|
"hours",
|
|||
|
"minutes",
|
|||
|
"seconds",
|
|||
|
"milliseconds"
|
|||
|
];
|
|||
|
var reverseUnits = orderedUnits$1.slice(0).reverse();
|
|||
|
function clone$1(dur, alts, clear = false) {
|
|||
|
const conf = {
|
|||
|
values: clear ? alts.values : { ...dur.values, ...alts.values || {} },
|
|||
|
loc: dur.loc.clone(alts.loc),
|
|||
|
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy,
|
|||
|
matrix: alts.matrix || dur.matrix
|
|||
|
};
|
|||
|
return new Duration(conf);
|
|||
|
}
|
|||
|
function antiTrunc(n2) {
|
|||
|
return n2 < 0 ? Math.floor(n2) : Math.ceil(n2);
|
|||
|
}
|
|||
|
function convert(matrix, fromMap, fromUnit, toMap, toUnit) {
|
|||
|
const conv = matrix[toUnit][fromUnit], raw = fromMap[fromUnit] / conv, sameSign = Math.sign(raw) === Math.sign(toMap[toUnit]), added = !sameSign && toMap[toUnit] !== 0 && Math.abs(raw) <= 1 ? antiTrunc(raw) : Math.trunc(raw);
|
|||
|
toMap[toUnit] += added;
|
|||
|
fromMap[fromUnit] -= added * conv;
|
|||
|
}
|
|||
|
function normalizeValues(matrix, vals) {
|
|||
|
reverseUnits.reduce((previous, current) => {
|
|||
|
if (!isUndefined(vals[current])) {
|
|||
|
if (previous) {
|
|||
|
convert(matrix, vals, previous, vals, current);
|
|||
|
}
|
|||
|
return current;
|
|||
|
} else {
|
|||
|
return previous;
|
|||
|
}
|
|||
|
}, null);
|
|||
|
}
|
|||
|
function removeZeroes(vals) {
|
|||
|
const newVals = {};
|
|||
|
for (const [key, value] of Object.entries(vals)) {
|
|||
|
if (value !== 0) {
|
|||
|
newVals[key] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
return newVals;
|
|||
|
}
|
|||
|
var Duration = class {
|
|||
|
/**
|
|||
|
* @private
|
|||
|
*/
|
|||
|
constructor(config) {
|
|||
|
const accurate = config.conversionAccuracy === "longterm" || false;
|
|||
|
let matrix = accurate ? accurateMatrix : casualMatrix;
|
|||
|
if (config.matrix) {
|
|||
|
matrix = config.matrix;
|
|||
|
}
|
|||
|
this.values = config.values;
|
|||
|
this.loc = config.loc || Locale.create();
|
|||
|
this.conversionAccuracy = accurate ? "longterm" : "casual";
|
|||
|
this.invalid = config.invalid || null;
|
|||
|
this.matrix = matrix;
|
|||
|
this.isLuxonDuration = true;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create Duration from a number of milliseconds.
|
|||
|
* @param {number} count of milliseconds
|
|||
|
* @param {Object} opts - options for parsing
|
|||
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|||
|
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
static fromMillis(count, opts) {
|
|||
|
return Duration.fromObject({ milliseconds: count }, opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a Duration from a JavaScript object with keys like 'years' and 'hours'.
|
|||
|
* If this object is empty then a zero milliseconds duration is returned.
|
|||
|
* @param {Object} obj - the object to create the DateTime from
|
|||
|
* @param {number} obj.years
|
|||
|
* @param {number} obj.quarters
|
|||
|
* @param {number} obj.months
|
|||
|
* @param {number} obj.weeks
|
|||
|
* @param {number} obj.days
|
|||
|
* @param {number} obj.hours
|
|||
|
* @param {number} obj.minutes
|
|||
|
* @param {number} obj.seconds
|
|||
|
* @param {number} obj.milliseconds
|
|||
|
* @param {Object} [opts=[]] - options for creating this Duration
|
|||
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|||
|
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|||
|
* @param {string} [opts.matrix=Object] - the custom conversion system to use
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
static fromObject(obj, opts = {}) {
|
|||
|
if (obj == null || typeof obj !== "object") {
|
|||
|
throw new InvalidArgumentError(
|
|||
|
`Duration.fromObject: argument expected to be an object, got ${obj === null ? "null" : typeof obj}`
|
|||
|
);
|
|||
|
}
|
|||
|
return new Duration({
|
|||
|
values: normalizeObject(obj, Duration.normalizeUnit),
|
|||
|
loc: Locale.fromObject(opts),
|
|||
|
conversionAccuracy: opts.conversionAccuracy,
|
|||
|
matrix: opts.matrix
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a Duration from DurationLike.
|
|||
|
*
|
|||
|
* @param {Object | number | Duration} durationLike
|
|||
|
* One of:
|
|||
|
* - object with keys like 'years' and 'hours'.
|
|||
|
* - number representing milliseconds
|
|||
|
* - Duration instance
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
static fromDurationLike(durationLike) {
|
|||
|
if (isNumber(durationLike)) {
|
|||
|
return Duration.fromMillis(durationLike);
|
|||
|
} else if (Duration.isDuration(durationLike)) {
|
|||
|
return durationLike;
|
|||
|
} else if (typeof durationLike === "object") {
|
|||
|
return Duration.fromObject(durationLike);
|
|||
|
} else {
|
|||
|
throw new InvalidArgumentError(
|
|||
|
`Unknown duration argument ${durationLike} of type ${typeof durationLike}`
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a Duration from an ISO 8601 duration string.
|
|||
|
* @param {string} text - text to parse
|
|||
|
* @param {Object} opts - options for parsing
|
|||
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|||
|
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|||
|
* @param {string} [opts.matrix=Object] - the preset conversion system to use
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations
|
|||
|
* @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
|
|||
|
* @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
|
|||
|
* @example Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
static fromISO(text2, opts) {
|
|||
|
const [parsed] = parseISODuration(text2);
|
|||
|
if (parsed) {
|
|||
|
return Duration.fromObject(parsed, opts);
|
|||
|
} else {
|
|||
|
return Duration.invalid("unparsable", `the input "${text2}" can't be parsed as ISO 8601`);
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a Duration from an ISO 8601 time string.
|
|||
|
* @param {string} text - text to parse
|
|||
|
* @param {Object} opts - options for parsing
|
|||
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|||
|
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|||
|
* @param {string} [opts.matrix=Object] - the conversion system to use
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Times
|
|||
|
* @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
|
|||
|
* @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
|
|||
|
* @example Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
|
|||
|
* @example Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
|
|||
|
* @example Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
static fromISOTime(text2, opts) {
|
|||
|
const [parsed] = parseISOTimeOnly(text2);
|
|||
|
if (parsed) {
|
|||
|
return Duration.fromObject(parsed, opts);
|
|||
|
} else {
|
|||
|
return Duration.invalid("unparsable", `the input "${text2}" can't be parsed as ISO 8601`);
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create an invalid Duration.
|
|||
|
* @param {string} reason - simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent
|
|||
|
* @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
static invalid(reason, explanation = null) {
|
|||
|
if (!reason) {
|
|||
|
throw new InvalidArgumentError("need to specify a reason the Duration is invalid");
|
|||
|
}
|
|||
|
const invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|||
|
if (Settings2.throwOnInvalid) {
|
|||
|
throw new InvalidDurationError(invalid);
|
|||
|
} else {
|
|||
|
return new Duration({ invalid });
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* @private
|
|||
|
*/
|
|||
|
static normalizeUnit(unit) {
|
|||
|
const normalized = {
|
|||
|
year: "years",
|
|||
|
years: "years",
|
|||
|
quarter: "quarters",
|
|||
|
quarters: "quarters",
|
|||
|
month: "months",
|
|||
|
months: "months",
|
|||
|
week: "weeks",
|
|||
|
weeks: "weeks",
|
|||
|
day: "days",
|
|||
|
days: "days",
|
|||
|
hour: "hours",
|
|||
|
hours: "hours",
|
|||
|
minute: "minutes",
|
|||
|
minutes: "minutes",
|
|||
|
second: "seconds",
|
|||
|
seconds: "seconds",
|
|||
|
millisecond: "milliseconds",
|
|||
|
milliseconds: "milliseconds"
|
|||
|
}[unit ? unit.toLowerCase() : unit];
|
|||
|
if (!normalized)
|
|||
|
throw new InvalidUnitError(unit);
|
|||
|
return normalized;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Check if an object is a Duration. Works across context boundaries
|
|||
|
* @param {object} o
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
static isDuration(o) {
|
|||
|
return o && o.isLuxonDuration || false;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the locale of a Duration, such 'en-GB'
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get locale() {
|
|||
|
return this.isValid ? this.loc.locale : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the numbering system of a Duration, such 'beng'. The numbering system is used when formatting the Duration
|
|||
|
*
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get numberingSystem() {
|
|||
|
return this.isValid ? this.loc.numberingSystem : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens:
|
|||
|
* * `S` for milliseconds
|
|||
|
* * `s` for seconds
|
|||
|
* * `m` for minutes
|
|||
|
* * `h` for hours
|
|||
|
* * `d` for days
|
|||
|
* * `w` for weeks
|
|||
|
* * `M` for months
|
|||
|
* * `y` for years
|
|||
|
* Notes:
|
|||
|
* * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits
|
|||
|
* * Tokens can be escaped by wrapping with single quotes.
|
|||
|
* * The duration will be converted to the set of units in the format string using {@link Duration#shiftTo} and the Durations's conversion accuracy setting.
|
|||
|
* @param {string} fmt - the format string
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {boolean} [opts.floor=true] - floor numerical values
|
|||
|
* @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2"
|
|||
|
* @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002"
|
|||
|
* @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000"
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toFormat(fmt, opts = {}) {
|
|||
|
const fmtOpts = {
|
|||
|
...opts,
|
|||
|
floor: opts.round !== false && opts.floor !== false
|
|||
|
};
|
|||
|
return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID$2;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of a Duration with all units included.
|
|||
|
* To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant.
|
|||
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
|
|||
|
* @param opts - On option object to override the formatting. Accepts the same keys as the options parameter of the native `Int.NumberFormat` constructor, as well as `listStyle`.
|
|||
|
* @example
|
|||
|
* ```js
|
|||
|
* var dur = Duration.fromObject({ days: 1, hours: 5, minutes: 6 })
|
|||
|
* dur.toHuman() //=> '1 day, 5 hours, 6 minutes'
|
|||
|
* dur.toHuman({ listStyle: "long" }) //=> '1 day, 5 hours, and 6 minutes'
|
|||
|
* dur.toHuman({ unitDisplay: "short" }) //=> '1 day, 5 hr, 6 min'
|
|||
|
* ```
|
|||
|
*/
|
|||
|
toHuman(opts = {}) {
|
|||
|
const l2 = orderedUnits$1.map((unit) => {
|
|||
|
const val = this.values[unit];
|
|||
|
if (isUndefined(val)) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
return this.loc.numberFormatter({ style: "unit", unitDisplay: "long", ...opts, unit: unit.slice(0, -1) }).format(val);
|
|||
|
}).filter((n2) => n2);
|
|||
|
return this.loc.listFormatter({ type: "conjunction", style: opts.listStyle || "narrow", ...opts }).format(l2);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a JavaScript object with this Duration's values.
|
|||
|
* @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 }
|
|||
|
* @return {Object}
|
|||
|
*/
|
|||
|
toObject() {
|
|||
|
if (!this.isValid)
|
|||
|
return {};
|
|||
|
return { ...this.values };
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of this Duration.
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations
|
|||
|
* @example Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S'
|
|||
|
* @example Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S'
|
|||
|
* @example Duration.fromObject({ months: 5 }).toISO() //=> 'P5M'
|
|||
|
* @example Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M'
|
|||
|
* @example Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISO() {
|
|||
|
if (!this.isValid)
|
|||
|
return null;
|
|||
|
let s2 = "P";
|
|||
|
if (this.years !== 0)
|
|||
|
s2 += this.years + "Y";
|
|||
|
if (this.months !== 0 || this.quarters !== 0)
|
|||
|
s2 += this.months + this.quarters * 3 + "M";
|
|||
|
if (this.weeks !== 0)
|
|||
|
s2 += this.weeks + "W";
|
|||
|
if (this.days !== 0)
|
|||
|
s2 += this.days + "D";
|
|||
|
if (this.hours !== 0 || this.minutes !== 0 || this.seconds !== 0 || this.milliseconds !== 0)
|
|||
|
s2 += "T";
|
|||
|
if (this.hours !== 0)
|
|||
|
s2 += this.hours + "H";
|
|||
|
if (this.minutes !== 0)
|
|||
|
s2 += this.minutes + "M";
|
|||
|
if (this.seconds !== 0 || this.milliseconds !== 0)
|
|||
|
s2 += roundTo(this.seconds + this.milliseconds / 1e3, 3) + "S";
|
|||
|
if (s2 === "P")
|
|||
|
s2 += "T0S";
|
|||
|
return s2;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day.
|
|||
|
* Note that this will return null if the duration is invalid, negative, or equal to or greater than 24 hours.
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Times
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
|
|||
|
* @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
|
|||
|
* @param {boolean} [opts.includePrefix=false] - include the `T` prefix
|
|||
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|||
|
* @example Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000'
|
|||
|
* @example Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00'
|
|||
|
* @example Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00'
|
|||
|
* @example Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000'
|
|||
|
* @example Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISOTime(opts = {}) {
|
|||
|
if (!this.isValid)
|
|||
|
return null;
|
|||
|
const millis = this.toMillis();
|
|||
|
if (millis < 0 || millis >= 864e5)
|
|||
|
return null;
|
|||
|
opts = {
|
|||
|
suppressMilliseconds: false,
|
|||
|
suppressSeconds: false,
|
|||
|
includePrefix: false,
|
|||
|
format: "extended",
|
|||
|
...opts
|
|||
|
};
|
|||
|
const value = this.shiftTo("hours", "minutes", "seconds", "milliseconds");
|
|||
|
let fmt = opts.format === "basic" ? "hhmm" : "hh:mm";
|
|||
|
if (!opts.suppressSeconds || value.seconds !== 0 || value.milliseconds !== 0) {
|
|||
|
fmt += opts.format === "basic" ? "ss" : ":ss";
|
|||
|
if (!opts.suppressMilliseconds || value.milliseconds !== 0) {
|
|||
|
fmt += ".SSS";
|
|||
|
}
|
|||
|
}
|
|||
|
let str = value.toFormat(fmt);
|
|||
|
if (opts.includePrefix) {
|
|||
|
str = "T" + str;
|
|||
|
}
|
|||
|
return str;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601 representation of this Duration appropriate for use in JSON.
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toJSON() {
|
|||
|
return this.toISO();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601 representation of this Duration appropriate for use in debugging.
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toString() {
|
|||
|
return this.toISO();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an milliseconds value of this Duration.
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
toMillis() {
|
|||
|
return this.as("milliseconds");
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an milliseconds value of this Duration. Alias of {@link toMillis}
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
valueOf() {
|
|||
|
return this.toMillis();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Make this Duration longer by the specified amount. Return a newly-constructed Duration.
|
|||
|
* @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
plus(duration) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const dur = Duration.fromDurationLike(duration), result = {};
|
|||
|
for (const k of orderedUnits$1) {
|
|||
|
if (hasOwnProperty(dur.values, k) || hasOwnProperty(this.values, k)) {
|
|||
|
result[k] = dur.get(k) + this.get(k);
|
|||
|
}
|
|||
|
}
|
|||
|
return clone$1(this, { values: result }, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Make this Duration shorter by the specified amount. Return a newly-constructed Duration.
|
|||
|
* @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
minus(duration) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const dur = Duration.fromDurationLike(duration);
|
|||
|
return this.plus(dur.negate());
|
|||
|
}
|
|||
|
/**
|
|||
|
* Scale this Duration by the specified amount. Return a newly-constructed Duration.
|
|||
|
* @param {function} fn - The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Must return a number.
|
|||
|
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 }
|
|||
|
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hours" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
mapUnits(fn) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const result = {};
|
|||
|
for (const k of Object.keys(this.values)) {
|
|||
|
result[k] = asNumber(fn(this.values[k], k));
|
|||
|
}
|
|||
|
return clone$1(this, { values: result }, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the value of unit.
|
|||
|
* @param {string} unit - a unit such as 'minute' or 'day'
|
|||
|
* @example Duration.fromObject({years: 2, days: 3}).get('years') //=> 2
|
|||
|
* @example Duration.fromObject({years: 2, days: 3}).get('months') //=> 0
|
|||
|
* @example Duration.fromObject({years: 2, days: 3}).get('days') //=> 3
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
get(unit) {
|
|||
|
return this[Duration.normalizeUnit(unit)];
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" the values of specified units. Return a newly-constructed Duration.
|
|||
|
* @param {Object} values - a mapping of units to numbers
|
|||
|
* @example dur.set({ years: 2017 })
|
|||
|
* @example dur.set({ hours: 8, minutes: 30 })
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
set(values) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const mixed = { ...this.values, ...normalizeObject(values, Duration.normalizeUnit) };
|
|||
|
return clone$1(this, { values: mixed });
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration.
|
|||
|
* @example dur.reconfigure({ locale: 'en-GB' })
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
reconfigure({ locale, numberingSystem, conversionAccuracy, matrix } = {}) {
|
|||
|
const loc = this.loc.clone({ locale, numberingSystem });
|
|||
|
const opts = { loc, matrix, conversionAccuracy };
|
|||
|
return clone$1(this, opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return the length of the duration in the specified unit.
|
|||
|
* @param {string} unit - a unit such as 'minutes' or 'days'
|
|||
|
* @example Duration.fromObject({years: 1}).as('days') //=> 365
|
|||
|
* @example Duration.fromObject({years: 1}).as('months') //=> 12
|
|||
|
* @example Duration.fromObject({hours: 60}).as('days') //=> 2.5
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
as(unit) {
|
|||
|
return this.isValid ? this.shiftTo(unit).get(unit) : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Reduce this Duration to its canonical representation in its current units.
|
|||
|
* @example Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 }
|
|||
|
* @example Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
normalize() {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const vals = this.toObject();
|
|||
|
normalizeValues(this.matrix, vals);
|
|||
|
return clone$1(this, { values: vals }, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Rescale units to its largest representation
|
|||
|
* @example Duration.fromObject({ milliseconds: 90000 }).rescale().toObject() //=> { minutes: 1, seconds: 30 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
rescale() {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const vals = removeZeroes(this.normalize().shiftToAll().toObject());
|
|||
|
return clone$1(this, { values: vals }, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Convert this Duration into its representation in a different set of units.
|
|||
|
* @example Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
shiftTo(...units) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
if (units.length === 0) {
|
|||
|
return this;
|
|||
|
}
|
|||
|
units = units.map((u) => Duration.normalizeUnit(u));
|
|||
|
const built = {}, accumulated = {}, vals = this.toObject();
|
|||
|
let lastUnit;
|
|||
|
for (const k of orderedUnits$1) {
|
|||
|
if (units.indexOf(k) >= 0) {
|
|||
|
lastUnit = k;
|
|||
|
let own = 0;
|
|||
|
for (const ak in accumulated) {
|
|||
|
own += this.matrix[ak][k] * accumulated[ak];
|
|||
|
accumulated[ak] = 0;
|
|||
|
}
|
|||
|
if (isNumber(vals[k])) {
|
|||
|
own += vals[k];
|
|||
|
}
|
|||
|
const i = Math.trunc(own);
|
|||
|
built[k] = i;
|
|||
|
accumulated[k] = (own * 1e3 - i * 1e3) / 1e3;
|
|||
|
for (const down in vals) {
|
|||
|
if (orderedUnits$1.indexOf(down) > orderedUnits$1.indexOf(k)) {
|
|||
|
convert(this.matrix, vals, down, built, k);
|
|||
|
}
|
|||
|
}
|
|||
|
} else if (isNumber(vals[k])) {
|
|||
|
accumulated[k] = vals[k];
|
|||
|
}
|
|||
|
}
|
|||
|
for (const key in accumulated) {
|
|||
|
if (accumulated[key] !== 0) {
|
|||
|
built[lastUnit] += key === lastUnit ? accumulated[key] : accumulated[key] / this.matrix[lastUnit][key];
|
|||
|
}
|
|||
|
}
|
|||
|
return clone$1(this, { values: built }, true).normalize();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Shift this Duration to all available units.
|
|||
|
* Same as shiftTo("years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds")
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
shiftToAll() {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
return this.shiftTo(
|
|||
|
"years",
|
|||
|
"months",
|
|||
|
"weeks",
|
|||
|
"days",
|
|||
|
"hours",
|
|||
|
"minutes",
|
|||
|
"seconds",
|
|||
|
"milliseconds"
|
|||
|
);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return the negative of this Duration.
|
|||
|
* @example Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
negate() {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const negated = {};
|
|||
|
for (const k of Object.keys(this.values)) {
|
|||
|
negated[k] = this.values[k] === 0 ? 0 : -this.values[k];
|
|||
|
}
|
|||
|
return clone$1(this, { values: negated }, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the years.
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get years() {
|
|||
|
return this.isValid ? this.values.years || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the quarters.
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get quarters() {
|
|||
|
return this.isValid ? this.values.quarters || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the months.
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get months() {
|
|||
|
return this.isValid ? this.values.months || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the weeks
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get weeks() {
|
|||
|
return this.isValid ? this.values.weeks || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the days.
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get days() {
|
|||
|
return this.isValid ? this.values.days || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the hours.
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get hours() {
|
|||
|
return this.isValid ? this.values.hours || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the minutes.
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get minutes() {
|
|||
|
return this.isValid ? this.values.minutes || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the seconds.
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
get seconds() {
|
|||
|
return this.isValid ? this.values.seconds || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the milliseconds.
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
get milliseconds() {
|
|||
|
return this.isValid ? this.values.milliseconds || 0 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns whether the Duration is invalid. Invalid durations are returned by diff operations
|
|||
|
* on invalid DateTimes or Intervals.
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
get isValid() {
|
|||
|
return this.invalid === null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an error code if this Duration became invalid, or null if the Duration is valid
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
get invalidReason() {
|
|||
|
return this.invalid ? this.invalid.reason : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an explanation of why this Duration became invalid, or null if the Duration is valid
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get invalidExplanation() {
|
|||
|
return this.invalid ? this.invalid.explanation : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Equality check
|
|||
|
* Two Durations are equal iff they have the same units and the same values for each unit.
|
|||
|
* @param {Duration} other
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
equals(other) {
|
|||
|
if (!this.isValid || !other.isValid) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (!this.loc.equals(other.loc)) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
function eq(v1, v2) {
|
|||
|
if (v1 === void 0 || v1 === 0)
|
|||
|
return v2 === void 0 || v2 === 0;
|
|||
|
return v1 === v2;
|
|||
|
}
|
|||
|
for (const u of orderedUnits$1) {
|
|||
|
if (!eq(this.values[u], other.values[u])) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
};
|
|||
|
var INVALID$1 = "Invalid Interval";
|
|||
|
function validateStartEnd(start, end) {
|
|||
|
if (!start || !start.isValid) {
|
|||
|
return Interval.invalid("missing or invalid start");
|
|||
|
} else if (!end || !end.isValid) {
|
|||
|
return Interval.invalid("missing or invalid end");
|
|||
|
} else if (end < start) {
|
|||
|
return Interval.invalid(
|
|||
|
"end before start",
|
|||
|
`The end of an interval must be after its start, but you had start=${start.toISO()} and end=${end.toISO()}`
|
|||
|
);
|
|||
|
} else {
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
var Interval = class {
|
|||
|
/**
|
|||
|
* @private
|
|||
|
*/
|
|||
|
constructor(config) {
|
|||
|
this.s = config.start;
|
|||
|
this.e = config.end;
|
|||
|
this.invalid = config.invalid || null;
|
|||
|
this.isLuxonInterval = true;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create an invalid Interval.
|
|||
|
* @param {string} reason - simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent
|
|||
|
* @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
static invalid(reason, explanation = null) {
|
|||
|
if (!reason) {
|
|||
|
throw new InvalidArgumentError("need to specify a reason the Interval is invalid");
|
|||
|
}
|
|||
|
const invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|||
|
if (Settings2.throwOnInvalid) {
|
|||
|
throw new InvalidIntervalError(invalid);
|
|||
|
} else {
|
|||
|
return new Interval({ invalid });
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end.
|
|||
|
* @param {DateTime|Date|Object} start
|
|||
|
* @param {DateTime|Date|Object} end
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
static fromDateTimes(start, end) {
|
|||
|
const builtStart = friendlyDateTime(start), builtEnd = friendlyDateTime(end);
|
|||
|
const validateError = validateStartEnd(builtStart, builtEnd);
|
|||
|
if (validateError == null) {
|
|||
|
return new Interval({
|
|||
|
start: builtStart,
|
|||
|
end: builtEnd
|
|||
|
});
|
|||
|
} else {
|
|||
|
return validateError;
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create an Interval from a start DateTime and a Duration to extend to.
|
|||
|
* @param {DateTime|Date|Object} start
|
|||
|
* @param {Duration|Object|number} duration - the length of the Interval.
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
static after(start, duration) {
|
|||
|
const dur = Duration.fromDurationLike(duration), dt = friendlyDateTime(start);
|
|||
|
return Interval.fromDateTimes(dt, dt.plus(dur));
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create an Interval from an end DateTime and a Duration to extend backwards to.
|
|||
|
* @param {DateTime|Date|Object} end
|
|||
|
* @param {Duration|Object|number} duration - the length of the Interval.
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
static before(end, duration) {
|
|||
|
const dur = Duration.fromDurationLike(duration), dt = friendlyDateTime(end);
|
|||
|
return Interval.fromDateTimes(dt.minus(dur), dt);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create an Interval from an ISO 8601 string.
|
|||
|
* Accepts `<start>/<end>`, `<start>/<duration>`, and `<duration>/<end>` formats.
|
|||
|
* @param {string} text - the ISO string to parse
|
|||
|
* @param {Object} [opts] - options to pass {@link DateTime#fromISO} and optionally {@link Duration#fromISO}
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
static fromISO(text2, opts) {
|
|||
|
const [s2, e] = (text2 || "").split("/", 2);
|
|||
|
if (s2 && e) {
|
|||
|
let start, startIsValid;
|
|||
|
try {
|
|||
|
start = DateTime.fromISO(s2, opts);
|
|||
|
startIsValid = start.isValid;
|
|||
|
} catch (e2) {
|
|||
|
startIsValid = false;
|
|||
|
}
|
|||
|
let end, endIsValid;
|
|||
|
try {
|
|||
|
end = DateTime.fromISO(e, opts);
|
|||
|
endIsValid = end.isValid;
|
|||
|
} catch (e2) {
|
|||
|
endIsValid = false;
|
|||
|
}
|
|||
|
if (startIsValid && endIsValid) {
|
|||
|
return Interval.fromDateTimes(start, end);
|
|||
|
}
|
|||
|
if (startIsValid) {
|
|||
|
const dur = Duration.fromISO(e, opts);
|
|||
|
if (dur.isValid) {
|
|||
|
return Interval.after(start, dur);
|
|||
|
}
|
|||
|
} else if (endIsValid) {
|
|||
|
const dur = Duration.fromISO(s2, opts);
|
|||
|
if (dur.isValid) {
|
|||
|
return Interval.before(end, dur);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return Interval.invalid("unparsable", `the input "${text2}" can't be parsed as ISO 8601`);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Check if an object is an Interval. Works across context boundaries
|
|||
|
* @param {object} o
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
static isInterval(o) {
|
|||
|
return o && o.isLuxonInterval || false;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the start of the Interval
|
|||
|
* @type {DateTime}
|
|||
|
*/
|
|||
|
get start() {
|
|||
|
return this.isValid ? this.s : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the end of the Interval
|
|||
|
* @type {DateTime}
|
|||
|
*/
|
|||
|
get end() {
|
|||
|
return this.isValid ? this.e : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'.
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
get isValid() {
|
|||
|
return this.invalidReason === null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an error code if this Interval is invalid, or null if the Interval is valid
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get invalidReason() {
|
|||
|
return this.invalid ? this.invalid.reason : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an explanation of why this Interval became invalid, or null if the Interval is valid
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get invalidExplanation() {
|
|||
|
return this.invalid ? this.invalid.explanation : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the length of the Interval in the specified unit.
|
|||
|
* @param {string} unit - the unit (such as 'hours' or 'days') to return the length in.
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
length(unit = "milliseconds") {
|
|||
|
return this.isValid ? this.toDuration(...[unit]).get(unit) : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the count of minutes, hours, days, months, or years included in the Interval, even in part.
|
|||
|
* Unlike {@link Interval#length} this counts sections of the calendar, not periods of time, e.g. specifying 'day'
|
|||
|
* asks 'what dates are included in this interval?', not 'how many days long is this interval?'
|
|||
|
* @param {string} [unit='milliseconds'] - the unit of time to count.
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
count(unit = "milliseconds") {
|
|||
|
if (!this.isValid)
|
|||
|
return NaN;
|
|||
|
const start = this.start.startOf(unit), end = this.end.startOf(unit);
|
|||
|
return Math.floor(end.diff(start, unit).get(unit)) + 1;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns whether this Interval's start and end are both in the same unit of time
|
|||
|
* @param {string} unit - the unit of time to check sameness on
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
hasSame(unit) {
|
|||
|
return this.isValid ? this.isEmpty() || this.e.minus(1).hasSame(this.s, unit) : false;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval has the same start and end DateTimes.
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
isEmpty() {
|
|||
|
return this.s.valueOf() === this.e.valueOf();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval's start is after the specified DateTime.
|
|||
|
* @param {DateTime} dateTime
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
isAfter(dateTime) {
|
|||
|
if (!this.isValid)
|
|||
|
return false;
|
|||
|
return this.s > dateTime;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval's end is before the specified DateTime.
|
|||
|
* @param {DateTime} dateTime
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
isBefore(dateTime) {
|
|||
|
if (!this.isValid)
|
|||
|
return false;
|
|||
|
return this.e <= dateTime;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval contains the specified DateTime.
|
|||
|
* @param {DateTime} dateTime
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
contains(dateTime) {
|
|||
|
if (!this.isValid)
|
|||
|
return false;
|
|||
|
return this.s <= dateTime && this.e > dateTime;
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Sets" the start and/or end dates. Returns a newly-constructed Interval.
|
|||
|
* @param {Object} values - the values to set
|
|||
|
* @param {DateTime} values.start - the starting DateTime
|
|||
|
* @param {DateTime} values.end - the ending DateTime
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
set({ start, end } = {}) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
return Interval.fromDateTimes(start || this.s, end || this.e);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Split this Interval at each of the specified DateTimes
|
|||
|
* @param {...DateTime} dateTimes - the unit of time to count.
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
splitAt(...dateTimes) {
|
|||
|
if (!this.isValid)
|
|||
|
return [];
|
|||
|
const sorted = dateTimes.map(friendlyDateTime).filter((d) => this.contains(d)).sort(), results = [];
|
|||
|
let { s: s2 } = this, i = 0;
|
|||
|
while (s2 < this.e) {
|
|||
|
const added = sorted[i] || this.e, next = +added > +this.e ? this.e : added;
|
|||
|
results.push(Interval.fromDateTimes(s2, next));
|
|||
|
s2 = next;
|
|||
|
i += 1;
|
|||
|
}
|
|||
|
return results;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Split this Interval into smaller Intervals, each of the specified length.
|
|||
|
* Left over time is grouped into a smaller interval
|
|||
|
* @param {Duration|Object|number} duration - The length of each resulting interval.
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
splitBy(duration) {
|
|||
|
const dur = Duration.fromDurationLike(duration);
|
|||
|
if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) {
|
|||
|
return [];
|
|||
|
}
|
|||
|
let { s: s2 } = this, idx = 1, next;
|
|||
|
const results = [];
|
|||
|
while (s2 < this.e) {
|
|||
|
const added = this.start.plus(dur.mapUnits((x) => x * idx));
|
|||
|
next = +added > +this.e ? this.e : added;
|
|||
|
results.push(Interval.fromDateTimes(s2, next));
|
|||
|
s2 = next;
|
|||
|
idx += 1;
|
|||
|
}
|
|||
|
return results;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Split this Interval into the specified number of smaller intervals.
|
|||
|
* @param {number} numberOfParts - The number of Intervals to divide the Interval into.
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
divideEqually(numberOfParts) {
|
|||
|
if (!this.isValid)
|
|||
|
return [];
|
|||
|
return this.splitBy(this.length() / numberOfParts).slice(0, numberOfParts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval overlaps with the specified Interval
|
|||
|
* @param {Interval} other
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
overlaps(other) {
|
|||
|
return this.e > other.s && this.s < other.e;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval's end is adjacent to the specified Interval's start.
|
|||
|
* @param {Interval} other
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
abutsStart(other) {
|
|||
|
if (!this.isValid)
|
|||
|
return false;
|
|||
|
return +this.e === +other.s;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval's start is adjacent to the specified Interval's end.
|
|||
|
* @param {Interval} other
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
abutsEnd(other) {
|
|||
|
if (!this.isValid)
|
|||
|
return false;
|
|||
|
return +other.e === +this.s;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval engulfs the start and end of the specified Interval.
|
|||
|
* @param {Interval} other
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
engulfs(other) {
|
|||
|
if (!this.isValid)
|
|||
|
return false;
|
|||
|
return this.s <= other.s && this.e >= other.e;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this Interval has the same start and end as the specified Interval.
|
|||
|
* @param {Interval} other
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
equals(other) {
|
|||
|
if (!this.isValid || !other.isValid) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
return this.s.equals(other.s) && this.e.equals(other.e);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an Interval representing the intersection of this Interval and the specified Interval.
|
|||
|
* Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals.
|
|||
|
* Returns null if the intersection is empty, meaning, the intervals don't intersect.
|
|||
|
* @param {Interval} other
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
intersection(other) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const s2 = this.s > other.s ? this.s : other.s, e = this.e < other.e ? this.e : other.e;
|
|||
|
if (s2 >= e) {
|
|||
|
return null;
|
|||
|
} else {
|
|||
|
return Interval.fromDateTimes(s2, e);
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an Interval representing the union of this Interval and the specified Interval.
|
|||
|
* Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals.
|
|||
|
* @param {Interval} other
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
union(other) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const s2 = this.s < other.s ? this.s : other.s, e = this.e > other.e ? this.e : other.e;
|
|||
|
return Interval.fromDateTimes(s2, e);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Merge an array of Intervals into a equivalent minimal set of Intervals.
|
|||
|
* Combines overlapping and adjacent Intervals.
|
|||
|
* @param {Array} intervals
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
static merge(intervals) {
|
|||
|
const [found, final] = intervals.sort((a, b) => a.s - b.s).reduce(
|
|||
|
([sofar, current], item) => {
|
|||
|
if (!current) {
|
|||
|
return [sofar, item];
|
|||
|
} else if (current.overlaps(item) || current.abutsStart(item)) {
|
|||
|
return [sofar, current.union(item)];
|
|||
|
} else {
|
|||
|
return [sofar.concat([current]), item];
|
|||
|
}
|
|||
|
},
|
|||
|
[[], null]
|
|||
|
);
|
|||
|
if (final) {
|
|||
|
found.push(final);
|
|||
|
}
|
|||
|
return found;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals.
|
|||
|
* @param {Array} intervals
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
static xor(intervals) {
|
|||
|
let start = null, currentCount = 0;
|
|||
|
const results = [], ends = intervals.map((i) => [
|
|||
|
{ time: i.s, type: "s" },
|
|||
|
{ time: i.e, type: "e" }
|
|||
|
]), flattened = Array.prototype.concat(...ends), arr = flattened.sort((a, b) => a.time - b.time);
|
|||
|
for (const i of arr) {
|
|||
|
currentCount += i.type === "s" ? 1 : -1;
|
|||
|
if (currentCount === 1) {
|
|||
|
start = i.time;
|
|||
|
} else {
|
|||
|
if (start && +start !== +i.time) {
|
|||
|
results.push(Interval.fromDateTimes(start, i.time));
|
|||
|
}
|
|||
|
start = null;
|
|||
|
}
|
|||
|
}
|
|||
|
return Interval.merge(results);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an Interval representing the span of time in this Interval that doesn't overlap with any of the specified Intervals.
|
|||
|
* @param {...Interval} intervals
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
difference(...intervals) {
|
|||
|
return Interval.xor([this].concat(intervals)).map((i) => this.intersection(i)).filter((i) => i && !i.isEmpty());
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this Interval appropriate for debugging.
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toString() {
|
|||
|
if (!this.isValid)
|
|||
|
return INVALID$1;
|
|||
|
return `[${this.s.toISO()} \u2013 ${this.e.toISO()})`;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a localized string representing this Interval. Accepts the same options as the
|
|||
|
* Intl.DateTimeFormat constructor and any presets defined by Luxon, such as
|
|||
|
* {@link DateTime.DATE_FULL} or {@link DateTime.TIME_SIMPLE}. The exact behavior of this method
|
|||
|
* is browser-specific, but in general it will return an appropriate representation of the
|
|||
|
* Interval in the assigned locale. Defaults to the system's locale if no locale has been
|
|||
|
* specified.
|
|||
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
|||
|
* @param {Object} [formatOpts=DateTime.DATE_SHORT] - Either a DateTime preset or
|
|||
|
* Intl.DateTimeFormat constructor options.
|
|||
|
* @param {Object} opts - Options to override the configuration of the start DateTime.
|
|||
|
* @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(); //=> 11/7/2022 – 11/8/2022
|
|||
|
* @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL); //=> November 7 – 8, 2022
|
|||
|
* @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL, { locale: 'fr-FR' }); //=> 7–8 novembre 2022
|
|||
|
* @example Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString(DateTime.TIME_SIMPLE); //=> 6:00 – 8:00 PM
|
|||
|
* @example Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> Mon, Nov 07, 6:00 – 8:00 p
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toLocaleString(formatOpts = DATE_SHORT, opts = {}) {
|
|||
|
return this.isValid ? Formatter.create(this.s.loc.clone(opts), formatOpts).formatInterval(this) : INVALID$1;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of this Interval.
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
|||
|
* @param {Object} opts - The same options as {@link DateTime#toISO}
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISO(opts) {
|
|||
|
if (!this.isValid)
|
|||
|
return INVALID$1;
|
|||
|
return `${this.s.toISO(opts)}/${this.e.toISO(opts)}`;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of date of this Interval.
|
|||
|
* The time components are ignored.
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISODate() {
|
|||
|
if (!this.isValid)
|
|||
|
return INVALID$1;
|
|||
|
return `${this.s.toISODate()}/${this.e.toISODate()}`;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of time of this Interval.
|
|||
|
* The date components are ignored.
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
|||
|
* @param {Object} opts - The same options as {@link DateTime#toISO}
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISOTime(opts) {
|
|||
|
if (!this.isValid)
|
|||
|
return INVALID$1;
|
|||
|
return `${this.s.toISOTime(opts)}/${this.e.toISOTime(opts)}`;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this Interval formatted according to the specified format
|
|||
|
* string. **You may not want this.** See {@link Interval#toLocaleString} for a more flexible
|
|||
|
* formatting tool.
|
|||
|
* @param {string} dateFormat - The format string. This string formats the start and end time.
|
|||
|
* See {@link DateTime#toFormat} for details.
|
|||
|
* @param {Object} opts - Options.
|
|||
|
* @param {string} [opts.separator = ' – '] - A separator to place between the start and end
|
|||
|
* representations.
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toFormat(dateFormat, { separator = " \u2013 " } = {}) {
|
|||
|
if (!this.isValid)
|
|||
|
return INVALID$1;
|
|||
|
return `${this.s.toFormat(dateFormat)}${separator}${this.e.toFormat(dateFormat)}`;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return a Duration representing the time spanned by this interval.
|
|||
|
* @param {string|string[]} [unit=['milliseconds']] - the unit or units (such as 'hours' or 'days') to include in the duration.
|
|||
|
* @param {Object} opts - options that affect the creation of the Duration
|
|||
|
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|||
|
* @example Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 }
|
|||
|
* @example Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 }
|
|||
|
* @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 }
|
|||
|
* @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 }
|
|||
|
* @example Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
toDuration(unit, opts) {
|
|||
|
if (!this.isValid) {
|
|||
|
return Duration.invalid(this.invalidReason);
|
|||
|
}
|
|||
|
return this.e.diff(this.s, unit, opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes
|
|||
|
* @param {function} mapFn
|
|||
|
* @return {Interval}
|
|||
|
* @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC())
|
|||
|
* @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 }))
|
|||
|
*/
|
|||
|
mapEndpoints(mapFn) {
|
|||
|
return Interval.fromDateTimes(mapFn(this.s), mapFn(this.e));
|
|||
|
}
|
|||
|
};
|
|||
|
var Info = class {
|
|||
|
/**
|
|||
|
* Return whether the specified zone contains a DST.
|
|||
|
* @param {string|Zone} [zone='local'] - Zone to check. Defaults to the environment's local zone.
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
static hasDST(zone = Settings2.defaultZone) {
|
|||
|
const proto = DateTime.now().setZone(zone).set({ month: 12 });
|
|||
|
return !zone.isUniversal && proto.offset !== proto.set({ month: 6 }).offset;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether the specified zone is a valid IANA specifier.
|
|||
|
* @param {string} zone - Zone to check
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
static isValidIANAZone(zone) {
|
|||
|
return IANAZone.isValidZone(zone);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Converts the input into a {@link Zone} instance.
|
|||
|
*
|
|||
|
* * If `input` is already a Zone instance, it is returned unchanged.
|
|||
|
* * If `input` is a string containing a valid time zone name, a Zone instance
|
|||
|
* with that name is returned.
|
|||
|
* * If `input` is a string that doesn't refer to a known time zone, a Zone
|
|||
|
* instance with {@link Zone#isValid} == false is returned.
|
|||
|
* * If `input is a number, a Zone instance with the specified fixed offset
|
|||
|
* in minutes is returned.
|
|||
|
* * If `input` is `null` or `undefined`, the default zone is returned.
|
|||
|
* @param {string|Zone|number} [input] - the value to be converted
|
|||
|
* @return {Zone}
|
|||
|
*/
|
|||
|
static normalizeZone(input) {
|
|||
|
return normalizeZone(input, Settings2.defaultZone);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an array of standalone month names.
|
|||
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
|||
|
* @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {string} [opts.locale] - the locale code
|
|||
|
* @param {string} [opts.numberingSystem=null] - the numbering system
|
|||
|
* @param {string} [opts.locObj=null] - an existing locale object to use
|
|||
|
* @param {string} [opts.outputCalendar='gregory'] - the calendar
|
|||
|
* @example Info.months()[0] //=> 'January'
|
|||
|
* @example Info.months('short')[0] //=> 'Jan'
|
|||
|
* @example Info.months('numeric')[0] //=> '1'
|
|||
|
* @example Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.'
|
|||
|
* @example Info.months('numeric', { locale: 'ar' })[0] //=> '١'
|
|||
|
* @example Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I'
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
static months(length = "long", { locale = null, numberingSystem = null, locObj = null, outputCalendar = "gregory" } = {}) {
|
|||
|
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an array of format month names.
|
|||
|
* Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that
|
|||
|
* changes the string.
|
|||
|
* See {@link Info#months}
|
|||
|
* @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {string} [opts.locale] - the locale code
|
|||
|
* @param {string} [opts.numberingSystem=null] - the numbering system
|
|||
|
* @param {string} [opts.locObj=null] - an existing locale object to use
|
|||
|
* @param {string} [opts.outputCalendar='gregory'] - the calendar
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
static monthsFormat(length = "long", { locale = null, numberingSystem = null, locObj = null, outputCalendar = "gregory" } = {}) {
|
|||
|
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an array of standalone week names.
|
|||
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
|||
|
* @param {string} [length='long'] - the length of the weekday representation, such as "narrow", "short", "long".
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {string} [opts.locale] - the locale code
|
|||
|
* @param {string} [opts.numberingSystem=null] - the numbering system
|
|||
|
* @param {string} [opts.locObj=null] - an existing locale object to use
|
|||
|
* @example Info.weekdays()[0] //=> 'Monday'
|
|||
|
* @example Info.weekdays('short')[0] //=> 'Mon'
|
|||
|
* @example Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.'
|
|||
|
* @example Info.weekdays('short', { locale: 'ar' })[0] //=> 'الاثنين'
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
static weekdays(length = "long", { locale = null, numberingSystem = null, locObj = null } = {}) {
|
|||
|
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an array of format week names.
|
|||
|
* Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that
|
|||
|
* changes the string.
|
|||
|
* See {@link Info#weekdays}
|
|||
|
* @param {string} [length='long'] - the length of the month representation, such as "narrow", "short", "long".
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {string} [opts.locale=null] - the locale code
|
|||
|
* @param {string} [opts.numberingSystem=null] - the numbering system
|
|||
|
* @param {string} [opts.locObj=null] - an existing locale object to use
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
static weekdaysFormat(length = "long", { locale = null, numberingSystem = null, locObj = null } = {}) {
|
|||
|
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an array of meridiems.
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {string} [opts.locale] - the locale code
|
|||
|
* @example Info.meridiems() //=> [ 'AM', 'PM' ]
|
|||
|
* @example Info.meridiems({ locale: 'my' }) //=> [ 'နံနက်', 'ညနေ' ]
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
static meridiems({ locale = null } = {}) {
|
|||
|
return Locale.create(locale).meridiems();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian.
|
|||
|
* @param {string} [length='short'] - the length of the era representation, such as "short" or "long".
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {string} [opts.locale] - the locale code
|
|||
|
* @example Info.eras() //=> [ 'BC', 'AD' ]
|
|||
|
* @example Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ]
|
|||
|
* @example Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ]
|
|||
|
* @return {Array}
|
|||
|
*/
|
|||
|
static eras(length = "short", { locale = null } = {}) {
|
|||
|
return Locale.create(locale, null, "gregory").eras(length);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return the set of available features in this environment.
|
|||
|
* Some features of Luxon are not available in all environments. For example, on older browsers, relative time formatting support is not available. Use this function to figure out if that's the case.
|
|||
|
* Keys:
|
|||
|
* * `relative`: whether this environment supports relative time formatting
|
|||
|
* @example Info.features() //=> { relative: false }
|
|||
|
* @return {Object}
|
|||
|
*/
|
|||
|
static features() {
|
|||
|
return { relative: hasRelative() };
|
|||
|
}
|
|||
|
};
|
|||
|
function dayDiff(earlier, later) {
|
|||
|
const utcDayStart = (dt) => dt.toUTC(0, { keepLocalTime: true }).startOf("day").valueOf(), ms = utcDayStart(later) - utcDayStart(earlier);
|
|||
|
return Math.floor(Duration.fromMillis(ms).as("days"));
|
|||
|
}
|
|||
|
function highOrderDiffs(cursor, later, units) {
|
|||
|
const differs = [
|
|||
|
["years", (a, b) => b.year - a.year],
|
|||
|
["quarters", (a, b) => b.quarter - a.quarter + (b.year - a.year) * 4],
|
|||
|
["months", (a, b) => b.month - a.month + (b.year - a.year) * 12],
|
|||
|
[
|
|||
|
"weeks",
|
|||
|
(a, b) => {
|
|||
|
const days = dayDiff(a, b);
|
|||
|
return (days - days % 7) / 7;
|
|||
|
}
|
|||
|
],
|
|||
|
["days", dayDiff]
|
|||
|
];
|
|||
|
const results = {};
|
|||
|
const earlier = cursor;
|
|||
|
let lowestOrder, highWater;
|
|||
|
for (const [unit, differ] of differs) {
|
|||
|
if (units.indexOf(unit) >= 0) {
|
|||
|
lowestOrder = unit;
|
|||
|
results[unit] = differ(cursor, later);
|
|||
|
highWater = earlier.plus(results);
|
|||
|
if (highWater > later) {
|
|||
|
results[unit]--;
|
|||
|
cursor = earlier.plus(results);
|
|||
|
} else {
|
|||
|
cursor = highWater;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return [cursor, results, highWater, lowestOrder];
|
|||
|
}
|
|||
|
function diff(earlier, later, units, opts) {
|
|||
|
let [cursor, results, highWater, lowestOrder] = highOrderDiffs(earlier, later, units);
|
|||
|
const remainingMillis = later - cursor;
|
|||
|
const lowerOrderUnits = units.filter(
|
|||
|
(u) => ["hours", "minutes", "seconds", "milliseconds"].indexOf(u) >= 0
|
|||
|
);
|
|||
|
if (lowerOrderUnits.length === 0) {
|
|||
|
if (highWater < later) {
|
|||
|
highWater = cursor.plus({ [lowestOrder]: 1 });
|
|||
|
}
|
|||
|
if (highWater !== cursor) {
|
|||
|
results[lowestOrder] = (results[lowestOrder] || 0) + remainingMillis / (highWater - cursor);
|
|||
|
}
|
|||
|
}
|
|||
|
const duration = Duration.fromObject(results, opts);
|
|||
|
if (lowerOrderUnits.length > 0) {
|
|||
|
return Duration.fromMillis(remainingMillis, opts).shiftTo(...lowerOrderUnits).plus(duration);
|
|||
|
} else {
|
|||
|
return duration;
|
|||
|
}
|
|||
|
}
|
|||
|
var numberingSystems = {
|
|||
|
arab: "[\u0660-\u0669]",
|
|||
|
arabext: "[\u06F0-\u06F9]",
|
|||
|
bali: "[\u1B50-\u1B59]",
|
|||
|
beng: "[\u09E6-\u09EF]",
|
|||
|
deva: "[\u0966-\u096F]",
|
|||
|
fullwide: "[\uFF10-\uFF19]",
|
|||
|
gujr: "[\u0AE6-\u0AEF]",
|
|||
|
hanidec: "[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",
|
|||
|
khmr: "[\u17E0-\u17E9]",
|
|||
|
knda: "[\u0CE6-\u0CEF]",
|
|||
|
laoo: "[\u0ED0-\u0ED9]",
|
|||
|
limb: "[\u1946-\u194F]",
|
|||
|
mlym: "[\u0D66-\u0D6F]",
|
|||
|
mong: "[\u1810-\u1819]",
|
|||
|
mymr: "[\u1040-\u1049]",
|
|||
|
orya: "[\u0B66-\u0B6F]",
|
|||
|
tamldec: "[\u0BE6-\u0BEF]",
|
|||
|
telu: "[\u0C66-\u0C6F]",
|
|||
|
thai: "[\u0E50-\u0E59]",
|
|||
|
tibt: "[\u0F20-\u0F29]",
|
|||
|
latn: "\\d"
|
|||
|
};
|
|||
|
var numberingSystemsUTF16 = {
|
|||
|
arab: [1632, 1641],
|
|||
|
arabext: [1776, 1785],
|
|||
|
bali: [6992, 7001],
|
|||
|
beng: [2534, 2543],
|
|||
|
deva: [2406, 2415],
|
|||
|
fullwide: [65296, 65303],
|
|||
|
gujr: [2790, 2799],
|
|||
|
khmr: [6112, 6121],
|
|||
|
knda: [3302, 3311],
|
|||
|
laoo: [3792, 3801],
|
|||
|
limb: [6470, 6479],
|
|||
|
mlym: [3430, 3439],
|
|||
|
mong: [6160, 6169],
|
|||
|
mymr: [4160, 4169],
|
|||
|
orya: [2918, 2927],
|
|||
|
tamldec: [3046, 3055],
|
|||
|
telu: [3174, 3183],
|
|||
|
thai: [3664, 3673],
|
|||
|
tibt: [3872, 3881]
|
|||
|
};
|
|||
|
var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
|
|||
|
function parseDigits(str) {
|
|||
|
let value = parseInt(str, 10);
|
|||
|
if (isNaN(value)) {
|
|||
|
value = "";
|
|||
|
for (let i = 0; i < str.length; i++) {
|
|||
|
const code = str.charCodeAt(i);
|
|||
|
if (str[i].search(numberingSystems.hanidec) !== -1) {
|
|||
|
value += hanidecChars.indexOf(str[i]);
|
|||
|
} else {
|
|||
|
for (const key in numberingSystemsUTF16) {
|
|||
|
const [min, max] = numberingSystemsUTF16[key];
|
|||
|
if (code >= min && code <= max) {
|
|||
|
value += code - min;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return parseInt(value, 10);
|
|||
|
} else {
|
|||
|
return value;
|
|||
|
}
|
|||
|
}
|
|||
|
function digitRegex({ numberingSystem }, append2 = "") {
|
|||
|
return new RegExp(`${numberingSystems[numberingSystem || "latn"]}${append2}`);
|
|||
|
}
|
|||
|
var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
|
|||
|
function intUnit(regex, post = (i) => i) {
|
|||
|
return { regex, deser: ([s2]) => post(parseDigits(s2)) };
|
|||
|
}
|
|||
|
var NBSP = String.fromCharCode(160);
|
|||
|
var spaceOrNBSP = `[ ${NBSP}]`;
|
|||
|
var spaceOrNBSPRegExp = new RegExp(spaceOrNBSP, "g");
|
|||
|
function fixListRegex(s2) {
|
|||
|
return s2.replace(/\./g, "\\.?").replace(spaceOrNBSPRegExp, spaceOrNBSP);
|
|||
|
}
|
|||
|
function stripInsensitivities(s2) {
|
|||
|
return s2.replace(/\./g, "").replace(spaceOrNBSPRegExp, " ").toLowerCase();
|
|||
|
}
|
|||
|
function oneOf(strings, startIndex) {
|
|||
|
if (strings === null) {
|
|||
|
return null;
|
|||
|
} else {
|
|||
|
return {
|
|||
|
regex: RegExp(strings.map(fixListRegex).join("|")),
|
|||
|
deser: ([s2]) => strings.findIndex((i) => stripInsensitivities(s2) === stripInsensitivities(i)) + startIndex
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
function offset(regex, groups) {
|
|||
|
return { regex, deser: ([, h, m]) => signedOffset(h, m), groups };
|
|||
|
}
|
|||
|
function simple(regex) {
|
|||
|
return { regex, deser: ([s2]) => s2 };
|
|||
|
}
|
|||
|
function escapeToken(value) {
|
|||
|
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|||
|
}
|
|||
|
function unitForToken(token, loc) {
|
|||
|
const one = digitRegex(loc), two = digitRegex(loc, "{2}"), three = digitRegex(loc, "{3}"), four = digitRegex(loc, "{4}"), six = digitRegex(loc, "{6}"), oneOrTwo = digitRegex(loc, "{1,2}"), oneToThree = digitRegex(loc, "{1,3}"), oneToSix = digitRegex(loc, "{1,6}"), oneToNine = digitRegex(loc, "{1,9}"), twoToFour = digitRegex(loc, "{2,4}"), fourToSix = digitRegex(loc, "{4,6}"), literal = (t) => ({ regex: RegExp(escapeToken(t.val)), deser: ([s2]) => s2, literal: true }), unitate = (t) => {
|
|||
|
if (token.literal) {
|
|||
|
return literal(t);
|
|||
|
}
|
|||
|
switch (t.val) {
|
|||
|
case "G":
|
|||
|
return oneOf(loc.eras("short", false), 0);
|
|||
|
case "GG":
|
|||
|
return oneOf(loc.eras("long", false), 0);
|
|||
|
case "y":
|
|||
|
return intUnit(oneToSix);
|
|||
|
case "yy":
|
|||
|
return intUnit(twoToFour, untruncateYear);
|
|||
|
case "yyyy":
|
|||
|
return intUnit(four);
|
|||
|
case "yyyyy":
|
|||
|
return intUnit(fourToSix);
|
|||
|
case "yyyyyy":
|
|||
|
return intUnit(six);
|
|||
|
case "M":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "MM":
|
|||
|
return intUnit(two);
|
|||
|
case "MMM":
|
|||
|
return oneOf(loc.months("short", true, false), 1);
|
|||
|
case "MMMM":
|
|||
|
return oneOf(loc.months("long", true, false), 1);
|
|||
|
case "L":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "LL":
|
|||
|
return intUnit(two);
|
|||
|
case "LLL":
|
|||
|
return oneOf(loc.months("short", false, false), 1);
|
|||
|
case "LLLL":
|
|||
|
return oneOf(loc.months("long", false, false), 1);
|
|||
|
case "d":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "dd":
|
|||
|
return intUnit(two);
|
|||
|
case "o":
|
|||
|
return intUnit(oneToThree);
|
|||
|
case "ooo":
|
|||
|
return intUnit(three);
|
|||
|
case "HH":
|
|||
|
return intUnit(two);
|
|||
|
case "H":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "hh":
|
|||
|
return intUnit(two);
|
|||
|
case "h":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "mm":
|
|||
|
return intUnit(two);
|
|||
|
case "m":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "q":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "qq":
|
|||
|
return intUnit(two);
|
|||
|
case "s":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "ss":
|
|||
|
return intUnit(two);
|
|||
|
case "S":
|
|||
|
return intUnit(oneToThree);
|
|||
|
case "SSS":
|
|||
|
return intUnit(three);
|
|||
|
case "u":
|
|||
|
return simple(oneToNine);
|
|||
|
case "uu":
|
|||
|
return simple(oneOrTwo);
|
|||
|
case "uuu":
|
|||
|
return intUnit(one);
|
|||
|
case "a":
|
|||
|
return oneOf(loc.meridiems(), 0);
|
|||
|
case "kkkk":
|
|||
|
return intUnit(four);
|
|||
|
case "kk":
|
|||
|
return intUnit(twoToFour, untruncateYear);
|
|||
|
case "W":
|
|||
|
return intUnit(oneOrTwo);
|
|||
|
case "WW":
|
|||
|
return intUnit(two);
|
|||
|
case "E":
|
|||
|
case "c":
|
|||
|
return intUnit(one);
|
|||
|
case "EEE":
|
|||
|
return oneOf(loc.weekdays("short", false, false), 1);
|
|||
|
case "EEEE":
|
|||
|
return oneOf(loc.weekdays("long", false, false), 1);
|
|||
|
case "ccc":
|
|||
|
return oneOf(loc.weekdays("short", true, false), 1);
|
|||
|
case "cccc":
|
|||
|
return oneOf(loc.weekdays("long", true, false), 1);
|
|||
|
case "Z":
|
|||
|
case "ZZ":
|
|||
|
return offset(new RegExp(`([+-]${oneOrTwo.source})(?::(${two.source}))?`), 2);
|
|||
|
case "ZZZ":
|
|||
|
return offset(new RegExp(`([+-]${oneOrTwo.source})(${two.source})?`), 2);
|
|||
|
case "z":
|
|||
|
return simple(/[a-z_+-/]{1,256}?/i);
|
|||
|
default:
|
|||
|
return literal(t);
|
|||
|
}
|
|||
|
};
|
|||
|
const unit = unitate(token) || {
|
|||
|
invalidReason: MISSING_FTP
|
|||
|
};
|
|||
|
unit.token = token;
|
|||
|
return unit;
|
|||
|
}
|
|||
|
var partTypeStyleToTokenVal = {
|
|||
|
year: {
|
|||
|
"2-digit": "yy",
|
|||
|
numeric: "yyyyy"
|
|||
|
},
|
|||
|
month: {
|
|||
|
numeric: "M",
|
|||
|
"2-digit": "MM",
|
|||
|
short: "MMM",
|
|||
|
long: "MMMM"
|
|||
|
},
|
|||
|
day: {
|
|||
|
numeric: "d",
|
|||
|
"2-digit": "dd"
|
|||
|
},
|
|||
|
weekday: {
|
|||
|
short: "EEE",
|
|||
|
long: "EEEE"
|
|||
|
},
|
|||
|
dayperiod: "a",
|
|||
|
dayPeriod: "a",
|
|||
|
hour: {
|
|||
|
numeric: "h",
|
|||
|
"2-digit": "hh"
|
|||
|
},
|
|||
|
minute: {
|
|||
|
numeric: "m",
|
|||
|
"2-digit": "mm"
|
|||
|
},
|
|||
|
second: {
|
|||
|
numeric: "s",
|
|||
|
"2-digit": "ss"
|
|||
|
},
|
|||
|
timeZoneName: {
|
|||
|
long: "ZZZZZ",
|
|||
|
short: "ZZZ"
|
|||
|
}
|
|||
|
};
|
|||
|
function tokenForPart(part, formatOpts) {
|
|||
|
const { type, value } = part;
|
|||
|
if (type === "literal") {
|
|||
|
return {
|
|||
|
literal: true,
|
|||
|
val: value
|
|||
|
};
|
|||
|
}
|
|||
|
const style = formatOpts[type];
|
|||
|
let val = partTypeStyleToTokenVal[type];
|
|||
|
if (typeof val === "object") {
|
|||
|
val = val[style];
|
|||
|
}
|
|||
|
if (val) {
|
|||
|
return {
|
|||
|
literal: false,
|
|||
|
val
|
|||
|
};
|
|||
|
}
|
|||
|
return void 0;
|
|||
|
}
|
|||
|
function buildRegex(units) {
|
|||
|
const re = units.map((u) => u.regex).reduce((f, r) => `${f}(${r.source})`, "");
|
|||
|
return [`^${re}$`, units];
|
|||
|
}
|
|||
|
function match(input, regex, handlers) {
|
|||
|
const matches = input.match(regex);
|
|||
|
if (matches) {
|
|||
|
const all = {};
|
|||
|
let matchIndex = 1;
|
|||
|
for (const i in handlers) {
|
|||
|
if (hasOwnProperty(handlers, i)) {
|
|||
|
const h = handlers[i], groups = h.groups ? h.groups + 1 : 1;
|
|||
|
if (!h.literal && h.token) {
|
|||
|
all[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups));
|
|||
|
}
|
|||
|
matchIndex += groups;
|
|||
|
}
|
|||
|
}
|
|||
|
return [matches, all];
|
|||
|
} else {
|
|||
|
return [matches, {}];
|
|||
|
}
|
|||
|
}
|
|||
|
function dateTimeFromMatches(matches) {
|
|||
|
const toField = (token) => {
|
|||
|
switch (token) {
|
|||
|
case "S":
|
|||
|
return "millisecond";
|
|||
|
case "s":
|
|||
|
return "second";
|
|||
|
case "m":
|
|||
|
return "minute";
|
|||
|
case "h":
|
|||
|
case "H":
|
|||
|
return "hour";
|
|||
|
case "d":
|
|||
|
return "day";
|
|||
|
case "o":
|
|||
|
return "ordinal";
|
|||
|
case "L":
|
|||
|
case "M":
|
|||
|
return "month";
|
|||
|
case "y":
|
|||
|
return "year";
|
|||
|
case "E":
|
|||
|
case "c":
|
|||
|
return "weekday";
|
|||
|
case "W":
|
|||
|
return "weekNumber";
|
|||
|
case "k":
|
|||
|
return "weekYear";
|
|||
|
case "q":
|
|||
|
return "quarter";
|
|||
|
default:
|
|||
|
return null;
|
|||
|
}
|
|||
|
};
|
|||
|
let zone = null;
|
|||
|
let specificOffset;
|
|||
|
if (!isUndefined(matches.z)) {
|
|||
|
zone = IANAZone.create(matches.z);
|
|||
|
}
|
|||
|
if (!isUndefined(matches.Z)) {
|
|||
|
if (!zone) {
|
|||
|
zone = new FixedOffsetZone(matches.Z);
|
|||
|
}
|
|||
|
specificOffset = matches.Z;
|
|||
|
}
|
|||
|
if (!isUndefined(matches.q)) {
|
|||
|
matches.M = (matches.q - 1) * 3 + 1;
|
|||
|
}
|
|||
|
if (!isUndefined(matches.h)) {
|
|||
|
if (matches.h < 12 && matches.a === 1) {
|
|||
|
matches.h += 12;
|
|||
|
} else if (matches.h === 12 && matches.a === 0) {
|
|||
|
matches.h = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
if (matches.G === 0 && matches.y) {
|
|||
|
matches.y = -matches.y;
|
|||
|
}
|
|||
|
if (!isUndefined(matches.u)) {
|
|||
|
matches.S = parseMillis(matches.u);
|
|||
|
}
|
|||
|
const vals = Object.keys(matches).reduce((r, k) => {
|
|||
|
const f = toField(k);
|
|||
|
if (f) {
|
|||
|
r[f] = matches[k];
|
|||
|
}
|
|||
|
return r;
|
|||
|
}, {});
|
|||
|
return [vals, zone, specificOffset];
|
|||
|
}
|
|||
|
var dummyDateTimeCache = null;
|
|||
|
function getDummyDateTime() {
|
|||
|
if (!dummyDateTimeCache) {
|
|||
|
dummyDateTimeCache = DateTime.fromMillis(1555555555555);
|
|||
|
}
|
|||
|
return dummyDateTimeCache;
|
|||
|
}
|
|||
|
function maybeExpandMacroToken(token, locale) {
|
|||
|
if (token.literal) {
|
|||
|
return token;
|
|||
|
}
|
|||
|
const formatOpts = Formatter.macroTokenToFormatOpts(token.val);
|
|||
|
const tokens = formatOptsToTokens(formatOpts, locale);
|
|||
|
if (tokens == null || tokens.includes(void 0)) {
|
|||
|
return token;
|
|||
|
}
|
|||
|
return tokens;
|
|||
|
}
|
|||
|
function expandMacroTokens(tokens, locale) {
|
|||
|
return Array.prototype.concat(...tokens.map((t) => maybeExpandMacroToken(t, locale)));
|
|||
|
}
|
|||
|
function explainFromTokens(locale, input, format) {
|
|||
|
const tokens = expandMacroTokens(Formatter.parseFormat(format), locale), units = tokens.map((t) => unitForToken(t, locale)), disqualifyingUnit = units.find((t) => t.invalidReason);
|
|||
|
if (disqualifyingUnit) {
|
|||
|
return { input, tokens, invalidReason: disqualifyingUnit.invalidReason };
|
|||
|
} else {
|
|||
|
const [regexString, handlers] = buildRegex(units), regex = RegExp(regexString, "i"), [rawMatches, matches] = match(input, regex, handlers), [result, zone, specificOffset] = matches ? dateTimeFromMatches(matches) : [null, null, void 0];
|
|||
|
if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
|
|||
|
throw new ConflictingSpecificationError(
|
|||
|
"Can't include meridiem when specifying 24-hour format"
|
|||
|
);
|
|||
|
}
|
|||
|
return { input, tokens, regex, rawMatches, matches, result, zone, specificOffset };
|
|||
|
}
|
|||
|
}
|
|||
|
function parseFromTokens(locale, input, format) {
|
|||
|
const { result, zone, specificOffset, invalidReason } = explainFromTokens(locale, input, format);
|
|||
|
return [result, zone, specificOffset, invalidReason];
|
|||
|
}
|
|||
|
function formatOptsToTokens(formatOpts, locale) {
|
|||
|
if (!formatOpts) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
const formatter = Formatter.create(locale, formatOpts);
|
|||
|
const parts = formatter.formatDateTimeParts(getDummyDateTime());
|
|||
|
return parts.map((p) => tokenForPart(p, formatOpts));
|
|||
|
}
|
|||
|
var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
|||
|
var leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
|
|||
|
function unitOutOfRange(unit, value) {
|
|||
|
return new Invalid(
|
|||
|
"unit out of range",
|
|||
|
`you specified ${value} (of type ${typeof value}) as a ${unit}, which is invalid`
|
|||
|
);
|
|||
|
}
|
|||
|
function dayOfWeek(year, month, day) {
|
|||
|
const d = new Date(Date.UTC(year, month - 1, day));
|
|||
|
if (year < 100 && year >= 0) {
|
|||
|
d.setUTCFullYear(d.getUTCFullYear() - 1900);
|
|||
|
}
|
|||
|
const js = d.getUTCDay();
|
|||
|
return js === 0 ? 7 : js;
|
|||
|
}
|
|||
|
function computeOrdinal(year, month, day) {
|
|||
|
return day + (isLeapYear(year) ? leapLadder : nonLeapLadder)[month - 1];
|
|||
|
}
|
|||
|
function uncomputeOrdinal(year, ordinal) {
|
|||
|
const table = isLeapYear(year) ? leapLadder : nonLeapLadder, month0 = table.findIndex((i) => i < ordinal), day = ordinal - table[month0];
|
|||
|
return { month: month0 + 1, day };
|
|||
|
}
|
|||
|
function gregorianToWeek(gregObj) {
|
|||
|
const { year, month, day } = gregObj, ordinal = computeOrdinal(year, month, day), weekday = dayOfWeek(year, month, day);
|
|||
|
let weekNumber = Math.floor((ordinal - weekday + 10) / 7), weekYear;
|
|||
|
if (weekNumber < 1) {
|
|||
|
weekYear = year - 1;
|
|||
|
weekNumber = weeksInWeekYear(weekYear);
|
|||
|
} else if (weekNumber > weeksInWeekYear(year)) {
|
|||
|
weekYear = year + 1;
|
|||
|
weekNumber = 1;
|
|||
|
} else {
|
|||
|
weekYear = year;
|
|||
|
}
|
|||
|
return { weekYear, weekNumber, weekday, ...timeObject(gregObj) };
|
|||
|
}
|
|||
|
function weekToGregorian(weekData) {
|
|||
|
const { weekYear, weekNumber, weekday } = weekData, weekdayOfJan4 = dayOfWeek(weekYear, 1, 4), yearInDays = daysInYear(weekYear);
|
|||
|
let ordinal = weekNumber * 7 + weekday - weekdayOfJan4 - 3, year;
|
|||
|
if (ordinal < 1) {
|
|||
|
year = weekYear - 1;
|
|||
|
ordinal += daysInYear(year);
|
|||
|
} else if (ordinal > yearInDays) {
|
|||
|
year = weekYear + 1;
|
|||
|
ordinal -= daysInYear(weekYear);
|
|||
|
} else {
|
|||
|
year = weekYear;
|
|||
|
}
|
|||
|
const { month, day } = uncomputeOrdinal(year, ordinal);
|
|||
|
return { year, month, day, ...timeObject(weekData) };
|
|||
|
}
|
|||
|
function gregorianToOrdinal(gregData) {
|
|||
|
const { year, month, day } = gregData;
|
|||
|
const ordinal = computeOrdinal(year, month, day);
|
|||
|
return { year, ordinal, ...timeObject(gregData) };
|
|||
|
}
|
|||
|
function ordinalToGregorian(ordinalData) {
|
|||
|
const { year, ordinal } = ordinalData;
|
|||
|
const { month, day } = uncomputeOrdinal(year, ordinal);
|
|||
|
return { year, month, day, ...timeObject(ordinalData) };
|
|||
|
}
|
|||
|
function hasInvalidWeekData(obj) {
|
|||
|
const validYear = isInteger(obj.weekYear), validWeek = integerBetween(obj.weekNumber, 1, weeksInWeekYear(obj.weekYear)), validWeekday = integerBetween(obj.weekday, 1, 7);
|
|||
|
if (!validYear) {
|
|||
|
return unitOutOfRange("weekYear", obj.weekYear);
|
|||
|
} else if (!validWeek) {
|
|||
|
return unitOutOfRange("week", obj.week);
|
|||
|
} else if (!validWeekday) {
|
|||
|
return unitOutOfRange("weekday", obj.weekday);
|
|||
|
} else
|
|||
|
return false;
|
|||
|
}
|
|||
|
function hasInvalidOrdinalData(obj) {
|
|||
|
const validYear = isInteger(obj.year), validOrdinal = integerBetween(obj.ordinal, 1, daysInYear(obj.year));
|
|||
|
if (!validYear) {
|
|||
|
return unitOutOfRange("year", obj.year);
|
|||
|
} else if (!validOrdinal) {
|
|||
|
return unitOutOfRange("ordinal", obj.ordinal);
|
|||
|
} else
|
|||
|
return false;
|
|||
|
}
|
|||
|
function hasInvalidGregorianData(obj) {
|
|||
|
const validYear = isInteger(obj.year), validMonth = integerBetween(obj.month, 1, 12), validDay = integerBetween(obj.day, 1, daysInMonth(obj.year, obj.month));
|
|||
|
if (!validYear) {
|
|||
|
return unitOutOfRange("year", obj.year);
|
|||
|
} else if (!validMonth) {
|
|||
|
return unitOutOfRange("month", obj.month);
|
|||
|
} else if (!validDay) {
|
|||
|
return unitOutOfRange("day", obj.day);
|
|||
|
} else
|
|||
|
return false;
|
|||
|
}
|
|||
|
function hasInvalidTimeData(obj) {
|
|||
|
const { hour, minute, second, millisecond } = obj;
|
|||
|
const validHour = integerBetween(hour, 0, 23) || hour === 24 && minute === 0 && second === 0 && millisecond === 0, validMinute = integerBetween(minute, 0, 59), validSecond = integerBetween(second, 0, 59), validMillisecond = integerBetween(millisecond, 0, 999);
|
|||
|
if (!validHour) {
|
|||
|
return unitOutOfRange("hour", hour);
|
|||
|
} else if (!validMinute) {
|
|||
|
return unitOutOfRange("minute", minute);
|
|||
|
} else if (!validSecond) {
|
|||
|
return unitOutOfRange("second", second);
|
|||
|
} else if (!validMillisecond) {
|
|||
|
return unitOutOfRange("millisecond", millisecond);
|
|||
|
} else
|
|||
|
return false;
|
|||
|
}
|
|||
|
var INVALID = "Invalid DateTime";
|
|||
|
var MAX_DATE = 864e13;
|
|||
|
function unsupportedZone(zone) {
|
|||
|
return new Invalid("unsupported zone", `the zone "${zone.name}" is not supported`);
|
|||
|
}
|
|||
|
function possiblyCachedWeekData(dt) {
|
|||
|
if (dt.weekData === null) {
|
|||
|
dt.weekData = gregorianToWeek(dt.c);
|
|||
|
}
|
|||
|
return dt.weekData;
|
|||
|
}
|
|||
|
function clone(inst, alts) {
|
|||
|
const current = {
|
|||
|
ts: inst.ts,
|
|||
|
zone: inst.zone,
|
|||
|
c: inst.c,
|
|||
|
o: inst.o,
|
|||
|
loc: inst.loc,
|
|||
|
invalid: inst.invalid
|
|||
|
};
|
|||
|
return new DateTime({ ...current, ...alts, old: current });
|
|||
|
}
|
|||
|
function fixOffset(localTS, o, tz) {
|
|||
|
let utcGuess = localTS - o * 60 * 1e3;
|
|||
|
const o2 = tz.offset(utcGuess);
|
|||
|
if (o === o2) {
|
|||
|
return [utcGuess, o];
|
|||
|
}
|
|||
|
utcGuess -= (o2 - o) * 60 * 1e3;
|
|||
|
const o3 = tz.offset(utcGuess);
|
|||
|
if (o2 === o3) {
|
|||
|
return [utcGuess, o2];
|
|||
|
}
|
|||
|
return [localTS - Math.min(o2, o3) * 60 * 1e3, Math.max(o2, o3)];
|
|||
|
}
|
|||
|
function tsToObj(ts, offset2) {
|
|||
|
ts += offset2 * 60 * 1e3;
|
|||
|
const d = new Date(ts);
|
|||
|
return {
|
|||
|
year: d.getUTCFullYear(),
|
|||
|
month: d.getUTCMonth() + 1,
|
|||
|
day: d.getUTCDate(),
|
|||
|
hour: d.getUTCHours(),
|
|||
|
minute: d.getUTCMinutes(),
|
|||
|
second: d.getUTCSeconds(),
|
|||
|
millisecond: d.getUTCMilliseconds()
|
|||
|
};
|
|||
|
}
|
|||
|
function objToTS(obj, offset2, zone) {
|
|||
|
return fixOffset(objToLocalTS(obj), offset2, zone);
|
|||
|
}
|
|||
|
function adjustTime(inst, dur) {
|
|||
|
const oPre = inst.o, year = inst.c.year + Math.trunc(dur.years), month = inst.c.month + Math.trunc(dur.months) + Math.trunc(dur.quarters) * 3, c = {
|
|||
|
...inst.c,
|
|||
|
year,
|
|||
|
month,
|
|||
|
day: Math.min(inst.c.day, daysInMonth(year, month)) + Math.trunc(dur.days) + Math.trunc(dur.weeks) * 7
|
|||
|
}, millisToAdd = Duration.fromObject({
|
|||
|
years: dur.years - Math.trunc(dur.years),
|
|||
|
quarters: dur.quarters - Math.trunc(dur.quarters),
|
|||
|
months: dur.months - Math.trunc(dur.months),
|
|||
|
weeks: dur.weeks - Math.trunc(dur.weeks),
|
|||
|
days: dur.days - Math.trunc(dur.days),
|
|||
|
hours: dur.hours,
|
|||
|
minutes: dur.minutes,
|
|||
|
seconds: dur.seconds,
|
|||
|
milliseconds: dur.milliseconds
|
|||
|
}).as("milliseconds"), localTS = objToLocalTS(c);
|
|||
|
let [ts, o] = fixOffset(localTS, oPre, inst.zone);
|
|||
|
if (millisToAdd !== 0) {
|
|||
|
ts += millisToAdd;
|
|||
|
o = inst.zone.offset(ts);
|
|||
|
}
|
|||
|
return { ts, o };
|
|||
|
}
|
|||
|
function parseDataToDateTime(parsed, parsedZone, opts, format, text2, specificOffset) {
|
|||
|
const { setZone, zone } = opts;
|
|||
|
if (parsed && Object.keys(parsed).length !== 0) {
|
|||
|
const interpretationZone = parsedZone || zone, inst = DateTime.fromObject(parsed, {
|
|||
|
...opts,
|
|||
|
zone: interpretationZone,
|
|||
|
specificOffset
|
|||
|
});
|
|||
|
return setZone ? inst : inst.setZone(zone);
|
|||
|
} else {
|
|||
|
return DateTime.invalid(
|
|||
|
new Invalid("unparsable", `the input "${text2}" can't be parsed as ${format}`)
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
function toTechFormat(dt, format, allowZ = true) {
|
|||
|
return dt.isValid ? Formatter.create(Locale.create("en-US"), {
|
|||
|
allowZ,
|
|||
|
forceSimple: true
|
|||
|
}).formatDateTimeFromString(dt, format) : null;
|
|||
|
}
|
|||
|
function toISODate(o, extended) {
|
|||
|
const longFormat = o.c.year > 9999 || o.c.year < 0;
|
|||
|
let c = "";
|
|||
|
if (longFormat && o.c.year >= 0)
|
|||
|
c += "+";
|
|||
|
c += padStart(o.c.year, longFormat ? 6 : 4);
|
|||
|
if (extended) {
|
|||
|
c += "-";
|
|||
|
c += padStart(o.c.month);
|
|||
|
c += "-";
|
|||
|
c += padStart(o.c.day);
|
|||
|
} else {
|
|||
|
c += padStart(o.c.month);
|
|||
|
c += padStart(o.c.day);
|
|||
|
}
|
|||
|
return c;
|
|||
|
}
|
|||
|
function toISOTime(o, extended, suppressSeconds, suppressMilliseconds, includeOffset, extendedZone) {
|
|||
|
let c = padStart(o.c.hour);
|
|||
|
if (extended) {
|
|||
|
c += ":";
|
|||
|
c += padStart(o.c.minute);
|
|||
|
if (o.c.second !== 0 || !suppressSeconds) {
|
|||
|
c += ":";
|
|||
|
}
|
|||
|
} else {
|
|||
|
c += padStart(o.c.minute);
|
|||
|
}
|
|||
|
if (o.c.second !== 0 || !suppressSeconds) {
|
|||
|
c += padStart(o.c.second);
|
|||
|
if (o.c.millisecond !== 0 || !suppressMilliseconds) {
|
|||
|
c += ".";
|
|||
|
c += padStart(o.c.millisecond, 3);
|
|||
|
}
|
|||
|
}
|
|||
|
if (includeOffset) {
|
|||
|
if (o.isOffsetFixed && o.offset === 0 && !extendedZone) {
|
|||
|
c += "Z";
|
|||
|
} else if (o.o < 0) {
|
|||
|
c += "-";
|
|||
|
c += padStart(Math.trunc(-o.o / 60));
|
|||
|
c += ":";
|
|||
|
c += padStart(Math.trunc(-o.o % 60));
|
|||
|
} else {
|
|||
|
c += "+";
|
|||
|
c += padStart(Math.trunc(o.o / 60));
|
|||
|
c += ":";
|
|||
|
c += padStart(Math.trunc(o.o % 60));
|
|||
|
}
|
|||
|
}
|
|||
|
if (extendedZone) {
|
|||
|
c += "[" + o.zone.ianaName + "]";
|
|||
|
}
|
|||
|
return c;
|
|||
|
}
|
|||
|
var defaultUnitValues = {
|
|||
|
month: 1,
|
|||
|
day: 1,
|
|||
|
hour: 0,
|
|||
|
minute: 0,
|
|||
|
second: 0,
|
|||
|
millisecond: 0
|
|||
|
};
|
|||
|
var defaultWeekUnitValues = {
|
|||
|
weekNumber: 1,
|
|||
|
weekday: 1,
|
|||
|
hour: 0,
|
|||
|
minute: 0,
|
|||
|
second: 0,
|
|||
|
millisecond: 0
|
|||
|
};
|
|||
|
var defaultOrdinalUnitValues = {
|
|||
|
ordinal: 1,
|
|||
|
hour: 0,
|
|||
|
minute: 0,
|
|||
|
second: 0,
|
|||
|
millisecond: 0
|
|||
|
};
|
|||
|
var orderedUnits = ["year", "month", "day", "hour", "minute", "second", "millisecond"];
|
|||
|
var orderedWeekUnits = [
|
|||
|
"weekYear",
|
|||
|
"weekNumber",
|
|||
|
"weekday",
|
|||
|
"hour",
|
|||
|
"minute",
|
|||
|
"second",
|
|||
|
"millisecond"
|
|||
|
];
|
|||
|
var orderedOrdinalUnits = ["year", "ordinal", "hour", "minute", "second", "millisecond"];
|
|||
|
function normalizeUnit(unit) {
|
|||
|
const normalized = {
|
|||
|
year: "year",
|
|||
|
years: "year",
|
|||
|
month: "month",
|
|||
|
months: "month",
|
|||
|
day: "day",
|
|||
|
days: "day",
|
|||
|
hour: "hour",
|
|||
|
hours: "hour",
|
|||
|
minute: "minute",
|
|||
|
minutes: "minute",
|
|||
|
quarter: "quarter",
|
|||
|
quarters: "quarter",
|
|||
|
second: "second",
|
|||
|
seconds: "second",
|
|||
|
millisecond: "millisecond",
|
|||
|
milliseconds: "millisecond",
|
|||
|
weekday: "weekday",
|
|||
|
weekdays: "weekday",
|
|||
|
weeknumber: "weekNumber",
|
|||
|
weeksnumber: "weekNumber",
|
|||
|
weeknumbers: "weekNumber",
|
|||
|
weekyear: "weekYear",
|
|||
|
weekyears: "weekYear",
|
|||
|
ordinal: "ordinal"
|
|||
|
}[unit.toLowerCase()];
|
|||
|
if (!normalized)
|
|||
|
throw new InvalidUnitError(unit);
|
|||
|
return normalized;
|
|||
|
}
|
|||
|
function quickDT(obj, opts) {
|
|||
|
const zone = normalizeZone(opts.zone, Settings2.defaultZone), loc = Locale.fromObject(opts), tsNow = Settings2.now();
|
|||
|
let ts, o;
|
|||
|
if (!isUndefined(obj.year)) {
|
|||
|
for (const u of orderedUnits) {
|
|||
|
if (isUndefined(obj[u])) {
|
|||
|
obj[u] = defaultUnitValues[u];
|
|||
|
}
|
|||
|
}
|
|||
|
const invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
|
|||
|
if (invalid) {
|
|||
|
return DateTime.invalid(invalid);
|
|||
|
}
|
|||
|
const offsetProvis = zone.offset(tsNow);
|
|||
|
[ts, o] = objToTS(obj, offsetProvis, zone);
|
|||
|
} else {
|
|||
|
ts = tsNow;
|
|||
|
}
|
|||
|
return new DateTime({ ts, zone, loc, o });
|
|||
|
}
|
|||
|
function diffRelative(start, end, opts) {
|
|||
|
const round = isUndefined(opts.round) ? true : opts.round, format = (c, unit) => {
|
|||
|
c = roundTo(c, round || opts.calendary ? 0 : 2, true);
|
|||
|
const formatter = end.loc.clone(opts).relFormatter(opts);
|
|||
|
return formatter.format(c, unit);
|
|||
|
}, differ = (unit) => {
|
|||
|
if (opts.calendary) {
|
|||
|
if (!end.hasSame(start, unit)) {
|
|||
|
return end.startOf(unit).diff(start.startOf(unit), unit).get(unit);
|
|||
|
} else
|
|||
|
return 0;
|
|||
|
} else {
|
|||
|
return end.diff(start, unit).get(unit);
|
|||
|
}
|
|||
|
};
|
|||
|
if (opts.unit) {
|
|||
|
return format(differ(opts.unit), opts.unit);
|
|||
|
}
|
|||
|
for (const unit of opts.units) {
|
|||
|
const count = differ(unit);
|
|||
|
if (Math.abs(count) >= 1) {
|
|||
|
return format(count, unit);
|
|||
|
}
|
|||
|
}
|
|||
|
return format(start > end ? -0 : 0, opts.units[opts.units.length - 1]);
|
|||
|
}
|
|||
|
function lastOpts(argList) {
|
|||
|
let opts = {}, args;
|
|||
|
if (argList.length > 0 && typeof argList[argList.length - 1] === "object") {
|
|||
|
opts = argList[argList.length - 1];
|
|||
|
args = Array.from(argList).slice(0, argList.length - 1);
|
|||
|
} else {
|
|||
|
args = Array.from(argList);
|
|||
|
}
|
|||
|
return [opts, args];
|
|||
|
}
|
|||
|
var DateTime = class {
|
|||
|
/**
|
|||
|
* @access private
|
|||
|
*/
|
|||
|
constructor(config) {
|
|||
|
const zone = config.zone || Settings2.defaultZone;
|
|||
|
let invalid = config.invalid || (Number.isNaN(config.ts) ? new Invalid("invalid input") : null) || (!zone.isValid ? unsupportedZone(zone) : null);
|
|||
|
this.ts = isUndefined(config.ts) ? Settings2.now() : config.ts;
|
|||
|
let c = null, o = null;
|
|||
|
if (!invalid) {
|
|||
|
const unchanged = config.old && config.old.ts === this.ts && config.old.zone.equals(zone);
|
|||
|
if (unchanged) {
|
|||
|
[c, o] = [config.old.c, config.old.o];
|
|||
|
} else {
|
|||
|
const ot = zone.offset(this.ts);
|
|||
|
c = tsToObj(this.ts, ot);
|
|||
|
invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null;
|
|||
|
c = invalid ? null : c;
|
|||
|
o = invalid ? null : ot;
|
|||
|
}
|
|||
|
}
|
|||
|
this._zone = zone;
|
|||
|
this.loc = config.loc || Locale.create();
|
|||
|
this.invalid = invalid;
|
|||
|
this.weekData = null;
|
|||
|
this.c = c;
|
|||
|
this.o = o;
|
|||
|
this.isLuxonDateTime = true;
|
|||
|
}
|
|||
|
// CONSTRUCT
|
|||
|
/**
|
|||
|
* Create a DateTime for the current instant, in the system's time zone.
|
|||
|
*
|
|||
|
* Use Settings to override these default values if needed.
|
|||
|
* @example DateTime.now().toISO() //~> now in the ISO format
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static now() {
|
|||
|
return new DateTime({});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a local DateTime
|
|||
|
* @param {number} [year] - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used
|
|||
|
* @param {number} [month=1] - The month, 1-indexed
|
|||
|
* @param {number} [day=1] - The day of the month, 1-indexed
|
|||
|
* @param {number} [hour=0] - The hour of the day, in 24-hour time
|
|||
|
* @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
|
|||
|
* @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
|
|||
|
* @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
|
|||
|
* @example DateTime.local() //~> now
|
|||
|
* @example DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time
|
|||
|
* @example DateTime.local(2017) //~> 2017-01-01T00:00:00
|
|||
|
* @example DateTime.local(2017, 3) //~> 2017-03-01T00:00:00
|
|||
|
* @example DateTime.local(2017, 3, 12, { locale: "fr" }) //~> 2017-03-12T00:00:00, with a French locale
|
|||
|
* @example DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00
|
|||
|
* @example DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC
|
|||
|
* @example DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00
|
|||
|
* @example DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10
|
|||
|
* @example DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static local() {
|
|||
|
const [opts, args] = lastOpts(arguments), [year, month, day, hour, minute, second, millisecond] = args;
|
|||
|
return quickDT({ year, month, day, hour, minute, second, millisecond }, opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime in UTC
|
|||
|
* @param {number} [year] - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used
|
|||
|
* @param {number} [month=1] - The month, 1-indexed
|
|||
|
* @param {number} [day=1] - The day of the month
|
|||
|
* @param {number} [hour=0] - The hour of the day, in 24-hour time
|
|||
|
* @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
|
|||
|
* @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
|
|||
|
* @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
|
|||
|
* @param {Object} options - configuration options for the DateTime
|
|||
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
|||
|
* @param {string} [options.outputCalendar] - the output calendar to set on the resulting DateTime instance
|
|||
|
* @param {string} [options.numberingSystem] - the numbering system to set on the resulting DateTime instance
|
|||
|
* @example DateTime.utc() //~> now
|
|||
|
* @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
|
|||
|
* @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
|
|||
|
* @example DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z
|
|||
|
* @example DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z
|
|||
|
* @example DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z
|
|||
|
* @example DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" }) //~> 2017-03-12T05:45:00Z with a French locale
|
|||
|
* @example DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z
|
|||
|
* @example DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr" }) //~> 2017-03-12T05:45:10.765Z with a French locale
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static utc() {
|
|||
|
const [opts, args] = lastOpts(arguments), [year, month, day, hour, minute, second, millisecond] = args;
|
|||
|
opts.zone = FixedOffsetZone.utcInstance;
|
|||
|
return quickDT({ year, month, day, hour, minute, second, millisecond }, opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from a JavaScript Date object. Uses the default zone.
|
|||
|
* @param {Date} date - a JavaScript Date object
|
|||
|
* @param {Object} options - configuration options for the DateTime
|
|||
|
* @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromJSDate(date, options = {}) {
|
|||
|
const ts = isDate(date) ? date.valueOf() : NaN;
|
|||
|
if (Number.isNaN(ts)) {
|
|||
|
return DateTime.invalid("invalid input");
|
|||
|
}
|
|||
|
const zoneToUse = normalizeZone(options.zone, Settings2.defaultZone);
|
|||
|
if (!zoneToUse.isValid) {
|
|||
|
return DateTime.invalid(unsupportedZone(zoneToUse));
|
|||
|
}
|
|||
|
return new DateTime({
|
|||
|
ts,
|
|||
|
zone: zoneToUse,
|
|||
|
loc: Locale.fromObject(options)
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
|
|||
|
* @param {number} milliseconds - a number of milliseconds since 1970 UTC
|
|||
|
* @param {Object} options - configuration options for the DateTime
|
|||
|
* @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
|
|||
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
|||
|
* @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
|||
|
* @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromMillis(milliseconds, options = {}) {
|
|||
|
if (!isNumber(milliseconds)) {
|
|||
|
throw new InvalidArgumentError(
|
|||
|
`fromMillis requires a numerical input, but received a ${typeof milliseconds} with value ${milliseconds}`
|
|||
|
);
|
|||
|
} else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
|
|||
|
return DateTime.invalid("Timestamp out of range");
|
|||
|
} else {
|
|||
|
return new DateTime({
|
|||
|
ts: milliseconds,
|
|||
|
zone: normalizeZone(options.zone, Settings2.defaultZone),
|
|||
|
loc: Locale.fromObject(options)
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
|
|||
|
* @param {number} seconds - a number of seconds since 1970 UTC
|
|||
|
* @param {Object} options - configuration options for the DateTime
|
|||
|
* @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
|
|||
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
|||
|
* @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
|||
|
* @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromSeconds(seconds, options = {}) {
|
|||
|
if (!isNumber(seconds)) {
|
|||
|
throw new InvalidArgumentError("fromSeconds requires a numerical input");
|
|||
|
} else {
|
|||
|
return new DateTime({
|
|||
|
ts: seconds * 1e3,
|
|||
|
zone: normalizeZone(options.zone, Settings2.defaultZone),
|
|||
|
loc: Locale.fromObject(options)
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults.
|
|||
|
* @param {Object} obj - the object to create the DateTime from
|
|||
|
* @param {number} obj.year - a year, such as 1987
|
|||
|
* @param {number} obj.month - a month, 1-12
|
|||
|
* @param {number} obj.day - a day of the month, 1-31, depending on the month
|
|||
|
* @param {number} obj.ordinal - day of the year, 1-365 or 366
|
|||
|
* @param {number} obj.weekYear - an ISO week year
|
|||
|
* @param {number} obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year
|
|||
|
* @param {number} obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday
|
|||
|
* @param {number} obj.hour - hour of the day, 0-23
|
|||
|
* @param {number} obj.minute - minute of the hour, 0-59
|
|||
|
* @param {number} obj.second - second of the minute, 0-59
|
|||
|
* @param {number} obj.millisecond - millisecond of the second, 0-999
|
|||
|
* @param {Object} opts - options for creating this DateTime
|
|||
|
* @param {string|Zone} [opts.zone='local'] - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone()
|
|||
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
|||
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
|||
|
* @example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'
|
|||
|
* @example DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'
|
|||
|
* @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06
|
|||
|
* @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }),
|
|||
|
* @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' })
|
|||
|
* @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'America/New_York' })
|
|||
|
* @example DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13'
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromObject(obj, opts = {}) {
|
|||
|
obj = obj || {};
|
|||
|
const zoneToUse = normalizeZone(opts.zone, Settings2.defaultZone);
|
|||
|
if (!zoneToUse.isValid) {
|
|||
|
return DateTime.invalid(unsupportedZone(zoneToUse));
|
|||
|
}
|
|||
|
const tsNow = Settings2.now(), offsetProvis = !isUndefined(opts.specificOffset) ? opts.specificOffset : zoneToUse.offset(tsNow), normalized = normalizeObject(obj, normalizeUnit), containsOrdinal = !isUndefined(normalized.ordinal), containsGregorYear = !isUndefined(normalized.year), containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day), containsGregor = containsGregorYear || containsGregorMD, definiteWeekDef = normalized.weekYear || normalized.weekNumber, loc = Locale.fromObject(opts);
|
|||
|
if ((containsGregor || containsOrdinal) && definiteWeekDef) {
|
|||
|
throw new ConflictingSpecificationError(
|
|||
|
"Can't mix weekYear/weekNumber units with year/month/day or ordinals"
|
|||
|
);
|
|||
|
}
|
|||
|
if (containsGregorMD && containsOrdinal) {
|
|||
|
throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
|
|||
|
}
|
|||
|
const useWeekData = definiteWeekDef || normalized.weekday && !containsGregor;
|
|||
|
let units, defaultValues, objNow = tsToObj(tsNow, offsetProvis);
|
|||
|
if (useWeekData) {
|
|||
|
units = orderedWeekUnits;
|
|||
|
defaultValues = defaultWeekUnitValues;
|
|||
|
objNow = gregorianToWeek(objNow);
|
|||
|
} else if (containsOrdinal) {
|
|||
|
units = orderedOrdinalUnits;
|
|||
|
defaultValues = defaultOrdinalUnitValues;
|
|||
|
objNow = gregorianToOrdinal(objNow);
|
|||
|
} else {
|
|||
|
units = orderedUnits;
|
|||
|
defaultValues = defaultUnitValues;
|
|||
|
}
|
|||
|
let foundFirst = false;
|
|||
|
for (const u of units) {
|
|||
|
const v = normalized[u];
|
|||
|
if (!isUndefined(v)) {
|
|||
|
foundFirst = true;
|
|||
|
} else if (foundFirst) {
|
|||
|
normalized[u] = defaultValues[u];
|
|||
|
} else {
|
|||
|
normalized[u] = objNow[u];
|
|||
|
}
|
|||
|
}
|
|||
|
const higherOrderInvalid = useWeekData ? hasInvalidWeekData(normalized) : containsOrdinal ? hasInvalidOrdinalData(normalized) : hasInvalidGregorianData(normalized), invalid = higherOrderInvalid || hasInvalidTimeData(normalized);
|
|||
|
if (invalid) {
|
|||
|
return DateTime.invalid(invalid);
|
|||
|
}
|
|||
|
const gregorian = useWeekData ? weekToGregorian(normalized) : containsOrdinal ? ordinalToGregorian(normalized) : normalized, [tsFinal, offsetFinal] = objToTS(gregorian, offsetProvis, zoneToUse), inst = new DateTime({
|
|||
|
ts: tsFinal,
|
|||
|
zone: zoneToUse,
|
|||
|
o: offsetFinal,
|
|||
|
loc
|
|||
|
});
|
|||
|
if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) {
|
|||
|
return DateTime.invalid(
|
|||
|
"mismatched weekday",
|
|||
|
`you can't specify both a weekday of ${normalized.weekday} and a date of ${inst.toISO()}`
|
|||
|
);
|
|||
|
}
|
|||
|
return inst;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from an ISO 8601 string
|
|||
|
* @param {string} text - the ISO string
|
|||
|
* @param {Object} opts - options to affect the creation
|
|||
|
* @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the time to this zone
|
|||
|
* @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one
|
|||
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
|||
|
* @param {string} [opts.outputCalendar] - the output calendar to set on the resulting DateTime instance
|
|||
|
* @param {string} [opts.numberingSystem] - the numbering system to set on the resulting DateTime instance
|
|||
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123')
|
|||
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00')
|
|||
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true})
|
|||
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'})
|
|||
|
* @example DateTime.fromISO('2016-W05-4')
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromISO(text2, opts = {}) {
|
|||
|
const [vals, parsedZone] = parseISODate(text2);
|
|||
|
return parseDataToDateTime(vals, parsedZone, opts, "ISO 8601", text2);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from an RFC 2822 string
|
|||
|
* @param {string} text - the RFC 2822 string
|
|||
|
* @param {Object} opts - options to affect the creation
|
|||
|
* @param {string|Zone} [opts.zone='local'] - convert the time to this zone. Since the offset is always specified in the string itself, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in.
|
|||
|
* @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one
|
|||
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
|||
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
|||
|
* @example DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT')
|
|||
|
* @example DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600')
|
|||
|
* @example DateTime.fromRFC2822('25 Nov 2016 13:23 Z')
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromRFC2822(text2, opts = {}) {
|
|||
|
const [vals, parsedZone] = parseRFC2822Date(text2);
|
|||
|
return parseDataToDateTime(vals, parsedZone, opts, "RFC 2822", text2);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from an HTTP header date
|
|||
|
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
|
|||
|
* @param {string} text - the HTTP header date
|
|||
|
* @param {Object} opts - options to affect the creation
|
|||
|
* @param {string|Zone} [opts.zone='local'] - convert the time to this zone. Since HTTP dates are always in UTC, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in.
|
|||
|
* @param {boolean} [opts.setZone=false] - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, so this option is equivalent to setting the `zone` option to 'utc', but this option is included for consistency with similar methods.
|
|||
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
|||
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
|||
|
* @example DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT')
|
|||
|
* @example DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT')
|
|||
|
* @example DateTime.fromHTTP('Sun Nov 6 08:49:37 1994')
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromHTTP(text2, opts = {}) {
|
|||
|
const [vals, parsedZone] = parseHTTPDate(text2);
|
|||
|
return parseDataToDateTime(vals, parsedZone, opts, "HTTP", opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from an input string and format string.
|
|||
|
* Defaults to en-US if no locale has been specified, regardless of the system's locale. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens).
|
|||
|
* @param {string} text - the string to parse
|
|||
|
* @param {string} fmt - the format the string is expected to be in (see the link below for the formats)
|
|||
|
* @param {Object} opts - options to affect the creation
|
|||
|
* @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone
|
|||
|
* @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
|
|||
|
* @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
|
|||
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromFormat(text2, fmt, opts = {}) {
|
|||
|
if (isUndefined(text2) || isUndefined(fmt)) {
|
|||
|
throw new InvalidArgumentError("fromFormat requires an input string and a format");
|
|||
|
}
|
|||
|
const { locale = null, numberingSystem = null } = opts, localeToUse = Locale.fromOpts({
|
|||
|
locale,
|
|||
|
numberingSystem,
|
|||
|
defaultToEN: true
|
|||
|
}), [vals, parsedZone, specificOffset, invalid] = parseFromTokens(localeToUse, text2, fmt);
|
|||
|
if (invalid) {
|
|||
|
return DateTime.invalid(invalid);
|
|||
|
} else {
|
|||
|
return parseDataToDateTime(vals, parsedZone, opts, `format ${fmt}`, text2, specificOffset);
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* @deprecated use fromFormat instead
|
|||
|
*/
|
|||
|
static fromString(text2, fmt, opts = {}) {
|
|||
|
return DateTime.fromFormat(text2, fmt, opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create a DateTime from a SQL date, time, or datetime
|
|||
|
* Defaults to en-US if no locale has been specified, regardless of the system's locale
|
|||
|
* @param {string} text - the string to parse
|
|||
|
* @param {Object} opts - options to affect the creation
|
|||
|
* @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone
|
|||
|
* @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
|
|||
|
* @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
|
|||
|
* @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
|
|||
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
|||
|
* @example DateTime.fromSQL('2017-05-15')
|
|||
|
* @example DateTime.fromSQL('2017-05-15 09:12:34')
|
|||
|
* @example DateTime.fromSQL('2017-05-15 09:12:34.342')
|
|||
|
* @example DateTime.fromSQL('2017-05-15 09:12:34.342+06:00')
|
|||
|
* @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles')
|
|||
|
* @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true })
|
|||
|
* @example DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' })
|
|||
|
* @example DateTime.fromSQL('09:12:34.342')
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static fromSQL(text2, opts = {}) {
|
|||
|
const [vals, parsedZone] = parseSQL(text2);
|
|||
|
return parseDataToDateTime(vals, parsedZone, opts, "SQL", text2);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Create an invalid DateTime.
|
|||
|
* @param {DateTime} reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent
|
|||
|
* @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
static invalid(reason, explanation = null) {
|
|||
|
if (!reason) {
|
|||
|
throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");
|
|||
|
}
|
|||
|
const invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|||
|
if (Settings2.throwOnInvalid) {
|
|||
|
throw new InvalidDateTimeError(invalid);
|
|||
|
} else {
|
|||
|
return new DateTime({ invalid });
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Check if an object is an instance of DateTime. Works across context boundaries
|
|||
|
* @param {object} o
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
static isDateTime(o) {
|
|||
|
return o && o.isLuxonDateTime || false;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Produce the format string for a set of options
|
|||
|
* @param formatOpts
|
|||
|
* @param localeOpts
|
|||
|
* @returns {string}
|
|||
|
*/
|
|||
|
static parseFormatForOpts(formatOpts, localeOpts = {}) {
|
|||
|
const tokenList = formatOptsToTokens(formatOpts, Locale.fromObject(localeOpts));
|
|||
|
return !tokenList ? null : tokenList.map((t) => t ? t.val : null).join("");
|
|||
|
}
|
|||
|
/**
|
|||
|
* Produce the the fully expanded format token for the locale
|
|||
|
* Does NOT quote characters, so quoted tokens will not round trip correctly
|
|||
|
* @param fmt
|
|||
|
* @param localeOpts
|
|||
|
* @returns {string}
|
|||
|
*/
|
|||
|
static expandFormat(fmt, localeOpts = {}) {
|
|||
|
const expanded = expandMacroTokens(Formatter.parseFormat(fmt), Locale.fromObject(localeOpts));
|
|||
|
return expanded.map((t) => t.val).join("");
|
|||
|
}
|
|||
|
// INFO
|
|||
|
/**
|
|||
|
* Get the value of unit.
|
|||
|
* @param {string} unit - a unit such as 'minute' or 'day'
|
|||
|
* @example DateTime.local(2017, 7, 4).get('month'); //=> 7
|
|||
|
* @example DateTime.local(2017, 7, 4).get('day'); //=> 4
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
get(unit) {
|
|||
|
return this[unit];
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns whether the DateTime is valid. Invalid DateTimes occur when:
|
|||
|
* * The DateTime was created from invalid calendar information, such as the 13th month or February 30
|
|||
|
* * The DateTime was created by an operation on another invalid date
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
get isValid() {
|
|||
|
return this.invalid === null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an error code if this DateTime is invalid, or null if the DateTime is valid
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get invalidReason() {
|
|||
|
return this.invalid ? this.invalid.reason : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get invalidExplanation() {
|
|||
|
return this.invalid ? this.invalid.explanation : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime
|
|||
|
*
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get locale() {
|
|||
|
return this.isValid ? this.loc.locale : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime
|
|||
|
*
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get numberingSystem() {
|
|||
|
return this.isValid ? this.loc.numberingSystem : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime
|
|||
|
*
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get outputCalendar() {
|
|||
|
return this.isValid ? this.loc.outputCalendar : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the time zone associated with this DateTime.
|
|||
|
* @type {Zone}
|
|||
|
*/
|
|||
|
get zone() {
|
|||
|
return this._zone;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the name of the time zone.
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get zoneName() {
|
|||
|
return this.isValid ? this.zone.name : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the year
|
|||
|
* @example DateTime.local(2017, 5, 25).year //=> 2017
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get year() {
|
|||
|
return this.isValid ? this.c.year : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the quarter
|
|||
|
* @example DateTime.local(2017, 5, 25).quarter //=> 2
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get quarter() {
|
|||
|
return this.isValid ? Math.ceil(this.c.month / 3) : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the month (1-12).
|
|||
|
* @example DateTime.local(2017, 5, 25).month //=> 5
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get month() {
|
|||
|
return this.isValid ? this.c.month : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the day of the month (1-30ish).
|
|||
|
* @example DateTime.local(2017, 5, 25).day //=> 25
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get day() {
|
|||
|
return this.isValid ? this.c.day : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the hour of the day (0-23).
|
|||
|
* @example DateTime.local(2017, 5, 25, 9).hour //=> 9
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get hour() {
|
|||
|
return this.isValid ? this.c.hour : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the minute of the hour (0-59).
|
|||
|
* @example DateTime.local(2017, 5, 25, 9, 30).minute //=> 30
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get minute() {
|
|||
|
return this.isValid ? this.c.minute : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the second of the minute (0-59).
|
|||
|
* @example DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get second() {
|
|||
|
return this.isValid ? this.c.second : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the millisecond of the second (0-999).
|
|||
|
* @example DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get millisecond() {
|
|||
|
return this.isValid ? this.c.millisecond : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the week year
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_week_date
|
|||
|
* @example DateTime.local(2014, 12, 31).weekYear //=> 2015
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get weekYear() {
|
|||
|
return this.isValid ? possiblyCachedWeekData(this).weekYear : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the week number of the week year (1-52ish).
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_week_date
|
|||
|
* @example DateTime.local(2017, 5, 25).weekNumber //=> 21
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get weekNumber() {
|
|||
|
return this.isValid ? possiblyCachedWeekData(this).weekNumber : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the day of the week.
|
|||
|
* 1 is Monday and 7 is Sunday
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_week_date
|
|||
|
* @example DateTime.local(2014, 11, 31).weekday //=> 4
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get weekday() {
|
|||
|
return this.isValid ? possiblyCachedWeekData(this).weekday : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the ordinal (meaning the day of the year)
|
|||
|
* @example DateTime.local(2017, 5, 25).ordinal //=> 145
|
|||
|
* @type {number|DateTime}
|
|||
|
*/
|
|||
|
get ordinal() {
|
|||
|
return this.isValid ? gregorianToOrdinal(this.c).ordinal : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the human readable short month name, such as 'Oct'.
|
|||
|
* Defaults to the system's locale if no locale has been specified
|
|||
|
* @example DateTime.local(2017, 10, 30).monthShort //=> Oct
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get monthShort() {
|
|||
|
return this.isValid ? Info.months("short", { locObj: this.loc })[this.month - 1] : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the human readable long month name, such as 'October'.
|
|||
|
* Defaults to the system's locale if no locale has been specified
|
|||
|
* @example DateTime.local(2017, 10, 30).monthLong //=> October
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get monthLong() {
|
|||
|
return this.isValid ? Info.months("long", { locObj: this.loc })[this.month - 1] : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the human readable short weekday, such as 'Mon'.
|
|||
|
* Defaults to the system's locale if no locale has been specified
|
|||
|
* @example DateTime.local(2017, 10, 30).weekdayShort //=> Mon
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get weekdayShort() {
|
|||
|
return this.isValid ? Info.weekdays("short", { locObj: this.loc })[this.weekday - 1] : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the human readable long weekday, such as 'Monday'.
|
|||
|
* Defaults to the system's locale if no locale has been specified
|
|||
|
* @example DateTime.local(2017, 10, 30).weekdayLong //=> Monday
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get weekdayLong() {
|
|||
|
return this.isValid ? Info.weekdays("long", { locObj: this.loc })[this.weekday - 1] : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the UTC offset of this DateTime in minutes
|
|||
|
* @example DateTime.now().offset //=> -240
|
|||
|
* @example DateTime.utc().offset //=> 0
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get offset() {
|
|||
|
return this.isValid ? +this.o : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the short human name for the zone's current offset, for example "EST" or "EDT".
|
|||
|
* Defaults to the system's locale if no locale has been specified
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get offsetNameShort() {
|
|||
|
if (this.isValid) {
|
|||
|
return this.zone.offsetName(this.ts, {
|
|||
|
format: "short",
|
|||
|
locale: this.locale
|
|||
|
});
|
|||
|
} else {
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time".
|
|||
|
* Defaults to the system's locale if no locale has been specified
|
|||
|
* @type {string}
|
|||
|
*/
|
|||
|
get offsetNameLong() {
|
|||
|
if (this.isValid) {
|
|||
|
return this.zone.offsetName(this.ts, {
|
|||
|
format: "long",
|
|||
|
locale: this.locale
|
|||
|
});
|
|||
|
} else {
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get whether this zone's offset ever changes, as in a DST.
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
get isOffsetFixed() {
|
|||
|
return this.isValid ? this.zone.isUniversal : null;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Get whether the DateTime is in a DST.
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
get isInDST() {
|
|||
|
if (this.isOffsetFixed) {
|
|||
|
return false;
|
|||
|
} else {
|
|||
|
return this.offset > this.set({ month: 1, day: 1 }).offset || this.offset > this.set({ month: 5 }).offset;
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns true if this DateTime is in a leap year, false otherwise
|
|||
|
* @example DateTime.local(2016).isInLeapYear //=> true
|
|||
|
* @example DateTime.local(2013).isInLeapYear //=> false
|
|||
|
* @type {boolean}
|
|||
|
*/
|
|||
|
get isInLeapYear() {
|
|||
|
return isLeapYear(this.year);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the number of days in this DateTime's month
|
|||
|
* @example DateTime.local(2016, 2).daysInMonth //=> 29
|
|||
|
* @example DateTime.local(2016, 3).daysInMonth //=> 31
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get daysInMonth() {
|
|||
|
return daysInMonth(this.year, this.month);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the number of days in this DateTime's year
|
|||
|
* @example DateTime.local(2016).daysInYear //=> 366
|
|||
|
* @example DateTime.local(2013).daysInYear //=> 365
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get daysInYear() {
|
|||
|
return this.isValid ? daysInYear(this.year) : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the number of weeks in this DateTime's year
|
|||
|
* @see https://en.wikipedia.org/wiki/ISO_week_date
|
|||
|
* @example DateTime.local(2004).weeksInWeekYear //=> 53
|
|||
|
* @example DateTime.local(2013).weeksInWeekYear //=> 52
|
|||
|
* @type {number}
|
|||
|
*/
|
|||
|
get weeksInWeekYear() {
|
|||
|
return this.isValid ? weeksInWeekYear(this.weekYear) : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the resolved Intl options for this DateTime.
|
|||
|
* This is useful in understanding the behavior of formatting methods
|
|||
|
* @param {Object} opts - the same options as toLocaleString
|
|||
|
* @return {Object}
|
|||
|
*/
|
|||
|
resolvedLocaleOptions(opts = {}) {
|
|||
|
const { locale, numberingSystem, calendar } = Formatter.create(
|
|||
|
this.loc.clone(opts),
|
|||
|
opts
|
|||
|
).resolvedOptions(this);
|
|||
|
return { locale, numberingSystem, outputCalendar: calendar };
|
|||
|
}
|
|||
|
// TRANSFORM
|
|||
|
/**
|
|||
|
* "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime.
|
|||
|
*
|
|||
|
* Equivalent to {@link DateTime#setZone}('utc')
|
|||
|
* @param {number} [offset=0] - optionally, an offset from UTC in minutes
|
|||
|
* @param {Object} [opts={}] - options to pass to `setZone()`
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
toUTC(offset2 = 0, opts = {}) {
|
|||
|
return this.setZone(FixedOffsetZone.instance(offset2), opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime.
|
|||
|
*
|
|||
|
* Equivalent to `setZone('local')`
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
toLocal() {
|
|||
|
return this.setZone(Settings2.defaultZone);
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime.
|
|||
|
*
|
|||
|
* By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, as with {@link DateTime#plus}. You may wish to use {@link DateTime#toLocal} and {@link DateTime#toUTC} which provide simple convenience wrappers for commonly used zones.
|
|||
|
* @param {string|Zone} [zone='local'] - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. You may also supply an instance of a {@link DateTime#Zone} class.
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {boolean} [opts.keepLocalTime=false] - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this.
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
setZone(zone, { keepLocalTime = false, keepCalendarTime = false } = {}) {
|
|||
|
zone = normalizeZone(zone, Settings2.defaultZone);
|
|||
|
if (zone.equals(this.zone)) {
|
|||
|
return this;
|
|||
|
} else if (!zone.isValid) {
|
|||
|
return DateTime.invalid(unsupportedZone(zone));
|
|||
|
} else {
|
|||
|
let newTS = this.ts;
|
|||
|
if (keepLocalTime || keepCalendarTime) {
|
|||
|
const offsetGuess = zone.offset(this.ts);
|
|||
|
const asObj = this.toObject();
|
|||
|
[newTS] = objToTS(asObj, offsetGuess, zone);
|
|||
|
}
|
|||
|
return clone(this, { ts: newTS, zone });
|
|||
|
}
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
|
|||
|
* @param {Object} properties - the properties to set
|
|||
|
* @example DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' })
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
reconfigure({ locale, numberingSystem, outputCalendar } = {}) {
|
|||
|
const loc = this.loc.clone({ locale, numberingSystem, outputCalendar });
|
|||
|
return clone(this, { loc });
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" the locale. Returns a newly-constructed DateTime.
|
|||
|
* Just a convenient alias for reconfigure({ locale })
|
|||
|
* @example DateTime.local(2017, 5, 25).setLocale('en-GB')
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
setLocale(locale) {
|
|||
|
return this.reconfigure({ locale });
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" the values of specified units. Returns a newly-constructed DateTime.
|
|||
|
* You can only set units with this method; for "setting" metadata, see {@link DateTime#reconfigure} and {@link DateTime#setZone}.
|
|||
|
* @param {Object} values - a mapping of units to numbers
|
|||
|
* @example dt.set({ year: 2017 })
|
|||
|
* @example dt.set({ hour: 8, minute: 30 })
|
|||
|
* @example dt.set({ weekday: 5 })
|
|||
|
* @example dt.set({ year: 2005, ordinal: 234 })
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
set(values) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const normalized = normalizeObject(values, normalizeUnit), settingWeekStuff = !isUndefined(normalized.weekYear) || !isUndefined(normalized.weekNumber) || !isUndefined(normalized.weekday), containsOrdinal = !isUndefined(normalized.ordinal), containsGregorYear = !isUndefined(normalized.year), containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day), containsGregor = containsGregorYear || containsGregorMD, definiteWeekDef = normalized.weekYear || normalized.weekNumber;
|
|||
|
if ((containsGregor || containsOrdinal) && definiteWeekDef) {
|
|||
|
throw new ConflictingSpecificationError(
|
|||
|
"Can't mix weekYear/weekNumber units with year/month/day or ordinals"
|
|||
|
);
|
|||
|
}
|
|||
|
if (containsGregorMD && containsOrdinal) {
|
|||
|
throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
|
|||
|
}
|
|||
|
let mixed;
|
|||
|
if (settingWeekStuff) {
|
|||
|
mixed = weekToGregorian({ ...gregorianToWeek(this.c), ...normalized });
|
|||
|
} else if (!isUndefined(normalized.ordinal)) {
|
|||
|
mixed = ordinalToGregorian({ ...gregorianToOrdinal(this.c), ...normalized });
|
|||
|
} else {
|
|||
|
mixed = { ...this.toObject(), ...normalized };
|
|||
|
if (isUndefined(normalized.day)) {
|
|||
|
mixed.day = Math.min(daysInMonth(mixed.year, mixed.month), mixed.day);
|
|||
|
}
|
|||
|
}
|
|||
|
const [ts, o] = objToTS(mixed, this.o, this.zone);
|
|||
|
return clone(this, { ts, o });
|
|||
|
}
|
|||
|
/**
|
|||
|
* Add a period of time to this DateTime and return the resulting DateTime
|
|||
|
*
|
|||
|
* Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, accounting for DSTs and leap years along the way. Thus, `dt.plus({ hours: 24 })` may result in a different time than `dt.plus({ days: 1 })` if there's a DST shift in between.
|
|||
|
* @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
|
|||
|
* @example DateTime.now().plus(123) //~> in 123 milliseconds
|
|||
|
* @example DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes
|
|||
|
* @example DateTime.now().plus({ days: 1 }) //~> this time tomorrow
|
|||
|
* @example DateTime.now().plus({ days: -1 }) //~> this time yesterday
|
|||
|
* @example DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min
|
|||
|
* @example DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
plus(duration) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const dur = Duration.fromDurationLike(duration);
|
|||
|
return clone(this, adjustTime(this, dur));
|
|||
|
}
|
|||
|
/**
|
|||
|
* Subtract a period of time to this DateTime and return the resulting DateTime
|
|||
|
* See {@link DateTime#plus}
|
|||
|
* @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
|
|||
|
@return {DateTime}
|
|||
|
*/
|
|||
|
minus(duration) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const dur = Duration.fromDurationLike(duration).negate();
|
|||
|
return clone(this, adjustTime(this, dur));
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" this DateTime to the beginning of a unit of time.
|
|||
|
* @param {string} unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
|
|||
|
* @example DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01'
|
|||
|
* @example DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01'
|
|||
|
* @example DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays
|
|||
|
* @example DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00'
|
|||
|
* @example DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00'
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
startOf(unit) {
|
|||
|
if (!this.isValid)
|
|||
|
return this;
|
|||
|
const o = {}, normalizedUnit = Duration.normalizeUnit(unit);
|
|||
|
switch (normalizedUnit) {
|
|||
|
case "years":
|
|||
|
o.month = 1;
|
|||
|
case "quarters":
|
|||
|
case "months":
|
|||
|
o.day = 1;
|
|||
|
case "weeks":
|
|||
|
case "days":
|
|||
|
o.hour = 0;
|
|||
|
case "hours":
|
|||
|
o.minute = 0;
|
|||
|
case "minutes":
|
|||
|
o.second = 0;
|
|||
|
case "seconds":
|
|||
|
o.millisecond = 0;
|
|||
|
break;
|
|||
|
}
|
|||
|
if (normalizedUnit === "weeks") {
|
|||
|
o.weekday = 1;
|
|||
|
}
|
|||
|
if (normalizedUnit === "quarters") {
|
|||
|
const q = Math.ceil(this.month / 3);
|
|||
|
o.month = (q - 1) * 3 + 1;
|
|||
|
}
|
|||
|
return this.set(o);
|
|||
|
}
|
|||
|
/**
|
|||
|
* "Set" this DateTime to the end (meaning the last millisecond) of a unit of time
|
|||
|
* @param {string} unit - The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
|
|||
|
* @example DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00'
|
|||
|
* @example DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00'
|
|||
|
* @example DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays
|
|||
|
* @example DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00'
|
|||
|
* @example DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00'
|
|||
|
* @return {DateTime}
|
|||
|
*/
|
|||
|
endOf(unit) {
|
|||
|
return this.isValid ? this.plus({ [unit]: 1 }).startOf(unit).minus(1) : this;
|
|||
|
}
|
|||
|
// OUTPUT
|
|||
|
/**
|
|||
|
* Returns a string representation of this DateTime formatted according to the specified format string.
|
|||
|
* **You may not want this.** See {@link DateTime#toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens).
|
|||
|
* Defaults to en-US if no locale has been specified, regardless of the system's locale.
|
|||
|
* @param {string} fmt - the format string
|
|||
|
* @param {Object} opts - opts to override the configuration options on this DateTime
|
|||
|
* @example DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22'
|
|||
|
* @example DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22'
|
|||
|
* @example DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22'
|
|||
|
* @example DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toFormat(fmt, opts = {}) {
|
|||
|
return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE`.
|
|||
|
* The exact behavior of this method is browser-specific, but in general it will return an appropriate representation
|
|||
|
* of the DateTime in the assigned locale.
|
|||
|
* Defaults to the system's locale if no locale has been specified
|
|||
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
|||
|
* @param formatOpts {Object} - Intl.DateTimeFormat constructor options and configuration options
|
|||
|
* @param {Object} opts - opts to override the configuration options on this DateTime
|
|||
|
* @example DateTime.now().toLocaleString(); //=> 4/20/2017
|
|||
|
* @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
|
|||
|
* @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
|
|||
|
* @example DateTime.now().toLocaleString(DateTime.DATE_FULL, { locale: 'fr' }); //=> '28 août 2022'
|
|||
|
* @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
|
|||
|
* @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
|
|||
|
* @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
|
|||
|
* @example DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM'
|
|||
|
* @example DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toLocaleString(formatOpts = DATE_SHORT, opts = {}) {
|
|||
|
return this.isValid ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this) : INVALID;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output.
|
|||
|
* Defaults to the system's locale if no locale has been specified
|
|||
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts
|
|||
|
* @param opts {Object} - Intl.DateTimeFormat constructor options, same as `toLocaleString`.
|
|||
|
* @example DateTime.now().toLocaleParts(); //=> [
|
|||
|
* //=> { type: 'day', value: '25' },
|
|||
|
* //=> { type: 'literal', value: '/' },
|
|||
|
* //=> { type: 'month', value: '05' },
|
|||
|
* //=> { type: 'literal', value: '/' },
|
|||
|
* //=> { type: 'year', value: '1982' }
|
|||
|
* //=> ]
|
|||
|
*/
|
|||
|
toLocaleParts(opts = {}) {
|
|||
|
return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTimeParts(this) : [];
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of this DateTime
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
|
|||
|
* @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
|
|||
|
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
|
|||
|
* @param {boolean} [opts.extendedZone=false] - add the time zone format extension
|
|||
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|||
|
* @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
|
|||
|
* @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
|
|||
|
* @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
|
|||
|
* @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISO({
|
|||
|
format = "extended",
|
|||
|
suppressSeconds = false,
|
|||
|
suppressMilliseconds = false,
|
|||
|
includeOffset = true,
|
|||
|
extendedZone = false
|
|||
|
} = {}) {
|
|||
|
if (!this.isValid) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
const ext = format === "extended";
|
|||
|
let c = toISODate(this, ext);
|
|||
|
c += "T";
|
|||
|
c += toISOTime(this, ext, suppressSeconds, suppressMilliseconds, includeOffset, extendedZone);
|
|||
|
return c;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of this DateTime's date component
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|||
|
* @example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'
|
|||
|
* @example DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISODate({ format = "extended" } = {}) {
|
|||
|
if (!this.isValid) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
return toISODate(this, format === "extended");
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of this DateTime's week date
|
|||
|
* @example DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISOWeekDate() {
|
|||
|
return toTechFormat(this, "kkkk-'W'WW-c");
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601-compliant string representation of this DateTime's time component
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
|
|||
|
* @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
|
|||
|
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
|
|||
|
* @param {boolean} [opts.extendedZone=true] - add the time zone format extension
|
|||
|
* @param {boolean} [opts.includePrefix=false] - include the `T` prefix
|
|||
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|||
|
* @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z'
|
|||
|
* @example DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z'
|
|||
|
* @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z'
|
|||
|
* @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toISOTime({
|
|||
|
suppressMilliseconds = false,
|
|||
|
suppressSeconds = false,
|
|||
|
includeOffset = true,
|
|||
|
includePrefix = false,
|
|||
|
extendedZone = false,
|
|||
|
format = "extended"
|
|||
|
} = {}) {
|
|||
|
if (!this.isValid) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
let c = includePrefix ? "T" : "";
|
|||
|
return c + toISOTime(
|
|||
|
this,
|
|||
|
format === "extended",
|
|||
|
suppressSeconds,
|
|||
|
suppressMilliseconds,
|
|||
|
includeOffset,
|
|||
|
extendedZone
|
|||
|
);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an RFC 2822-compatible string representation of this DateTime
|
|||
|
* @example DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000'
|
|||
|
* @example DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toRFC2822() {
|
|||
|
return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", false);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this DateTime appropriate for use in HTTP headers. The output is always expressed in GMT.
|
|||
|
* Specifically, the string conforms to RFC 1123.
|
|||
|
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
|
|||
|
* @example DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT'
|
|||
|
* @example DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toHTTP() {
|
|||
|
return toTechFormat(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'");
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this DateTime appropriate for use in SQL Date
|
|||
|
* @example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toSQLDate() {
|
|||
|
if (!this.isValid) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
return toISODate(this, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this DateTime appropriate for use in SQL Time
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
|
|||
|
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
|
|||
|
* @param {boolean} [opts.includeOffsetSpace=true] - include the space between the time and the offset, such as '05:15:16.345 -04:00'
|
|||
|
* @example DateTime.utc().toSQL() //=> '05:15:16.345'
|
|||
|
* @example DateTime.now().toSQL() //=> '05:15:16.345 -04:00'
|
|||
|
* @example DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345'
|
|||
|
* @example DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toSQLTime({ includeOffset = true, includeZone = false, includeOffsetSpace = true } = {}) {
|
|||
|
let fmt = "HH:mm:ss.SSS";
|
|||
|
if (includeZone || includeOffset) {
|
|||
|
if (includeOffsetSpace) {
|
|||
|
fmt += " ";
|
|||
|
}
|
|||
|
if (includeZone) {
|
|||
|
fmt += "z";
|
|||
|
} else if (includeOffset) {
|
|||
|
fmt += "ZZ";
|
|||
|
}
|
|||
|
}
|
|||
|
return toTechFormat(this, fmt, true);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this DateTime appropriate for use in SQL DateTime
|
|||
|
* @param {Object} opts - options
|
|||
|
* @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
|
|||
|
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
|
|||
|
* @param {boolean} [opts.includeOffsetSpace=true] - include the space between the time and the offset, such as '05:15:16.345 -04:00'
|
|||
|
* @example DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z'
|
|||
|
* @example DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00'
|
|||
|
* @example DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000'
|
|||
|
* @example DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York'
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toSQL(opts = {}) {
|
|||
|
if (!this.isValid) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
return `${this.toSQLDate()} ${this.toSQLTime(opts)}`;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this DateTime appropriate for debugging
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toString() {
|
|||
|
return this.isValid ? this.toISO() : INVALID;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime#toMillis}
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
valueOf() {
|
|||
|
return this.toMillis();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the epoch milliseconds of this DateTime.
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
toMillis() {
|
|||
|
return this.isValid ? this.ts : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the epoch seconds of this DateTime.
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
toSeconds() {
|
|||
|
return this.isValid ? this.ts / 1e3 : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns the epoch seconds (as a whole number) of this DateTime.
|
|||
|
* @return {number}
|
|||
|
*/
|
|||
|
toUnixInteger() {
|
|||
|
return this.isValid ? Math.floor(this.ts / 1e3) : NaN;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns an ISO 8601 representation of this DateTime appropriate for use in JSON.
|
|||
|
* @return {string}
|
|||
|
*/
|
|||
|
toJSON() {
|
|||
|
return this.toISO();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a BSON serializable equivalent to this DateTime.
|
|||
|
* @return {Date}
|
|||
|
*/
|
|||
|
toBSON() {
|
|||
|
return this.toJSDate();
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a JavaScript object with this DateTime's year, month, day, and so on.
|
|||
|
* @param opts - options for generating the object
|
|||
|
* @param {boolean} [opts.includeConfig=false] - include configuration attributes in the output
|
|||
|
* @example DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 }
|
|||
|
* @return {Object}
|
|||
|
*/
|
|||
|
toObject(opts = {}) {
|
|||
|
if (!this.isValid)
|
|||
|
return {};
|
|||
|
const base = { ...this.c };
|
|||
|
if (opts.includeConfig) {
|
|||
|
base.outputCalendar = this.outputCalendar;
|
|||
|
base.numberingSystem = this.loc.numberingSystem;
|
|||
|
base.locale = this.loc.locale;
|
|||
|
}
|
|||
|
return base;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a JavaScript Date equivalent to this DateTime.
|
|||
|
* @return {Date}
|
|||
|
*/
|
|||
|
toJSDate() {
|
|||
|
return new Date(this.isValid ? this.ts : NaN);
|
|||
|
}
|
|||
|
// COMPARE
|
|||
|
/**
|
|||
|
* Return the difference between two DateTimes as a Duration.
|
|||
|
* @param {DateTime} otherDateTime - the DateTime to compare this one to
|
|||
|
* @param {string|string[]} [unit=['milliseconds']] - the unit or array of units (such as 'hours' or 'days') to include in the duration.
|
|||
|
* @param {Object} opts - options that affect the creation of the Duration
|
|||
|
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|||
|
* @example
|
|||
|
* var i1 = DateTime.fromISO('1982-05-25T09:45'),
|
|||
|
* i2 = DateTime.fromISO('1983-10-14T10:30');
|
|||
|
* i2.diff(i1).toObject() //=> { milliseconds: 43807500000 }
|
|||
|
* i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 }
|
|||
|
* i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 }
|
|||
|
* i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 }
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
diff(otherDateTime, unit = "milliseconds", opts = {}) {
|
|||
|
if (!this.isValid || !otherDateTime.isValid) {
|
|||
|
return Duration.invalid("created by diffing an invalid DateTime");
|
|||
|
}
|
|||
|
const durOpts = { locale: this.locale, numberingSystem: this.numberingSystem, ...opts };
|
|||
|
const units = maybeArray(unit).map(Duration.normalizeUnit), otherIsLater = otherDateTime.valueOf() > this.valueOf(), earlier = otherIsLater ? this : otherDateTime, later = otherIsLater ? otherDateTime : this, diffed = diff(earlier, later, units, durOpts);
|
|||
|
return otherIsLater ? diffed.negate() : diffed;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return the difference between this DateTime and right now.
|
|||
|
* See {@link DateTime#diff}
|
|||
|
* @param {string|string[]} [unit=['milliseconds']] - the unit or units units (such as 'hours' or 'days') to include in the duration
|
|||
|
* @param {Object} opts - options that affect the creation of the Duration
|
|||
|
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|||
|
* @return {Duration}
|
|||
|
*/
|
|||
|
diffNow(unit = "milliseconds", opts = {}) {
|
|||
|
return this.diff(DateTime.now(), unit, opts);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return an Interval spanning between this DateTime and another DateTime
|
|||
|
* @param {DateTime} otherDateTime - the other end point of the Interval
|
|||
|
* @return {Interval}
|
|||
|
*/
|
|||
|
until(otherDateTime) {
|
|||
|
return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this;
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return whether this DateTime is in the same unit of time as another DateTime.
|
|||
|
* Higher-order units must also be identical for this function to return `true`.
|
|||
|
* Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link DateTime#setZone} to convert one of the dates if needed.
|
|||
|
* @param {DateTime} otherDateTime - the other DateTime
|
|||
|
* @param {string} unit - the unit of time to check sameness on
|
|||
|
* @example DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
hasSame(otherDateTime, unit) {
|
|||
|
if (!this.isValid)
|
|||
|
return false;
|
|||
|
const inputMs = otherDateTime.valueOf();
|
|||
|
const adjustedToZone = this.setZone(otherDateTime.zone, { keepLocalTime: true });
|
|||
|
return adjustedToZone.startOf(unit) <= inputMs && inputMs <= adjustedToZone.endOf(unit);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Equality check
|
|||
|
* Two DateTimes are equal if and only if they represent the same millisecond, have the same zone and location, and are both valid.
|
|||
|
* To compare just the millisecond values, use `+dt1 === +dt2`.
|
|||
|
* @param {DateTime} other - the other DateTime
|
|||
|
* @return {boolean}
|
|||
|
*/
|
|||
|
equals(other) {
|
|||
|
return this.isValid && other.isValid && this.valueOf() === other.valueOf() && this.zone.equals(other.zone) && this.loc.equals(other.loc);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your
|
|||
|
* platform supports Intl.RelativeTimeFormat. Rounds down by default.
|
|||
|
* @param {Object} options - options that affect the output
|
|||
|
* @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
|
|||
|
* @param {string} [options.style="long"] - the style of units, must be "long", "short", or "narrow"
|
|||
|
* @param {string|string[]} options.unit - use a specific unit or array of units; if omitted, or an array, the method will pick the best unit. Use an array or one of "years", "quarters", "months", "weeks", "days", "hours", "minutes", or "seconds"
|
|||
|
* @param {boolean} [options.round=true] - whether to round the numbers in the output.
|
|||
|
* @param {number} [options.padding=0] - padding in milliseconds. This allows you to round up the result if it fits inside the threshold. Don't use in combination with {round: false} because the decimal output will include the padding.
|
|||
|
* @param {string} options.locale - override the locale of this DateTime
|
|||
|
* @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
|
|||
|
* @example DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day"
|
|||
|
* @example DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día"
|
|||
|
* @example DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures"
|
|||
|
* @example DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago"
|
|||
|
* @example DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago"
|
|||
|
* @example DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago"
|
|||
|
*/
|
|||
|
toRelative(options = {}) {
|
|||
|
if (!this.isValid)
|
|||
|
return null;
|
|||
|
const base = options.base || DateTime.fromObject({}, { zone: this.zone }), padding = options.padding ? this < base ? -options.padding : options.padding : 0;
|
|||
|
let units = ["years", "months", "days", "hours", "minutes", "seconds"];
|
|||
|
let unit = options.unit;
|
|||
|
if (Array.isArray(options.unit)) {
|
|||
|
units = options.unit;
|
|||
|
unit = void 0;
|
|||
|
}
|
|||
|
return diffRelative(base, this.plus(padding), {
|
|||
|
...options,
|
|||
|
numeric: "always",
|
|||
|
units,
|
|||
|
unit
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Returns a string representation of this date relative to today, such as "yesterday" or "next month".
|
|||
|
* Only internationalizes on platforms that supports Intl.RelativeTimeFormat.
|
|||
|
* @param {Object} options - options that affect the output
|
|||
|
* @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
|
|||
|
* @param {string} options.locale - override the locale of this DateTime
|
|||
|
* @param {string} options.unit - use a specific unit; if omitted, the method will pick the unit. Use one of "years", "quarters", "months", "weeks", or "days"
|
|||
|
* @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
|
|||
|
* @example DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow"
|
|||
|
* @example DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana"
|
|||
|
* @example DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain"
|
|||
|
* @example DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"
|
|||
|
*/
|
|||
|
toRelativeCalendar(options = {}) {
|
|||
|
if (!this.isValid)
|
|||
|
return null;
|
|||
|
return diffRelative(options.base || DateTime.fromObject({}, { zone: this.zone }), this, {
|
|||
|
...options,
|
|||
|
numeric: "auto",
|
|||
|
units: ["years", "months", "days"],
|
|||
|
calendary: true
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return the min of several date times
|
|||
|
* @param {...DateTime} dateTimes - the DateTimes from which to choose the minimum
|
|||
|
* @return {DateTime} the min DateTime, or undefined if called with no argument
|
|||
|
*/
|
|||
|
static min(...dateTimes) {
|
|||
|
if (!dateTimes.every(DateTime.isDateTime)) {
|
|||
|
throw new InvalidArgumentError("min requires all arguments be DateTimes");
|
|||
|
}
|
|||
|
return bestBy(dateTimes, (i) => i.valueOf(), Math.min);
|
|||
|
}
|
|||
|
/**
|
|||
|
* Return the max of several date times
|
|||
|
* @param {...DateTime} dateTimes - the DateTimes from which to choose the maximum
|
|||
|
* @return {DateTime} the max DateTime, or undefined if called with no argument
|
|||
|
*/
|
|||
|
static max(...dateTimes) {
|
|||
|
if (!dateTimes.every(DateTime.isDateTime)) {
|
|||
|
throw new InvalidArgumentError("max requires all arguments be DateTimes");
|
|||
|
}
|
|||
|
return bestBy(dateTimes, (i) => i.valueOf(), Math.max);
|
|||
|
}
|
|||
|
// MISC
|
|||
|
/**
|
|||
|
* Explain how a string would be parsed by fromFormat()
|
|||
|
* @param {string} text - the string to parse
|
|||
|
* @param {string} fmt - the format the string is expected to be in (see description)
|
|||
|
* @param {Object} options - options taken by fromFormat()
|
|||
|
* @return {Object}
|
|||
|
*/
|
|||
|
static fromFormatExplain(text2, fmt, options = {}) {
|
|||
|
const { locale = null, numberingSystem = null } = options, localeToUse = Locale.fromOpts({
|
|||
|
locale,
|
|||
|
numberingSystem,
|
|||
|
defaultToEN: true
|
|||
|
});
|
|||
|
return explainFromTokens(localeToUse, text2, fmt);
|
|||
|
}
|
|||
|
/**
|
|||
|
* @deprecated use fromFormatExplain instead
|
|||
|
*/
|
|||
|
static fromStringExplain(text2, fmt, options = {}) {
|
|||
|
return DateTime.fromFormatExplain(text2, fmt, options);
|
|||
|
}
|
|||
|
// FORMAT PRESETS
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 10/14/1983
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATE_SHORT() {
|
|||
|
return DATE_SHORT;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'Oct 14, 1983'
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATE_MED() {
|
|||
|
return DATE_MED;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'Fri, Oct 14, 1983'
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATE_MED_WITH_WEEKDAY() {
|
|||
|
return DATE_MED_WITH_WEEKDAY;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'October 14, 1983'
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATE_FULL() {
|
|||
|
return DATE_FULL;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'Tuesday, October 14, 1983'
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATE_HUGE() {
|
|||
|
return DATE_HUGE;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get TIME_SIMPLE() {
|
|||
|
return TIME_SIMPLE;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get TIME_WITH_SECONDS() {
|
|||
|
return TIME_WITH_SECONDS;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get TIME_WITH_SHORT_OFFSET() {
|
|||
|
return TIME_WITH_SHORT_OFFSET;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get TIME_WITH_LONG_OFFSET() {
|
|||
|
return TIME_WITH_LONG_OFFSET;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '09:30', always 24-hour.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get TIME_24_SIMPLE() {
|
|||
|
return TIME_24_SIMPLE;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '09:30:23', always 24-hour.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get TIME_24_WITH_SECONDS() {
|
|||
|
return TIME_24_WITH_SECONDS;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '09:30:23 EDT', always 24-hour.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get TIME_24_WITH_SHORT_OFFSET() {
|
|||
|
return TIME_24_WITH_SHORT_OFFSET;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get TIME_24_WITH_LONG_OFFSET() {
|
|||
|
return TIME_24_WITH_LONG_OFFSET;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_SHORT() {
|
|||
|
return DATETIME_SHORT;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_SHORT_WITH_SECONDS() {
|
|||
|
return DATETIME_SHORT_WITH_SECONDS;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_MED() {
|
|||
|
return DATETIME_MED;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_MED_WITH_SECONDS() {
|
|||
|
return DATETIME_MED_WITH_SECONDS;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_MED_WITH_WEEKDAY() {
|
|||
|
return DATETIME_MED_WITH_WEEKDAY;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_FULL() {
|
|||
|
return DATETIME_FULL;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_FULL_WITH_SECONDS() {
|
|||
|
return DATETIME_FULL_WITH_SECONDS;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_HUGE() {
|
|||
|
return DATETIME_HUGE;
|
|||
|
}
|
|||
|
/**
|
|||
|
* {@link DateTime#toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
|
|||
|
* @type {Object}
|
|||
|
*/
|
|||
|
static get DATETIME_HUGE_WITH_SECONDS() {
|
|||
|
return DATETIME_HUGE_WITH_SECONDS;
|
|||
|
}
|
|||
|
};
|
|||
|
function friendlyDateTime(dateTimeish) {
|
|||
|
if (DateTime.isDateTime(dateTimeish)) {
|
|||
|
return dateTimeish;
|
|||
|
} else if (dateTimeish && dateTimeish.valueOf && isNumber(dateTimeish.valueOf())) {
|
|||
|
return DateTime.fromJSDate(dateTimeish);
|
|||
|
} else if (dateTimeish && typeof dateTimeish === "object") {
|
|||
|
return DateTime.fromObject(dateTimeish);
|
|||
|
} else {
|
|||
|
throw new InvalidArgumentError(
|
|||
|
`Unknown datetime argument: ${dateTimeish}, of type ${typeof dateTimeish}`
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
var DEFAULT_QUERY_SETTINGS = {
|
|||
|
renderNullAs: "\\-",
|
|||
|
taskCompletionTracking: false,
|
|||
|
taskCompletionUseEmojiShorthand: false,
|
|||
|
taskCompletionText: "completion",
|
|||
|
taskCompletionDateFormat: "yyyy-MM-dd",
|
|||
|
recursiveSubTaskCompletion: false,
|
|||
|
warnOnEmptyResult: true,
|
|||
|
refreshEnabled: true,
|
|||
|
refreshInterval: 2500,
|
|||
|
defaultDateFormat: "MMMM dd, yyyy",
|
|||
|
defaultDateTimeFormat: "h:mm a - MMMM dd, yyyy",
|
|||
|
maxRecursiveRenderDepth: 4,
|
|||
|
tableIdColumnName: "File",
|
|||
|
tableGroupColumnName: "Group",
|
|||
|
showResultCount: true
|
|||
|
};
|
|||
|
var DEFAULT_EXPORT_SETTINGS = {
|
|||
|
allowHtml: true
|
|||
|
};
|
|||
|
({
|
|||
|
...DEFAULT_QUERY_SETTINGS,
|
|||
|
...DEFAULT_EXPORT_SETTINGS,
|
|||
|
...{
|
|||
|
inlineQueryPrefix: "=",
|
|||
|
inlineJsQueryPrefix: "$=",
|
|||
|
inlineQueriesInCodeblocks: true,
|
|||
|
enableInlineDataview: true,
|
|||
|
enableDataviewJs: false,
|
|||
|
enableInlineDataviewJs: false,
|
|||
|
prettyRenderInlineFields: true,
|
|||
|
dataviewJsKeyword: "dataviewjs"
|
|||
|
}
|
|||
|
});
|
|||
|
var Success = class {
|
|||
|
constructor(value) {
|
|||
|
this.value = value;
|
|||
|
this.successful = true;
|
|||
|
}
|
|||
|
map(f) {
|
|||
|
return new Success(f(this.value));
|
|||
|
}
|
|||
|
flatMap(f) {
|
|||
|
return f(this.value);
|
|||
|
}
|
|||
|
mapErr(f) {
|
|||
|
return this;
|
|||
|
}
|
|||
|
bimap(succ, _fail) {
|
|||
|
return this.map(succ);
|
|||
|
}
|
|||
|
orElse(_value) {
|
|||
|
return this.value;
|
|||
|
}
|
|||
|
cast() {
|
|||
|
return this;
|
|||
|
}
|
|||
|
orElseThrow(_message) {
|
|||
|
return this.value;
|
|||
|
}
|
|||
|
};
|
|||
|
var Failure = class {
|
|||
|
constructor(error) {
|
|||
|
this.error = error;
|
|||
|
this.successful = false;
|
|||
|
}
|
|||
|
map(_f) {
|
|||
|
return this;
|
|||
|
}
|
|||
|
flatMap(_f) {
|
|||
|
return this;
|
|||
|
}
|
|||
|
mapErr(f) {
|
|||
|
return new Failure(f(this.error));
|
|||
|
}
|
|||
|
bimap(_succ, fail) {
|
|||
|
return this.mapErr(fail);
|
|||
|
}
|
|||
|
orElse(value) {
|
|||
|
return value;
|
|||
|
}
|
|||
|
cast() {
|
|||
|
return this;
|
|||
|
}
|
|||
|
orElseThrow(message) {
|
|||
|
if (message)
|
|||
|
throw new Error(message(this.error));
|
|||
|
else
|
|||
|
throw new Error("" + this.error);
|
|||
|
}
|
|||
|
};
|
|||
|
var Result;
|
|||
|
(function(Result2) {
|
|||
|
function success(value) {
|
|||
|
return new Success(value);
|
|||
|
}
|
|||
|
Result2.success = success;
|
|||
|
function failure(error) {
|
|||
|
return new Failure(error);
|
|||
|
}
|
|||
|
Result2.failure = failure;
|
|||
|
function flatMap2(first, second, f) {
|
|||
|
if (first.successful) {
|
|||
|
if (second.successful)
|
|||
|
return f(first.value, second.value);
|
|||
|
else
|
|||
|
return failure(second.error);
|
|||
|
} else {
|
|||
|
return failure(first.error);
|
|||
|
}
|
|||
|
}
|
|||
|
Result2.flatMap2 = flatMap2;
|
|||
|
function map2(first, second, f) {
|
|||
|
return flatMap2(first, second, (a, b) => success(f(a, b)));
|
|||
|
}
|
|||
|
Result2.map2 = map2;
|
|||
|
})(Result || (Result = {}));
|
|||
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|||
|
var parsimmon_umd_min = { exports: {} };
|
|||
|
(function(module3, exports2) {
|
|||
|
!function(n2, t) {
|
|||
|
module3.exports = t();
|
|||
|
}("undefined" != typeof self ? self : commonjsGlobal, function() {
|
|||
|
return function(n2) {
|
|||
|
var t = {};
|
|||
|
function r(e) {
|
|||
|
if (t[e])
|
|||
|
return t[e].exports;
|
|||
|
var u = t[e] = { i: e, l: false, exports: {} };
|
|||
|
return n2[e].call(u.exports, u, u.exports, r), u.l = true, u.exports;
|
|||
|
}
|
|||
|
return r.m = n2, r.c = t, r.d = function(n3, t2, e) {
|
|||
|
r.o(n3, t2) || Object.defineProperty(n3, t2, { configurable: false, enumerable: true, get: e });
|
|||
|
}, r.r = function(n3) {
|
|||
|
Object.defineProperty(n3, "__esModule", { value: true });
|
|||
|
}, r.n = function(n3) {
|
|||
|
var t2 = n3 && n3.__esModule ? function() {
|
|||
|
return n3.default;
|
|||
|
} : function() {
|
|||
|
return n3;
|
|||
|
};
|
|||
|
return r.d(t2, "a", t2), t2;
|
|||
|
}, r.o = function(n3, t2) {
|
|||
|
return Object.prototype.hasOwnProperty.call(n3, t2);
|
|||
|
}, r.p = "", r(r.s = 0);
|
|||
|
}([function(n2, t, r) {
|
|||
|
function e(n3) {
|
|||
|
if (!(this instanceof e))
|
|||
|
return new e(n3);
|
|||
|
this._ = n3;
|
|||
|
}
|
|||
|
var u = e.prototype;
|
|||
|
function o(n3, t2) {
|
|||
|
for (var r2 = 0; r2 < n3; r2++)
|
|||
|
t2(r2);
|
|||
|
}
|
|||
|
function i(n3, t2, r2) {
|
|||
|
return function(n4, t3) {
|
|||
|
o(t3.length, function(r3) {
|
|||
|
n4(t3[r3], r3, t3);
|
|||
|
});
|
|||
|
}(function(r3, e2, u2) {
|
|||
|
t2 = n3(t2, r3, e2, u2);
|
|||
|
}, r2), t2;
|
|||
|
}
|
|||
|
function a(n3, t2) {
|
|||
|
return i(function(t3, r2, e2, u2) {
|
|||
|
return t3.concat([n3(r2, e2, u2)]);
|
|||
|
}, [], t2);
|
|||
|
}
|
|||
|
function f(n3, t2) {
|
|||
|
var r2 = { v: 0, buf: t2 };
|
|||
|
return o(n3, function() {
|
|||
|
var n4;
|
|||
|
r2 = { v: r2.v << 1 | (n4 = r2.buf, n4[0] >> 7), buf: function(n5) {
|
|||
|
var t3 = i(function(n6, t4, r3, e2) {
|
|||
|
return n6.concat(r3 === e2.length - 1 ? Buffer.from([t4, 0]).readUInt16BE(0) : e2.readUInt16BE(r3));
|
|||
|
}, [], n5);
|
|||
|
return Buffer.from(a(function(n6) {
|
|||
|
return (n6 << 1 & 65535) >> 8;
|
|||
|
}, t3));
|
|||
|
}(r2.buf) };
|
|||
|
}), r2;
|
|||
|
}
|
|||
|
function c() {
|
|||
|
return "undefined" != typeof Buffer;
|
|||
|
}
|
|||
|
function s2() {
|
|||
|
if (!c())
|
|||
|
throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.");
|
|||
|
}
|
|||
|
function l2(n3) {
|
|||
|
s2();
|
|||
|
var t2 = i(function(n4, t3) {
|
|||
|
return n4 + t3;
|
|||
|
}, 0, n3);
|
|||
|
if (t2 % 8 != 0)
|
|||
|
throw new Error("The bits [" + n3.join(", ") + "] add up to " + t2 + " which is not an even number of bytes; the total should be divisible by 8");
|
|||
|
var r2, u2 = t2 / 8, o2 = (r2 = function(n4) {
|
|||
|
return n4 > 48;
|
|||
|
}, i(function(n4, t3) {
|
|||
|
return n4 || (r2(t3) ? t3 : n4);
|
|||
|
}, null, n3));
|
|||
|
if (o2)
|
|||
|
throw new Error(o2 + " bit range requested exceeds 48 bit (6 byte) Number max.");
|
|||
|
return new e(function(t3, r3) {
|
|||
|
var e2 = u2 + r3;
|
|||
|
return e2 > t3.length ? x(r3, u2.toString() + " bytes") : b(e2, i(function(n4, t4) {
|
|||
|
var r4 = f(t4, n4.buf);
|
|||
|
return { coll: n4.coll.concat(r4.v), buf: r4.buf };
|
|||
|
}, { coll: [], buf: t3.slice(r3, e2) }, n3).coll);
|
|||
|
});
|
|||
|
}
|
|||
|
function h(n3, t2) {
|
|||
|
return new e(function(r2, e2) {
|
|||
|
return s2(), e2 + t2 > r2.length ? x(e2, t2 + " bytes for " + n3) : b(e2 + t2, r2.slice(e2, e2 + t2));
|
|||
|
});
|
|||
|
}
|
|||
|
function p(n3, t2) {
|
|||
|
if ("number" != typeof (r2 = t2) || Math.floor(r2) !== r2 || t2 < 0 || t2 > 6)
|
|||
|
throw new Error(n3 + " requires integer length in range [0, 6].");
|
|||
|
var r2;
|
|||
|
}
|
|||
|
function d(n3) {
|
|||
|
return p("uintBE", n3), h("uintBE(" + n3 + ")", n3).map(function(t2) {
|
|||
|
return t2.readUIntBE(0, n3);
|
|||
|
});
|
|||
|
}
|
|||
|
function v(n3) {
|
|||
|
return p("uintLE", n3), h("uintLE(" + n3 + ")", n3).map(function(t2) {
|
|||
|
return t2.readUIntLE(0, n3);
|
|||
|
});
|
|||
|
}
|
|||
|
function g(n3) {
|
|||
|
return p("intBE", n3), h("intBE(" + n3 + ")", n3).map(function(t2) {
|
|||
|
return t2.readIntBE(0, n3);
|
|||
|
});
|
|||
|
}
|
|||
|
function m(n3) {
|
|||
|
return p("intLE", n3), h("intLE(" + n3 + ")", n3).map(function(t2) {
|
|||
|
return t2.readIntLE(0, n3);
|
|||
|
});
|
|||
|
}
|
|||
|
function y(n3) {
|
|||
|
return n3 instanceof e;
|
|||
|
}
|
|||
|
function E(n3) {
|
|||
|
return "[object Array]" === {}.toString.call(n3);
|
|||
|
}
|
|||
|
function w(n3) {
|
|||
|
return c() && Buffer.isBuffer(n3);
|
|||
|
}
|
|||
|
function b(n3, t2) {
|
|||
|
return { status: true, index: n3, value: t2, furthest: -1, expected: [] };
|
|||
|
}
|
|||
|
function x(n3, t2) {
|
|||
|
return E(t2) || (t2 = [t2]), { status: false, index: -1, value: null, furthest: n3, expected: t2 };
|
|||
|
}
|
|||
|
function B(n3, t2) {
|
|||
|
if (!t2)
|
|||
|
return n3;
|
|||
|
if (n3.furthest > t2.furthest)
|
|||
|
return n3;
|
|||
|
var r2 = n3.furthest === t2.furthest ? function(n4, t3) {
|
|||
|
if (function() {
|
|||
|
if (void 0 !== e._supportsSet)
|
|||
|
return e._supportsSet;
|
|||
|
var n5 = "undefined" != typeof Set;
|
|||
|
return e._supportsSet = n5, n5;
|
|||
|
}() && Array.from) {
|
|||
|
for (var r3 = new Set(n4), u2 = 0; u2 < t3.length; u2++)
|
|||
|
r3.add(t3[u2]);
|
|||
|
var o2 = Array.from(r3);
|
|||
|
return o2.sort(), o2;
|
|||
|
}
|
|||
|
for (var i2 = {}, a2 = 0; a2 < n4.length; a2++)
|
|||
|
i2[n4[a2]] = true;
|
|||
|
for (var f2 = 0; f2 < t3.length; f2++)
|
|||
|
i2[t3[f2]] = true;
|
|||
|
var c2 = [];
|
|||
|
for (var s3 in i2)
|
|||
|
({}).hasOwnProperty.call(i2, s3) && c2.push(s3);
|
|||
|
return c2.sort(), c2;
|
|||
|
}(n3.expected, t2.expected) : t2.expected;
|
|||
|
return { status: n3.status, index: n3.index, value: n3.value, furthest: t2.furthest, expected: r2 };
|
|||
|
}
|
|||
|
var j = {};
|
|||
|
function S(n3, t2) {
|
|||
|
if (w(n3))
|
|||
|
return { offset: t2, line: -1, column: -1 };
|
|||
|
n3 in j || (j[n3] = {});
|
|||
|
for (var r2 = j[n3], e2 = 0, u2 = 0, o2 = 0, i2 = t2; i2 >= 0; ) {
|
|||
|
if (i2 in r2) {
|
|||
|
e2 = r2[i2].line, 0 === o2 && (o2 = r2[i2].lineStart);
|
|||
|
break;
|
|||
|
}
|
|||
|
("\n" === n3.charAt(i2) || "\r" === n3.charAt(i2) && "\n" !== n3.charAt(i2 + 1)) && (u2++, 0 === o2 && (o2 = i2 + 1)), i2--;
|
|||
|
}
|
|||
|
var a2 = e2 + u2, f2 = t2 - o2;
|
|||
|
return r2[t2] = { line: a2, lineStart: o2 }, { offset: t2, line: a2 + 1, column: f2 + 1 };
|
|||
|
}
|
|||
|
function _(n3) {
|
|||
|
if (!y(n3))
|
|||
|
throw new Error("not a parser: " + n3);
|
|||
|
}
|
|||
|
function L(n3, t2) {
|
|||
|
return "string" == typeof n3 ? n3.charAt(t2) : n3[t2];
|
|||
|
}
|
|||
|
function O(n3) {
|
|||
|
if ("number" != typeof n3)
|
|||
|
throw new Error("not a number: " + n3);
|
|||
|
}
|
|||
|
function k(n3) {
|
|||
|
if ("function" != typeof n3)
|
|||
|
throw new Error("not a function: " + n3);
|
|||
|
}
|
|||
|
function P(n3) {
|
|||
|
if ("string" != typeof n3)
|
|||
|
throw new Error("not a string: " + n3);
|
|||
|
}
|
|||
|
var q = 2, A = 3, I = 8, F = 5 * I, M = 4 * I, z = " ";
|
|||
|
function R(n3, t2) {
|
|||
|
return new Array(t2 + 1).join(n3);
|
|||
|
}
|
|||
|
function U(n3, t2, r2) {
|
|||
|
var e2 = t2 - n3.length;
|
|||
|
return e2 <= 0 ? n3 : R(r2, e2) + n3;
|
|||
|
}
|
|||
|
function W(n3, t2, r2, e2) {
|
|||
|
return { from: n3 - t2 > 0 ? n3 - t2 : 0, to: n3 + r2 > e2 ? e2 : n3 + r2 };
|
|||
|
}
|
|||
|
function D(n3, t2) {
|
|||
|
var r2, e2, u2, o2, f2, c2 = t2.index, s3 = c2.offset, l3 = 1;
|
|||
|
if (s3 === n3.length)
|
|||
|
return "Got the end of the input";
|
|||
|
if (w(n3)) {
|
|||
|
var h2 = s3 - s3 % I, p2 = s3 - h2, d2 = W(h2, F, M + I, n3.length), v2 = a(function(n4) {
|
|||
|
return a(function(n5) {
|
|||
|
return U(n5.toString(16), 2, "0");
|
|||
|
}, n4);
|
|||
|
}, function(n4, t3) {
|
|||
|
var r3 = n4.length, e3 = [], u3 = 0;
|
|||
|
if (r3 <= t3)
|
|||
|
return [n4.slice()];
|
|||
|
for (var o3 = 0; o3 < r3; o3++)
|
|||
|
e3[u3] || e3.push([]), e3[u3].push(n4[o3]), (o3 + 1) % t3 == 0 && u3++;
|
|||
|
return e3;
|
|||
|
}(n3.slice(d2.from, d2.to).toJSON().data, I));
|
|||
|
o2 = function(n4) {
|
|||
|
return 0 === n4.from && 1 === n4.to ? { from: n4.from, to: n4.to } : { from: n4.from / I, to: Math.floor(n4.to / I) };
|
|||
|
}(d2), e2 = h2 / I, r2 = 3 * p2, p2 >= 4 && (r2 += 1), l3 = 2, u2 = a(function(n4) {
|
|||
|
return n4.length <= 4 ? n4.join(" ") : n4.slice(0, 4).join(" ") + " " + n4.slice(4).join(" ");
|
|||
|
}, v2), (f2 = (8 * (o2.to > 0 ? o2.to - 1 : o2.to)).toString(16).length) < 2 && (f2 = 2);
|
|||
|
} else {
|
|||
|
var g2 = n3.split(/\r\n|[\n\r\u2028\u2029]/);
|
|||
|
r2 = c2.column - 1, e2 = c2.line - 1, o2 = W(e2, q, A, g2.length), u2 = g2.slice(o2.from, o2.to), f2 = o2.to.toString().length;
|
|||
|
}
|
|||
|
var m2 = e2 - o2.from;
|
|||
|
return w(n3) && (f2 = (8 * (o2.to > 0 ? o2.to - 1 : o2.to)).toString(16).length) < 2 && (f2 = 2), i(function(t3, e3, u3) {
|
|||
|
var i2, a2 = u3 === m2, c3 = a2 ? "> " : z;
|
|||
|
return i2 = w(n3) ? U((8 * (o2.from + u3)).toString(16), f2, "0") : U((o2.from + u3 + 1).toString(), f2, " "), [].concat(t3, [c3 + i2 + " | " + e3], a2 ? [z + R(" ", f2) + " | " + U("", r2, " ") + R("^", l3)] : []);
|
|||
|
}, [], u2).join("\n");
|
|||
|
}
|
|||
|
function N(n3, t2) {
|
|||
|
return ["\n", "-- PARSING FAILED " + R("-", 50), "\n\n", D(n3, t2), "\n\n", (r2 = t2.expected, 1 === r2.length ? "Expected:\n\n" + r2[0] : "Expected one of the following: \n\n" + r2.join(", ")), "\n"].join("");
|
|||
|
var r2;
|
|||
|
}
|
|||
|
function G(n3) {
|
|||
|
return void 0 !== n3.flags ? n3.flags : [n3.global ? "g" : "", n3.ignoreCase ? "i" : "", n3.multiline ? "m" : "", n3.unicode ? "u" : "", n3.sticky ? "y" : ""].join("");
|
|||
|
}
|
|||
|
function C() {
|
|||
|
for (var n3 = [].slice.call(arguments), t2 = n3.length, r2 = 0; r2 < t2; r2 += 1)
|
|||
|
_(n3[r2]);
|
|||
|
return e(function(r3, e2) {
|
|||
|
for (var u2, o2 = new Array(t2), i2 = 0; i2 < t2; i2 += 1) {
|
|||
|
if (!(u2 = B(n3[i2]._(r3, e2), u2)).status)
|
|||
|
return u2;
|
|||
|
o2[i2] = u2.value, e2 = u2.index;
|
|||
|
}
|
|||
|
return B(b(e2, o2), u2);
|
|||
|
});
|
|||
|
}
|
|||
|
function J() {
|
|||
|
var n3 = [].slice.call(arguments);
|
|||
|
if (0 === n3.length)
|
|||
|
throw new Error("seqMap needs at least one argument");
|
|||
|
var t2 = n3.pop();
|
|||
|
return k(t2), C.apply(null, n3).map(function(n4) {
|
|||
|
return t2.apply(null, n4);
|
|||
|
});
|
|||
|
}
|
|||
|
function T() {
|
|||
|
var n3 = [].slice.call(arguments), t2 = n3.length;
|
|||
|
if (0 === t2)
|
|||
|
return Y("zero alternates");
|
|||
|
for (var r2 = 0; r2 < t2; r2 += 1)
|
|||
|
_(n3[r2]);
|
|||
|
return e(function(t3, r3) {
|
|||
|
for (var e2, u2 = 0; u2 < n3.length; u2 += 1)
|
|||
|
if ((e2 = B(n3[u2]._(t3, r3), e2)).status)
|
|||
|
return e2;
|
|||
|
return e2;
|
|||
|
});
|
|||
|
}
|
|||
|
function V(n3, t2) {
|
|||
|
return H(n3, t2).or(X([]));
|
|||
|
}
|
|||
|
function H(n3, t2) {
|
|||
|
return _(n3), _(t2), J(n3, t2.then(n3).many(), function(n4, t3) {
|
|||
|
return [n4].concat(t3);
|
|||
|
});
|
|||
|
}
|
|||
|
function K(n3) {
|
|||
|
P(n3);
|
|||
|
var t2 = "'" + n3 + "'";
|
|||
|
return e(function(r2, e2) {
|
|||
|
var u2 = e2 + n3.length, o2 = r2.slice(e2, u2);
|
|||
|
return o2 === n3 ? b(u2, o2) : x(e2, t2);
|
|||
|
});
|
|||
|
}
|
|||
|
function Q(n3, t2) {
|
|||
|
!function(n4) {
|
|||
|
if (!(n4 instanceof RegExp))
|
|||
|
throw new Error("not a regexp: " + n4);
|
|||
|
for (var t3 = G(n4), r3 = 0; r3 < t3.length; r3++) {
|
|||
|
var e2 = t3.charAt(r3);
|
|||
|
if ("i" !== e2 && "m" !== e2 && "u" !== e2 && "s" !== e2)
|
|||
|
throw new Error('unsupported regexp flag "' + e2 + '": ' + n4);
|
|||
|
}
|
|||
|
}(n3), arguments.length >= 2 ? O(t2) : t2 = 0;
|
|||
|
var r2 = function(n4) {
|
|||
|
return RegExp("^(?:" + n4.source + ")", G(n4));
|
|||
|
}(n3), u2 = "" + n3;
|
|||
|
return e(function(n4, e2) {
|
|||
|
var o2 = r2.exec(n4.slice(e2));
|
|||
|
if (o2) {
|
|||
|
if (0 <= t2 && t2 <= o2.length) {
|
|||
|
var i2 = o2[0], a2 = o2[t2];
|
|||
|
return b(e2 + i2.length, a2);
|
|||
|
}
|
|||
|
return x(e2, "valid match group (0 to " + o2.length + ") in " + u2);
|
|||
|
}
|
|||
|
return x(e2, u2);
|
|||
|
});
|
|||
|
}
|
|||
|
function X(n3) {
|
|||
|
return e(function(t2, r2) {
|
|||
|
return b(r2, n3);
|
|||
|
});
|
|||
|
}
|
|||
|
function Y(n3) {
|
|||
|
return e(function(t2, r2) {
|
|||
|
return x(r2, n3);
|
|||
|
});
|
|||
|
}
|
|||
|
function Z(n3) {
|
|||
|
if (y(n3))
|
|||
|
return e(function(t2, r2) {
|
|||
|
var e2 = n3._(t2, r2);
|
|||
|
return e2.index = r2, e2.value = "", e2;
|
|||
|
});
|
|||
|
if ("string" == typeof n3)
|
|||
|
return Z(K(n3));
|
|||
|
if (n3 instanceof RegExp)
|
|||
|
return Z(Q(n3));
|
|||
|
throw new Error("not a string, regexp, or parser: " + n3);
|
|||
|
}
|
|||
|
function $(n3) {
|
|||
|
return _(n3), e(function(t2, r2) {
|
|||
|
var e2 = n3._(t2, r2), u2 = t2.slice(r2, e2.index);
|
|||
|
return e2.status ? x(r2, 'not "' + u2 + '"') : b(r2, null);
|
|||
|
});
|
|||
|
}
|
|||
|
function nn(n3) {
|
|||
|
return k(n3), e(function(t2, r2) {
|
|||
|
var e2 = L(t2, r2);
|
|||
|
return r2 < t2.length && n3(e2) ? b(r2 + 1, e2) : x(r2, "a character/byte matching " + n3);
|
|||
|
});
|
|||
|
}
|
|||
|
function tn(n3, t2) {
|
|||
|
arguments.length < 2 && (t2 = n3, n3 = void 0);
|
|||
|
var r2 = e(function(n4, e2) {
|
|||
|
return r2._ = t2()._, r2._(n4, e2);
|
|||
|
});
|
|||
|
return n3 ? r2.desc(n3) : r2;
|
|||
|
}
|
|||
|
function rn() {
|
|||
|
return Y("fantasy-land/empty");
|
|||
|
}
|
|||
|
u.parse = function(n3) {
|
|||
|
if ("string" != typeof n3 && !w(n3))
|
|||
|
throw new Error(".parse must be called with a string or Buffer as its argument");
|
|||
|
var t2, r2 = this.skip(an)._(n3, 0);
|
|||
|
return t2 = r2.status ? { status: true, value: r2.value } : { status: false, index: S(n3, r2.furthest), expected: r2.expected }, delete j[n3], t2;
|
|||
|
}, u.tryParse = function(n3) {
|
|||
|
var t2 = this.parse(n3);
|
|||
|
if (t2.status)
|
|||
|
return t2.value;
|
|||
|
var r2 = N(n3, t2), e2 = new Error(r2);
|
|||
|
throw e2.type = "ParsimmonError", e2.result = t2, e2;
|
|||
|
}, u.assert = function(n3, t2) {
|
|||
|
return this.chain(function(r2) {
|
|||
|
return n3(r2) ? X(r2) : Y(t2);
|
|||
|
});
|
|||
|
}, u.or = function(n3) {
|
|||
|
return T(this, n3);
|
|||
|
}, u.trim = function(n3) {
|
|||
|
return this.wrap(n3, n3);
|
|||
|
}, u.wrap = function(n3, t2) {
|
|||
|
return J(n3, this, t2, function(n4, t3) {
|
|||
|
return t3;
|
|||
|
});
|
|||
|
}, u.thru = function(n3) {
|
|||
|
return n3(this);
|
|||
|
}, u.then = function(n3) {
|
|||
|
return _(n3), C(this, n3).map(function(n4) {
|
|||
|
return n4[1];
|
|||
|
});
|
|||
|
}, u.many = function() {
|
|||
|
var n3 = this;
|
|||
|
return e(function(t2, r2) {
|
|||
|
for (var e2 = [], u2 = void 0; ; ) {
|
|||
|
if (!(u2 = B(n3._(t2, r2), u2)).status)
|
|||
|
return B(b(r2, e2), u2);
|
|||
|
if (r2 === u2.index)
|
|||
|
throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");
|
|||
|
r2 = u2.index, e2.push(u2.value);
|
|||
|
}
|
|||
|
});
|
|||
|
}, u.tieWith = function(n3) {
|
|||
|
return P(n3), this.map(function(t2) {
|
|||
|
if (function(n4) {
|
|||
|
if (!E(n4))
|
|||
|
throw new Error("not an array: " + n4);
|
|||
|
}(t2), t2.length) {
|
|||
|
P(t2[0]);
|
|||
|
for (var r2 = t2[0], e2 = 1; e2 < t2.length; e2++)
|
|||
|
P(t2[e2]), r2 += n3 + t2[e2];
|
|||
|
return r2;
|
|||
|
}
|
|||
|
return "";
|
|||
|
});
|
|||
|
}, u.tie = function() {
|
|||
|
return this.tieWith("");
|
|||
|
}, u.times = function(n3, t2) {
|
|||
|
var r2 = this;
|
|||
|
return arguments.length < 2 && (t2 = n3), O(n3), O(t2), e(function(e2, u2) {
|
|||
|
for (var o2 = [], i2 = void 0, a2 = void 0, f2 = 0; f2 < n3; f2 += 1) {
|
|||
|
if (a2 = B(i2 = r2._(e2, u2), a2), !i2.status)
|
|||
|
return a2;
|
|||
|
u2 = i2.index, o2.push(i2.value);
|
|||
|
}
|
|||
|
for (; f2 < t2 && (a2 = B(i2 = r2._(e2, u2), a2), i2.status); f2 += 1)
|
|||
|
u2 = i2.index, o2.push(i2.value);
|
|||
|
return B(b(u2, o2), a2);
|
|||
|
});
|
|||
|
}, u.result = function(n3) {
|
|||
|
return this.map(function() {
|
|||
|
return n3;
|
|||
|
});
|
|||
|
}, u.atMost = function(n3) {
|
|||
|
return this.times(0, n3);
|
|||
|
}, u.atLeast = function(n3) {
|
|||
|
return J(this.times(n3), this.many(), function(n4, t2) {
|
|||
|
return n4.concat(t2);
|
|||
|
});
|
|||
|
}, u.map = function(n3) {
|
|||
|
k(n3);
|
|||
|
var t2 = this;
|
|||
|
return e(function(r2, e2) {
|
|||
|
var u2 = t2._(r2, e2);
|
|||
|
return u2.status ? B(b(u2.index, n3(u2.value)), u2) : u2;
|
|||
|
});
|
|||
|
}, u.contramap = function(n3) {
|
|||
|
k(n3);
|
|||
|
var t2 = this;
|
|||
|
return e(function(r2, e2) {
|
|||
|
var u2 = t2.parse(n3(r2.slice(e2)));
|
|||
|
return u2.status ? b(e2 + r2.length, u2.value) : u2;
|
|||
|
});
|
|||
|
}, u.promap = function(n3, t2) {
|
|||
|
return k(n3), k(t2), this.contramap(n3).map(t2);
|
|||
|
}, u.skip = function(n3) {
|
|||
|
return C(this, n3).map(function(n4) {
|
|||
|
return n4[0];
|
|||
|
});
|
|||
|
}, u.mark = function() {
|
|||
|
return J(en, this, en, function(n3, t2, r2) {
|
|||
|
return { start: n3, value: t2, end: r2 };
|
|||
|
});
|
|||
|
}, u.node = function(n3) {
|
|||
|
return J(en, this, en, function(t2, r2, e2) {
|
|||
|
return { name: n3, value: r2, start: t2, end: e2 };
|
|||
|
});
|
|||
|
}, u.sepBy = function(n3) {
|
|||
|
return V(this, n3);
|
|||
|
}, u.sepBy1 = function(n3) {
|
|||
|
return H(this, n3);
|
|||
|
}, u.lookahead = function(n3) {
|
|||
|
return this.skip(Z(n3));
|
|||
|
}, u.notFollowedBy = function(n3) {
|
|||
|
return this.skip($(n3));
|
|||
|
}, u.desc = function(n3) {
|
|||
|
E(n3) || (n3 = [n3]);
|
|||
|
var t2 = this;
|
|||
|
return e(function(r2, e2) {
|
|||
|
var u2 = t2._(r2, e2);
|
|||
|
return u2.status || (u2.expected = n3), u2;
|
|||
|
});
|
|||
|
}, u.fallback = function(n3) {
|
|||
|
return this.or(X(n3));
|
|||
|
}, u.ap = function(n3) {
|
|||
|
return J(n3, this, function(n4, t2) {
|
|||
|
return n4(t2);
|
|||
|
});
|
|||
|
}, u.chain = function(n3) {
|
|||
|
var t2 = this;
|
|||
|
return e(function(r2, e2) {
|
|||
|
var u2 = t2._(r2, e2);
|
|||
|
return u2.status ? B(n3(u2.value)._(r2, u2.index), u2) : u2;
|
|||
|
});
|
|||
|
}, u.concat = u.or, u.empty = rn, u.of = X, u["fantasy-land/ap"] = u.ap, u["fantasy-land/chain"] = u.chain, u["fantasy-land/concat"] = u.concat, u["fantasy-land/empty"] = u.empty, u["fantasy-land/of"] = u.of, u["fantasy-land/map"] = u.map;
|
|||
|
var en = e(function(n3, t2) {
|
|||
|
return b(t2, S(n3, t2));
|
|||
|
}), un = e(function(n3, t2) {
|
|||
|
return t2 >= n3.length ? x(t2, "any character/byte") : b(t2 + 1, L(n3, t2));
|
|||
|
}), on = e(function(n3, t2) {
|
|||
|
return b(n3.length, n3.slice(t2));
|
|||
|
}), an = e(function(n3, t2) {
|
|||
|
return t2 < n3.length ? x(t2, "EOF") : b(t2, null);
|
|||
|
}), fn = Q(/[0-9]/).desc("a digit"), cn = Q(/[0-9]*/).desc("optional digits"), sn = Q(/[a-z]/i).desc("a letter"), ln = Q(/[a-z]*/i).desc("optional letters"), hn = Q(/\s*/).desc("optional whitespace"), pn = Q(/\s+/).desc("whitespace"), dn = K("\r"), vn = K("\n"), gn = K("\r\n"), mn = T(gn, vn, dn).desc("newline"), yn = T(mn, an);
|
|||
|
e.all = on, e.alt = T, e.any = un, e.cr = dn, e.createLanguage = function(n3) {
|
|||
|
var t2 = {};
|
|||
|
for (var r2 in n3)
|
|||
|
({}).hasOwnProperty.call(n3, r2) && function(r3) {
|
|||
|
t2[r3] = tn(function() {
|
|||
|
return n3[r3](t2);
|
|||
|
});
|
|||
|
}(r2);
|
|||
|
return t2;
|
|||
|
}, e.crlf = gn, e.custom = function(n3) {
|
|||
|
return e(n3(b, x));
|
|||
|
}, e.digit = fn, e.digits = cn, e.empty = rn, e.end = yn, e.eof = an, e.fail = Y, e.formatError = N, e.index = en, e.isParser = y, e.lazy = tn, e.letter = sn, e.letters = ln, e.lf = vn, e.lookahead = Z, e.makeFailure = x, e.makeSuccess = b, e.newline = mn, e.noneOf = function(n3) {
|
|||
|
return nn(function(t2) {
|
|||
|
return n3.indexOf(t2) < 0;
|
|||
|
}).desc("none of '" + n3 + "'");
|
|||
|
}, e.notFollowedBy = $, e.of = X, e.oneOf = function(n3) {
|
|||
|
for (var t2 = n3.split(""), r2 = 0; r2 < t2.length; r2++)
|
|||
|
t2[r2] = "'" + t2[r2] + "'";
|
|||
|
return nn(function(t3) {
|
|||
|
return n3.indexOf(t3) >= 0;
|
|||
|
}).desc(t2);
|
|||
|
}, e.optWhitespace = hn, e.Parser = e, e.range = function(n3, t2) {
|
|||
|
return nn(function(r2) {
|
|||
|
return n3 <= r2 && r2 <= t2;
|
|||
|
}).desc(n3 + "-" + t2);
|
|||
|
}, e.regex = Q, e.regexp = Q, e.sepBy = V, e.sepBy1 = H, e.seq = C, e.seqMap = J, e.seqObj = function() {
|
|||
|
for (var n3, t2 = {}, r2 = 0, u2 = (n3 = arguments, Array.prototype.slice.call(n3)), o2 = u2.length, i2 = 0; i2 < o2; i2 += 1) {
|
|||
|
var a2 = u2[i2];
|
|||
|
if (!y(a2)) {
|
|||
|
if (E(a2) && 2 === a2.length && "string" == typeof a2[0] && y(a2[1])) {
|
|||
|
var f2 = a2[0];
|
|||
|
if (Object.prototype.hasOwnProperty.call(t2, f2))
|
|||
|
throw new Error("seqObj: duplicate key " + f2);
|
|||
|
t2[f2] = true, r2++;
|
|||
|
continue;
|
|||
|
}
|
|||
|
throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.");
|
|||
|
}
|
|||
|
}
|
|||
|
if (0 === r2)
|
|||
|
throw new Error("seqObj expects at least one named parser, found zero");
|
|||
|
return e(function(n4, t3) {
|
|||
|
for (var r3, e2 = {}, i3 = 0; i3 < o2; i3 += 1) {
|
|||
|
var a3, f3;
|
|||
|
if (E(u2[i3]) ? (a3 = u2[i3][0], f3 = u2[i3][1]) : (a3 = null, f3 = u2[i3]), !(r3 = B(f3._(n4, t3), r3)).status)
|
|||
|
return r3;
|
|||
|
a3 && (e2[a3] = r3.value), t3 = r3.index;
|
|||
|
}
|
|||
|
return B(b(t3, e2), r3);
|
|||
|
});
|
|||
|
}, e.string = K, e.succeed = X, e.takeWhile = function(n3) {
|
|||
|
return k(n3), e(function(t2, r2) {
|
|||
|
for (var e2 = r2; e2 < t2.length && n3(L(t2, e2)); )
|
|||
|
e2++;
|
|||
|
return b(e2, t2.slice(r2, e2));
|
|||
|
});
|
|||
|
}, e.test = nn, e.whitespace = pn, e["fantasy-land/empty"] = rn, e["fantasy-land/of"] = X, e.Binary = { bitSeq: l2, bitSeqObj: function(n3) {
|
|||
|
s2();
|
|||
|
var t2 = {}, r2 = 0, e2 = a(function(n4) {
|
|||
|
if (E(n4)) {
|
|||
|
var e3 = n4;
|
|||
|
if (2 !== e3.length)
|
|||
|
throw new Error("[" + e3.join(", ") + "] should be length 2, got length " + e3.length);
|
|||
|
if (P(e3[0]), O(e3[1]), Object.prototype.hasOwnProperty.call(t2, e3[0]))
|
|||
|
throw new Error("duplicate key in bitSeqObj: " + e3[0]);
|
|||
|
return t2[e3[0]] = true, r2++, e3;
|
|||
|
}
|
|||
|
return O(n4), [null, n4];
|
|||
|
}, n3);
|
|||
|
if (r2 < 1)
|
|||
|
throw new Error("bitSeqObj expects at least one named pair, got [" + n3.join(", ") + "]");
|
|||
|
var u2 = a(function(n4) {
|
|||
|
return n4[0];
|
|||
|
}, e2);
|
|||
|
return l2(a(function(n4) {
|
|||
|
return n4[1];
|
|||
|
}, e2)).map(function(n4) {
|
|||
|
return i(function(n5, t3) {
|
|||
|
return null !== t3[0] && (n5[t3[0]] = t3[1]), n5;
|
|||
|
}, {}, a(function(t3, r3) {
|
|||
|
return [t3, n4[r3]];
|
|||
|
}, u2));
|
|||
|
});
|
|||
|
}, byte: function(n3) {
|
|||
|
if (s2(), O(n3), n3 > 255)
|
|||
|
throw new Error("Value specified to byte constructor (" + n3 + "=0x" + n3.toString(16) + ") is larger in value than a single byte.");
|
|||
|
var t2 = (n3 > 15 ? "0x" : "0x0") + n3.toString(16);
|
|||
|
return e(function(r2, e2) {
|
|||
|
var u2 = L(r2, e2);
|
|||
|
return u2 === n3 ? b(e2 + 1, u2) : x(e2, t2);
|
|||
|
});
|
|||
|
}, buffer: function(n3) {
|
|||
|
return h("buffer", n3).map(function(n4) {
|
|||
|
return Buffer.from(n4);
|
|||
|
});
|
|||
|
}, encodedString: function(n3, t2) {
|
|||
|
return h("string", t2).map(function(t3) {
|
|||
|
return t3.toString(n3);
|
|||
|
});
|
|||
|
}, uintBE: d, uint8BE: d(1), uint16BE: d(2), uint32BE: d(4), uintLE: v, uint8LE: v(1), uint16LE: v(2), uint32LE: v(4), intBE: g, int8BE: g(1), int16BE: g(2), int32BE: g(4), intLE: m, int8LE: m(1), int16LE: m(2), int32LE: m(4), floatBE: h("floatBE", 4).map(function(n3) {
|
|||
|
return n3.readFloatBE(0);
|
|||
|
}), floatLE: h("floatLE", 4).map(function(n3) {
|
|||
|
return n3.readFloatLE(0);
|
|||
|
}), doubleBE: h("doubleBE", 8).map(function(n3) {
|
|||
|
return n3.readDoubleBE(0);
|
|||
|
}), doubleLE: h("doubleLE", 8).map(function(n3) {
|
|||
|
return n3.readDoubleLE(0);
|
|||
|
}) }, n2.exports = e;
|
|||
|
}]);
|
|||
|
});
|
|||
|
})(parsimmon_umd_min);
|
|||
|
var emojiRegex = () => {
|
|||
|
return /(?:[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84
|
|||
|
};
|
|||
|
function normalizeDuration(dur) {
|
|||
|
if (dur === void 0 || dur === null)
|
|||
|
return dur;
|
|||
|
return dur.shiftToAll().normalize();
|
|||
|
}
|
|||
|
function getFileTitle(path) {
|
|||
|
if (path.includes("/"))
|
|||
|
path = path.substring(path.lastIndexOf("/") + 1);
|
|||
|
if (path.endsWith(".md"))
|
|||
|
path = path.substring(0, path.length - 3);
|
|||
|
return path;
|
|||
|
}
|
|||
|
parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.regex(new RegExp(emojiRegex(), "")), parsimmon_umd_min.exports.regex(/[0-9\p{Letter}_-]+/u).map((str) => str.toLocaleLowerCase()), parsimmon_umd_min.exports.whitespace.map((_) => "-"), parsimmon_umd_min.exports.any.map((_) => "")).many().map((result) => result.join(""));
|
|||
|
var HEADER_CANONICALIZER = parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.regex(new RegExp(emojiRegex(), "")), parsimmon_umd_min.exports.regex(/[0-9\p{Letter}_-]+/u), parsimmon_umd_min.exports.whitespace.map((_) => " "), parsimmon_umd_min.exports.any.map((_) => " ")).many().map((result) => {
|
|||
|
return result.join("").split(/\s+/).join(" ").trim();
|
|||
|
});
|
|||
|
function normalizeHeaderForLink(header) {
|
|||
|
return HEADER_CANONICALIZER.tryParse(header);
|
|||
|
}
|
|||
|
function renderMinimalDuration(dur) {
|
|||
|
dur = normalizeDuration(dur);
|
|||
|
dur = Duration.fromObject(Object.fromEntries(Object.entries(dur.toObject()).filter(([, quantity]) => quantity > 0)));
|
|||
|
return dur.toHuman();
|
|||
|
}
|
|||
|
var Values;
|
|||
|
(function(Values2) {
|
|||
|
function toString(field, setting = DEFAULT_QUERY_SETTINGS, recursive = false) {
|
|||
|
let wrapped = wrapValue(field);
|
|||
|
if (!wrapped)
|
|||
|
return setting.renderNullAs;
|
|||
|
switch (wrapped.type) {
|
|||
|
case "null":
|
|||
|
return setting.renderNullAs;
|
|||
|
case "string":
|
|||
|
return wrapped.value;
|
|||
|
case "number":
|
|||
|
case "boolean":
|
|||
|
return "" + wrapped.value;
|
|||
|
case "html":
|
|||
|
return wrapped.value.outerHTML;
|
|||
|
case "widget":
|
|||
|
return wrapped.value.markdown();
|
|||
|
case "link":
|
|||
|
return wrapped.value.markdown();
|
|||
|
case "function":
|
|||
|
return "<function>";
|
|||
|
case "array":
|
|||
|
let result = "";
|
|||
|
if (recursive)
|
|||
|
result += "[";
|
|||
|
result += wrapped.value.map((f) => toString(f, setting, true)).join(", ");
|
|||
|
if (recursive)
|
|||
|
result += "]";
|
|||
|
return result;
|
|||
|
case "object":
|
|||
|
return "{ " + Object.entries(wrapped.value).map((e) => e[0] + ": " + toString(e[1], setting, true)).join(", ") + " }";
|
|||
|
case "date":
|
|||
|
if (wrapped.value.second == 0 && wrapped.value.hour == 0 && wrapped.value.minute == 0) {
|
|||
|
return wrapped.value.toFormat(setting.defaultDateFormat);
|
|||
|
}
|
|||
|
return wrapped.value.toFormat(setting.defaultDateTimeFormat);
|
|||
|
case "duration":
|
|||
|
return renderMinimalDuration(wrapped.value);
|
|||
|
}
|
|||
|
}
|
|||
|
Values2.toString = toString;
|
|||
|
function wrapValue(val) {
|
|||
|
if (isNull(val))
|
|||
|
return { type: "null", value: val };
|
|||
|
else if (isNumber2(val))
|
|||
|
return { type: "number", value: val };
|
|||
|
else if (isString2(val))
|
|||
|
return { type: "string", value: val };
|
|||
|
else if (isBoolean(val))
|
|||
|
return { type: "boolean", value: val };
|
|||
|
else if (isDuration(val))
|
|||
|
return { type: "duration", value: val };
|
|||
|
else if (isDate2(val))
|
|||
|
return { type: "date", value: val };
|
|||
|
else if (isWidget(val))
|
|||
|
return { type: "widget", value: val };
|
|||
|
else if (isArray(val))
|
|||
|
return { type: "array", value: val };
|
|||
|
else if (isLink(val))
|
|||
|
return { type: "link", value: val };
|
|||
|
else if (isFunction(val))
|
|||
|
return { type: "function", value: val };
|
|||
|
else if (isHtml(val))
|
|||
|
return { type: "html", value: val };
|
|||
|
else if (isObject(val))
|
|||
|
return { type: "object", value: val };
|
|||
|
else
|
|||
|
return void 0;
|
|||
|
}
|
|||
|
Values2.wrapValue = wrapValue;
|
|||
|
function mapLeaves(val, func) {
|
|||
|
if (isObject(val)) {
|
|||
|
let result = {};
|
|||
|
for (let [key, value] of Object.entries(val))
|
|||
|
result[key] = mapLeaves(value, func);
|
|||
|
return result;
|
|||
|
} else if (isArray(val)) {
|
|||
|
let result = [];
|
|||
|
for (let value of val)
|
|||
|
result.push(mapLeaves(value, func));
|
|||
|
return result;
|
|||
|
} else {
|
|||
|
return func(val);
|
|||
|
}
|
|||
|
}
|
|||
|
Values2.mapLeaves = mapLeaves;
|
|||
|
function compareValue(val1, val2, linkNormalizer) {
|
|||
|
var _a, _b;
|
|||
|
if (val1 === void 0)
|
|||
|
val1 = null;
|
|||
|
if (val2 === void 0)
|
|||
|
val2 = null;
|
|||
|
if (val1 === null && val2 === null)
|
|||
|
return 0;
|
|||
|
else if (val1 === null)
|
|||
|
return -1;
|
|||
|
else if (val2 === null)
|
|||
|
return 1;
|
|||
|
let wrap1 = wrapValue(val1);
|
|||
|
let wrap2 = wrapValue(val2);
|
|||
|
if (wrap1 === void 0 && wrap2 === void 0)
|
|||
|
return 0;
|
|||
|
else if (wrap1 === void 0)
|
|||
|
return -1;
|
|||
|
else if (wrap2 === void 0)
|
|||
|
return 1;
|
|||
|
if (wrap1.type != wrap2.type)
|
|||
|
return wrap1.type.localeCompare(wrap2.type);
|
|||
|
if (wrap1.value === wrap2.value)
|
|||
|
return 0;
|
|||
|
switch (wrap1.type) {
|
|||
|
case "string":
|
|||
|
return wrap1.value.localeCompare(wrap2.value);
|
|||
|
case "number":
|
|||
|
if (wrap1.value < wrap2.value)
|
|||
|
return -1;
|
|||
|
else if (wrap1.value == wrap2.value)
|
|||
|
return 0;
|
|||
|
return 1;
|
|||
|
case "null":
|
|||
|
return 0;
|
|||
|
case "boolean":
|
|||
|
if (wrap1.value == wrap2.value)
|
|||
|
return 0;
|
|||
|
else
|
|||
|
return wrap1.value ? 1 : -1;
|
|||
|
case "link":
|
|||
|
let link1 = wrap1.value;
|
|||
|
let link2 = wrap2.value;
|
|||
|
let normalize = linkNormalizer !== null && linkNormalizer !== void 0 ? linkNormalizer : (x) => x;
|
|||
|
let pathCompare = normalize(link1.path).localeCompare(normalize(link2.path));
|
|||
|
if (pathCompare != 0)
|
|||
|
return pathCompare;
|
|||
|
let typeCompare = link1.type.localeCompare(link2.type);
|
|||
|
if (typeCompare != 0)
|
|||
|
return typeCompare;
|
|||
|
if (link1.subpath && !link2.subpath)
|
|||
|
return 1;
|
|||
|
if (!link1.subpath && link2.subpath)
|
|||
|
return -1;
|
|||
|
if (!link1.subpath && !link2.subpath)
|
|||
|
return 0;
|
|||
|
return ((_a = link1.subpath) !== null && _a !== void 0 ? _a : "").localeCompare((_b = link2.subpath) !== null && _b !== void 0 ? _b : "");
|
|||
|
case "date":
|
|||
|
return wrap1.value < wrap2.value ? -1 : wrap1.value.equals(wrap2.value) ? 0 : 1;
|
|||
|
case "duration":
|
|||
|
return wrap1.value < wrap2.value ? -1 : wrap1.value.equals(wrap2.value) ? 0 : 1;
|
|||
|
case "array":
|
|||
|
let f1 = wrap1.value;
|
|||
|
let f2 = wrap2.value;
|
|||
|
for (let index = 0; index < Math.min(f1.length, f2.length); index++) {
|
|||
|
let comp = compareValue(f1[index], f2[index]);
|
|||
|
if (comp != 0)
|
|||
|
return comp;
|
|||
|
}
|
|||
|
return f1.length - f2.length;
|
|||
|
case "object":
|
|||
|
let o1 = wrap1.value;
|
|||
|
let o2 = wrap2.value;
|
|||
|
let k1 = Array.from(Object.keys(o1));
|
|||
|
let k2 = Array.from(Object.keys(o2));
|
|||
|
k1.sort();
|
|||
|
k2.sort();
|
|||
|
let keyCompare = compareValue(k1, k2);
|
|||
|
if (keyCompare != 0)
|
|||
|
return keyCompare;
|
|||
|
for (let key of k1) {
|
|||
|
let comp = compareValue(o1[key], o2[key]);
|
|||
|
if (comp != 0)
|
|||
|
return comp;
|
|||
|
}
|
|||
|
return 0;
|
|||
|
case "widget":
|
|||
|
case "html":
|
|||
|
case "function":
|
|||
|
return 0;
|
|||
|
}
|
|||
|
}
|
|||
|
Values2.compareValue = compareValue;
|
|||
|
function typeOf(val) {
|
|||
|
var _a;
|
|||
|
return (_a = wrapValue(val)) === null || _a === void 0 ? void 0 : _a.type;
|
|||
|
}
|
|||
|
Values2.typeOf = typeOf;
|
|||
|
function isTruthy(field) {
|
|||
|
let wrapped = wrapValue(field);
|
|||
|
if (!wrapped)
|
|||
|
return false;
|
|||
|
switch (wrapped.type) {
|
|||
|
case "number":
|
|||
|
return wrapped.value != 0;
|
|||
|
case "string":
|
|||
|
return wrapped.value.length > 0;
|
|||
|
case "boolean":
|
|||
|
return wrapped.value;
|
|||
|
case "link":
|
|||
|
return !!wrapped.value.path;
|
|||
|
case "date":
|
|||
|
return wrapped.value.toMillis() != 0;
|
|||
|
case "duration":
|
|||
|
return wrapped.value.as("seconds") != 0;
|
|||
|
case "object":
|
|||
|
return Object.keys(wrapped.value).length > 0;
|
|||
|
case "array":
|
|||
|
return wrapped.value.length > 0;
|
|||
|
case "null":
|
|||
|
return false;
|
|||
|
case "html":
|
|||
|
case "widget":
|
|||
|
case "function":
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
Values2.isTruthy = isTruthy;
|
|||
|
function deepCopy(field) {
|
|||
|
if (field === null || field === void 0)
|
|||
|
return field;
|
|||
|
if (Values2.isArray(field)) {
|
|||
|
return [].concat(field.map((v) => deepCopy(v)));
|
|||
|
} else if (Values2.isObject(field)) {
|
|||
|
let result = {};
|
|||
|
for (let [key, value] of Object.entries(field))
|
|||
|
result[key] = deepCopy(value);
|
|||
|
return result;
|
|||
|
} else {
|
|||
|
return field;
|
|||
|
}
|
|||
|
}
|
|||
|
Values2.deepCopy = deepCopy;
|
|||
|
function isString2(val) {
|
|||
|
return typeof val == "string";
|
|||
|
}
|
|||
|
Values2.isString = isString2;
|
|||
|
function isNumber2(val) {
|
|||
|
return typeof val == "number";
|
|||
|
}
|
|||
|
Values2.isNumber = isNumber2;
|
|||
|
function isDate2(val) {
|
|||
|
return val instanceof DateTime;
|
|||
|
}
|
|||
|
Values2.isDate = isDate2;
|
|||
|
function isDuration(val) {
|
|||
|
return val instanceof Duration;
|
|||
|
}
|
|||
|
Values2.isDuration = isDuration;
|
|||
|
function isNull(val) {
|
|||
|
return val === null || val === void 0;
|
|||
|
}
|
|||
|
Values2.isNull = isNull;
|
|||
|
function isArray(val) {
|
|||
|
return Array.isArray(val);
|
|||
|
}
|
|||
|
Values2.isArray = isArray;
|
|||
|
function isBoolean(val) {
|
|||
|
return typeof val === "boolean";
|
|||
|
}
|
|||
|
Values2.isBoolean = isBoolean;
|
|||
|
function isLink(val) {
|
|||
|
return val instanceof Link;
|
|||
|
}
|
|||
|
Values2.isLink = isLink;
|
|||
|
function isWidget(val) {
|
|||
|
return val instanceof Widget;
|
|||
|
}
|
|||
|
Values2.isWidget = isWidget;
|
|||
|
function isHtml(val) {
|
|||
|
if (typeof HTMLElement !== "undefined") {
|
|||
|
return val instanceof HTMLElement;
|
|||
|
} else {
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
Values2.isHtml = isHtml;
|
|||
|
function isObject(val) {
|
|||
|
return typeof val == "object" && !isHtml(val) && !isWidget(val) && !isArray(val) && !isDuration(val) && !isDate2(val) && !isLink(val) && val !== void 0 && !isNull(val);
|
|||
|
}
|
|||
|
Values2.isObject = isObject;
|
|||
|
function isFunction(val) {
|
|||
|
return typeof val == "function";
|
|||
|
}
|
|||
|
Values2.isFunction = isFunction;
|
|||
|
})(Values || (Values = {}));
|
|||
|
var Groupings;
|
|||
|
(function(Groupings2) {
|
|||
|
function isElementGroup(entry) {
|
|||
|
return Values.isObject(entry) && Object.keys(entry).length == 2 && "key" in entry && "rows" in entry;
|
|||
|
}
|
|||
|
Groupings2.isElementGroup = isElementGroup;
|
|||
|
function isGrouping(entry) {
|
|||
|
for (let element2 of entry)
|
|||
|
if (!isElementGroup(element2))
|
|||
|
return false;
|
|||
|
return true;
|
|||
|
}
|
|||
|
Groupings2.isGrouping = isGrouping;
|
|||
|
function count(elements) {
|
|||
|
if (isGrouping(elements)) {
|
|||
|
let result = 0;
|
|||
|
for (let subgroup of elements)
|
|||
|
result += count(subgroup.rows);
|
|||
|
return result;
|
|||
|
} else {
|
|||
|
return elements.length;
|
|||
|
}
|
|||
|
}
|
|||
|
Groupings2.count = count;
|
|||
|
})(Groupings || (Groupings = {}));
|
|||
|
var Link = class {
|
|||
|
constructor(fields) {
|
|||
|
Object.assign(this, fields);
|
|||
|
}
|
|||
|
/** Create a link to a specific file. */
|
|||
|
static file(path, embed = false, display) {
|
|||
|
return new Link({
|
|||
|
path,
|
|||
|
embed,
|
|||
|
display,
|
|||
|
subpath: void 0,
|
|||
|
type: "file"
|
|||
|
});
|
|||
|
}
|
|||
|
static infer(linkpath, embed = false, display) {
|
|||
|
if (linkpath.includes("#^")) {
|
|||
|
let split = linkpath.split("#^");
|
|||
|
return Link.block(split[0], split[1], embed, display);
|
|||
|
} else if (linkpath.includes("#")) {
|
|||
|
let split = linkpath.split("#");
|
|||
|
return Link.header(split[0], split[1], embed, display);
|
|||
|
} else
|
|||
|
return Link.file(linkpath, embed, display);
|
|||
|
}
|
|||
|
/** Create a link to a specific file and header in that file. */
|
|||
|
static header(path, header, embed, display) {
|
|||
|
return new Link({
|
|||
|
path,
|
|||
|
embed,
|
|||
|
display,
|
|||
|
subpath: normalizeHeaderForLink(header),
|
|||
|
type: "header"
|
|||
|
});
|
|||
|
}
|
|||
|
/** Create a link to a specific file and block in that file. */
|
|||
|
static block(path, blockId, embed, display) {
|
|||
|
return new Link({
|
|||
|
path,
|
|||
|
embed,
|
|||
|
display,
|
|||
|
subpath: blockId,
|
|||
|
type: "block"
|
|||
|
});
|
|||
|
}
|
|||
|
static fromObject(object) {
|
|||
|
return new Link(object);
|
|||
|
}
|
|||
|
/** Checks for link equality (i.e., that the links are pointing to the same exact location). */
|
|||
|
equals(other) {
|
|||
|
if (other == void 0 || other == null)
|
|||
|
return false;
|
|||
|
return this.path == other.path && this.type == other.type && this.subpath == other.subpath;
|
|||
|
}
|
|||
|
/** Convert this link to it's markdown representation. */
|
|||
|
toString() {
|
|||
|
return this.markdown();
|
|||
|
}
|
|||
|
/** Convert this link to a raw object which is serialization-friendly. */
|
|||
|
toObject() {
|
|||
|
return { path: this.path, type: this.type, subpath: this.subpath, display: this.display, embed: this.embed };
|
|||
|
}
|
|||
|
/** Update this link with a new path. */
|
|||
|
//@ts-ignore; error appeared after updating Obsidian to 0.15.4; it also updated other packages but didn't say which
|
|||
|
withPath(path) {
|
|||
|
return new Link(Object.assign({}, this, { path }));
|
|||
|
}
|
|||
|
/** Return a new link which points to the same location but with a new display value. */
|
|||
|
withDisplay(display) {
|
|||
|
return new Link(Object.assign({}, this, { display }));
|
|||
|
}
|
|||
|
/** Convert a file link into a link to a specific header. */
|
|||
|
withHeader(header) {
|
|||
|
return Link.header(this.path, header, this.embed, this.display);
|
|||
|
}
|
|||
|
/** Convert any link into a link to its file. */
|
|||
|
toFile() {
|
|||
|
return Link.file(this.path, this.embed, this.display);
|
|||
|
}
|
|||
|
/** Convert this link into an embedded link. */
|
|||
|
toEmbed() {
|
|||
|
if (this.embed) {
|
|||
|
return this;
|
|||
|
} else {
|
|||
|
let link = new Link(this);
|
|||
|
link.embed = true;
|
|||
|
return link;
|
|||
|
}
|
|||
|
}
|
|||
|
/** Convert this link into a non-embedded link. */
|
|||
|
fromEmbed() {
|
|||
|
if (!this.embed) {
|
|||
|
return this;
|
|||
|
} else {
|
|||
|
let link = new Link(this);
|
|||
|
link.embed = false;
|
|||
|
return link;
|
|||
|
}
|
|||
|
}
|
|||
|
/** Convert this link to markdown so it can be rendered. */
|
|||
|
markdown() {
|
|||
|
let result = (this.embed ? "!" : "") + "[[" + this.obsidianLink();
|
|||
|
if (this.display) {
|
|||
|
result += "|" + this.display;
|
|||
|
} else {
|
|||
|
result += "|" + getFileTitle(this.path);
|
|||
|
if (this.type == "header" || this.type == "block")
|
|||
|
result += " > " + this.subpath;
|
|||
|
}
|
|||
|
result += "]]";
|
|||
|
return result;
|
|||
|
}
|
|||
|
/** Convert the inner part of the link to something that Obsidian can open / understand. */
|
|||
|
obsidianLink() {
|
|||
|
var _a, _b;
|
|||
|
const escaped = this.path.replace("|", "\\|");
|
|||
|
if (this.type == "header")
|
|||
|
return escaped + "#" + ((_a = this.subpath) === null || _a === void 0 ? void 0 : _a.replace("|", "\\|"));
|
|||
|
if (this.type == "block")
|
|||
|
return escaped + "#^" + ((_b = this.subpath) === null || _b === void 0 ? void 0 : _b.replace("|", "\\|"));
|
|||
|
else
|
|||
|
return escaped;
|
|||
|
}
|
|||
|
/** The stripped name of the file this link points to. */
|
|||
|
fileName() {
|
|||
|
return getFileTitle(this.path).replace(".md", "");
|
|||
|
}
|
|||
|
};
|
|||
|
var Widget = class {
|
|||
|
constructor($widget) {
|
|||
|
this.$widget = $widget;
|
|||
|
}
|
|||
|
};
|
|||
|
var ListPairWidget = class extends Widget {
|
|||
|
constructor(key, value) {
|
|||
|
super("dataview:list-pair");
|
|||
|
this.key = key;
|
|||
|
this.value = value;
|
|||
|
}
|
|||
|
markdown() {
|
|||
|
return `${Values.toString(this.key)}: ${Values.toString(this.value)}`;
|
|||
|
}
|
|||
|
};
|
|||
|
var ExternalLinkWidget = class extends Widget {
|
|||
|
constructor(url, display) {
|
|||
|
super("dataview:external-link");
|
|||
|
this.url = url;
|
|||
|
this.display = display;
|
|||
|
}
|
|||
|
markdown() {
|
|||
|
var _a;
|
|||
|
return `[${(_a = this.display) !== null && _a !== void 0 ? _a : this.url}](${this.url})`;
|
|||
|
}
|
|||
|
};
|
|||
|
var Widgets;
|
|||
|
(function(Widgets2) {
|
|||
|
function listPair(key, value) {
|
|||
|
return new ListPairWidget(key, value);
|
|||
|
}
|
|||
|
Widgets2.listPair = listPair;
|
|||
|
function externalLink(url, display) {
|
|||
|
return new ExternalLinkWidget(url, display);
|
|||
|
}
|
|||
|
Widgets2.externalLink = externalLink;
|
|||
|
function isListPair(widget) {
|
|||
|
return widget.$widget === "dataview:list-pair";
|
|||
|
}
|
|||
|
Widgets2.isListPair = isListPair;
|
|||
|
function isExternalLink(widget) {
|
|||
|
return widget.$widget === "dataview:external-link";
|
|||
|
}
|
|||
|
Widgets2.isExternalLink = isExternalLink;
|
|||
|
function isBuiltin(widget) {
|
|||
|
return isListPair(widget) || isExternalLink(widget);
|
|||
|
}
|
|||
|
Widgets2.isBuiltin = isBuiltin;
|
|||
|
})(Widgets || (Widgets = {}));
|
|||
|
var Fields;
|
|||
|
(function(Fields2) {
|
|||
|
function variable(name) {
|
|||
|
return { type: "variable", name };
|
|||
|
}
|
|||
|
Fields2.variable = variable;
|
|||
|
function literal(value) {
|
|||
|
return { type: "literal", value };
|
|||
|
}
|
|||
|
Fields2.literal = literal;
|
|||
|
function binaryOp(left, op, right) {
|
|||
|
return { type: "binaryop", left, op, right };
|
|||
|
}
|
|||
|
Fields2.binaryOp = binaryOp;
|
|||
|
function index(obj, index2) {
|
|||
|
return { type: "index", object: obj, index: index2 };
|
|||
|
}
|
|||
|
Fields2.index = index;
|
|||
|
function indexVariable(name) {
|
|||
|
let parts = name.split(".");
|
|||
|
let result = Fields2.variable(parts[0]);
|
|||
|
for (let index2 = 1; index2 < parts.length; index2++) {
|
|||
|
result = Fields2.index(result, Fields2.literal(parts[index2]));
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
Fields2.indexVariable = indexVariable;
|
|||
|
function lambda(args, value) {
|
|||
|
return { type: "lambda", arguments: args, value };
|
|||
|
}
|
|||
|
Fields2.lambda = lambda;
|
|||
|
function func(func2, args) {
|
|||
|
return { type: "function", func: func2, arguments: args };
|
|||
|
}
|
|||
|
Fields2.func = func;
|
|||
|
function list(values) {
|
|||
|
return { type: "list", values };
|
|||
|
}
|
|||
|
Fields2.list = list;
|
|||
|
function object(values) {
|
|||
|
return { type: "object", values };
|
|||
|
}
|
|||
|
Fields2.object = object;
|
|||
|
function negate(child) {
|
|||
|
return { type: "negated", child };
|
|||
|
}
|
|||
|
Fields2.negate = negate;
|
|||
|
function isCompareOp(op) {
|
|||
|
return op == "<=" || op == "<" || op == ">" || op == ">=" || op == "!=" || op == "=";
|
|||
|
}
|
|||
|
Fields2.isCompareOp = isCompareOp;
|
|||
|
Fields2.NULL = Fields2.literal(null);
|
|||
|
})(Fields || (Fields = {}));
|
|||
|
var Sources;
|
|||
|
(function(Sources2) {
|
|||
|
function tag(tag2) {
|
|||
|
return { type: "tag", tag: tag2 };
|
|||
|
}
|
|||
|
Sources2.tag = tag;
|
|||
|
function csv(path) {
|
|||
|
return { type: "csv", path };
|
|||
|
}
|
|||
|
Sources2.csv = csv;
|
|||
|
function folder(prefix) {
|
|||
|
return { type: "folder", folder: prefix };
|
|||
|
}
|
|||
|
Sources2.folder = folder;
|
|||
|
function link(file, incoming) {
|
|||
|
return { type: "link", file, direction: incoming ? "incoming" : "outgoing" };
|
|||
|
}
|
|||
|
Sources2.link = link;
|
|||
|
function binaryOp(left, op, right) {
|
|||
|
return { type: "binaryop", left, op, right };
|
|||
|
}
|
|||
|
Sources2.binaryOp = binaryOp;
|
|||
|
function and(left, right) {
|
|||
|
return { type: "binaryop", left, op: "&", right };
|
|||
|
}
|
|||
|
Sources2.and = and;
|
|||
|
function or(left, right) {
|
|||
|
return { type: "binaryop", left, op: "|", right };
|
|||
|
}
|
|||
|
Sources2.or = or;
|
|||
|
function negate(child) {
|
|||
|
return { type: "negate", child };
|
|||
|
}
|
|||
|
Sources2.negate = negate;
|
|||
|
function empty2() {
|
|||
|
return { type: "empty" };
|
|||
|
}
|
|||
|
Sources2.empty = empty2;
|
|||
|
})(Sources || (Sources = {}));
|
|||
|
var EMOJI_REGEX = new RegExp(emojiRegex(), "");
|
|||
|
var DURATION_TYPES = {
|
|||
|
year: Duration.fromObject({ years: 1 }),
|
|||
|
years: Duration.fromObject({ years: 1 }),
|
|||
|
yr: Duration.fromObject({ years: 1 }),
|
|||
|
yrs: Duration.fromObject({ years: 1 }),
|
|||
|
month: Duration.fromObject({ months: 1 }),
|
|||
|
months: Duration.fromObject({ months: 1 }),
|
|||
|
mo: Duration.fromObject({ months: 1 }),
|
|||
|
mos: Duration.fromObject({ months: 1 }),
|
|||
|
week: Duration.fromObject({ weeks: 1 }),
|
|||
|
weeks: Duration.fromObject({ weeks: 1 }),
|
|||
|
wk: Duration.fromObject({ weeks: 1 }),
|
|||
|
wks: Duration.fromObject({ weeks: 1 }),
|
|||
|
w: Duration.fromObject({ weeks: 1 }),
|
|||
|
day: Duration.fromObject({ days: 1 }),
|
|||
|
days: Duration.fromObject({ days: 1 }),
|
|||
|
d: Duration.fromObject({ days: 1 }),
|
|||
|
hour: Duration.fromObject({ hours: 1 }),
|
|||
|
hours: Duration.fromObject({ hours: 1 }),
|
|||
|
hr: Duration.fromObject({ hours: 1 }),
|
|||
|
hrs: Duration.fromObject({ hours: 1 }),
|
|||
|
h: Duration.fromObject({ hours: 1 }),
|
|||
|
minute: Duration.fromObject({ minutes: 1 }),
|
|||
|
minutes: Duration.fromObject({ minutes: 1 }),
|
|||
|
min: Duration.fromObject({ minutes: 1 }),
|
|||
|
mins: Duration.fromObject({ minutes: 1 }),
|
|||
|
m: Duration.fromObject({ minutes: 1 }),
|
|||
|
second: Duration.fromObject({ seconds: 1 }),
|
|||
|
seconds: Duration.fromObject({ seconds: 1 }),
|
|||
|
sec: Duration.fromObject({ seconds: 1 }),
|
|||
|
secs: Duration.fromObject({ seconds: 1 }),
|
|||
|
s: Duration.fromObject({ seconds: 1 })
|
|||
|
};
|
|||
|
var DATE_SHORTHANDS = {
|
|||
|
now: () => DateTime.local(),
|
|||
|
today: () => DateTime.local().startOf("day"),
|
|||
|
yesterday: () => DateTime.local().startOf("day").minus(Duration.fromObject({ days: 1 })),
|
|||
|
tomorrow: () => DateTime.local().startOf("day").plus(Duration.fromObject({ days: 1 })),
|
|||
|
sow: () => DateTime.local().startOf("week"),
|
|||
|
"start-of-week": () => DateTime.local().startOf("week"),
|
|||
|
eow: () => DateTime.local().endOf("week"),
|
|||
|
"end-of-week": () => DateTime.local().endOf("week"),
|
|||
|
soy: () => DateTime.local().startOf("year"),
|
|||
|
"start-of-year": () => DateTime.local().startOf("year"),
|
|||
|
eoy: () => DateTime.local().endOf("year"),
|
|||
|
"end-of-year": () => DateTime.local().endOf("year"),
|
|||
|
som: () => DateTime.local().startOf("month"),
|
|||
|
"start-of-month": () => DateTime.local().startOf("month"),
|
|||
|
eom: () => DateTime.local().endOf("month"),
|
|||
|
"end-of-month": () => DateTime.local().endOf("month")
|
|||
|
};
|
|||
|
var KEYWORDS = ["FROM", "WHERE", "LIMIT", "GROUP", "FLATTEN"];
|
|||
|
function splitOnUnescapedPipe(link) {
|
|||
|
let pipe = -1;
|
|||
|
while ((pipe = link.indexOf("|", pipe + 1)) >= 0) {
|
|||
|
if (pipe > 0 && link[pipe - 1] == "\\")
|
|||
|
continue;
|
|||
|
return [link.substring(0, pipe).replace(/\\\|/g, "|"), link.substring(pipe + 1)];
|
|||
|
}
|
|||
|
return [link.replace(/\\\|/g, "|"), void 0];
|
|||
|
}
|
|||
|
function parseInnerLink(rawlink) {
|
|||
|
let [link, display] = splitOnUnescapedPipe(rawlink);
|
|||
|
return Link.infer(link, false, display);
|
|||
|
}
|
|||
|
function createBinaryParser(child, sep, combine) {
|
|||
|
return parsimmon_umd_min.exports.seqMap(child, parsimmon_umd_min.exports.seq(parsimmon_umd_min.exports.optWhitespace, sep, parsimmon_umd_min.exports.optWhitespace, child).many(), (first, rest) => {
|
|||
|
if (rest.length == 0)
|
|||
|
return first;
|
|||
|
let node = combine(first, rest[0][1], rest[0][3]);
|
|||
|
for (let index = 1; index < rest.length; index++) {
|
|||
|
node = combine(node, rest[index][1], rest[index][3]);
|
|||
|
}
|
|||
|
return node;
|
|||
|
});
|
|||
|
}
|
|||
|
function chainOpt(base, ...funcs) {
|
|||
|
return parsimmon_umd_min.exports.custom((success, failure) => {
|
|||
|
return (input, i) => {
|
|||
|
let result = base._(input, i);
|
|||
|
if (!result.status)
|
|||
|
return result;
|
|||
|
for (let func of funcs) {
|
|||
|
let next = func(result.value)._(input, result.index);
|
|||
|
if (!next.status)
|
|||
|
return result;
|
|||
|
result = next;
|
|||
|
}
|
|||
|
return result;
|
|||
|
};
|
|||
|
});
|
|||
|
}
|
|||
|
var EXPRESSION = parsimmon_umd_min.exports.createLanguage({
|
|||
|
// A floating point number; the decimal point is optional.
|
|||
|
number: (q) => parsimmon_umd_min.exports.regexp(/-?[0-9]+(\.[0-9]+)?/).map((str) => Number.parseFloat(str)).desc("number"),
|
|||
|
// A quote-surrounded string which supports escape characters ('\').
|
|||
|
string: (q) => parsimmon_umd_min.exports.string('"').then(parsimmon_umd_min.exports.alt(q.escapeCharacter, parsimmon_umd_min.exports.noneOf('"\\')).atLeast(0).map((chars) => chars.join(""))).skip(parsimmon_umd_min.exports.string('"')).desc("string"),
|
|||
|
escapeCharacter: (_) => parsimmon_umd_min.exports.string("\\").then(parsimmon_umd_min.exports.any).map((escaped) => {
|
|||
|
if (escaped === '"')
|
|||
|
return '"';
|
|||
|
if (escaped === "\\")
|
|||
|
return "\\";
|
|||
|
else
|
|||
|
return "\\" + escaped;
|
|||
|
}),
|
|||
|
// A boolean true/false value.
|
|||
|
bool: (_) => parsimmon_umd_min.exports.regexp(/true|false|True|False/).map((str) => str.toLowerCase() == "true").desc("boolean ('true' or 'false')"),
|
|||
|
// A tag of the form '#stuff/hello-there'.
|
|||
|
tag: (_) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("#"), parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.regexp(/[^\u2000-\u206F\u2E00-\u2E7F'!"#$%&()*+,.:;<=>?@^`{|}~\[\]\\\s]/).desc("text")).many(), (start, rest) => start + rest.join("")).desc("tag ('#hello/stuff')"),
|
|||
|
// A variable identifier, which is alphanumeric and must start with a letter or... emoji.
|
|||
|
identifier: (_) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.regexp(/\p{Letter}/u), parsimmon_umd_min.exports.regexp(EMOJI_REGEX).desc("text")), parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.regexp(/[0-9\p{Letter}_-]/u), parsimmon_umd_min.exports.regexp(EMOJI_REGEX).desc("text")).many(), (first, rest) => first + rest.join("")).desc("variable identifier"),
|
|||
|
// An Obsidian link of the form [[<link>]].
|
|||
|
link: (_) => parsimmon_umd_min.exports.regexp(/\[\[([^\[\]]*?)\]\]/u, 1).map((linkInner) => parseInnerLink(linkInner)).desc("file link"),
|
|||
|
// An embeddable link which can start with '!'. This overlaps with the normal negation operator, so it is only
|
|||
|
// provided for metadata parsing.
|
|||
|
embedLink: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("!").atMost(1), q.link, (p, l2) => {
|
|||
|
if (p.length > 0)
|
|||
|
l2.embed = true;
|
|||
|
return l2;
|
|||
|
}).desc("file link"),
|
|||
|
// Binary plus or minus operator.
|
|||
|
binaryPlusMinus: (_) => parsimmon_umd_min.exports.regexp(/\+|-/).map((str) => str).desc("'+' or '-'"),
|
|||
|
// Binary times or divide operator.
|
|||
|
binaryMulDiv: (_) => parsimmon_umd_min.exports.regexp(/\*|\/|%/).map((str) => str).desc("'*' or '/' or '%'"),
|
|||
|
// Binary comparison operator.
|
|||
|
binaryCompareOp: (_) => parsimmon_umd_min.exports.regexp(/>=|<=|!=|>|<|=/).map((str) => str).desc("'>=' or '<=' or '!=' or '=' or '>' or '<'"),
|
|||
|
// Binary boolean combination operator.
|
|||
|
binaryBooleanOp: (_) => parsimmon_umd_min.exports.regexp(/and|or|&|\|/i).map((str) => {
|
|||
|
if (str.toLowerCase() == "and")
|
|||
|
return "&";
|
|||
|
else if (str.toLowerCase() == "or")
|
|||
|
return "|";
|
|||
|
else
|
|||
|
return str;
|
|||
|
}).desc("'and' or 'or'"),
|
|||
|
// A date which can be YYYY-MM[-DDTHH:mm:ss].
|
|||
|
rootDate: (_) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/\d{4}/), parsimmon_umd_min.exports.string("-"), parsimmon_umd_min.exports.regexp(/\d{2}/), (year, _2, month) => {
|
|||
|
return DateTime.fromObject({ year: Number.parseInt(year), month: Number.parseInt(month) });
|
|||
|
}).desc("date in format YYYY-MM[-DDTHH-MM-SS.MS]"),
|
|||
|
dateShorthand: (_) => parsimmon_umd_min.exports.alt(...Object.keys(DATE_SHORTHANDS).sort((a, b) => b.length - a.length).map(parsimmon_umd_min.exports.string)),
|
|||
|
date: (q) => chainOpt(q.rootDate, (ym) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("-"), parsimmon_umd_min.exports.regexp(/\d{2}/), (_, day) => ym.set({ day: Number.parseInt(day) })), (ymd) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("T"), parsimmon_umd_min.exports.regexp(/\d{2}/), (_, hour) => ymd.set({ hour: Number.parseInt(hour) })), (ymdh) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string(":"), parsimmon_umd_min.exports.regexp(/\d{2}/), (_, minute) => ymdh.set({ minute: Number.parseInt(minute) })), (ymdhm) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string(":"), parsimmon_umd_min.exports.regexp(/\d{2}/), (_, second) => ymdhm.set({ second: Number.parseInt(second) })), (ymdhms) => parsimmon_umd_min.exports.alt(
|
|||
|
parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("."), parsimmon_umd_min.exports.regexp(/\d{3}/), (_, millisecond) => ymdhms.set({ millisecond: Number.parseInt(millisecond) })),
|
|||
|
parsimmon_umd_min.exports.succeed(ymdhms)
|
|||
|
// pass
|
|||
|
), (dt) => parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("+").or(parsimmon_umd_min.exports.string("-")), parsimmon_umd_min.exports.regexp(/\d{1,2}(:\d{2})?/), (pm, hr) => dt.setZone("UTC" + pm + hr, { keepLocalTime: true })), parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("Z"), () => dt.setZone("utc", { keepLocalTime: true })), parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("["), parsimmon_umd_min.exports.regexp(/[0-9A-Za-z+-\/]+/u), parsimmon_umd_min.exports.string("]"), (_a, zone, _b) => dt.setZone(zone, { keepLocalTime: true })))).assert((dt) => dt.isValid, "valid date").desc("date in format YYYY-MM[-DDTHH-MM-SS.MS]"),
|
|||
|
// A date, plus various shorthand times of day it could be.
|
|||
|
datePlus: (q) => parsimmon_umd_min.exports.alt(q.dateShorthand.map((d) => DATE_SHORTHANDS[d]()), q.date).desc("date in format YYYY-MM[-DDTHH-MM-SS.MS] or in shorthand"),
|
|||
|
// A duration of time.
|
|||
|
durationType: (_) => parsimmon_umd_min.exports.alt(...Object.keys(DURATION_TYPES).sort((a, b) => b.length - a.length).map(parsimmon_umd_min.exports.string)),
|
|||
|
duration: (q) => parsimmon_umd_min.exports.seqMap(q.number, parsimmon_umd_min.exports.optWhitespace, q.durationType, (count, _, t) => DURATION_TYPES[t].mapUnits((x) => x * count)).sepBy1(parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace).or(parsimmon_umd_min.exports.optWhitespace)).map((durations) => durations.reduce((p, c) => p.plus(c))).desc("duration like 4hr2min"),
|
|||
|
// A raw null value.
|
|||
|
rawNull: (_) => parsimmon_umd_min.exports.string("null"),
|
|||
|
// Source parsing.
|
|||
|
tagSource: (q) => q.tag.map((tag) => Sources.tag(tag)),
|
|||
|
csvSource: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("csv(").skip(parsimmon_umd_min.exports.optWhitespace), q.string, parsimmon_umd_min.exports.string(")"), (_1, path, _2) => Sources.csv(path)),
|
|||
|
linkIncomingSource: (q) => q.link.map((link) => Sources.link(link.path, true)),
|
|||
|
linkOutgoingSource: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("outgoing(").skip(parsimmon_umd_min.exports.optWhitespace), q.link, parsimmon_umd_min.exports.string(")"), (_1, link, _2) => Sources.link(link.path, false)),
|
|||
|
folderSource: (q) => q.string.map((str) => Sources.folder(str)),
|
|||
|
parensSource: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("("), parsimmon_umd_min.exports.optWhitespace, q.source, parsimmon_umd_min.exports.optWhitespace, parsimmon_umd_min.exports.string(")"), (_1, _2, field, _3, _4) => field),
|
|||
|
negateSource: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.string("-"), parsimmon_umd_min.exports.string("!")), q.atomSource, (_, source) => Sources.negate(source)),
|
|||
|
atomSource: (q) => parsimmon_umd_min.exports.alt(q.parensSource, q.negateSource, q.linkOutgoingSource, q.linkIncomingSource, q.folderSource, q.tagSource, q.csvSource),
|
|||
|
binaryOpSource: (q) => createBinaryParser(q.atomSource, q.binaryBooleanOp.map((s2) => s2), Sources.binaryOp),
|
|||
|
source: (q) => q.binaryOpSource,
|
|||
|
// Field parsing.
|
|||
|
variableField: (q) => q.identifier.chain((r) => {
|
|||
|
if (KEYWORDS.includes(r.toUpperCase())) {
|
|||
|
return parsimmon_umd_min.exports.fail("Variable fields cannot be a keyword (" + KEYWORDS.join(" or ") + ")");
|
|||
|
} else {
|
|||
|
return parsimmon_umd_min.exports.succeed(Fields.variable(r));
|
|||
|
}
|
|||
|
}).desc("variable"),
|
|||
|
numberField: (q) => q.number.map((val) => Fields.literal(val)).desc("number"),
|
|||
|
stringField: (q) => q.string.map((val) => Fields.literal(val)).desc("string"),
|
|||
|
boolField: (q) => q.bool.map((val) => Fields.literal(val)).desc("boolean"),
|
|||
|
dateField: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("date("), parsimmon_umd_min.exports.optWhitespace, q.datePlus, parsimmon_umd_min.exports.optWhitespace, parsimmon_umd_min.exports.string(")"), (prefix, _1, date, _2, postfix) => Fields.literal(date)).desc("date"),
|
|||
|
durationField: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("dur("), parsimmon_umd_min.exports.optWhitespace, q.duration, parsimmon_umd_min.exports.optWhitespace, parsimmon_umd_min.exports.string(")"), (prefix, _1, dur, _2, postfix) => Fields.literal(dur)).desc("duration"),
|
|||
|
nullField: (q) => q.rawNull.map((_) => Fields.NULL),
|
|||
|
linkField: (q) => q.link.map((f) => Fields.literal(f)),
|
|||
|
listField: (q) => q.field.sepBy(parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace)).wrap(parsimmon_umd_min.exports.string("[").skip(parsimmon_umd_min.exports.optWhitespace), parsimmon_umd_min.exports.optWhitespace.then(parsimmon_umd_min.exports.string("]"))).map((l2) => Fields.list(l2)).desc("list ('[1, 2, 3]')"),
|
|||
|
objectField: (q) => parsimmon_umd_min.exports.seqMap(q.identifier.or(q.string), parsimmon_umd_min.exports.string(":").trim(parsimmon_umd_min.exports.optWhitespace), q.field, (name, _sep, value) => {
|
|||
|
return { name, value };
|
|||
|
}).sepBy(parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace)).wrap(parsimmon_umd_min.exports.string("{").skip(parsimmon_umd_min.exports.optWhitespace), parsimmon_umd_min.exports.optWhitespace.then(parsimmon_umd_min.exports.string("}"))).map((vals) => {
|
|||
|
let res = {};
|
|||
|
for (let entry of vals)
|
|||
|
res[entry.name] = entry.value;
|
|||
|
return Fields.object(res);
|
|||
|
}).desc("object ('{ a: 1, b: 2 }')"),
|
|||
|
atomInlineField: (q) => parsimmon_umd_min.exports.alt(q.date, q.duration.map((d) => normalizeDuration(d)), q.string, q.tag, q.embedLink, q.bool, q.number, q.rawNull),
|
|||
|
inlineFieldList: (q) => q.atomInlineField.sepBy(parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace).lookahead(q.atomInlineField)),
|
|||
|
inlineField: (q) => parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.seqMap(q.atomInlineField, parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace), q.inlineFieldList, (f, _s, l2) => [f].concat(l2)), q.atomInlineField),
|
|||
|
atomField: (q) => parsimmon_umd_min.exports.alt(
|
|||
|
// Place embed links above negated fields as they are the special parser case '![[thing]]' and are generally unambigious.
|
|||
|
q.embedLink.map((l2) => Fields.literal(l2)),
|
|||
|
q.negatedField,
|
|||
|
q.linkField,
|
|||
|
q.listField,
|
|||
|
q.objectField,
|
|||
|
q.lambdaField,
|
|||
|
q.parensField,
|
|||
|
q.boolField,
|
|||
|
q.numberField,
|
|||
|
q.stringField,
|
|||
|
q.dateField,
|
|||
|
q.durationField,
|
|||
|
q.nullField,
|
|||
|
q.variableField
|
|||
|
),
|
|||
|
indexField: (q) => parsimmon_umd_min.exports.seqMap(q.atomField, parsimmon_umd_min.exports.alt(q.dotPostfix, q.indexPostfix, q.functionPostfix).many(), (obj, postfixes) => {
|
|||
|
let result = obj;
|
|||
|
for (let post of postfixes) {
|
|||
|
switch (post.type) {
|
|||
|
case "dot":
|
|||
|
result = Fields.index(result, Fields.literal(post.field));
|
|||
|
break;
|
|||
|
case "index":
|
|||
|
result = Fields.index(result, post.field);
|
|||
|
break;
|
|||
|
case "function":
|
|||
|
result = Fields.func(result, post.fields);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}),
|
|||
|
negatedField: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("!"), q.indexField, (_, field) => Fields.negate(field)).desc("negated field"),
|
|||
|
parensField: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("("), parsimmon_umd_min.exports.optWhitespace, q.field, parsimmon_umd_min.exports.optWhitespace, parsimmon_umd_min.exports.string(")"), (_1, _2, field, _3, _4) => field),
|
|||
|
lambdaField: (q) => parsimmon_umd_min.exports.seqMap(q.identifier.sepBy(parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace)).wrap(parsimmon_umd_min.exports.string("(").trim(parsimmon_umd_min.exports.optWhitespace), parsimmon_umd_min.exports.string(")").trim(parsimmon_umd_min.exports.optWhitespace)), parsimmon_umd_min.exports.string("=>").trim(parsimmon_umd_min.exports.optWhitespace), q.field, (ident, _ignore, value) => {
|
|||
|
return { type: "lambda", arguments: ident, value };
|
|||
|
}),
|
|||
|
dotPostfix: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("."), q.identifier, (_, field) => {
|
|||
|
return { type: "dot", field };
|
|||
|
}),
|
|||
|
indexPostfix: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("["), parsimmon_umd_min.exports.optWhitespace, q.field, parsimmon_umd_min.exports.optWhitespace, parsimmon_umd_min.exports.string("]"), (_, _2, field, _3, _4) => {
|
|||
|
return { type: "index", field };
|
|||
|
}),
|
|||
|
functionPostfix: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("("), parsimmon_umd_min.exports.optWhitespace, q.field.sepBy(parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace)), parsimmon_umd_min.exports.optWhitespace, parsimmon_umd_min.exports.string(")"), (_, _1, fields, _2, _3) => {
|
|||
|
return { type: "function", fields };
|
|||
|
}),
|
|||
|
// The precedence hierarchy of operators - multiply/divide, add/subtract, compare, and then boolean operations.
|
|||
|
binaryMulDivField: (q) => createBinaryParser(q.indexField, q.binaryMulDiv, Fields.binaryOp),
|
|||
|
binaryPlusMinusField: (q) => createBinaryParser(q.binaryMulDivField, q.binaryPlusMinus, Fields.binaryOp),
|
|||
|
binaryCompareField: (q) => createBinaryParser(q.binaryPlusMinusField, q.binaryCompareOp, Fields.binaryOp),
|
|||
|
binaryBooleanField: (q) => createBinaryParser(q.binaryCompareField, q.binaryBooleanOp, Fields.binaryOp),
|
|||
|
binaryOpField: (q) => q.binaryBooleanField,
|
|||
|
field: (q) => q.binaryOpField
|
|||
|
});
|
|||
|
function parseField(text2) {
|
|||
|
try {
|
|||
|
return Result.success(EXPRESSION.field.tryParse(text2));
|
|||
|
} catch (error) {
|
|||
|
return Result.failure("" + error);
|
|||
|
}
|
|||
|
}
|
|||
|
var QueryFields;
|
|||
|
(function(QueryFields2) {
|
|||
|
function named(name, field) {
|
|||
|
return { name, field };
|
|||
|
}
|
|||
|
QueryFields2.named = named;
|
|||
|
function sortBy(field, dir) {
|
|||
|
return { field, direction: dir };
|
|||
|
}
|
|||
|
QueryFields2.sortBy = sortBy;
|
|||
|
})(QueryFields || (QueryFields = {}));
|
|||
|
function captureRaw(base) {
|
|||
|
return parsimmon_umd_min.exports.custom((success, failure) => {
|
|||
|
return (input, i) => {
|
|||
|
let result = base._(input, i);
|
|||
|
if (!result.status)
|
|||
|
return result;
|
|||
|
return Object.assign({}, result, { value: [result.value, input.substring(i, result.index)] });
|
|||
|
};
|
|||
|
});
|
|||
|
}
|
|||
|
function stripNewlines(text2) {
|
|||
|
return text2.split(/[\r\n]+/).map((t) => t.trim()).join("");
|
|||
|
}
|
|||
|
var QUERY_LANGUAGE = parsimmon_umd_min.exports.createLanguage({
|
|||
|
// Simple atom parsing, like words, identifiers, numbers.
|
|||
|
queryType: (q) => parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.regexp(/TABLE|LIST|TASK|CALENDAR/i)).map((str) => str.toLowerCase()).desc("query type ('TABLE', 'LIST', 'TASK', or 'CALENDAR')"),
|
|||
|
explicitNamedField: (q) => parsimmon_umd_min.exports.seqMap(EXPRESSION.field.skip(parsimmon_umd_min.exports.whitespace), parsimmon_umd_min.exports.regexp(/AS/i).skip(parsimmon_umd_min.exports.whitespace), EXPRESSION.identifier.or(EXPRESSION.string), (field, _as, ident) => QueryFields.named(ident, field)),
|
|||
|
namedField: (q) => parsimmon_umd_min.exports.alt(q.explicitNamedField, captureRaw(EXPRESSION.field).map(([value, text2]) => QueryFields.named(stripNewlines(text2), value))),
|
|||
|
sortField: (q) => parsimmon_umd_min.exports.seqMap(EXPRESSION.field.skip(parsimmon_umd_min.exports.optWhitespace), parsimmon_umd_min.exports.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1), (field, dir) => {
|
|||
|
let direction = dir.length == 0 ? "ascending" : dir[0].toLowerCase();
|
|||
|
if (direction == "desc")
|
|||
|
direction = "descending";
|
|||
|
if (direction == "asc")
|
|||
|
direction = "ascending";
|
|||
|
return {
|
|||
|
field,
|
|||
|
direction
|
|||
|
};
|
|||
|
}),
|
|||
|
headerClause: (q) => q.queryType.skip(parsimmon_umd_min.exports.whitespace).chain((qtype) => {
|
|||
|
switch (qtype) {
|
|||
|
case "table":
|
|||
|
return parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/WITHOUT\s+ID/i).skip(parsimmon_umd_min.exports.optWhitespace).atMost(1), parsimmon_umd_min.exports.sepBy(q.namedField, parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace)), (withoutId, fields) => {
|
|||
|
return { type: "table", fields, showId: withoutId.length == 0 };
|
|||
|
});
|
|||
|
case "list":
|
|||
|
return parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/WITHOUT\s+ID/i).skip(parsimmon_umd_min.exports.optWhitespace).atMost(1), EXPRESSION.field.atMost(1), (withoutId, format) => {
|
|||
|
return {
|
|||
|
type: "list",
|
|||
|
format: format.length == 1 ? format[0] : void 0,
|
|||
|
showId: withoutId.length == 0
|
|||
|
};
|
|||
|
});
|
|||
|
case "task":
|
|||
|
return parsimmon_umd_min.exports.succeed({ type: "task" });
|
|||
|
case "calendar":
|
|||
|
return parsimmon_umd_min.exports.seqMap(q.namedField, (field) => {
|
|||
|
return {
|
|||
|
type: "calendar",
|
|||
|
showId: true,
|
|||
|
field
|
|||
|
};
|
|||
|
});
|
|||
|
default:
|
|||
|
return parsimmon_umd_min.exports.fail(`Unrecognized query type '${qtype}'`);
|
|||
|
}
|
|||
|
}).desc("TABLE or LIST or TASK or CALENDAR"),
|
|||
|
fromClause: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/FROM/i), parsimmon_umd_min.exports.whitespace, EXPRESSION.source, (_1, _2, source) => source),
|
|||
|
whereClause: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/WHERE/i), parsimmon_umd_min.exports.whitespace, EXPRESSION.field, (where, _, field) => {
|
|||
|
return { type: "where", clause: field };
|
|||
|
}).desc("WHERE <expression>"),
|
|||
|
sortByClause: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/SORT/i), parsimmon_umd_min.exports.whitespace, q.sortField.sepBy1(parsimmon_umd_min.exports.string(",").trim(parsimmon_umd_min.exports.optWhitespace)), (sort, _1, fields) => {
|
|||
|
return { type: "sort", fields };
|
|||
|
}).desc("SORT field [ASC/DESC]"),
|
|||
|
limitClause: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/LIMIT/i), parsimmon_umd_min.exports.whitespace, EXPRESSION.field, (limit, _1, field) => {
|
|||
|
return { type: "limit", amount: field };
|
|||
|
}).desc("LIMIT <value>"),
|
|||
|
flattenClause: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/FLATTEN/i).skip(parsimmon_umd_min.exports.whitespace), q.namedField, (_, field) => {
|
|||
|
return { type: "flatten", field };
|
|||
|
}).desc("FLATTEN <value> [AS <name>]"),
|
|||
|
groupByClause: (q) => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.regexp(/GROUP BY/i).skip(parsimmon_umd_min.exports.whitespace), q.namedField, (_, field) => {
|
|||
|
return { type: "group", field };
|
|||
|
}).desc("GROUP BY <value> [AS <name>]"),
|
|||
|
// Full query parsing.
|
|||
|
clause: (q) => parsimmon_umd_min.exports.alt(q.fromClause, q.whereClause, q.sortByClause, q.limitClause, q.groupByClause, q.flattenClause),
|
|||
|
query: (q) => parsimmon_umd_min.exports.seqMap(q.headerClause.trim(parsimmon_umd_min.exports.optWhitespace), q.fromClause.trim(parsimmon_umd_min.exports.optWhitespace).atMost(1), q.clause.trim(parsimmon_umd_min.exports.optWhitespace).many(), (header, from, clauses) => {
|
|||
|
return {
|
|||
|
header,
|
|||
|
source: from.length == 0 ? Sources.folder("") : from[0],
|
|||
|
operations: clauses,
|
|||
|
settings: DEFAULT_QUERY_SETTINGS
|
|||
|
};
|
|||
|
})
|
|||
|
});
|
|||
|
var getAPI2 = (app) => {
|
|||
|
var _a;
|
|||
|
if (app)
|
|||
|
return (_a = app.plugins.plugins.dataview) === null || _a === void 0 ? void 0 : _a.api;
|
|||
|
else
|
|||
|
return window.DataviewAPI;
|
|||
|
};
|
|||
|
var isPluginEnabled = (app) => app.plugins.enabledPlugins.has("dataview");
|
|||
|
exports.DATE_SHORTHANDS = DATE_SHORTHANDS;
|
|||
|
exports.DURATION_TYPES = DURATION_TYPES;
|
|||
|
exports.EXPRESSION = EXPRESSION;
|
|||
|
exports.KEYWORDS = KEYWORDS;
|
|||
|
exports.QUERY_LANGUAGE = QUERY_LANGUAGE;
|
|||
|
exports.getAPI = getAPI2;
|
|||
|
exports.isPluginEnabled = isPluginEnabled;
|
|||
|
exports.parseField = parseField;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// src/main.ts
|
|||
|
var main_exports = {};
|
|||
|
__export(main_exports, {
|
|||
|
default: () => AdvancedRandomNote
|
|||
|
});
|
|||
|
module.exports = __toCommonJS(main_exports);
|
|||
|
var import_obsidian6 = require("obsidian");
|
|||
|
|
|||
|
// src/gui/modals/OpenRandomNoteModal/openRandomNoteModal.ts
|
|||
|
var import_obsidian = require("obsidian");
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/utils.js
|
|||
|
function noop() {
|
|||
|
}
|
|||
|
function assign(tar, src) {
|
|||
|
for (const k in src)
|
|||
|
tar[k] = src[k];
|
|||
|
return (
|
|||
|
/** @type {T & S} */
|
|||
|
tar
|
|||
|
);
|
|||
|
}
|
|||
|
function run(fn) {
|
|||
|
return fn();
|
|||
|
}
|
|||
|
function blank_object() {
|
|||
|
return /* @__PURE__ */ Object.create(null);
|
|||
|
}
|
|||
|
function run_all(fns) {
|
|||
|
fns.forEach(run);
|
|||
|
}
|
|||
|
function is_function(thing) {
|
|||
|
return typeof thing === "function";
|
|||
|
}
|
|||
|
function safe_not_equal(a, b) {
|
|||
|
return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
|
|||
|
}
|
|||
|
function is_empty(obj) {
|
|||
|
return Object.keys(obj).length === 0;
|
|||
|
}
|
|||
|
function create_slot(definition, ctx, $$scope, fn) {
|
|||
|
if (definition) {
|
|||
|
const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);
|
|||
|
return definition[0](slot_ctx);
|
|||
|
}
|
|||
|
}
|
|||
|
function get_slot_context(definition, ctx, $$scope, fn) {
|
|||
|
return definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;
|
|||
|
}
|
|||
|
function get_slot_changes(definition, $$scope, dirty, fn) {
|
|||
|
if (definition[2] && fn) {
|
|||
|
const lets = definition[2](fn(dirty));
|
|||
|
if ($$scope.dirty === void 0) {
|
|||
|
return lets;
|
|||
|
}
|
|||
|
if (typeof lets === "object") {
|
|||
|
const merged = [];
|
|||
|
const len = Math.max($$scope.dirty.length, lets.length);
|
|||
|
for (let i = 0; i < len; i += 1) {
|
|||
|
merged[i] = $$scope.dirty[i] | lets[i];
|
|||
|
}
|
|||
|
return merged;
|
|||
|
}
|
|||
|
return $$scope.dirty | lets;
|
|||
|
}
|
|||
|
return $$scope.dirty;
|
|||
|
}
|
|||
|
function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
|
|||
|
if (slot_changes) {
|
|||
|
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
|
|||
|
slot.p(slot_context, slot_changes);
|
|||
|
}
|
|||
|
}
|
|||
|
function get_all_dirty_from_scope($$scope) {
|
|||
|
if ($$scope.ctx.length > 32) {
|
|||
|
const dirty = [];
|
|||
|
const length = $$scope.ctx.length / 32;
|
|||
|
for (let i = 0; i < length; i++) {
|
|||
|
dirty[i] = -1;
|
|||
|
}
|
|||
|
return dirty;
|
|||
|
}
|
|||
|
return -1;
|
|||
|
}
|
|||
|
function exclude_internal_props(props) {
|
|||
|
const result = {};
|
|||
|
for (const k in props)
|
|||
|
if (k[0] !== "$")
|
|||
|
result[k] = props[k];
|
|||
|
return result;
|
|||
|
}
|
|||
|
function compute_rest_props(props, keys) {
|
|||
|
const rest = {};
|
|||
|
keys = new Set(keys);
|
|||
|
for (const k in props)
|
|||
|
if (!keys.has(k) && k[0] !== "$")
|
|||
|
rest[k] = props[k];
|
|||
|
return rest;
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/globals.js
|
|||
|
var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : (
|
|||
|
// @ts-ignore Node typings have this
|
|||
|
global
|
|||
|
);
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js
|
|||
|
var ResizeObserverSingleton = class {
|
|||
|
/** @param {ResizeObserverOptions} options */
|
|||
|
constructor(options) {
|
|||
|
/**
|
|||
|
* @private
|
|||
|
* @readonly
|
|||
|
* @type {WeakMap<Element, import('./private.js').Listener>}
|
|||
|
*/
|
|||
|
__publicField(this, "_listeners", "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0);
|
|||
|
/**
|
|||
|
* @private
|
|||
|
* @type {ResizeObserver}
|
|||
|
*/
|
|||
|
__publicField(this, "_observer");
|
|||
|
/** @type {ResizeObserverOptions} */
|
|||
|
__publicField(this, "options");
|
|||
|
this.options = options;
|
|||
|
}
|
|||
|
/**
|
|||
|
* @param {Element} element
|
|||
|
* @param {import('./private.js').Listener} listener
|
|||
|
* @returns {() => void}
|
|||
|
*/
|
|||
|
observe(element2, listener) {
|
|||
|
this._listeners.set(element2, listener);
|
|||
|
this._getObserver().observe(element2, this.options);
|
|||
|
return () => {
|
|||
|
this._listeners.delete(element2);
|
|||
|
this._observer.unobserve(element2);
|
|||
|
};
|
|||
|
}
|
|||
|
/**
|
|||
|
* @private
|
|||
|
*/
|
|||
|
_getObserver() {
|
|||
|
var _a;
|
|||
|
return (_a = this._observer) != null ? _a : this._observer = new ResizeObserver((entries) => {
|
|||
|
var _a2;
|
|||
|
for (const entry of entries) {
|
|||
|
ResizeObserverSingleton.entries.set(entry.target, entry);
|
|||
|
(_a2 = this._listeners.get(entry.target)) == null ? void 0 : _a2(entry);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
ResizeObserverSingleton.entries = "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0;
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/dom.js
|
|||
|
var is_hydrating = false;
|
|||
|
function start_hydrating() {
|
|||
|
is_hydrating = true;
|
|||
|
}
|
|||
|
function end_hydrating() {
|
|||
|
is_hydrating = false;
|
|||
|
}
|
|||
|
function append(target, node) {
|
|||
|
target.appendChild(node);
|
|||
|
}
|
|||
|
function append_styles(target, style_sheet_id, styles) {
|
|||
|
const append_styles_to = get_root_for_style(target);
|
|||
|
if (!append_styles_to.getElementById(style_sheet_id)) {
|
|||
|
const style = element("style");
|
|||
|
style.id = style_sheet_id;
|
|||
|
style.textContent = styles;
|
|||
|
append_stylesheet(append_styles_to, style);
|
|||
|
}
|
|||
|
}
|
|||
|
function get_root_for_style(node) {
|
|||
|
if (!node)
|
|||
|
return document;
|
|||
|
const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
|
|||
|
if (root && /** @type {ShadowRoot} */
|
|||
|
root.host) {
|
|||
|
return (
|
|||
|
/** @type {ShadowRoot} */
|
|||
|
root
|
|||
|
);
|
|||
|
}
|
|||
|
return node.ownerDocument;
|
|||
|
}
|
|||
|
function append_stylesheet(node, style) {
|
|||
|
append(
|
|||
|
/** @type {Document} */
|
|||
|
node.head || node,
|
|||
|
style
|
|||
|
);
|
|||
|
return style.sheet;
|
|||
|
}
|
|||
|
function insert(target, node, anchor) {
|
|||
|
target.insertBefore(node, anchor || null);
|
|||
|
}
|
|||
|
function detach(node) {
|
|||
|
if (node.parentNode) {
|
|||
|
node.parentNode.removeChild(node);
|
|||
|
}
|
|||
|
}
|
|||
|
function destroy_each(iterations, detaching) {
|
|||
|
for (let i = 0; i < iterations.length; i += 1) {
|
|||
|
if (iterations[i])
|
|||
|
iterations[i].d(detaching);
|
|||
|
}
|
|||
|
}
|
|||
|
function element(name) {
|
|||
|
return document.createElement(name);
|
|||
|
}
|
|||
|
function svg_element(name) {
|
|||
|
return document.createElementNS("http://www.w3.org/2000/svg", name);
|
|||
|
}
|
|||
|
function text(data) {
|
|||
|
return document.createTextNode(data);
|
|||
|
}
|
|||
|
function space() {
|
|||
|
return text(" ");
|
|||
|
}
|
|||
|
function empty() {
|
|||
|
return text("");
|
|||
|
}
|
|||
|
function listen(node, event, handler, options) {
|
|||
|
node.addEventListener(event, handler, options);
|
|||
|
return () => node.removeEventListener(event, handler, options);
|
|||
|
}
|
|||
|
function prevent_default(fn) {
|
|||
|
return function(event) {
|
|||
|
event.preventDefault();
|
|||
|
return fn.call(this, event);
|
|||
|
};
|
|||
|
}
|
|||
|
function attr(node, attribute, value) {
|
|||
|
if (value == null)
|
|||
|
node.removeAttribute(attribute);
|
|||
|
else if (node.getAttribute(attribute) !== value)
|
|||
|
node.setAttribute(attribute, value);
|
|||
|
}
|
|||
|
function set_svg_attributes(node, attributes) {
|
|||
|
for (const key in attributes) {
|
|||
|
attr(node, key, attributes[key]);
|
|||
|
}
|
|||
|
}
|
|||
|
function children(element2) {
|
|||
|
return Array.from(element2.childNodes);
|
|||
|
}
|
|||
|
function set_data(text2, data) {
|
|||
|
data = "" + data;
|
|||
|
if (text2.data === data)
|
|||
|
return;
|
|||
|
text2.data = /** @type {string} */
|
|||
|
data;
|
|||
|
}
|
|||
|
function set_input_value(input, value) {
|
|||
|
input.value = value == null ? "" : value;
|
|||
|
}
|
|||
|
function select_option(select, value, mounting) {
|
|||
|
for (let i = 0; i < select.options.length; i += 1) {
|
|||
|
const option = select.options[i];
|
|||
|
if (option.__value === value) {
|
|||
|
option.selected = true;
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!mounting || value !== void 0) {
|
|||
|
select.selectedIndex = -1;
|
|||
|
}
|
|||
|
}
|
|||
|
function select_value(select) {
|
|||
|
const selected_option = select.querySelector(":checked");
|
|||
|
return selected_option && selected_option.__value;
|
|||
|
}
|
|||
|
function toggle_class(element2, name, toggle) {
|
|||
|
element2.classList.toggle(name, !!toggle);
|
|||
|
}
|
|||
|
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|||
|
return new CustomEvent(type, { detail, bubbles, cancelable });
|
|||
|
}
|
|||
|
function get_custom_elements_slots(element2) {
|
|||
|
const result = {};
|
|||
|
element2.childNodes.forEach(
|
|||
|
/** @param {Element} node */
|
|||
|
(node) => {
|
|||
|
result[node.slot || "default"] = true;
|
|||
|
}
|
|||
|
);
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/lifecycle.js
|
|||
|
var current_component;
|
|||
|
function set_current_component(component) {
|
|||
|
current_component = component;
|
|||
|
}
|
|||
|
function get_current_component() {
|
|||
|
if (!current_component)
|
|||
|
throw new Error("Function called outside component initialization");
|
|||
|
return current_component;
|
|||
|
}
|
|||
|
function onDestroy(fn) {
|
|||
|
get_current_component().$$.on_destroy.push(fn);
|
|||
|
}
|
|||
|
function createEventDispatcher() {
|
|||
|
const component = get_current_component();
|
|||
|
return (type, detail, { cancelable = false } = {}) => {
|
|||
|
const callbacks = component.$$.callbacks[type];
|
|||
|
if (callbacks) {
|
|||
|
const event = custom_event(
|
|||
|
/** @type {string} */
|
|||
|
type,
|
|||
|
detail,
|
|||
|
{ cancelable }
|
|||
|
);
|
|||
|
callbacks.slice().forEach((fn) => {
|
|||
|
fn.call(component, event);
|
|||
|
});
|
|||
|
return !event.defaultPrevented;
|
|||
|
}
|
|||
|
return true;
|
|||
|
};
|
|||
|
}
|
|||
|
function bubble(component, event) {
|
|||
|
const callbacks = component.$$.callbacks[event.type];
|
|||
|
if (callbacks) {
|
|||
|
callbacks.slice().forEach((fn) => fn.call(this, event));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/scheduler.js
|
|||
|
var dirty_components = [];
|
|||
|
var binding_callbacks = [];
|
|||
|
var render_callbacks = [];
|
|||
|
var flush_callbacks = [];
|
|||
|
var resolved_promise = /* @__PURE__ */ Promise.resolve();
|
|||
|
var update_scheduled = false;
|
|||
|
function schedule_update() {
|
|||
|
if (!update_scheduled) {
|
|||
|
update_scheduled = true;
|
|||
|
resolved_promise.then(flush);
|
|||
|
}
|
|||
|
}
|
|||
|
function add_render_callback(fn) {
|
|||
|
render_callbacks.push(fn);
|
|||
|
}
|
|||
|
function add_flush_callback(fn) {
|
|||
|
flush_callbacks.push(fn);
|
|||
|
}
|
|||
|
var seen_callbacks = /* @__PURE__ */ new Set();
|
|||
|
var flushidx = 0;
|
|||
|
function flush() {
|
|||
|
if (flushidx !== 0) {
|
|||
|
return;
|
|||
|
}
|
|||
|
const saved_component = current_component;
|
|||
|
do {
|
|||
|
try {
|
|||
|
while (flushidx < dirty_components.length) {
|
|||
|
const component = dirty_components[flushidx];
|
|||
|
flushidx++;
|
|||
|
set_current_component(component);
|
|||
|
update(component.$$);
|
|||
|
}
|
|||
|
} catch (e) {
|
|||
|
dirty_components.length = 0;
|
|||
|
flushidx = 0;
|
|||
|
throw e;
|
|||
|
}
|
|||
|
set_current_component(null);
|
|||
|
dirty_components.length = 0;
|
|||
|
flushidx = 0;
|
|||
|
while (binding_callbacks.length)
|
|||
|
binding_callbacks.pop()();
|
|||
|
for (let i = 0; i < render_callbacks.length; i += 1) {
|
|||
|
const callback = render_callbacks[i];
|
|||
|
if (!seen_callbacks.has(callback)) {
|
|||
|
seen_callbacks.add(callback);
|
|||
|
callback();
|
|||
|
}
|
|||
|
}
|
|||
|
render_callbacks.length = 0;
|
|||
|
} while (dirty_components.length);
|
|||
|
while (flush_callbacks.length) {
|
|||
|
flush_callbacks.pop()();
|
|||
|
}
|
|||
|
update_scheduled = false;
|
|||
|
seen_callbacks.clear();
|
|||
|
set_current_component(saved_component);
|
|||
|
}
|
|||
|
function update($$) {
|
|||
|
if ($$.fragment !== null) {
|
|||
|
$$.update();
|
|||
|
run_all($$.before_update);
|
|||
|
const dirty = $$.dirty;
|
|||
|
$$.dirty = [-1];
|
|||
|
$$.fragment && $$.fragment.p($$.ctx, dirty);
|
|||
|
$$.after_update.forEach(add_render_callback);
|
|||
|
}
|
|||
|
}
|
|||
|
function flush_render_callbacks(fns) {
|
|||
|
const filtered = [];
|
|||
|
const targets = [];
|
|||
|
render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
|
|||
|
targets.forEach((c) => c());
|
|||
|
render_callbacks = filtered;
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/transitions.js
|
|||
|
var outroing = /* @__PURE__ */ new Set();
|
|||
|
var outros;
|
|||
|
function group_outros() {
|
|||
|
outros = {
|
|||
|
r: 0,
|
|||
|
c: [],
|
|||
|
p: outros
|
|||
|
// parent group
|
|||
|
};
|
|||
|
}
|
|||
|
function check_outros() {
|
|||
|
if (!outros.r) {
|
|||
|
run_all(outros.c);
|
|||
|
}
|
|||
|
outros = outros.p;
|
|||
|
}
|
|||
|
function transition_in(block, local) {
|
|||
|
if (block && block.i) {
|
|||
|
outroing.delete(block);
|
|||
|
block.i(local);
|
|||
|
}
|
|||
|
}
|
|||
|
function transition_out(block, local, detach2, callback) {
|
|||
|
if (block && block.o) {
|
|||
|
if (outroing.has(block))
|
|||
|
return;
|
|||
|
outroing.add(block);
|
|||
|
outros.c.push(() => {
|
|||
|
outroing.delete(block);
|
|||
|
if (callback) {
|
|||
|
if (detach2)
|
|||
|
block.d(1);
|
|||
|
callback();
|
|||
|
}
|
|||
|
});
|
|||
|
block.o(local);
|
|||
|
} else if (callback) {
|
|||
|
callback();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/each.js
|
|||
|
function ensure_array_like(array_like_or_iterator) {
|
|||
|
return (array_like_or_iterator == null ? void 0 : array_like_or_iterator.length) !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/spread.js
|
|||
|
function get_spread_update(levels, updates) {
|
|||
|
const update2 = {};
|
|||
|
const to_null_out = {};
|
|||
|
const accounted_for = { $$scope: 1 };
|
|||
|
let i = levels.length;
|
|||
|
while (i--) {
|
|||
|
const o = levels[i];
|
|||
|
const n = updates[i];
|
|||
|
if (n) {
|
|||
|
for (const key in o) {
|
|||
|
if (!(key in n))
|
|||
|
to_null_out[key] = 1;
|
|||
|
}
|
|||
|
for (const key in n) {
|
|||
|
if (!accounted_for[key]) {
|
|||
|
update2[key] = n[key];
|
|||
|
accounted_for[key] = 1;
|
|||
|
}
|
|||
|
}
|
|||
|
levels[i] = n;
|
|||
|
} else {
|
|||
|
for (const key in o) {
|
|||
|
accounted_for[key] = 1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
for (const key in to_null_out) {
|
|||
|
if (!(key in update2))
|
|||
|
update2[key] = void 0;
|
|||
|
}
|
|||
|
return update2;
|
|||
|
}
|
|||
|
function get_spread_object(spread_props) {
|
|||
|
return typeof spread_props === "object" && spread_props !== null ? spread_props : {};
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/svelte/src/shared/boolean_attributes.js
|
|||
|
var _boolean_attributes = (
|
|||
|
/** @type {const} */
|
|||
|
[
|
|||
|
"allowfullscreen",
|
|||
|
"allowpaymentrequest",
|
|||
|
"async",
|
|||
|
"autofocus",
|
|||
|
"autoplay",
|
|||
|
"checked",
|
|||
|
"controls",
|
|||
|
"default",
|
|||
|
"defer",
|
|||
|
"disabled",
|
|||
|
"formnovalidate",
|
|||
|
"hidden",
|
|||
|
"inert",
|
|||
|
"ismap",
|
|||
|
"loop",
|
|||
|
"multiple",
|
|||
|
"muted",
|
|||
|
"nomodule",
|
|||
|
"novalidate",
|
|||
|
"open",
|
|||
|
"playsinline",
|
|||
|
"readonly",
|
|||
|
"required",
|
|||
|
"reversed",
|
|||
|
"selected"
|
|||
|
]
|
|||
|
);
|
|||
|
var boolean_attributes = /* @__PURE__ */ new Set([..._boolean_attributes]);
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/Component.js
|
|||
|
function bind(component, name, callback) {
|
|||
|
const index = component.$$.props[name];
|
|||
|
if (index !== void 0) {
|
|||
|
component.$$.bound[index] = callback;
|
|||
|
callback(component.$$.ctx[index]);
|
|||
|
}
|
|||
|
}
|
|||
|
function create_component(block) {
|
|||
|
block && block.c();
|
|||
|
}
|
|||
|
function mount_component(component, target, anchor) {
|
|||
|
const { fragment, after_update } = component.$$;
|
|||
|
fragment && fragment.m(target, anchor);
|
|||
|
add_render_callback(() => {
|
|||
|
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
|
|||
|
if (component.$$.on_destroy) {
|
|||
|
component.$$.on_destroy.push(...new_on_destroy);
|
|||
|
} else {
|
|||
|
run_all(new_on_destroy);
|
|||
|
}
|
|||
|
component.$$.on_mount = [];
|
|||
|
});
|
|||
|
after_update.forEach(add_render_callback);
|
|||
|
}
|
|||
|
function destroy_component(component, detaching) {
|
|||
|
const $$ = component.$$;
|
|||
|
if ($$.fragment !== null) {
|
|||
|
flush_render_callbacks($$.after_update);
|
|||
|
run_all($$.on_destroy);
|
|||
|
$$.fragment && $$.fragment.d(detaching);
|
|||
|
$$.on_destroy = $$.fragment = null;
|
|||
|
$$.ctx = [];
|
|||
|
}
|
|||
|
}
|
|||
|
function make_dirty(component, i) {
|
|||
|
if (component.$$.dirty[0] === -1) {
|
|||
|
dirty_components.push(component);
|
|||
|
schedule_update();
|
|||
|
component.$$.dirty.fill(0);
|
|||
|
}
|
|||
|
component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
|
|||
|
}
|
|||
|
function init(component, options, instance9, create_fragment9, not_equal, props, append_styles2, dirty = [-1]) {
|
|||
|
const parent_component = current_component;
|
|||
|
set_current_component(component);
|
|||
|
const $$ = component.$$ = {
|
|||
|
fragment: null,
|
|||
|
ctx: [],
|
|||
|
// state
|
|||
|
props,
|
|||
|
update: noop,
|
|||
|
not_equal,
|
|||
|
bound: blank_object(),
|
|||
|
// lifecycle
|
|||
|
on_mount: [],
|
|||
|
on_destroy: [],
|
|||
|
on_disconnect: [],
|
|||
|
before_update: [],
|
|||
|
after_update: [],
|
|||
|
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
|
|||
|
// everything else
|
|||
|
callbacks: blank_object(),
|
|||
|
dirty,
|
|||
|
skip_bound: false,
|
|||
|
root: options.target || parent_component.$$.root
|
|||
|
};
|
|||
|
append_styles2 && append_styles2($$.root);
|
|||
|
let ready = false;
|
|||
|
$$.ctx = instance9 ? instance9(component, options.props || {}, (i, ret, ...rest) => {
|
|||
|
const value = rest.length ? rest[0] : ret;
|
|||
|
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
|
|||
|
if (!$$.skip_bound && $$.bound[i])
|
|||
|
$$.bound[i](value);
|
|||
|
if (ready)
|
|||
|
make_dirty(component, i);
|
|||
|
}
|
|||
|
return ret;
|
|||
|
}) : [];
|
|||
|
$$.update();
|
|||
|
ready = true;
|
|||
|
run_all($$.before_update);
|
|||
|
$$.fragment = create_fragment9 ? create_fragment9($$.ctx) : false;
|
|||
|
if (options.target) {
|
|||
|
if (options.hydrate) {
|
|||
|
start_hydrating();
|
|||
|
const nodes = children(options.target);
|
|||
|
$$.fragment && $$.fragment.l(nodes);
|
|||
|
nodes.forEach(detach);
|
|||
|
} else {
|
|||
|
$$.fragment && $$.fragment.c();
|
|||
|
}
|
|||
|
if (options.intro)
|
|||
|
transition_in(component.$$.fragment);
|
|||
|
mount_component(component, options.target, options.anchor);
|
|||
|
end_hydrating();
|
|||
|
flush();
|
|||
|
}
|
|||
|
set_current_component(parent_component);
|
|||
|
}
|
|||
|
var SvelteElement;
|
|||
|
if (typeof HTMLElement === "function") {
|
|||
|
SvelteElement = class extends HTMLElement {
|
|||
|
constructor($$componentCtor, $$slots, use_shadow_dom) {
|
|||
|
super();
|
|||
|
/** The Svelte component constructor */
|
|||
|
__publicField(this, "$$ctor");
|
|||
|
/** Slots */
|
|||
|
__publicField(this, "$$s");
|
|||
|
/** The Svelte component instance */
|
|||
|
__publicField(this, "$$c");
|
|||
|
/** Whether or not the custom element is connected */
|
|||
|
__publicField(this, "$$cn", false);
|
|||
|
/** Component props data */
|
|||
|
__publicField(this, "$$d", {});
|
|||
|
/** `true` if currently in the process of reflecting component props back to attributes */
|
|||
|
__publicField(this, "$$r", false);
|
|||
|
/** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
|
|||
|
__publicField(this, "$$p_d", {});
|
|||
|
/** @type {Record<string, Function[]>} Event listeners */
|
|||
|
__publicField(this, "$$l", {});
|
|||
|
/** @type {Map<Function, Function>} Event listener unsubscribe functions */
|
|||
|
__publicField(this, "$$l_u", /* @__PURE__ */ new Map());
|
|||
|
this.$$ctor = $$componentCtor;
|
|||
|
this.$$s = $$slots;
|
|||
|
if (use_shadow_dom) {
|
|||
|
this.attachShadow({ mode: "open" });
|
|||
|
}
|
|||
|
}
|
|||
|
addEventListener(type, listener, options) {
|
|||
|
this.$$l[type] = this.$$l[type] || [];
|
|||
|
this.$$l[type].push(listener);
|
|||
|
if (this.$$c) {
|
|||
|
const unsub = this.$$c.$on(type, listener);
|
|||
|
this.$$l_u.set(listener, unsub);
|
|||
|
}
|
|||
|
super.addEventListener(type, listener, options);
|
|||
|
}
|
|||
|
removeEventListener(type, listener, options) {
|
|||
|
super.removeEventListener(type, listener, options);
|
|||
|
if (this.$$c) {
|
|||
|
const unsub = this.$$l_u.get(listener);
|
|||
|
if (unsub) {
|
|||
|
unsub();
|
|||
|
this.$$l_u.delete(listener);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
async connectedCallback() {
|
|||
|
this.$$cn = true;
|
|||
|
if (!this.$$c) {
|
|||
|
let create_slot2 = function(name) {
|
|||
|
return () => {
|
|||
|
let node;
|
|||
|
const obj = {
|
|||
|
c: function create() {
|
|||
|
node = element("slot");
|
|||
|
if (name !== "default") {
|
|||
|
attr(node, "name", name);
|
|||
|
}
|
|||
|
},
|
|||
|
/**
|
|||
|
* @param {HTMLElement} target
|
|||
|
* @param {HTMLElement} [anchor]
|
|||
|
*/
|
|||
|
m: function mount(target, anchor) {
|
|||
|
insert(target, node, anchor);
|
|||
|
},
|
|||
|
d: function destroy(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(node);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
return obj;
|
|||
|
};
|
|||
|
};
|
|||
|
await Promise.resolve();
|
|||
|
if (!this.$$cn) {
|
|||
|
return;
|
|||
|
}
|
|||
|
const $$slots = {};
|
|||
|
const existing_slots = get_custom_elements_slots(this);
|
|||
|
for (const name of this.$$s) {
|
|||
|
if (name in existing_slots) {
|
|||
|
$$slots[name] = [create_slot2(name)];
|
|||
|
}
|
|||
|
}
|
|||
|
for (const attribute of this.attributes) {
|
|||
|
const name = this.$$g_p(attribute.name);
|
|||
|
if (!(name in this.$$d)) {
|
|||
|
this.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, "toProp");
|
|||
|
}
|
|||
|
}
|
|||
|
this.$$c = new this.$$ctor({
|
|||
|
target: this.shadowRoot || this,
|
|||
|
props: {
|
|||
|
...this.$$d,
|
|||
|
$$slots,
|
|||
|
$$scope: {
|
|||
|
ctx: []
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
const reflect_attributes = () => {
|
|||
|
this.$$r = true;
|
|||
|
for (const key in this.$$p_d) {
|
|||
|
this.$$d[key] = this.$$c.$$.ctx[this.$$c.$$.props[key]];
|
|||
|
if (this.$$p_d[key].reflect) {
|
|||
|
const attribute_value = get_custom_element_value(
|
|||
|
key,
|
|||
|
this.$$d[key],
|
|||
|
this.$$p_d,
|
|||
|
"toAttribute"
|
|||
|
);
|
|||
|
if (attribute_value == null) {
|
|||
|
this.removeAttribute(key);
|
|||
|
} else {
|
|||
|
this.setAttribute(this.$$p_d[key].attribute || key, attribute_value);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
this.$$r = false;
|
|||
|
};
|
|||
|
this.$$c.$$.after_update.push(reflect_attributes);
|
|||
|
reflect_attributes();
|
|||
|
for (const type in this.$$l) {
|
|||
|
for (const listener of this.$$l[type]) {
|
|||
|
const unsub = this.$$c.$on(type, listener);
|
|||
|
this.$$l_u.set(listener, unsub);
|
|||
|
}
|
|||
|
}
|
|||
|
this.$$l = {};
|
|||
|
}
|
|||
|
}
|
|||
|
// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
|
|||
|
// and setting attributes through setAttribute etc, this is helpful
|
|||
|
attributeChangedCallback(attr2, _oldValue, newValue) {
|
|||
|
var _a;
|
|||
|
if (this.$$r)
|
|||
|
return;
|
|||
|
attr2 = this.$$g_p(attr2);
|
|||
|
this.$$d[attr2] = get_custom_element_value(attr2, newValue, this.$$p_d, "toProp");
|
|||
|
(_a = this.$$c) == null ? void 0 : _a.$set({ [attr2]: this.$$d[attr2] });
|
|||
|
}
|
|||
|
disconnectedCallback() {
|
|||
|
this.$$cn = false;
|
|||
|
Promise.resolve().then(() => {
|
|||
|
if (!this.$$cn) {
|
|||
|
this.$$c.$destroy();
|
|||
|
this.$$c = void 0;
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
$$g_p(attribute_name) {
|
|||
|
return Object.keys(this.$$p_d).find(
|
|||
|
(key) => this.$$p_d[key].attribute === attribute_name || !this.$$p_d[key].attribute && key.toLowerCase() === attribute_name
|
|||
|
) || attribute_name;
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function get_custom_element_value(prop, value, props_definition, transform) {
|
|||
|
var _a;
|
|||
|
const type = (_a = props_definition[prop]) == null ? void 0 : _a.type;
|
|||
|
value = type === "Boolean" && typeof value !== "boolean" ? value != null : value;
|
|||
|
if (!transform || !props_definition[prop]) {
|
|||
|
return value;
|
|||
|
} else if (transform === "toAttribute") {
|
|||
|
switch (type) {
|
|||
|
case "Object":
|
|||
|
case "Array":
|
|||
|
return value == null ? null : JSON.stringify(value);
|
|||
|
case "Boolean":
|
|||
|
return value ? "" : null;
|
|||
|
case "Number":
|
|||
|
return value == null ? null : value;
|
|||
|
default:
|
|||
|
return value;
|
|||
|
}
|
|||
|
} else {
|
|||
|
switch (type) {
|
|||
|
case "Object":
|
|||
|
case "Array":
|
|||
|
return value && JSON.parse(value);
|
|||
|
case "Boolean":
|
|||
|
return value;
|
|||
|
case "Number":
|
|||
|
return value != null ? +value : value;
|
|||
|
default:
|
|||
|
return value;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
var SvelteComponent = class {
|
|||
|
constructor() {
|
|||
|
/**
|
|||
|
* ### PRIVATE API
|
|||
|
*
|
|||
|
* Do not use, may change at any time
|
|||
|
*
|
|||
|
* @type {any}
|
|||
|
*/
|
|||
|
__publicField(this, "$$");
|
|||
|
/**
|
|||
|
* ### PRIVATE API
|
|||
|
*
|
|||
|
* Do not use, may change at any time
|
|||
|
*
|
|||
|
* @type {any}
|
|||
|
*/
|
|||
|
__publicField(this, "$$set");
|
|||
|
}
|
|||
|
/** @returns {void} */
|
|||
|
$destroy() {
|
|||
|
destroy_component(this, 1);
|
|||
|
this.$destroy = noop;
|
|||
|
}
|
|||
|
/**
|
|||
|
* @template {Extract<keyof Events, string>} K
|
|||
|
* @param {K} type
|
|||
|
* @param {((e: Events[K]) => void) | null | undefined} callback
|
|||
|
* @returns {() => void}
|
|||
|
*/
|
|||
|
$on(type, callback) {
|
|||
|
if (!is_function(callback)) {
|
|||
|
return noop;
|
|||
|
}
|
|||
|
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
|
|||
|
callbacks.push(callback);
|
|||
|
return () => {
|
|||
|
const index = callbacks.indexOf(callback);
|
|||
|
if (index !== -1)
|
|||
|
callbacks.splice(index, 1);
|
|||
|
};
|
|||
|
}
|
|||
|
/**
|
|||
|
* @param {Partial<Props>} props
|
|||
|
* @returns {void}
|
|||
|
*/
|
|||
|
$set(props) {
|
|||
|
if (this.$$set && !is_empty(props)) {
|
|||
|
this.$$.skip_bound = true;
|
|||
|
this.$$set(props);
|
|||
|
this.$$.skip_bound = false;
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// node_modules/svelte/src/shared/version.js
|
|||
|
var PUBLIC_VERSION = "4";
|
|||
|
|
|||
|
// node_modules/svelte/src/runtime/internal/disclose-version/index.js
|
|||
|
if (typeof window !== "undefined")
|
|||
|
(window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
|
|||
|
|
|||
|
// src/types.ts
|
|||
|
var QUERY_TYPES = ["Default", "Dataview", "Regex"];
|
|||
|
var OPEN_TYPES = ["Active Leaf", "New Leaf", "New Window"];
|
|||
|
var QUERY_OPEN_TYPES = ["Default", "Active Leaf", "New Leaf", "New Window"];
|
|||
|
|
|||
|
// src/gui/modals/OpenRandomNoteModal/OpenRandomNoteModal.svelte
|
|||
|
function add_css(target) {
|
|||
|
append_styles(target, "svelte-1wv2i3", "form.svelte-1wv2i3{display:flex;flex-direction:column;gap:1em}button.svelte-1wv2i3{max-width:max-content}");
|
|||
|
}
|
|||
|
function get_each_context(ctx, list, i) {
|
|||
|
const child_ctx = ctx.slice();
|
|||
|
child_ctx[5] = list[i];
|
|||
|
return child_ctx;
|
|||
|
}
|
|||
|
function create_else_block(ctx) {
|
|||
|
let p;
|
|||
|
return {
|
|||
|
c() {
|
|||
|
p = element("p");
|
|||
|
p.textContent = "Go to settings tab to make search queries.";
|
|||
|
attr(p, "class", "setting-item-description");
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, p, anchor);
|
|||
|
},
|
|||
|
p: noop,
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(p);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_if_block(ctx) {
|
|||
|
let form;
|
|||
|
let select;
|
|||
|
let t0;
|
|||
|
let button;
|
|||
|
let mounted;
|
|||
|
let dispose;
|
|||
|
let each_value = ensure_array_like(
|
|||
|
/*queries*/
|
|||
|
ctx[0]
|
|||
|
);
|
|||
|
let each_blocks = [];
|
|||
|
for (let i = 0; i < each_value.length; i += 1) {
|
|||
|
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
|
|||
|
}
|
|||
|
return {
|
|||
|
c() {
|
|||
|
form = element("form");
|
|||
|
select = element("select");
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].c();
|
|||
|
}
|
|||
|
t0 = space();
|
|||
|
button = element("button");
|
|||
|
button.textContent = "Find Random Note";
|
|||
|
attr(select, "class", "dropdown");
|
|||
|
if (
|
|||
|
/*selectedQuery*/
|
|||
|
ctx[1] === void 0
|
|||
|
)
|
|||
|
add_render_callback(() => (
|
|||
|
/*select_change_handler*/
|
|||
|
ctx[4].call(select)
|
|||
|
));
|
|||
|
attr(button, "class", "mod-cta svelte-1wv2i3");
|
|||
|
attr(button, "type", "submit");
|
|||
|
attr(form, "class", "svelte-1wv2i3");
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, form, anchor);
|
|||
|
append(form, select);
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].m(select, null);
|
|||
|
}
|
|||
|
}
|
|||
|
select_option(
|
|||
|
select,
|
|||
|
/*selectedQuery*/
|
|||
|
ctx[1],
|
|||
|
true
|
|||
|
);
|
|||
|
append(form, t0);
|
|||
|
append(form, button);
|
|||
|
if (!mounted) {
|
|||
|
dispose = [
|
|||
|
listen(
|
|||
|
select,
|
|||
|
"change",
|
|||
|
/*select_change_handler*/
|
|||
|
ctx[4]
|
|||
|
),
|
|||
|
listen(form, "submit", prevent_default(
|
|||
|
/*handleFormSubmit*/
|
|||
|
ctx[2]
|
|||
|
))
|
|||
|
];
|
|||
|
mounted = true;
|
|||
|
}
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
if (dirty & /*queries*/
|
|||
|
1) {
|
|||
|
each_value = ensure_array_like(
|
|||
|
/*queries*/
|
|||
|
ctx2[0]
|
|||
|
);
|
|||
|
let i;
|
|||
|
for (i = 0; i < each_value.length; i += 1) {
|
|||
|
const child_ctx = get_each_context(ctx2, each_value, i);
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].p(child_ctx, dirty);
|
|||
|
} else {
|
|||
|
each_blocks[i] = create_each_block(child_ctx);
|
|||
|
each_blocks[i].c();
|
|||
|
each_blocks[i].m(select, null);
|
|||
|
}
|
|||
|
}
|
|||
|
for (; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].d(1);
|
|||
|
}
|
|||
|
each_blocks.length = each_value.length;
|
|||
|
}
|
|||
|
if (dirty & /*selectedQuery, queries*/
|
|||
|
3) {
|
|||
|
select_option(
|
|||
|
select,
|
|||
|
/*selectedQuery*/
|
|||
|
ctx2[1]
|
|||
|
);
|
|||
|
}
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(form);
|
|||
|
}
|
|||
|
destroy_each(each_blocks, detaching);
|
|||
|
mounted = false;
|
|||
|
run_all(dispose);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_each_block(ctx) {
|
|||
|
let option;
|
|||
|
let t_value = (
|
|||
|
/*query*/
|
|||
|
ctx[5].name + ""
|
|||
|
);
|
|||
|
let t;
|
|||
|
let option_value_value;
|
|||
|
return {
|
|||
|
c() {
|
|||
|
option = element("option");
|
|||
|
t = text(t_value);
|
|||
|
option.__value = option_value_value = /*query*/
|
|||
|
ctx[5];
|
|||
|
set_input_value(option, option.__value);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, option, anchor);
|
|||
|
append(option, t);
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
if (dirty & /*queries*/
|
|||
|
1 && t_value !== (t_value = /*query*/
|
|||
|
ctx2[5].name + ""))
|
|||
|
set_data(t, t_value);
|
|||
|
if (dirty & /*queries*/
|
|||
|
1 && option_value_value !== (option_value_value = /*query*/
|
|||
|
ctx2[5])) {
|
|||
|
option.__value = option_value_value;
|
|||
|
set_input_value(option, option.__value);
|
|||
|
}
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(option);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_fragment(ctx) {
|
|||
|
let h3;
|
|||
|
let t1;
|
|||
|
let if_block_anchor;
|
|||
|
function select_block_type(ctx2, dirty) {
|
|||
|
if (
|
|||
|
/*queries*/
|
|||
|
ctx2[0].length > 0
|
|||
|
)
|
|||
|
return create_if_block;
|
|||
|
return create_else_block;
|
|||
|
}
|
|||
|
let current_block_type = select_block_type(ctx, -1);
|
|||
|
let if_block = current_block_type(ctx);
|
|||
|
return {
|
|||
|
c() {
|
|||
|
h3 = element("h3");
|
|||
|
h3.textContent = "Select Random Note Query";
|
|||
|
t1 = space();
|
|||
|
if_block.c();
|
|||
|
if_block_anchor = empty();
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, h3, anchor);
|
|||
|
insert(target, t1, anchor);
|
|||
|
if_block.m(target, anchor);
|
|||
|
insert(target, if_block_anchor, anchor);
|
|||
|
},
|
|||
|
p(ctx2, [dirty]) {
|
|||
|
if (current_block_type === (current_block_type = select_block_type(ctx2, dirty)) && if_block) {
|
|||
|
if_block.p(ctx2, dirty);
|
|||
|
} else {
|
|||
|
if_block.d(1);
|
|||
|
if_block = current_block_type(ctx2);
|
|||
|
if (if_block) {
|
|||
|
if_block.c();
|
|||
|
if_block.m(if_block_anchor.parentNode, if_block_anchor);
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
i: noop,
|
|||
|
o: noop,
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(h3);
|
|||
|
detach(t1);
|
|||
|
detach(if_block_anchor);
|
|||
|
}
|
|||
|
if_block.d(detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function instance($$self, $$props, $$invalidate) {
|
|||
|
let { queries } = $$props;
|
|||
|
let { handleSubmit } = $$props;
|
|||
|
let selectedQuery;
|
|||
|
const handleFormSubmit = () => {
|
|||
|
handleSubmit(selectedQuery);
|
|||
|
};
|
|||
|
function select_change_handler() {
|
|||
|
selectedQuery = select_value(this);
|
|||
|
$$invalidate(1, selectedQuery);
|
|||
|
$$invalidate(0, queries);
|
|||
|
}
|
|||
|
$$self.$$set = ($$props2) => {
|
|||
|
if ("queries" in $$props2)
|
|||
|
$$invalidate(0, queries = $$props2.queries);
|
|||
|
if ("handleSubmit" in $$props2)
|
|||
|
$$invalidate(3, handleSubmit = $$props2.handleSubmit);
|
|||
|
};
|
|||
|
return [queries, selectedQuery, handleFormSubmit, handleSubmit, select_change_handler];
|
|||
|
}
|
|||
|
var OpenRandomNoteModal = class extends SvelteComponent {
|
|||
|
constructor(options) {
|
|||
|
super();
|
|||
|
init(this, options, instance, create_fragment, safe_not_equal, { queries: 0, handleSubmit: 3 }, add_css);
|
|||
|
}
|
|||
|
};
|
|||
|
var OpenRandomNoteModal_default = OpenRandomNoteModal;
|
|||
|
|
|||
|
// src/gui/modals/OpenRandomNoteModal/openRandomNoteModal.ts
|
|||
|
var RandomNoteModal = class extends import_obsidian.Modal {
|
|||
|
constructor(app, queries, submitCallback) {
|
|||
|
super(app);
|
|||
|
this.submitCallback = void 0;
|
|||
|
this.handleSubmit = (query) => {
|
|||
|
if (this.submitCallback) {
|
|||
|
this.submitCallback(query);
|
|||
|
}
|
|||
|
this.close();
|
|||
|
};
|
|||
|
this.queries = queries;
|
|||
|
this.view = new OpenRandomNoteModal_default({
|
|||
|
target: this.contentEl,
|
|||
|
props: { queries, handleSubmit: this.handleSubmit }
|
|||
|
});
|
|||
|
this.submitCallback = submitCallback;
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// src/search.ts
|
|||
|
var import_obsidian3 = require("obsidian");
|
|||
|
var import_obsidian_dataview = __toESM(require_lib());
|
|||
|
|
|||
|
// src/utilities.ts
|
|||
|
var import_obsidian2 = require("obsidian");
|
|||
|
|
|||
|
// node_modules/uuid/dist/esm-browser/rng.js
|
|||
|
var getRandomValues;
|
|||
|
var rnds8 = new Uint8Array(16);
|
|||
|
function rng() {
|
|||
|
if (!getRandomValues) {
|
|||
|
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|||
|
if (!getRandomValues) {
|
|||
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|||
|
}
|
|||
|
}
|
|||
|
return getRandomValues(rnds8);
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/uuid/dist/esm-browser/stringify.js
|
|||
|
var byteToHex = [];
|
|||
|
for (let i = 0; i < 256; ++i) {
|
|||
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|||
|
}
|
|||
|
function unsafeStringify(arr, offset = 0) {
|
|||
|
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|||
|
}
|
|||
|
|
|||
|
// node_modules/uuid/dist/esm-browser/native.js
|
|||
|
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|||
|
var native_default = {
|
|||
|
randomUUID
|
|||
|
};
|
|||
|
|
|||
|
// node_modules/uuid/dist/esm-browser/v4.js
|
|||
|
function v4(options, buf, offset) {
|
|||
|
if (native_default.randomUUID && !buf && !options) {
|
|||
|
return native_default.randomUUID();
|
|||
|
}
|
|||
|
options = options || {};
|
|||
|
const rnds = options.random || (options.rng || rng)();
|
|||
|
rnds[6] = rnds[6] & 15 | 64;
|
|||
|
rnds[8] = rnds[8] & 63 | 128;
|
|||
|
if (buf) {
|
|||
|
offset = offset || 0;
|
|||
|
for (let i = 0; i < 16; ++i) {
|
|||
|
buf[offset + i] = rnds[i];
|
|||
|
}
|
|||
|
return buf;
|
|||
|
}
|
|||
|
return unsafeStringify(rnds);
|
|||
|
}
|
|||
|
var v4_default = v4;
|
|||
|
|
|||
|
// src/utilities.ts
|
|||
|
function getRandomElement(arr) {
|
|||
|
if (arr.length === 0)
|
|||
|
return null;
|
|||
|
const index = Math.floor(Math.random() * arr.length);
|
|||
|
return arr[index];
|
|||
|
}
|
|||
|
function addOrRemoveQueryCommand(plugin, query) {
|
|||
|
if (query.createCommand) {
|
|||
|
plugin.addQueryCommand(query);
|
|||
|
} else {
|
|||
|
plugin.removeQueryCommand(query);
|
|||
|
}
|
|||
|
}
|
|||
|
function findObsidianCommand(app, commandId) {
|
|||
|
return app.commands.findCommand(commandId);
|
|||
|
}
|
|||
|
function deleteObsidianCommand(app, commandId) {
|
|||
|
if (findObsidianCommand(app, commandId)) {
|
|||
|
delete app.commands.commands[commandId];
|
|||
|
delete app.commands.editorCommands[commandId];
|
|||
|
}
|
|||
|
}
|
|||
|
function getPluginCommandId(commandId, manifest) {
|
|||
|
return manifest.id + ":" + commandId;
|
|||
|
}
|
|||
|
function getTagString(tag) {
|
|||
|
if (tag.startsWith("!#")) {
|
|||
|
return tag.replace("!", "");
|
|||
|
} else if (tag.startsWith("!")) {
|
|||
|
return tag.replace("!", "#");
|
|||
|
} else if (tag.startsWith("#")) {
|
|||
|
return tag;
|
|||
|
} else {
|
|||
|
return "#" + tag;
|
|||
|
}
|
|||
|
}
|
|||
|
function getTagStrings(tags) {
|
|||
|
return tags.map((tag) => getTagString(tag));
|
|||
|
}
|
|||
|
function getQueryCommandId() {
|
|||
|
return "query:" + v4_default();
|
|||
|
}
|
|||
|
function createQuery(name, query) {
|
|||
|
return {
|
|||
|
id: getQueryCommandId(),
|
|||
|
name,
|
|||
|
query,
|
|||
|
type: "Default",
|
|||
|
createCommand: false,
|
|||
|
useDisabledFolders: true,
|
|||
|
openType: "Default"
|
|||
|
};
|
|||
|
}
|
|||
|
function flattenFiles(abstractFiles) {
|
|||
|
return abstractFiles.map((abstractFile) => flattenFile(abstractFile)).flat();
|
|||
|
}
|
|||
|
function flattenFile(abstractFile) {
|
|||
|
if (abstractFile instanceof import_obsidian2.TFolder) {
|
|||
|
return flattenFiles(abstractFile.children);
|
|||
|
}
|
|||
|
return [abstractFile];
|
|||
|
}
|
|||
|
function toRecord(arr) {
|
|||
|
const recordObject = {};
|
|||
|
arr.forEach((item) => recordObject[item] = item);
|
|||
|
return recordObject;
|
|||
|
}
|
|||
|
function getOpenTypeLabels() {
|
|||
|
return OPEN_TYPES.map((item) => item);
|
|||
|
}
|
|||
|
|
|||
|
// src/search.ts
|
|||
|
var Search = class {
|
|||
|
constructor(plugin) {
|
|||
|
this.searchFiles = async (files, disabledDisabledPaths) => {
|
|||
|
const result = files.filter((file) => !this.isInDisabledFolder(file, disabledDisabledPaths));
|
|||
|
if (result.length <= 0) {
|
|||
|
new import_obsidian3.Notice(
|
|||
|
"Advanced Random Note: Found zero files."
|
|||
|
);
|
|||
|
}
|
|||
|
return result;
|
|||
|
};
|
|||
|
this.plugin = plugin;
|
|||
|
}
|
|||
|
async search(query) {
|
|||
|
let result = [];
|
|||
|
if (query.type === "Dataview") {
|
|||
|
const api = (0, import_obsidian_dataview.getAPI)();
|
|||
|
if (!api) {
|
|||
|
new import_obsidian3.Notice(
|
|||
|
"Advanced Random Note: Dataview API could not be found, is Dataview installed?"
|
|||
|
);
|
|||
|
return [];
|
|||
|
}
|
|||
|
const dataviewResult = await (api == null ? void 0 : api.query(query.query));
|
|||
|
if (!dataviewResult || !(dataviewResult == null ? void 0 : dataviewResult.successful)) {
|
|||
|
new import_obsidian3.Notice(
|
|||
|
"Advanced Random Note: Error running dataview query"
|
|||
|
);
|
|||
|
return [];
|
|||
|
}
|
|||
|
if (dataviewResult.value.type !== "list") {
|
|||
|
new import_obsidian3.Notice(
|
|||
|
"Advanced Random Note: Dataview query is not a list"
|
|||
|
);
|
|||
|
return [];
|
|||
|
}
|
|||
|
result = dataviewResult.value.values.map(
|
|||
|
(value) => this.plugin.app.vault.getAbstractFileByPath(value.path)
|
|||
|
).filter((file) => file !== null && file instanceof import_obsidian3.TFile).map((file) => file);
|
|||
|
} else {
|
|||
|
const files = this.plugin.app.vault.getFiles();
|
|||
|
if (query.type === "Regex") {
|
|||
|
const regex = new RegExp(query.query);
|
|||
|
result = files.filter((file) => regex.test(file.path));
|
|||
|
} else {
|
|||
|
result = files.filter(
|
|||
|
(file) => this.checkFileToMatchQuery(file, query)
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
if (query.useDisabledFolders) {
|
|||
|
result = result.filter((file) => !this.isInDisabledFolder(file));
|
|||
|
if (result.length <= 0) {
|
|||
|
new import_obsidian3.Notice(
|
|||
|
"Advanced Random Note: Found zero files matching your query."
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
processQuery(query) {
|
|||
|
const regexResult = {
|
|||
|
path: /path:(.*?)(tag:|file:|$)/.exec(query.query),
|
|||
|
file: /file:(.*?)(tag:|path:|$)/.exec(query.query),
|
|||
|
tags: /tag:(.*?)(file:|path:|$)/.exec(query.query)
|
|||
|
};
|
|||
|
const path = regexResult.path ? regexResult.path[1].trim() : "";
|
|||
|
const file = regexResult.file ? regexResult.file[1].trim() : "";
|
|||
|
const tags = (regexResult.tags ? regexResult.tags[1].trim().split(" ") : []).map((tag) => {
|
|||
|
const trimmedTag = tag.trim();
|
|||
|
return {
|
|||
|
included: !trimmedTag.startsWith("!"),
|
|||
|
tag: getTagString(trimmedTag)
|
|||
|
};
|
|||
|
});
|
|||
|
const processedQuery = {
|
|||
|
path,
|
|||
|
file,
|
|||
|
tags
|
|||
|
};
|
|||
|
return processedQuery;
|
|||
|
}
|
|||
|
checkFileToMatchQuery(file, query) {
|
|||
|
const processedQuery = this.processQuery(query);
|
|||
|
return this.checkTagsWithFile(processedQuery.tags, file) && this.checkFilenameWithFile(processedQuery.file, file) && this.checkPathWithFile(processedQuery.path, file);
|
|||
|
}
|
|||
|
checkTagsWithFile(tags, file) {
|
|||
|
var _a, _b, _c, _d;
|
|||
|
if (tags.length <= 0) {
|
|||
|
return true;
|
|||
|
} else if (file.extension !== "md") {
|
|||
|
return false;
|
|||
|
}
|
|||
|
const fileCache = this.plugin.app.metadataCache.getFileCache(file);
|
|||
|
const fileCacheTags = (_a = fileCache == null ? void 0 : fileCache.tags) != null ? _a : [];
|
|||
|
let frontmatterTags = (_c = (_b = fileCache == null ? void 0 : fileCache.frontmatter) == null ? void 0 : _b.tags) != null ? _c : [];
|
|||
|
const frontmatterTag = (_d = fileCache == null ? void 0 : fileCache.frontmatter) == null ? void 0 : _d.tag;
|
|||
|
if (frontmatterTags[0] === null)
|
|||
|
frontmatterTags = [];
|
|||
|
let fileTags = fileCacheTags.map((tagCache) => tagCache.tag);
|
|||
|
fileTags = fileTags.concat(getTagStrings(frontmatterTags));
|
|||
|
if (frontmatterTag) {
|
|||
|
fileTags.push(getTagString(frontmatterTag));
|
|||
|
}
|
|||
|
if (fileTags.length <= 0 && tags.length > 0)
|
|||
|
return false;
|
|||
|
const includedTags = tags.filter((tag) => tag.included);
|
|||
|
const excludedTags = tags.filter((tag) => !tag.included);
|
|||
|
let includesTags = false;
|
|||
|
let excludesTags = false;
|
|||
|
includesTags = includedTags && fileTags && includedTags.every((searchTag) => {
|
|||
|
return fileTags.some(
|
|||
|
(fileTag) => fileTag.includes(searchTag.tag)
|
|||
|
);
|
|||
|
}) || !includedTags;
|
|||
|
excludesTags = excludedTags && fileTags && excludedTags.every((searchTag) => {
|
|||
|
return fileTags.every(
|
|||
|
(fileTag) => !fileTag.includes(searchTag.tag)
|
|||
|
);
|
|||
|
}) || excludedTags && !fileTags || !excludedTags;
|
|||
|
return includesTags && excludesTags;
|
|||
|
}
|
|||
|
checkFilenameWithFile(filename, file) {
|
|||
|
return file.name.includes(filename);
|
|||
|
}
|
|||
|
checkPathWithFile(path, file) {
|
|||
|
return path !== "/" && file.path.includes(path) || path === "/" && !file.path.includes(path);
|
|||
|
}
|
|||
|
isInDisabledFolder(file, disabledDisabledPaths) {
|
|||
|
if (this.plugin.settings.disabledFolders === "")
|
|||
|
return false;
|
|||
|
return this.plugin.settings.disabledFolders.split(/\r?\n/).some((disabledFolder) => {
|
|||
|
const trimmedFolder = disabledFolder.trim();
|
|||
|
if (disabledDisabledPaths && trimmedFolder === disabledDisabledPaths)
|
|||
|
return false;
|
|||
|
return trimmedFolder && file.path.startsWith(trimmedFolder);
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// src/settings.ts
|
|||
|
var import_obsidian5 = require("obsidian");
|
|||
|
|
|||
|
// node_modules/@fortawesome/free-solid-svg-icons/index.mjs
|
|||
|
var faTrash = {
|
|||
|
prefix: "fas",
|
|||
|
iconName: "trash",
|
|||
|
icon: [448, 512, [], "f1f8", "M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"]
|
|||
|
};
|
|||
|
var faGear = {
|
|||
|
prefix: "fas",
|
|||
|
iconName: "gear",
|
|||
|
icon: [512, 512, [9881, "cog"], "f013", "M495.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"]
|
|||
|
};
|
|||
|
var faCog = faGear;
|
|||
|
var faBolt = {
|
|||
|
prefix: "fas",
|
|||
|
iconName: "bolt",
|
|||
|
icon: [448, 512, [9889, "zap"], "f0e7", "M349.4 44.6c5.9-13.7 1.5-29.7-10.6-38.5s-28.6-8-39.9 1.8l-256 224c-10 8.8-13.6 22.9-8.9 35.3S50.7 288 64 288H175.5L98.6 467.4c-5.9 13.7-1.5 29.7 10.6 38.5s28.6 8 39.9-1.8l256-224c10-8.8 13.6-22.9 8.9-35.3s-16.6-20.7-30-20.7H272.5L349.4 44.6z"]
|
|||
|
};
|
|||
|
var faClone = {
|
|||
|
prefix: "fas",
|
|||
|
iconName: "clone",
|
|||
|
icon: [512, 512, [], "f24d", "M288 448H64V224h64V160H64c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H288c35.3 0 64-28.7 64-64V384H288v64zm-64-96H448c35.3 0 64-28.7 64-64V64c0-35.3-28.7-64-64-64H224c-35.3 0-64 28.7-64 64V288c0 35.3 28.7 64 64 64z"]
|
|||
|
};
|
|||
|
|
|||
|
// node_modules/svelte-awesome/components/svg/Raw.svelte
|
|||
|
function create_fragment2(ctx) {
|
|||
|
let g;
|
|||
|
return {
|
|||
|
c() {
|
|||
|
g = svg_element("g");
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, g, anchor);
|
|||
|
g.innerHTML = /*raw*/
|
|||
|
ctx[0];
|
|||
|
},
|
|||
|
p(ctx2, [dirty]) {
|
|||
|
if (dirty & /*raw*/
|
|||
|
1)
|
|||
|
g.innerHTML = /*raw*/
|
|||
|
ctx2[0];
|
|||
|
;
|
|||
|
},
|
|||
|
i: noop,
|
|||
|
o: noop,
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(g);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function instance2($$self, $$props, $$invalidate) {
|
|||
|
let cursor = 870711;
|
|||
|
function getId() {
|
|||
|
cursor += 1;
|
|||
|
return `fa-${cursor.toString(16)}`;
|
|||
|
}
|
|||
|
let raw = "";
|
|||
|
let { data } = $$props;
|
|||
|
function getRaw(data2) {
|
|||
|
if (!data2 || !data2.raw) {
|
|||
|
return "";
|
|||
|
}
|
|||
|
let rawData = data2.raw;
|
|||
|
const ids = {};
|
|||
|
rawData = rawData.replace(/\s(?:xml:)?id=["']?([^"')\s]+)/g, (match, id) => {
|
|||
|
const uniqueId = getId();
|
|||
|
ids[id] = uniqueId;
|
|||
|
return ` id="${uniqueId}"`;
|
|||
|
});
|
|||
|
rawData = rawData.replace(/#(?:([^'")\s]+)|xpointer\(id\((['"]?)([^')]+)\2\)\))/g, (match, rawId, _, pointerId) => {
|
|||
|
const id = rawId || pointerId;
|
|||
|
if (!id || !ids[id]) {
|
|||
|
return match;
|
|||
|
}
|
|||
|
return `#${ids[id]}`;
|
|||
|
});
|
|||
|
return rawData;
|
|||
|
}
|
|||
|
$$self.$$set = ($$props2) => {
|
|||
|
if ("data" in $$props2)
|
|||
|
$$invalidate(1, data = $$props2.data);
|
|||
|
};
|
|||
|
$$self.$$.update = () => {
|
|||
|
if ($$self.$$.dirty & /*data*/
|
|||
|
2) {
|
|||
|
$:
|
|||
|
$$invalidate(0, raw = getRaw(data));
|
|||
|
}
|
|||
|
};
|
|||
|
return [raw, data];
|
|||
|
}
|
|||
|
var Raw = class extends SvelteComponent {
|
|||
|
constructor(options) {
|
|||
|
super();
|
|||
|
init(this, options, instance2, create_fragment2, safe_not_equal, { data: 1 });
|
|||
|
}
|
|||
|
};
|
|||
|
var Raw_default = Raw;
|
|||
|
|
|||
|
// node_modules/svelte-awesome/components/svg/Svg.svelte
|
|||
|
function add_css2(target) {
|
|||
|
append_styles(target, "svelte-1mc5hvj", ".fa-icon.svelte-1mc5hvj{display:inline-block;fill:currentColor}.fa-flip-horizontal.svelte-1mc5hvj{transform:scale(-1, 1)}.fa-flip-vertical.svelte-1mc5hvj{transform:scale(1, -1)}.fa-spin.svelte-1mc5hvj{animation:svelte-1mc5hvj-fa-spin 1s 0s infinite linear}.fa-inverse.svelte-1mc5hvj{color:#fff}.fa-pulse.svelte-1mc5hvj{animation:svelte-1mc5hvj-fa-spin 1s infinite steps(8)}@keyframes svelte-1mc5hvj-fa-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}");
|
|||
|
}
|
|||
|
function create_fragment3(ctx) {
|
|||
|
let svg;
|
|||
|
let svg_class_value;
|
|||
|
let svg_role_value;
|
|||
|
let current;
|
|||
|
const default_slot_template = (
|
|||
|
/*#slots*/
|
|||
|
ctx[12].default
|
|||
|
);
|
|||
|
const default_slot = create_slot(
|
|||
|
default_slot_template,
|
|||
|
ctx,
|
|||
|
/*$$scope*/
|
|||
|
ctx[11],
|
|||
|
null
|
|||
|
);
|
|||
|
let svg_levels = [
|
|||
|
{ version: "1.1" },
|
|||
|
{
|
|||
|
class: svg_class_value = "fa-icon " + /*className*/
|
|||
|
ctx[0]
|
|||
|
},
|
|||
|
{ width: (
|
|||
|
/*width*/
|
|||
|
ctx[1]
|
|||
|
) },
|
|||
|
{ height: (
|
|||
|
/*height*/
|
|||
|
ctx[2]
|
|||
|
) },
|
|||
|
{ "aria-label": (
|
|||
|
/*label*/
|
|||
|
ctx[9]
|
|||
|
) },
|
|||
|
{
|
|||
|
role: svg_role_value = /*label*/
|
|||
|
ctx[9] ? "img" : "presentation"
|
|||
|
},
|
|||
|
{ viewBox: (
|
|||
|
/*box*/
|
|||
|
ctx[3]
|
|||
|
) },
|
|||
|
{ style: (
|
|||
|
/*style*/
|
|||
|
ctx[8]
|
|||
|
) },
|
|||
|
/*$$restProps*/
|
|||
|
ctx[10]
|
|||
|
];
|
|||
|
let svg_data = {};
|
|||
|
for (let i = 0; i < svg_levels.length; i += 1) {
|
|||
|
svg_data = assign(svg_data, svg_levels[i]);
|
|||
|
}
|
|||
|
return {
|
|||
|
c() {
|
|||
|
svg = svg_element("svg");
|
|||
|
if (default_slot)
|
|||
|
default_slot.c();
|
|||
|
set_svg_attributes(svg, svg_data);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-spin",
|
|||
|
/*spin*/
|
|||
|
ctx[4]
|
|||
|
);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-pulse",
|
|||
|
/*pulse*/
|
|||
|
ctx[6]
|
|||
|
);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-inverse",
|
|||
|
/*inverse*/
|
|||
|
ctx[5]
|
|||
|
);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-flip-horizontal",
|
|||
|
/*flip*/
|
|||
|
ctx[7] === "horizontal"
|
|||
|
);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-flip-vertical",
|
|||
|
/*flip*/
|
|||
|
ctx[7] === "vertical"
|
|||
|
);
|
|||
|
toggle_class(svg, "svelte-1mc5hvj", true);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, svg, anchor);
|
|||
|
if (default_slot) {
|
|||
|
default_slot.m(svg, null);
|
|||
|
}
|
|||
|
current = true;
|
|||
|
},
|
|||
|
p(ctx2, [dirty]) {
|
|||
|
if (default_slot) {
|
|||
|
if (default_slot.p && (!current || dirty & /*$$scope*/
|
|||
|
2048)) {
|
|||
|
update_slot_base(
|
|||
|
default_slot,
|
|||
|
default_slot_template,
|
|||
|
ctx2,
|
|||
|
/*$$scope*/
|
|||
|
ctx2[11],
|
|||
|
!current ? get_all_dirty_from_scope(
|
|||
|
/*$$scope*/
|
|||
|
ctx2[11]
|
|||
|
) : get_slot_changes(
|
|||
|
default_slot_template,
|
|||
|
/*$$scope*/
|
|||
|
ctx2[11],
|
|||
|
dirty,
|
|||
|
null
|
|||
|
),
|
|||
|
null
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
set_svg_attributes(svg, svg_data = get_spread_update(svg_levels, [
|
|||
|
{ version: "1.1" },
|
|||
|
(!current || dirty & /*className*/
|
|||
|
1 && svg_class_value !== (svg_class_value = "fa-icon " + /*className*/
|
|||
|
ctx2[0])) && { class: svg_class_value },
|
|||
|
(!current || dirty & /*width*/
|
|||
|
2) && { width: (
|
|||
|
/*width*/
|
|||
|
ctx2[1]
|
|||
|
) },
|
|||
|
(!current || dirty & /*height*/
|
|||
|
4) && { height: (
|
|||
|
/*height*/
|
|||
|
ctx2[2]
|
|||
|
) },
|
|||
|
(!current || dirty & /*label*/
|
|||
|
512) && { "aria-label": (
|
|||
|
/*label*/
|
|||
|
ctx2[9]
|
|||
|
) },
|
|||
|
(!current || dirty & /*label*/
|
|||
|
512 && svg_role_value !== (svg_role_value = /*label*/
|
|||
|
ctx2[9] ? "img" : "presentation")) && { role: svg_role_value },
|
|||
|
(!current || dirty & /*box*/
|
|||
|
8) && { viewBox: (
|
|||
|
/*box*/
|
|||
|
ctx2[3]
|
|||
|
) },
|
|||
|
(!current || dirty & /*style*/
|
|||
|
256) && { style: (
|
|||
|
/*style*/
|
|||
|
ctx2[8]
|
|||
|
) },
|
|||
|
dirty & /*$$restProps*/
|
|||
|
1024 && /*$$restProps*/
|
|||
|
ctx2[10]
|
|||
|
]));
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-spin",
|
|||
|
/*spin*/
|
|||
|
ctx2[4]
|
|||
|
);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-pulse",
|
|||
|
/*pulse*/
|
|||
|
ctx2[6]
|
|||
|
);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-inverse",
|
|||
|
/*inverse*/
|
|||
|
ctx2[5]
|
|||
|
);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-flip-horizontal",
|
|||
|
/*flip*/
|
|||
|
ctx2[7] === "horizontal"
|
|||
|
);
|
|||
|
toggle_class(
|
|||
|
svg,
|
|||
|
"fa-flip-vertical",
|
|||
|
/*flip*/
|
|||
|
ctx2[7] === "vertical"
|
|||
|
);
|
|||
|
toggle_class(svg, "svelte-1mc5hvj", true);
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(default_slot, local);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(default_slot, local);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(svg);
|
|||
|
}
|
|||
|
if (default_slot)
|
|||
|
default_slot.d(detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function instance3($$self, $$props, $$invalidate) {
|
|||
|
const omit_props_names = ["class", "width", "height", "box", "spin", "inverse", "pulse", "flip", "style", "label"];
|
|||
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|||
|
let { $$slots: slots = {}, $$scope } = $$props;
|
|||
|
let { class: className = "" } = $$props;
|
|||
|
let { width } = $$props;
|
|||
|
let { height } = $$props;
|
|||
|
let { box = "0 0 0 0" } = $$props;
|
|||
|
let { spin = false } = $$props;
|
|||
|
let { inverse = false } = $$props;
|
|||
|
let { pulse = false } = $$props;
|
|||
|
let { flip = "none" } = $$props;
|
|||
|
let { style = "" } = $$props;
|
|||
|
let { label = "" } = $$props;
|
|||
|
$$self.$$set = ($$new_props) => {
|
|||
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|||
|
$$invalidate(10, $$restProps = compute_rest_props($$props, omit_props_names));
|
|||
|
if ("class" in $$new_props)
|
|||
|
$$invalidate(0, className = $$new_props.class);
|
|||
|
if ("width" in $$new_props)
|
|||
|
$$invalidate(1, width = $$new_props.width);
|
|||
|
if ("height" in $$new_props)
|
|||
|
$$invalidate(2, height = $$new_props.height);
|
|||
|
if ("box" in $$new_props)
|
|||
|
$$invalidate(3, box = $$new_props.box);
|
|||
|
if ("spin" in $$new_props)
|
|||
|
$$invalidate(4, spin = $$new_props.spin);
|
|||
|
if ("inverse" in $$new_props)
|
|||
|
$$invalidate(5, inverse = $$new_props.inverse);
|
|||
|
if ("pulse" in $$new_props)
|
|||
|
$$invalidate(6, pulse = $$new_props.pulse);
|
|||
|
if ("flip" in $$new_props)
|
|||
|
$$invalidate(7, flip = $$new_props.flip);
|
|||
|
if ("style" in $$new_props)
|
|||
|
$$invalidate(8, style = $$new_props.style);
|
|||
|
if ("label" in $$new_props)
|
|||
|
$$invalidate(9, label = $$new_props.label);
|
|||
|
if ("$$scope" in $$new_props)
|
|||
|
$$invalidate(11, $$scope = $$new_props.$$scope);
|
|||
|
};
|
|||
|
return [
|
|||
|
className,
|
|||
|
width,
|
|||
|
height,
|
|||
|
box,
|
|||
|
spin,
|
|||
|
inverse,
|
|||
|
pulse,
|
|||
|
flip,
|
|||
|
style,
|
|||
|
label,
|
|||
|
$$restProps,
|
|||
|
$$scope,
|
|||
|
slots
|
|||
|
];
|
|||
|
}
|
|||
|
var Svg = class extends SvelteComponent {
|
|||
|
constructor(options) {
|
|||
|
super();
|
|||
|
init(
|
|||
|
this,
|
|||
|
options,
|
|||
|
instance3,
|
|||
|
create_fragment3,
|
|||
|
safe_not_equal,
|
|||
|
{
|
|||
|
class: 0,
|
|||
|
width: 1,
|
|||
|
height: 2,
|
|||
|
box: 3,
|
|||
|
spin: 4,
|
|||
|
inverse: 5,
|
|||
|
pulse: 6,
|
|||
|
flip: 7,
|
|||
|
style: 8,
|
|||
|
label: 9
|
|||
|
},
|
|||
|
add_css2
|
|||
|
);
|
|||
|
}
|
|||
|
};
|
|||
|
var Svg_default = Svg;
|
|||
|
|
|||
|
// node_modules/svelte-awesome/components/Icon.svelte
|
|||
|
function get_each_context2(ctx, list, i) {
|
|||
|
const child_ctx = ctx.slice();
|
|||
|
child_ctx[24] = list[i];
|
|||
|
return child_ctx;
|
|||
|
}
|
|||
|
function get_each_context_1(ctx, list, i) {
|
|||
|
const child_ctx = ctx.slice();
|
|||
|
child_ctx[27] = list[i];
|
|||
|
return child_ctx;
|
|||
|
}
|
|||
|
function create_if_block2(ctx) {
|
|||
|
let t0;
|
|||
|
let t1;
|
|||
|
let if_block2_anchor;
|
|||
|
let current;
|
|||
|
let if_block0 = (
|
|||
|
/*iconData*/
|
|||
|
ctx[6].paths && create_if_block_3(ctx)
|
|||
|
);
|
|||
|
let if_block1 = (
|
|||
|
/*iconData*/
|
|||
|
ctx[6].polygons && create_if_block_2(ctx)
|
|||
|
);
|
|||
|
let if_block2 = (
|
|||
|
/*iconData*/
|
|||
|
ctx[6].raw && create_if_block_1(ctx)
|
|||
|
);
|
|||
|
return {
|
|||
|
c() {
|
|||
|
if (if_block0)
|
|||
|
if_block0.c();
|
|||
|
t0 = space();
|
|||
|
if (if_block1)
|
|||
|
if_block1.c();
|
|||
|
t1 = space();
|
|||
|
if (if_block2)
|
|||
|
if_block2.c();
|
|||
|
if_block2_anchor = empty();
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
if (if_block0)
|
|||
|
if_block0.m(target, anchor);
|
|||
|
insert(target, t0, anchor);
|
|||
|
if (if_block1)
|
|||
|
if_block1.m(target, anchor);
|
|||
|
insert(target, t1, anchor);
|
|||
|
if (if_block2)
|
|||
|
if_block2.m(target, anchor);
|
|||
|
insert(target, if_block2_anchor, anchor);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
if (
|
|||
|
/*iconData*/
|
|||
|
ctx2[6].paths
|
|||
|
) {
|
|||
|
if (if_block0) {
|
|||
|
if_block0.p(ctx2, dirty);
|
|||
|
} else {
|
|||
|
if_block0 = create_if_block_3(ctx2);
|
|||
|
if_block0.c();
|
|||
|
if_block0.m(t0.parentNode, t0);
|
|||
|
}
|
|||
|
} else if (if_block0) {
|
|||
|
if_block0.d(1);
|
|||
|
if_block0 = null;
|
|||
|
}
|
|||
|
if (
|
|||
|
/*iconData*/
|
|||
|
ctx2[6].polygons
|
|||
|
) {
|
|||
|
if (if_block1) {
|
|||
|
if_block1.p(ctx2, dirty);
|
|||
|
} else {
|
|||
|
if_block1 = create_if_block_2(ctx2);
|
|||
|
if_block1.c();
|
|||
|
if_block1.m(t1.parentNode, t1);
|
|||
|
}
|
|||
|
} else if (if_block1) {
|
|||
|
if_block1.d(1);
|
|||
|
if_block1 = null;
|
|||
|
}
|
|||
|
if (
|
|||
|
/*iconData*/
|
|||
|
ctx2[6].raw
|
|||
|
) {
|
|||
|
if (if_block2) {
|
|||
|
if_block2.p(ctx2, dirty);
|
|||
|
if (dirty & /*iconData*/
|
|||
|
64) {
|
|||
|
transition_in(if_block2, 1);
|
|||
|
}
|
|||
|
} else {
|
|||
|
if_block2 = create_if_block_1(ctx2);
|
|||
|
if_block2.c();
|
|||
|
transition_in(if_block2, 1);
|
|||
|
if_block2.m(if_block2_anchor.parentNode, if_block2_anchor);
|
|||
|
}
|
|||
|
} else if (if_block2) {
|
|||
|
group_outros();
|
|||
|
transition_out(if_block2, 1, 1, () => {
|
|||
|
if_block2 = null;
|
|||
|
});
|
|||
|
check_outros();
|
|||
|
}
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(if_block2);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(if_block2);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(t0);
|
|||
|
detach(t1);
|
|||
|
detach(if_block2_anchor);
|
|||
|
}
|
|||
|
if (if_block0)
|
|||
|
if_block0.d(detaching);
|
|||
|
if (if_block1)
|
|||
|
if_block1.d(detaching);
|
|||
|
if (if_block2)
|
|||
|
if_block2.d(detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_if_block_3(ctx) {
|
|||
|
let each_1_anchor;
|
|||
|
let each_value_1 = ensure_array_like(
|
|||
|
/*iconData*/
|
|||
|
ctx[6].paths
|
|||
|
);
|
|||
|
let each_blocks = [];
|
|||
|
for (let i = 0; i < each_value_1.length; i += 1) {
|
|||
|
each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i));
|
|||
|
}
|
|||
|
return {
|
|||
|
c() {
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].c();
|
|||
|
}
|
|||
|
each_1_anchor = empty();
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].m(target, anchor);
|
|||
|
}
|
|||
|
}
|
|||
|
insert(target, each_1_anchor, anchor);
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
if (dirty & /*iconData*/
|
|||
|
64) {
|
|||
|
each_value_1 = ensure_array_like(
|
|||
|
/*iconData*/
|
|||
|
ctx2[6].paths
|
|||
|
);
|
|||
|
let i;
|
|||
|
for (i = 0; i < each_value_1.length; i += 1) {
|
|||
|
const child_ctx = get_each_context_1(ctx2, each_value_1, i);
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].p(child_ctx, dirty);
|
|||
|
} else {
|
|||
|
each_blocks[i] = create_each_block_1(child_ctx);
|
|||
|
each_blocks[i].c();
|
|||
|
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
|
|||
|
}
|
|||
|
}
|
|||
|
for (; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].d(1);
|
|||
|
}
|
|||
|
each_blocks.length = each_value_1.length;
|
|||
|
}
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(each_1_anchor);
|
|||
|
}
|
|||
|
destroy_each(each_blocks, detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_each_block_1(ctx) {
|
|||
|
let path_1;
|
|||
|
let path_1_levels = [
|
|||
|
/*path*/
|
|||
|
ctx[27]
|
|||
|
];
|
|||
|
let path_data = {};
|
|||
|
for (let i = 0; i < path_1_levels.length; i += 1) {
|
|||
|
path_data = assign(path_data, path_1_levels[i]);
|
|||
|
}
|
|||
|
return {
|
|||
|
c() {
|
|||
|
path_1 = svg_element("path");
|
|||
|
set_svg_attributes(path_1, path_data);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, path_1, anchor);
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
set_svg_attributes(path_1, path_data = get_spread_update(path_1_levels, [dirty & /*iconData*/
|
|||
|
64 && /*path*/
|
|||
|
ctx2[27]]));
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(path_1);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_if_block_2(ctx) {
|
|||
|
let each_1_anchor;
|
|||
|
let each_value = ensure_array_like(
|
|||
|
/*iconData*/
|
|||
|
ctx[6].polygons
|
|||
|
);
|
|||
|
let each_blocks = [];
|
|||
|
for (let i = 0; i < each_value.length; i += 1) {
|
|||
|
each_blocks[i] = create_each_block2(get_each_context2(ctx, each_value, i));
|
|||
|
}
|
|||
|
return {
|
|||
|
c() {
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].c();
|
|||
|
}
|
|||
|
each_1_anchor = empty();
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].m(target, anchor);
|
|||
|
}
|
|||
|
}
|
|||
|
insert(target, each_1_anchor, anchor);
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
if (dirty & /*iconData*/
|
|||
|
64) {
|
|||
|
each_value = ensure_array_like(
|
|||
|
/*iconData*/
|
|||
|
ctx2[6].polygons
|
|||
|
);
|
|||
|
let i;
|
|||
|
for (i = 0; i < each_value.length; i += 1) {
|
|||
|
const child_ctx = get_each_context2(ctx2, each_value, i);
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].p(child_ctx, dirty);
|
|||
|
} else {
|
|||
|
each_blocks[i] = create_each_block2(child_ctx);
|
|||
|
each_blocks[i].c();
|
|||
|
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
|
|||
|
}
|
|||
|
}
|
|||
|
for (; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].d(1);
|
|||
|
}
|
|||
|
each_blocks.length = each_value.length;
|
|||
|
}
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(each_1_anchor);
|
|||
|
}
|
|||
|
destroy_each(each_blocks, detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_each_block2(ctx) {
|
|||
|
let polygon_1;
|
|||
|
let polygon_1_levels = [
|
|||
|
/*polygon*/
|
|||
|
ctx[24]
|
|||
|
];
|
|||
|
let polygon_data = {};
|
|||
|
for (let i = 0; i < polygon_1_levels.length; i += 1) {
|
|||
|
polygon_data = assign(polygon_data, polygon_1_levels[i]);
|
|||
|
}
|
|||
|
return {
|
|||
|
c() {
|
|||
|
polygon_1 = svg_element("polygon");
|
|||
|
set_svg_attributes(polygon_1, polygon_data);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, polygon_1, anchor);
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
set_svg_attributes(polygon_1, polygon_data = get_spread_update(polygon_1_levels, [dirty & /*iconData*/
|
|||
|
64 && /*polygon*/
|
|||
|
ctx2[24]]));
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(polygon_1);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_if_block_1(ctx) {
|
|||
|
let raw;
|
|||
|
let updating_data;
|
|||
|
let current;
|
|||
|
function raw_data_binding(value) {
|
|||
|
ctx[16](value);
|
|||
|
}
|
|||
|
let raw_props = {};
|
|||
|
if (
|
|||
|
/*iconData*/
|
|||
|
ctx[6] !== void 0
|
|||
|
) {
|
|||
|
raw_props.data = /*iconData*/
|
|||
|
ctx[6];
|
|||
|
}
|
|||
|
raw = new Raw_default({ props: raw_props });
|
|||
|
binding_callbacks.push(() => bind(raw, "data", raw_data_binding));
|
|||
|
return {
|
|||
|
c() {
|
|||
|
create_component(raw.$$.fragment);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
mount_component(raw, target, anchor);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
const raw_changes = {};
|
|||
|
if (!updating_data && dirty & /*iconData*/
|
|||
|
64) {
|
|||
|
updating_data = true;
|
|||
|
raw_changes.data = /*iconData*/
|
|||
|
ctx2[6];
|
|||
|
add_flush_callback(() => updating_data = false);
|
|||
|
}
|
|||
|
raw.$set(raw_changes);
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(raw.$$.fragment, local);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(raw.$$.fragment, local);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
destroy_component(raw, detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function fallback_block(ctx) {
|
|||
|
let if_block_anchor;
|
|||
|
let current;
|
|||
|
let if_block = (
|
|||
|
/*iconData*/
|
|||
|
ctx[6] && create_if_block2(ctx)
|
|||
|
);
|
|||
|
return {
|
|||
|
c() {
|
|||
|
if (if_block)
|
|||
|
if_block.c();
|
|||
|
if_block_anchor = empty();
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
if (if_block)
|
|||
|
if_block.m(target, anchor);
|
|||
|
insert(target, if_block_anchor, anchor);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
if (
|
|||
|
/*iconData*/
|
|||
|
ctx2[6]
|
|||
|
) {
|
|||
|
if (if_block) {
|
|||
|
if_block.p(ctx2, dirty);
|
|||
|
if (dirty & /*iconData*/
|
|||
|
64) {
|
|||
|
transition_in(if_block, 1);
|
|||
|
}
|
|||
|
} else {
|
|||
|
if_block = create_if_block2(ctx2);
|
|||
|
if_block.c();
|
|||
|
transition_in(if_block, 1);
|
|||
|
if_block.m(if_block_anchor.parentNode, if_block_anchor);
|
|||
|
}
|
|||
|
} else if (if_block) {
|
|||
|
group_outros();
|
|||
|
transition_out(if_block, 1, 1, () => {
|
|||
|
if_block = null;
|
|||
|
});
|
|||
|
check_outros();
|
|||
|
}
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(if_block);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(if_block);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(if_block_anchor);
|
|||
|
}
|
|||
|
if (if_block)
|
|||
|
if_block.d(detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_default_slot(ctx) {
|
|||
|
let current;
|
|||
|
const default_slot_template = (
|
|||
|
/*#slots*/
|
|||
|
ctx[15].default
|
|||
|
);
|
|||
|
const default_slot = create_slot(
|
|||
|
default_slot_template,
|
|||
|
ctx,
|
|||
|
/*$$scope*/
|
|||
|
ctx[17],
|
|||
|
null
|
|||
|
);
|
|||
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|||
|
return {
|
|||
|
c() {
|
|||
|
if (default_slot_or_fallback)
|
|||
|
default_slot_or_fallback.c();
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
if (default_slot_or_fallback) {
|
|||
|
default_slot_or_fallback.m(target, anchor);
|
|||
|
}
|
|||
|
current = true;
|
|||
|
},
|
|||
|
p(ctx2, dirty) {
|
|||
|
if (default_slot) {
|
|||
|
if (default_slot.p && (!current || dirty & /*$$scope*/
|
|||
|
131072)) {
|
|||
|
update_slot_base(
|
|||
|
default_slot,
|
|||
|
default_slot_template,
|
|||
|
ctx2,
|
|||
|
/*$$scope*/
|
|||
|
ctx2[17],
|
|||
|
!current ? get_all_dirty_from_scope(
|
|||
|
/*$$scope*/
|
|||
|
ctx2[17]
|
|||
|
) : get_slot_changes(
|
|||
|
default_slot_template,
|
|||
|
/*$$scope*/
|
|||
|
ctx2[17],
|
|||
|
dirty,
|
|||
|
null
|
|||
|
),
|
|||
|
null
|
|||
|
);
|
|||
|
}
|
|||
|
} else {
|
|||
|
if (default_slot_or_fallback && default_slot_or_fallback.p && (!current || dirty & /*iconData*/
|
|||
|
64)) {
|
|||
|
default_slot_or_fallback.p(ctx2, !current ? -1 : dirty);
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(default_slot_or_fallback, local);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(default_slot_or_fallback, local);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (default_slot_or_fallback)
|
|||
|
default_slot_or_fallback.d(detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_fragment4(ctx) {
|
|||
|
let svg;
|
|||
|
let current;
|
|||
|
const svg_spread_levels = [
|
|||
|
{ label: (
|
|||
|
/*label*/
|
|||
|
ctx[5]
|
|||
|
) },
|
|||
|
{ width: (
|
|||
|
/*width*/
|
|||
|
ctx[7]
|
|||
|
) },
|
|||
|
{ height: (
|
|||
|
/*height*/
|
|||
|
ctx[8]
|
|||
|
) },
|
|||
|
{ box: (
|
|||
|
/*box*/
|
|||
|
ctx[10]
|
|||
|
) },
|
|||
|
{ style: (
|
|||
|
/*combinedStyle*/
|
|||
|
ctx[9]
|
|||
|
) },
|
|||
|
{ spin: (
|
|||
|
/*spin*/
|
|||
|
ctx[1]
|
|||
|
) },
|
|||
|
{ flip: (
|
|||
|
/*flip*/
|
|||
|
ctx[4]
|
|||
|
) },
|
|||
|
{ inverse: (
|
|||
|
/*inverse*/
|
|||
|
ctx[2]
|
|||
|
) },
|
|||
|
{ pulse: (
|
|||
|
/*pulse*/
|
|||
|
ctx[3]
|
|||
|
) },
|
|||
|
{ class: (
|
|||
|
/*className*/
|
|||
|
ctx[0]
|
|||
|
) },
|
|||
|
/*$$restProps*/
|
|||
|
ctx[11]
|
|||
|
];
|
|||
|
let svg_props = {
|
|||
|
$$slots: { default: [create_default_slot] },
|
|||
|
$$scope: { ctx }
|
|||
|
};
|
|||
|
for (let i = 0; i < svg_spread_levels.length; i += 1) {
|
|||
|
svg_props = assign(svg_props, svg_spread_levels[i]);
|
|||
|
}
|
|||
|
svg = new Svg_default({ props: svg_props });
|
|||
|
return {
|
|||
|
c() {
|
|||
|
create_component(svg.$$.fragment);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
mount_component(svg, target, anchor);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
p(ctx2, [dirty]) {
|
|||
|
const svg_changes = dirty & /*label, width, height, box, combinedStyle, spin, flip, inverse, pulse, className, $$restProps*/
|
|||
|
4031 ? get_spread_update(svg_spread_levels, [
|
|||
|
dirty & /*label*/
|
|||
|
32 && { label: (
|
|||
|
/*label*/
|
|||
|
ctx2[5]
|
|||
|
) },
|
|||
|
dirty & /*width*/
|
|||
|
128 && { width: (
|
|||
|
/*width*/
|
|||
|
ctx2[7]
|
|||
|
) },
|
|||
|
dirty & /*height*/
|
|||
|
256 && { height: (
|
|||
|
/*height*/
|
|||
|
ctx2[8]
|
|||
|
) },
|
|||
|
dirty & /*box*/
|
|||
|
1024 && { box: (
|
|||
|
/*box*/
|
|||
|
ctx2[10]
|
|||
|
) },
|
|||
|
dirty & /*combinedStyle*/
|
|||
|
512 && { style: (
|
|||
|
/*combinedStyle*/
|
|||
|
ctx2[9]
|
|||
|
) },
|
|||
|
dirty & /*spin*/
|
|||
|
2 && { spin: (
|
|||
|
/*spin*/
|
|||
|
ctx2[1]
|
|||
|
) },
|
|||
|
dirty & /*flip*/
|
|||
|
16 && { flip: (
|
|||
|
/*flip*/
|
|||
|
ctx2[4]
|
|||
|
) },
|
|||
|
dirty & /*inverse*/
|
|||
|
4 && { inverse: (
|
|||
|
/*inverse*/
|
|||
|
ctx2[2]
|
|||
|
) },
|
|||
|
dirty & /*pulse*/
|
|||
|
8 && { pulse: (
|
|||
|
/*pulse*/
|
|||
|
ctx2[3]
|
|||
|
) },
|
|||
|
dirty & /*className*/
|
|||
|
1 && { class: (
|
|||
|
/*className*/
|
|||
|
ctx2[0]
|
|||
|
) },
|
|||
|
dirty & /*$$restProps*/
|
|||
|
2048 && get_spread_object(
|
|||
|
/*$$restProps*/
|
|||
|
ctx2[11]
|
|||
|
)
|
|||
|
]) : {};
|
|||
|
if (dirty & /*$$scope, iconData*/
|
|||
|
131136) {
|
|||
|
svg_changes.$$scope = { dirty, ctx: ctx2 };
|
|||
|
}
|
|||
|
svg.$set(svg_changes);
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(svg.$$.fragment, local);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(svg.$$.fragment, local);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
destroy_component(svg, detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
var childrenHeight = 0;
|
|||
|
var childrenWidth = 0;
|
|||
|
var outerScale = 1;
|
|||
|
function normaliseData(data) {
|
|||
|
let name;
|
|||
|
let iconData;
|
|||
|
if (!data) {
|
|||
|
return void 0;
|
|||
|
} else if ("definition" in data) {
|
|||
|
console.error("`import faIconName from '@fortawesome/package-name/faIconName` not supported - Please use `import { faIconName } from '@fortawesome/package-name/faIconName'` instead");
|
|||
|
return void 0;
|
|||
|
} else if ("iconName" in data && "icon" in data) {
|
|||
|
name = data.iconName;
|
|||
|
let paths = [];
|
|||
|
const [width, height, , , path] = data.icon;
|
|||
|
if (Array.isArray(path)) {
|
|||
|
paths = path;
|
|||
|
} else {
|
|||
|
paths = [path];
|
|||
|
}
|
|||
|
iconData = {
|
|||
|
width,
|
|||
|
height,
|
|||
|
paths: paths.map((path2) => {
|
|||
|
return { d: path2 };
|
|||
|
})
|
|||
|
};
|
|||
|
} else {
|
|||
|
name = Object.keys(data)[0];
|
|||
|
iconData = data[name];
|
|||
|
}
|
|||
|
return iconData;
|
|||
|
}
|
|||
|
function instance4($$self, $$props, $$invalidate) {
|
|||
|
const omit_props_names = ["class", "data", "scale", "spin", "inverse", "pulse", "flip", "label", "style"];
|
|||
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|||
|
let { $$slots: slots = {}, $$scope } = $$props;
|
|||
|
let { class: className = "" } = $$props;
|
|||
|
let { data } = $$props;
|
|||
|
let iconData;
|
|||
|
let { scale = 1 } = $$props;
|
|||
|
let { spin = false } = $$props;
|
|||
|
let { inverse = false } = $$props;
|
|||
|
let { pulse = false } = $$props;
|
|||
|
let { flip = void 0 } = $$props;
|
|||
|
let { label = "" } = $$props;
|
|||
|
let { style = "" } = $$props;
|
|||
|
let width = 10;
|
|||
|
let height = 10;
|
|||
|
let combinedStyle;
|
|||
|
let box;
|
|||
|
function normalisedScale() {
|
|||
|
let numScale = 1;
|
|||
|
if (typeof scale !== "undefined") {
|
|||
|
numScale = Number(scale);
|
|||
|
}
|
|||
|
if (isNaN(numScale) || numScale <= 0) {
|
|||
|
console.warn('Invalid prop: prop "scale" should be a number over 0.');
|
|||
|
return outerScale;
|
|||
|
}
|
|||
|
return numScale * outerScale;
|
|||
|
}
|
|||
|
function calculateBox() {
|
|||
|
if (iconData) {
|
|||
|
return `0 0 ${iconData.width} ${iconData.height}`;
|
|||
|
}
|
|||
|
return `0 0 ${width} ${height}`;
|
|||
|
}
|
|||
|
function calculateRatio() {
|
|||
|
if (!iconData) {
|
|||
|
return 1;
|
|||
|
}
|
|||
|
return Math.max(iconData.width, iconData.height) / 16;
|
|||
|
}
|
|||
|
function calculateWidth() {
|
|||
|
if (childrenWidth) {
|
|||
|
return childrenWidth;
|
|||
|
}
|
|||
|
if (iconData) {
|
|||
|
return iconData.width / calculateRatio() * normalisedScale();
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|
|||
|
function calculateHeight() {
|
|||
|
if (childrenHeight) {
|
|||
|
return childrenHeight;
|
|||
|
}
|
|||
|
if (iconData) {
|
|||
|
return iconData.height / calculateRatio() * normalisedScale();
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|
|||
|
function calculateStyle() {
|
|||
|
let combined = "";
|
|||
|
if (style !== null) {
|
|||
|
combined += style;
|
|||
|
}
|
|||
|
let size = normalisedScale();
|
|||
|
if (size === 1) {
|
|||
|
if (combined.length === 0) {
|
|||
|
return "";
|
|||
|
}
|
|||
|
return combined;
|
|||
|
}
|
|||
|
if (combined !== "" && !combined.endsWith(";")) {
|
|||
|
combined += "; ";
|
|||
|
}
|
|||
|
return `${combined}font-size: ${size}em`;
|
|||
|
}
|
|||
|
function raw_data_binding(value) {
|
|||
|
iconData = value;
|
|||
|
$$invalidate(6, iconData), $$invalidate(12, data), $$invalidate(14, style), $$invalidate(13, scale);
|
|||
|
}
|
|||
|
$$self.$$set = ($$new_props) => {
|
|||
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|||
|
$$invalidate(11, $$restProps = compute_rest_props($$props, omit_props_names));
|
|||
|
if ("class" in $$new_props)
|
|||
|
$$invalidate(0, className = $$new_props.class);
|
|||
|
if ("data" in $$new_props)
|
|||
|
$$invalidate(12, data = $$new_props.data);
|
|||
|
if ("scale" in $$new_props)
|
|||
|
$$invalidate(13, scale = $$new_props.scale);
|
|||
|
if ("spin" in $$new_props)
|
|||
|
$$invalidate(1, spin = $$new_props.spin);
|
|||
|
if ("inverse" in $$new_props)
|
|||
|
$$invalidate(2, inverse = $$new_props.inverse);
|
|||
|
if ("pulse" in $$new_props)
|
|||
|
$$invalidate(3, pulse = $$new_props.pulse);
|
|||
|
if ("flip" in $$new_props)
|
|||
|
$$invalidate(4, flip = $$new_props.flip);
|
|||
|
if ("label" in $$new_props)
|
|||
|
$$invalidate(5, label = $$new_props.label);
|
|||
|
if ("style" in $$new_props)
|
|||
|
$$invalidate(14, style = $$new_props.style);
|
|||
|
if ("$$scope" in $$new_props)
|
|||
|
$$invalidate(17, $$scope = $$new_props.$$scope);
|
|||
|
};
|
|||
|
$$self.$$.update = () => {
|
|||
|
if ($$self.$$.dirty & /*data, style, scale*/
|
|||
|
28672) {
|
|||
|
$: {
|
|||
|
$$invalidate(6, iconData = normaliseData(data));
|
|||
|
style;
|
|||
|
scale;
|
|||
|
$$invalidate(7, width = calculateWidth());
|
|||
|
$$invalidate(8, height = calculateHeight());
|
|||
|
$$invalidate(9, combinedStyle = calculateStyle());
|
|||
|
$$invalidate(10, box = calculateBox());
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
return [
|
|||
|
className,
|
|||
|
spin,
|
|||
|
inverse,
|
|||
|
pulse,
|
|||
|
flip,
|
|||
|
label,
|
|||
|
iconData,
|
|||
|
width,
|
|||
|
height,
|
|||
|
combinedStyle,
|
|||
|
box,
|
|||
|
$$restProps,
|
|||
|
data,
|
|||
|
scale,
|
|||
|
style,
|
|||
|
slots,
|
|||
|
raw_data_binding,
|
|||
|
$$scope
|
|||
|
];
|
|||
|
}
|
|||
|
var Icon = class extends SvelteComponent {
|
|||
|
constructor(options) {
|
|||
|
super();
|
|||
|
init(this, options, instance4, create_fragment4, safe_not_equal, {
|
|||
|
class: 0,
|
|||
|
data: 12,
|
|||
|
scale: 13,
|
|||
|
spin: 1,
|
|||
|
inverse: 2,
|
|||
|
pulse: 3,
|
|||
|
flip: 4,
|
|||
|
label: 5,
|
|||
|
style: 14
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
var Icon_default = Icon;
|
|||
|
|
|||
|
// src/gui/queryItem/QueryItem.svelte
|
|||
|
function add_css3(target) {
|
|||
|
append_styles(target, "svelte-1gjzzg7", ".query-item.svelte-1gjzzg7{display:flex;justify-content:space-between;align-items:center;height:max-content}.query-item__name.svelte-1gjzzg7{margin:0}.query-item__options.svelte-1gjzzg7{display:flex;gap:0.125rem;align-items:center}.query-item__option.svelte-1gjzzg7{aspect-ratio:1 / 1}button.svelte-1gjzzg7{background:transparent;padding:0;border:none;box-shadow:none}button.svelte-1gjzzg7:hover{cursor:pointer}button.svelte-1gjzzg7:focus-visible{box-shadow:0 0 0 3px var(--background-modifier-border-focus)}.active.svelte-1gjzzg7{color:var(--color-yellow)}");
|
|||
|
}
|
|||
|
function create_fragment5(ctx) {
|
|||
|
let div1;
|
|||
|
let button0;
|
|||
|
let t0_value = (
|
|||
|
/*query*/
|
|||
|
ctx[0].name + ""
|
|||
|
);
|
|||
|
let t0;
|
|||
|
let t1;
|
|||
|
let div0;
|
|||
|
let button1;
|
|||
|
let icon0;
|
|||
|
let t2;
|
|||
|
let button2;
|
|||
|
let icon1;
|
|||
|
let t3;
|
|||
|
let button3;
|
|||
|
let icon2;
|
|||
|
let t4;
|
|||
|
let button4;
|
|||
|
let icon3;
|
|||
|
let current;
|
|||
|
let mounted;
|
|||
|
let dispose;
|
|||
|
icon0 = new Icon_default({ props: { data: faBolt } });
|
|||
|
icon1 = new Icon_default({ props: { data: faCog } });
|
|||
|
icon2 = new Icon_default({ props: { data: faClone } });
|
|||
|
icon3 = new Icon_default({ props: { data: faTrash } });
|
|||
|
return {
|
|||
|
c() {
|
|||
|
div1 = element("div");
|
|||
|
button0 = element("button");
|
|||
|
t0 = text(t0_value);
|
|||
|
t1 = space();
|
|||
|
div0 = element("div");
|
|||
|
button1 = element("button");
|
|||
|
create_component(icon0.$$.fragment);
|
|||
|
t2 = space();
|
|||
|
button2 = element("button");
|
|||
|
create_component(icon1.$$.fragment);
|
|||
|
t3 = space();
|
|||
|
button3 = element("button");
|
|||
|
create_component(icon2.$$.fragment);
|
|||
|
t4 = space();
|
|||
|
button4 = element("button");
|
|||
|
create_component(icon3.$$.fragment);
|
|||
|
attr(button0, "class", "query-item__name svelte-1gjzzg7");
|
|||
|
attr(button1, "class", "query-item__option svelte-1gjzzg7");
|
|||
|
toggle_class(
|
|||
|
button1,
|
|||
|
"active",
|
|||
|
/*query*/
|
|||
|
ctx[0].createCommand
|
|||
|
);
|
|||
|
attr(button2, "class", "query-item__option svelte-1gjzzg7");
|
|||
|
attr(button3, "class", "query-item__option svelte-1gjzzg7");
|
|||
|
attr(button4, "class", "query-item__option svelte-1gjzzg7");
|
|||
|
attr(div0, "class", "query-item__options svelte-1gjzzg7");
|
|||
|
attr(div1, "class", "query-item svelte-1gjzzg7");
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, div1, anchor);
|
|||
|
append(div1, button0);
|
|||
|
append(button0, t0);
|
|||
|
append(div1, t1);
|
|||
|
append(div1, div0);
|
|||
|
append(div0, button1);
|
|||
|
mount_component(icon0, button1, null);
|
|||
|
append(div0, t2);
|
|||
|
append(div0, button2);
|
|||
|
mount_component(icon1, button2, null);
|
|||
|
append(div0, t3);
|
|||
|
append(div0, button3);
|
|||
|
mount_component(icon2, button3, null);
|
|||
|
append(div0, t4);
|
|||
|
append(div0, button4);
|
|||
|
mount_component(icon3, button4, null);
|
|||
|
current = true;
|
|||
|
if (!mounted) {
|
|||
|
dispose = [
|
|||
|
listen(
|
|||
|
button0,
|
|||
|
"click",
|
|||
|
/*editQuery*/
|
|||
|
ctx[2]
|
|||
|
),
|
|||
|
listen(
|
|||
|
button1,
|
|||
|
"click",
|
|||
|
/*toggleCommandForQuery*/
|
|||
|
ctx[4]
|
|||
|
),
|
|||
|
listen(
|
|||
|
button2,
|
|||
|
"click",
|
|||
|
/*editQuery*/
|
|||
|
ctx[2]
|
|||
|
),
|
|||
|
listen(
|
|||
|
button3,
|
|||
|
"click",
|
|||
|
/*duplicateQuery*/
|
|||
|
ctx[3]
|
|||
|
),
|
|||
|
listen(
|
|||
|
button4,
|
|||
|
"click",
|
|||
|
/*deleteQuery*/
|
|||
|
ctx[1]
|
|||
|
)
|
|||
|
];
|
|||
|
mounted = true;
|
|||
|
}
|
|||
|
},
|
|||
|
p(ctx2, [dirty]) {
|
|||
|
if ((!current || dirty & /*query*/
|
|||
|
1) && t0_value !== (t0_value = /*query*/
|
|||
|
ctx2[0].name + ""))
|
|||
|
set_data(t0, t0_value);
|
|||
|
if (!current || dirty & /*query*/
|
|||
|
1) {
|
|||
|
toggle_class(
|
|||
|
button1,
|
|||
|
"active",
|
|||
|
/*query*/
|
|||
|
ctx2[0].createCommand
|
|||
|
);
|
|||
|
}
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(icon0.$$.fragment, local);
|
|||
|
transition_in(icon1.$$.fragment, local);
|
|||
|
transition_in(icon2.$$.fragment, local);
|
|||
|
transition_in(icon3.$$.fragment, local);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(icon0.$$.fragment, local);
|
|||
|
transition_out(icon1.$$.fragment, local);
|
|||
|
transition_out(icon2.$$.fragment, local);
|
|||
|
transition_out(icon3.$$.fragment, local);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(div1);
|
|||
|
}
|
|||
|
destroy_component(icon0);
|
|||
|
destroy_component(icon1);
|
|||
|
destroy_component(icon2);
|
|||
|
destroy_component(icon3);
|
|||
|
mounted = false;
|
|||
|
run_all(dispose);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function instance5($$self, $$props, $$invalidate) {
|
|||
|
let { query } = $$props;
|
|||
|
const dispatch = createEventDispatcher();
|
|||
|
const deleteQuery = () => {
|
|||
|
dispatch("deleteQuery", { query });
|
|||
|
};
|
|||
|
const editQuery = () => {
|
|||
|
dispatch("editQuery", { query });
|
|||
|
};
|
|||
|
const duplicateQuery = () => {
|
|||
|
dispatch("duplicateQuery", { query });
|
|||
|
};
|
|||
|
const toggleCommandForQuery = () => {
|
|||
|
dispatch("toggleCommandForQuery", { query });
|
|||
|
};
|
|||
|
$$self.$$set = ($$props2) => {
|
|||
|
if ("query" in $$props2)
|
|||
|
$$invalidate(0, query = $$props2.query);
|
|||
|
};
|
|||
|
return [query, deleteQuery, editQuery, duplicateQuery, toggleCommandForQuery];
|
|||
|
}
|
|||
|
var QueryItem = class extends SvelteComponent {
|
|||
|
constructor(options) {
|
|||
|
super();
|
|||
|
init(this, options, instance5, create_fragment5, safe_not_equal, { query: 0 }, add_css3);
|
|||
|
}
|
|||
|
};
|
|||
|
var QueryItem_default = QueryItem;
|
|||
|
|
|||
|
// src/gui/queryItem/QueryList.svelte
|
|||
|
function add_css4(target) {
|
|||
|
append_styles(target, "svelte-1o6bs82", ".query-list.svelte-1o6bs82{display:flex;flex-direction:column;gap:0.25rem}");
|
|||
|
}
|
|||
|
function get_each_context3(ctx, list, i) {
|
|||
|
const child_ctx = ctx.slice();
|
|||
|
child_ctx[7] = list[i];
|
|||
|
child_ctx[8] = list;
|
|||
|
child_ctx[9] = i;
|
|||
|
return child_ctx;
|
|||
|
}
|
|||
|
function create_else_block2(ctx) {
|
|||
|
let p;
|
|||
|
return {
|
|||
|
c() {
|
|||
|
p = element("p");
|
|||
|
p.textContent = "Create a query";
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, p, anchor);
|
|||
|
},
|
|||
|
p: noop,
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(p);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_each_block3(ctx) {
|
|||
|
let queryitem;
|
|||
|
let updating_query;
|
|||
|
let current;
|
|||
|
function queryitem_query_binding(value) {
|
|||
|
ctx[1](
|
|||
|
value,
|
|||
|
/*query*/
|
|||
|
ctx[7],
|
|||
|
/*each_value*/
|
|||
|
ctx[8],
|
|||
|
/*query_index*/
|
|||
|
ctx[9]
|
|||
|
);
|
|||
|
}
|
|||
|
let queryitem_props = {};
|
|||
|
if (
|
|||
|
/*query*/
|
|||
|
ctx[7] !== void 0
|
|||
|
) {
|
|||
|
queryitem_props.query = /*query*/
|
|||
|
ctx[7];
|
|||
|
}
|
|||
|
queryitem = new QueryItem_default({ props: queryitem_props });
|
|||
|
binding_callbacks.push(() => bind(queryitem, "query", queryitem_query_binding));
|
|||
|
queryitem.$on(
|
|||
|
"editQuery",
|
|||
|
/*editQuery_handler*/
|
|||
|
ctx[2]
|
|||
|
);
|
|||
|
queryitem.$on(
|
|||
|
"deleteQuery",
|
|||
|
/*deleteQuery_handler*/
|
|||
|
ctx[3]
|
|||
|
);
|
|||
|
queryitem.$on(
|
|||
|
"duplicateQuery",
|
|||
|
/*duplicateQuery_handler*/
|
|||
|
ctx[4]
|
|||
|
);
|
|||
|
queryitem.$on(
|
|||
|
"toggleCommandForQuery",
|
|||
|
/*toggleCommandForQuery_handler*/
|
|||
|
ctx[5]
|
|||
|
);
|
|||
|
queryitem.$on(
|
|||
|
"saveChanges",
|
|||
|
/*saveChanges_handler*/
|
|||
|
ctx[6]
|
|||
|
);
|
|||
|
return {
|
|||
|
c() {
|
|||
|
create_component(queryitem.$$.fragment);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
mount_component(queryitem, target, anchor);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
p(new_ctx, dirty) {
|
|||
|
ctx = new_ctx;
|
|||
|
const queryitem_changes = {};
|
|||
|
if (!updating_query && dirty & /*queries*/
|
|||
|
1) {
|
|||
|
updating_query = true;
|
|||
|
queryitem_changes.query = /*query*/
|
|||
|
ctx[7];
|
|||
|
add_flush_callback(() => updating_query = false);
|
|||
|
}
|
|||
|
queryitem.$set(queryitem_changes);
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(queryitem.$$.fragment, local);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(queryitem.$$.fragment, local);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
destroy_component(queryitem, detaching);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_fragment6(ctx) {
|
|||
|
let div;
|
|||
|
let current;
|
|||
|
let each_value = ensure_array_like(
|
|||
|
/*queries*/
|
|||
|
ctx[0]
|
|||
|
);
|
|||
|
let each_blocks = [];
|
|||
|
for (let i = 0; i < each_value.length; i += 1) {
|
|||
|
each_blocks[i] = create_each_block3(get_each_context3(ctx, each_value, i));
|
|||
|
}
|
|||
|
const out = (i) => transition_out(each_blocks[i], 1, 1, () => {
|
|||
|
each_blocks[i] = null;
|
|||
|
});
|
|||
|
let each_1_else = null;
|
|||
|
if (!each_value.length) {
|
|||
|
each_1_else = create_else_block2(ctx);
|
|||
|
}
|
|||
|
return {
|
|||
|
c() {
|
|||
|
div = element("div");
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].c();
|
|||
|
}
|
|||
|
if (each_1_else) {
|
|||
|
each_1_else.c();
|
|||
|
}
|
|||
|
attr(div, "class", "query-list svelte-1o6bs82");
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, div, anchor);
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].m(div, null);
|
|||
|
}
|
|||
|
}
|
|||
|
if (each_1_else) {
|
|||
|
each_1_else.m(div, null);
|
|||
|
}
|
|||
|
current = true;
|
|||
|
},
|
|||
|
p(ctx2, [dirty]) {
|
|||
|
if (dirty & /*queries*/
|
|||
|
1) {
|
|||
|
each_value = ensure_array_like(
|
|||
|
/*queries*/
|
|||
|
ctx2[0]
|
|||
|
);
|
|||
|
let i;
|
|||
|
for (i = 0; i < each_value.length; i += 1) {
|
|||
|
const child_ctx = get_each_context3(ctx2, each_value, i);
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].p(child_ctx, dirty);
|
|||
|
transition_in(each_blocks[i], 1);
|
|||
|
} else {
|
|||
|
each_blocks[i] = create_each_block3(child_ctx);
|
|||
|
each_blocks[i].c();
|
|||
|
transition_in(each_blocks[i], 1);
|
|||
|
each_blocks[i].m(div, null);
|
|||
|
}
|
|||
|
}
|
|||
|
group_outros();
|
|||
|
for (i = each_value.length; i < each_blocks.length; i += 1) {
|
|||
|
out(i);
|
|||
|
}
|
|||
|
check_outros();
|
|||
|
if (!each_value.length && each_1_else) {
|
|||
|
each_1_else.p(ctx2, dirty);
|
|||
|
} else if (!each_value.length) {
|
|||
|
each_1_else = create_else_block2(ctx2);
|
|||
|
each_1_else.c();
|
|||
|
each_1_else.m(div, null);
|
|||
|
} else if (each_1_else) {
|
|||
|
each_1_else.d(1);
|
|||
|
each_1_else = null;
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
for (let i = 0; i < each_value.length; i += 1) {
|
|||
|
transition_in(each_blocks[i]);
|
|||
|
}
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
each_blocks = each_blocks.filter(Boolean);
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
transition_out(each_blocks[i]);
|
|||
|
}
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(div);
|
|||
|
}
|
|||
|
destroy_each(each_blocks, detaching);
|
|||
|
if (each_1_else)
|
|||
|
each_1_else.d();
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function instance6($$self, $$props, $$invalidate) {
|
|||
|
let { queries } = $$props;
|
|||
|
function queryitem_query_binding(value, query, each_value, query_index) {
|
|||
|
each_value[query_index] = value;
|
|||
|
$$invalidate(0, queries);
|
|||
|
}
|
|||
|
function editQuery_handler(event) {
|
|||
|
bubble.call(this, $$self, event);
|
|||
|
}
|
|||
|
function deleteQuery_handler(event) {
|
|||
|
bubble.call(this, $$self, event);
|
|||
|
}
|
|||
|
function duplicateQuery_handler(event) {
|
|||
|
bubble.call(this, $$self, event);
|
|||
|
}
|
|||
|
function toggleCommandForQuery_handler(event) {
|
|||
|
bubble.call(this, $$self, event);
|
|||
|
}
|
|||
|
function saveChanges_handler(event) {
|
|||
|
bubble.call(this, $$self, event);
|
|||
|
}
|
|||
|
$$self.$$set = ($$props2) => {
|
|||
|
if ("queries" in $$props2)
|
|||
|
$$invalidate(0, queries = $$props2.queries);
|
|||
|
};
|
|||
|
return [
|
|||
|
queries,
|
|||
|
queryitem_query_binding,
|
|||
|
editQuery_handler,
|
|||
|
deleteQuery_handler,
|
|||
|
duplicateQuery_handler,
|
|||
|
toggleCommandForQuery_handler,
|
|||
|
saveChanges_handler
|
|||
|
];
|
|||
|
}
|
|||
|
var QueryList = class extends SvelteComponent {
|
|||
|
constructor(options) {
|
|||
|
super();
|
|||
|
init(this, options, instance6, create_fragment6, safe_not_equal, { queries: 0 }, add_css4);
|
|||
|
}
|
|||
|
};
|
|||
|
var QueryList_default = QueryList;
|
|||
|
|
|||
|
// src/gui/modals/EditQueryModal/editQueryModal.ts
|
|||
|
var import_obsidian4 = require("obsidian");
|
|||
|
|
|||
|
// src/gui/modals/EditQueryModal/EditQueryModal.svelte
|
|||
|
function add_css5(target) {
|
|||
|
append_styles(target, "svelte-1u40o4f", ".title.svelte-1u40o4f{text-align:center}.title__input.svelte-1u40o4f{text-align:center;background:transparent;padding:0;border:none;font-size:var(--h2-size);width:100%}.content.svelte-1u40o4f{display:flex;flex-direction:column;gap:1em}");
|
|||
|
}
|
|||
|
function get_each_context4(ctx, list, i) {
|
|||
|
const child_ctx = ctx.slice();
|
|||
|
child_ctx[13] = list[i];
|
|||
|
return child_ctx;
|
|||
|
}
|
|||
|
function get_each_context_12(ctx, list, i) {
|
|||
|
const child_ctx = ctx.slice();
|
|||
|
child_ctx[13] = list[i];
|
|||
|
return child_ctx;
|
|||
|
}
|
|||
|
function create_each_block_12(ctx) {
|
|||
|
let option;
|
|||
|
let t_value = (
|
|||
|
/*type*/
|
|||
|
ctx[13] + ""
|
|||
|
);
|
|||
|
let t;
|
|||
|
let option_value_value;
|
|||
|
return {
|
|||
|
c() {
|
|||
|
option = element("option");
|
|||
|
t = text(t_value);
|
|||
|
option.__value = option_value_value = /*type*/
|
|||
|
ctx[13];
|
|||
|
set_input_value(option, option.__value);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, option, anchor);
|
|||
|
append(option, t);
|
|||
|
},
|
|||
|
p: noop,
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(option);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_each_block4(ctx) {
|
|||
|
let option;
|
|||
|
let t_value = (
|
|||
|
/*type*/
|
|||
|
ctx[13] + ""
|
|||
|
);
|
|||
|
let t;
|
|||
|
let option_value_value;
|
|||
|
return {
|
|||
|
c() {
|
|||
|
option = element("option");
|
|||
|
t = text(t_value);
|
|||
|
option.__value = option_value_value = /*type*/
|
|||
|
ctx[13];
|
|||
|
set_input_value(option, option.__value);
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, option, anchor);
|
|||
|
append(option, t);
|
|||
|
},
|
|||
|
p: noop,
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(option);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function create_fragment7(ctx) {
|
|||
|
let h2;
|
|||
|
let input0;
|
|||
|
let t0;
|
|||
|
let div26;
|
|||
|
let div5;
|
|||
|
let div2;
|
|||
|
let t4;
|
|||
|
let div4;
|
|||
|
let div3;
|
|||
|
let input1;
|
|||
|
let t5;
|
|||
|
let div11;
|
|||
|
let div8;
|
|||
|
let t9;
|
|||
|
let div10;
|
|||
|
let div9;
|
|||
|
let input2;
|
|||
|
let t10;
|
|||
|
let div16;
|
|||
|
let div14;
|
|||
|
let t14;
|
|||
|
let div15;
|
|||
|
let select0;
|
|||
|
let t15;
|
|||
|
let div21;
|
|||
|
let div19;
|
|||
|
let t19;
|
|||
|
let div20;
|
|||
|
let select1;
|
|||
|
let t20;
|
|||
|
let div25;
|
|||
|
let div24;
|
|||
|
let div22;
|
|||
|
let t22;
|
|||
|
let div23;
|
|||
|
let t23;
|
|||
|
let t24;
|
|||
|
let textarea;
|
|||
|
let textarea_rows_value;
|
|||
|
let mounted;
|
|||
|
let dispose;
|
|||
|
let each_value_1 = ensure_array_like(QUERY_OPEN_TYPES);
|
|||
|
let each_blocks_1 = [];
|
|||
|
for (let i = 0; i < each_value_1.length; i += 1) {
|
|||
|
each_blocks_1[i] = create_each_block_12(get_each_context_12(ctx, each_value_1, i));
|
|||
|
}
|
|||
|
let each_value = ensure_array_like(QUERY_TYPES);
|
|||
|
let each_blocks = [];
|
|||
|
for (let i = 0; i < each_value.length; i += 1) {
|
|||
|
each_blocks[i] = create_each_block4(get_each_context4(ctx, each_value, i));
|
|||
|
}
|
|||
|
return {
|
|||
|
c() {
|
|||
|
h2 = element("h2");
|
|||
|
input0 = element("input");
|
|||
|
t0 = space();
|
|||
|
div26 = element("div");
|
|||
|
div5 = element("div");
|
|||
|
div2 = element("div");
|
|||
|
div2.innerHTML = `<div class="setting-item-name">Create command</div> <div class="setting-item-description">Make the query into an executable command.</div>`;
|
|||
|
t4 = space();
|
|||
|
div4 = element("div");
|
|||
|
div3 = element("div");
|
|||
|
input1 = element("input");
|
|||
|
t5 = space();
|
|||
|
div11 = element("div");
|
|||
|
div8 = element("div");
|
|||
|
div8.innerHTML = `<div class="setting-item-name">Use disabled folders</div> <div class="setting-item-description">Use disabled folders from settings.</div>`;
|
|||
|
t9 = space();
|
|||
|
div10 = element("div");
|
|||
|
div9 = element("div");
|
|||
|
input2 = element("input");
|
|||
|
t10 = space();
|
|||
|
div16 = element("div");
|
|||
|
div14 = element("div");
|
|||
|
div14.innerHTML = `<div class="setting-item-name">Open in</div> <div class="setting-item-description">Where to open the file.</div>`;
|
|||
|
t14 = space();
|
|||
|
div15 = element("div");
|
|||
|
select0 = element("select");
|
|||
|
for (let i = 0; i < each_blocks_1.length; i += 1) {
|
|||
|
each_blocks_1[i].c();
|
|||
|
}
|
|||
|
t15 = space();
|
|||
|
div21 = element("div");
|
|||
|
div19 = element("div");
|
|||
|
div19.innerHTML = `<div class="setting-item-name">Query type</div> <div class="setting-item-description">Use Regex, Dataview, or the default.</div>`;
|
|||
|
t19 = space();
|
|||
|
div20 = element("div");
|
|||
|
select1 = element("select");
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].c();
|
|||
|
}
|
|||
|
t20 = space();
|
|||
|
div25 = element("div");
|
|||
|
div24 = element("div");
|
|||
|
div22 = element("div");
|
|||
|
div22.textContent = "Query";
|
|||
|
t22 = space();
|
|||
|
div23 = element("div");
|
|||
|
t23 = text(
|
|||
|
/*queryDescription*/
|
|||
|
ctx[2]
|
|||
|
);
|
|||
|
t24 = space();
|
|||
|
textarea = element("textarea");
|
|||
|
attr(input0, "class", "title__input svelte-1u40o4f");
|
|||
|
attr(input0, "type", "text");
|
|||
|
attr(input0, "placeholder", "Query name");
|
|||
|
attr(h2, "class", "title svelte-1u40o4f");
|
|||
|
attr(div2, "class", "setting-item-info");
|
|||
|
attr(input1, "type", "checkbox");
|
|||
|
attr(input1, "tabindex", "0");
|
|||
|
attr(div3, "class", "checkbox-container");
|
|||
|
toggle_class(
|
|||
|
div3,
|
|||
|
"is-enabled",
|
|||
|
/*query*/
|
|||
|
ctx[0].createCommand
|
|||
|
);
|
|||
|
attr(div4, "class", "setting-item-control");
|
|||
|
attr(div5, "class", "setting-item mod-toggle");
|
|||
|
attr(div8, "class", "setting-item-info");
|
|||
|
attr(input2, "type", "checkbox");
|
|||
|
attr(input2, "tabindex", "0");
|
|||
|
attr(div9, "class", "checkbox-container");
|
|||
|
toggle_class(
|
|||
|
div9,
|
|||
|
"is-enabled",
|
|||
|
/*query*/
|
|||
|
ctx[0].useDisabledFolders
|
|||
|
);
|
|||
|
attr(div10, "class", "setting-item-control");
|
|||
|
attr(div11, "class", "setting-item mod-toggle");
|
|||
|
attr(div14, "class", "setting-item-info");
|
|||
|
attr(select0, "class", "dropdown");
|
|||
|
if (
|
|||
|
/*query*/
|
|||
|
ctx[0].openType === void 0
|
|||
|
)
|
|||
|
add_render_callback(() => (
|
|||
|
/*select0_change_handler*/
|
|||
|
ctx[10].call(select0)
|
|||
|
));
|
|||
|
attr(div15, "class", "setting-item-control");
|
|||
|
attr(div16, "class", "setting-item");
|
|||
|
attr(div19, "class", "setting-item-info");
|
|||
|
attr(select1, "class", "dropdown");
|
|||
|
if (
|
|||
|
/*query*/
|
|||
|
ctx[0].type === void 0
|
|||
|
)
|
|||
|
add_render_callback(() => (
|
|||
|
/*select1_change_handler*/
|
|||
|
ctx[11].call(select1)
|
|||
|
));
|
|||
|
attr(div20, "class", "setting-item-control");
|
|||
|
attr(div21, "class", "setting-item");
|
|||
|
attr(div22, "class", "setting-item-name");
|
|||
|
attr(div23, "class", "setting-item-description");
|
|||
|
attr(div24, "class", "setting-item-info");
|
|||
|
attr(textarea, "rows", textarea_rows_value = 12);
|
|||
|
attr(
|
|||
|
textarea,
|
|||
|
"placeholder",
|
|||
|
/*queryPlaceholder*/
|
|||
|
ctx[1]
|
|||
|
);
|
|||
|
attr(div25, "class", "content svelte-1u40o4f");
|
|||
|
attr(div26, "class", "content svelte-1u40o4f");
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, h2, anchor);
|
|||
|
append(h2, input0);
|
|||
|
set_input_value(
|
|||
|
input0,
|
|||
|
/*query*/
|
|||
|
ctx[0].name
|
|||
|
);
|
|||
|
insert(target, t0, anchor);
|
|||
|
insert(target, div26, anchor);
|
|||
|
append(div26, div5);
|
|||
|
append(div5, div2);
|
|||
|
append(div5, t4);
|
|||
|
append(div5, div4);
|
|||
|
append(div4, div3);
|
|||
|
append(div3, input1);
|
|||
|
input1.checked = /*query*/
|
|||
|
ctx[0].createCommand;
|
|||
|
append(div26, t5);
|
|||
|
append(div26, div11);
|
|||
|
append(div11, div8);
|
|||
|
append(div11, t9);
|
|||
|
append(div11, div10);
|
|||
|
append(div10, div9);
|
|||
|
append(div9, input2);
|
|||
|
input2.checked = /*query*/
|
|||
|
ctx[0].useDisabledFolders;
|
|||
|
append(div26, t10);
|
|||
|
append(div26, div16);
|
|||
|
append(div16, div14);
|
|||
|
append(div16, t14);
|
|||
|
append(div16, div15);
|
|||
|
append(div15, select0);
|
|||
|
for (let i = 0; i < each_blocks_1.length; i += 1) {
|
|||
|
if (each_blocks_1[i]) {
|
|||
|
each_blocks_1[i].m(select0, null);
|
|||
|
}
|
|||
|
}
|
|||
|
select_option(
|
|||
|
select0,
|
|||
|
/*query*/
|
|||
|
ctx[0].openType,
|
|||
|
true
|
|||
|
);
|
|||
|
append(div26, t15);
|
|||
|
append(div26, div21);
|
|||
|
append(div21, div19);
|
|||
|
append(div21, t19);
|
|||
|
append(div21, div20);
|
|||
|
append(div20, select1);
|
|||
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].m(select1, null);
|
|||
|
}
|
|||
|
}
|
|||
|
select_option(
|
|||
|
select1,
|
|||
|
/*query*/
|
|||
|
ctx[0].type,
|
|||
|
true
|
|||
|
);
|
|||
|
append(div26, t20);
|
|||
|
append(div26, div25);
|
|||
|
append(div25, div24);
|
|||
|
append(div24, div22);
|
|||
|
append(div24, t22);
|
|||
|
append(div24, div23);
|
|||
|
append(div23, t23);
|
|||
|
append(div25, t24);
|
|||
|
append(div25, textarea);
|
|||
|
set_input_value(
|
|||
|
textarea,
|
|||
|
/*query*/
|
|||
|
ctx[0].query
|
|||
|
);
|
|||
|
if (!mounted) {
|
|||
|
dispose = [
|
|||
|
listen(
|
|||
|
input0,
|
|||
|
"input",
|
|||
|
/*input0_input_handler*/
|
|||
|
ctx[5]
|
|||
|
),
|
|||
|
listen(
|
|||
|
input0,
|
|||
|
"input",
|
|||
|
/*emitHandleChange*/
|
|||
|
ctx[3]
|
|||
|
),
|
|||
|
listen(
|
|||
|
input1,
|
|||
|
"change",
|
|||
|
/*input1_change_handler*/
|
|||
|
ctx[6]
|
|||
|
),
|
|||
|
listen(
|
|||
|
div3,
|
|||
|
"click",
|
|||
|
/*click_handler*/
|
|||
|
ctx[7]
|
|||
|
),
|
|||
|
listen(
|
|||
|
input2,
|
|||
|
"change",
|
|||
|
/*input2_change_handler*/
|
|||
|
ctx[8]
|
|||
|
),
|
|||
|
listen(
|
|||
|
div9,
|
|||
|
"click",
|
|||
|
/*click_handler_1*/
|
|||
|
ctx[9]
|
|||
|
),
|
|||
|
listen(
|
|||
|
select0,
|
|||
|
"change",
|
|||
|
/*select0_change_handler*/
|
|||
|
ctx[10]
|
|||
|
),
|
|||
|
listen(
|
|||
|
select0,
|
|||
|
"change",
|
|||
|
/*emitHandleChange*/
|
|||
|
ctx[3]
|
|||
|
),
|
|||
|
listen(
|
|||
|
select1,
|
|||
|
"change",
|
|||
|
/*select1_change_handler*/
|
|||
|
ctx[11]
|
|||
|
),
|
|||
|
listen(
|
|||
|
select1,
|
|||
|
"change",
|
|||
|
/*emitHandleChange*/
|
|||
|
ctx[3]
|
|||
|
),
|
|||
|
listen(
|
|||
|
textarea,
|
|||
|
"input",
|
|||
|
/*textarea_input_handler*/
|
|||
|
ctx[12]
|
|||
|
),
|
|||
|
listen(
|
|||
|
textarea,
|
|||
|
"input",
|
|||
|
/*emitHandleChange*/
|
|||
|
ctx[3]
|
|||
|
)
|
|||
|
];
|
|||
|
mounted = true;
|
|||
|
}
|
|||
|
},
|
|||
|
p(ctx2, [dirty]) {
|
|||
|
if (dirty & /*query, QUERY_OPEN_TYPES*/
|
|||
|
1 && input0.value !== /*query*/
|
|||
|
ctx2[0].name) {
|
|||
|
set_input_value(
|
|||
|
input0,
|
|||
|
/*query*/
|
|||
|
ctx2[0].name
|
|||
|
);
|
|||
|
}
|
|||
|
if (dirty & /*query, QUERY_OPEN_TYPES*/
|
|||
|
1) {
|
|||
|
input1.checked = /*query*/
|
|||
|
ctx2[0].createCommand;
|
|||
|
}
|
|||
|
if (dirty & /*query*/
|
|||
|
1) {
|
|||
|
toggle_class(
|
|||
|
div3,
|
|||
|
"is-enabled",
|
|||
|
/*query*/
|
|||
|
ctx2[0].createCommand
|
|||
|
);
|
|||
|
}
|
|||
|
if (dirty & /*query, QUERY_OPEN_TYPES*/
|
|||
|
1) {
|
|||
|
input2.checked = /*query*/
|
|||
|
ctx2[0].useDisabledFolders;
|
|||
|
}
|
|||
|
if (dirty & /*query*/
|
|||
|
1) {
|
|||
|
toggle_class(
|
|||
|
div9,
|
|||
|
"is-enabled",
|
|||
|
/*query*/
|
|||
|
ctx2[0].useDisabledFolders
|
|||
|
);
|
|||
|
}
|
|||
|
if (dirty & /*QUERY_OPEN_TYPES*/
|
|||
|
0) {
|
|||
|
each_value_1 = ensure_array_like(QUERY_OPEN_TYPES);
|
|||
|
let i;
|
|||
|
for (i = 0; i < each_value_1.length; i += 1) {
|
|||
|
const child_ctx = get_each_context_12(ctx2, each_value_1, i);
|
|||
|
if (each_blocks_1[i]) {
|
|||
|
each_blocks_1[i].p(child_ctx, dirty);
|
|||
|
} else {
|
|||
|
each_blocks_1[i] = create_each_block_12(child_ctx);
|
|||
|
each_blocks_1[i].c();
|
|||
|
each_blocks_1[i].m(select0, null);
|
|||
|
}
|
|||
|
}
|
|||
|
for (; i < each_blocks_1.length; i += 1) {
|
|||
|
each_blocks_1[i].d(1);
|
|||
|
}
|
|||
|
each_blocks_1.length = each_value_1.length;
|
|||
|
}
|
|||
|
if (dirty & /*query, QUERY_OPEN_TYPES*/
|
|||
|
1) {
|
|||
|
select_option(
|
|||
|
select0,
|
|||
|
/*query*/
|
|||
|
ctx2[0].openType
|
|||
|
);
|
|||
|
}
|
|||
|
if (dirty & /*QUERY_TYPES*/
|
|||
|
0) {
|
|||
|
each_value = ensure_array_like(QUERY_TYPES);
|
|||
|
let i;
|
|||
|
for (i = 0; i < each_value.length; i += 1) {
|
|||
|
const child_ctx = get_each_context4(ctx2, each_value, i);
|
|||
|
if (each_blocks[i]) {
|
|||
|
each_blocks[i].p(child_ctx, dirty);
|
|||
|
} else {
|
|||
|
each_blocks[i] = create_each_block4(child_ctx);
|
|||
|
each_blocks[i].c();
|
|||
|
each_blocks[i].m(select1, null);
|
|||
|
}
|
|||
|
}
|
|||
|
for (; i < each_blocks.length; i += 1) {
|
|||
|
each_blocks[i].d(1);
|
|||
|
}
|
|||
|
each_blocks.length = each_value.length;
|
|||
|
}
|
|||
|
if (dirty & /*query, QUERY_OPEN_TYPES*/
|
|||
|
1) {
|
|||
|
select_option(
|
|||
|
select1,
|
|||
|
/*query*/
|
|||
|
ctx2[0].type
|
|||
|
);
|
|||
|
}
|
|||
|
if (dirty & /*queryDescription*/
|
|||
|
4)
|
|||
|
set_data(
|
|||
|
t23,
|
|||
|
/*queryDescription*/
|
|||
|
ctx2[2]
|
|||
|
);
|
|||
|
if (dirty & /*queryPlaceholder*/
|
|||
|
2) {
|
|||
|
attr(
|
|||
|
textarea,
|
|||
|
"placeholder",
|
|||
|
/*queryPlaceholder*/
|
|||
|
ctx2[1]
|
|||
|
);
|
|||
|
}
|
|||
|
if (dirty & /*query, QUERY_OPEN_TYPES*/
|
|||
|
1) {
|
|||
|
set_input_value(
|
|||
|
textarea,
|
|||
|
/*query*/
|
|||
|
ctx2[0].query
|
|||
|
);
|
|||
|
}
|
|||
|
},
|
|||
|
i: noop,
|
|||
|
o: noop,
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(h2);
|
|||
|
detach(t0);
|
|||
|
detach(div26);
|
|||
|
}
|
|||
|
destroy_each(each_blocks_1, detaching);
|
|||
|
destroy_each(each_blocks, detaching);
|
|||
|
mounted = false;
|
|||
|
run_all(dispose);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function instance7($$self, $$props, $$invalidate) {
|
|||
|
let { query } = $$props;
|
|||
|
let { handleChange } = $$props;
|
|||
|
let queryPlaceholder = "";
|
|||
|
let queryDescription = "";
|
|||
|
const emitHandleChange = () => {
|
|||
|
handleChange(query);
|
|||
|
};
|
|||
|
onDestroy(() => {
|
|||
|
emitHandleChange();
|
|||
|
});
|
|||
|
function input0_input_handler() {
|
|||
|
query.name = this.value;
|
|||
|
$$invalidate(0, query);
|
|||
|
}
|
|||
|
function input1_change_handler() {
|
|||
|
query.createCommand = this.checked;
|
|||
|
$$invalidate(0, query);
|
|||
|
}
|
|||
|
const click_handler = () => {
|
|||
|
$$invalidate(0, query.createCommand = !query.createCommand, query);
|
|||
|
emitHandleChange();
|
|||
|
};
|
|||
|
function input2_change_handler() {
|
|||
|
query.useDisabledFolders = this.checked;
|
|||
|
$$invalidate(0, query);
|
|||
|
}
|
|||
|
const click_handler_1 = () => {
|
|||
|
$$invalidate(0, query.useDisabledFolders = !query.useDisabledFolders, query);
|
|||
|
emitHandleChange();
|
|||
|
};
|
|||
|
function select0_change_handler() {
|
|||
|
query.openType = select_value(this);
|
|||
|
$$invalidate(0, query);
|
|||
|
}
|
|||
|
function select1_change_handler() {
|
|||
|
query.type = select_value(this);
|
|||
|
$$invalidate(0, query);
|
|||
|
}
|
|||
|
function textarea_input_handler() {
|
|||
|
query.query = this.value;
|
|||
|
$$invalidate(0, query);
|
|||
|
}
|
|||
|
$$self.$$set = ($$props2) => {
|
|||
|
if ("query" in $$props2)
|
|||
|
$$invalidate(0, query = $$props2.query);
|
|||
|
if ("handleChange" in $$props2)
|
|||
|
$$invalidate(4, handleChange = $$props2.handleChange);
|
|||
|
};
|
|||
|
$$self.$$.update = () => {
|
|||
|
if ($$self.$$.dirty & /*query*/
|
|||
|
1) {
|
|||
|
$: {
|
|||
|
switch (query.type) {
|
|||
|
case "Dataview":
|
|||
|
$$invalidate(2, queryDescription = "Only works for list queries.");
|
|||
|
$$invalidate(1, queryPlaceholder = "LIST\n...");
|
|||
|
break;
|
|||
|
case "Regex":
|
|||
|
$$invalidate(2, queryDescription = "");
|
|||
|
$$invalidate(1, queryPlaceholder = "Regular Expression...");
|
|||
|
break;
|
|||
|
default:
|
|||
|
$$invalidate(2, queryDescription = "");
|
|||
|
$$invalidate(1, queryPlaceholder = "path: ... file: ... tag: ...");
|
|||
|
break;
|
|||
|
}
|
|||
|
if (query.type === "Dataview") {
|
|||
|
} else if (query.type === "Default") {
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
return [
|
|||
|
query,
|
|||
|
queryPlaceholder,
|
|||
|
queryDescription,
|
|||
|
emitHandleChange,
|
|||
|
handleChange,
|
|||
|
input0_input_handler,
|
|||
|
input1_change_handler,
|
|||
|
click_handler,
|
|||
|
input2_change_handler,
|
|||
|
click_handler_1,
|
|||
|
select0_change_handler,
|
|||
|
select1_change_handler,
|
|||
|
textarea_input_handler
|
|||
|
];
|
|||
|
}
|
|||
|
var EditQueryModal = class extends SvelteComponent {
|
|||
|
constructor(options) {
|
|||
|
super();
|
|||
|
init(this, options, instance7, create_fragment7, safe_not_equal, { query: 0, handleChange: 4 }, add_css5);
|
|||
|
}
|
|||
|
};
|
|||
|
var EditQueryModal_default = EditQueryModal;
|
|||
|
|
|||
|
// src/gui/modals/EditQueryModal/editQueryModal.ts
|
|||
|
var EditQueryModal2 = class extends import_obsidian4.Modal {
|
|||
|
constructor(app, query, handleChange) {
|
|||
|
super(app);
|
|||
|
this.query = query;
|
|||
|
this.view = new EditQueryModal_default({
|
|||
|
target: this.contentEl,
|
|||
|
props: {
|
|||
|
query,
|
|||
|
handleChange
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// src/gui/queryItem/QueryView.svelte
|
|||
|
function add_css6(target) {
|
|||
|
append_styles(target, "svelte-1wfaisu", ".query-list-view.svelte-1wfaisu{display:flex;flex-direction:column;gap:1rem}.query-form.svelte-1wfaisu{display:flex;justify-content:right;gap:var(--size-4-2)}");
|
|||
|
}
|
|||
|
function create_fragment8(ctx) {
|
|||
|
let div;
|
|||
|
let querylist;
|
|||
|
let updating_queries;
|
|||
|
let t0;
|
|||
|
let form;
|
|||
|
let input;
|
|||
|
let t1;
|
|||
|
let button;
|
|||
|
let current;
|
|||
|
let mounted;
|
|||
|
let dispose;
|
|||
|
function querylist_queries_binding(value) {
|
|||
|
ctx[10](value);
|
|||
|
}
|
|||
|
let querylist_props = {};
|
|||
|
if (
|
|||
|
/*queries*/
|
|||
|
ctx[0] !== void 0
|
|||
|
) {
|
|||
|
querylist_props.queries = /*queries*/
|
|||
|
ctx[0];
|
|||
|
}
|
|||
|
querylist = new QueryList_default({ props: querylist_props });
|
|||
|
binding_callbacks.push(() => bind(querylist, "queries", querylist_queries_binding));
|
|||
|
querylist.$on(
|
|||
|
"deleteQuery",
|
|||
|
/*deleteQuery*/
|
|||
|
ctx[2]
|
|||
|
);
|
|||
|
querylist.$on(
|
|||
|
"editQuery",
|
|||
|
/*editQuery*/
|
|||
|
ctx[3]
|
|||
|
);
|
|||
|
querylist.$on(
|
|||
|
"toggleCommandForQuery",
|
|||
|
/*toggleCommandForQuery*/
|
|||
|
ctx[4]
|
|||
|
);
|
|||
|
querylist.$on(
|
|||
|
"duplicateQuery",
|
|||
|
/*duplicateQuery*/
|
|||
|
ctx[5]
|
|||
|
);
|
|||
|
querylist.$on(
|
|||
|
"saveChanges",
|
|||
|
/*saveChanges*/
|
|||
|
ctx[7]
|
|||
|
);
|
|||
|
return {
|
|||
|
c() {
|
|||
|
div = element("div");
|
|||
|
create_component(querylist.$$.fragment);
|
|||
|
t0 = space();
|
|||
|
form = element("form");
|
|||
|
input = element("input");
|
|||
|
t1 = space();
|
|||
|
button = element("button");
|
|||
|
button.textContent = "Add Query";
|
|||
|
attr(input, "type", "text");
|
|||
|
attr(input, "placeholder", "Name");
|
|||
|
attr(button, "class", "mod-cta");
|
|||
|
attr(button, "type", "submit");
|
|||
|
attr(form, "class", "query-form svelte-1wfaisu");
|
|||
|
attr(div, "class", "query-list-view svelte-1wfaisu");
|
|||
|
},
|
|||
|
m(target, anchor) {
|
|||
|
insert(target, div, anchor);
|
|||
|
mount_component(querylist, div, null);
|
|||
|
append(div, t0);
|
|||
|
append(div, form);
|
|||
|
append(form, input);
|
|||
|
set_input_value(
|
|||
|
input,
|
|||
|
/*queryFormName*/
|
|||
|
ctx[1]
|
|||
|
);
|
|||
|
append(form, t1);
|
|||
|
append(form, button);
|
|||
|
current = true;
|
|||
|
if (!mounted) {
|
|||
|
dispose = [
|
|||
|
listen(
|
|||
|
input,
|
|||
|
"input",
|
|||
|
/*input_input_handler*/
|
|||
|
ctx[11]
|
|||
|
),
|
|||
|
listen(form, "submit", prevent_default(
|
|||
|
/*handleSubmit*/
|
|||
|
ctx[6]
|
|||
|
))
|
|||
|
];
|
|||
|
mounted = true;
|
|||
|
}
|
|||
|
},
|
|||
|
p(ctx2, [dirty]) {
|
|||
|
const querylist_changes = {};
|
|||
|
if (!updating_queries && dirty & /*queries*/
|
|||
|
1) {
|
|||
|
updating_queries = true;
|
|||
|
querylist_changes.queries = /*queries*/
|
|||
|
ctx2[0];
|
|||
|
add_flush_callback(() => updating_queries = false);
|
|||
|
}
|
|||
|
querylist.$set(querylist_changes);
|
|||
|
if (dirty & /*queryFormName*/
|
|||
|
2 && input.value !== /*queryFormName*/
|
|||
|
ctx2[1]) {
|
|||
|
set_input_value(
|
|||
|
input,
|
|||
|
/*queryFormName*/
|
|||
|
ctx2[1]
|
|||
|
);
|
|||
|
}
|
|||
|
},
|
|||
|
i(local) {
|
|||
|
if (current)
|
|||
|
return;
|
|||
|
transition_in(querylist.$$.fragment, local);
|
|||
|
current = true;
|
|||
|
},
|
|||
|
o(local) {
|
|||
|
transition_out(querylist.$$.fragment, local);
|
|||
|
current = false;
|
|||
|
},
|
|||
|
d(detaching) {
|
|||
|
if (detaching) {
|
|||
|
detach(div);
|
|||
|
}
|
|||
|
destroy_component(querylist);
|
|||
|
mounted = false;
|
|||
|
run_all(dispose);
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
function instance8($$self, $$props, $$invalidate) {
|
|||
|
let { plugin } = $$props;
|
|||
|
let { queries } = $$props;
|
|||
|
let { saveQueries } = $$props;
|
|||
|
let queryFormName = "";
|
|||
|
const deleteQuery = (e) => {
|
|||
|
const query = e.detail.query;
|
|||
|
$$invalidate(0, queries = queries.filter((q) => q.id !== query.id));
|
|||
|
plugin.removeQueryCommand(query);
|
|||
|
saveQueries(queries);
|
|||
|
};
|
|||
|
const editQuery = (e) => {
|
|||
|
const query = e.detail.query;
|
|||
|
const modal = new EditQueryModal2(
|
|||
|
plugin.app,
|
|||
|
query,
|
|||
|
(query2) => {
|
|||
|
addOrRemoveQueryCommand(plugin, query2);
|
|||
|
$$invalidate(0, queries);
|
|||
|
saveQueries(queries);
|
|||
|
}
|
|||
|
);
|
|||
|
modal.open();
|
|||
|
$$invalidate(0, queries);
|
|||
|
saveQueries(queries);
|
|||
|
};
|
|||
|
const toggleCommandForQuery = (e) => {
|
|||
|
const query = e.detail.query;
|
|||
|
query.createCommand = !query.createCommand;
|
|||
|
$$invalidate(0, queries);
|
|||
|
addOrRemoveQueryCommand(plugin, query);
|
|||
|
saveQueries(queries);
|
|||
|
};
|
|||
|
const duplicateQuery = (e) => {
|
|||
|
const query = e.detail.query;
|
|||
|
const queryClone = structuredClone(query);
|
|||
|
queryClone.id = getQueryCommandId();
|
|||
|
queryClone.name = queryClone.name + " (Copy)";
|
|||
|
$$invalidate(0, queries = [...queries, queryClone]);
|
|||
|
saveQueries(queries);
|
|||
|
if (query.createCommand) {
|
|||
|
plugin.addQueryCommand(query);
|
|||
|
}
|
|||
|
};
|
|||
|
const handleSubmit = () => {
|
|||
|
if (queryFormName.trim() === "")
|
|||
|
return;
|
|||
|
$$invalidate(0, queries = [...queries, createQuery(queryFormName, "")]);
|
|||
|
$$invalidate(1, queryFormName = "");
|
|||
|
saveQueries(queries);
|
|||
|
};
|
|||
|
const saveChanges = () => {
|
|||
|
$$invalidate(0, queries);
|
|||
|
saveQueries(queries);
|
|||
|
};
|
|||
|
function querylist_queries_binding(value) {
|
|||
|
queries = value;
|
|||
|
$$invalidate(0, queries);
|
|||
|
}
|
|||
|
function input_input_handler() {
|
|||
|
queryFormName = this.value;
|
|||
|
$$invalidate(1, queryFormName);
|
|||
|
}
|
|||
|
$$self.$$set = ($$props2) => {
|
|||
|
if ("plugin" in $$props2)
|
|||
|
$$invalidate(8, plugin = $$props2.plugin);
|
|||
|
if ("queries" in $$props2)
|
|||
|
$$invalidate(0, queries = $$props2.queries);
|
|||
|
if ("saveQueries" in $$props2)
|
|||
|
$$invalidate(9, saveQueries = $$props2.saveQueries);
|
|||
|
};
|
|||
|
return [
|
|||
|
queries,
|
|||
|
queryFormName,
|
|||
|
deleteQuery,
|
|||
|
editQuery,
|
|||
|
toggleCommandForQuery,
|
|||
|
duplicateQuery,
|
|||
|
handleSubmit,
|
|||
|
saveChanges,
|
|||
|
plugin,
|
|||
|
saveQueries,
|
|||
|
querylist_queries_binding,
|
|||
|
input_input_handler
|
|||
|
];
|
|||
|
}
|
|||
|
var QueryView = class extends SvelteComponent {
|
|||
|
constructor(options) {
|
|||
|
super();
|
|||
|
init(this, options, instance8, create_fragment8, safe_not_equal, { plugin: 8, queries: 0, saveQueries: 9 }, add_css6);
|
|||
|
}
|
|||
|
};
|
|||
|
var QueryView_default = QueryView;
|
|||
|
|
|||
|
// src/settings.ts
|
|||
|
var DEFAULT_SETTINGS = {
|
|||
|
queries: [],
|
|||
|
disabledFolders: "",
|
|||
|
debug: false,
|
|||
|
openType: "Active Leaf",
|
|||
|
setActive: true
|
|||
|
};
|
|||
|
var SettingTab = class extends import_obsidian5.PluginSettingTab {
|
|||
|
constructor(app, plugin) {
|
|||
|
super(app, plugin);
|
|||
|
this.plugin = plugin;
|
|||
|
}
|
|||
|
display() {
|
|||
|
this.containerEl.empty();
|
|||
|
this.addSetting();
|
|||
|
this.addQueriesSetting();
|
|||
|
}
|
|||
|
addSetting() {
|
|||
|
new import_obsidian5.Setting(this.containerEl).setName("Open files as active").setDesc("Make files active when they are opened.").addToggle((toggle) => {
|
|||
|
toggle.setValue(this.plugin.settings.setActive).onChange(async (value) => {
|
|||
|
this.plugin.settings.setActive = value;
|
|||
|
await this.plugin.saveSettings();
|
|||
|
});
|
|||
|
});
|
|||
|
new import_obsidian5.Setting(this.containerEl).setName("Open in").setDesc("Where to open files.").addDropdown(
|
|||
|
(dropdown) => dropdown.addOptions(toRecord(getOpenTypeLabels())).setValue(this.plugin.settings.openType).onChange(async (value) => {
|
|||
|
this.plugin.settings.openType = value;
|
|||
|
await this.plugin.saveSettings();
|
|||
|
})
|
|||
|
);
|
|||
|
new import_obsidian5.Setting(this.containerEl).setName("Disabled folders").setDesc("Skips these folders when searching for files.").addTextArea((text2) => {
|
|||
|
text2.setPlaceholder("templates/").setValue(this.plugin.settings.disabledFolders).onChange(async (value) => {
|
|||
|
this.plugin.settings.disabledFolders = value.trim();
|
|||
|
await this.plugin.saveSettings();
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
addQueriesSetting() {
|
|||
|
this.containerEl.createEl("div", {
|
|||
|
text: "Queries",
|
|||
|
cls: "setting-item setting-item-heading"
|
|||
|
});
|
|||
|
const setting = new import_obsidian5.Setting(this.containerEl);
|
|||
|
setting.infoEl.remove();
|
|||
|
setting.settingEl.style.display = "block";
|
|||
|
new QueryView_default({
|
|||
|
target: setting.settingEl,
|
|||
|
props: {
|
|||
|
plugin: this.plugin,
|
|||
|
queries: this.plugin.settings.queries,
|
|||
|
saveQueries: async (queries) => {
|
|||
|
this.plugin.settings.queries = queries;
|
|||
|
await this.plugin.saveSettings();
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// src/main.ts
|
|||
|
var AdvancedRandomNote = class extends import_obsidian6.Plugin {
|
|||
|
async onload() {
|
|||
|
await this.loadSettings();
|
|||
|
this.addCommand({
|
|||
|
id: "open-query-modal",
|
|||
|
name: "Open query modal",
|
|||
|
callback: () => this.handleOpenRandomFileModal()
|
|||
|
});
|
|||
|
this.addCommand({
|
|||
|
id: "open-random-note",
|
|||
|
name: "Open random note",
|
|||
|
callback: () => {
|
|||
|
this.openRandomMarkdownFile();
|
|||
|
}
|
|||
|
});
|
|||
|
this.addCommand({
|
|||
|
id: "open-random-file",
|
|||
|
name: "Open random file",
|
|||
|
callback: () => {
|
|||
|
this.openRandomVaultFile();
|
|||
|
}
|
|||
|
});
|
|||
|
this.addRibbonIcon("dice", "Open random note modal", () => {
|
|||
|
this.handleOpenRandomFileModal();
|
|||
|
});
|
|||
|
this.registerEvent(
|
|||
|
this.app.workspace.on("file-menu", (menu, file) => {
|
|||
|
if (!(file instanceof import_obsidian6.TFolder) || file.isRoot())
|
|||
|
return;
|
|||
|
menu.addItem((item) => {
|
|||
|
item.setTitle("Open random note").setIcon("dice").onClick(async () => {
|
|||
|
const files = flattenFile(file);
|
|||
|
const foundFiles = await new Search(
|
|||
|
this
|
|||
|
).searchFiles(files, file.path + "/");
|
|||
|
this.openRandomFile(foundFiles);
|
|||
|
});
|
|||
|
});
|
|||
|
})
|
|||
|
);
|
|||
|
this.addQueryCommands();
|
|||
|
this.addSettingTab(new SettingTab(this.app, this));
|
|||
|
if (this.settings.debug) {
|
|||
|
console.log("Loaded " + this.manifest.name);
|
|||
|
}
|
|||
|
}
|
|||
|
async loadSettings() {
|
|||
|
this.settings = Object.assign(
|
|||
|
{},
|
|||
|
DEFAULT_SETTINGS,
|
|||
|
await this.loadData()
|
|||
|
);
|
|||
|
}
|
|||
|
async saveSettings() {
|
|||
|
await this.saveData(this.settings);
|
|||
|
}
|
|||
|
async openFile(file, openType = "Default") {
|
|||
|
if (openType === "Default")
|
|||
|
openType = this.settings.openType;
|
|||
|
switch (openType) {
|
|||
|
case "New Window":
|
|||
|
await this.app.workspace.getLeaf("window").openFile(file, { active: this.settings.setActive });
|
|||
|
return;
|
|||
|
case "New Leaf":
|
|||
|
await this.app.workspace.getLeaf("tab").openFile(file, { active: this.settings.setActive });
|
|||
|
return;
|
|||
|
default:
|
|||
|
await this.app.workspace.openLinkText(file.path, "", false, {
|
|||
|
active: this.settings.setActive
|
|||
|
});
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
async openRandomFile(files, openType = "Default") {
|
|||
|
const file = getRandomElement(files);
|
|||
|
if (!file)
|
|||
|
return;
|
|||
|
if (this.settings.debug) {
|
|||
|
console.log("Found and opened file:");
|
|||
|
console.log(file);
|
|||
|
}
|
|||
|
await this.openFile(file, openType);
|
|||
|
}
|
|||
|
async openRandomMarkdownFile() {
|
|||
|
const foundFiles = await new Search(this).searchFiles(
|
|||
|
this.app.vault.getMarkdownFiles()
|
|||
|
);
|
|||
|
await this.openRandomFile(foundFiles);
|
|||
|
}
|
|||
|
async openRandomVaultFile() {
|
|||
|
const foundFiles = await new Search(this).searchFiles(
|
|||
|
this.app.vault.getFiles()
|
|||
|
);
|
|||
|
await this.openRandomFile(foundFiles);
|
|||
|
}
|
|||
|
handleOpenRandomFileModal() {
|
|||
|
const modal = new RandomNoteModal(
|
|||
|
this.app,
|
|||
|
this.settings.queries,
|
|||
|
async (query) => this.executeQuery(query)
|
|||
|
);
|
|||
|
modal.open();
|
|||
|
}
|
|||
|
async executeQuery(query) {
|
|||
|
const files = await new Search(this).search(query);
|
|||
|
if (files.length <= 0) {
|
|||
|
return;
|
|||
|
}
|
|||
|
await this.openRandomFile(files, query.openType);
|
|||
|
}
|
|||
|
addQueryCommands() {
|
|||
|
this.settings.queries.forEach(
|
|||
|
(query) => query.createCommand && this.addQueryCommand(query)
|
|||
|
);
|
|||
|
}
|
|||
|
addQueryCommand(query) {
|
|||
|
this.addCommand({
|
|||
|
id: query.id,
|
|||
|
name: query.name,
|
|||
|
callback: async () => this.executeQuery(query)
|
|||
|
});
|
|||
|
}
|
|||
|
removeQueryCommand(query) {
|
|||
|
deleteObsidianCommand(
|
|||
|
this.app,
|
|||
|
getPluginCommandId(query.id, this.manifest)
|
|||
|
);
|
|||
|
}
|
|||
|
};
|
|||
|
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9sdXhvbi9zcmMvZXJyb3JzLmpzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9ub2RlX21vZHVsZXMvbHV4b24vc3JjL2ltcGwvZm9ybWF0cy5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvbm9kZV9tb2R1bGVzL2x1eG9uL3NyYy96b25lLmpzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9ub2RlX21vZHVsZXMvbHV4b24vc3JjL3pvbmVzL3N5c3RlbVpvbmUuanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9sdXhvbi9zcmMvem9uZXMvSUFOQVpvbmUuanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9sdXhvbi9zcmMvaW1wbC9sb2NhbGUuanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9sdXhvbi9zcmMvem9uZXMvZml4ZWRPZmZzZXRab25lLmpzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9ub2RlX21vZHVsZXMvbHV4b24vc3JjL3pvbmVzL2ludmFsaWRab25lLmpzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9ub2RlX21vZHVsZXMvbHV4b24vc3JjL2ltcGwvem9uZVV0aWwuanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9sdXhvbi9zcmMvc2V0dGluZ3MuanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9sdXhvbi9zcmMvaW1wbC91dGlsLmpzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9ub2RlX21vZHVsZXMvbHV4b24vc3JjL2ltcGwvZW5nbGlzaC5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvbm9kZV9tb2R1bGVzL2x1eG9uL3NyYy9pbXBsL2Zvcm1hdHRlci5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvbm9kZV9tb2R1bGVzL2x1eG9uL3NyYy9pbXBsL2ludmFsaWQuanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9sdXhvbi9zcmMvaW1wbC9yZWdleFBhcnNlci5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvbm9kZV9tb2R1bGVzL2x1eG9uL3NyYy9kdXJhdGlvbi5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvbm9kZV9tb2R1bGVzL2x1eG9uL3NyYy9pbnRlcnZhbC5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvbm9kZV9tb2R1bGVzL2x1eG9uL3NyYy9pbmZvLmpzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9ub2RlX21vZHVsZXMvbHV4b24vc3JjL2ltcGwvZGlmZi5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvbm9kZV9tb2R1bGVzL2x1eG9uL3NyYy9pbXBsL2RpZ2l0cy5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvbm9kZV9tb2R1bGVzL2x1eG9uL3NyYy9pbXBsL3Rva2VuUGFyc2VyLmpzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9ub2RlX21vZHVsZXMvbHV4b24vc3JjL2ltcGwvY29udmVyc2lvbnMuanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9sdXhvbi9zcmMvZGF0ZXRpbWUuanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L3NyYy9zZXR0aW5ncy50cyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvc3JjL2FwaS9yZXN1bHQudHMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9wYXJzaW1tb24vYnVpbGQvcGFyc2ltbW9uLnVtZC5taW4uanMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L25vZGVfbW9kdWxlcy9lbW9qaS1yZWdleC9pbmRleC5qcyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvc3JjL3V0aWwvbm9ybWFsaXplLnRzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9zcmMvZGF0YS1tb2RlbC92YWx1ZS50cyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvc3JjL2V4cHJlc3Npb24vZmllbGQudHMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L3NyYy9kYXRhLWluZGV4L3NvdXJjZS50cyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvc3JjL2V4cHJlc3Npb24vcGFyc2UudHMiLCAibm9kZV9tb2R1bGVzL29ic2lkaWFuLWRhdGF2aWV3L3NyYy9xdWVyeS9xdWVyeS50cyIsICJub2RlX21vZHVsZXMvb2JzaWRpYW4tZGF0YXZpZXcvc3JjL3F1ZXJ5L3BhcnNlLnRzIiwgIm5vZGVfbW9kdWxlcy9vYnNpZGlhbi1kYXRhdmlldy9zcmMvaW5kZXgudHMiLCAic3JjL21haW4udHMiLCAic3JjL2d1aS9tb2RhbHMvT3BlblJhbmRvbU5vdGVNb2RhbC9vcGVuUmFuZG9tTm90ZU1vZGFsLnRzIiwgIm5vZGVfbW9kdWxlcy9zdmVsdGUvc3JjL3J1bnRpbWUvaW50ZXJuYWwvdXRpbHMuanMiLCAibm9kZV9tb2R1bGVzL3N2ZWx0ZS9zcmMvcnVudGltZS9pbnRlcm5hbC9nbG9iYWxzLmpzIiwgIm5vZGVfbW9kdWxlcy9zdmVsdGUvc3JjL3J1bnRpbWUvaW50ZXJuYWwvUmVzaXplT2JzZXJ2ZXJTaW5nbGV0b24uanMiLCAibm9kZV9tb2R1bGVzL3N2ZWx0ZS9zcmMvcnVudGltZS9pbnRlcm5hbC9kb20uanMiLCAibm9kZV9tb2R1bGVzL3N2ZWx0ZS9zcmMvcnVudGltZS9pbnRlcm5hbC9saWZlY3ljbGUuanMiLCAibm9kZV9tb2R1bGVzL3N2ZWx0ZS9zcmMvcnVudGltZS9pbnRlcm5hbC9zY2hlZHVsZXIuanMiLCAibm9kZV9tb2R1bGVzL3N2ZWx0ZS9zcmMvcnVudGltZS9pbnRlcm5hbC90cmFuc2l0aW9ucy5qcyIsICJub2RlX21vZHVsZXMvc3ZlbHRlL3NyYy9ydW50aW1lL2ludGVybmFsL2VhY2guanMiLCAibm9kZV9tb2R1bGVzL3N2ZWx0ZS9zcmMvcnVudGltZS9pbnRlcm5hbC9zcHJlYWQuanMiLCAibm9kZV9tb2R1bGVzL3N2ZWx0ZS9zcmMvc2hhcmVkL2Jvb2xlYW5fYXR0cmlidXRlcy5qc
|