27550 lines
964 KiB
JavaScript
27550 lines
964 KiB
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 __defProps = Object.defineProperties;
|
||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||
var __getProtoOf = Object.getPrototypeOf;
|
||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||
var __spreadValues = (a, b) => {
|
||
for (var prop in b || (b = {}))
|
||
if (__hasOwnProp.call(b, prop))
|
||
__defNormalProp(a, prop, b[prop]);
|
||
if (__getOwnPropSymbols)
|
||
for (var prop of __getOwnPropSymbols(b)) {
|
||
if (__propIsEnum.call(b, prop))
|
||
__defNormalProp(a, prop, b[prop]);
|
||
}
|
||
return a;
|
||
};
|
||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||
var __objRest = (source, exclude) => {
|
||
var target = {};
|
||
for (var prop in source)
|
||
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
||
target[prop] = source[prop];
|
||
if (source != null && __getOwnPropSymbols)
|
||
for (var prop of __getOwnPropSymbols(source)) {
|
||
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
||
target[prop] = source[prop];
|
||
}
|
||
return target;
|
||
};
|
||
var __commonJS = (cb, mod) => function __require() {
|
||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||
};
|
||
var __export = (target, all3) => {
|
||
for (var name in all3)
|
||
__defProp(target, name, { get: all3[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;
|
||
};
|
||
var __async = (__this, __arguments, generator) => {
|
||
return new Promise((resolve, reject) => {
|
||
var fulfilled = (value) => {
|
||
try {
|
||
step(generator.next(value));
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
};
|
||
var rejected = (value) => {
|
||
try {
|
||
step(generator.throw(value));
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
};
|
||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||
step((generator = generator.apply(__this, __arguments)).next());
|
||
});
|
||
};
|
||
|
||
// 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 LuxonError2 = class extends Error {
|
||
};
|
||
var InvalidDateTimeError2 = class extends LuxonError2 {
|
||
constructor(reason) {
|
||
super(`Invalid DateTime: ${reason.toMessage()}`);
|
||
}
|
||
};
|
||
var InvalidIntervalError2 = class extends LuxonError2 {
|
||
constructor(reason) {
|
||
super(`Invalid Interval: ${reason.toMessage()}`);
|
||
}
|
||
};
|
||
var InvalidDurationError2 = class extends LuxonError2 {
|
||
constructor(reason) {
|
||
super(`Invalid Duration: ${reason.toMessage()}`);
|
||
}
|
||
};
|
||
var ConflictingSpecificationError2 = class extends LuxonError2 {
|
||
};
|
||
var InvalidUnitError2 = class extends LuxonError2 {
|
||
constructor(unit) {
|
||
super(`Invalid unit ${unit}`);
|
||
}
|
||
};
|
||
var InvalidArgumentError2 = class extends LuxonError2 {
|
||
};
|
||
var ZoneIsAbstractError2 = class extends LuxonError2 {
|
||
constructor() {
|
||
super("Zone is an abstract class");
|
||
}
|
||
};
|
||
var n2 = "numeric";
|
||
var s2 = "short";
|
||
var l2 = "long";
|
||
var DATE_SHORT2 = {
|
||
year: n2,
|
||
month: n2,
|
||
day: n2
|
||
};
|
||
var DATE_MED2 = {
|
||
year: n2,
|
||
month: s2,
|
||
day: n2
|
||
};
|
||
var DATE_MED_WITH_WEEKDAY2 = {
|
||
year: n2,
|
||
month: s2,
|
||
day: n2,
|
||
weekday: s2
|
||
};
|
||
var DATE_FULL2 = {
|
||
year: n2,
|
||
month: l2,
|
||
day: n2
|
||
};
|
||
var DATE_HUGE2 = {
|
||
year: n2,
|
||
month: l2,
|
||
day: n2,
|
||
weekday: l2
|
||
};
|
||
var TIME_SIMPLE2 = {
|
||
hour: n2,
|
||
minute: n2
|
||
};
|
||
var TIME_WITH_SECONDS2 = {
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2
|
||
};
|
||
var TIME_WITH_SHORT_OFFSET2 = {
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2,
|
||
timeZoneName: s2
|
||
};
|
||
var TIME_WITH_LONG_OFFSET2 = {
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2,
|
||
timeZoneName: l2
|
||
};
|
||
var TIME_24_SIMPLE2 = {
|
||
hour: n2,
|
||
minute: n2,
|
||
hourCycle: "h23"
|
||
};
|
||
var TIME_24_WITH_SECONDS2 = {
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2,
|
||
hourCycle: "h23"
|
||
};
|
||
var TIME_24_WITH_SHORT_OFFSET2 = {
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2,
|
||
hourCycle: "h23",
|
||
timeZoneName: s2
|
||
};
|
||
var TIME_24_WITH_LONG_OFFSET2 = {
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2,
|
||
hourCycle: "h23",
|
||
timeZoneName: l2
|
||
};
|
||
var DATETIME_SHORT2 = {
|
||
year: n2,
|
||
month: n2,
|
||
day: n2,
|
||
hour: n2,
|
||
minute: n2
|
||
};
|
||
var DATETIME_SHORT_WITH_SECONDS2 = {
|
||
year: n2,
|
||
month: n2,
|
||
day: n2,
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2
|
||
};
|
||
var DATETIME_MED2 = {
|
||
year: n2,
|
||
month: s2,
|
||
day: n2,
|
||
hour: n2,
|
||
minute: n2
|
||
};
|
||
var DATETIME_MED_WITH_SECONDS2 = {
|
||
year: n2,
|
||
month: s2,
|
||
day: n2,
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2
|
||
};
|
||
var DATETIME_MED_WITH_WEEKDAY2 = {
|
||
year: n2,
|
||
month: s2,
|
||
day: n2,
|
||
weekday: s2,
|
||
hour: n2,
|
||
minute: n2
|
||
};
|
||
var DATETIME_FULL2 = {
|
||
year: n2,
|
||
month: l2,
|
||
day: n2,
|
||
hour: n2,
|
||
minute: n2,
|
||
timeZoneName: s2
|
||
};
|
||
var DATETIME_FULL_WITH_SECONDS2 = {
|
||
year: n2,
|
||
month: l2,
|
||
day: n2,
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2,
|
||
timeZoneName: s2
|
||
};
|
||
var DATETIME_HUGE2 = {
|
||
year: n2,
|
||
month: l2,
|
||
day: n2,
|
||
weekday: l2,
|
||
hour: n2,
|
||
minute: n2,
|
||
timeZoneName: l2
|
||
};
|
||
var DATETIME_HUGE_WITH_SECONDS2 = {
|
||
year: n2,
|
||
month: l2,
|
||
day: n2,
|
||
weekday: l2,
|
||
hour: n2,
|
||
minute: n2,
|
||
second: n2,
|
||
timeZoneName: l2
|
||
};
|
||
var Zone2 = class {
|
||
/**
|
||
* The type of zone
|
||
* @abstract
|
||
* @type {string}
|
||
*/
|
||
get type() {
|
||
throw new ZoneIsAbstractError2();
|
||
}
|
||
/**
|
||
* The name of this zone.
|
||
* @abstract
|
||
* @type {string}
|
||
*/
|
||
get name() {
|
||
throw new ZoneIsAbstractError2();
|
||
}
|
||
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 ZoneIsAbstractError2();
|
||
}
|
||
/**
|
||
* 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 ZoneIsAbstractError2();
|
||
}
|
||
/**
|
||
* 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 ZoneIsAbstractError2();
|
||
}
|
||
/**
|
||
* 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 ZoneIsAbstractError2();
|
||
}
|
||
/**
|
||
* Return whether this Zone is equal to another zone
|
||
* @abstract
|
||
* @param {Zone} otherZone - the zone to compare
|
||
* @return {boolean}
|
||
*/
|
||
equals(otherZone) {
|
||
throw new ZoneIsAbstractError2();
|
||
}
|
||
/**
|
||
* Return whether this Zone is valid.
|
||
* @abstract
|
||
* @type {boolean}
|
||
*/
|
||
get isValid() {
|
||
throw new ZoneIsAbstractError2();
|
||
}
|
||
};
|
||
var singleton$1 = null;
|
||
var SystemZone2 = class _SystemZone extends Zone2 {
|
||
/**
|
||
* 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 parseZoneInfo2(ts, format, locale);
|
||
}
|
||
/** @override **/
|
||
formatOffset(ts, format) {
|
||
return formatOffset2(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 dtfCache2 = {};
|
||
function makeDTF2(zone) {
|
||
if (!dtfCache2[zone]) {
|
||
dtfCache2[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 dtfCache2[zone];
|
||
}
|
||
var typeToPos2 = {
|
||
year: 0,
|
||
month: 1,
|
||
day: 2,
|
||
era: 3,
|
||
hour: 4,
|
||
minute: 5,
|
||
second: 6
|
||
};
|
||
function hackyOffset2(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 partsOffset2(dtf, date) {
|
||
const formatted = dtf.formatToParts(date);
|
||
const filled = [];
|
||
for (let i = 0; i < formatted.length; i++) {
|
||
const { type, value } = formatted[i];
|
||
const pos = typeToPos2[type];
|
||
if (type === "era") {
|
||
filled[pos] = value;
|
||
} else if (!isUndefined3(pos)) {
|
||
filled[pos] = parseInt(value, 10);
|
||
}
|
||
}
|
||
return filled;
|
||
}
|
||
var ianaZoneCache2 = {};
|
||
var IANAZone2 = class _IANAZone extends Zone2 {
|
||
/**
|
||
* @param {string} name - Zone name
|
||
* @return {IANAZone}
|
||
*/
|
||
static create(name) {
|
||
if (!ianaZoneCache2[name]) {
|
||
ianaZoneCache2[name] = new _IANAZone(name);
|
||
}
|
||
return ianaZoneCache2[name];
|
||
}
|
||
/**
|
||
* Reset local caches. Should only be necessary in testing scenarios.
|
||
* @return {void}
|
||
*/
|
||
static resetCache() {
|
||
ianaZoneCache2 = {};
|
||
dtfCache2 = {};
|
||
}
|
||
/**
|
||
* 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(s3) {
|
||
return this.isValidZone(s3);
|
||
}
|
||
/**
|
||
* 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 parseZoneInfo2(ts, format, locale, this.name);
|
||
}
|
||
/** @override **/
|
||
formatOffset(ts, format) {
|
||
return formatOffset2(this.offset(ts), format);
|
||
}
|
||
/** @override **/
|
||
offset(ts) {
|
||
const date = new Date(ts);
|
||
if (isNaN(date))
|
||
return NaN;
|
||
const dtf = makeDTF2(this.name);
|
||
let [year, month, day, adOrBc, hour, minute, second] = dtf.formatToParts ? partsOffset2(dtf, date) : hackyOffset2(dtf, date);
|
||
if (adOrBc === "BC") {
|
||
year = -Math.abs(year) + 1;
|
||
}
|
||
const adjustedHour = hour === 24 ? 0 : hour;
|
||
const asUTC = objToLocalTS2({
|
||
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 intlLFCache2 = {};
|
||
function getCachedLF2(locString, opts = {}) {
|
||
const key = JSON.stringify([locString, opts]);
|
||
let dtf = intlLFCache2[key];
|
||
if (!dtf) {
|
||
dtf = new Intl.ListFormat(locString, opts);
|
||
intlLFCache2[key] = dtf;
|
||
}
|
||
return dtf;
|
||
}
|
||
var intlDTCache2 = {};
|
||
function getCachedDTF2(locString, opts = {}) {
|
||
const key = JSON.stringify([locString, opts]);
|
||
let dtf = intlDTCache2[key];
|
||
if (!dtf) {
|
||
dtf = new Intl.DateTimeFormat(locString, opts);
|
||
intlDTCache2[key] = dtf;
|
||
}
|
||
return dtf;
|
||
}
|
||
var intlNumCache2 = {};
|
||
function getCachedINF2(locString, opts = {}) {
|
||
const key = JSON.stringify([locString, opts]);
|
||
let inf = intlNumCache2[key];
|
||
if (!inf) {
|
||
inf = new Intl.NumberFormat(locString, opts);
|
||
intlNumCache2[key] = inf;
|
||
}
|
||
return inf;
|
||
}
|
||
var intlRelCache2 = {};
|
||
function getCachedRTF2(locString, opts = {}) {
|
||
const _a2 = opts, { base } = _a2, cacheKeyOpts = __objRest(_a2, ["base"]);
|
||
const key = JSON.stringify([locString, cacheKeyOpts]);
|
||
let inf = intlRelCache2[key];
|
||
if (!inf) {
|
||
inf = new Intl.RelativeTimeFormat(locString, opts);
|
||
intlRelCache2[key] = inf;
|
||
}
|
||
return inf;
|
||
}
|
||
var sysLocaleCache2 = null;
|
||
function systemLocale2() {
|
||
if (sysLocaleCache2) {
|
||
return sysLocaleCache2;
|
||
} else {
|
||
sysLocaleCache2 = new Intl.DateTimeFormat().resolvedOptions().locale;
|
||
return sysLocaleCache2;
|
||
}
|
||
}
|
||
function parseLocaleString2(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 = getCachedDTF2(localeStr).resolvedOptions();
|
||
selectedStr = localeStr;
|
||
} catch (e) {
|
||
const smaller = localeStr.substring(0, uIndex);
|
||
options = getCachedDTF2(smaller).resolvedOptions();
|
||
selectedStr = smaller;
|
||
}
|
||
const { numberingSystem, calendar } = options;
|
||
return [selectedStr, numberingSystem, calendar];
|
||
}
|
||
}
|
||
function intlConfigString2(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 mapMonths2(f) {
|
||
const ms = [];
|
||
for (let i = 1; i <= 12; i++) {
|
||
const dt = DateTime2.utc(2016, i, 1);
|
||
ms.push(f(dt));
|
||
}
|
||
return ms;
|
||
}
|
||
function mapWeekdays2(f) {
|
||
const ms = [];
|
||
for (let i = 1; i <= 7; i++) {
|
||
const dt = DateTime2.utc(2016, 11, 13 + i);
|
||
ms.push(f(dt));
|
||
}
|
||
return ms;
|
||
}
|
||
function listStuff2(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 supportsFastNumbers2(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 PolyNumberFormatter2 = class {
|
||
constructor(intl, forceSimple, opts) {
|
||
this.padTo = opts.padTo || 0;
|
||
this.floor = opts.floor || false;
|
||
const _a2 = opts, { padTo, floor } = _a2, otherOpts = __objRest(_a2, ["padTo", "floor"]);
|
||
if (!forceSimple || Object.keys(otherOpts).length > 0) {
|
||
const intlOpts = __spreadValues({ useGrouping: false }, opts);
|
||
if (opts.padTo > 0)
|
||
intlOpts.minimumIntegerDigits = opts.padTo;
|
||
this.inf = getCachedINF2(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) : roundTo2(i, 3);
|
||
return padStart2(fixed, this.padTo);
|
||
}
|
||
}
|
||
};
|
||
var PolyDateFormatter2 = 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 && IANAZone2.create(offsetZ).valid) {
|
||
z = offsetZ;
|
||
this.dt = dt;
|
||
} else {
|
||
z = "UTC";
|
||
if (opts.timeZoneName) {
|
||
this.dt = dt;
|
||
} else {
|
||
this.dt = dt.offset === 0 ? dt : DateTime2.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 = __spreadValues({}, this.opts);
|
||
intlOpts.timeZone = intlOpts.timeZone || z;
|
||
this.dtf = getCachedDTF2(intl, intlOpts);
|
||
}
|
||
format() {
|
||
return this.dtf.format(this.dt.toJSDate());
|
||
}
|
||
formatToParts() {
|
||
return this.dtf.formatToParts(this.dt.toJSDate());
|
||
}
|
||
resolvedOptions() {
|
||
return this.dtf.resolvedOptions();
|
||
}
|
||
};
|
||
var PolyRelFormatter2 = class {
|
||
constructor(intl, isEnglish, opts) {
|
||
this.opts = __spreadValues({ style: "long" }, opts);
|
||
if (!isEnglish && hasRelative2()) {
|
||
this.rtf = getCachedRTF2(intl, opts);
|
||
}
|
||
}
|
||
format(count, unit) {
|
||
if (this.rtf) {
|
||
return this.rtf.format(count, unit);
|
||
} else {
|
||
return formatRelativeTime2(unit, count, this.opts.numeric, this.opts.style !== "long");
|
||
}
|
||
}
|
||
formatToParts(count, unit) {
|
||
if (this.rtf) {
|
||
return this.rtf.formatToParts(count, unit);
|
||
} else {
|
||
return [];
|
||
}
|
||
}
|
||
};
|
||
var Locale2 = class _Locale {
|
||
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" : systemLocale2());
|
||
const numberingSystemR = numberingSystem || Settings2.defaultNumberingSystem;
|
||
const outputCalendarR = outputCalendar || Settings2.defaultOutputCalendar;
|
||
return new _Locale(localeR, numberingSystemR, outputCalendarR, specifiedLocale);
|
||
}
|
||
static resetCache() {
|
||
sysLocaleCache2 = null;
|
||
intlDTCache2 = {};
|
||
intlNumCache2 = {};
|
||
intlRelCache2 = {};
|
||
}
|
||
static fromObject({ locale, numberingSystem, outputCalendar } = {}) {
|
||
return _Locale.create(locale, numberingSystem, outputCalendar);
|
||
}
|
||
constructor(locale, numbering, outputCalendar, specifiedLocale) {
|
||
const [parsedLocale, parsedNumberingSystem, parsedOutputCalendar] = parseLocaleString2(locale);
|
||
this.locale = parsedLocale;
|
||
this.numberingSystem = numbering || parsedNumberingSystem || null;
|
||
this.outputCalendar = outputCalendar || parsedOutputCalendar || null;
|
||
this.intl = intlConfigString2(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 = supportsFastNumbers2(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(__spreadProps(__spreadValues({}, alts), { defaultToEN: true }));
|
||
}
|
||
redefaultToSystem(alts = {}) {
|
||
return this.clone(__spreadProps(__spreadValues({}, alts), { defaultToEN: false }));
|
||
}
|
||
months(length, format = false, defaultOK = true) {
|
||
return listStuff2(this, length, defaultOK, months2, () => {
|
||
const intl = format ? { month: length, day: "numeric" } : { month: length }, formatStr = format ? "format" : "standalone";
|
||
if (!this.monthsCache[formatStr][length]) {
|
||
this.monthsCache[formatStr][length] = mapMonths2((dt) => this.extract(dt, intl, "month"));
|
||
}
|
||
return this.monthsCache[formatStr][length];
|
||
});
|
||
}
|
||
weekdays(length, format = false, defaultOK = true) {
|
||
return listStuff2(this, length, defaultOK, weekdays2, () => {
|
||
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] = mapWeekdays2(
|
||
(dt) => this.extract(dt, intl, "weekday")
|
||
);
|
||
}
|
||
return this.weekdaysCache[formatStr][length];
|
||
});
|
||
}
|
||
meridiems(defaultOK = true) {
|
||
return listStuff2(
|
||
this,
|
||
void 0,
|
||
defaultOK,
|
||
() => meridiems2,
|
||
() => {
|
||
if (!this.meridiemCache) {
|
||
const intl = { hour: "numeric", hourCycle: "h12" };
|
||
this.meridiemCache = [DateTime2.utc(2016, 11, 13, 9), DateTime2.utc(2016, 11, 13, 19)].map(
|
||
(dt) => this.extract(dt, intl, "dayperiod")
|
||
);
|
||
}
|
||
return this.meridiemCache;
|
||
}
|
||
);
|
||
}
|
||
eras(length, defaultOK = true) {
|
||
return listStuff2(this, length, defaultOK, eras2, () => {
|
||
const intl = { era: length };
|
||
if (!this.eraCache[length]) {
|
||
this.eraCache[length] = [DateTime2.utc(-40, 1, 1), DateTime2.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 PolyNumberFormatter2(this.intl, opts.forceSimple || this.fastNumbers, opts);
|
||
}
|
||
dtFormatter(dt, intlOpts = {}) {
|
||
return new PolyDateFormatter2(dt, this.intl, intlOpts);
|
||
}
|
||
relFormatter(opts = {}) {
|
||
return new PolyRelFormatter2(this.intl, this.isEnglish(), opts);
|
||
}
|
||
listFormatter(opts = {}) {
|
||
return getCachedLF2(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 singleton3 = null;
|
||
var FixedOffsetZone2 = class _FixedOffsetZone extends Zone2 {
|
||
/**
|
||
* Get a singleton instance of UTC
|
||
* @return {FixedOffsetZone}
|
||
*/
|
||
static get utcInstance() {
|
||
if (singleton3 === null) {
|
||
singleton3 = new _FixedOffsetZone(0);
|
||
}
|
||
return singleton3;
|
||
}
|
||
/**
|
||
* Get an instance with a specified offset
|
||
* @param {number} offset - The offset in minutes
|
||
* @return {FixedOffsetZone}
|
||
*/
|
||
static instance(offset4) {
|
||
return offset4 === 0 ? _FixedOffsetZone.utcInstance : new _FixedOffsetZone(offset4);
|
||
}
|
||
/**
|
||
* 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(s3) {
|
||
if (s3) {
|
||
const r = s3.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);
|
||
if (r) {
|
||
return new _FixedOffsetZone(signedOffset2(r[1], r[2]));
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
constructor(offset4) {
|
||
super();
|
||
this.fixed = offset4;
|
||
}
|
||
/** @override **/
|
||
get type() {
|
||
return "fixed";
|
||
}
|
||
/** @override **/
|
||
get name() {
|
||
return this.fixed === 0 ? "UTC" : `UTC${formatOffset2(this.fixed, "narrow")}`;
|
||
}
|
||
get ianaName() {
|
||
if (this.fixed === 0) {
|
||
return "Etc/UTC";
|
||
} else {
|
||
return `Etc/GMT${formatOffset2(-this.fixed, "narrow")}`;
|
||
}
|
||
}
|
||
/** @override **/
|
||
offsetName() {
|
||
return this.name;
|
||
}
|
||
/** @override **/
|
||
formatOffset(ts, format) {
|
||
return formatOffset2(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 InvalidZone2 = class extends Zone2 {
|
||
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 normalizeZone2(input, defaultZone3) {
|
||
if (isUndefined3(input) || input === null) {
|
||
return defaultZone3;
|
||
} else if (input instanceof Zone2) {
|
||
return input;
|
||
} else if (isString3(input)) {
|
||
const lowered = input.toLowerCase();
|
||
if (lowered === "default")
|
||
return defaultZone3;
|
||
else if (lowered === "local" || lowered === "system")
|
||
return SystemZone2.instance;
|
||
else if (lowered === "utc" || lowered === "gmt")
|
||
return FixedOffsetZone2.utcInstance;
|
||
else
|
||
return FixedOffsetZone2.parseSpecifier(lowered) || IANAZone2.create(input);
|
||
} else if (isNumber3(input)) {
|
||
return FixedOffsetZone2.instance(input);
|
||
} else if (typeof input === "object" && input.offset && typeof input.offset === "number") {
|
||
return input;
|
||
} else {
|
||
return new InvalidZone2(input);
|
||
}
|
||
}
|
||
var now3 = () => Date.now();
|
||
var defaultZone2 = "system";
|
||
var defaultLocale2 = null;
|
||
var defaultNumberingSystem2 = null;
|
||
var defaultOutputCalendar2 = null;
|
||
var twoDigitCutoffYear2 = 60;
|
||
var throwOnInvalid2;
|
||
var Settings2 = class {
|
||
/**
|
||
* Get the callback for returning the current timestamp.
|
||
* @type {function}
|
||
*/
|
||
static get now() {
|
||
return now3;
|
||
}
|
||
/**
|
||
* 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(n3) {
|
||
now3 = n3;
|
||
}
|
||
/**
|
||
* 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) {
|
||
defaultZone2 = 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 normalizeZone2(defaultZone2, SystemZone2.instance);
|
||
}
|
||
/**
|
||
* Get the default locale to create DateTimes with. Does not affect existing instances.
|
||
* @type {string}
|
||
*/
|
||
static get defaultLocale() {
|
||
return defaultLocale2;
|
||
}
|
||
/**
|
||
* Set the default locale to create DateTimes with. Does not affect existing instances.
|
||
* @type {string}
|
||
*/
|
||
static set defaultLocale(locale) {
|
||
defaultLocale2 = locale;
|
||
}
|
||
/**
|
||
* Get the default numbering system to create DateTimes with. Does not affect existing instances.
|
||
* @type {string}
|
||
*/
|
||
static get defaultNumberingSystem() {
|
||
return defaultNumberingSystem2;
|
||
}
|
||
/**
|
||
* Set the default numbering system to create DateTimes with. Does not affect existing instances.
|
||
* @type {string}
|
||
*/
|
||
static set defaultNumberingSystem(numberingSystem) {
|
||
defaultNumberingSystem2 = numberingSystem;
|
||
}
|
||
/**
|
||
* Get the default output calendar to create DateTimes with. Does not affect existing instances.
|
||
* @type {string}
|
||
*/
|
||
static get defaultOutputCalendar() {
|
||
return defaultOutputCalendar2;
|
||
}
|
||
/**
|
||
* Set the default output calendar to create DateTimes with. Does not affect existing instances.
|
||
* @type {string}
|
||
*/
|
||
static set defaultOutputCalendar(outputCalendar) {
|
||
defaultOutputCalendar2 = 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 twoDigitCutoffYear2;
|
||
}
|
||
/**
|
||
* 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) {
|
||
twoDigitCutoffYear2 = cutoffYear % 100;
|
||
}
|
||
/**
|
||
* Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
|
||
* @type {boolean}
|
||
*/
|
||
static get throwOnInvalid() {
|
||
return throwOnInvalid2;
|
||
}
|
||
/**
|
||
* Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
|
||
* @type {boolean}
|
||
*/
|
||
static set throwOnInvalid(t) {
|
||
throwOnInvalid2 = t;
|
||
}
|
||
/**
|
||
* Reset Luxon's global caches. Should only be necessary in testing scenarios.
|
||
* @return {void}
|
||
*/
|
||
static resetCaches() {
|
||
Locale2.resetCache();
|
||
IANAZone2.resetCache();
|
||
}
|
||
};
|
||
function isUndefined3(o) {
|
||
return typeof o === "undefined";
|
||
}
|
||
function isNumber3(o) {
|
||
return typeof o === "number";
|
||
}
|
||
function isInteger2(o) {
|
||
return typeof o === "number" && o % 1 === 0;
|
||
}
|
||
function isString3(o) {
|
||
return typeof o === "string";
|
||
}
|
||
function isDate3(o) {
|
||
return Object.prototype.toString.call(o) === "[object Date]";
|
||
}
|
||
function hasRelative2() {
|
||
try {
|
||
return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}
|
||
function maybeArray2(thing) {
|
||
return Array.isArray(thing) ? thing : [thing];
|
||
}
|
||
function bestBy2(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 pick2(obj, keys) {
|
||
return keys.reduce((a, k) => {
|
||
a[k] = obj[k];
|
||
return a;
|
||
}, {});
|
||
}
|
||
function hasOwnProperty3(obj, prop) {
|
||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||
}
|
||
function integerBetween2(thing, bottom2, top2) {
|
||
return isInteger2(thing) && thing >= bottom2 && thing <= top2;
|
||
}
|
||
function floorMod2(x, n3) {
|
||
return x - n3 * Math.floor(x / n3);
|
||
}
|
||
function padStart2(input, n3 = 2) {
|
||
const isNeg = input < 0;
|
||
let padded;
|
||
if (isNeg) {
|
||
padded = "-" + ("" + -input).padStart(n3, "0");
|
||
} else {
|
||
padded = ("" + input).padStart(n3, "0");
|
||
}
|
||
return padded;
|
||
}
|
||
function parseInteger2(string) {
|
||
if (isUndefined3(string) || string === null || string === "") {
|
||
return void 0;
|
||
} else {
|
||
return parseInt(string, 10);
|
||
}
|
||
}
|
||
function parseFloating2(string) {
|
||
if (isUndefined3(string) || string === null || string === "") {
|
||
return void 0;
|
||
} else {
|
||
return parseFloat(string);
|
||
}
|
||
}
|
||
function parseMillis2(fraction) {
|
||
if (isUndefined3(fraction) || fraction === null || fraction === "") {
|
||
return void 0;
|
||
} else {
|
||
const f = parseFloat("0." + fraction) * 1e3;
|
||
return Math.floor(f);
|
||
}
|
||
}
|
||
function roundTo2(number, digits, towardZero = false) {
|
||
const factor = 10 ** digits, rounder = towardZero ? Math.trunc : Math.round;
|
||
return rounder(number * factor) / factor;
|
||
}
|
||
function isLeapYear2(year) {
|
||
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
||
}
|
||
function daysInYear2(year) {
|
||
return isLeapYear2(year) ? 366 : 365;
|
||
}
|
||
function daysInMonth2(year, month) {
|
||
const modMonth = floorMod2(month - 1, 12) + 1, modYear = year + (month - modMonth) / 12;
|
||
if (modMonth === 2) {
|
||
return isLeapYear2(modYear) ? 29 : 28;
|
||
} else {
|
||
return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1];
|
||
}
|
||
}
|
||
function objToLocalTS2(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 weeksInWeekYear2(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 untruncateYear2(year) {
|
||
if (year > 99) {
|
||
return year;
|
||
} else
|
||
return year > Settings2.twoDigitCutoffYear ? 1900 + year : 2e3 + year;
|
||
}
|
||
function parseZoneInfo2(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 = __spreadValues({ timeZoneName: offsetFormat }, intlOpts);
|
||
const parsed = new Intl.DateTimeFormat(locale, modified).formatToParts(date).find((m) => m.type.toLowerCase() === "timezonename");
|
||
return parsed ? parsed.value : null;
|
||
}
|
||
function signedOffset2(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 asNumber2(value) {
|
||
const numericValue = Number(value);
|
||
if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue))
|
||
throw new InvalidArgumentError2(`Invalid unit value ${value}`);
|
||
return numericValue;
|
||
}
|
||
function normalizeObject2(obj, normalizer) {
|
||
const normalized = {};
|
||
for (const u in obj) {
|
||
if (hasOwnProperty3(obj, u)) {
|
||
const v = obj[u];
|
||
if (v === void 0 || v === null)
|
||
continue;
|
||
normalized[normalizer(u)] = asNumber2(v);
|
||
}
|
||
}
|
||
return normalized;
|
||
}
|
||
function formatOffset2(offset4, format) {
|
||
const hours = Math.trunc(Math.abs(offset4 / 60)), minutes = Math.trunc(Math.abs(offset4 % 60)), sign = offset4 >= 0 ? "+" : "-";
|
||
switch (format) {
|
||
case "short":
|
||
return `${sign}${padStart2(hours, 2)}:${padStart2(minutes, 2)}`;
|
||
case "narrow":
|
||
return `${sign}${hours}${minutes > 0 ? `:${minutes}` : ""}`;
|
||
case "techie":
|
||
return `${sign}${padStart2(hours, 2)}${padStart2(minutes, 2)}`;
|
||
default:
|
||
throw new RangeError(`Value format ${format} is out of range for property format`);
|
||
}
|
||
}
|
||
function timeObject2(obj) {
|
||
return pick2(obj, ["hour", "minute", "second", "millisecond"]);
|
||
}
|
||
var monthsLong2 = [
|
||
"January",
|
||
"February",
|
||
"March",
|
||
"April",
|
||
"May",
|
||
"June",
|
||
"July",
|
||
"August",
|
||
"September",
|
||
"October",
|
||
"November",
|
||
"December"
|
||
];
|
||
var monthsShort2 = [
|
||
"Jan",
|
||
"Feb",
|
||
"Mar",
|
||
"Apr",
|
||
"May",
|
||
"Jun",
|
||
"Jul",
|
||
"Aug",
|
||
"Sep",
|
||
"Oct",
|
||
"Nov",
|
||
"Dec"
|
||
];
|
||
var monthsNarrow2 = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"];
|
||
function months2(length) {
|
||
switch (length) {
|
||
case "narrow":
|
||
return [...monthsNarrow2];
|
||
case "short":
|
||
return [...monthsShort2];
|
||
case "long":
|
||
return [...monthsLong2];
|
||
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 weekdaysLong2 = [
|
||
"Monday",
|
||
"Tuesday",
|
||
"Wednesday",
|
||
"Thursday",
|
||
"Friday",
|
||
"Saturday",
|
||
"Sunday"
|
||
];
|
||
var weekdaysShort2 = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
||
var weekdaysNarrow2 = ["M", "T", "W", "T", "F", "S", "S"];
|
||
function weekdays2(length) {
|
||
switch (length) {
|
||
case "narrow":
|
||
return [...weekdaysNarrow2];
|
||
case "short":
|
||
return [...weekdaysShort2];
|
||
case "long":
|
||
return [...weekdaysLong2];
|
||
case "numeric":
|
||
return ["1", "2", "3", "4", "5", "6", "7"];
|
||
default:
|
||
return null;
|
||
}
|
||
}
|
||
var meridiems2 = ["AM", "PM"];
|
||
var erasLong2 = ["Before Christ", "Anno Domini"];
|
||
var erasShort2 = ["BC", "AD"];
|
||
var erasNarrow2 = ["B", "A"];
|
||
function eras2(length) {
|
||
switch (length) {
|
||
case "narrow":
|
||
return [...erasNarrow2];
|
||
case "short":
|
||
return [...erasShort2];
|
||
case "long":
|
||
return [...erasLong2];
|
||
default:
|
||
return null;
|
||
}
|
||
}
|
||
function meridiemForDateTime2(dt) {
|
||
return meridiems2[dt.hour < 12 ? 0 : 1];
|
||
}
|
||
function weekdayForDateTime2(dt, length) {
|
||
return weekdays2(length)[dt.weekday - 1];
|
||
}
|
||
function monthForDateTime2(dt, length) {
|
||
return months2(length)[dt.month - 1];
|
||
}
|
||
function eraForDateTime2(dt, length) {
|
||
return eras2(length)[dt.year < 0 ? 0 : 1];
|
||
}
|
||
function formatRelativeTime2(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 stringifyTokens2(splits, tokenToString) {
|
||
let s3 = "";
|
||
for (const token of splits) {
|
||
if (token.literal) {
|
||
s3 += token.val;
|
||
} else {
|
||
s3 += tokenToString(token.val);
|
||
}
|
||
}
|
||
return s3;
|
||
}
|
||
var macroTokenToFormatOpts2 = {
|
||
D: DATE_SHORT2,
|
||
DD: DATE_MED2,
|
||
DDD: DATE_FULL2,
|
||
DDDD: DATE_HUGE2,
|
||
t: TIME_SIMPLE2,
|
||
tt: TIME_WITH_SECONDS2,
|
||
ttt: TIME_WITH_SHORT_OFFSET2,
|
||
tttt: TIME_WITH_LONG_OFFSET2,
|
||
T: TIME_24_SIMPLE2,
|
||
TT: TIME_24_WITH_SECONDS2,
|
||
TTT: TIME_24_WITH_SHORT_OFFSET2,
|
||
TTTT: TIME_24_WITH_LONG_OFFSET2,
|
||
f: DATETIME_SHORT2,
|
||
ff: DATETIME_MED2,
|
||
fff: DATETIME_FULL2,
|
||
ffff: DATETIME_HUGE2,
|
||
F: DATETIME_SHORT_WITH_SECONDS2,
|
||
FF: DATETIME_MED_WITH_SECONDS2,
|
||
FFF: DATETIME_FULL_WITH_SECONDS2,
|
||
FFFF: DATETIME_HUGE_WITH_SECONDS2
|
||
};
|
||
var Formatter2 = class _Formatter {
|
||
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 macroTokenToFormatOpts2[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, __spreadValues(__spreadValues({}, this.opts), opts));
|
||
return df.format();
|
||
}
|
||
formatDateTime(dt, opts = {}) {
|
||
const df = this.loc.dtFormatter(dt, __spreadValues(__spreadValues({}, this.opts), opts));
|
||
return df.format();
|
||
}
|
||
formatDateTimeParts(dt, opts = {}) {
|
||
const df = this.loc.dtFormatter(dt, __spreadValues(__spreadValues({}, this.opts), opts));
|
||
return df.formatToParts();
|
||
}
|
||
formatInterval(interval, opts = {}) {
|
||
const df = this.loc.dtFormatter(interval.start, __spreadValues(__spreadValues({}, this.opts), opts));
|
||
return df.dtf.formatRange(interval.start.toJSDate(), interval.end.toJSDate());
|
||
}
|
||
resolvedOptions(dt, opts = {}) {
|
||
const df = this.loc.dtFormatter(dt, __spreadValues(__spreadValues({}, this.opts), opts));
|
||
return df.resolvedOptions();
|
||
}
|
||
num(n3, p = 0) {
|
||
if (this.opts.forceSimple) {
|
||
return padStart2(n3, p);
|
||
}
|
||
const opts = __spreadValues({}, this.opts);
|
||
if (p > 0) {
|
||
opts.padTo = p;
|
||
}
|
||
return this.loc.numberFormatter(opts).format(n3);
|
||
}
|
||
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), formatOffset3 = (opts) => {
|
||
if (dt.isOffsetFixed && dt.offset === 0 && opts.allowZ) {
|
||
return "Z";
|
||
}
|
||
return dt.isValid ? dt.zone.formatOffset(dt.ts, opts.format) : "";
|
||
}, meridiem = () => knownEnglish ? meridiemForDateTime2(dt) : string({ hour: "numeric", hourCycle: "h12" }, "dayperiod"), month = (length, standalone) => knownEnglish ? monthForDateTime2(dt, length) : string(standalone ? { month: length } : { month: length, day: "numeric" }, "month"), weekday = (length, standalone) => knownEnglish ? weekdayForDateTime2(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 ? eraForDateTime2(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 formatOffset3({ format: "narrow", allowZ: this.opts.allowZ });
|
||
case "ZZ":
|
||
return formatOffset3({ format: "short", allowZ: this.opts.allowZ });
|
||
case "ZZZ":
|
||
return formatOffset3({ 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 stringifyTokens2(_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 stringifyTokens2(tokens, tokenToString(collapsed));
|
||
}
|
||
};
|
||
var Invalid2 = class {
|
||
constructor(reason, explanation) {
|
||
this.reason = reason;
|
||
this.explanation = explanation;
|
||
}
|
||
toMessage() {
|
||
if (this.explanation) {
|
||
return `${this.reason}: ${this.explanation}`;
|
||
} else {
|
||
return this.reason;
|
||
}
|
||
}
|
||
};
|
||
var ianaRegex2 = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
|
||
function combineRegexes2(...regexes) {
|
||
const full = regexes.reduce((f, r) => f + r.source, "");
|
||
return RegExp(`^${full}$`);
|
||
}
|
||
function combineExtractors2(...extractors) {
|
||
return (m) => extractors.reduce(
|
||
([mergedVals, mergedZone, cursor], ex) => {
|
||
const [val, zone, next] = ex(m, cursor);
|
||
return [__spreadValues(__spreadValues({}, mergedVals), val), zone || mergedZone, next];
|
||
},
|
||
[{}, null, 1]
|
||
).slice(0, 2);
|
||
}
|
||
function parse3(s3, ...patterns) {
|
||
if (s3 == null) {
|
||
return [null, null];
|
||
}
|
||
for (const [regex, extractor] of patterns) {
|
||
const m = regex.exec(s3);
|
||
if (m) {
|
||
return extractor(m);
|
||
}
|
||
}
|
||
return [null, null];
|
||
}
|
||
function simpleParse2(...keys) {
|
||
return (match3, cursor) => {
|
||
const ret = {};
|
||
let i;
|
||
for (i = 0; i < keys.length; i++) {
|
||
ret[keys[i]] = parseInteger2(match3[cursor + i]);
|
||
}
|
||
return [ret, null, cursor + i];
|
||
};
|
||
}
|
||
var offsetRegex2 = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/;
|
||
var isoExtendedZone2 = `(?:${offsetRegex2.source}?(?:\\[(${ianaRegex2.source})\\])?)?`;
|
||
var isoTimeBaseRegex2 = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/;
|
||
var isoTimeRegex2 = RegExp(`${isoTimeBaseRegex2.source}${isoExtendedZone2}`);
|
||
var isoTimeExtensionRegex2 = RegExp(`(?:T${isoTimeRegex2.source})?`);
|
||
var isoYmdRegex2 = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/;
|
||
var isoWeekRegex2 = /(\d{4})-?W(\d\d)(?:-?(\d))?/;
|
||
var isoOrdinalRegex2 = /(\d{4})-?(\d{3})/;
|
||
var extractISOWeekData2 = simpleParse2("weekYear", "weekNumber", "weekDay");
|
||
var extractISOOrdinalData2 = simpleParse2("year", "ordinal");
|
||
var sqlYmdRegex2 = /(\d{4})-(\d\d)-(\d\d)/;
|
||
var sqlTimeRegex2 = RegExp(
|
||
`${isoTimeBaseRegex2.source} ?(?:${offsetRegex2.source}|(${ianaRegex2.source}))?`
|
||
);
|
||
var sqlTimeExtensionRegex2 = RegExp(`(?: ${sqlTimeRegex2.source})?`);
|
||
function int2(match3, pos, fallback) {
|
||
const m = match3[pos];
|
||
return isUndefined3(m) ? fallback : parseInteger2(m);
|
||
}
|
||
function extractISOYmd2(match3, cursor) {
|
||
const item = {
|
||
year: int2(match3, cursor),
|
||
month: int2(match3, cursor + 1, 1),
|
||
day: int2(match3, cursor + 2, 1)
|
||
};
|
||
return [item, null, cursor + 3];
|
||
}
|
||
function extractISOTime2(match3, cursor) {
|
||
const item = {
|
||
hours: int2(match3, cursor, 0),
|
||
minutes: int2(match3, cursor + 1, 0),
|
||
seconds: int2(match3, cursor + 2, 0),
|
||
milliseconds: parseMillis2(match3[cursor + 3])
|
||
};
|
||
return [item, null, cursor + 4];
|
||
}
|
||
function extractISOOffset2(match3, cursor) {
|
||
const local = !match3[cursor] && !match3[cursor + 1], fullOffset = signedOffset2(match3[cursor + 1], match3[cursor + 2]), zone = local ? null : FixedOffsetZone2.instance(fullOffset);
|
||
return [{}, zone, cursor + 3];
|
||
}
|
||
function extractIANAZone2(match3, cursor) {
|
||
const zone = match3[cursor] ? IANAZone2.create(match3[cursor]) : null;
|
||
return [{}, zone, cursor + 1];
|
||
}
|
||
var isoTimeOnly2 = RegExp(`^T?${isoTimeBaseRegex2.source}$`);
|
||
var isoDuration2 = /^-?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 extractISODuration2(match3) {
|
||
const [s3, yearStr, monthStr, weekStr, dayStr, hourStr, minuteStr, secondStr, millisecondsStr] = match3;
|
||
const hasNegativePrefix = s3[0] === "-";
|
||
const negativeSeconds = secondStr && secondStr[0] === "-";
|
||
const maybeNegate = (num, force = false) => num !== void 0 && (force || num && hasNegativePrefix) ? -num : num;
|
||
return [
|
||
{
|
||
years: maybeNegate(parseFloating2(yearStr)),
|
||
months: maybeNegate(parseFloating2(monthStr)),
|
||
weeks: maybeNegate(parseFloating2(weekStr)),
|
||
days: maybeNegate(parseFloating2(dayStr)),
|
||
hours: maybeNegate(parseFloating2(hourStr)),
|
||
minutes: maybeNegate(parseFloating2(minuteStr)),
|
||
seconds: maybeNegate(parseFloating2(secondStr), secondStr === "-0"),
|
||
milliseconds: maybeNegate(parseMillis2(millisecondsStr), negativeSeconds)
|
||
}
|
||
];
|
||
}
|
||
var obsOffsets2 = {
|
||
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 fromStrings2(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
||
const result = {
|
||
year: yearStr.length === 2 ? untruncateYear2(parseInteger2(yearStr)) : parseInteger2(yearStr),
|
||
month: monthsShort2.indexOf(monthStr) + 1,
|
||
day: parseInteger2(dayStr),
|
||
hour: parseInteger2(hourStr),
|
||
minute: parseInteger2(minuteStr)
|
||
};
|
||
if (secondStr)
|
||
result.second = parseInteger2(secondStr);
|
||
if (weekdayStr) {
|
||
result.weekday = weekdayStr.length > 3 ? weekdaysLong2.indexOf(weekdayStr) + 1 : weekdaysShort2.indexOf(weekdayStr) + 1;
|
||
}
|
||
return result;
|
||
}
|
||
var rfc28222 = /^(?:(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 extractRFC28222(match3) {
|
||
const [
|
||
,
|
||
weekdayStr,
|
||
dayStr,
|
||
monthStr,
|
||
yearStr,
|
||
hourStr,
|
||
minuteStr,
|
||
secondStr,
|
||
obsOffset,
|
||
milOffset,
|
||
offHourStr,
|
||
offMinuteStr
|
||
] = match3, result = fromStrings2(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
||
let offset4;
|
||
if (obsOffset) {
|
||
offset4 = obsOffsets2[obsOffset];
|
||
} else if (milOffset) {
|
||
offset4 = 0;
|
||
} else {
|
||
offset4 = signedOffset2(offHourStr, offMinuteStr);
|
||
}
|
||
return [result, new FixedOffsetZone2(offset4)];
|
||
}
|
||
function preprocessRFC28222(s3) {
|
||
return s3.replace(/\([^()]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
|
||
}
|
||
var rfc11232 = /^(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 rfc8502 = /^(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 ascii2 = /^(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 extractRFC1123Or8502(match3) {
|
||
const [, weekdayStr, dayStr, monthStr, yearStr, hourStr, minuteStr, secondStr] = match3, result = fromStrings2(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
||
return [result, FixedOffsetZone2.utcInstance];
|
||
}
|
||
function extractASCII2(match3) {
|
||
const [, weekdayStr, monthStr, dayStr, hourStr, minuteStr, secondStr, yearStr] = match3, result = fromStrings2(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
||
return [result, FixedOffsetZone2.utcInstance];
|
||
}
|
||
var isoYmdWithTimeExtensionRegex2 = combineRegexes2(isoYmdRegex2, isoTimeExtensionRegex2);
|
||
var isoWeekWithTimeExtensionRegex2 = combineRegexes2(isoWeekRegex2, isoTimeExtensionRegex2);
|
||
var isoOrdinalWithTimeExtensionRegex2 = combineRegexes2(isoOrdinalRegex2, isoTimeExtensionRegex2);
|
||
var isoTimeCombinedRegex2 = combineRegexes2(isoTimeRegex2);
|
||
var extractISOYmdTimeAndOffset2 = combineExtractors2(
|
||
extractISOYmd2,
|
||
extractISOTime2,
|
||
extractISOOffset2,
|
||
extractIANAZone2
|
||
);
|
||
var extractISOWeekTimeAndOffset2 = combineExtractors2(
|
||
extractISOWeekData2,
|
||
extractISOTime2,
|
||
extractISOOffset2,
|
||
extractIANAZone2
|
||
);
|
||
var extractISOOrdinalDateAndTime2 = combineExtractors2(
|
||
extractISOOrdinalData2,
|
||
extractISOTime2,
|
||
extractISOOffset2,
|
||
extractIANAZone2
|
||
);
|
||
var extractISOTimeAndOffset2 = combineExtractors2(
|
||
extractISOTime2,
|
||
extractISOOffset2,
|
||
extractIANAZone2
|
||
);
|
||
function parseISODate2(s3) {
|
||
return parse3(
|
||
s3,
|
||
[isoYmdWithTimeExtensionRegex2, extractISOYmdTimeAndOffset2],
|
||
[isoWeekWithTimeExtensionRegex2, extractISOWeekTimeAndOffset2],
|
||
[isoOrdinalWithTimeExtensionRegex2, extractISOOrdinalDateAndTime2],
|
||
[isoTimeCombinedRegex2, extractISOTimeAndOffset2]
|
||
);
|
||
}
|
||
function parseRFC2822Date2(s3) {
|
||
return parse3(preprocessRFC28222(s3), [rfc28222, extractRFC28222]);
|
||
}
|
||
function parseHTTPDate2(s3) {
|
||
return parse3(
|
||
s3,
|
||
[rfc11232, extractRFC1123Or8502],
|
||
[rfc8502, extractRFC1123Or8502],
|
||
[ascii2, extractASCII2]
|
||
);
|
||
}
|
||
function parseISODuration2(s3) {
|
||
return parse3(s3, [isoDuration2, extractISODuration2]);
|
||
}
|
||
var extractISOTimeOnly2 = combineExtractors2(extractISOTime2);
|
||
function parseISOTimeOnly2(s3) {
|
||
return parse3(s3, [isoTimeOnly2, extractISOTimeOnly2]);
|
||
}
|
||
var sqlYmdWithTimeExtensionRegex2 = combineRegexes2(sqlYmdRegex2, sqlTimeExtensionRegex2);
|
||
var sqlTimeCombinedRegex2 = combineRegexes2(sqlTimeRegex2);
|
||
var extractISOTimeOffsetAndIANAZone2 = combineExtractors2(
|
||
extractISOTime2,
|
||
extractISOOffset2,
|
||
extractIANAZone2
|
||
);
|
||
function parseSQL2(s3) {
|
||
return parse3(
|
||
s3,
|
||
[sqlYmdWithTimeExtensionRegex2, extractISOYmdTimeAndOffset2],
|
||
[sqlTimeCombinedRegex2, extractISOTimeOffsetAndIANAZone2]
|
||
);
|
||
}
|
||
var INVALID$2 = "Invalid Duration";
|
||
var lowOrderMatrix2 = {
|
||
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 casualMatrix2 = __spreadValues({
|
||
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
|
||
}
|
||
}, lowOrderMatrix2);
|
||
var daysInYearAccurate2 = 146097 / 400;
|
||
var daysInMonthAccurate2 = 146097 / 4800;
|
||
var accurateMatrix2 = __spreadValues({
|
||
years: {
|
||
quarters: 4,
|
||
months: 12,
|
||
weeks: daysInYearAccurate2 / 7,
|
||
days: daysInYearAccurate2,
|
||
hours: daysInYearAccurate2 * 24,
|
||
minutes: daysInYearAccurate2 * 24 * 60,
|
||
seconds: daysInYearAccurate2 * 24 * 60 * 60,
|
||
milliseconds: daysInYearAccurate2 * 24 * 60 * 60 * 1e3
|
||
},
|
||
quarters: {
|
||
months: 3,
|
||
weeks: daysInYearAccurate2 / 28,
|
||
days: daysInYearAccurate2 / 4,
|
||
hours: daysInYearAccurate2 * 24 / 4,
|
||
minutes: daysInYearAccurate2 * 24 * 60 / 4,
|
||
seconds: daysInYearAccurate2 * 24 * 60 * 60 / 4,
|
||
milliseconds: daysInYearAccurate2 * 24 * 60 * 60 * 1e3 / 4
|
||
},
|
||
months: {
|
||
weeks: daysInMonthAccurate2 / 7,
|
||
days: daysInMonthAccurate2,
|
||
hours: daysInMonthAccurate2 * 24,
|
||
minutes: daysInMonthAccurate2 * 24 * 60,
|
||
seconds: daysInMonthAccurate2 * 24 * 60 * 60,
|
||
milliseconds: daysInMonthAccurate2 * 24 * 60 * 60 * 1e3
|
||
}
|
||
}, lowOrderMatrix2);
|
||
var orderedUnits$1 = [
|
||
"years",
|
||
"quarters",
|
||
"months",
|
||
"weeks",
|
||
"days",
|
||
"hours",
|
||
"minutes",
|
||
"seconds",
|
||
"milliseconds"
|
||
];
|
||
var reverseUnits2 = orderedUnits$1.slice(0).reverse();
|
||
function clone$1(dur, alts, clear = false) {
|
||
const conf = {
|
||
values: clear ? alts.values : __spreadValues(__spreadValues({}, dur.values), alts.values || {}),
|
||
loc: dur.loc.clone(alts.loc),
|
||
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy,
|
||
matrix: alts.matrix || dur.matrix
|
||
};
|
||
return new Duration2(conf);
|
||
}
|
||
function antiTrunc(n3) {
|
||
return n3 < 0 ? Math.floor(n3) : Math.ceil(n3);
|
||
}
|
||
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 normalizeValues2(matrix, vals) {
|
||
reverseUnits2.reduce((previous, current) => {
|
||
if (!isUndefined3(vals[current])) {
|
||
if (previous) {
|
||
convert(matrix, vals, previous, vals, current);
|
||
}
|
||
return current;
|
||
} else {
|
||
return previous;
|
||
}
|
||
}, null);
|
||
}
|
||
function removeZeroes2(vals) {
|
||
const newVals = {};
|
||
for (const [key, value] of Object.entries(vals)) {
|
||
if (value !== 0) {
|
||
newVals[key] = value;
|
||
}
|
||
}
|
||
return newVals;
|
||
}
|
||
var Duration2 = class _Duration {
|
||
/**
|
||
* @private
|
||
*/
|
||
constructor(config) {
|
||
const accurate = config.conversionAccuracy === "longterm" || false;
|
||
let matrix = accurate ? accurateMatrix2 : casualMatrix2;
|
||
if (config.matrix) {
|
||
matrix = config.matrix;
|
||
}
|
||
this.values = config.values;
|
||
this.loc = config.loc || Locale2.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 InvalidArgumentError2(
|
||
`Duration.fromObject: argument expected to be an object, got ${obj === null ? "null" : typeof obj}`
|
||
);
|
||
}
|
||
return new _Duration({
|
||
values: normalizeObject2(obj, _Duration.normalizeUnit),
|
||
loc: Locale2.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 (isNumber3(durationLike)) {
|
||
return _Duration.fromMillis(durationLike);
|
||
} else if (_Duration.isDuration(durationLike)) {
|
||
return durationLike;
|
||
} else if (typeof durationLike === "object") {
|
||
return _Duration.fromObject(durationLike);
|
||
} else {
|
||
throw new InvalidArgumentError2(
|
||
`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] = parseISODuration2(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] = parseISOTimeOnly2(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 InvalidArgumentError2("need to specify a reason the Duration is invalid");
|
||
}
|
||
const invalid = reason instanceof Invalid2 ? reason : new Invalid2(reason, explanation);
|
||
if (Settings2.throwOnInvalid) {
|
||
throw new InvalidDurationError2(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 InvalidUnitError2(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 = __spreadProps(__spreadValues({}, opts), {
|
||
floor: opts.round !== false && opts.floor !== false
|
||
});
|
||
return this.isValid ? Formatter2.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 l3 = orderedUnits$1.map((unit) => {
|
||
const val = this.values[unit];
|
||
if (isUndefined3(val)) {
|
||
return null;
|
||
}
|
||
return this.loc.numberFormatter(__spreadProps(__spreadValues({ style: "unit", unitDisplay: "long" }, opts), { unit: unit.slice(0, -1) })).format(val);
|
||
}).filter((n3) => n3);
|
||
return this.loc.listFormatter(__spreadValues({ type: "conjunction", style: opts.listStyle || "narrow" }, opts)).format(l3);
|
||
}
|
||
/**
|
||
* 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 __spreadValues({}, 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 s3 = "P";
|
||
if (this.years !== 0)
|
||
s3 += this.years + "Y";
|
||
if (this.months !== 0 || this.quarters !== 0)
|
||
s3 += this.months + this.quarters * 3 + "M";
|
||
if (this.weeks !== 0)
|
||
s3 += this.weeks + "W";
|
||
if (this.days !== 0)
|
||
s3 += this.days + "D";
|
||
if (this.hours !== 0 || this.minutes !== 0 || this.seconds !== 0 || this.milliseconds !== 0)
|
||
s3 += "T";
|
||
if (this.hours !== 0)
|
||
s3 += this.hours + "H";
|
||
if (this.minutes !== 0)
|
||
s3 += this.minutes + "M";
|
||
if (this.seconds !== 0 || this.milliseconds !== 0)
|
||
s3 += roundTo2(this.seconds + this.milliseconds / 1e3, 3) + "S";
|
||
if (s3 === "P")
|
||
s3 += "T0S";
|
||
return s3;
|
||
}
|
||
/**
|
||
* 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 = __spreadValues({
|
||
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 (hasOwnProperty3(dur.values, k) || hasOwnProperty3(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(fn2) {
|
||
if (!this.isValid)
|
||
return this;
|
||
const result = {};
|
||
for (const k of Object.keys(this.values)) {
|
||
result[k] = asNumber2(fn2(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 = __spreadValues(__spreadValues({}, this.values), normalizeObject2(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();
|
||
normalizeValues2(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 = removeZeroes2(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 (isNumber3(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 (isNumber3(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 validateStartEnd2(start2, end2) {
|
||
if (!start2 || !start2.isValid) {
|
||
return Interval2.invalid("missing or invalid start");
|
||
} else if (!end2 || !end2.isValid) {
|
||
return Interval2.invalid("missing or invalid end");
|
||
} else if (end2 < start2) {
|
||
return Interval2.invalid(
|
||
"end before start",
|
||
`The end of an interval must be after its start, but you had start=${start2.toISO()} and end=${end2.toISO()}`
|
||
);
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
var Interval2 = class _Interval {
|
||
/**
|
||
* @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 InvalidArgumentError2("need to specify a reason the Interval is invalid");
|
||
}
|
||
const invalid = reason instanceof Invalid2 ? reason : new Invalid2(reason, explanation);
|
||
if (Settings2.throwOnInvalid) {
|
||
throw new InvalidIntervalError2(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(start2, end2) {
|
||
const builtStart = friendlyDateTime2(start2), builtEnd = friendlyDateTime2(end2);
|
||
const validateError = validateStartEnd2(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(start2, duration) {
|
||
const dur = Duration2.fromDurationLike(duration), dt = friendlyDateTime2(start2);
|
||
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(end2, duration) {
|
||
const dur = Duration2.fromDurationLike(duration), dt = friendlyDateTime2(end2);
|
||
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 [s3, e] = (text2 || "").split("/", 2);
|
||
if (s3 && e) {
|
||
let start2, startIsValid;
|
||
try {
|
||
start2 = DateTime2.fromISO(s3, opts);
|
||
startIsValid = start2.isValid;
|
||
} catch (e2) {
|
||
startIsValid = false;
|
||
}
|
||
let end2, endIsValid;
|
||
try {
|
||
end2 = DateTime2.fromISO(e, opts);
|
||
endIsValid = end2.isValid;
|
||
} catch (e2) {
|
||
endIsValid = false;
|
||
}
|
||
if (startIsValid && endIsValid) {
|
||
return _Interval.fromDateTimes(start2, end2);
|
||
}
|
||
if (startIsValid) {
|
||
const dur = Duration2.fromISO(e, opts);
|
||
if (dur.isValid) {
|
||
return _Interval.after(start2, dur);
|
||
}
|
||
} else if (endIsValid) {
|
||
const dur = Duration2.fromISO(s3, opts);
|
||
if (dur.isValid) {
|
||
return _Interval.before(end2, 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 start2 = this.start.startOf(unit), end2 = this.end.startOf(unit);
|
||
return Math.floor(end2.diff(start2, 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: start2, end: end2 } = {}) {
|
||
if (!this.isValid)
|
||
return this;
|
||
return _Interval.fromDateTimes(start2 || this.s, end2 || 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(friendlyDateTime2).filter((d) => this.contains(d)).sort(), results = [];
|
||
let { s: s3 } = this, i = 0;
|
||
while (s3 < this.e) {
|
||
const added = sorted[i] || this.e, next = +added > +this.e ? this.e : added;
|
||
results.push(_Interval.fromDateTimes(s3, next));
|
||
s3 = 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 = Duration2.fromDurationLike(duration);
|
||
if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) {
|
||
return [];
|
||
}
|
||
let { s: s3 } = this, idx = 1, next;
|
||
const results = [];
|
||
while (s3 < this.e) {
|
||
const added = this.start.plus(dur.mapUnits((x) => x * idx));
|
||
next = +added > +this.e ? this.e : added;
|
||
results.push(_Interval.fromDateTimes(s3, next));
|
||
s3 = 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 s3 = this.s > other.s ? this.s : other.s, e = this.e < other.e ? this.e : other.e;
|
||
if (s3 >= e) {
|
||
return null;
|
||
} else {
|
||
return _Interval.fromDateTimes(s3, 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 s3 = this.s < other.s ? this.s : other.s, e = this.e > other.e ? this.e : other.e;
|
||
return _Interval.fromDateTimes(s3, 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 start2 = 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) {
|
||
start2 = i.time;
|
||
} else {
|
||
if (start2 && +start2 !== +i.time) {
|
||
results.push(_Interval.fromDateTimes(start2, i.time));
|
||
}
|
||
start2 = 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_SHORT2, opts = {}) {
|
||
return this.isValid ? Formatter2.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 Duration2.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 Info2 = 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 = DateTime2.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 IANAZone2.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 normalizeZone2(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 || Locale2.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 || Locale2.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 || Locale2.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 || Locale2.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 Locale2.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 Locale2.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: hasRelative2() };
|
||
}
|
||
};
|
||
function dayDiff2(earlier, later) {
|
||
const utcDayStart = (dt) => dt.toUTC(0, { keepLocalTime: true }).startOf("day").valueOf(), ms = utcDayStart(later) - utcDayStart(earlier);
|
||
return Math.floor(Duration2.fromMillis(ms).as("days"));
|
||
}
|
||
function highOrderDiffs2(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 = dayDiff2(a, b);
|
||
return (days - days % 7) / 7;
|
||
}
|
||
],
|
||
["days", dayDiff2]
|
||
];
|
||
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 diff2(earlier, later, units, opts) {
|
||
let [cursor, results, highWater, lowestOrder] = highOrderDiffs2(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 = Duration2.fromObject(results, opts);
|
||
if (lowerOrderUnits.length > 0) {
|
||
return Duration2.fromMillis(remainingMillis, opts).shiftTo(...lowerOrderUnits).plus(duration);
|
||
} else {
|
||
return duration;
|
||
}
|
||
}
|
||
var numberingSystems2 = {
|
||
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 numberingSystemsUTF162 = {
|
||
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 hanidecChars2 = numberingSystems2.hanidec.replace(/[\[|\]]/g, "").split("");
|
||
function parseDigits2(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(numberingSystems2.hanidec) !== -1) {
|
||
value += hanidecChars2.indexOf(str[i]);
|
||
} else {
|
||
for (const key in numberingSystemsUTF162) {
|
||
const [min2, max2] = numberingSystemsUTF162[key];
|
||
if (code >= min2 && code <= max2) {
|
||
value += code - min2;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return parseInt(value, 10);
|
||
} else {
|
||
return value;
|
||
}
|
||
}
|
||
function digitRegex2({ numberingSystem }, append3 = "") {
|
||
return new RegExp(`${numberingSystems2[numberingSystem || "latn"]}${append3}`);
|
||
}
|
||
var MISSING_FTP2 = "missing Intl.DateTimeFormat.formatToParts support";
|
||
function intUnit2(regex, post = (i) => i) {
|
||
return { regex, deser: ([s3]) => post(parseDigits2(s3)) };
|
||
}
|
||
var NBSP2 = String.fromCharCode(160);
|
||
var spaceOrNBSP2 = `[ ${NBSP2}]`;
|
||
var spaceOrNBSPRegExp2 = new RegExp(spaceOrNBSP2, "g");
|
||
function fixListRegex2(s3) {
|
||
return s3.replace(/\./g, "\\.?").replace(spaceOrNBSPRegExp2, spaceOrNBSP2);
|
||
}
|
||
function stripInsensitivities2(s3) {
|
||
return s3.replace(/\./g, "").replace(spaceOrNBSPRegExp2, " ").toLowerCase();
|
||
}
|
||
function oneOf2(strings, startIndex) {
|
||
if (strings === null) {
|
||
return null;
|
||
} else {
|
||
return {
|
||
regex: RegExp(strings.map(fixListRegex2).join("|")),
|
||
deser: ([s3]) => strings.findIndex((i) => stripInsensitivities2(s3) === stripInsensitivities2(i)) + startIndex
|
||
};
|
||
}
|
||
}
|
||
function offset3(regex, groups) {
|
||
return { regex, deser: ([, h, m]) => signedOffset2(h, m), groups };
|
||
}
|
||
function simple2(regex) {
|
||
return { regex, deser: ([s3]) => s3 };
|
||
}
|
||
function escapeToken2(value) {
|
||
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
||
}
|
||
function unitForToken2(token, loc) {
|
||
const one = digitRegex2(loc), two = digitRegex2(loc, "{2}"), three = digitRegex2(loc, "{3}"), four = digitRegex2(loc, "{4}"), six = digitRegex2(loc, "{6}"), oneOrTwo = digitRegex2(loc, "{1,2}"), oneToThree = digitRegex2(loc, "{1,3}"), oneToSix = digitRegex2(loc, "{1,6}"), oneToNine = digitRegex2(loc, "{1,9}"), twoToFour = digitRegex2(loc, "{2,4}"), fourToSix = digitRegex2(loc, "{4,6}"), literal = (t) => ({ regex: RegExp(escapeToken2(t.val)), deser: ([s3]) => s3, literal: true }), unitate = (t) => {
|
||
if (token.literal) {
|
||
return literal(t);
|
||
}
|
||
switch (t.val) {
|
||
case "G":
|
||
return oneOf2(loc.eras("short", false), 0);
|
||
case "GG":
|
||
return oneOf2(loc.eras("long", false), 0);
|
||
case "y":
|
||
return intUnit2(oneToSix);
|
||
case "yy":
|
||
return intUnit2(twoToFour, untruncateYear2);
|
||
case "yyyy":
|
||
return intUnit2(four);
|
||
case "yyyyy":
|
||
return intUnit2(fourToSix);
|
||
case "yyyyyy":
|
||
return intUnit2(six);
|
||
case "M":
|
||
return intUnit2(oneOrTwo);
|
||
case "MM":
|
||
return intUnit2(two);
|
||
case "MMM":
|
||
return oneOf2(loc.months("short", true, false), 1);
|
||
case "MMMM":
|
||
return oneOf2(loc.months("long", true, false), 1);
|
||
case "L":
|
||
return intUnit2(oneOrTwo);
|
||
case "LL":
|
||
return intUnit2(two);
|
||
case "LLL":
|
||
return oneOf2(loc.months("short", false, false), 1);
|
||
case "LLLL":
|
||
return oneOf2(loc.months("long", false, false), 1);
|
||
case "d":
|
||
return intUnit2(oneOrTwo);
|
||
case "dd":
|
||
return intUnit2(two);
|
||
case "o":
|
||
return intUnit2(oneToThree);
|
||
case "ooo":
|
||
return intUnit2(three);
|
||
case "HH":
|
||
return intUnit2(two);
|
||
case "H":
|
||
return intUnit2(oneOrTwo);
|
||
case "hh":
|
||
return intUnit2(two);
|
||
case "h":
|
||
return intUnit2(oneOrTwo);
|
||
case "mm":
|
||
return intUnit2(two);
|
||
case "m":
|
||
return intUnit2(oneOrTwo);
|
||
case "q":
|
||
return intUnit2(oneOrTwo);
|
||
case "qq":
|
||
return intUnit2(two);
|
||
case "s":
|
||
return intUnit2(oneOrTwo);
|
||
case "ss":
|
||
return intUnit2(two);
|
||
case "S":
|
||
return intUnit2(oneToThree);
|
||
case "SSS":
|
||
return intUnit2(three);
|
||
case "u":
|
||
return simple2(oneToNine);
|
||
case "uu":
|
||
return simple2(oneOrTwo);
|
||
case "uuu":
|
||
return intUnit2(one);
|
||
case "a":
|
||
return oneOf2(loc.meridiems(), 0);
|
||
case "kkkk":
|
||
return intUnit2(four);
|
||
case "kk":
|
||
return intUnit2(twoToFour, untruncateYear2);
|
||
case "W":
|
||
return intUnit2(oneOrTwo);
|
||
case "WW":
|
||
return intUnit2(two);
|
||
case "E":
|
||
case "c":
|
||
return intUnit2(one);
|
||
case "EEE":
|
||
return oneOf2(loc.weekdays("short", false, false), 1);
|
||
case "EEEE":
|
||
return oneOf2(loc.weekdays("long", false, false), 1);
|
||
case "ccc":
|
||
return oneOf2(loc.weekdays("short", true, false), 1);
|
||
case "cccc":
|
||
return oneOf2(loc.weekdays("long", true, false), 1);
|
||
case "Z":
|
||
case "ZZ":
|
||
return offset3(new RegExp(`([+-]${oneOrTwo.source})(?::(${two.source}))?`), 2);
|
||
case "ZZZ":
|
||
return offset3(new RegExp(`([+-]${oneOrTwo.source})(${two.source})?`), 2);
|
||
case "z":
|
||
return simple2(/[a-z_+-/]{1,256}?/i);
|
||
default:
|
||
return literal(t);
|
||
}
|
||
};
|
||
const unit = unitate(token) || {
|
||
invalidReason: MISSING_FTP2
|
||
};
|
||
unit.token = token;
|
||
return unit;
|
||
}
|
||
var partTypeStyleToTokenVal2 = {
|
||
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 tokenForPart2(part, formatOpts) {
|
||
const { type, value } = part;
|
||
if (type === "literal") {
|
||
return {
|
||
literal: true,
|
||
val: value
|
||
};
|
||
}
|
||
const style = formatOpts[type];
|
||
let val = partTypeStyleToTokenVal2[type];
|
||
if (typeof val === "object") {
|
||
val = val[style];
|
||
}
|
||
if (val) {
|
||
return {
|
||
literal: false,
|
||
val
|
||
};
|
||
}
|
||
return void 0;
|
||
}
|
||
function buildRegex2(units) {
|
||
const re = units.map((u) => u.regex).reduce((f, r) => `${f}(${r.source})`, "");
|
||
return [`^${re}$`, units];
|
||
}
|
||
function match2(input, regex, handlers) {
|
||
const matches = input.match(regex);
|
||
if (matches) {
|
||
const all3 = {};
|
||
let matchIndex = 1;
|
||
for (const i in handlers) {
|
||
if (hasOwnProperty3(handlers, i)) {
|
||
const h = handlers[i], groups = h.groups ? h.groups + 1 : 1;
|
||
if (!h.literal && h.token) {
|
||
all3[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups));
|
||
}
|
||
matchIndex += groups;
|
||
}
|
||
}
|
||
return [matches, all3];
|
||
} else {
|
||
return [matches, {}];
|
||
}
|
||
}
|
||
function dateTimeFromMatches2(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 (!isUndefined3(matches.z)) {
|
||
zone = IANAZone2.create(matches.z);
|
||
}
|
||
if (!isUndefined3(matches.Z)) {
|
||
if (!zone) {
|
||
zone = new FixedOffsetZone2(matches.Z);
|
||
}
|
||
specificOffset = matches.Z;
|
||
}
|
||
if (!isUndefined3(matches.q)) {
|
||
matches.M = (matches.q - 1) * 3 + 1;
|
||
}
|
||
if (!isUndefined3(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 (!isUndefined3(matches.u)) {
|
||
matches.S = parseMillis2(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 dummyDateTimeCache2 = null;
|
||
function getDummyDateTime2() {
|
||
if (!dummyDateTimeCache2) {
|
||
dummyDateTimeCache2 = DateTime2.fromMillis(1555555555555);
|
||
}
|
||
return dummyDateTimeCache2;
|
||
}
|
||
function maybeExpandMacroToken2(token, locale) {
|
||
if (token.literal) {
|
||
return token;
|
||
}
|
||
const formatOpts = Formatter2.macroTokenToFormatOpts(token.val);
|
||
const tokens = formatOptsToTokens2(formatOpts, locale);
|
||
if (tokens == null || tokens.includes(void 0)) {
|
||
return token;
|
||
}
|
||
return tokens;
|
||
}
|
||
function expandMacroTokens2(tokens, locale) {
|
||
return Array.prototype.concat(...tokens.map((t) => maybeExpandMacroToken2(t, locale)));
|
||
}
|
||
function explainFromTokens2(locale, input, format) {
|
||
const tokens = expandMacroTokens2(Formatter2.parseFormat(format), locale), units = tokens.map((t) => unitForToken2(t, locale)), disqualifyingUnit = units.find((t) => t.invalidReason);
|
||
if (disqualifyingUnit) {
|
||
return { input, tokens, invalidReason: disqualifyingUnit.invalidReason };
|
||
} else {
|
||
const [regexString, handlers] = buildRegex2(units), regex = RegExp(regexString, "i"), [rawMatches, matches] = match2(input, regex, handlers), [result, zone, specificOffset] = matches ? dateTimeFromMatches2(matches) : [null, null, void 0];
|
||
if (hasOwnProperty3(matches, "a") && hasOwnProperty3(matches, "H")) {
|
||
throw new ConflictingSpecificationError2(
|
||
"Can't include meridiem when specifying 24-hour format"
|
||
);
|
||
}
|
||
return { input, tokens, regex, rawMatches, matches, result, zone, specificOffset };
|
||
}
|
||
}
|
||
function parseFromTokens2(locale, input, format) {
|
||
const { result, zone, specificOffset, invalidReason } = explainFromTokens2(locale, input, format);
|
||
return [result, zone, specificOffset, invalidReason];
|
||
}
|
||
function formatOptsToTokens2(formatOpts, locale) {
|
||
if (!formatOpts) {
|
||
return null;
|
||
}
|
||
const formatter = Formatter2.create(locale, formatOpts);
|
||
const parts = formatter.formatDateTimeParts(getDummyDateTime2());
|
||
return parts.map((p) => tokenForPart2(p, formatOpts));
|
||
}
|
||
var nonLeapLadder2 = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
||
var leapLadder2 = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
|
||
function unitOutOfRange2(unit, value) {
|
||
return new Invalid2(
|
||
"unit out of range",
|
||
`you specified ${value} (of type ${typeof value}) as a ${unit}, which is invalid`
|
||
);
|
||
}
|
||
function dayOfWeek2(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 computeOrdinal2(year, month, day) {
|
||
return day + (isLeapYear2(year) ? leapLadder2 : nonLeapLadder2)[month - 1];
|
||
}
|
||
function uncomputeOrdinal2(year, ordinal) {
|
||
const table = isLeapYear2(year) ? leapLadder2 : nonLeapLadder2, month0 = table.findIndex((i) => i < ordinal), day = ordinal - table[month0];
|
||
return { month: month0 + 1, day };
|
||
}
|
||
function gregorianToWeek2(gregObj) {
|
||
const { year, month, day } = gregObj, ordinal = computeOrdinal2(year, month, day), weekday = dayOfWeek2(year, month, day);
|
||
let weekNumber = Math.floor((ordinal - weekday + 10) / 7), weekYear;
|
||
if (weekNumber < 1) {
|
||
weekYear = year - 1;
|
||
weekNumber = weeksInWeekYear2(weekYear);
|
||
} else if (weekNumber > weeksInWeekYear2(year)) {
|
||
weekYear = year + 1;
|
||
weekNumber = 1;
|
||
} else {
|
||
weekYear = year;
|
||
}
|
||
return __spreadValues({ weekYear, weekNumber, weekday }, timeObject2(gregObj));
|
||
}
|
||
function weekToGregorian2(weekData) {
|
||
const { weekYear, weekNumber, weekday } = weekData, weekdayOfJan4 = dayOfWeek2(weekYear, 1, 4), yearInDays = daysInYear2(weekYear);
|
||
let ordinal = weekNumber * 7 + weekday - weekdayOfJan4 - 3, year;
|
||
if (ordinal < 1) {
|
||
year = weekYear - 1;
|
||
ordinal += daysInYear2(year);
|
||
} else if (ordinal > yearInDays) {
|
||
year = weekYear + 1;
|
||
ordinal -= daysInYear2(weekYear);
|
||
} else {
|
||
year = weekYear;
|
||
}
|
||
const { month, day } = uncomputeOrdinal2(year, ordinal);
|
||
return __spreadValues({ year, month, day }, timeObject2(weekData));
|
||
}
|
||
function gregorianToOrdinal2(gregData) {
|
||
const { year, month, day } = gregData;
|
||
const ordinal = computeOrdinal2(year, month, day);
|
||
return __spreadValues({ year, ordinal }, timeObject2(gregData));
|
||
}
|
||
function ordinalToGregorian2(ordinalData) {
|
||
const { year, ordinal } = ordinalData;
|
||
const { month, day } = uncomputeOrdinal2(year, ordinal);
|
||
return __spreadValues({ year, month, day }, timeObject2(ordinalData));
|
||
}
|
||
function hasInvalidWeekData2(obj) {
|
||
const validYear = isInteger2(obj.weekYear), validWeek = integerBetween2(obj.weekNumber, 1, weeksInWeekYear2(obj.weekYear)), validWeekday = integerBetween2(obj.weekday, 1, 7);
|
||
if (!validYear) {
|
||
return unitOutOfRange2("weekYear", obj.weekYear);
|
||
} else if (!validWeek) {
|
||
return unitOutOfRange2("week", obj.week);
|
||
} else if (!validWeekday) {
|
||
return unitOutOfRange2("weekday", obj.weekday);
|
||
} else
|
||
return false;
|
||
}
|
||
function hasInvalidOrdinalData2(obj) {
|
||
const validYear = isInteger2(obj.year), validOrdinal = integerBetween2(obj.ordinal, 1, daysInYear2(obj.year));
|
||
if (!validYear) {
|
||
return unitOutOfRange2("year", obj.year);
|
||
} else if (!validOrdinal) {
|
||
return unitOutOfRange2("ordinal", obj.ordinal);
|
||
} else
|
||
return false;
|
||
}
|
||
function hasInvalidGregorianData2(obj) {
|
||
const validYear = isInteger2(obj.year), validMonth = integerBetween2(obj.month, 1, 12), validDay = integerBetween2(obj.day, 1, daysInMonth2(obj.year, obj.month));
|
||
if (!validYear) {
|
||
return unitOutOfRange2("year", obj.year);
|
||
} else if (!validMonth) {
|
||
return unitOutOfRange2("month", obj.month);
|
||
} else if (!validDay) {
|
||
return unitOutOfRange2("day", obj.day);
|
||
} else
|
||
return false;
|
||
}
|
||
function hasInvalidTimeData2(obj) {
|
||
const { hour, minute, second, millisecond } = obj;
|
||
const validHour = integerBetween2(hour, 0, 23) || hour === 24 && minute === 0 && second === 0 && millisecond === 0, validMinute = integerBetween2(minute, 0, 59), validSecond = integerBetween2(second, 0, 59), validMillisecond = integerBetween2(millisecond, 0, 999);
|
||
if (!validHour) {
|
||
return unitOutOfRange2("hour", hour);
|
||
} else if (!validMinute) {
|
||
return unitOutOfRange2("minute", minute);
|
||
} else if (!validSecond) {
|
||
return unitOutOfRange2("second", second);
|
||
} else if (!validMillisecond) {
|
||
return unitOutOfRange2("millisecond", millisecond);
|
||
} else
|
||
return false;
|
||
}
|
||
var INVALID4 = "Invalid DateTime";
|
||
var MAX_DATE2 = 864e13;
|
||
function unsupportedZone2(zone) {
|
||
return new Invalid2("unsupported zone", `the zone "${zone.name}" is not supported`);
|
||
}
|
||
function possiblyCachedWeekData2(dt) {
|
||
if (dt.weekData === null) {
|
||
dt.weekData = gregorianToWeek2(dt.c);
|
||
}
|
||
return dt.weekData;
|
||
}
|
||
function clone3(inst, alts) {
|
||
const current = {
|
||
ts: inst.ts,
|
||
zone: inst.zone,
|
||
c: inst.c,
|
||
o: inst.o,
|
||
loc: inst.loc,
|
||
invalid: inst.invalid
|
||
};
|
||
return new DateTime2(__spreadProps(__spreadValues(__spreadValues({}, current), alts), { old: current }));
|
||
}
|
||
function fixOffset2(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 tsToObj2(ts, offset4) {
|
||
ts += offset4 * 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 objToTS2(obj, offset4, zone) {
|
||
return fixOffset2(objToLocalTS2(obj), offset4, zone);
|
||
}
|
||
function adjustTime2(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 = __spreadProps(__spreadValues({}, inst.c), {
|
||
year,
|
||
month,
|
||
day: Math.min(inst.c.day, daysInMonth2(year, month)) + Math.trunc(dur.days) + Math.trunc(dur.weeks) * 7
|
||
}), millisToAdd = Duration2.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 = objToLocalTS2(c);
|
||
let [ts, o] = fixOffset2(localTS, oPre, inst.zone);
|
||
if (millisToAdd !== 0) {
|
||
ts += millisToAdd;
|
||
o = inst.zone.offset(ts);
|
||
}
|
||
return { ts, o };
|
||
}
|
||
function parseDataToDateTime2(parsed, parsedZone, opts, format, text2, specificOffset) {
|
||
const { setZone, zone } = opts;
|
||
if (parsed && Object.keys(parsed).length !== 0) {
|
||
const interpretationZone = parsedZone || zone, inst = DateTime2.fromObject(parsed, __spreadProps(__spreadValues({}, opts), {
|
||
zone: interpretationZone,
|
||
specificOffset
|
||
}));
|
||
return setZone ? inst : inst.setZone(zone);
|
||
} else {
|
||
return DateTime2.invalid(
|
||
new Invalid2("unparsable", `the input "${text2}" can't be parsed as ${format}`)
|
||
);
|
||
}
|
||
}
|
||
function toTechFormat2(dt, format, allowZ = true) {
|
||
return dt.isValid ? Formatter2.create(Locale2.create("en-US"), {
|
||
allowZ,
|
||
forceSimple: true
|
||
}).formatDateTimeFromString(dt, format) : null;
|
||
}
|
||
function toISODate2(o, extended) {
|
||
const longFormat = o.c.year > 9999 || o.c.year < 0;
|
||
let c = "";
|
||
if (longFormat && o.c.year >= 0)
|
||
c += "+";
|
||
c += padStart2(o.c.year, longFormat ? 6 : 4);
|
||
if (extended) {
|
||
c += "-";
|
||
c += padStart2(o.c.month);
|
||
c += "-";
|
||
c += padStart2(o.c.day);
|
||
} else {
|
||
c += padStart2(o.c.month);
|
||
c += padStart2(o.c.day);
|
||
}
|
||
return c;
|
||
}
|
||
function toISOTime2(o, extended, suppressSeconds, suppressMilliseconds, includeOffset, extendedZone) {
|
||
let c = padStart2(o.c.hour);
|
||
if (extended) {
|
||
c += ":";
|
||
c += padStart2(o.c.minute);
|
||
if (o.c.second !== 0 || !suppressSeconds) {
|
||
c += ":";
|
||
}
|
||
} else {
|
||
c += padStart2(o.c.minute);
|
||
}
|
||
if (o.c.second !== 0 || !suppressSeconds) {
|
||
c += padStart2(o.c.second);
|
||
if (o.c.millisecond !== 0 || !suppressMilliseconds) {
|
||
c += ".";
|
||
c += padStart2(o.c.millisecond, 3);
|
||
}
|
||
}
|
||
if (includeOffset) {
|
||
if (o.isOffsetFixed && o.offset === 0 && !extendedZone) {
|
||
c += "Z";
|
||
} else if (o.o < 0) {
|
||
c += "-";
|
||
c += padStart2(Math.trunc(-o.o / 60));
|
||
c += ":";
|
||
c += padStart2(Math.trunc(-o.o % 60));
|
||
} else {
|
||
c += "+";
|
||
c += padStart2(Math.trunc(o.o / 60));
|
||
c += ":";
|
||
c += padStart2(Math.trunc(o.o % 60));
|
||
}
|
||
}
|
||
if (extendedZone) {
|
||
c += "[" + o.zone.ianaName + "]";
|
||
}
|
||
return c;
|
||
}
|
||
var defaultUnitValues2 = {
|
||
month: 1,
|
||
day: 1,
|
||
hour: 0,
|
||
minute: 0,
|
||
second: 0,
|
||
millisecond: 0
|
||
};
|
||
var defaultWeekUnitValues2 = {
|
||
weekNumber: 1,
|
||
weekday: 1,
|
||
hour: 0,
|
||
minute: 0,
|
||
second: 0,
|
||
millisecond: 0
|
||
};
|
||
var defaultOrdinalUnitValues2 = {
|
||
ordinal: 1,
|
||
hour: 0,
|
||
minute: 0,
|
||
second: 0,
|
||
millisecond: 0
|
||
};
|
||
var orderedUnits3 = ["year", "month", "day", "hour", "minute", "second", "millisecond"];
|
||
var orderedWeekUnits2 = [
|
||
"weekYear",
|
||
"weekNumber",
|
||
"weekday",
|
||
"hour",
|
||
"minute",
|
||
"second",
|
||
"millisecond"
|
||
];
|
||
var orderedOrdinalUnits2 = ["year", "ordinal", "hour", "minute", "second", "millisecond"];
|
||
function normalizeUnit2(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 InvalidUnitError2(unit);
|
||
return normalized;
|
||
}
|
||
function quickDT2(obj, opts) {
|
||
const zone = normalizeZone2(opts.zone, Settings2.defaultZone), loc = Locale2.fromObject(opts), tsNow = Settings2.now();
|
||
let ts, o;
|
||
if (!isUndefined3(obj.year)) {
|
||
for (const u of orderedUnits3) {
|
||
if (isUndefined3(obj[u])) {
|
||
obj[u] = defaultUnitValues2[u];
|
||
}
|
||
}
|
||
const invalid = hasInvalidGregorianData2(obj) || hasInvalidTimeData2(obj);
|
||
if (invalid) {
|
||
return DateTime2.invalid(invalid);
|
||
}
|
||
const offsetProvis = zone.offset(tsNow);
|
||
[ts, o] = objToTS2(obj, offsetProvis, zone);
|
||
} else {
|
||
ts = tsNow;
|
||
}
|
||
return new DateTime2({ ts, zone, loc, o });
|
||
}
|
||
function diffRelative2(start2, end2, opts) {
|
||
const round2 = isUndefined3(opts.round) ? true : opts.round, format = (c, unit) => {
|
||
c = roundTo2(c, round2 || opts.calendary ? 0 : 2, true);
|
||
const formatter = end2.loc.clone(opts).relFormatter(opts);
|
||
return formatter.format(c, unit);
|
||
}, differ = (unit) => {
|
||
if (opts.calendary) {
|
||
if (!end2.hasSame(start2, unit)) {
|
||
return end2.startOf(unit).diff(start2.startOf(unit), unit).get(unit);
|
||
} else
|
||
return 0;
|
||
} else {
|
||
return end2.diff(start2, 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(start2 > end2 ? -0 : 0, opts.units[opts.units.length - 1]);
|
||
}
|
||
function lastOpts2(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 DateTime2 = class _DateTime {
|
||
/**
|
||
* @access private
|
||
*/
|
||
constructor(config) {
|
||
const zone = config.zone || Settings2.defaultZone;
|
||
let invalid = config.invalid || (Number.isNaN(config.ts) ? new Invalid2("invalid input") : null) || (!zone.isValid ? unsupportedZone2(zone) : null);
|
||
this.ts = isUndefined3(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 = tsToObj2(this.ts, ot);
|
||
invalid = Number.isNaN(c.year) ? new Invalid2("invalid input") : null;
|
||
c = invalid ? null : c;
|
||
o = invalid ? null : ot;
|
||
}
|
||
}
|
||
this._zone = zone;
|
||
this.loc = config.loc || Locale2.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] = lastOpts2(arguments), [year, month, day, hour, minute, second, millisecond] = args;
|
||
return quickDT2({ 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] = lastOpts2(arguments), [year, month, day, hour, minute, second, millisecond] = args;
|
||
opts.zone = FixedOffsetZone2.utcInstance;
|
||
return quickDT2({ 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 = isDate3(date) ? date.valueOf() : NaN;
|
||
if (Number.isNaN(ts)) {
|
||
return _DateTime.invalid("invalid input");
|
||
}
|
||
const zoneToUse = normalizeZone2(options.zone, Settings2.defaultZone);
|
||
if (!zoneToUse.isValid) {
|
||
return _DateTime.invalid(unsupportedZone2(zoneToUse));
|
||
}
|
||
return new _DateTime({
|
||
ts,
|
||
zone: zoneToUse,
|
||
loc: Locale2.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 (!isNumber3(milliseconds)) {
|
||
throw new InvalidArgumentError2(
|
||
`fromMillis requires a numerical input, but received a ${typeof milliseconds} with value ${milliseconds}`
|
||
);
|
||
} else if (milliseconds < -MAX_DATE2 || milliseconds > MAX_DATE2) {
|
||
return _DateTime.invalid("Timestamp out of range");
|
||
} else {
|
||
return new _DateTime({
|
||
ts: milliseconds,
|
||
zone: normalizeZone2(options.zone, Settings2.defaultZone),
|
||
loc: Locale2.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 (!isNumber3(seconds)) {
|
||
throw new InvalidArgumentError2("fromSeconds requires a numerical input");
|
||
} else {
|
||
return new _DateTime({
|
||
ts: seconds * 1e3,
|
||
zone: normalizeZone2(options.zone, Settings2.defaultZone),
|
||
loc: Locale2.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 = normalizeZone2(opts.zone, Settings2.defaultZone);
|
||
if (!zoneToUse.isValid) {
|
||
return _DateTime.invalid(unsupportedZone2(zoneToUse));
|
||
}
|
||
const tsNow = Settings2.now(), offsetProvis = !isUndefined3(opts.specificOffset) ? opts.specificOffset : zoneToUse.offset(tsNow), normalized = normalizeObject2(obj, normalizeUnit2), containsOrdinal = !isUndefined3(normalized.ordinal), containsGregorYear = !isUndefined3(normalized.year), containsGregorMD = !isUndefined3(normalized.month) || !isUndefined3(normalized.day), containsGregor = containsGregorYear || containsGregorMD, definiteWeekDef = normalized.weekYear || normalized.weekNumber, loc = Locale2.fromObject(opts);
|
||
if ((containsGregor || containsOrdinal) && definiteWeekDef) {
|
||
throw new ConflictingSpecificationError2(
|
||
"Can't mix weekYear/weekNumber units with year/month/day or ordinals"
|
||
);
|
||
}
|
||
if (containsGregorMD && containsOrdinal) {
|
||
throw new ConflictingSpecificationError2("Can't mix ordinal dates with month/day");
|
||
}
|
||
const useWeekData = definiteWeekDef || normalized.weekday && !containsGregor;
|
||
let units, defaultValues, objNow = tsToObj2(tsNow, offsetProvis);
|
||
if (useWeekData) {
|
||
units = orderedWeekUnits2;
|
||
defaultValues = defaultWeekUnitValues2;
|
||
objNow = gregorianToWeek2(objNow);
|
||
} else if (containsOrdinal) {
|
||
units = orderedOrdinalUnits2;
|
||
defaultValues = defaultOrdinalUnitValues2;
|
||
objNow = gregorianToOrdinal2(objNow);
|
||
} else {
|
||
units = orderedUnits3;
|
||
defaultValues = defaultUnitValues2;
|
||
}
|
||
let foundFirst = false;
|
||
for (const u of units) {
|
||
const v = normalized[u];
|
||
if (!isUndefined3(v)) {
|
||
foundFirst = true;
|
||
} else if (foundFirst) {
|
||
normalized[u] = defaultValues[u];
|
||
} else {
|
||
normalized[u] = objNow[u];
|
||
}
|
||
}
|
||
const higherOrderInvalid = useWeekData ? hasInvalidWeekData2(normalized) : containsOrdinal ? hasInvalidOrdinalData2(normalized) : hasInvalidGregorianData2(normalized), invalid = higherOrderInvalid || hasInvalidTimeData2(normalized);
|
||
if (invalid) {
|
||
return _DateTime.invalid(invalid);
|
||
}
|
||
const gregorian = useWeekData ? weekToGregorian2(normalized) : containsOrdinal ? ordinalToGregorian2(normalized) : normalized, [tsFinal, offsetFinal] = objToTS2(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] = parseISODate2(text2);
|
||
return parseDataToDateTime2(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] = parseRFC2822Date2(text2);
|
||
return parseDataToDateTime2(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] = parseHTTPDate2(text2);
|
||
return parseDataToDateTime2(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 (isUndefined3(text2) || isUndefined3(fmt)) {
|
||
throw new InvalidArgumentError2("fromFormat requires an input string and a format");
|
||
}
|
||
const { locale = null, numberingSystem = null } = opts, localeToUse = Locale2.fromOpts({
|
||
locale,
|
||
numberingSystem,
|
||
defaultToEN: true
|
||
}), [vals, parsedZone, specificOffset, invalid] = parseFromTokens2(localeToUse, text2, fmt);
|
||
if (invalid) {
|
||
return _DateTime.invalid(invalid);
|
||
} else {
|
||
return parseDataToDateTime2(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] = parseSQL2(text2);
|
||
return parseDataToDateTime2(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 InvalidArgumentError2("need to specify a reason the DateTime is invalid");
|
||
}
|
||
const invalid = reason instanceof Invalid2 ? reason : new Invalid2(reason, explanation);
|
||
if (Settings2.throwOnInvalid) {
|
||
throw new InvalidDateTimeError2(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 = formatOptsToTokens2(formatOpts, Locale2.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 = expandMacroTokens2(Formatter2.parseFormat(fmt), Locale2.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 ? possiblyCachedWeekData2(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 ? possiblyCachedWeekData2(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 ? possiblyCachedWeekData2(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 ? gregorianToOrdinal2(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 ? Info2.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 ? Info2.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 ? Info2.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 ? Info2.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 isLeapYear2(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 daysInMonth2(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 ? daysInYear2(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 ? weeksInWeekYear2(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 } = Formatter2.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(offset4 = 0, opts = {}) {
|
||
return this.setZone(FixedOffsetZone2.instance(offset4), 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 = normalizeZone2(zone, Settings2.defaultZone);
|
||
if (zone.equals(this.zone)) {
|
||
return this;
|
||
} else if (!zone.isValid) {
|
||
return _DateTime.invalid(unsupportedZone2(zone));
|
||
} else {
|
||
let newTS = this.ts;
|
||
if (keepLocalTime || keepCalendarTime) {
|
||
const offsetGuess = zone.offset(this.ts);
|
||
const asObj = this.toObject();
|
||
[newTS] = objToTS2(asObj, offsetGuess, zone);
|
||
}
|
||
return clone3(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 clone3(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 = normalizeObject2(values, normalizeUnit2), settingWeekStuff = !isUndefined3(normalized.weekYear) || !isUndefined3(normalized.weekNumber) || !isUndefined3(normalized.weekday), containsOrdinal = !isUndefined3(normalized.ordinal), containsGregorYear = !isUndefined3(normalized.year), containsGregorMD = !isUndefined3(normalized.month) || !isUndefined3(normalized.day), containsGregor = containsGregorYear || containsGregorMD, definiteWeekDef = normalized.weekYear || normalized.weekNumber;
|
||
if ((containsGregor || containsOrdinal) && definiteWeekDef) {
|
||
throw new ConflictingSpecificationError2(
|
||
"Can't mix weekYear/weekNumber units with year/month/day or ordinals"
|
||
);
|
||
}
|
||
if (containsGregorMD && containsOrdinal) {
|
||
throw new ConflictingSpecificationError2("Can't mix ordinal dates with month/day");
|
||
}
|
||
let mixed;
|
||
if (settingWeekStuff) {
|
||
mixed = weekToGregorian2(__spreadValues(__spreadValues({}, gregorianToWeek2(this.c)), normalized));
|
||
} else if (!isUndefined3(normalized.ordinal)) {
|
||
mixed = ordinalToGregorian2(__spreadValues(__spreadValues({}, gregorianToOrdinal2(this.c)), normalized));
|
||
} else {
|
||
mixed = __spreadValues(__spreadValues({}, this.toObject()), normalized);
|
||
if (isUndefined3(normalized.day)) {
|
||
mixed.day = Math.min(daysInMonth2(mixed.year, mixed.month), mixed.day);
|
||
}
|
||
}
|
||
const [ts, o] = objToTS2(mixed, this.o, this.zone);
|
||
return clone3(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 = Duration2.fromDurationLike(duration);
|
||
return clone3(this, adjustTime2(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 = Duration2.fromDurationLike(duration).negate();
|
||
return clone3(this, adjustTime2(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 = Duration2.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 ? Formatter2.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID4;
|
||
}
|
||
/**
|
||
* 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_SHORT2, opts = {}) {
|
||
return this.isValid ? Formatter2.create(this.loc.clone(opts), formatOpts).formatDateTime(this) : INVALID4;
|
||
}
|
||
/**
|
||
* 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 ? Formatter2.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 = toISODate2(this, ext);
|
||
c += "T";
|
||
c += toISOTime2(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 toISODate2(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 toTechFormat2(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 + toISOTime2(
|
||
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 toTechFormat2(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 toTechFormat2(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 toISODate2(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 toTechFormat2(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() : INVALID4;
|
||
}
|
||
/**
|
||
* 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 = __spreadValues({}, 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 Duration2.invalid("created by diffing an invalid DateTime");
|
||
}
|
||
const durOpts = __spreadValues({ locale: this.locale, numberingSystem: this.numberingSystem }, opts);
|
||
const units = maybeArray2(unit).map(Duration2.normalizeUnit), otherIsLater = otherDateTime.valueOf() > this.valueOf(), earlier = otherIsLater ? this : otherDateTime, later = otherIsLater ? otherDateTime : this, diffed = diff2(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 ? Interval2.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 diffRelative2(base, this.plus(padding), __spreadProps(__spreadValues({}, 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 diffRelative2(options.base || _DateTime.fromObject({}, { zone: this.zone }), this, __spreadProps(__spreadValues({}, 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 InvalidArgumentError2("min requires all arguments be DateTimes");
|
||
}
|
||
return bestBy2(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 InvalidArgumentError2("max requires all arguments be DateTimes");
|
||
}
|
||
return bestBy2(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 = Locale2.fromOpts({
|
||
locale,
|
||
numberingSystem,
|
||
defaultToEN: true
|
||
});
|
||
return explainFromTokens2(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_SHORT2;
|
||
}
|
||
/**
|
||
* {@link DateTime#toLocaleString} format like 'Oct 14, 1983'
|
||
* @type {Object}
|
||
*/
|
||
static get DATE_MED() {
|
||
return DATE_MED2;
|
||
}
|
||
/**
|
||
* {@link DateTime#toLocaleString} format like 'Fri, Oct 14, 1983'
|
||
* @type {Object}
|
||
*/
|
||
static get DATE_MED_WITH_WEEKDAY() {
|
||
return DATE_MED_WITH_WEEKDAY2;
|
||
}
|
||
/**
|
||
* {@link DateTime#toLocaleString} format like 'October 14, 1983'
|
||
* @type {Object}
|
||
*/
|
||
static get DATE_FULL() {
|
||
return DATE_FULL2;
|
||
}
|
||
/**
|
||
* {@link DateTime#toLocaleString} format like 'Tuesday, October 14, 1983'
|
||
* @type {Object}
|
||
*/
|
||
static get DATE_HUGE() {
|
||
return DATE_HUGE2;
|
||
}
|
||
/**
|
||
* {@link DateTime#toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
|
||
* @type {Object}
|
||
*/
|
||
static get TIME_SIMPLE() {
|
||
return TIME_SIMPLE2;
|
||
}
|
||
/**
|
||
* {@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_SECONDS2;
|
||
}
|
||
/**
|
||
* {@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_OFFSET2;
|
||
}
|
||
/**
|
||
* {@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_OFFSET2;
|
||
}
|
||
/**
|
||
* {@link DateTime#toLocaleString} format like '09:30', always 24-hour.
|
||
* @type {Object}
|
||
*/
|
||
static get TIME_24_SIMPLE() {
|
||
return TIME_24_SIMPLE2;
|
||
}
|
||
/**
|
||
* {@link DateTime#toLocaleString} format like '09:30:23', always 24-hour.
|
||
* @type {Object}
|
||
*/
|
||
static get TIME_24_WITH_SECONDS() {
|
||
return TIME_24_WITH_SECONDS2;
|
||
}
|
||
/**
|
||
* {@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_OFFSET2;
|
||
}
|
||
/**
|
||
* {@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_OFFSET2;
|
||
}
|
||
/**
|
||
* {@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_SHORT2;
|
||
}
|
||
/**
|
||
* {@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_SECONDS2;
|
||
}
|
||
/**
|
||
* {@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_MED2;
|
||
}
|
||
/**
|
||
* {@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_SECONDS2;
|
||
}
|
||
/**
|
||
* {@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_WEEKDAY2;
|
||
}
|
||
/**
|
||
* {@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_FULL2;
|
||
}
|
||
/**
|
||
* {@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_SECONDS2;
|
||
}
|
||
/**
|
||
* {@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_HUGE2;
|
||
}
|
||
/**
|
||
* {@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_SECONDS2;
|
||
}
|
||
};
|
||
function friendlyDateTime2(dateTimeish) {
|
||
if (DateTime2.isDateTime(dateTimeish)) {
|
||
return dateTimeish;
|
||
} else if (dateTimeish && dateTimeish.valueOf && isNumber3(dateTimeish.valueOf())) {
|
||
return DateTime2.fromJSDate(dateTimeish);
|
||
} else if (dateTimeish && typeof dateTimeish === "object") {
|
||
return DateTime2.fromObject(dateTimeish);
|
||
} else {
|
||
throw new InvalidArgumentError2(
|
||
`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
|
||
};
|
||
__spreadValues(__spreadValues(__spreadValues({}, DEFAULT_QUERY_SETTINGS), DEFAULT_EXPORT_SETTINGS), {
|
||
inlineQueryPrefix: "=",
|
||
inlineJsQueryPrefix: "$=",
|
||
inlineQueriesInCodeblocks: true,
|
||
enableInlineDataview: true,
|
||
enableDataviewJs: false,
|
||
enableInlineDataviewJs: false,
|
||
prettyRenderInlineFields: true,
|
||
dataviewJsKeyword: "dataviewjs"
|
||
});
|
||
var Success = class _Success {
|
||
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 _Failure {
|
||
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(n3, t) {
|
||
module3.exports = t();
|
||
}("undefined" != typeof self ? self : commonjsGlobal, function() {
|
||
return function(n3) {
|
||
var t = {};
|
||
function r(e) {
|
||
if (t[e])
|
||
return t[e].exports;
|
||
var u = t[e] = { i: e, l: false, exports: {} };
|
||
return n3[e].call(u.exports, u, u.exports, r), u.l = true, u.exports;
|
||
}
|
||
return r.m = n3, r.c = t, r.d = function(n4, t2, e) {
|
||
r.o(n4, t2) || Object.defineProperty(n4, t2, { configurable: false, enumerable: true, get: e });
|
||
}, r.r = function(n4) {
|
||
Object.defineProperty(n4, "__esModule", { value: true });
|
||
}, r.n = function(n4) {
|
||
var t2 = n4 && n4.__esModule ? function() {
|
||
return n4.default;
|
||
} : function() {
|
||
return n4;
|
||
};
|
||
return r.d(t2, "a", t2), t2;
|
||
}, r.o = function(n4, t2) {
|
||
return Object.prototype.hasOwnProperty.call(n4, t2);
|
||
}, r.p = "", r(r.s = 0);
|
||
}([function(n3, t, r) {
|
||
function e(n4) {
|
||
if (!(this instanceof e))
|
||
return new e(n4);
|
||
this._ = n4;
|
||
}
|
||
var u = e.prototype;
|
||
function o(n4, t2) {
|
||
for (var r2 = 0; r2 < n4; r2++)
|
||
t2(r2);
|
||
}
|
||
function i(n4, t2, r2) {
|
||
return function(n5, t3) {
|
||
o(t3.length, function(r3) {
|
||
n5(t3[r3], r3, t3);
|
||
});
|
||
}(function(r3, e2, u2) {
|
||
t2 = n4(t2, r3, e2, u2);
|
||
}, r2), t2;
|
||
}
|
||
function a(n4, t2) {
|
||
return i(function(t3, r2, e2, u2) {
|
||
return t3.concat([n4(r2, e2, u2)]);
|
||
}, [], t2);
|
||
}
|
||
function f(n4, t2) {
|
||
var r2 = { v: 0, buf: t2 };
|
||
return o(n4, function() {
|
||
var n5;
|
||
r2 = { v: r2.v << 1 | (n5 = r2.buf, n5[0] >> 7), buf: function(n6) {
|
||
var t3 = i(function(n7, t4, r3, e2) {
|
||
return n7.concat(r3 === e2.length - 1 ? Buffer.from([t4, 0]).readUInt16BE(0) : e2.readUInt16BE(r3));
|
||
}, [], n6);
|
||
return Buffer.from(a(function(n7) {
|
||
return (n7 << 1 & 65535) >> 8;
|
||
}, t3));
|
||
}(r2.buf) };
|
||
}), r2;
|
||
}
|
||
function c() {
|
||
return "undefined" != typeof Buffer;
|
||
}
|
||
function s3() {
|
||
if (!c())
|
||
throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.");
|
||
}
|
||
function l3(n4) {
|
||
s3();
|
||
var t2 = i(function(n5, t3) {
|
||
return n5 + t3;
|
||
}, 0, n4);
|
||
if (t2 % 8 != 0)
|
||
throw new Error("The bits [" + n4.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(n5) {
|
||
return n5 > 48;
|
||
}, i(function(n5, t3) {
|
||
return n5 || (r2(t3) ? t3 : n5);
|
||
}, null, n4));
|
||
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(n5, t4) {
|
||
var r4 = f(t4, n5.buf);
|
||
return { coll: n5.coll.concat(r4.v), buf: r4.buf };
|
||
}, { coll: [], buf: t3.slice(r3, e2) }, n4).coll);
|
||
});
|
||
}
|
||
function h(n4, t2) {
|
||
return new e(function(r2, e2) {
|
||
return s3(), e2 + t2 > r2.length ? x(e2, t2 + " bytes for " + n4) : b(e2 + t2, r2.slice(e2, e2 + t2));
|
||
});
|
||
}
|
||
function p(n4, t2) {
|
||
if ("number" != typeof (r2 = t2) || Math.floor(r2) !== r2 || t2 < 0 || t2 > 6)
|
||
throw new Error(n4 + " requires integer length in range [0, 6].");
|
||
var r2;
|
||
}
|
||
function d(n4) {
|
||
return p("uintBE", n4), h("uintBE(" + n4 + ")", n4).map(function(t2) {
|
||
return t2.readUIntBE(0, n4);
|
||
});
|
||
}
|
||
function v(n4) {
|
||
return p("uintLE", n4), h("uintLE(" + n4 + ")", n4).map(function(t2) {
|
||
return t2.readUIntLE(0, n4);
|
||
});
|
||
}
|
||
function g(n4) {
|
||
return p("intBE", n4), h("intBE(" + n4 + ")", n4).map(function(t2) {
|
||
return t2.readIntBE(0, n4);
|
||
});
|
||
}
|
||
function m(n4) {
|
||
return p("intLE", n4), h("intLE(" + n4 + ")", n4).map(function(t2) {
|
||
return t2.readIntLE(0, n4);
|
||
});
|
||
}
|
||
function y(n4) {
|
||
return n4 instanceof e;
|
||
}
|
||
function E(n4) {
|
||
return "[object Array]" === {}.toString.call(n4);
|
||
}
|
||
function w(n4) {
|
||
return c() && Buffer.isBuffer(n4);
|
||
}
|
||
function b(n4, t2) {
|
||
return { status: true, index: n4, value: t2, furthest: -1, expected: [] };
|
||
}
|
||
function x(n4, t2) {
|
||
return E(t2) || (t2 = [t2]), { status: false, index: -1, value: null, furthest: n4, expected: t2 };
|
||
}
|
||
function B(n4, t2) {
|
||
if (!t2)
|
||
return n4;
|
||
if (n4.furthest > t2.furthest)
|
||
return n4;
|
||
var r2 = n4.furthest === t2.furthest ? function(n5, t3) {
|
||
if (function() {
|
||
if (void 0 !== e._supportsSet)
|
||
return e._supportsSet;
|
||
var n6 = "undefined" != typeof Set;
|
||
return e._supportsSet = n6, n6;
|
||
}() && Array.from) {
|
||
for (var r3 = new Set(n5), 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 < n5.length; a2++)
|
||
i2[n5[a2]] = true;
|
||
for (var f2 = 0; f2 < t3.length; f2++)
|
||
i2[t3[f2]] = true;
|
||
var c2 = [];
|
||
for (var s4 in i2)
|
||
({}).hasOwnProperty.call(i2, s4) && c2.push(s4);
|
||
return c2.sort(), c2;
|
||
}(n4.expected, t2.expected) : t2.expected;
|
||
return { status: n4.status, index: n4.index, value: n4.value, furthest: t2.furthest, expected: r2 };
|
||
}
|
||
var j = {};
|
||
function S(n4, t2) {
|
||
if (w(n4))
|
||
return { offset: t2, line: -1, column: -1 };
|
||
n4 in j || (j[n4] = {});
|
||
for (var r2 = j[n4], 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" === n4.charAt(i2) || "\r" === n4.charAt(i2) && "\n" !== n4.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 _(n4) {
|
||
if (!y(n4))
|
||
throw new Error("not a parser: " + n4);
|
||
}
|
||
function L(n4, t2) {
|
||
return "string" == typeof n4 ? n4.charAt(t2) : n4[t2];
|
||
}
|
||
function O(n4) {
|
||
if ("number" != typeof n4)
|
||
throw new Error("not a number: " + n4);
|
||
}
|
||
function k(n4) {
|
||
if ("function" != typeof n4)
|
||
throw new Error("not a function: " + n4);
|
||
}
|
||
function P(n4) {
|
||
if ("string" != typeof n4)
|
||
throw new Error("not a string: " + n4);
|
||
}
|
||
var q = 2, A = 3, I = 8, F = 5 * I, M = 4 * I, z = " ";
|
||
function R(n4, t2) {
|
||
return new Array(t2 + 1).join(n4);
|
||
}
|
||
function U(n4, t2, r2) {
|
||
var e2 = t2 - n4.length;
|
||
return e2 <= 0 ? n4 : R(r2, e2) + n4;
|
||
}
|
||
function W(n4, t2, r2, e2) {
|
||
return { from: n4 - t2 > 0 ? n4 - t2 : 0, to: n4 + r2 > e2 ? e2 : n4 + r2 };
|
||
}
|
||
function D(n4, t2) {
|
||
var r2, e2, u2, o2, f2, c2 = t2.index, s4 = c2.offset, l4 = 1;
|
||
if (s4 === n4.length)
|
||
return "Got the end of the input";
|
||
if (w(n4)) {
|
||
var h2 = s4 - s4 % I, p2 = s4 - h2, d2 = W(h2, F, M + I, n4.length), v2 = a(function(n5) {
|
||
return a(function(n6) {
|
||
return U(n6.toString(16), 2, "0");
|
||
}, n5);
|
||
}, function(n5, t3) {
|
||
var r3 = n5.length, e3 = [], u3 = 0;
|
||
if (r3 <= t3)
|
||
return [n5.slice()];
|
||
for (var o3 = 0; o3 < r3; o3++)
|
||
e3[u3] || e3.push([]), e3[u3].push(n5[o3]), (o3 + 1) % t3 == 0 && u3++;
|
||
return e3;
|
||
}(n4.slice(d2.from, d2.to).toJSON().data, I));
|
||
o2 = function(n5) {
|
||
return 0 === n5.from && 1 === n5.to ? { from: n5.from, to: n5.to } : { from: n5.from / I, to: Math.floor(n5.to / I) };
|
||
}(d2), e2 = h2 / I, r2 = 3 * p2, p2 >= 4 && (r2 += 1), l4 = 2, u2 = a(function(n5) {
|
||
return n5.length <= 4 ? n5.join(" ") : n5.slice(0, 4).join(" ") + " " + n5.slice(4).join(" ");
|
||
}, v2), (f2 = (8 * (o2.to > 0 ? o2.to - 1 : o2.to)).toString(16).length) < 2 && (f2 = 2);
|
||
} else {
|
||
var g2 = n4.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(n4) && (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(n4) ? 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("^", l4)] : []);
|
||
}, [], u2).join("\n");
|
||
}
|
||
function N(n4, t2) {
|
||
return ["\n", "-- PARSING FAILED " + R("-", 50), "\n\n", D(n4, 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(n4) {
|
||
return void 0 !== n4.flags ? n4.flags : [n4.global ? "g" : "", n4.ignoreCase ? "i" : "", n4.multiline ? "m" : "", n4.unicode ? "u" : "", n4.sticky ? "y" : ""].join("");
|
||
}
|
||
function C() {
|
||
for (var n4 = [].slice.call(arguments), t2 = n4.length, r2 = 0; r2 < t2; r2 += 1)
|
||
_(n4[r2]);
|
||
return e(function(r3, e2) {
|
||
for (var u2, o2 = new Array(t2), i2 = 0; i2 < t2; i2 += 1) {
|
||
if (!(u2 = B(n4[i2]._(r3, e2), u2)).status)
|
||
return u2;
|
||
o2[i2] = u2.value, e2 = u2.index;
|
||
}
|
||
return B(b(e2, o2), u2);
|
||
});
|
||
}
|
||
function J() {
|
||
var n4 = [].slice.call(arguments);
|
||
if (0 === n4.length)
|
||
throw new Error("seqMap needs at least one argument");
|
||
var t2 = n4.pop();
|
||
return k(t2), C.apply(null, n4).map(function(n5) {
|
||
return t2.apply(null, n5);
|
||
});
|
||
}
|
||
function T() {
|
||
var n4 = [].slice.call(arguments), t2 = n4.length;
|
||
if (0 === t2)
|
||
return Y("zero alternates");
|
||
for (var r2 = 0; r2 < t2; r2 += 1)
|
||
_(n4[r2]);
|
||
return e(function(t3, r3) {
|
||
for (var e2, u2 = 0; u2 < n4.length; u2 += 1)
|
||
if ((e2 = B(n4[u2]._(t3, r3), e2)).status)
|
||
return e2;
|
||
return e2;
|
||
});
|
||
}
|
||
function V(n4, t2) {
|
||
return H(n4, t2).or(X([]));
|
||
}
|
||
function H(n4, t2) {
|
||
return _(n4), _(t2), J(n4, t2.then(n4).many(), function(n5, t3) {
|
||
return [n5].concat(t3);
|
||
});
|
||
}
|
||
function K(n4) {
|
||
P(n4);
|
||
var t2 = "'" + n4 + "'";
|
||
return e(function(r2, e2) {
|
||
var u2 = e2 + n4.length, o2 = r2.slice(e2, u2);
|
||
return o2 === n4 ? b(u2, o2) : x(e2, t2);
|
||
});
|
||
}
|
||
function Q(n4, t2) {
|
||
!function(n5) {
|
||
if (!(n5 instanceof RegExp))
|
||
throw new Error("not a regexp: " + n5);
|
||
for (var t3 = G(n5), 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 + '": ' + n5);
|
||
}
|
||
}(n4), arguments.length >= 2 ? O(t2) : t2 = 0;
|
||
var r2 = function(n5) {
|
||
return RegExp("^(?:" + n5.source + ")", G(n5));
|
||
}(n4), u2 = "" + n4;
|
||
return e(function(n5, e2) {
|
||
var o2 = r2.exec(n5.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(n4) {
|
||
return e(function(t2, r2) {
|
||
return b(r2, n4);
|
||
});
|
||
}
|
||
function Y(n4) {
|
||
return e(function(t2, r2) {
|
||
return x(r2, n4);
|
||
});
|
||
}
|
||
function Z(n4) {
|
||
if (y(n4))
|
||
return e(function(t2, r2) {
|
||
var e2 = n4._(t2, r2);
|
||
return e2.index = r2, e2.value = "", e2;
|
||
});
|
||
if ("string" == typeof n4)
|
||
return Z(K(n4));
|
||
if (n4 instanceof RegExp)
|
||
return Z(Q(n4));
|
||
throw new Error("not a string, regexp, or parser: " + n4);
|
||
}
|
||
function $(n4) {
|
||
return _(n4), e(function(t2, r2) {
|
||
var e2 = n4._(t2, r2), u2 = t2.slice(r2, e2.index);
|
||
return e2.status ? x(r2, 'not "' + u2 + '"') : b(r2, null);
|
||
});
|
||
}
|
||
function nn(n4) {
|
||
return k(n4), e(function(t2, r2) {
|
||
var e2 = L(t2, r2);
|
||
return r2 < t2.length && n4(e2) ? b(r2 + 1, e2) : x(r2, "a character/byte matching " + n4);
|
||
});
|
||
}
|
||
function tn(n4, t2) {
|
||
arguments.length < 2 && (t2 = n4, n4 = void 0);
|
||
var r2 = e(function(n5, e2) {
|
||
return r2._ = t2()._, r2._(n5, e2);
|
||
});
|
||
return n4 ? r2.desc(n4) : r2;
|
||
}
|
||
function rn() {
|
||
return Y("fantasy-land/empty");
|
||
}
|
||
u.parse = function(n4) {
|
||
if ("string" != typeof n4 && !w(n4))
|
||
throw new Error(".parse must be called with a string or Buffer as its argument");
|
||
var t2, r2 = this.skip(an)._(n4, 0);
|
||
return t2 = r2.status ? { status: true, value: r2.value } : { status: false, index: S(n4, r2.furthest), expected: r2.expected }, delete j[n4], t2;
|
||
}, u.tryParse = function(n4) {
|
||
var t2 = this.parse(n4);
|
||
if (t2.status)
|
||
return t2.value;
|
||
var r2 = N(n4, t2), e2 = new Error(r2);
|
||
throw e2.type = "ParsimmonError", e2.result = t2, e2;
|
||
}, u.assert = function(n4, t2) {
|
||
return this.chain(function(r2) {
|
||
return n4(r2) ? X(r2) : Y(t2);
|
||
});
|
||
}, u.or = function(n4) {
|
||
return T(this, n4);
|
||
}, u.trim = function(n4) {
|
||
return this.wrap(n4, n4);
|
||
}, u.wrap = function(n4, t2) {
|
||
return J(n4, this, t2, function(n5, t3) {
|
||
return t3;
|
||
});
|
||
}, u.thru = function(n4) {
|
||
return n4(this);
|
||
}, u.then = function(n4) {
|
||
return _(n4), C(this, n4).map(function(n5) {
|
||
return n5[1];
|
||
});
|
||
}, u.many = function() {
|
||
var n4 = this;
|
||
return e(function(t2, r2) {
|
||
for (var e2 = [], u2 = void 0; ; ) {
|
||
if (!(u2 = B(n4._(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(n4) {
|
||
return P(n4), this.map(function(t2) {
|
||
if (function(n5) {
|
||
if (!E(n5))
|
||
throw new Error("not an array: " + n5);
|
||
}(t2), t2.length) {
|
||
P(t2[0]);
|
||
for (var r2 = t2[0], e2 = 1; e2 < t2.length; e2++)
|
||
P(t2[e2]), r2 += n4 + t2[e2];
|
||
return r2;
|
||
}
|
||
return "";
|
||
});
|
||
}, u.tie = function() {
|
||
return this.tieWith("");
|
||
}, u.times = function(n4, t2) {
|
||
var r2 = this;
|
||
return arguments.length < 2 && (t2 = n4), O(n4), O(t2), e(function(e2, u2) {
|
||
for (var o2 = [], i2 = void 0, a2 = void 0, f2 = 0; f2 < n4; 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(n4) {
|
||
return this.map(function() {
|
||
return n4;
|
||
});
|
||
}, u.atMost = function(n4) {
|
||
return this.times(0, n4);
|
||
}, u.atLeast = function(n4) {
|
||
return J(this.times(n4), this.many(), function(n5, t2) {
|
||
return n5.concat(t2);
|
||
});
|
||
}, u.map = function(n4) {
|
||
k(n4);
|
||
var t2 = this;
|
||
return e(function(r2, e2) {
|
||
var u2 = t2._(r2, e2);
|
||
return u2.status ? B(b(u2.index, n4(u2.value)), u2) : u2;
|
||
});
|
||
}, u.contramap = function(n4) {
|
||
k(n4);
|
||
var t2 = this;
|
||
return e(function(r2, e2) {
|
||
var u2 = t2.parse(n4(r2.slice(e2)));
|
||
return u2.status ? b(e2 + r2.length, u2.value) : u2;
|
||
});
|
||
}, u.promap = function(n4, t2) {
|
||
return k(n4), k(t2), this.contramap(n4).map(t2);
|
||
}, u.skip = function(n4) {
|
||
return C(this, n4).map(function(n5) {
|
||
return n5[0];
|
||
});
|
||
}, u.mark = function() {
|
||
return J(en, this, en, function(n4, t2, r2) {
|
||
return { start: n4, value: t2, end: r2 };
|
||
});
|
||
}, u.node = function(n4) {
|
||
return J(en, this, en, function(t2, r2, e2) {
|
||
return { name: n4, value: r2, start: t2, end: e2 };
|
||
});
|
||
}, u.sepBy = function(n4) {
|
||
return V(this, n4);
|
||
}, u.sepBy1 = function(n4) {
|
||
return H(this, n4);
|
||
}, u.lookahead = function(n4) {
|
||
return this.skip(Z(n4));
|
||
}, u.notFollowedBy = function(n4) {
|
||
return this.skip($(n4));
|
||
}, u.desc = function(n4) {
|
||
E(n4) || (n4 = [n4]);
|
||
var t2 = this;
|
||
return e(function(r2, e2) {
|
||
var u2 = t2._(r2, e2);
|
||
return u2.status || (u2.expected = n4), u2;
|
||
});
|
||
}, u.fallback = function(n4) {
|
||
return this.or(X(n4));
|
||
}, u.ap = function(n4) {
|
||
return J(n4, this, function(n5, t2) {
|
||
return n5(t2);
|
||
});
|
||
}, u.chain = function(n4) {
|
||
var t2 = this;
|
||
return e(function(r2, e2) {
|
||
var u2 = t2._(r2, e2);
|
||
return u2.status ? B(n4(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(n4, t2) {
|
||
return b(t2, S(n4, t2));
|
||
}), un = e(function(n4, t2) {
|
||
return t2 >= n4.length ? x(t2, "any character/byte") : b(t2 + 1, L(n4, t2));
|
||
}), on = e(function(n4, t2) {
|
||
return b(n4.length, n4.slice(t2));
|
||
}), an = e(function(n4, t2) {
|
||
return t2 < n4.length ? x(t2, "EOF") : b(t2, null);
|
||
}), fn2 = 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(n4) {
|
||
var t2 = {};
|
||
for (var r2 in n4)
|
||
({}).hasOwnProperty.call(n4, r2) && function(r3) {
|
||
t2[r3] = tn(function() {
|
||
return n4[r3](t2);
|
||
});
|
||
}(r2);
|
||
return t2;
|
||
}, e.crlf = gn, e.custom = function(n4) {
|
||
return e(n4(b, x));
|
||
}, e.digit = fn2, 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(n4) {
|
||
return nn(function(t2) {
|
||
return n4.indexOf(t2) < 0;
|
||
}).desc("none of '" + n4 + "'");
|
||
}, e.notFollowedBy = $, e.of = X, e.oneOf = function(n4) {
|
||
for (var t2 = n4.split(""), r2 = 0; r2 < t2.length; r2++)
|
||
t2[r2] = "'" + t2[r2] + "'";
|
||
return nn(function(t3) {
|
||
return n4.indexOf(t3) >= 0;
|
||
}).desc(t2);
|
||
}, e.optWhitespace = hn, e.Parser = e, e.range = function(n4, t2) {
|
||
return nn(function(r2) {
|
||
return n4 <= r2 && r2 <= t2;
|
||
}).desc(n4 + "-" + t2);
|
||
}, e.regex = Q, e.regexp = Q, e.sepBy = V, e.sepBy1 = H, e.seq = C, e.seqMap = J, e.seqObj = function() {
|
||
for (var n4, t2 = {}, r2 = 0, u2 = (n4 = arguments, Array.prototype.slice.call(n4)), 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(n5, 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._(n5, 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(n4) {
|
||
return k(n4), e(function(t2, r2) {
|
||
for (var e2 = r2; e2 < t2.length && n4(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: l3, bitSeqObj: function(n4) {
|
||
s3();
|
||
var t2 = {}, r2 = 0, e2 = a(function(n5) {
|
||
if (E(n5)) {
|
||
var e3 = n5;
|
||
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(n5), [null, n5];
|
||
}, n4);
|
||
if (r2 < 1)
|
||
throw new Error("bitSeqObj expects at least one named pair, got [" + n4.join(", ") + "]");
|
||
var u2 = a(function(n5) {
|
||
return n5[0];
|
||
}, e2);
|
||
return l3(a(function(n5) {
|
||
return n5[1];
|
||
}, e2)).map(function(n5) {
|
||
return i(function(n6, t3) {
|
||
return null !== t3[0] && (n6[t3[0]] = t3[1]), n6;
|
||
}, {}, a(function(t3, r3) {
|
||
return [t3, n5[r3]];
|
||
}, u2));
|
||
});
|
||
}, byte: function(n4) {
|
||
if (s3(), O(n4), n4 > 255)
|
||
throw new Error("Value specified to byte constructor (" + n4 + "=0x" + n4.toString(16) + ") is larger in value than a single byte.");
|
||
var t2 = (n4 > 15 ? "0x" : "0x0") + n4.toString(16);
|
||
return e(function(r2, e2) {
|
||
var u2 = L(r2, e2);
|
||
return u2 === n4 ? b(e2 + 1, u2) : x(e2, t2);
|
||
});
|
||
}, buffer: function(n4) {
|
||
return h("buffer", n4).map(function(n5) {
|
||
return Buffer.from(n5);
|
||
});
|
||
}, encodedString: function(n4, t2) {
|
||
return h("string", t2).map(function(t3) {
|
||
return t3.toString(n4);
|
||
});
|
||
}, 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(n4) {
|
||
return n4.readFloatBE(0);
|
||
}), floatLE: h("floatLE", 4).map(function(n4) {
|
||
return n4.readFloatLE(0);
|
||
}), doubleBE: h("doubleBE", 8).map(function(n4) {
|
||
return n4.readDoubleBE(0);
|
||
}), doubleLE: h("doubleLE", 8).map(function(n4) {
|
||
return n4.readDoubleLE(0);
|
||
}) }, n3.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\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDD-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF6](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7C\uDE80-\uDE86\uDE90-\uDEAC\uDEB0-\uDEBA\uDEC0-\uDEC2\uDED0-\uDED9\uDEE0-\uDEE7]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?))/g;
|
||
};
|
||
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 = Duration2.fromObject(Object.fromEntries(Object.entries(dur.toObject()).filter(([, quantity]) => quantity > 0)));
|
||
return dur.toHuman();
|
||
}
|
||
var Values;
|
||
(function(Values2) {
|
||
function toString3(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) => toString3(f, setting, true)).join(", ");
|
||
if (recursive)
|
||
result += "]";
|
||
return result;
|
||
case "object":
|
||
return "{ " + Object.entries(wrapped.value).map((e) => e[0] + ": " + toString3(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 = toString3;
|
||
function wrapValue(val) {
|
||
if (isNull(val))
|
||
return { type: "null", value: val };
|
||
else if (isNumber4(val))
|
||
return { type: "number", value: val };
|
||
else if (isString4(val))
|
||
return { type: "string", value: val };
|
||
else if (isBoolean2(val))
|
||
return { type: "boolean", value: val };
|
||
else if (isDuration(val))
|
||
return { type: "duration", value: val };
|
||
else if (isDate4(val))
|
||
return { type: "date", value: val };
|
||
else if (isWidget(val))
|
||
return { type: "widget", value: val };
|
||
else if (isArray2(val))
|
||
return { type: "array", value: val };
|
||
else if (isLink(val))
|
||
return { type: "link", value: val };
|
||
else if (isFunction2(val))
|
||
return { type: "function", value: val };
|
||
else if (isHtml(val))
|
||
return { type: "html", value: val };
|
||
else if (isObject3(val))
|
||
return { type: "object", value: val };
|
||
else
|
||
return void 0;
|
||
}
|
||
Values2.wrapValue = wrapValue;
|
||
function mapLeaves(val, func) {
|
||
if (isObject3(val)) {
|
||
let result = {};
|
||
for (let [key, value] of Object.entries(val))
|
||
result[key] = mapLeaves(value, func);
|
||
return result;
|
||
} else if (isArray2(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 _a2, _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 ((_a2 = link1.subpath) !== null && _a2 !== void 0 ? _a2 : "").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 _a2;
|
||
return (_a2 = wrapValue(val)) === null || _a2 === void 0 ? void 0 : _a2.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 isString4(val) {
|
||
return typeof val == "string";
|
||
}
|
||
Values2.isString = isString4;
|
||
function isNumber4(val) {
|
||
return typeof val == "number";
|
||
}
|
||
Values2.isNumber = isNumber4;
|
||
function isDate4(val) {
|
||
return val instanceof DateTime2;
|
||
}
|
||
Values2.isDate = isDate4;
|
||
function isDuration(val) {
|
||
return val instanceof Duration2;
|
||
}
|
||
Values2.isDuration = isDuration;
|
||
function isNull(val) {
|
||
return val === null || val === void 0;
|
||
}
|
||
Values2.isNull = isNull;
|
||
function isArray2(val) {
|
||
return Array.isArray(val);
|
||
}
|
||
Values2.isArray = isArray2;
|
||
function isBoolean2(val) {
|
||
return typeof val === "boolean";
|
||
}
|
||
Values2.isBoolean = isBoolean2;
|
||
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 isObject3(val) {
|
||
return typeof val == "object" && !isHtml(val) && !isWidget(val) && !isArray2(val) && !isDuration(val) && !isDate4(val) && !isLink(val) && val !== void 0 && !isNull(val);
|
||
}
|
||
Values2.isObject = isObject3;
|
||
function isFunction2(val) {
|
||
return typeof val == "function";
|
||
}
|
||
Values2.isFunction = isFunction2;
|
||
})(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 _Link {
|
||
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 _a2, _b;
|
||
const escaped = this.path.replace("|", "\\|");
|
||
if (this.type == "header")
|
||
return escaped + "#" + ((_a2 = this.subpath) === null || _a2 === void 0 ? void 0 : _a2.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 _a2;
|
||
return `[${(_a2 = this.display) !== null && _a2 !== void 0 ? _a2 : 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(left2, op, right2) {
|
||
return { type: "binaryop", left: left2, op, right: right2 };
|
||
}
|
||
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(left2, op, right2) {
|
||
return { type: "binaryop", left: left2, op, right: right2 };
|
||
}
|
||
Sources2.binaryOp = binaryOp;
|
||
function and(left2, right2) {
|
||
return { type: "binaryop", left: left2, op: "&", right: right2 };
|
||
}
|
||
Sources2.and = and;
|
||
function or(left2, right2) {
|
||
return { type: "binaryop", left: left2, op: "|", right: right2 };
|
||
}
|
||
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: Duration2.fromObject({ years: 1 }),
|
||
years: Duration2.fromObject({ years: 1 }),
|
||
yr: Duration2.fromObject({ years: 1 }),
|
||
yrs: Duration2.fromObject({ years: 1 }),
|
||
month: Duration2.fromObject({ months: 1 }),
|
||
months: Duration2.fromObject({ months: 1 }),
|
||
mo: Duration2.fromObject({ months: 1 }),
|
||
mos: Duration2.fromObject({ months: 1 }),
|
||
week: Duration2.fromObject({ weeks: 1 }),
|
||
weeks: Duration2.fromObject({ weeks: 1 }),
|
||
wk: Duration2.fromObject({ weeks: 1 }),
|
||
wks: Duration2.fromObject({ weeks: 1 }),
|
||
w: Duration2.fromObject({ weeks: 1 }),
|
||
day: Duration2.fromObject({ days: 1 }),
|
||
days: Duration2.fromObject({ days: 1 }),
|
||
d: Duration2.fromObject({ days: 1 }),
|
||
hour: Duration2.fromObject({ hours: 1 }),
|
||
hours: Duration2.fromObject({ hours: 1 }),
|
||
hr: Duration2.fromObject({ hours: 1 }),
|
||
hrs: Duration2.fromObject({ hours: 1 }),
|
||
h: Duration2.fromObject({ hours: 1 }),
|
||
minute: Duration2.fromObject({ minutes: 1 }),
|
||
minutes: Duration2.fromObject({ minutes: 1 }),
|
||
min: Duration2.fromObject({ minutes: 1 }),
|
||
mins: Duration2.fromObject({ minutes: 1 }),
|
||
m: Duration2.fromObject({ minutes: 1 }),
|
||
second: Duration2.fromObject({ seconds: 1 }),
|
||
seconds: Duration2.fromObject({ seconds: 1 }),
|
||
sec: Duration2.fromObject({ seconds: 1 }),
|
||
secs: Duration2.fromObject({ seconds: 1 }),
|
||
s: Duration2.fromObject({ seconds: 1 })
|
||
};
|
||
var DATE_SHORTHANDS = {
|
||
now: () => DateTime2.local(),
|
||
today: () => DateTime2.local().startOf("day"),
|
||
yesterday: () => DateTime2.local().startOf("day").minus(Duration2.fromObject({ days: 1 })),
|
||
tomorrow: () => DateTime2.local().startOf("day").plus(Duration2.fromObject({ days: 1 })),
|
||
sow: () => DateTime2.local().startOf("week"),
|
||
"start-of-week": () => DateTime2.local().startOf("week"),
|
||
eow: () => DateTime2.local().endOf("week"),
|
||
"end-of-week": () => DateTime2.local().endOf("week"),
|
||
soy: () => DateTime2.local().startOf("year"),
|
||
"start-of-year": () => DateTime2.local().startOf("year"),
|
||
eoy: () => DateTime2.local().endOf("year"),
|
||
"end-of-year": () => DateTime2.local().endOf("year"),
|
||
som: () => DateTime2.local().startOf("month"),
|
||
"start-of-month": () => DateTime2.local().startOf("month"),
|
||
eom: () => DateTime2.local().endOf("month"),
|
||
"end-of-month": () => DateTime2.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(), (start2, rest) => start2 + 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(new 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, l3) => {
|
||
if (p.length > 0)
|
||
l3.embed = true;
|
||
return l3;
|
||
}).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 DateTime2.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("]"), (_a2, 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((s3) => s3), 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((l3) => Fields.list(l3)).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, l3) => [f].concat(l3)), 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((l3) => Fields.literal(l3)),
|
||
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 _a2;
|
||
if (app)
|
||
return (_a2 = app.plugins.plugins.dataview) === null || _a2 === void 0 ? void 0 : _a2.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;
|
||
}
|
||
});
|
||
|
||
// node_modules/before-after-hook/lib/register.js
|
||
var require_register = __commonJS({
|
||
"node_modules/before-after-hook/lib/register.js"(exports, module2) {
|
||
module2.exports = register;
|
||
function register(state, name, method, options) {
|
||
if (typeof method !== "function") {
|
||
throw new Error("method for before hook must be a function");
|
||
}
|
||
if (!options) {
|
||
options = {};
|
||
}
|
||
if (Array.isArray(name)) {
|
||
return name.reverse().reduce(function(callback, name2) {
|
||
return register.bind(null, state, name2, callback, options);
|
||
}, method)();
|
||
}
|
||
return Promise.resolve().then(function() {
|
||
if (!state.registry[name]) {
|
||
return method(options);
|
||
}
|
||
return state.registry[name].reduce(function(method2, registered) {
|
||
return registered.hook.bind(null, method2, options);
|
||
}, method)();
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/before-after-hook/lib/add.js
|
||
var require_add = __commonJS({
|
||
"node_modules/before-after-hook/lib/add.js"(exports, module2) {
|
||
module2.exports = addHook;
|
||
function addHook(state, kind, name, hook2) {
|
||
var orig = hook2;
|
||
if (!state.registry[name]) {
|
||
state.registry[name] = [];
|
||
}
|
||
if (kind === "before") {
|
||
hook2 = function(method, options) {
|
||
return Promise.resolve().then(orig.bind(null, options)).then(method.bind(null, options));
|
||
};
|
||
}
|
||
if (kind === "after") {
|
||
hook2 = function(method, options) {
|
||
var result;
|
||
return Promise.resolve().then(method.bind(null, options)).then(function(result_) {
|
||
result = result_;
|
||
return orig(result, options);
|
||
}).then(function() {
|
||
return result;
|
||
});
|
||
};
|
||
}
|
||
if (kind === "error") {
|
||
hook2 = function(method, options) {
|
||
return Promise.resolve().then(method.bind(null, options)).catch(function(error) {
|
||
return orig(error, options);
|
||
});
|
||
};
|
||
}
|
||
state.registry[name].push({
|
||
hook: hook2,
|
||
orig
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/before-after-hook/lib/remove.js
|
||
var require_remove = __commonJS({
|
||
"node_modules/before-after-hook/lib/remove.js"(exports, module2) {
|
||
module2.exports = removeHook;
|
||
function removeHook(state, name, method) {
|
||
if (!state.registry[name]) {
|
||
return;
|
||
}
|
||
var index = state.registry[name].map(function(registered) {
|
||
return registered.orig;
|
||
}).indexOf(method);
|
||
if (index === -1) {
|
||
return;
|
||
}
|
||
state.registry[name].splice(index, 1);
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/before-after-hook/index.js
|
||
var require_before_after_hook = __commonJS({
|
||
"node_modules/before-after-hook/index.js"(exports, module2) {
|
||
var register = require_register();
|
||
var addHook = require_add();
|
||
var removeHook = require_remove();
|
||
var bind2 = Function.bind;
|
||
var bindable = bind2.bind(bind2);
|
||
function bindApi(hook2, state, name) {
|
||
var removeHookRef = bindable(removeHook, null).apply(
|
||
null,
|
||
name ? [state, name] : [state]
|
||
);
|
||
hook2.api = { remove: removeHookRef };
|
||
hook2.remove = removeHookRef;
|
||
["before", "error", "after", "wrap"].forEach(function(kind) {
|
||
var args = name ? [state, kind, name] : [state, kind];
|
||
hook2[kind] = hook2.api[kind] = bindable(addHook, null).apply(null, args);
|
||
});
|
||
}
|
||
function HookSingular() {
|
||
var singularHookName = "h";
|
||
var singularHookState = {
|
||
registry: {}
|
||
};
|
||
var singularHook = register.bind(null, singularHookState, singularHookName);
|
||
bindApi(singularHook, singularHookState, singularHookName);
|
||
return singularHook;
|
||
}
|
||
function HookCollection() {
|
||
var state = {
|
||
registry: {}
|
||
};
|
||
var hook2 = register.bind(null, state);
|
||
bindApi(hook2, state);
|
||
return hook2;
|
||
}
|
||
var collectionHookDeprecationMessageDisplayed = false;
|
||
function Hook() {
|
||
if (!collectionHookDeprecationMessageDisplayed) {
|
||
console.warn(
|
||
'[before-after-hook]: "Hook()" repurposing warning, use "Hook.Collection()". Read more: https://git.io/upgrade-before-after-hook-to-1.4'
|
||
);
|
||
collectionHookDeprecationMessageDisplayed = true;
|
||
}
|
||
return HookCollection();
|
||
}
|
||
Hook.Singular = HookSingular.bind();
|
||
Hook.Collection = HookCollection.bind();
|
||
module2.exports = Hook;
|
||
module2.exports.Hook = Hook;
|
||
module2.exports.Singular = Hook.Singular;
|
||
module2.exports.Collection = Hook.Collection;
|
||
}
|
||
});
|
||
|
||
// node_modules/wrappy/wrappy.js
|
||
var require_wrappy = __commonJS({
|
||
"node_modules/wrappy/wrappy.js"(exports, module2) {
|
||
module2.exports = wrappy;
|
||
function wrappy(fn2, cb) {
|
||
if (fn2 && cb)
|
||
return wrappy(fn2)(cb);
|
||
if (typeof fn2 !== "function")
|
||
throw new TypeError("need wrapper function");
|
||
Object.keys(fn2).forEach(function(k) {
|
||
wrapper[k] = fn2[k];
|
||
});
|
||
return wrapper;
|
||
function wrapper() {
|
||
var args = new Array(arguments.length);
|
||
for (var i = 0; i < args.length; i++) {
|
||
args[i] = arguments[i];
|
||
}
|
||
var ret = fn2.apply(this, args);
|
||
var cb2 = args[args.length - 1];
|
||
if (typeof ret === "function" && ret !== cb2) {
|
||
Object.keys(cb2).forEach(function(k) {
|
||
ret[k] = cb2[k];
|
||
});
|
||
}
|
||
return ret;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/once/once.js
|
||
var require_once = __commonJS({
|
||
"node_modules/once/once.js"(exports, module2) {
|
||
var wrappy = require_wrappy();
|
||
module2.exports = wrappy(once2);
|
||
module2.exports.strict = wrappy(onceStrict);
|
||
once2.proto = once2(function() {
|
||
Object.defineProperty(Function.prototype, "once", {
|
||
value: function() {
|
||
return once2(this);
|
||
},
|
||
configurable: true
|
||
});
|
||
Object.defineProperty(Function.prototype, "onceStrict", {
|
||
value: function() {
|
||
return onceStrict(this);
|
||
},
|
||
configurable: true
|
||
});
|
||
});
|
||
function once2(fn2) {
|
||
var f = function() {
|
||
if (f.called)
|
||
return f.value;
|
||
f.called = true;
|
||
return f.value = fn2.apply(this, arguments);
|
||
};
|
||
f.called = false;
|
||
return f;
|
||
}
|
||
function onceStrict(fn2) {
|
||
var f = function() {
|
||
if (f.called)
|
||
throw new Error(f.onceError);
|
||
f.called = true;
|
||
return f.value = fn2.apply(this, arguments);
|
||
};
|
||
var name = fn2.name || "Function wrapped with `once`";
|
||
f.onceError = name + " shouldn't be called more than once";
|
||
f.called = false;
|
||
return f;
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/lz-string/libs/lz-string.js
|
||
var require_lz_string = __commonJS({
|
||
"node_modules/lz-string/libs/lz-string.js"(exports, module2) {
|
||
var LZString2 = function() {
|
||
var f = String.fromCharCode;
|
||
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
||
var baseReverseDic = {};
|
||
function getBaseValue(alphabet, character) {
|
||
if (!baseReverseDic[alphabet]) {
|
||
baseReverseDic[alphabet] = {};
|
||
for (var i = 0; i < alphabet.length; i++) {
|
||
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
||
}
|
||
}
|
||
return baseReverseDic[alphabet][character];
|
||
}
|
||
var LZString3 = {
|
||
compressToBase64: function(input) {
|
||
if (input == null)
|
||
return "";
|
||
var res = LZString3._compress(input, 6, function(a) {
|
||
return keyStrBase64.charAt(a);
|
||
});
|
||
switch (res.length % 4) {
|
||
default:
|
||
case 0:
|
||
return res;
|
||
case 1:
|
||
return res + "===";
|
||
case 2:
|
||
return res + "==";
|
||
case 3:
|
||
return res + "=";
|
||
}
|
||
},
|
||
decompressFromBase64: function(input) {
|
||
if (input == null)
|
||
return "";
|
||
if (input == "")
|
||
return null;
|
||
return LZString3._decompress(input.length, 32, function(index) {
|
||
return getBaseValue(keyStrBase64, input.charAt(index));
|
||
});
|
||
},
|
||
compressToUTF16: function(input) {
|
||
if (input == null)
|
||
return "";
|
||
return LZString3._compress(input, 15, function(a) {
|
||
return f(a + 32);
|
||
}) + " ";
|
||
},
|
||
decompressFromUTF16: function(compressed) {
|
||
if (compressed == null)
|
||
return "";
|
||
if (compressed == "")
|
||
return null;
|
||
return LZString3._decompress(compressed.length, 16384, function(index) {
|
||
return compressed.charCodeAt(index) - 32;
|
||
});
|
||
},
|
||
//compress into uint8array (UCS-2 big endian format)
|
||
compressToUint8Array: function(uncompressed) {
|
||
var compressed = LZString3.compress(uncompressed);
|
||
var buf = new Uint8Array(compressed.length * 2);
|
||
for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
|
||
var current_value = compressed.charCodeAt(i);
|
||
buf[i * 2] = current_value >>> 8;
|
||
buf[i * 2 + 1] = current_value % 256;
|
||
}
|
||
return buf;
|
||
},
|
||
//decompress from uint8array (UCS-2 big endian format)
|
||
decompressFromUint8Array: function(compressed) {
|
||
if (compressed === null || compressed === void 0) {
|
||
return LZString3.decompress(compressed);
|
||
} else {
|
||
var buf = new Array(compressed.length / 2);
|
||
for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) {
|
||
buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
|
||
}
|
||
var result = [];
|
||
buf.forEach(function(c) {
|
||
result.push(f(c));
|
||
});
|
||
return LZString3.decompress(result.join(""));
|
||
}
|
||
},
|
||
//compress into a string that is already URI encoded
|
||
compressToEncodedURIComponent: function(input) {
|
||
if (input == null)
|
||
return "";
|
||
return LZString3._compress(input, 6, function(a) {
|
||
return keyStrUriSafe.charAt(a);
|
||
});
|
||
},
|
||
//decompress from an output of compressToEncodedURIComponent
|
||
decompressFromEncodedURIComponent: function(input) {
|
||
if (input == null)
|
||
return "";
|
||
if (input == "")
|
||
return null;
|
||
input = input.replace(/ /g, "+");
|
||
return LZString3._decompress(input.length, 32, function(index) {
|
||
return getBaseValue(keyStrUriSafe, input.charAt(index));
|
||
});
|
||
},
|
||
compress: function(uncompressed) {
|
||
return LZString3._compress(uncompressed, 16, function(a) {
|
||
return f(a);
|
||
});
|
||
},
|
||
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
||
if (uncompressed == null)
|
||
return "";
|
||
var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
|
||
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
||
context_c = uncompressed.charAt(ii);
|
||
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
||
context_dictionary[context_c] = context_dictSize++;
|
||
context_dictionaryToCreate[context_c] = true;
|
||
}
|
||
context_wc = context_w + context_c;
|
||
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) {
|
||
context_w = context_wc;
|
||
} else {
|
||
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
||
if (context_w.charCodeAt(0) < 256) {
|
||
for (i = 0; i < context_numBits; i++) {
|
||
context_data_val = context_data_val << 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
}
|
||
value = context_w.charCodeAt(0);
|
||
for (i = 0; i < 8; i++) {
|
||
context_data_val = context_data_val << 1 | value & 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = value >> 1;
|
||
}
|
||
} else {
|
||
value = 1;
|
||
for (i = 0; i < context_numBits; i++) {
|
||
context_data_val = context_data_val << 1 | value;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = 0;
|
||
}
|
||
value = context_w.charCodeAt(0);
|
||
for (i = 0; i < 16; i++) {
|
||
context_data_val = context_data_val << 1 | value & 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = value >> 1;
|
||
}
|
||
}
|
||
context_enlargeIn--;
|
||
if (context_enlargeIn == 0) {
|
||
context_enlargeIn = Math.pow(2, context_numBits);
|
||
context_numBits++;
|
||
}
|
||
delete context_dictionaryToCreate[context_w];
|
||
} else {
|
||
value = context_dictionary[context_w];
|
||
for (i = 0; i < context_numBits; i++) {
|
||
context_data_val = context_data_val << 1 | value & 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = value >> 1;
|
||
}
|
||
}
|
||
context_enlargeIn--;
|
||
if (context_enlargeIn == 0) {
|
||
context_enlargeIn = Math.pow(2, context_numBits);
|
||
context_numBits++;
|
||
}
|
||
context_dictionary[context_wc] = context_dictSize++;
|
||
context_w = String(context_c);
|
||
}
|
||
}
|
||
if (context_w !== "") {
|
||
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
||
if (context_w.charCodeAt(0) < 256) {
|
||
for (i = 0; i < context_numBits; i++) {
|
||
context_data_val = context_data_val << 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
}
|
||
value = context_w.charCodeAt(0);
|
||
for (i = 0; i < 8; i++) {
|
||
context_data_val = context_data_val << 1 | value & 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = value >> 1;
|
||
}
|
||
} else {
|
||
value = 1;
|
||
for (i = 0; i < context_numBits; i++) {
|
||
context_data_val = context_data_val << 1 | value;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = 0;
|
||
}
|
||
value = context_w.charCodeAt(0);
|
||
for (i = 0; i < 16; i++) {
|
||
context_data_val = context_data_val << 1 | value & 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = value >> 1;
|
||
}
|
||
}
|
||
context_enlargeIn--;
|
||
if (context_enlargeIn == 0) {
|
||
context_enlargeIn = Math.pow(2, context_numBits);
|
||
context_numBits++;
|
||
}
|
||
delete context_dictionaryToCreate[context_w];
|
||
} else {
|
||
value = context_dictionary[context_w];
|
||
for (i = 0; i < context_numBits; i++) {
|
||
context_data_val = context_data_val << 1 | value & 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = value >> 1;
|
||
}
|
||
}
|
||
context_enlargeIn--;
|
||
if (context_enlargeIn == 0) {
|
||
context_enlargeIn = Math.pow(2, context_numBits);
|
||
context_numBits++;
|
||
}
|
||
}
|
||
value = 2;
|
||
for (i = 0; i < context_numBits; i++) {
|
||
context_data_val = context_data_val << 1 | value & 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data_position = 0;
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
context_data_val = 0;
|
||
} else {
|
||
context_data_position++;
|
||
}
|
||
value = value >> 1;
|
||
}
|
||
while (true) {
|
||
context_data_val = context_data_val << 1;
|
||
if (context_data_position == bitsPerChar - 1) {
|
||
context_data.push(getCharFromInt(context_data_val));
|
||
break;
|
||
} else
|
||
context_data_position++;
|
||
}
|
||
return context_data.join("");
|
||
},
|
||
decompress: function(compressed) {
|
||
if (compressed == null)
|
||
return "";
|
||
if (compressed == "")
|
||
return null;
|
||
return LZString3._decompress(compressed.length, 32768, function(index) {
|
||
return compressed.charCodeAt(index);
|
||
});
|
||
},
|
||
_decompress: function(length, resetValue, getNextValue) {
|
||
var dictionary = [], next, enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = { val: getNextValue(0), position: resetValue, index: 1 };
|
||
for (i = 0; i < 3; i += 1) {
|
||
dictionary[i] = i;
|
||
}
|
||
bits = 0;
|
||
maxpower = Math.pow(2, 2);
|
||
power = 1;
|
||
while (power != maxpower) {
|
||
resb = data.val & data.position;
|
||
data.position >>= 1;
|
||
if (data.position == 0) {
|
||
data.position = resetValue;
|
||
data.val = getNextValue(data.index++);
|
||
}
|
||
bits |= (resb > 0 ? 1 : 0) * power;
|
||
power <<= 1;
|
||
}
|
||
switch (next = bits) {
|
||
case 0:
|
||
bits = 0;
|
||
maxpower = Math.pow(2, 8);
|
||
power = 1;
|
||
while (power != maxpower) {
|
||
resb = data.val & data.position;
|
||
data.position >>= 1;
|
||
if (data.position == 0) {
|
||
data.position = resetValue;
|
||
data.val = getNextValue(data.index++);
|
||
}
|
||
bits |= (resb > 0 ? 1 : 0) * power;
|
||
power <<= 1;
|
||
}
|
||
c = f(bits);
|
||
break;
|
||
case 1:
|
||
bits = 0;
|
||
maxpower = Math.pow(2, 16);
|
||
power = 1;
|
||
while (power != maxpower) {
|
||
resb = data.val & data.position;
|
||
data.position >>= 1;
|
||
if (data.position == 0) {
|
||
data.position = resetValue;
|
||
data.val = getNextValue(data.index++);
|
||
}
|
||
bits |= (resb > 0 ? 1 : 0) * power;
|
||
power <<= 1;
|
||
}
|
||
c = f(bits);
|
||
break;
|
||
case 2:
|
||
return "";
|
||
}
|
||
dictionary[3] = c;
|
||
w = c;
|
||
result.push(c);
|
||
while (true) {
|
||
if (data.index > length) {
|
||
return "";
|
||
}
|
||
bits = 0;
|
||
maxpower = Math.pow(2, numBits);
|
||
power = 1;
|
||
while (power != maxpower) {
|
||
resb = data.val & data.position;
|
||
data.position >>= 1;
|
||
if (data.position == 0) {
|
||
data.position = resetValue;
|
||
data.val = getNextValue(data.index++);
|
||
}
|
||
bits |= (resb > 0 ? 1 : 0) * power;
|
||
power <<= 1;
|
||
}
|
||
switch (c = bits) {
|
||
case 0:
|
||
bits = 0;
|
||
maxpower = Math.pow(2, 8);
|
||
power = 1;
|
||
while (power != maxpower) {
|
||
resb = data.val & data.position;
|
||
data.position >>= 1;
|
||
if (data.position == 0) {
|
||
data.position = resetValue;
|
||
data.val = getNextValue(data.index++);
|
||
}
|
||
bits |= (resb > 0 ? 1 : 0) * power;
|
||
power <<= 1;
|
||
}
|
||
dictionary[dictSize++] = f(bits);
|
||
c = dictSize - 1;
|
||
enlargeIn--;
|
||
break;
|
||
case 1:
|
||
bits = 0;
|
||
maxpower = Math.pow(2, 16);
|
||
power = 1;
|
||
while (power != maxpower) {
|
||
resb = data.val & data.position;
|
||
data.position >>= 1;
|
||
if (data.position == 0) {
|
||
data.position = resetValue;
|
||
data.val = getNextValue(data.index++);
|
||
}
|
||
bits |= (resb > 0 ? 1 : 0) * power;
|
||
power <<= 1;
|
||
}
|
||
dictionary[dictSize++] = f(bits);
|
||
c = dictSize - 1;
|
||
enlargeIn--;
|
||
break;
|
||
case 2:
|
||
return result.join("");
|
||
}
|
||
if (enlargeIn == 0) {
|
||
enlargeIn = Math.pow(2, numBits);
|
||
numBits++;
|
||
}
|
||
if (dictionary[c]) {
|
||
entry = dictionary[c];
|
||
} else {
|
||
if (c === dictSize) {
|
||
entry = w + w.charAt(0);
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
result.push(entry);
|
||
dictionary[dictSize++] = w + entry.charAt(0);
|
||
enlargeIn--;
|
||
w = entry;
|
||
if (enlargeIn == 0) {
|
||
enlargeIn = Math.pow(2, numBits);
|
||
numBits++;
|
||
}
|
||
}
|
||
}
|
||
};
|
||
return LZString3;
|
||
}();
|
||
if (typeof define === "function" && define.amd) {
|
||
define(function() {
|
||
return LZString2;
|
||
});
|
||
} else if (typeof module2 !== "undefined" && module2 != null) {
|
||
module2.exports = LZString2;
|
||
} else if (typeof angular !== "undefined" && angular != null) {
|
||
angular.module("LZString", []).factory("LZString", function() {
|
||
return LZString2;
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/escape-string-regexp/index.js
|
||
var require_escape_string_regexp = __commonJS({
|
||
"node_modules/escape-string-regexp/index.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = (string) => {
|
||
if (typeof string !== "string") {
|
||
throw new TypeError("Expected a string");
|
||
}
|
||
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash.deburr/index.js
|
||
var require_lodash = __commonJS({
|
||
"node_modules/lodash.deburr/index.js"(exports, module2) {
|
||
var INFINITY = 1 / 0;
|
||
var symbolTag = "[object Symbol]";
|
||
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
||
var rsComboMarksRange = "\\u0300-\\u036f\\ufe20-\\ufe23";
|
||
var rsComboSymbolsRange = "\\u20d0-\\u20f0";
|
||
var rsCombo = "[" + rsComboMarksRange + rsComboSymbolsRange + "]";
|
||
var reComboMark = RegExp(rsCombo, "g");
|
||
var deburredLetters = {
|
||
// Latin-1 Supplement block.
|
||
"\xC0": "A",
|
||
"\xC1": "A",
|
||
"\xC2": "A",
|
||
"\xC3": "A",
|
||
"\xC4": "A",
|
||
"\xC5": "A",
|
||
"\xE0": "a",
|
||
"\xE1": "a",
|
||
"\xE2": "a",
|
||
"\xE3": "a",
|
||
"\xE4": "a",
|
||
"\xE5": "a",
|
||
"\xC7": "C",
|
||
"\xE7": "c",
|
||
"\xD0": "D",
|
||
"\xF0": "d",
|
||
"\xC8": "E",
|
||
"\xC9": "E",
|
||
"\xCA": "E",
|
||
"\xCB": "E",
|
||
"\xE8": "e",
|
||
"\xE9": "e",
|
||
"\xEA": "e",
|
||
"\xEB": "e",
|
||
"\xCC": "I",
|
||
"\xCD": "I",
|
||
"\xCE": "I",
|
||
"\xCF": "I",
|
||
"\xEC": "i",
|
||
"\xED": "i",
|
||
"\xEE": "i",
|
||
"\xEF": "i",
|
||
"\xD1": "N",
|
||
"\xF1": "n",
|
||
"\xD2": "O",
|
||
"\xD3": "O",
|
||
"\xD4": "O",
|
||
"\xD5": "O",
|
||
"\xD6": "O",
|
||
"\xD8": "O",
|
||
"\xF2": "o",
|
||
"\xF3": "o",
|
||
"\xF4": "o",
|
||
"\xF5": "o",
|
||
"\xF6": "o",
|
||
"\xF8": "o",
|
||
"\xD9": "U",
|
||
"\xDA": "U",
|
||
"\xDB": "U",
|
||
"\xDC": "U",
|
||
"\xF9": "u",
|
||
"\xFA": "u",
|
||
"\xFB": "u",
|
||
"\xFC": "u",
|
||
"\xDD": "Y",
|
||
"\xFD": "y",
|
||
"\xFF": "y",
|
||
"\xC6": "Ae",
|
||
"\xE6": "ae",
|
||
"\xDE": "Th",
|
||
"\xFE": "th",
|
||
"\xDF": "ss",
|
||
// Latin Extended-A block.
|
||
"\u0100": "A",
|
||
"\u0102": "A",
|
||
"\u0104": "A",
|
||
"\u0101": "a",
|
||
"\u0103": "a",
|
||
"\u0105": "a",
|
||
"\u0106": "C",
|
||
"\u0108": "C",
|
||
"\u010A": "C",
|
||
"\u010C": "C",
|
||
"\u0107": "c",
|
||
"\u0109": "c",
|
||
"\u010B": "c",
|
||
"\u010D": "c",
|
||
"\u010E": "D",
|
||
"\u0110": "D",
|
||
"\u010F": "d",
|
||
"\u0111": "d",
|
||
"\u0112": "E",
|
||
"\u0114": "E",
|
||
"\u0116": "E",
|
||
"\u0118": "E",
|
||
"\u011A": "E",
|
||
"\u0113": "e",
|
||
"\u0115": "e",
|
||
"\u0117": "e",
|
||
"\u0119": "e",
|
||
"\u011B": "e",
|
||
"\u011C": "G",
|
||
"\u011E": "G",
|
||
"\u0120": "G",
|
||
"\u0122": "G",
|
||
"\u011D": "g",
|
||
"\u011F": "g",
|
||
"\u0121": "g",
|
||
"\u0123": "g",
|
||
"\u0124": "H",
|
||
"\u0126": "H",
|
||
"\u0125": "h",
|
||
"\u0127": "h",
|
||
"\u0128": "I",
|
||
"\u012A": "I",
|
||
"\u012C": "I",
|
||
"\u012E": "I",
|
||
"\u0130": "I",
|
||
"\u0129": "i",
|
||
"\u012B": "i",
|
||
"\u012D": "i",
|
||
"\u012F": "i",
|
||
"\u0131": "i",
|
||
"\u0134": "J",
|
||
"\u0135": "j",
|
||
"\u0136": "K",
|
||
"\u0137": "k",
|
||
"\u0138": "k",
|
||
"\u0139": "L",
|
||
"\u013B": "L",
|
||
"\u013D": "L",
|
||
"\u013F": "L",
|
||
"\u0141": "L",
|
||
"\u013A": "l",
|
||
"\u013C": "l",
|
||
"\u013E": "l",
|
||
"\u0140": "l",
|
||
"\u0142": "l",
|
||
"\u0143": "N",
|
||
"\u0145": "N",
|
||
"\u0147": "N",
|
||
"\u014A": "N",
|
||
"\u0144": "n",
|
||
"\u0146": "n",
|
||
"\u0148": "n",
|
||
"\u014B": "n",
|
||
"\u014C": "O",
|
||
"\u014E": "O",
|
||
"\u0150": "O",
|
||
"\u014D": "o",
|
||
"\u014F": "o",
|
||
"\u0151": "o",
|
||
"\u0154": "R",
|
||
"\u0156": "R",
|
||
"\u0158": "R",
|
||
"\u0155": "r",
|
||
"\u0157": "r",
|
||
"\u0159": "r",
|
||
"\u015A": "S",
|
||
"\u015C": "S",
|
||
"\u015E": "S",
|
||
"\u0160": "S",
|
||
"\u015B": "s",
|
||
"\u015D": "s",
|
||
"\u015F": "s",
|
||
"\u0161": "s",
|
||
"\u0162": "T",
|
||
"\u0164": "T",
|
||
"\u0166": "T",
|
||
"\u0163": "t",
|
||
"\u0165": "t",
|
||
"\u0167": "t",
|
||
"\u0168": "U",
|
||
"\u016A": "U",
|
||
"\u016C": "U",
|
||
"\u016E": "U",
|
||
"\u0170": "U",
|
||
"\u0172": "U",
|
||
"\u0169": "u",
|
||
"\u016B": "u",
|
||
"\u016D": "u",
|
||
"\u016F": "u",
|
||
"\u0171": "u",
|
||
"\u0173": "u",
|
||
"\u0174": "W",
|
||
"\u0175": "w",
|
||
"\u0176": "Y",
|
||
"\u0177": "y",
|
||
"\u0178": "Y",
|
||
"\u0179": "Z",
|
||
"\u017B": "Z",
|
||
"\u017D": "Z",
|
||
"\u017A": "z",
|
||
"\u017C": "z",
|
||
"\u017E": "z",
|
||
"\u0132": "IJ",
|
||
"\u0133": "ij",
|
||
"\u0152": "Oe",
|
||
"\u0153": "oe",
|
||
"\u0149": "'n",
|
||
"\u017F": "ss"
|
||
};
|
||
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
||
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
||
var root = freeGlobal || freeSelf || Function("return this")();
|
||
function basePropertyOf(object) {
|
||
return function(key) {
|
||
return object == null ? void 0 : object[key];
|
||
};
|
||
}
|
||
var deburrLetter = basePropertyOf(deburredLetters);
|
||
var objectProto = Object.prototype;
|
||
var objectToString = objectProto.toString;
|
||
var Symbol2 = root.Symbol;
|
||
var symbolProto = Symbol2 ? Symbol2.prototype : void 0;
|
||
var symbolToString = symbolProto ? symbolProto.toString : void 0;
|
||
function baseToString(value) {
|
||
if (typeof value == "string") {
|
||
return value;
|
||
}
|
||
if (isSymbol(value)) {
|
||
return symbolToString ? symbolToString.call(value) : "";
|
||
}
|
||
var result = value + "";
|
||
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
||
}
|
||
function isObjectLike(value) {
|
||
return !!value && typeof value == "object";
|
||
}
|
||
function isSymbol(value) {
|
||
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
||
}
|
||
function toString3(value) {
|
||
return value == null ? "" : baseToString(value);
|
||
}
|
||
function deburr(string) {
|
||
string = toString3(string);
|
||
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
|
||
}
|
||
module2.exports = deburr;
|
||
}
|
||
});
|
||
|
||
// node_modules/@sindresorhus/transliterate/node_modules/escape-string-regexp/index.js
|
||
var require_escape_string_regexp2 = __commonJS({
|
||
"node_modules/@sindresorhus/transliterate/node_modules/escape-string-regexp/index.js"(exports, module2) {
|
||
"use strict";
|
||
var matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
|
||
module2.exports = (string) => {
|
||
if (typeof string !== "string") {
|
||
throw new TypeError("Expected a string");
|
||
}
|
||
return string.replace(matchOperatorsRegex, "\\$&");
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/@sindresorhus/transliterate/replacements.js
|
||
var require_replacements = __commonJS({
|
||
"node_modules/@sindresorhus/transliterate/replacements.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = [
|
||
// German umlauts
|
||
["\xDF", "ss"],
|
||
["\xE4", "ae"],
|
||
["\xC4", "Ae"],
|
||
["\xF6", "oe"],
|
||
["\xD6", "Oe"],
|
||
["\xFC", "ue"],
|
||
["\xDC", "Ue"],
|
||
// Latin
|
||
["\xC0", "A"],
|
||
["\xC1", "A"],
|
||
["\xC2", "A"],
|
||
["\xC3", "A"],
|
||
["\xC4", "Ae"],
|
||
["\xC5", "A"],
|
||
["\xC6", "AE"],
|
||
["\xC7", "C"],
|
||
["\xC8", "E"],
|
||
["\xC9", "E"],
|
||
["\xCA", "E"],
|
||
["\xCB", "E"],
|
||
["\xCC", "I"],
|
||
["\xCD", "I"],
|
||
["\xCE", "I"],
|
||
["\xCF", "I"],
|
||
["\xD0", "D"],
|
||
["\xD1", "N"],
|
||
["\xD2", "O"],
|
||
["\xD3", "O"],
|
||
["\xD4", "O"],
|
||
["\xD5", "O"],
|
||
["\xD6", "Oe"],
|
||
["\u0150", "O"],
|
||
["\xD8", "O"],
|
||
["\xD9", "U"],
|
||
["\xDA", "U"],
|
||
["\xDB", "U"],
|
||
["\xDC", "Ue"],
|
||
["\u0170", "U"],
|
||
["\xDD", "Y"],
|
||
["\xDE", "TH"],
|
||
["\xDF", "ss"],
|
||
["\xE0", "a"],
|
||
["\xE1", "a"],
|
||
["\xE2", "a"],
|
||
["\xE3", "a"],
|
||
["\xE4", "ae"],
|
||
["\xE5", "a"],
|
||
["\xE6", "ae"],
|
||
["\xE7", "c"],
|
||
["\xE8", "e"],
|
||
["\xE9", "e"],
|
||
["\xEA", "e"],
|
||
["\xEB", "e"],
|
||
["\xEC", "i"],
|
||
["\xED", "i"],
|
||
["\xEE", "i"],
|
||
["\xEF", "i"],
|
||
["\xF0", "d"],
|
||
["\xF1", "n"],
|
||
["\xF2", "o"],
|
||
["\xF3", "o"],
|
||
["\xF4", "o"],
|
||
["\xF5", "o"],
|
||
["\xF6", "oe"],
|
||
["\u0151", "o"],
|
||
["\xF8", "o"],
|
||
["\xF9", "u"],
|
||
["\xFA", "u"],
|
||
["\xFB", "u"],
|
||
["\xFC", "ue"],
|
||
["\u0171", "u"],
|
||
["\xFD", "y"],
|
||
["\xFE", "th"],
|
||
["\xFF", "y"],
|
||
["\u1E9E", "SS"],
|
||
// Vietnamese
|
||
["\xE0", "a"],
|
||
["\xC0", "A"],
|
||
["\xE1", "a"],
|
||
["\xC1", "A"],
|
||
["\xE2", "a"],
|
||
["\xC2", "A"],
|
||
["\xE3", "a"],
|
||
["\xC3", "A"],
|
||
["\xE8", "e"],
|
||
["\xC8", "E"],
|
||
["\xE9", "e"],
|
||
["\xC9", "E"],
|
||
["\xEA", "e"],
|
||
["\xCA", "E"],
|
||
["\xEC", "i"],
|
||
["\xCC", "I"],
|
||
["\xED", "i"],
|
||
["\xCD", "I"],
|
||
["\xF2", "o"],
|
||
["\xD2", "O"],
|
||
["\xF3", "o"],
|
||
["\xD3", "O"],
|
||
["\xF4", "o"],
|
||
["\xD4", "O"],
|
||
["\xF5", "o"],
|
||
["\xD5", "O"],
|
||
["\xF9", "u"],
|
||
["\xD9", "U"],
|
||
["\xFA", "u"],
|
||
["\xDA", "U"],
|
||
["\xFD", "y"],
|
||
["\xDD", "Y"],
|
||
["\u0103", "a"],
|
||
["\u0102", "A"],
|
||
["\u0110", "D"],
|
||
["\u0111", "d"],
|
||
["\u0129", "i"],
|
||
["\u0128", "I"],
|
||
["\u0169", "u"],
|
||
["\u0168", "U"],
|
||
["\u01A1", "o"],
|
||
["\u01A0", "O"],
|
||
["\u01B0", "u"],
|
||
["\u01AF", "U"],
|
||
["\u1EA1", "a"],
|
||
["\u1EA0", "A"],
|
||
["\u1EA3", "a"],
|
||
["\u1EA2", "A"],
|
||
["\u1EA5", "a"],
|
||
["\u1EA4", "A"],
|
||
["\u1EA7", "a"],
|
||
["\u1EA6", "A"],
|
||
["\u1EA9", "a"],
|
||
["\u1EA8", "A"],
|
||
["\u1EAB", "a"],
|
||
["\u1EAA", "A"],
|
||
["\u1EAD", "a"],
|
||
["\u1EAC", "A"],
|
||
["\u1EAF", "a"],
|
||
["\u1EAE", "A"],
|
||
["\u1EB1", "a"],
|
||
["\u1EB0", "A"],
|
||
["\u1EB3", "a"],
|
||
["\u1EB2", "A"],
|
||
["\u1EB5", "a"],
|
||
["\u1EB4", "A"],
|
||
["\u1EB7", "a"],
|
||
["\u1EB6", "A"],
|
||
["\u1EB9", "e"],
|
||
["\u1EB8", "E"],
|
||
["\u1EBB", "e"],
|
||
["\u1EBA", "E"],
|
||
["\u1EBD", "e"],
|
||
["\u1EBC", "E"],
|
||
["\u1EBF", "e"],
|
||
["\u1EBE", "E"],
|
||
["\u1EC1", "e"],
|
||
["\u1EC0", "E"],
|
||
["\u1EC3", "e"],
|
||
["\u1EC2", "E"],
|
||
["\u1EC5", "e"],
|
||
["\u1EC4", "E"],
|
||
["\u1EC7", "e"],
|
||
["\u1EC6", "E"],
|
||
["\u1EC9", "i"],
|
||
["\u1EC8", "I"],
|
||
["\u1ECB", "i"],
|
||
["\u1ECA", "I"],
|
||
["\u1ECD", "o"],
|
||
["\u1ECC", "O"],
|
||
["\u1ECF", "o"],
|
||
["\u1ECE", "O"],
|
||
["\u1ED1", "o"],
|
||
["\u1ED0", "O"],
|
||
["\u1ED3", "o"],
|
||
["\u1ED2", "O"],
|
||
["\u1ED5", "o"],
|
||
["\u1ED4", "O"],
|
||
["\u1ED7", "o"],
|
||
["\u1ED6", "O"],
|
||
["\u1ED9", "o"],
|
||
["\u1ED8", "O"],
|
||
["\u1EDB", "o"],
|
||
["\u1EDA", "O"],
|
||
["\u1EDD", "o"],
|
||
["\u1EDC", "O"],
|
||
["\u1EDF", "o"],
|
||
["\u1EDE", "O"],
|
||
["\u1EE1", "o"],
|
||
["\u1EE0", "O"],
|
||
["\u1EE3", "o"],
|
||
["\u1EE2", "O"],
|
||
["\u1EE5", "u"],
|
||
["\u1EE4", "U"],
|
||
["\u1EE7", "u"],
|
||
["\u1EE6", "U"],
|
||
["\u1EE9", "u"],
|
||
["\u1EE8", "U"],
|
||
["\u1EEB", "u"],
|
||
["\u1EEA", "U"],
|
||
["\u1EED", "u"],
|
||
["\u1EEC", "U"],
|
||
["\u1EEF", "u"],
|
||
["\u1EEE", "U"],
|
||
["\u1EF1", "u"],
|
||
["\u1EF0", "U"],
|
||
["\u1EF3", "y"],
|
||
["\u1EF2", "Y"],
|
||
["\u1EF5", "y"],
|
||
["\u1EF4", "Y"],
|
||
["\u1EF7", "y"],
|
||
["\u1EF6", "Y"],
|
||
["\u1EF9", "y"],
|
||
["\u1EF8", "Y"],
|
||
// Arabic
|
||
["\u0621", "e"],
|
||
["\u0622", "a"],
|
||
["\u0623", "a"],
|
||
["\u0624", "w"],
|
||
["\u0625", "i"],
|
||
["\u0626", "y"],
|
||
["\u0627", "a"],
|
||
["\u0628", "b"],
|
||
["\u0629", "t"],
|
||
["\u062A", "t"],
|
||
["\u062B", "th"],
|
||
["\u062C", "j"],
|
||
["\u062D", "h"],
|
||
["\u062E", "kh"],
|
||
["\u062F", "d"],
|
||
["\u0630", "dh"],
|
||
["\u0631", "r"],
|
||
["\u0632", "z"],
|
||
["\u0633", "s"],
|
||
["\u0634", "sh"],
|
||
["\u0635", "s"],
|
||
["\u0636", "d"],
|
||
["\u0637", "t"],
|
||
["\u0638", "z"],
|
||
["\u0639", "e"],
|
||
["\u063A", "gh"],
|
||
["\u0640", "_"],
|
||
["\u0641", "f"],
|
||
["\u0642", "q"],
|
||
["\u0643", "k"],
|
||
["\u0644", "l"],
|
||
["\u0645", "m"],
|
||
["\u0646", "n"],
|
||
["\u0647", "h"],
|
||
["\u0648", "w"],
|
||
["\u0649", "a"],
|
||
["\u064A", "y"],
|
||
["\u064E\u200E", "a"],
|
||
["\u064F", "u"],
|
||
["\u0650\u200E", "i"],
|
||
["\u0660", "0"],
|
||
["\u0661", "1"],
|
||
["\u0662", "2"],
|
||
["\u0663", "3"],
|
||
["\u0664", "4"],
|
||
["\u0665", "5"],
|
||
["\u0666", "6"],
|
||
["\u0667", "7"],
|
||
["\u0668", "8"],
|
||
["\u0669", "9"],
|
||
// Persian / Farsi
|
||
["\u0686", "ch"],
|
||
["\u06A9", "k"],
|
||
["\u06AF", "g"],
|
||
["\u067E", "p"],
|
||
["\u0698", "zh"],
|
||
["\u06CC", "y"],
|
||
["\u06F0", "0"],
|
||
["\u06F1", "1"],
|
||
["\u06F2", "2"],
|
||
["\u06F3", "3"],
|
||
["\u06F4", "4"],
|
||
["\u06F5", "5"],
|
||
["\u06F6", "6"],
|
||
["\u06F7", "7"],
|
||
["\u06F8", "8"],
|
||
["\u06F9", "9"],
|
||
// Pashto
|
||
["\u067C", "p"],
|
||
["\u0681", "z"],
|
||
["\u0685", "c"],
|
||
["\u0689", "d"],
|
||
["\uFEAB", "d"],
|
||
["\uFEAD", "r"],
|
||
["\u0693", "r"],
|
||
["\uFEAF", "z"],
|
||
["\u0696", "g"],
|
||
["\u069A", "x"],
|
||
["\u06AB", "g"],
|
||
["\u06BC", "n"],
|
||
["\u06C0", "e"],
|
||
["\u06D0", "e"],
|
||
["\u06CD", "ai"],
|
||
// Urdu
|
||
["\u0679", "t"],
|
||
["\u0688", "d"],
|
||
["\u0691", "r"],
|
||
["\u06BA", "n"],
|
||
["\u06C1", "h"],
|
||
["\u06BE", "h"],
|
||
["\u06D2", "e"],
|
||
// Russian
|
||
["\u0410", "A"],
|
||
["\u0430", "a"],
|
||
["\u0411", "B"],
|
||
["\u0431", "b"],
|
||
["\u0412", "V"],
|
||
["\u0432", "v"],
|
||
["\u0413", "G"],
|
||
["\u0433", "g"],
|
||
["\u0414", "D"],
|
||
["\u0434", "d"],
|
||
["\u0415", "E"],
|
||
["\u0435", "e"],
|
||
["\u0416", "Zh"],
|
||
["\u0436", "zh"],
|
||
["\u0417", "Z"],
|
||
["\u0437", "z"],
|
||
["\u0418", "I"],
|
||
["\u0438", "i"],
|
||
["\u0419", "J"],
|
||
["\u0439", "j"],
|
||
["\u041A", "K"],
|
||
["\u043A", "k"],
|
||
["\u041B", "L"],
|
||
["\u043B", "l"],
|
||
["\u041C", "M"],
|
||
["\u043C", "m"],
|
||
["\u041D", "N"],
|
||
["\u043D", "n"],
|
||
["\u041E", "O"],
|
||
["\u043E", "o"],
|
||
["\u041F", "P"],
|
||
["\u043F", "p"],
|
||
["\u0420", "R"],
|
||
["\u0440", "r"],
|
||
["\u0421", "S"],
|
||
["\u0441", "s"],
|
||
["\u0422", "T"],
|
||
["\u0442", "t"],
|
||
["\u0423", "U"],
|
||
["\u0443", "u"],
|
||
["\u0424", "F"],
|
||
["\u0444", "f"],
|
||
["\u0425", "H"],
|
||
["\u0445", "h"],
|
||
["\u0426", "Cz"],
|
||
["\u0446", "cz"],
|
||
["\u0427", "Ch"],
|
||
["\u0447", "ch"],
|
||
["\u0428", "Sh"],
|
||
["\u0448", "sh"],
|
||
["\u0429", "Shh"],
|
||
["\u0449", "shh"],
|
||
["\u042A", ""],
|
||
["\u044A", ""],
|
||
["\u042B", "Y"],
|
||
["\u044B", "y"],
|
||
["\u042C", ""],
|
||
["\u044C", ""],
|
||
["\u042D", "E"],
|
||
["\u044D", "e"],
|
||
["\u042E", "Yu"],
|
||
["\u044E", "yu"],
|
||
["\u042F", "Ya"],
|
||
["\u044F", "ya"],
|
||
["\u0401", "Yo"],
|
||
["\u0451", "yo"],
|
||
// Romanian
|
||
["\u0103", "a"],
|
||
["\u0102", "A"],
|
||
["\u0219", "s"],
|
||
["\u0218", "S"],
|
||
["\u021B", "t"],
|
||
["\u021A", "T"],
|
||
["\u0163", "t"],
|
||
["\u0162", "T"],
|
||
// Turkish
|
||
["\u015F", "s"],
|
||
["\u015E", "S"],
|
||
["\xE7", "c"],
|
||
["\xC7", "C"],
|
||
["\u011F", "g"],
|
||
["\u011E", "G"],
|
||
["\u0131", "i"],
|
||
["\u0130", "I"],
|
||
// Armenian
|
||
["\u0561", "a"],
|
||
["\u0531", "A"],
|
||
["\u0562", "b"],
|
||
["\u0532", "B"],
|
||
["\u0563", "g"],
|
||
["\u0533", "G"],
|
||
["\u0564", "d"],
|
||
["\u0534", "D"],
|
||
["\u0565", "ye"],
|
||
["\u0535", "Ye"],
|
||
["\u0566", "z"],
|
||
["\u0536", "Z"],
|
||
["\u0567", "e"],
|
||
["\u0537", "E"],
|
||
["\u0568", "y"],
|
||
["\u0538", "Y"],
|
||
["\u0569", "t"],
|
||
["\u0539", "T"],
|
||
["\u056A", "zh"],
|
||
["\u053A", "Zh"],
|
||
["\u056B", "i"],
|
||
["\u053B", "I"],
|
||
["\u056C", "l"],
|
||
["\u053C", "L"],
|
||
["\u056D", "kh"],
|
||
["\u053D", "Kh"],
|
||
["\u056E", "ts"],
|
||
["\u053E", "Ts"],
|
||
["\u056F", "k"],
|
||
["\u053F", "K"],
|
||
["\u0570", "h"],
|
||
["\u0540", "H"],
|
||
["\u0571", "dz"],
|
||
["\u0541", "Dz"],
|
||
["\u0572", "gh"],
|
||
["\u0542", "Gh"],
|
||
["\u0573", "tch"],
|
||
["\u0543", "Tch"],
|
||
["\u0574", "m"],
|
||
["\u0544", "M"],
|
||
["\u0575", "y"],
|
||
["\u0545", "Y"],
|
||
["\u0576", "n"],
|
||
["\u0546", "N"],
|
||
["\u0577", "sh"],
|
||
["\u0547", "Sh"],
|
||
["\u0578", "vo"],
|
||
["\u0548", "Vo"],
|
||
["\u0579", "ch"],
|
||
["\u0549", "Ch"],
|
||
["\u057A", "p"],
|
||
["\u054A", "P"],
|
||
["\u057B", "j"],
|
||
["\u054B", "J"],
|
||
["\u057C", "r"],
|
||
["\u054C", "R"],
|
||
["\u057D", "s"],
|
||
["\u054D", "S"],
|
||
["\u057E", "v"],
|
||
["\u054E", "V"],
|
||
["\u057F", "t"],
|
||
["\u054F", "T"],
|
||
["\u0580", "r"],
|
||
["\u0550", "R"],
|
||
["\u0581", "c"],
|
||
["\u0551", "C"],
|
||
["\u0578\u0582", "u"],
|
||
["\u0548\u0552", "U"],
|
||
["\u0548\u0582", "U"],
|
||
["\u0583", "p"],
|
||
["\u0553", "P"],
|
||
["\u0584", "q"],
|
||
["\u0554", "Q"],
|
||
["\u0585", "o"],
|
||
["\u0555", "O"],
|
||
["\u0586", "f"],
|
||
["\u0556", "F"],
|
||
["\u0587", "yev"],
|
||
// Georgian
|
||
["\u10D0", "a"],
|
||
["\u10D1", "b"],
|
||
["\u10D2", "g"],
|
||
["\u10D3", "d"],
|
||
["\u10D4", "e"],
|
||
["\u10D5", "v"],
|
||
["\u10D6", "z"],
|
||
["\u10D7", "t"],
|
||
["\u10D8", "i"],
|
||
["\u10D9", "k"],
|
||
["\u10DA", "l"],
|
||
["\u10DB", "m"],
|
||
["\u10DC", "n"],
|
||
["\u10DD", "o"],
|
||
["\u10DE", "p"],
|
||
["\u10DF", "zh"],
|
||
["\u10E0", "r"],
|
||
["\u10E1", "s"],
|
||
["\u10E2", "t"],
|
||
["\u10E3", "u"],
|
||
["\u10E4", "ph"],
|
||
["\u10E5", "q"],
|
||
["\u10E6", "gh"],
|
||
["\u10E7", "k"],
|
||
["\u10E8", "sh"],
|
||
["\u10E9", "ch"],
|
||
["\u10EA", "ts"],
|
||
["\u10EB", "dz"],
|
||
["\u10EC", "ts"],
|
||
["\u10ED", "tch"],
|
||
["\u10EE", "kh"],
|
||
["\u10EF", "j"],
|
||
["\u10F0", "h"],
|
||
// Czech
|
||
["\u010D", "c"],
|
||
["\u010F", "d"],
|
||
["\u011B", "e"],
|
||
["\u0148", "n"],
|
||
["\u0159", "r"],
|
||
["\u0161", "s"],
|
||
["\u0165", "t"],
|
||
["\u016F", "u"],
|
||
["\u017E", "z"],
|
||
["\u010C", "C"],
|
||
["\u010E", "D"],
|
||
["\u011A", "E"],
|
||
["\u0147", "N"],
|
||
["\u0158", "R"],
|
||
["\u0160", "S"],
|
||
["\u0164", "T"],
|
||
["\u016E", "U"],
|
||
["\u017D", "Z"],
|
||
// Dhivehi
|
||
["\u0780", "h"],
|
||
["\u0781", "sh"],
|
||
["\u0782", "n"],
|
||
["\u0783", "r"],
|
||
["\u0784", "b"],
|
||
["\u0785", "lh"],
|
||
["\u0786", "k"],
|
||
["\u0787", "a"],
|
||
["\u0788", "v"],
|
||
["\u0789", "m"],
|
||
["\u078A", "f"],
|
||
["\u078B", "dh"],
|
||
["\u078C", "th"],
|
||
["\u078D", "l"],
|
||
["\u078E", "g"],
|
||
["\u078F", "gn"],
|
||
["\u0790", "s"],
|
||
["\u0791", "d"],
|
||
["\u0792", "z"],
|
||
["\u0793", "t"],
|
||
["\u0794", "y"],
|
||
["\u0795", "p"],
|
||
["\u0796", "j"],
|
||
["\u0797", "ch"],
|
||
["\u0798", "tt"],
|
||
["\u0799", "hh"],
|
||
["\u079A", "kh"],
|
||
["\u079B", "th"],
|
||
["\u079C", "z"],
|
||
["\u079D", "sh"],
|
||
["\u079E", "s"],
|
||
["\u079F", "d"],
|
||
["\u07A0", "t"],
|
||
["\u07A1", "z"],
|
||
["\u07A2", "a"],
|
||
["\u07A3", "gh"],
|
||
["\u07A4", "q"],
|
||
["\u07A5", "w"],
|
||
["\u07A6", "a"],
|
||
["\u07A7", "aa"],
|
||
["\u07A8", "i"],
|
||
["\u07A9", "ee"],
|
||
["\u07AA", "u"],
|
||
["\u07AB", "oo"],
|
||
["\u07AC", "e"],
|
||
["\u07AD", "ey"],
|
||
["\u07AE", "o"],
|
||
["\u07AF", "oa"],
|
||
["\u07B0", ""],
|
||
// Greek
|
||
["\u03B1", "a"],
|
||
["\u03B2", "v"],
|
||
["\u03B3", "g"],
|
||
["\u03B4", "d"],
|
||
["\u03B5", "e"],
|
||
["\u03B6", "z"],
|
||
["\u03B7", "i"],
|
||
["\u03B8", "th"],
|
||
["\u03B9", "i"],
|
||
["\u03BA", "k"],
|
||
["\u03BB", "l"],
|
||
["\u03BC", "m"],
|
||
["\u03BD", "n"],
|
||
["\u03BE", "ks"],
|
||
["\u03BF", "o"],
|
||
["\u03C0", "p"],
|
||
["\u03C1", "r"],
|
||
["\u03C3", "s"],
|
||
["\u03C4", "t"],
|
||
["\u03C5", "y"],
|
||
["\u03C6", "f"],
|
||
["\u03C7", "x"],
|
||
["\u03C8", "ps"],
|
||
["\u03C9", "o"],
|
||
["\u03AC", "a"],
|
||
["\u03AD", "e"],
|
||
["\u03AF", "i"],
|
||
["\u03CC", "o"],
|
||
["\u03CD", "y"],
|
||
["\u03AE", "i"],
|
||
["\u03CE", "o"],
|
||
["\u03C2", "s"],
|
||
["\u03CA", "i"],
|
||
["\u03B0", "y"],
|
||
["\u03CB", "y"],
|
||
["\u0390", "i"],
|
||
["\u0391", "A"],
|
||
["\u0392", "B"],
|
||
["\u0393", "G"],
|
||
["\u0394", "D"],
|
||
["\u0395", "E"],
|
||
["\u0396", "Z"],
|
||
["\u0397", "I"],
|
||
["\u0398", "TH"],
|
||
["\u0399", "I"],
|
||
["\u039A", "K"],
|
||
["\u039B", "L"],
|
||
["\u039C", "M"],
|
||
["\u039D", "N"],
|
||
["\u039E", "KS"],
|
||
["\u039F", "O"],
|
||
["\u03A0", "P"],
|
||
["\u03A1", "R"],
|
||
["\u03A3", "S"],
|
||
["\u03A4", "T"],
|
||
["\u03A5", "Y"],
|
||
["\u03A6", "F"],
|
||
["\u03A7", "X"],
|
||
["\u03A8", "PS"],
|
||
["\u03A9", "O"],
|
||
["\u0386", "A"],
|
||
["\u0388", "E"],
|
||
["\u038A", "I"],
|
||
["\u038C", "O"],
|
||
["\u038E", "Y"],
|
||
["\u0389", "I"],
|
||
["\u038F", "O"],
|
||
["\u03AA", "I"],
|
||
["\u03AB", "Y"],
|
||
// Disabled as it conflicts with German and Latin.
|
||
// Hungarian
|
||
// ['ä', 'a'],
|
||
// ['Ä', 'A'],
|
||
// ['ö', 'o'],
|
||
// ['Ö', 'O'],
|
||
// ['ü', 'u'],
|
||
// ['Ü', 'U'],
|
||
// ['ű', 'u'],
|
||
// ['Ű', 'U'],
|
||
// Latvian
|
||
["\u0101", "a"],
|
||
["\u0113", "e"],
|
||
["\u0123", "g"],
|
||
["\u012B", "i"],
|
||
["\u0137", "k"],
|
||
["\u013C", "l"],
|
||
["\u0146", "n"],
|
||
["\u016B", "u"],
|
||
["\u0100", "A"],
|
||
["\u0112", "E"],
|
||
["\u0122", "G"],
|
||
["\u012A", "I"],
|
||
["\u0136", "K"],
|
||
["\u013B", "L"],
|
||
["\u0145", "N"],
|
||
["\u016A", "U"],
|
||
["\u010D", "c"],
|
||
["\u0161", "s"],
|
||
["\u017E", "z"],
|
||
["\u010C", "C"],
|
||
["\u0160", "S"],
|
||
["\u017D", "Z"],
|
||
// Lithuanian
|
||
["\u0105", "a"],
|
||
["\u010D", "c"],
|
||
["\u0119", "e"],
|
||
["\u0117", "e"],
|
||
["\u012F", "i"],
|
||
["\u0161", "s"],
|
||
["\u0173", "u"],
|
||
["\u016B", "u"],
|
||
["\u017E", "z"],
|
||
["\u0104", "A"],
|
||
["\u010C", "C"],
|
||
["\u0118", "E"],
|
||
["\u0116", "E"],
|
||
["\u012E", "I"],
|
||
["\u0160", "S"],
|
||
["\u0172", "U"],
|
||
["\u016A", "U"],
|
||
// Macedonian
|
||
["\u040C", "Kj"],
|
||
["\u045C", "kj"],
|
||
["\u0409", "Lj"],
|
||
["\u0459", "lj"],
|
||
["\u040A", "Nj"],
|
||
["\u045A", "nj"],
|
||
["\u0422\u0441", "Ts"],
|
||
["\u0442\u0441", "ts"],
|
||
// Polish
|
||
["\u0105", "a"],
|
||
["\u0107", "c"],
|
||
["\u0119", "e"],
|
||
["\u0142", "l"],
|
||
["\u0144", "n"],
|
||
["\u015B", "s"],
|
||
["\u017A", "z"],
|
||
["\u017C", "z"],
|
||
["\u0104", "A"],
|
||
["\u0106", "C"],
|
||
["\u0118", "E"],
|
||
["\u0141", "L"],
|
||
["\u0143", "N"],
|
||
["\u015A", "S"],
|
||
["\u0179", "Z"],
|
||
["\u017B", "Z"],
|
||
// Disabled as it conflicts with Vietnamese.
|
||
// Serbian
|
||
// ['љ', 'lj'],
|
||
// ['њ', 'nj'],
|
||
// ['Љ', 'Lj'],
|
||
// ['Њ', 'Nj'],
|
||
// ['đ', 'dj'],
|
||
// ['Đ', 'Dj'],
|
||
// ['ђ', 'dj'],
|
||
// ['ј', 'j'],
|
||
// ['ћ', 'c'],
|
||
// ['џ', 'dz'],
|
||
// ['Ђ', 'Dj'],
|
||
// ['Ј', 'j'],
|
||
// ['Ћ', 'C'],
|
||
// ['Џ', 'Dz'],
|
||
// Disabled as it conflicts with German and Latin.
|
||
// Slovak
|
||
// ['ä', 'a'],
|
||
// ['Ä', 'A'],
|
||
// ['ľ', 'l'],
|
||
// ['ĺ', 'l'],
|
||
// ['ŕ', 'r'],
|
||
// ['Ľ', 'L'],
|
||
// ['Ĺ', 'L'],
|
||
// ['Ŕ', 'R'],
|
||
// Disabled as it conflicts with German and Latin.
|
||
// Swedish
|
||
// ['å', 'o'],
|
||
// ['Å', 'o'],
|
||
// ['ä', 'a'],
|
||
// ['Ä', 'A'],
|
||
// ['ë', 'e'],
|
||
// ['Ë', 'E'],
|
||
// ['ö', 'o'],
|
||
// ['Ö', 'O'],
|
||
// Ukrainian
|
||
["\u0404", "Ye"],
|
||
["\u0406", "I"],
|
||
["\u0407", "Yi"],
|
||
["\u0490", "G"],
|
||
["\u0454", "ye"],
|
||
["\u0456", "i"],
|
||
["\u0457", "yi"],
|
||
["\u0491", "g"]
|
||
// Danish
|
||
// ['Æ', 'Ae'],
|
||
// ['Ø', 'Oe'],
|
||
// ['Å', 'Aa'],
|
||
// ['æ', 'ae'],
|
||
// ['ø', 'oe'],
|
||
// ['å', 'aa']
|
||
];
|
||
}
|
||
});
|
||
|
||
// node_modules/@sindresorhus/transliterate/index.js
|
||
var require_transliterate = __commonJS({
|
||
"node_modules/@sindresorhus/transliterate/index.js"(exports, module2) {
|
||
"use strict";
|
||
var deburr = require_lodash();
|
||
var escapeStringRegexp = require_escape_string_regexp2();
|
||
var builtinReplacements = require_replacements();
|
||
var doCustomReplacements = (string, replacements) => {
|
||
for (const [key, value] of replacements) {
|
||
string = string.replace(new RegExp(escapeStringRegexp(key), "g"), value);
|
||
}
|
||
return string;
|
||
};
|
||
module2.exports = (string, options) => {
|
||
if (typeof string !== "string") {
|
||
throw new TypeError(`Expected a string, got \`${typeof string}\``);
|
||
}
|
||
options = __spreadValues({
|
||
customReplacements: []
|
||
}, options);
|
||
const customReplacements = new Map([
|
||
...builtinReplacements,
|
||
...options.customReplacements
|
||
]);
|
||
string = string.normalize();
|
||
string = doCustomReplacements(string, customReplacements);
|
||
string = deburr(string);
|
||
return string;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/@sindresorhus/slugify/overridable-replacements.js
|
||
var require_overridable_replacements = __commonJS({
|
||
"node_modules/@sindresorhus/slugify/overridable-replacements.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = [
|
||
["&", " and "],
|
||
["\u{1F984}", " unicorn "],
|
||
["\u2665", " love "]
|
||
];
|
||
}
|
||
});
|
||
|
||
// node_modules/@sindresorhus/slugify/index.js
|
||
var require_slugify = __commonJS({
|
||
"node_modules/@sindresorhus/slugify/index.js"(exports, module2) {
|
||
"use strict";
|
||
var escapeStringRegexp = require_escape_string_regexp();
|
||
var transliterate = require_transliterate();
|
||
var builtinOverridableReplacements = require_overridable_replacements();
|
||
var decamelize = (string) => {
|
||
return string.replace(/([A-Z]{2,})(\d+)/g, "$1 $2").replace(/([a-z\d]+)([A-Z]{2,})/g, "$1 $2").replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1 $2");
|
||
};
|
||
var removeMootSeparators = (string, separator) => {
|
||
const escapedSeparator = escapeStringRegexp(separator);
|
||
return string.replace(new RegExp(`${escapedSeparator}{2,}`, "g"), separator).replace(new RegExp(`^${escapedSeparator}|${escapedSeparator}$`, "g"), "");
|
||
};
|
||
var slugify3 = (string, options) => {
|
||
if (typeof string !== "string") {
|
||
throw new TypeError(`Expected a string, got \`${typeof string}\``);
|
||
}
|
||
options = __spreadValues({
|
||
separator: "-",
|
||
lowercase: true,
|
||
decamelize: true,
|
||
customReplacements: [],
|
||
preserveLeadingUnderscore: false
|
||
}, options);
|
||
const shouldPrependUnderscore = options.preserveLeadingUnderscore && string.startsWith("_");
|
||
const customReplacements = new Map([
|
||
...builtinOverridableReplacements,
|
||
...options.customReplacements
|
||
]);
|
||
string = transliterate(string, { customReplacements });
|
||
if (options.decamelize) {
|
||
string = decamelize(string);
|
||
}
|
||
let patternSlug = /[^a-zA-Z\d]+/g;
|
||
if (options.lowercase) {
|
||
string = string.toLowerCase();
|
||
patternSlug = /[^a-z\d]+/g;
|
||
}
|
||
string = string.replace(patternSlug, options.separator);
|
||
string = string.replace(/\\/g, "");
|
||
if (options.separator) {
|
||
string = removeMootSeparators(string, options.separator);
|
||
}
|
||
if (shouldPrependUnderscore) {
|
||
string = `_${string}`;
|
||
}
|
||
return string;
|
||
};
|
||
var counter = () => {
|
||
const occurrences = /* @__PURE__ */ new Map();
|
||
const countable = (string, options) => {
|
||
string = slugify3(string, options);
|
||
if (!string) {
|
||
return "";
|
||
}
|
||
const stringLower = string.toLowerCase();
|
||
const numberless = occurrences.get(stringLower.replace(/(?:-\d+?)+?$/, "")) || 0;
|
||
const counter2 = occurrences.get(stringLower);
|
||
occurrences.set(stringLower, typeof counter2 === "number" ? counter2 + 1 : 1);
|
||
const newCounter = occurrences.get(stringLower) || 2;
|
||
if (newCounter >= 2 || numberless > 2) {
|
||
string = `${string}-${newCounter}`;
|
||
}
|
||
return string;
|
||
};
|
||
countable.reset = () => {
|
||
occurrences.clear();
|
||
};
|
||
return countable;
|
||
};
|
||
module2.exports = slugify3;
|
||
module2.exports.counter = counter;
|
||
}
|
||
});
|
||
|
||
// node_modules/crypto-js/core.js
|
||
var require_core = __commonJS({
|
||
"node_modules/crypto-js/core.js"(exports, module2) {
|
||
(function(root, factory) {
|
||
if (typeof exports === "object") {
|
||
module2.exports = exports = factory();
|
||
} else if (typeof define === "function" && define.amd) {
|
||
define([], factory);
|
||
} else {
|
||
root.CryptoJS = factory();
|
||
}
|
||
})(exports, function() {
|
||
var CryptoJS = CryptoJS || function(Math2, undefined2) {
|
||
var crypto2;
|
||
if (typeof window !== "undefined" && window.crypto) {
|
||
crypto2 = window.crypto;
|
||
}
|
||
if (typeof self !== "undefined" && self.crypto) {
|
||
crypto2 = self.crypto;
|
||
}
|
||
if (typeof globalThis !== "undefined" && globalThis.crypto) {
|
||
crypto2 = globalThis.crypto;
|
||
}
|
||
if (!crypto2 && typeof window !== "undefined" && window.msCrypto) {
|
||
crypto2 = window.msCrypto;
|
||
}
|
||
if (!crypto2 && typeof global !== "undefined" && global.crypto) {
|
||
crypto2 = global.crypto;
|
||
}
|
||
if (!crypto2 && typeof require === "function") {
|
||
try {
|
||
crypto2 = require("crypto");
|
||
} catch (err) {
|
||
}
|
||
}
|
||
var cryptoSecureRandomInt = function() {
|
||
if (crypto2) {
|
||
if (typeof crypto2.getRandomValues === "function") {
|
||
try {
|
||
return crypto2.getRandomValues(new Uint32Array(1))[0];
|
||
} catch (err) {
|
||
}
|
||
}
|
||
if (typeof crypto2.randomBytes === "function") {
|
||
try {
|
||
return crypto2.randomBytes(4).readInt32LE();
|
||
} catch (err) {
|
||
}
|
||
}
|
||
}
|
||
throw new Error("Native crypto module could not be used to get secure random number.");
|
||
};
|
||
var create = Object.create || function() {
|
||
function F() {
|
||
}
|
||
return function(obj) {
|
||
var subtype;
|
||
F.prototype = obj;
|
||
subtype = new F();
|
||
F.prototype = null;
|
||
return subtype;
|
||
};
|
||
}();
|
||
var C = {};
|
||
var C_lib = C.lib = {};
|
||
var Base = C_lib.Base = function() {
|
||
return {
|
||
/**
|
||
* Creates a new object that inherits from this object.
|
||
*
|
||
* @param {Object} overrides Properties to copy into the new object.
|
||
*
|
||
* @return {Object} The new object.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var MyType = CryptoJS.lib.Base.extend({
|
||
* field: 'value',
|
||
*
|
||
* method: function () {
|
||
* }
|
||
* });
|
||
*/
|
||
extend: function(overrides) {
|
||
var subtype = create(this);
|
||
if (overrides) {
|
||
subtype.mixIn(overrides);
|
||
}
|
||
if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
|
||
subtype.init = function() {
|
||
subtype.$super.init.apply(this, arguments);
|
||
};
|
||
}
|
||
subtype.init.prototype = subtype;
|
||
subtype.$super = this;
|
||
return subtype;
|
||
},
|
||
/**
|
||
* Extends this object and runs the init method.
|
||
* Arguments to create() will be passed to init().
|
||
*
|
||
* @return {Object} The new object.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var instance = MyType.create();
|
||
*/
|
||
create: function() {
|
||
var instance5 = this.extend();
|
||
instance5.init.apply(instance5, arguments);
|
||
return instance5;
|
||
},
|
||
/**
|
||
* Initializes a newly created object.
|
||
* Override this method to add some logic when your objects are created.
|
||
*
|
||
* @example
|
||
*
|
||
* var MyType = CryptoJS.lib.Base.extend({
|
||
* init: function () {
|
||
* // ...
|
||
* }
|
||
* });
|
||
*/
|
||
init: function() {
|
||
},
|
||
/**
|
||
* Copies properties into this object.
|
||
*
|
||
* @param {Object} properties The properties to mix in.
|
||
*
|
||
* @example
|
||
*
|
||
* MyType.mixIn({
|
||
* field: 'value'
|
||
* });
|
||
*/
|
||
mixIn: function(properties) {
|
||
for (var propertyName in properties) {
|
||
if (properties.hasOwnProperty(propertyName)) {
|
||
this[propertyName] = properties[propertyName];
|
||
}
|
||
}
|
||
if (properties.hasOwnProperty("toString")) {
|
||
this.toString = properties.toString;
|
||
}
|
||
},
|
||
/**
|
||
* Creates a copy of this object.
|
||
*
|
||
* @return {Object} The clone.
|
||
*
|
||
* @example
|
||
*
|
||
* var clone = instance.clone();
|
||
*/
|
||
clone: function() {
|
||
return this.init.prototype.extend(this);
|
||
}
|
||
};
|
||
}();
|
||
var WordArray = C_lib.WordArray = Base.extend({
|
||
/**
|
||
* Initializes a newly created word array.
|
||
*
|
||
* @param {Array} words (Optional) An array of 32-bit words.
|
||
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
||
*
|
||
* @example
|
||
*
|
||
* var wordArray = CryptoJS.lib.WordArray.create();
|
||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
||
*/
|
||
init: function(words, sigBytes) {
|
||
words = this.words = words || [];
|
||
if (sigBytes != undefined2) {
|
||
this.sigBytes = sigBytes;
|
||
} else {
|
||
this.sigBytes = words.length * 4;
|
||
}
|
||
},
|
||
/**
|
||
* Converts this word array to a string.
|
||
*
|
||
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
||
*
|
||
* @return {string} The stringified word array.
|
||
*
|
||
* @example
|
||
*
|
||
* var string = wordArray + '';
|
||
* var string = wordArray.toString();
|
||
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
||
*/
|
||
toString: function(encoder) {
|
||
return (encoder || Hex).stringify(this);
|
||
},
|
||
/**
|
||
* Concatenates a word array to this word array.
|
||
*
|
||
* @param {WordArray} wordArray The word array to append.
|
||
*
|
||
* @return {WordArray} This word array.
|
||
*
|
||
* @example
|
||
*
|
||
* wordArray1.concat(wordArray2);
|
||
*/
|
||
concat: function(wordArray) {
|
||
var thisWords = this.words;
|
||
var thatWords = wordArray.words;
|
||
var thisSigBytes = this.sigBytes;
|
||
var thatSigBytes = wordArray.sigBytes;
|
||
this.clamp();
|
||
if (thisSigBytes % 4) {
|
||
for (var i = 0; i < thatSigBytes; i++) {
|
||
var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
||
thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
|
||
}
|
||
} else {
|
||
for (var j = 0; j < thatSigBytes; j += 4) {
|
||
thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
|
||
}
|
||
}
|
||
this.sigBytes += thatSigBytes;
|
||
return this;
|
||
},
|
||
/**
|
||
* Removes insignificant bits.
|
||
*
|
||
* @example
|
||
*
|
||
* wordArray.clamp();
|
||
*/
|
||
clamp: function() {
|
||
var words = this.words;
|
||
var sigBytes = this.sigBytes;
|
||
words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
|
||
words.length = Math2.ceil(sigBytes / 4);
|
||
},
|
||
/**
|
||
* Creates a copy of this word array.
|
||
*
|
||
* @return {WordArray} The clone.
|
||
*
|
||
* @example
|
||
*
|
||
* var clone = wordArray.clone();
|
||
*/
|
||
clone: function() {
|
||
var clone3 = Base.clone.call(this);
|
||
clone3.words = this.words.slice(0);
|
||
return clone3;
|
||
},
|
||
/**
|
||
* Creates a word array filled with random bytes.
|
||
*
|
||
* @param {number} nBytes The number of random bytes to generate.
|
||
*
|
||
* @return {WordArray} The random word array.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
||
*/
|
||
random: function(nBytes) {
|
||
var words = [];
|
||
for (var i = 0; i < nBytes; i += 4) {
|
||
words.push(cryptoSecureRandomInt());
|
||
}
|
||
return new WordArray.init(words, nBytes);
|
||
}
|
||
});
|
||
var C_enc = C.enc = {};
|
||
var Hex = C_enc.Hex = {
|
||
/**
|
||
* Converts a word array to a hex string.
|
||
*
|
||
* @param {WordArray} wordArray The word array.
|
||
*
|
||
* @return {string} The hex string.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
||
*/
|
||
stringify: function(wordArray) {
|
||
var words = wordArray.words;
|
||
var sigBytes = wordArray.sigBytes;
|
||
var hexChars = [];
|
||
for (var i = 0; i < sigBytes; i++) {
|
||
var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
||
hexChars.push((bite >>> 4).toString(16));
|
||
hexChars.push((bite & 15).toString(16));
|
||
}
|
||
return hexChars.join("");
|
||
},
|
||
/**
|
||
* Converts a hex string to a word array.
|
||
*
|
||
* @param {string} hexStr The hex string.
|
||
*
|
||
* @return {WordArray} The word array.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
||
*/
|
||
parse: function(hexStr) {
|
||
var hexStrLength = hexStr.length;
|
||
var words = [];
|
||
for (var i = 0; i < hexStrLength; i += 2) {
|
||
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
|
||
}
|
||
return new WordArray.init(words, hexStrLength / 2);
|
||
}
|
||
};
|
||
var Latin1 = C_enc.Latin1 = {
|
||
/**
|
||
* Converts a word array to a Latin1 string.
|
||
*
|
||
* @param {WordArray} wordArray The word array.
|
||
*
|
||
* @return {string} The Latin1 string.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
||
*/
|
||
stringify: function(wordArray) {
|
||
var words = wordArray.words;
|
||
var sigBytes = wordArray.sigBytes;
|
||
var latin1Chars = [];
|
||
for (var i = 0; i < sigBytes; i++) {
|
||
var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
||
latin1Chars.push(String.fromCharCode(bite));
|
||
}
|
||
return latin1Chars.join("");
|
||
},
|
||
/**
|
||
* Converts a Latin1 string to a word array.
|
||
*
|
||
* @param {string} latin1Str The Latin1 string.
|
||
*
|
||
* @return {WordArray} The word array.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
||
*/
|
||
parse: function(latin1Str) {
|
||
var latin1StrLength = latin1Str.length;
|
||
var words = [];
|
||
for (var i = 0; i < latin1StrLength; i++) {
|
||
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
|
||
}
|
||
return new WordArray.init(words, latin1StrLength);
|
||
}
|
||
};
|
||
var Utf8 = C_enc.Utf8 = {
|
||
/**
|
||
* Converts a word array to a UTF-8 string.
|
||
*
|
||
* @param {WordArray} wordArray The word array.
|
||
*
|
||
* @return {string} The UTF-8 string.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
||
*/
|
||
stringify: function(wordArray) {
|
||
try {
|
||
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
||
} catch (e) {
|
||
throw new Error("Malformed UTF-8 data");
|
||
}
|
||
},
|
||
/**
|
||
* Converts a UTF-8 string to a word array.
|
||
*
|
||
* @param {string} utf8Str The UTF-8 string.
|
||
*
|
||
* @return {WordArray} The word array.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
||
*/
|
||
parse: function(utf8Str) {
|
||
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
||
}
|
||
};
|
||
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
||
/**
|
||
* Resets this block algorithm's data buffer to its initial state.
|
||
*
|
||
* @example
|
||
*
|
||
* bufferedBlockAlgorithm.reset();
|
||
*/
|
||
reset: function() {
|
||
this._data = new WordArray.init();
|
||
this._nDataBytes = 0;
|
||
},
|
||
/**
|
||
* Adds new data to this block algorithm's buffer.
|
||
*
|
||
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
||
*
|
||
* @example
|
||
*
|
||
* bufferedBlockAlgorithm._append('data');
|
||
* bufferedBlockAlgorithm._append(wordArray);
|
||
*/
|
||
_append: function(data) {
|
||
if (typeof data == "string") {
|
||
data = Utf8.parse(data);
|
||
}
|
||
this._data.concat(data);
|
||
this._nDataBytes += data.sigBytes;
|
||
},
|
||
/**
|
||
* Processes available data blocks.
|
||
*
|
||
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
||
*
|
||
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
||
*
|
||
* @return {WordArray} The processed data.
|
||
*
|
||
* @example
|
||
*
|
||
* var processedData = bufferedBlockAlgorithm._process();
|
||
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
||
*/
|
||
_process: function(doFlush) {
|
||
var processedWords;
|
||
var data = this._data;
|
||
var dataWords = data.words;
|
||
var dataSigBytes = data.sigBytes;
|
||
var blockSize = this.blockSize;
|
||
var blockSizeBytes = blockSize * 4;
|
||
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
||
if (doFlush) {
|
||
nBlocksReady = Math2.ceil(nBlocksReady);
|
||
} else {
|
||
nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
||
}
|
||
var nWordsReady = nBlocksReady * blockSize;
|
||
var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
|
||
if (nWordsReady) {
|
||
for (var offset3 = 0; offset3 < nWordsReady; offset3 += blockSize) {
|
||
this._doProcessBlock(dataWords, offset3);
|
||
}
|
||
processedWords = dataWords.splice(0, nWordsReady);
|
||
data.sigBytes -= nBytesReady;
|
||
}
|
||
return new WordArray.init(processedWords, nBytesReady);
|
||
},
|
||
/**
|
||
* Creates a copy of this object.
|
||
*
|
||
* @return {Object} The clone.
|
||
*
|
||
* @example
|
||
*
|
||
* var clone = bufferedBlockAlgorithm.clone();
|
||
*/
|
||
clone: function() {
|
||
var clone3 = Base.clone.call(this);
|
||
clone3._data = this._data.clone();
|
||
return clone3;
|
||
},
|
||
_minBufferSize: 0
|
||
});
|
||
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
||
/**
|
||
* Configuration options.
|
||
*/
|
||
cfg: Base.extend(),
|
||
/**
|
||
* Initializes a newly created hasher.
|
||
*
|
||
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
||
*
|
||
* @example
|
||
*
|
||
* var hasher = CryptoJS.algo.SHA256.create();
|
||
*/
|
||
init: function(cfg) {
|
||
this.cfg = this.cfg.extend(cfg);
|
||
this.reset();
|
||
},
|
||
/**
|
||
* Resets this hasher to its initial state.
|
||
*
|
||
* @example
|
||
*
|
||
* hasher.reset();
|
||
*/
|
||
reset: function() {
|
||
BufferedBlockAlgorithm.reset.call(this);
|
||
this._doReset();
|
||
},
|
||
/**
|
||
* Updates this hasher with a message.
|
||
*
|
||
* @param {WordArray|string} messageUpdate The message to append.
|
||
*
|
||
* @return {Hasher} This hasher.
|
||
*
|
||
* @example
|
||
*
|
||
* hasher.update('message');
|
||
* hasher.update(wordArray);
|
||
*/
|
||
update: function(messageUpdate) {
|
||
this._append(messageUpdate);
|
||
this._process();
|
||
return this;
|
||
},
|
||
/**
|
||
* Finalizes the hash computation.
|
||
* Note that the finalize operation is effectively a destructive, read-once operation.
|
||
*
|
||
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
||
*
|
||
* @return {WordArray} The hash.
|
||
*
|
||
* @example
|
||
*
|
||
* var hash = hasher.finalize();
|
||
* var hash = hasher.finalize('message');
|
||
* var hash = hasher.finalize(wordArray);
|
||
*/
|
||
finalize: function(messageUpdate) {
|
||
if (messageUpdate) {
|
||
this._append(messageUpdate);
|
||
}
|
||
var hash3 = this._doFinalize();
|
||
return hash3;
|
||
},
|
||
blockSize: 512 / 32,
|
||
/**
|
||
* Creates a shortcut function to a hasher's object interface.
|
||
*
|
||
* @param {Hasher} hasher The hasher to create a helper for.
|
||
*
|
||
* @return {Function} The shortcut function.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
||
*/
|
||
_createHelper: function(hasher) {
|
||
return function(message, cfg) {
|
||
return new hasher.init(cfg).finalize(message);
|
||
};
|
||
},
|
||
/**
|
||
* Creates a shortcut function to the HMAC's object interface.
|
||
*
|
||
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
||
*
|
||
* @return {Function} The shortcut function.
|
||
*
|
||
* @static
|
||
*
|
||
* @example
|
||
*
|
||
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
||
*/
|
||
_createHmacHelper: function(hasher) {
|
||
return function(message, key) {
|
||
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
||
};
|
||
}
|
||
});
|
||
var C_algo = C.algo = {};
|
||
return C;
|
||
}(Math);
|
||
return CryptoJS;
|
||
});
|
||
}
|
||
});
|
||
|
||
// node_modules/crypto-js/sha1.js
|
||
var require_sha1 = __commonJS({
|
||
"node_modules/crypto-js/sha1.js"(exports, module2) {
|
||
(function(root, factory) {
|
||
if (typeof exports === "object") {
|
||
module2.exports = exports = factory(require_core());
|
||
} else if (typeof define === "function" && define.amd) {
|
||
define(["./core"], factory);
|
||
} else {
|
||
factory(root.CryptoJS);
|
||
}
|
||
})(exports, function(CryptoJS) {
|
||
(function() {
|
||
var C = CryptoJS;
|
||
var C_lib = C.lib;
|
||
var WordArray = C_lib.WordArray;
|
||
var Hasher = C_lib.Hasher;
|
||
var C_algo = C.algo;
|
||
var W = [];
|
||
var SHA1 = C_algo.SHA1 = Hasher.extend({
|
||
_doReset: function() {
|
||
this._hash = new WordArray.init([
|
||
1732584193,
|
||
4023233417,
|
||
2562383102,
|
||
271733878,
|
||
3285377520
|
||
]);
|
||
},
|
||
_doProcessBlock: function(M, offset3) {
|
||
var H = this._hash.words;
|
||
var a = H[0];
|
||
var b = H[1];
|
||
var c = H[2];
|
||
var d = H[3];
|
||
var e = H[4];
|
||
for (var i = 0; i < 80; i++) {
|
||
if (i < 16) {
|
||
W[i] = M[offset3 + i] | 0;
|
||
} else {
|
||
var n2 = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
|
||
W[i] = n2 << 1 | n2 >>> 31;
|
||
}
|
||
var t = (a << 5 | a >>> 27) + e + W[i];
|
||
if (i < 20) {
|
||
t += (b & c | ~b & d) + 1518500249;
|
||
} else if (i < 40) {
|
||
t += (b ^ c ^ d) + 1859775393;
|
||
} else if (i < 60) {
|
||
t += (b & c | b & d | c & d) - 1894007588;
|
||
} else {
|
||
t += (b ^ c ^ d) - 899497514;
|
||
}
|
||
e = d;
|
||
d = c;
|
||
c = b << 30 | b >>> 2;
|
||
b = a;
|
||
a = t;
|
||
}
|
||
H[0] = H[0] + a | 0;
|
||
H[1] = H[1] + b | 0;
|
||
H[2] = H[2] + c | 0;
|
||
H[3] = H[3] + d | 0;
|
||
H[4] = H[4] + e | 0;
|
||
},
|
||
_doFinalize: function() {
|
||
var data = this._data;
|
||
var dataWords = data.words;
|
||
var nBitsTotal = this._nDataBytes * 8;
|
||
var nBitsLeft = data.sigBytes * 8;
|
||
dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
|
||
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296);
|
||
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
|
||
data.sigBytes = dataWords.length * 4;
|
||
this._process();
|
||
return this._hash;
|
||
},
|
||
clone: function() {
|
||
var clone3 = Hasher.clone.call(this);
|
||
clone3._hash = this._hash.clone();
|
||
return clone3;
|
||
}
|
||
});
|
||
C.SHA1 = Hasher._createHelper(SHA1);
|
||
C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
|
||
})();
|
||
return CryptoJS.SHA1;
|
||
});
|
||
}
|
||
});
|
||
|
||
// main.ts
|
||
var main_exports = {};
|
||
__export(main_exports, {
|
||
default: () => DigitalGarden
|
||
});
|
||
module.exports = __toCommonJS(main_exports);
|
||
var import_obsidian14 = require("obsidian");
|
||
|
||
// node_modules/luxon/src/errors.js
|
||
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");
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/impl/formats.js
|
||
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
|
||
};
|
||
|
||
// node_modules/luxon/src/zone.js
|
||
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();
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/zones/systemZone.js
|
||
var singleton = null;
|
||
var SystemZone = class _SystemZone extends Zone {
|
||
/**
|
||
* Get a singleton instance of the local zone
|
||
* @return {SystemZone}
|
||
*/
|
||
static get instance() {
|
||
if (singleton === null) {
|
||
singleton = new _SystemZone();
|
||
}
|
||
return singleton;
|
||
}
|
||
/** @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;
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/zones/IANAZone.js
|
||
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 _IANAZone 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;
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/impl/locale.js
|
||
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 _a2 = opts, { base } = _a2, cacheKeyOpts = __objRest(_a2, ["base"]);
|
||
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(2009, 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, englishFn, intlFn) {
|
||
const mode = loc.listingMode();
|
||
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 _a2 = opts, { padTo, floor } = _a2, otherOpts = __objRest(_a2, ["padTo", "floor"]);
|
||
if (!forceSimple || Object.keys(otherOpts).length > 0) {
|
||
const intlOpts = __spreadValues({ 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;
|
||
this.originalZone = void 0;
|
||
let z = void 0;
|
||
if (this.opts.timeZone) {
|
||
this.dt = dt;
|
||
} else if (dt.zone.type === "fixed") {
|
||
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";
|
||
this.dt = dt.offset === 0 ? dt : dt.setZone("UTC").plus({ minutes: dt.offset });
|
||
this.originalZone = dt.zone;
|
||
}
|
||
} else if (dt.zone.type === "system") {
|
||
this.dt = dt;
|
||
} else if (dt.zone.type === "iana") {
|
||
this.dt = dt;
|
||
z = dt.zone.name;
|
||
} else {
|
||
z = "UTC";
|
||
this.dt = dt.setZone("UTC").plus({ minutes: dt.offset });
|
||
this.originalZone = dt.zone;
|
||
}
|
||
const intlOpts = __spreadValues({}, this.opts);
|
||
intlOpts.timeZone = intlOpts.timeZone || z;
|
||
this.dtf = getCachedDTF(intl, intlOpts);
|
||
}
|
||
format() {
|
||
if (this.originalZone) {
|
||
return this.formatToParts().map(({ value }) => value).join("");
|
||
}
|
||
return this.dtf.format(this.dt.toJSDate());
|
||
}
|
||
formatToParts() {
|
||
const parts = this.dtf.formatToParts(this.dt.toJSDate());
|
||
if (this.originalZone) {
|
||
return parts.map((part) => {
|
||
if (part.type === "timeZoneName") {
|
||
const offsetName = this.originalZone.offsetName(this.dt.ts, {
|
||
locale: this.dt.locale,
|
||
format: this.opts.timeZoneName
|
||
});
|
||
return __spreadProps(__spreadValues({}, part), {
|
||
value: offsetName
|
||
});
|
||
} else {
|
||
return part;
|
||
}
|
||
});
|
||
}
|
||
return parts;
|
||
}
|
||
resolvedOptions() {
|
||
return this.dtf.resolvedOptions();
|
||
}
|
||
};
|
||
var PolyRelFormatter = class {
|
||
constructor(intl, isEnglish, opts) {
|
||
this.opts = __spreadValues({ 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 _Locale {
|
||
static fromOpts(opts) {
|
||
return _Locale.create(opts.locale, opts.numberingSystem, opts.outputCalendar, opts.defaultToEN);
|
||
}
|
||
static create(locale, numberingSystem, outputCalendar, defaultToEN = false) {
|
||
const specifiedLocale = locale || Settings.defaultLocale;
|
||
const localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale());
|
||
const numberingSystemR = numberingSystem || Settings.defaultNumberingSystem;
|
||
const outputCalendarR = outputCalendar || Settings.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(__spreadProps(__spreadValues({}, alts), { defaultToEN: true }));
|
||
}
|
||
redefaultToSystem(alts = {}) {
|
||
return this.clone(__spreadProps(__spreadValues({}, alts), { defaultToEN: false }));
|
||
}
|
||
months(length, format = false) {
|
||
return listStuff(this, length, 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) {
|
||
return listStuff(this, length, 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() {
|
||
return listStuff(
|
||
this,
|
||
void 0,
|
||
() => 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) {
|
||
return listStuff(this, length, 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;
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/zones/fixedOffsetZone.js
|
||
var singleton2 = null;
|
||
var FixedOffsetZone = class _FixedOffsetZone extends Zone {
|
||
/**
|
||
* Get a singleton instance of UTC
|
||
* @return {FixedOffsetZone}
|
||
*/
|
||
static get utcInstance() {
|
||
if (singleton2 === null) {
|
||
singleton2 = new _FixedOffsetZone(0);
|
||
}
|
||
return singleton2;
|
||
}
|
||
/**
|
||
* Get an instance with a specified offset
|
||
* @param {number} offset - The offset in minutes
|
||
* @return {FixedOffsetZone}
|
||
*/
|
||
static instance(offset3) {
|
||
return offset3 === 0 ? _FixedOffsetZone.utcInstance : new _FixedOffsetZone(offset3);
|
||
}
|
||
/**
|
||
* 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(offset3) {
|
||
super();
|
||
this.fixed = offset3;
|
||
}
|
||
/** @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;
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/zones/invalidZone.js
|
||
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;
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/impl/zoneUtil.js
|
||
function normalizeZone(input, defaultZone2) {
|
||
let offset3;
|
||
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" && "offset" in input && typeof input.offset === "function") {
|
||
return input;
|
||
} else {
|
||
return new InvalidZone(input);
|
||
}
|
||
}
|
||
|
||
// node_modules/luxon/src/settings.js
|
||
var now = () => Date.now();
|
||
var defaultZone = "system";
|
||
var defaultLocale = null;
|
||
var defaultNumberingSystem = null;
|
||
var defaultOutputCalendar = null;
|
||
var twoDigitCutoffYear = 60;
|
||
var throwOnInvalid;
|
||
var Settings = class {
|
||
/**
|
||
* Get the callback for returning the current timestamp.
|
||
* @type {function}
|
||
*/
|
||
static get now() {
|
||
return now;
|
||
}
|
||
/**
|
||
* 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) {
|
||
now = 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 interpreted as current century
|
||
* @example Settings.twoDigitCutoffYear = 50 // '49' -> 1949; '50' -> 2050
|
||
* @example Settings.twoDigitCutoffYear = 1950 // interpreted as 50
|
||
* @example Settings.twoDigitCutoffYear = 2050 // ALSO interpreted 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();
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/impl/util.js
|
||
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, bottom2, top2) {
|
||
return isInteger(thing) && thing >= bottom2 && thing <= top2;
|
||
}
|
||
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(obj.year, obj.month - 1, obj.day);
|
||
}
|
||
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 > Settings.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 = __spreadValues({ 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(offset3, format) {
|
||
const hours = Math.trunc(Math.abs(offset3 / 60)), minutes = Math.trunc(Math.abs(offset3 % 60)), sign = offset3 >= 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"]);
|
||
}
|
||
|
||
// node_modules/luxon/src/impl/english.js
|
||
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]}`;
|
||
default:
|
||
}
|
||
}
|
||
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}`;
|
||
}
|
||
|
||
// node_modules/luxon/src/impl/formatter.js
|
||
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 _Formatter {
|
||
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 || /^\s+$/.test(currentFull), 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: /^\s+$/.test(currentFull), val: currentFull });
|
||
}
|
||
currentFull = c;
|
||
current = c;
|
||
}
|
||
}
|
||
if (currentFull.length > 0) {
|
||
splits.push({ literal: bracketed || /^\s+$/.test(currentFull), 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, __spreadValues(__spreadValues({}, this.opts), opts));
|
||
return df.format();
|
||
}
|
||
dtFormatter(dt, opts = {}) {
|
||
return this.loc.dtFormatter(dt, __spreadValues(__spreadValues({}, this.opts), opts));
|
||
}
|
||
formatDateTime(dt, opts) {
|
||
return this.dtFormatter(dt, opts).format();
|
||
}
|
||
formatDateTimeParts(dt, opts) {
|
||
return this.dtFormatter(dt, opts).formatToParts();
|
||
}
|
||
formatInterval(interval, opts) {
|
||
const df = this.dtFormatter(interval.start, opts);
|
||
return df.dtf.formatRange(interval.start.toJSDate(), interval.end.toJSDate());
|
||
}
|
||
resolvedOptions(dt, opts) {
|
||
return this.dtFormatter(dt, opts).resolvedOptions();
|
||
}
|
||
num(n2, p = 0) {
|
||
if (this.opts.forceSimple) {
|
||
return padStart(n2, p);
|
||
}
|
||
const opts = __spreadValues({}, 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));
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/impl/invalid.js
|
||
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;
|
||
}
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/impl/regexParser.js
|
||
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 [__spreadValues(__spreadValues({}, 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 offset3;
|
||
if (obsOffset) {
|
||
offset3 = obsOffsets[obsOffset];
|
||
} else if (milOffset) {
|
||
offset3 = 0;
|
||
} else {
|
||
offset3 = signedOffset(offHourStr, offMinuteStr);
|
||
}
|
||
return [result, new FixedOffsetZone(offset3)];
|
||
}
|
||
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]
|
||
);
|
||
}
|
||
|
||
// node_modules/luxon/src/duration.js
|
||
var INVALID = "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 = __spreadValues({
|
||
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 = __spreadValues({
|
||
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 = [
|
||
"years",
|
||
"quarters",
|
||
"months",
|
||
"weeks",
|
||
"days",
|
||
"hours",
|
||
"minutes",
|
||
"seconds",
|
||
"milliseconds"
|
||
];
|
||
var reverseUnits = orderedUnits.slice(0).reverse();
|
||
function clone(dur, alts, clear = false) {
|
||
const conf = {
|
||
values: clear ? alts.values : __spreadValues(__spreadValues({}, 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 durationToMillis(matrix, vals) {
|
||
var _a2;
|
||
let sum = (_a2 = vals.milliseconds) != null ? _a2 : 0;
|
||
for (const unit of reverseUnits.slice(1)) {
|
||
if (vals[unit]) {
|
||
sum += vals[unit] * matrix[unit]["milliseconds"];
|
||
}
|
||
}
|
||
return sum;
|
||
}
|
||
function normalizeValues(matrix, vals) {
|
||
const factor = durationToMillis(matrix, vals) < 0 ? -1 : 1;
|
||
orderedUnits.reduceRight((previous, current) => {
|
||
if (!isUndefined(vals[current])) {
|
||
if (previous) {
|
||
const previousVal = vals[previous] * factor;
|
||
const conv = matrix[current][previous];
|
||
const rollUp = Math.floor(previousVal / conv);
|
||
vals[current] += rollUp * factor;
|
||
vals[previous] -= rollUp * conv * factor;
|
||
}
|
||
return current;
|
||
} else {
|
||
return previous;
|
||
}
|
||
}, null);
|
||
orderedUnits.reduce((previous, current) => {
|
||
if (!isUndefined(vals[current])) {
|
||
if (previous) {
|
||
const fraction = vals[previous] % 1;
|
||
vals[previous] -= fraction;
|
||
vals[current] += fraction * matrix[previous][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 _Duration {
|
||
/**
|
||
* @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 (Settings.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 = __spreadProps(__spreadValues({}, opts), {
|
||
floor: opts.round !== false && opts.floor !== false
|
||
});
|
||
return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID;
|
||
}
|
||
/**
|
||
* 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 = {}) {
|
||
if (!this.isValid)
|
||
return INVALID;
|
||
const l2 = orderedUnits.map((unit) => {
|
||
const val = this.values[unit];
|
||
if (isUndefined(val)) {
|
||
return null;
|
||
}
|
||
return this.loc.numberFormatter(__spreadProps(__spreadValues({ style: "unit", unitDisplay: "long" }, opts), { unit: unit.slice(0, -1) })).format(val);
|
||
}).filter((n2) => n2);
|
||
return this.loc.listFormatter(__spreadValues({ 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 __spreadValues({}, 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 = __spreadProps(__spreadValues({
|
||
suppressMilliseconds: false,
|
||
suppressSeconds: false,
|
||
includePrefix: false,
|
||
format: "extended"
|
||
}, opts), {
|
||
includeOffset: false
|
||
});
|
||
const dateTime = DateTime.fromMillis(millis, { zone: "UTC" });
|
||
return dateTime.toISOTime(opts);
|
||
}
|
||
/**
|
||
* 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() {
|
||
if (!this.isValid)
|
||
return NaN;
|
||
return durationToMillis(this.matrix, this.values);
|
||
}
|
||
/**
|
||
* 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) {
|
||
if (hasOwnProperty(dur.values, k) || hasOwnProperty(this.values, k)) {
|
||
result[k] = dur.get(k) + this.get(k);
|
||
}
|
||
}
|
||
return clone(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(fn2) {
|
||
if (!this.isValid)
|
||
return this;
|
||
const result = {};
|
||
for (const k of Object.keys(this.values)) {
|
||
result[k] = asNumber(fn2(this.values[k], k));
|
||
}
|
||
return clone(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 = __spreadValues(__spreadValues({}, this.values), normalizeObject(values, _Duration.normalizeUnit));
|
||
return clone(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(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.
|
||
* Assuming the overall value of the Duration is positive, this means:
|
||
* - excessive values for lower-order units are converted to higher-order units (if possible, see first and second example)
|
||
* - negative lower-order units are converted to higher order units (there must be such a higher order unit, otherwise
|
||
* the overall value would be negative, see second example)
|
||
* - fractional values for higher-order units are converted to lower-order units (if possible, see fourth example)
|
||
*
|
||
* If the overall value is negative, the result of this method is equivalent to `this.negate().normalize().negate()`.
|
||
* @example Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 }
|
||
* @example Duration.fromObject({ days: 5000 }).normalize().toObject() //=> { days: 5000 }
|
||
* @example Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 }
|
||
* @example Duration.fromObject({ years: 2.5, days: 0, hours: 0 }).normalize().toObject() //=> { years: 2, days: 182, hours: 12 }
|
||
* @return {Duration}
|
||
*/
|
||
normalize() {
|
||
if (!this.isValid)
|
||
return this;
|
||
const vals = this.toObject();
|
||
normalizeValues(this.matrix, vals);
|
||
return clone(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(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) {
|
||
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;
|
||
} 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];
|
||
}
|
||
}
|
||
normalizeValues(this.matrix, built);
|
||
return clone(this, { values: built }, true);
|
||
}
|
||
/**
|
||
* 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(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) {
|
||
if (!eq(this.values[u], other.values[u])) {
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/interval.js
|
||
var INVALID2 = "Invalid Interval";
|
||
function validateStartEnd(start2, end2) {
|
||
if (!start2 || !start2.isValid) {
|
||
return Interval.invalid("missing or invalid start");
|
||
} else if (!end2 || !end2.isValid) {
|
||
return Interval.invalid("missing or invalid end");
|
||
} else if (end2 < start2) {
|
||
return Interval.invalid(
|
||
"end before start",
|
||
`The end of an interval must be after its start, but you had start=${start2.toISO()} and end=${end2.toISO()}`
|
||
);
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
var Interval = class _Interval {
|
||
/**
|
||
* @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 (Settings.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(start2, end2) {
|
||
const builtStart = friendlyDateTime(start2), builtEnd = friendlyDateTime(end2);
|
||
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(start2, duration) {
|
||
const dur = Duration.fromDurationLike(duration), dt = friendlyDateTime(start2);
|
||
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(end2, duration) {
|
||
const dur = Duration.fromDurationLike(duration), dt = friendlyDateTime(end2);
|
||
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 start2, startIsValid;
|
||
try {
|
||
start2 = DateTime.fromISO(s2, opts);
|
||
startIsValid = start2.isValid;
|
||
} catch (e2) {
|
||
startIsValid = false;
|
||
}
|
||
let end2, endIsValid;
|
||
try {
|
||
end2 = DateTime.fromISO(e, opts);
|
||
endIsValid = end2.isValid;
|
||
} catch (e2) {
|
||
endIsValid = false;
|
||
}
|
||
if (startIsValid && endIsValid) {
|
||
return _Interval.fromDateTimes(start2, end2);
|
||
}
|
||
if (startIsValid) {
|
||
const dur = Duration.fromISO(e, opts);
|
||
if (dur.isValid) {
|
||
return _Interval.after(start2, dur);
|
||
}
|
||
} else if (endIsValid) {
|
||
const dur = Duration.fromISO(s2, opts);
|
||
if (dur.isValid) {
|
||
return _Interval.before(end2, 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 start2 = this.start.startOf(unit), end2 = this.end.startOf(unit);
|
||
return Math.floor(end2.diff(start2, unit).get(unit)) + (end2.valueOf() !== this.end.valueOf());
|
||
}
|
||
/**
|
||
* 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: start2, end: end2 } = {}) {
|
||
if (!this.isValid)
|
||
return this;
|
||
return _Interval.fromDateTimes(start2 || this.s, end2 || 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 start2 = 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) {
|
||
start2 = i.time;
|
||
} else {
|
||
if (start2 && +start2 !== +i.time) {
|
||
results.push(_Interval.fromDateTimes(start2, i.time));
|
||
}
|
||
start2 = 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 INVALID2;
|
||
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) : INVALID2;
|
||
}
|
||
/**
|
||
* 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 INVALID2;
|
||
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 INVALID2;
|
||
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 INVALID2;
|
||
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 INVALID2;
|
||
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));
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/info.js
|
||
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 = Settings.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, Settings.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() };
|
||
}
|
||
};
|
||
|
||
// node_modules/luxon/src/impl/diff.js
|
||
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);
|
||
if (cursor > later) {
|
||
highWater = cursor;
|
||
results[unit]--;
|
||
cursor = earlier.plus(results);
|
||
}
|
||
} else {
|
||
cursor = highWater;
|
||
}
|
||
}
|
||
}
|
||
return [cursor, results, highWater, lowestOrder];
|
||
}
|
||
function diff_default(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;
|
||
}
|
||
}
|
||
|
||
// node_modules/luxon/src/impl/digits.js
|
||
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 [min2, max2] = numberingSystemsUTF16[key];
|
||
if (code >= min2 && code <= max2) {
|
||
value += code - min2;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return parseInt(value, 10);
|
||
} else {
|
||
return value;
|
||
}
|
||
}
|
||
function digitRegex({ numberingSystem }, append3 = "") {
|
||
return new RegExp(`${numberingSystems[numberingSystem || "latn"]}${append3}`);
|
||
}
|
||
|
||
// node_modules/luxon/src/impl/tokenParser.js
|
||
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"), 0);
|
||
case "GG":
|
||
return oneOf(loc.eras("long"), 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), 1);
|
||
case "MMMM":
|
||
return oneOf(loc.months("long", true), 1);
|
||
case "L":
|
||
return intUnit(oneOrTwo);
|
||
case "LL":
|
||
return intUnit(two);
|
||
case "LLL":
|
||
return oneOf(loc.months("short", false), 1);
|
||
case "LLLL":
|
||
return oneOf(loc.months("long", 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), 1);
|
||
case "EEEE":
|
||
return oneOf(loc.weekdays("long", false), 1);
|
||
case "ccc":
|
||
return oneOf(loc.weekdays("short", true), 1);
|
||
case "cccc":
|
||
return oneOf(loc.weekdays("long", true), 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);
|
||
case " ":
|
||
return simple(/[^\S\n\r]/);
|
||
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",
|
||
hour12: {
|
||
numeric: "h",
|
||
"2-digit": "hh"
|
||
},
|
||
hour24: {
|
||
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, resolvedOpts) {
|
||
const { type, value } = part;
|
||
if (type === "literal") {
|
||
const isSpace = /^\s+$/.test(value);
|
||
return {
|
||
literal: !isSpace,
|
||
val: isSpace ? " " : value
|
||
};
|
||
}
|
||
const style = formatOpts[type];
|
||
let actualType = type;
|
||
if (type === "hour") {
|
||
if (formatOpts.hour12 != null) {
|
||
actualType = formatOpts.hour12 ? "hour12" : "hour24";
|
||
} else if (formatOpts.hourCycle != null) {
|
||
if (formatOpts.hourCycle === "h11" || formatOpts.hourCycle === "h12") {
|
||
actualType = "hour12";
|
||
} else {
|
||
actualType = "hour24";
|
||
}
|
||
} else {
|
||
actualType = resolvedOpts.hour12 ? "hour12" : "hour24";
|
||
}
|
||
}
|
||
let val = partTypeStyleToTokenVal[actualType];
|
||
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 all3 = {};
|
||
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) {
|
||
all3[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups));
|
||
}
|
||
matchIndex += groups;
|
||
}
|
||
}
|
||
return [matches, all3];
|
||
} 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 df = formatter.dtFormatter(getDummyDateTime());
|
||
const parts = df.formatToParts();
|
||
const resolvedOpts = df.resolvedOptions();
|
||
return parts.map((p) => tokenForPart(p, formatOpts, resolvedOpts));
|
||
}
|
||
|
||
// node_modules/luxon/src/impl/conversions.js
|
||
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 __spreadValues({ 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 __spreadValues({ year, month, day }, timeObject(weekData));
|
||
}
|
||
function gregorianToOrdinal(gregData) {
|
||
const { year, month, day } = gregData;
|
||
const ordinal = computeOrdinal(year, month, day);
|
||
return __spreadValues({ year, ordinal }, timeObject(gregData));
|
||
}
|
||
function ordinalToGregorian(ordinalData) {
|
||
const { year, ordinal } = ordinalData;
|
||
const { month, day } = uncomputeOrdinal(year, ordinal);
|
||
return __spreadValues({ 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;
|
||
}
|
||
|
||
// node_modules/luxon/src/datetime.js
|
||
var INVALID3 = "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 clone2(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(__spreadProps(__spreadValues(__spreadValues({}, 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, offset3) {
|
||
ts += offset3 * 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, offset3, zone) {
|
||
return fixOffset(objToLocalTS(obj), offset3, 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 = __spreadProps(__spreadValues({}, 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 || parsedZone) {
|
||
const interpretationZone = parsedZone || zone, inst = DateTime.fromObject(parsed, __spreadProps(__spreadValues({}, 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.millisecond !== 0 || o.c.second !== 0 || !suppressSeconds) {
|
||
c += ":";
|
||
}
|
||
} else {
|
||
c += padStart(o.c.minute);
|
||
}
|
||
if (o.c.millisecond !== 0 || 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 orderedUnits2 = ["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, Settings.defaultZone), loc = Locale.fromObject(opts), tsNow = Settings.now();
|
||
let ts, o;
|
||
if (!isUndefined(obj.year)) {
|
||
for (const u of orderedUnits2) {
|
||
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(start2, end2, opts) {
|
||
const round2 = isUndefined(opts.round) ? true : opts.round, format = (c, unit) => {
|
||
c = roundTo(c, round2 || opts.calendary ? 0 : 2, true);
|
||
const formatter = end2.loc.clone(opts).relFormatter(opts);
|
||
return formatter.format(c, unit);
|
||
}, differ = (unit) => {
|
||
if (opts.calendary) {
|
||
if (!end2.hasSame(start2, unit)) {
|
||
return end2.startOf(unit).diff(start2.startOf(unit), unit).get(unit);
|
||
} else
|
||
return 0;
|
||
} else {
|
||
return end2.diff(start2, 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(start2 > end2 ? -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 _DateTime {
|
||
/**
|
||
* @access private
|
||
*/
|
||
constructor(config) {
|
||
const zone = config.zone || Settings.defaultZone;
|
||
let invalid = config.invalid || (Number.isNaN(config.ts) ? new Invalid("invalid input") : null) || (!zone.isValid ? unsupportedZone(zone) : null);
|
||
this.ts = isUndefined(config.ts) ? Settings.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, Settings.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, Settings.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, Settings.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, Settings.defaultZone);
|
||
if (!zoneToUse.isValid) {
|
||
return _DateTime.invalid(unsupportedZone(zoneToUse));
|
||
}
|
||
const tsNow = Settings.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 = orderedUnits2;
|
||
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 {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 {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 (Settings.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;
|
||
}
|
||
}
|
||
/**
|
||
* Get those DateTimes which have the same local time as this DateTime, but a different offset from UTC
|
||
* in this DateTime's zone. During DST changes local time can be ambiguous, for example
|
||
* `2023-10-29T02:30:00` in `Europe/Berlin` can have offset `+01:00` or `+02:00`.
|
||
* This method will return both possible DateTimes if this DateTime's local time is ambiguous.
|
||
* @returns {DateTime[]}
|
||
*/
|
||
getPossibleOffsets() {
|
||
if (!this.isValid || this.isOffsetFixed) {
|
||
return [this];
|
||
}
|
||
const dayMs = 864e5;
|
||
const minuteMs = 6e4;
|
||
const localTS = objToLocalTS(this.c);
|
||
const oEarlier = this.zone.offset(localTS - dayMs);
|
||
const oLater = this.zone.offset(localTS + dayMs);
|
||
const o1 = this.zone.offset(localTS - oEarlier * minuteMs);
|
||
const o2 = this.zone.offset(localTS - oLater * minuteMs);
|
||
if (o1 === o2) {
|
||
return [this];
|
||
}
|
||
const ts1 = localTS - o1 * minuteMs;
|
||
const ts2 = localTS - o2 * minuteMs;
|
||
const c1 = tsToObj(ts1, o1);
|
||
const c2 = tsToObj(ts2, o2);
|
||
if (c1.hour === c2.hour && c1.minute === c2.minute && c1.second === c2.second && c1.millisecond === c2.millisecond) {
|
||
return [clone2(this, { ts: ts1 }), clone2(this, { ts: ts2 })];
|
||
}
|
||
return [this];
|
||
}
|
||
/**
|
||
* 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(offset3 = 0, opts = {}) {
|
||
return this.setZone(FixedOffsetZone.instance(offset3), 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(Settings.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, Settings.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 clone2(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 clone2(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(__spreadValues(__spreadValues({}, gregorianToWeek(this.c)), normalized));
|
||
} else if (!isUndefined(normalized.ordinal)) {
|
||
mixed = ordinalToGregorian(__spreadValues(__spreadValues({}, gregorianToOrdinal(this.c)), normalized));
|
||
} else {
|
||
mixed = __spreadValues(__spreadValues({}, 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 clone2(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 clone2(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 clone2(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;
|
||
case "milliseconds":
|
||
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) : INVALID3;
|
||
}
|
||
/**
|
||
* 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) : INVALID3;
|
||
}
|
||
/**
|
||
* 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() : INVALID3;
|
||
}
|
||
/**
|
||
* 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 = __spreadValues({}, 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 = __spreadValues({ 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_default(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), __spreadProps(__spreadValues({}, 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, __spreadProps(__spreadValues({}, 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}`
|
||
);
|
||
}
|
||
}
|
||
|
||
// src/publisher/Publisher.ts
|
||
var import_obsidian2 = require("obsidian");
|
||
var import_obsidian_dataview = __toESM(require_lib());
|
||
|
||
// node_modules/js-base64/base64.mjs
|
||
var version = "3.7.5";
|
||
var VERSION = version;
|
||
var _hasatob = typeof atob === "function";
|
||
var _hasbtoa = typeof btoa === "function";
|
||
var _hasBuffer = typeof Buffer === "function";
|
||
var _TD = typeof TextDecoder === "function" ? new TextDecoder() : void 0;
|
||
var _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
|
||
var b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||
var b64chs = Array.prototype.slice.call(b64ch);
|
||
var b64tab = ((a) => {
|
||
let tab = {};
|
||
a.forEach((c, i) => tab[c] = i);
|
||
return tab;
|
||
})(b64chs);
|
||
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
||
var _fromCC = String.fromCharCode.bind(String);
|
||
var _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
|
||
var _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
|
||
var _tidyB64 = (s2) => s2.replace(/[^A-Za-z0-9\+\/]/g, "");
|
||
var btoaPolyfill = (bin) => {
|
||
let u32, c0, c1, c2, asc = "";
|
||
const pad = bin.length % 3;
|
||
for (let i = 0; i < bin.length; ) {
|
||
if ((c0 = bin.charCodeAt(i++)) > 255 || (c1 = bin.charCodeAt(i++)) > 255 || (c2 = bin.charCodeAt(i++)) > 255)
|
||
throw new TypeError("invalid character found");
|
||
u32 = c0 << 16 | c1 << 8 | c2;
|
||
asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
|
||
}
|
||
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
|
||
};
|
||
var _btoa = _hasbtoa ? (bin) => btoa(bin) : _hasBuffer ? (bin) => Buffer.from(bin, "binary").toString("base64") : btoaPolyfill;
|
||
var _fromUint8Array = _hasBuffer ? (u8a) => Buffer.from(u8a).toString("base64") : (u8a) => {
|
||
const maxargs = 4096;
|
||
let strs = [];
|
||
for (let i = 0, l2 = u8a.length; i < l2; i += maxargs) {
|
||
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
|
||
}
|
||
return _btoa(strs.join(""));
|
||
};
|
||
var fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
|
||
var cb_utob = (c) => {
|
||
if (c.length < 2) {
|
||
var cc = c.charCodeAt(0);
|
||
return cc < 128 ? c : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
|
||
} else {
|
||
var cc = 65536 + (c.charCodeAt(0) - 55296) * 1024 + (c.charCodeAt(1) - 56320);
|
||
return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
|
||
}
|
||
};
|
||
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
||
var utob = (u) => u.replace(re_utob, cb_utob);
|
||
var _encode = _hasBuffer ? (s2) => Buffer.from(s2, "utf8").toString("base64") : _TE ? (s2) => _fromUint8Array(_TE.encode(s2)) : (s2) => _btoa(utob(s2));
|
||
var encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
|
||
var encodeURI2 = (src) => encode(src, true);
|
||
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
||
var cb_btou = (cccc) => {
|
||
switch (cccc.length) {
|
||
case 4:
|
||
var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset3 = cp - 65536;
|
||
return _fromCC((offset3 >>> 10) + 55296) + _fromCC((offset3 & 1023) + 56320);
|
||
case 3:
|
||
return _fromCC((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2));
|
||
default:
|
||
return _fromCC((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1));
|
||
}
|
||
};
|
||
var btou = (b) => b.replace(re_btou, cb_btou);
|
||
var atobPolyfill = (asc) => {
|
||
asc = asc.replace(/\s+/g, "");
|
||
if (!b64re.test(asc))
|
||
throw new TypeError("malformed base64.");
|
||
asc += "==".slice(2 - (asc.length & 3));
|
||
let u24, bin = "", r1, r2;
|
||
for (let i = 0; i < asc.length; ) {
|
||
u24 = b64tab[asc.charAt(i++)] << 18 | b64tab[asc.charAt(i++)] << 12 | (r1 = b64tab[asc.charAt(i++)]) << 6 | (r2 = b64tab[asc.charAt(i++)]);
|
||
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255) : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255) : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
|
||
}
|
||
return bin;
|
||
};
|
||
var _atob = _hasatob ? (asc) => atob(_tidyB64(asc)) : _hasBuffer ? (asc) => Buffer.from(asc, "base64").toString("binary") : atobPolyfill;
|
||
var _toUint8Array = _hasBuffer ? (a) => _U8Afrom(Buffer.from(a, "base64")) : (a) => _U8Afrom(_atob(a).split("").map((c) => c.charCodeAt(0)));
|
||
var toUint8Array = (a) => _toUint8Array(_unURI(a));
|
||
var _decode = _hasBuffer ? (a) => Buffer.from(a, "base64").toString("utf8") : _TD ? (a) => _TD.decode(_toUint8Array(a)) : (a) => btou(_atob(a));
|
||
var _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == "-" ? "+" : "/"));
|
||
var decode = (src) => _decode(_unURI(src));
|
||
var isValid = (src) => {
|
||
if (typeof src !== "string")
|
||
return false;
|
||
const s2 = src.replace(/\s+/g, "").replace(/={0,2}$/, "");
|
||
return !/[^\s0-9a-zA-Z\+/]/.test(s2) || !/[^\s0-9a-zA-Z\-_]/.test(s2);
|
||
};
|
||
var _noEnum = (v) => {
|
||
return {
|
||
value: v,
|
||
enumerable: false,
|
||
writable: true,
|
||
configurable: true
|
||
};
|
||
};
|
||
var extendString = function() {
|
||
const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
|
||
_add("fromBase64", function() {
|
||
return decode(this);
|
||
});
|
||
_add("toBase64", function(urlsafe) {
|
||
return encode(this, urlsafe);
|
||
});
|
||
_add("toBase64URI", function() {
|
||
return encode(this, true);
|
||
});
|
||
_add("toBase64URL", function() {
|
||
return encode(this, true);
|
||
});
|
||
_add("toUint8Array", function() {
|
||
return toUint8Array(this);
|
||
});
|
||
};
|
||
var extendUint8Array = function() {
|
||
const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
|
||
_add("toBase64", function(urlsafe) {
|
||
return fromUint8Array(this, urlsafe);
|
||
});
|
||
_add("toBase64URI", function() {
|
||
return fromUint8Array(this, true);
|
||
});
|
||
_add("toBase64URL", function() {
|
||
return fromUint8Array(this, true);
|
||
});
|
||
};
|
||
var extendBuiltins = () => {
|
||
extendString();
|
||
extendUint8Array();
|
||
};
|
||
var gBase64 = {
|
||
version,
|
||
VERSION,
|
||
atob: _atob,
|
||
atobPolyfill,
|
||
btoa: _btoa,
|
||
btoaPolyfill,
|
||
fromBase64: decode,
|
||
toBase64: encode,
|
||
encode,
|
||
encodeURI: encodeURI2,
|
||
encodeURL: encodeURI2,
|
||
utob,
|
||
btou,
|
||
decode,
|
||
isValid,
|
||
fromUint8Array,
|
||
toUint8Array,
|
||
extendString,
|
||
extendUint8Array,
|
||
extendBuiltins
|
||
};
|
||
|
||
// node_modules/universal-user-agent/dist-web/index.js
|
||
function getUserAgent() {
|
||
if (typeof navigator === "object" && "userAgent" in navigator) {
|
||
return navigator.userAgent;
|
||
}
|
||
if (typeof process === "object" && "version" in process) {
|
||
return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`;
|
||
}
|
||
return "<environment undetectable>";
|
||
}
|
||
|
||
// node_modules/@octokit/core/dist-web/index.js
|
||
var import_before_after_hook = __toESM(require_before_after_hook());
|
||
|
||
// node_modules/is-plain-object/dist/is-plain-object.mjs
|
||
function isObject(o) {
|
||
return Object.prototype.toString.call(o) === "[object Object]";
|
||
}
|
||
function isPlainObject(o) {
|
||
var ctor, prot;
|
||
if (isObject(o) === false)
|
||
return false;
|
||
ctor = o.constructor;
|
||
if (ctor === void 0)
|
||
return true;
|
||
prot = ctor.prototype;
|
||
if (isObject(prot) === false)
|
||
return false;
|
||
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
// node_modules/@octokit/endpoint/dist-web/index.js
|
||
var VERSION2 = "9.0.0";
|
||
var userAgent = `octokit-endpoint.js/${VERSION2} ${getUserAgent()}`;
|
||
var DEFAULTS = {
|
||
method: "GET",
|
||
baseUrl: "https://api.github.com",
|
||
headers: {
|
||
accept: "application/vnd.github.v3+json",
|
||
"user-agent": userAgent
|
||
},
|
||
mediaType: {
|
||
format: ""
|
||
}
|
||
};
|
||
function lowercaseKeys(object) {
|
||
if (!object) {
|
||
return {};
|
||
}
|
||
return Object.keys(object).reduce((newObj, key) => {
|
||
newObj[key.toLowerCase()] = object[key];
|
||
return newObj;
|
||
}, {});
|
||
}
|
||
function mergeDeep(defaults2, options) {
|
||
const result = Object.assign({}, defaults2);
|
||
Object.keys(options).forEach((key) => {
|
||
if (isPlainObject(options[key])) {
|
||
if (!(key in defaults2))
|
||
Object.assign(result, { [key]: options[key] });
|
||
else
|
||
result[key] = mergeDeep(defaults2[key], options[key]);
|
||
} else {
|
||
Object.assign(result, { [key]: options[key] });
|
||
}
|
||
});
|
||
return result;
|
||
}
|
||
function removeUndefinedProperties(obj) {
|
||
for (const key in obj) {
|
||
if (obj[key] === void 0) {
|
||
delete obj[key];
|
||
}
|
||
}
|
||
return obj;
|
||
}
|
||
function merge(defaults2, route, options) {
|
||
var _a2;
|
||
if (typeof route === "string") {
|
||
let [method, url] = route.split(" ");
|
||
options = Object.assign(url ? { method, url } : { url: method }, options);
|
||
} else {
|
||
options = Object.assign({}, route);
|
||
}
|
||
options.headers = lowercaseKeys(options.headers);
|
||
removeUndefinedProperties(options);
|
||
removeUndefinedProperties(options.headers);
|
||
const mergedOptions = mergeDeep(defaults2 || {}, options);
|
||
if (options.url === "/graphql") {
|
||
if (defaults2 && ((_a2 = defaults2.mediaType.previews) == null ? void 0 : _a2.length)) {
|
||
mergedOptions.mediaType.previews = defaults2.mediaType.previews.filter(
|
||
(preview) => !mergedOptions.mediaType.previews.includes(preview)
|
||
).concat(mergedOptions.mediaType.previews);
|
||
}
|
||
mergedOptions.mediaType.previews = (mergedOptions.mediaType.previews || []).map((preview) => preview.replace(/-preview/, ""));
|
||
}
|
||
return mergedOptions;
|
||
}
|
||
function addQueryParameters(url, parameters) {
|
||
const separator = /\?/.test(url) ? "&" : "?";
|
||
const names = Object.keys(parameters);
|
||
if (names.length === 0) {
|
||
return url;
|
||
}
|
||
return url + separator + names.map((name) => {
|
||
if (name === "q") {
|
||
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
||
}
|
||
return `${name}=${encodeURIComponent(parameters[name])}`;
|
||
}).join("&");
|
||
}
|
||
var urlVariableRegex = /\{[^}]+\}/g;
|
||
function removeNonChars(variableName) {
|
||
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
|
||
}
|
||
function extractUrlVariableNames(url) {
|
||
const matches = url.match(urlVariableRegex);
|
||
if (!matches) {
|
||
return [];
|
||
}
|
||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
||
}
|
||
function omit(object, keysToOmit) {
|
||
return Object.keys(object).filter((option) => !keysToOmit.includes(option)).reduce((obj, key) => {
|
||
obj[key] = object[key];
|
||
return obj;
|
||
}, {});
|
||
}
|
||
function encodeReserved(str) {
|
||
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) {
|
||
if (!/%[0-9A-Fa-f]/.test(part)) {
|
||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
||
}
|
||
return part;
|
||
}).join("");
|
||
}
|
||
function encodeUnreserved(str) {
|
||
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
||
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
||
});
|
||
}
|
||
function encodeValue(operator, value, key) {
|
||
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
|
||
if (key) {
|
||
return encodeUnreserved(key) + "=" + value;
|
||
} else {
|
||
return value;
|
||
}
|
||
}
|
||
function isDefined(value) {
|
||
return value !== void 0 && value !== null;
|
||
}
|
||
function isKeyOperator(operator) {
|
||
return operator === ";" || operator === "&" || operator === "?";
|
||
}
|
||
function getValues(context, operator, key, modifier) {
|
||
var value = context[key], result = [];
|
||
if (isDefined(value) && value !== "") {
|
||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||
value = value.toString();
|
||
if (modifier && modifier !== "*") {
|
||
value = value.substring(0, parseInt(modifier, 10));
|
||
}
|
||
result.push(
|
||
encodeValue(operator, value, isKeyOperator(operator) ? key : "")
|
||
);
|
||
} else {
|
||
if (modifier === "*") {
|
||
if (Array.isArray(value)) {
|
||
value.filter(isDefined).forEach(function(value2) {
|
||
result.push(
|
||
encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
|
||
);
|
||
});
|
||
} else {
|
||
Object.keys(value).forEach(function(k) {
|
||
if (isDefined(value[k])) {
|
||
result.push(encodeValue(operator, value[k], k));
|
||
}
|
||
});
|
||
}
|
||
} else {
|
||
const tmp = [];
|
||
if (Array.isArray(value)) {
|
||
value.filter(isDefined).forEach(function(value2) {
|
||
tmp.push(encodeValue(operator, value2));
|
||
});
|
||
} else {
|
||
Object.keys(value).forEach(function(k) {
|
||
if (isDefined(value[k])) {
|
||
tmp.push(encodeUnreserved(k));
|
||
tmp.push(encodeValue(operator, value[k].toString()));
|
||
}
|
||
});
|
||
}
|
||
if (isKeyOperator(operator)) {
|
||
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
||
} else if (tmp.length !== 0) {
|
||
result.push(tmp.join(","));
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
if (operator === ";") {
|
||
if (isDefined(value)) {
|
||
result.push(encodeUnreserved(key));
|
||
}
|
||
} else if (value === "" && (operator === "&" || operator === "?")) {
|
||
result.push(encodeUnreserved(key) + "=");
|
||
} else if (value === "") {
|
||
result.push("");
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
function parseUrl(template) {
|
||
return {
|
||
expand: expand.bind(null, template)
|
||
};
|
||
}
|
||
function expand(template, context) {
|
||
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
||
return template.replace(
|
||
/\{([^\{\}]+)\}|([^\{\}]+)/g,
|
||
function(_, expression, literal) {
|
||
if (expression) {
|
||
let operator = "";
|
||
const values = [];
|
||
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
||
operator = expression.charAt(0);
|
||
expression = expression.substr(1);
|
||
}
|
||
expression.split(/,/g).forEach(function(variable) {
|
||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
||
});
|
||
if (operator && operator !== "+") {
|
||
var separator = ",";
|
||
if (operator === "?") {
|
||
separator = "&";
|
||
} else if (operator !== "#") {
|
||
separator = operator;
|
||
}
|
||
return (values.length !== 0 ? operator : "") + values.join(separator);
|
||
} else {
|
||
return values.join(",");
|
||
}
|
||
} else {
|
||
return encodeReserved(literal);
|
||
}
|
||
}
|
||
);
|
||
}
|
||
function parse2(options) {
|
||
var _a2;
|
||
let method = options.method.toUpperCase();
|
||
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
||
let headers = Object.assign({}, options.headers);
|
||
let body;
|
||
let parameters = omit(options, [
|
||
"method",
|
||
"baseUrl",
|
||
"url",
|
||
"headers",
|
||
"request",
|
||
"mediaType"
|
||
]);
|
||
const urlVariableNames = extractUrlVariableNames(url);
|
||
url = parseUrl(url).expand(parameters);
|
||
if (!/^http/.test(url)) {
|
||
url = options.baseUrl + url;
|
||
}
|
||
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl");
|
||
const remainingParameters = omit(parameters, omittedParameters);
|
||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
||
if (!isBinaryRequest) {
|
||
if (options.mediaType.format) {
|
||
headers.accept = headers.accept.split(/,/).map(
|
||
(format) => format.replace(
|
||
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,
|
||
`application/vnd$1$2.${options.mediaType.format}`
|
||
)
|
||
).join(",");
|
||
}
|
||
if (url.endsWith("/graphql")) {
|
||
if ((_a2 = options.mediaType.previews) == null ? void 0 : _a2.length) {
|
||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
|
||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
|
||
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
|
||
return `application/vnd.github.${preview}-preview${format}`;
|
||
}).join(",");
|
||
}
|
||
}
|
||
}
|
||
if (["GET", "HEAD"].includes(method)) {
|
||
url = addQueryParameters(url, remainingParameters);
|
||
} else {
|
||
if ("data" in remainingParameters) {
|
||
body = remainingParameters.data;
|
||
} else {
|
||
if (Object.keys(remainingParameters).length) {
|
||
body = remainingParameters;
|
||
}
|
||
}
|
||
}
|
||
if (!headers["content-type"] && typeof body !== "undefined") {
|
||
headers["content-type"] = "application/json; charset=utf-8";
|
||
}
|
||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
||
body = "";
|
||
}
|
||
return Object.assign(
|
||
{ method, url, headers },
|
||
typeof body !== "undefined" ? { body } : null,
|
||
options.request ? { request: options.request } : null
|
||
);
|
||
}
|
||
function endpointWithDefaults(defaults2, route, options) {
|
||
return parse2(merge(defaults2, route, options));
|
||
}
|
||
function withDefaults(oldDefaults, newDefaults) {
|
||
const DEFAULTS2 = merge(oldDefaults, newDefaults);
|
||
const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2);
|
||
return Object.assign(endpoint2, {
|
||
DEFAULTS: DEFAULTS2,
|
||
defaults: withDefaults.bind(null, DEFAULTS2),
|
||
merge: merge.bind(null, DEFAULTS2),
|
||
parse: parse2
|
||
});
|
||
}
|
||
var endpoint = withDefaults(null, DEFAULTS);
|
||
|
||
// node_modules/deprecation/dist-web/index.js
|
||
var Deprecation = class extends Error {
|
||
constructor(message) {
|
||
super(message);
|
||
if (Error.captureStackTrace) {
|
||
Error.captureStackTrace(this, this.constructor);
|
||
}
|
||
this.name = "Deprecation";
|
||
}
|
||
};
|
||
|
||
// node_modules/@octokit/request-error/dist-web/index.js
|
||
var import_once = __toESM(require_once());
|
||
var logOnceCode = (0, import_once.default)((deprecation) => console.warn(deprecation));
|
||
var logOnceHeaders = (0, import_once.default)((deprecation) => console.warn(deprecation));
|
||
var RequestError = class extends Error {
|
||
constructor(message, statusCode, options) {
|
||
super(message);
|
||
if (Error.captureStackTrace) {
|
||
Error.captureStackTrace(this, this.constructor);
|
||
}
|
||
this.name = "HttpError";
|
||
this.status = statusCode;
|
||
let headers;
|
||
if ("headers" in options && typeof options.headers !== "undefined") {
|
||
headers = options.headers;
|
||
}
|
||
if ("response" in options) {
|
||
this.response = options.response;
|
||
headers = options.response.headers;
|
||
}
|
||
const requestCopy = Object.assign({}, options.request);
|
||
if (options.request.headers.authorization) {
|
||
requestCopy.headers = Object.assign({}, options.request.headers, {
|
||
authorization: options.request.headers.authorization.replace(
|
||
/ .*$/,
|
||
" [REDACTED]"
|
||
)
|
||
});
|
||
}
|
||
requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
||
this.request = requestCopy;
|
||
Object.defineProperty(this, "code", {
|
||
get() {
|
||
logOnceCode(
|
||
new Deprecation(
|
||
"[@octokit/request-error] `error.code` is deprecated, use `error.status`."
|
||
)
|
||
);
|
||
return statusCode;
|
||
}
|
||
});
|
||
Object.defineProperty(this, "headers", {
|
||
get() {
|
||
logOnceHeaders(
|
||
new Deprecation(
|
||
"[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`."
|
||
)
|
||
);
|
||
return headers || {};
|
||
}
|
||
});
|
||
}
|
||
};
|
||
|
||
// node_modules/@octokit/request/dist-web/index.js
|
||
var VERSION3 = "8.1.1";
|
||
function getBufferResponse(response) {
|
||
return response.arrayBuffer();
|
||
}
|
||
function fetchWrapper(requestOptions) {
|
||
var _a2, _b, _c;
|
||
const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console;
|
||
const parseSuccessResponseBody = ((_a2 = requestOptions.request) == null ? void 0 : _a2.parseSuccessResponseBody) !== false;
|
||
if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {
|
||
requestOptions.body = JSON.stringify(requestOptions.body);
|
||
}
|
||
let headers = {};
|
||
let status;
|
||
let url;
|
||
let { fetch } = globalThis;
|
||
if ((_b = requestOptions.request) == null ? void 0 : _b.fetch) {
|
||
fetch = requestOptions.request.fetch;
|
||
}
|
||
if (!fetch) {
|
||
throw new Error(
|
||
"fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing"
|
||
);
|
||
}
|
||
return fetch(requestOptions.url, __spreadValues({
|
||
method: requestOptions.method,
|
||
body: requestOptions.body,
|
||
headers: requestOptions.headers,
|
||
signal: (_c = requestOptions.request) == null ? void 0 : _c.signal
|
||
}, requestOptions.body && { duplex: "half" })).then((response) => __async(this, null, function* () {
|
||
url = response.url;
|
||
status = response.status;
|
||
for (const keyAndValue of response.headers) {
|
||
headers[keyAndValue[0]] = keyAndValue[1];
|
||
}
|
||
if ("deprecation" in headers) {
|
||
const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/);
|
||
const deprecationLink = matches && matches.pop();
|
||
log.warn(
|
||
`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`
|
||
);
|
||
}
|
||
if (status === 204 || status === 205) {
|
||
return;
|
||
}
|
||
if (requestOptions.method === "HEAD") {
|
||
if (status < 400) {
|
||
return;
|
||
}
|
||
throw new RequestError(response.statusText, status, {
|
||
response: {
|
||
url,
|
||
status,
|
||
headers,
|
||
data: void 0
|
||
},
|
||
request: requestOptions
|
||
});
|
||
}
|
||
if (status === 304) {
|
||
throw new RequestError("Not modified", status, {
|
||
response: {
|
||
url,
|
||
status,
|
||
headers,
|
||
data: yield getResponseData(response)
|
||
},
|
||
request: requestOptions
|
||
});
|
||
}
|
||
if (status >= 400) {
|
||
const data = yield getResponseData(response);
|
||
const error = new RequestError(toErrorMessage(data), status, {
|
||
response: {
|
||
url,
|
||
status,
|
||
headers,
|
||
data
|
||
},
|
||
request: requestOptions
|
||
});
|
||
throw error;
|
||
}
|
||
return parseSuccessResponseBody ? yield getResponseData(response) : response.body;
|
||
})).then((data) => {
|
||
return {
|
||
status,
|
||
url,
|
||
headers,
|
||
data
|
||
};
|
||
}).catch((error) => {
|
||
if (error instanceof RequestError)
|
||
throw error;
|
||
else if (error.name === "AbortError")
|
||
throw error;
|
||
throw new RequestError(error.message, 500, {
|
||
request: requestOptions
|
||
});
|
||
});
|
||
}
|
||
function getResponseData(response) {
|
||
return __async(this, null, function* () {
|
||
const contentType = response.headers.get("content-type");
|
||
if (/application\/json/.test(contentType)) {
|
||
return response.json();
|
||
}
|
||
if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
|
||
return response.text();
|
||
}
|
||
return getBufferResponse(response);
|
||
});
|
||
}
|
||
function toErrorMessage(data) {
|
||
if (typeof data === "string")
|
||
return data;
|
||
if ("message" in data) {
|
||
if (Array.isArray(data.errors)) {
|
||
return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}`;
|
||
}
|
||
return data.message;
|
||
}
|
||
return `Unknown error: ${JSON.stringify(data)}`;
|
||
}
|
||
function withDefaults2(oldEndpoint, newDefaults) {
|
||
const endpoint2 = oldEndpoint.defaults(newDefaults);
|
||
const newApi = function(route, parameters) {
|
||
const endpointOptions = endpoint2.merge(route, parameters);
|
||
if (!endpointOptions.request || !endpointOptions.request.hook) {
|
||
return fetchWrapper(endpoint2.parse(endpointOptions));
|
||
}
|
||
const request2 = (route2, parameters2) => {
|
||
return fetchWrapper(
|
||
endpoint2.parse(endpoint2.merge(route2, parameters2))
|
||
);
|
||
};
|
||
Object.assign(request2, {
|
||
endpoint: endpoint2,
|
||
defaults: withDefaults2.bind(null, endpoint2)
|
||
});
|
||
return endpointOptions.request.hook(request2, endpointOptions);
|
||
};
|
||
return Object.assign(newApi, {
|
||
endpoint: endpoint2,
|
||
defaults: withDefaults2.bind(null, endpoint2)
|
||
});
|
||
}
|
||
var request = withDefaults2(endpoint, {
|
||
headers: {
|
||
"user-agent": `octokit-request.js/${VERSION3} ${getUserAgent()}`
|
||
}
|
||
});
|
||
|
||
// node_modules/@octokit/graphql/dist-web/index.js
|
||
var VERSION4 = "7.0.1";
|
||
function _buildMessageForResponseErrors(data) {
|
||
return `Request failed due to following response errors:
|
||
` + data.errors.map((e) => ` - ${e.message}`).join("\n");
|
||
}
|
||
var GraphqlResponseError = class extends Error {
|
||
constructor(request2, headers, response) {
|
||
super(_buildMessageForResponseErrors(response));
|
||
this.request = request2;
|
||
this.headers = headers;
|
||
this.response = response;
|
||
this.name = "GraphqlResponseError";
|
||
this.errors = response.errors;
|
||
this.data = response.data;
|
||
if (Error.captureStackTrace) {
|
||
Error.captureStackTrace(this, this.constructor);
|
||
}
|
||
}
|
||
};
|
||
var NON_VARIABLE_OPTIONS = [
|
||
"method",
|
||
"baseUrl",
|
||
"url",
|
||
"headers",
|
||
"request",
|
||
"query",
|
||
"mediaType"
|
||
];
|
||
var FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
|
||
var GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
||
function graphql(request2, query, options) {
|
||
if (options) {
|
||
if (typeof query === "string" && "query" in options) {
|
||
return Promise.reject(
|
||
new Error(`[@octokit/graphql] "query" cannot be used as variable name`)
|
||
);
|
||
}
|
||
for (const key in options) {
|
||
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
|
||
continue;
|
||
return Promise.reject(
|
||
new Error(
|
||
`[@octokit/graphql] "${key}" cannot be used as variable name`
|
||
)
|
||
);
|
||
}
|
||
}
|
||
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
|
||
const requestOptions = Object.keys(
|
||
parsedOptions
|
||
).reduce((result, key) => {
|
||
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
||
result[key] = parsedOptions[key];
|
||
return result;
|
||
}
|
||
if (!result.variables) {
|
||
result.variables = {};
|
||
}
|
||
result.variables[key] = parsedOptions[key];
|
||
return result;
|
||
}, {});
|
||
const baseUrl = parsedOptions.baseUrl || request2.endpoint.DEFAULTS.baseUrl;
|
||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
||
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
||
}
|
||
return request2(requestOptions).then((response) => {
|
||
if (response.data.errors) {
|
||
const headers = {};
|
||
for (const key of Object.keys(response.headers)) {
|
||
headers[key] = response.headers[key];
|
||
}
|
||
throw new GraphqlResponseError(
|
||
requestOptions,
|
||
headers,
|
||
response.data
|
||
);
|
||
}
|
||
return response.data.data;
|
||
});
|
||
}
|
||
function withDefaults3(request2, newDefaults) {
|
||
const newRequest = request2.defaults(newDefaults);
|
||
const newApi = (query, options) => {
|
||
return graphql(newRequest, query, options);
|
||
};
|
||
return Object.assign(newApi, {
|
||
defaults: withDefaults3.bind(null, newRequest),
|
||
endpoint: newRequest.endpoint
|
||
});
|
||
}
|
||
var graphql2 = withDefaults3(request, {
|
||
headers: {
|
||
"user-agent": `octokit-graphql.js/${VERSION4} ${getUserAgent()}`
|
||
},
|
||
method: "POST",
|
||
url: "/graphql"
|
||
});
|
||
function withCustomRequest(customRequest) {
|
||
return withDefaults3(customRequest, {
|
||
method: "POST",
|
||
url: "/graphql"
|
||
});
|
||
}
|
||
|
||
// node_modules/@octokit/auth-token/dist-web/index.js
|
||
var REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
|
||
var REGEX_IS_INSTALLATION = /^ghs_/;
|
||
var REGEX_IS_USER_TO_SERVER = /^ghu_/;
|
||
function auth(token) {
|
||
return __async(this, null, function* () {
|
||
const isApp = token.split(/\./).length === 3;
|
||
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);
|
||
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
|
||
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
||
return {
|
||
type: "token",
|
||
token,
|
||
tokenType
|
||
};
|
||
});
|
||
}
|
||
function withAuthorizationPrefix(token) {
|
||
if (token.split(/\./).length === 3) {
|
||
return `bearer ${token}`;
|
||
}
|
||
return `token ${token}`;
|
||
}
|
||
function hook(token, request2, route, parameters) {
|
||
return __async(this, null, function* () {
|
||
const endpoint2 = request2.endpoint.merge(
|
||
route,
|
||
parameters
|
||
);
|
||
endpoint2.headers.authorization = withAuthorizationPrefix(token);
|
||
return request2(endpoint2);
|
||
});
|
||
}
|
||
var createTokenAuth = function createTokenAuth2(token) {
|
||
if (!token) {
|
||
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
||
}
|
||
if (typeof token !== "string") {
|
||
throw new Error(
|
||
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
||
);
|
||
}
|
||
token = token.replace(/^(token|bearer) +/i, "");
|
||
return Object.assign(auth.bind(null, token), {
|
||
hook: hook.bind(null, token)
|
||
});
|
||
};
|
||
|
||
// node_modules/@octokit/core/dist-web/index.js
|
||
var VERSION5 = "5.0.0";
|
||
var _a;
|
||
var Octokit = (_a = class {
|
||
static defaults(defaults2) {
|
||
const OctokitWithDefaults = class extends this {
|
||
constructor(...args) {
|
||
const options = args[0] || {};
|
||
if (typeof defaults2 === "function") {
|
||
super(defaults2(options));
|
||
return;
|
||
}
|
||
super(
|
||
Object.assign(
|
||
{},
|
||
defaults2,
|
||
options,
|
||
options.userAgent && defaults2.userAgent ? {
|
||
userAgent: `${options.userAgent} ${defaults2.userAgent}`
|
||
} : null
|
||
)
|
||
);
|
||
}
|
||
};
|
||
return OctokitWithDefaults;
|
||
}
|
||
/**
|
||
* Attach a plugin (or many) to your Octokit instance.
|
||
*
|
||
* @example
|
||
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
||
*/
|
||
static plugin(...newPlugins) {
|
||
var _a2;
|
||
const currentPlugins = this.plugins;
|
||
const NewOctokit = (_a2 = class extends this {
|
||
}, _a2.plugins = currentPlugins.concat(
|
||
newPlugins.filter((plugin) => !currentPlugins.includes(plugin))
|
||
), _a2);
|
||
return NewOctokit;
|
||
}
|
||
constructor(options = {}) {
|
||
const hook2 = new import_before_after_hook.Collection();
|
||
const requestDefaults = {
|
||
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
||
headers: {},
|
||
request: Object.assign({}, options.request, {
|
||
// @ts-ignore internal usage only, no need to type
|
||
hook: hook2.bind(null, "request")
|
||
}),
|
||
mediaType: {
|
||
previews: [],
|
||
format: ""
|
||
}
|
||
};
|
||
requestDefaults.headers["user-agent"] = [
|
||
options.userAgent,
|
||
`octokit-core.js/${VERSION5} ${getUserAgent()}`
|
||
].filter(Boolean).join(" ");
|
||
if (options.baseUrl) {
|
||
requestDefaults.baseUrl = options.baseUrl;
|
||
}
|
||
if (options.previews) {
|
||
requestDefaults.mediaType.previews = options.previews;
|
||
}
|
||
if (options.timeZone) {
|
||
requestDefaults.headers["time-zone"] = options.timeZone;
|
||
}
|
||
this.request = request.defaults(requestDefaults);
|
||
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
||
this.log = Object.assign(
|
||
{
|
||
debug: () => {
|
||
},
|
||
info: () => {
|
||
},
|
||
warn: console.warn.bind(console),
|
||
error: console.error.bind(console)
|
||
},
|
||
options.log
|
||
);
|
||
this.hook = hook2;
|
||
if (!options.authStrategy) {
|
||
if (!options.auth) {
|
||
this.auth = () => __async(this, null, function* () {
|
||
return {
|
||
type: "unauthenticated"
|
||
};
|
||
});
|
||
} else {
|
||
const auth2 = createTokenAuth(options.auth);
|
||
hook2.wrap("request", auth2.hook);
|
||
this.auth = auth2;
|
||
}
|
||
} else {
|
||
const _a2 = options, { authStrategy } = _a2, otherOptions = __objRest(_a2, ["authStrategy"]);
|
||
const auth2 = authStrategy(
|
||
Object.assign(
|
||
{
|
||
request: this.request,
|
||
log: this.log,
|
||
// we pass the current octokit instance as well as its constructor options
|
||
// to allow for authentication strategies that return a new octokit instance
|
||
// that shares the same internal state as the current one. The original
|
||
// requirement for this was the "event-octokit" authentication strategy
|
||
// of https://github.com/probot/octokit-auth-probot.
|
||
octokit: this,
|
||
octokitOptions: otherOptions
|
||
},
|
||
options.auth
|
||
)
|
||
);
|
||
hook2.wrap("request", auth2.hook);
|
||
this.auth = auth2;
|
||
}
|
||
const classConstructor = this.constructor;
|
||
classConstructor.plugins.forEach((plugin) => {
|
||
Object.assign(this, plugin(this, options));
|
||
});
|
||
}
|
||
}, _a.VERSION = VERSION5, _a.plugins = [], _a);
|
||
|
||
// src/publisher/Publisher.ts
|
||
var import_lz_string = __toESM(require_lz_string());
|
||
|
||
// src/utils/utils.ts
|
||
var import_slugify = __toESM(require_slugify());
|
||
var import_sha1 = __toESM(require_sha1());
|
||
var REWRITE_RULE_DELIMITER = ":";
|
||
function arrayBufferToBase64(buffer) {
|
||
let binary = "";
|
||
const bytes = new Uint8Array(buffer);
|
||
const len = bytes.byteLength;
|
||
for (let i = 0; i < len; i++) {
|
||
binary += String.fromCharCode(bytes[i]);
|
||
}
|
||
return gBase64.btoa(binary);
|
||
}
|
||
function extractBaseUrl(url) {
|
||
return url && url.replace("https://", "").replace("http://", "").replace(/\/$/, "");
|
||
}
|
||
function generateUrlPath(filePath, slugifyPath = true) {
|
||
if (!filePath) {
|
||
return filePath;
|
||
}
|
||
const extensionLessPath = filePath.substring(0, filePath.lastIndexOf("."));
|
||
if (!slugifyPath) {
|
||
return extensionLessPath + "/";
|
||
}
|
||
return extensionLessPath.split("/").map((x) => (0, import_slugify.default)(x)).join("/") + "/";
|
||
}
|
||
function generateBlobHash(content) {
|
||
const byteLength = new TextEncoder().encode(content).byteLength;
|
||
const header = `blob ${byteLength}\0`;
|
||
const gitBlob = header + content;
|
||
return (0, import_sha1.default)(gitBlob).toString();
|
||
}
|
||
function kebabize(str) {
|
||
return str.split("").map((letter, idx) => {
|
||
return letter.toUpperCase() === letter ? `${idx !== 0 ? "-" : ""}${letter.toLowerCase()}` : letter;
|
||
}).join("");
|
||
}
|
||
var wrapAround = (value, size) => {
|
||
return (value % size + size) % size;
|
||
};
|
||
function getRewriteRules(pathRewriteRules) {
|
||
return pathRewriteRules.split("\n").filter((line) => line.includes(REWRITE_RULE_DELIMITER)).map((line) => {
|
||
const [searchPath, newPath] = line.split(REWRITE_RULE_DELIMITER);
|
||
return { from: searchPath, to: newPath };
|
||
});
|
||
}
|
||
function getGardenPathForNote(vaultPath, rules) {
|
||
for (const { from, to } of rules) {
|
||
if (vaultPath.startsWith(from)) {
|
||
const newPath = vaultPath.replace(from, to);
|
||
if (newPath.startsWith("/")) {
|
||
return newPath.replace("/", "");
|
||
}
|
||
return newPath;
|
||
}
|
||
}
|
||
return vaultPath;
|
||
}
|
||
function escapeRegExp(string) {
|
||
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||
}
|
||
function fixSvgForXmlSerializer(svgElement) {
|
||
var _a2;
|
||
const styles = svgElement.getElementsByTagName("style");
|
||
if (styles.length > 0) {
|
||
for (let i = 0; i < styles.length; i++) {
|
||
const style = styles[i];
|
||
if (!((_a2 = style.textContent) == null ? void 0 : _a2.trim())) {
|
||
style.textContent = "/**/";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function sanitizePermalink(permalink) {
|
||
if (!permalink.endsWith("/")) {
|
||
permalink += "/";
|
||
}
|
||
if (!permalink.startsWith("/")) {
|
||
permalink = "/" + permalink;
|
||
}
|
||
return permalink;
|
||
}
|
||
|
||
// src/publisher/Validator.ts
|
||
var import_obsidian = require("obsidian");
|
||
function isPublishFrontmatterValid(frontMatter) {
|
||
if (!frontMatter || !frontMatter["dg-publish"]) {
|
||
new import_obsidian.Notice(
|
||
"Note does not have the dg-publish: true set. Please add this and try again."
|
||
);
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
// src/ui/suggest/constants.ts
|
||
var seedling = `<g style="pointer-events:all"><title style="pointer-events: none" opacity="0.33">Layer 1</title><g id="hair" style="pointer-events: none" opacity="0.33"></g><g id="skin" style="pointer-events: none" opacity="0.33"></g><g id="skin-shadow" style="pointer-events: none" opacity="0.33"></g><g id="line"><path fill="currentColor" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2" d="M47.71119,35.9247" id="svg_3"></path><polyline fill="currentColor" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="49.813106536865234,93.05191133916378 49.813106536865234,69.57996462285519 40.03312683105469,26.548054680228233 " id="svg_4"></polyline><line x1="49.81311" x2="59.59309" y1="69.57996" y2="50.02" fill="currentColor" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" id="svg_5"></line><path fill="currentColor" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M27.99666,14.21103C35.9517,16.94766 39.92393,26.36911 39.92393,26.36911S30.99696,31.3526 23.04075,28.61655S11.11348,16.45847 11.11348,16.45847S20.04456,11.4789 27.99666,14.21103z" id="svg_6"></path><path fill="currentColor" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M76.46266698455811,45.61669603088379 C84.67706698455811,47.43146603088379 89.6945869845581,56.34024603088379 89.6945869845581,56.34024603088379 S81.3917769845581,62.30603603088379 73.17639698455811,60.492046030883785 S59.94447698455811,49.768496030883796 59.94447698455811,49.768496030883796 S68.2515869845581,43.80622603088379 76.46266698455811,45.61669603088379 z" id="svg_7"></path></g></g>`;
|
||
var excaliDrawBundle = `<style> .container {font-family: sans-serif; text-align: center;} .button-wrapper button {z-index: 1;height: 40px; width: 100px; margin: 10px;padding: 5px;} .excalidraw .App-menu_top .buttonList { display: flex;} .excalidraw-wrapper { height: 800px; margin: 50px; position: relative;} :root[dir="ltr"] .excalidraw .layer-ui__wrapper .zen-mode-transition.App-menu_bottom--transition-left {transform: none;} </style><script src="https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js"><\/script><script src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.production.min.js"><\/script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@excalidraw/excalidraw@0/dist/excalidraw.production.min.js"><\/script>`;
|
||
var excalidraw = (excaliDrawJson, drawingId) => `<div id="${drawingId}"></div><script>(function(){const InitialData=${excaliDrawJson};InitialData.scrollToContent=true;App=()=>{const e=React.useRef(null),t=React.useRef(null),[n,i]=React.useState({width:void 0,height:void 0});return React.useEffect(()=>{i({width:t.current.getBoundingClientRect().width,height:t.current.getBoundingClientRect().height});const e=()=>{i({width:t.current.getBoundingClientRect().width,height:t.current.getBoundingClientRect().height})};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[t]),React.createElement(React.Fragment,null,React.createElement("div",{className:"excalidraw-wrapper",ref:t},React.createElement(ExcalidrawLib.Excalidraw,{ref:e,width:n.width,height:n.height,initialData:InitialData,viewModeEnabled:!0,zenModeEnabled:!0,gridModeEnabled:!1})))},excalidrawWrapper=document.getElementById("${drawingId}");ReactDOM.render(React.createElement(App),excalidrawWrapper);})();<\/script>`;
|
||
|
||
// src/publisher/Publisher.ts
|
||
var import_slugify2 = __toESM(require_slugify());
|
||
|
||
// src/utils/markdown.ts
|
||
var seperateHashesFromHeader = (rawHeading) => {
|
||
const regex = new RegExp("^(?<hashes>#+)(?<space>\\s?)(?<title>.*)$");
|
||
const matches = rawHeading.match(regex);
|
||
if (matches == null ? void 0 : matches.groups) {
|
||
const { hashes, _space, title } = matches.groups;
|
||
return {
|
||
hashes,
|
||
title
|
||
};
|
||
}
|
||
return { hashes: "#", title: rawHeading.trim() };
|
||
};
|
||
var fixMarkdownHeaderSyntax = (rawHeading) => {
|
||
const { hashes, title } = seperateHashesFromHeader(rawHeading);
|
||
return `${hashes} ${title}`;
|
||
};
|
||
|
||
// src/publisher/Publisher.ts
|
||
var Publisher = class {
|
||
constructor(vault, metadataCache, settings) {
|
||
this.frontmatterRegex = /^\s*?---\n([\s\S]*?)\n---/g;
|
||
this.blockrefRegex = /(\^\w+(\n|$))/g;
|
||
this.codeFenceRegex = /`(.*?)`/g;
|
||
this.codeBlockRegex = /```.*?\n[\s\S]+?```/g;
|
||
this.excaliDrawRegex = /:\[\[(\d*?,\d*?)\],.*?\]\]/g;
|
||
this.vault = vault;
|
||
this.metadataCache = metadataCache;
|
||
this.settings = settings;
|
||
this.rewriteRules = getRewriteRules(settings.pathRewriteRules);
|
||
}
|
||
getFilesMarkedForPublishing() {
|
||
return __async(this, null, function* () {
|
||
var _a2;
|
||
const files = this.vault.getMarkdownFiles();
|
||
const notesToPublish = [];
|
||
const imagesToPublish = /* @__PURE__ */ new Set();
|
||
for (const file of files) {
|
||
try {
|
||
const frontMatter = (_a2 = this.metadataCache.getCache(file.path)) == null ? void 0 : _a2.frontmatter;
|
||
if (frontMatter && frontMatter["dg-publish"] === true) {
|
||
notesToPublish.push(file);
|
||
const images = yield this.extractImageLinks(
|
||
yield this.vault.cachedRead(file),
|
||
file.path
|
||
);
|
||
images.forEach((i) => imagesToPublish.add(i));
|
||
}
|
||
} catch (e) {
|
||
}
|
||
}
|
||
return {
|
||
notes: notesToPublish,
|
||
images: Array.from(imagesToPublish)
|
||
};
|
||
});
|
||
}
|
||
deleteNote(vaultFilePath) {
|
||
return __async(this, null, function* () {
|
||
const path = `src/site/notes/${vaultFilePath}`;
|
||
return yield this.delete(path);
|
||
});
|
||
}
|
||
deleteImage(vaultFilePath) {
|
||
return __async(this, null, function* () {
|
||
const path = `src/site/img/user/${encodeURI(vaultFilePath)}`;
|
||
return yield this.delete(path);
|
||
});
|
||
}
|
||
delete(path) {
|
||
return __async(this, null, function* () {
|
||
if (!this.settings.githubRepo) {
|
||
new import_obsidian2.Notice(
|
||
"Config error: You need to define a GitHub repo in the plugin settings"
|
||
);
|
||
throw {};
|
||
}
|
||
if (!this.settings.githubUserName) {
|
||
new import_obsidian2.Notice(
|
||
"Config error: You need to define a GitHub Username in the plugin settings"
|
||
);
|
||
throw {};
|
||
}
|
||
if (!this.settings.githubToken) {
|
||
new import_obsidian2.Notice(
|
||
"Config error: You need to define a GitHub Token in the plugin settings"
|
||
);
|
||
throw {};
|
||
}
|
||
const octokit = new Octokit({ auth: this.settings.githubToken });
|
||
const payload = {
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path,
|
||
message: `Delete content ${path}`,
|
||
sha: ""
|
||
};
|
||
try {
|
||
const response = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path
|
||
}
|
||
);
|
||
if (response.status === 200 && (response == null ? void 0 : response.data.type) === "file") {
|
||
payload.sha = response.data.sha;
|
||
}
|
||
} catch (e) {
|
||
console.log(e);
|
||
return false;
|
||
}
|
||
try {
|
||
yield octokit.request(
|
||
"DELETE /repos/{owner}/{repo}/contents/{path}",
|
||
payload
|
||
);
|
||
} catch (e) {
|
||
console.log(e);
|
||
return false;
|
||
}
|
||
return true;
|
||
});
|
||
}
|
||
publish(file) {
|
||
return __async(this, null, function* () {
|
||
var _a2;
|
||
if (!isPublishFrontmatterValid(
|
||
(_a2 = this.metadataCache.getCache(file.path)) == null ? void 0 : _a2.frontmatter
|
||
)) {
|
||
return false;
|
||
}
|
||
try {
|
||
const [text2, assets] = yield this.generateMarkdown(file);
|
||
yield this.uploadText(file.path, text2);
|
||
yield this.uploadAssets(assets);
|
||
return true;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
});
|
||
}
|
||
generateMarkdown(file) {
|
||
return __async(this, null, function* () {
|
||
this.rewriteRules = getRewriteRules(this.settings.pathRewriteRules);
|
||
const assets = { images: [] };
|
||
if (file.name.endsWith(".excalidraw.md")) {
|
||
return [yield this.generateExcalidrawMarkdown(file, true), assets];
|
||
}
|
||
let text2 = yield this.vault.cachedRead(file);
|
||
text2 = yield this.convertCustomFilters(text2);
|
||
text2 = yield this.convertFrontMatter(text2, file);
|
||
text2 = yield this.createBlockIDs(text2);
|
||
text2 = yield this.createTranscludedText(text2, file.path, 0);
|
||
text2 = yield this.convertDataViews(text2, file.path);
|
||
text2 = yield this.convertLinksToFullPath(text2, file.path);
|
||
text2 = yield this.removeObsidianComments(text2);
|
||
text2 = yield this.createSvgEmbeds(text2, file.path);
|
||
const text_and_images = yield this.convertImageLinks(text2, file.path);
|
||
return [text_and_images[0], { images: text_and_images[1] }];
|
||
});
|
||
}
|
||
convertCustomFilters(text2) {
|
||
return __async(this, null, function* () {
|
||
for (const filter2 of this.settings.customFilters) {
|
||
text2 = text2.replace(
|
||
RegExp(filter2.pattern, filter2.flags),
|
||
filter2.replace
|
||
);
|
||
}
|
||
return text2;
|
||
});
|
||
}
|
||
createBlockIDs(text2) {
|
||
return __async(this, null, function* () {
|
||
const block_pattern = / \^([\w\d-]+)/g;
|
||
const complex_block_pattern = /\n\^([\w\d-]+)\n/g;
|
||
text2 = text2.replace(
|
||
complex_block_pattern,
|
||
(match2, $1) => {
|
||
return `{ #${$1}}
|
||
|
||
`;
|
||
}
|
||
);
|
||
text2 = text2.replace(block_pattern, (match2, $1) => {
|
||
return `
|
||
{ #${$1}}
|
||
`;
|
||
});
|
||
return text2;
|
||
});
|
||
}
|
||
uploadToGithub(path, content) {
|
||
return __async(this, null, function* () {
|
||
if (!this.settings.githubRepo) {
|
||
new import_obsidian2.Notice(
|
||
"Config error: You need to define a GitHub repo in the plugin settings"
|
||
);
|
||
throw {};
|
||
}
|
||
if (!this.settings.githubUserName) {
|
||
new import_obsidian2.Notice(
|
||
"Config error: You need to define a GitHub Username in the plugin settings"
|
||
);
|
||
throw {};
|
||
}
|
||
if (!this.settings.githubToken) {
|
||
new import_obsidian2.Notice(
|
||
"Config error: You need to define a GitHub Token in the plugin settings"
|
||
);
|
||
throw {};
|
||
}
|
||
const octokit = new Octokit({ auth: this.settings.githubToken });
|
||
const payload = {
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path,
|
||
message: `Add content ${path}`,
|
||
content,
|
||
sha: ""
|
||
};
|
||
try {
|
||
const response = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path
|
||
}
|
||
);
|
||
if (response.status === 200 && response.data.type === "file") {
|
||
payload.sha = response.data.sha;
|
||
}
|
||
} catch (e) {
|
||
console.log(e);
|
||
}
|
||
payload.message = `Update content ${path}`;
|
||
yield octokit.request(
|
||
"PUT /repos/{owner}/{repo}/contents/{path}",
|
||
payload
|
||
);
|
||
});
|
||
}
|
||
uploadText(filePath, content) {
|
||
return __async(this, null, function* () {
|
||
content = gBase64.encode(content);
|
||
const path = `src/site/notes/${filePath}`;
|
||
yield this.uploadToGithub(path, content);
|
||
});
|
||
}
|
||
uploadImage(filePath, content) {
|
||
return __async(this, null, function* () {
|
||
const path = `src/site${filePath}`;
|
||
yield this.uploadToGithub(path, content);
|
||
});
|
||
}
|
||
uploadAssets(assets) {
|
||
return __async(this, null, function* () {
|
||
for (let idx = 0; idx < assets.images.length; idx++) {
|
||
const image = assets.images[idx];
|
||
yield this.uploadImage(image.path, image.content);
|
||
}
|
||
});
|
||
}
|
||
stripAwayCodeFencesAndFrontmatter(text2) {
|
||
let textToBeProcessed = text2;
|
||
textToBeProcessed = textToBeProcessed.replace(this.excaliDrawRegex, "");
|
||
textToBeProcessed = textToBeProcessed.replace(this.codeBlockRegex, "");
|
||
textToBeProcessed = textToBeProcessed.replace(this.codeFenceRegex, "");
|
||
textToBeProcessed = textToBeProcessed.replace(
|
||
this.frontmatterRegex,
|
||
""
|
||
);
|
||
return textToBeProcessed;
|
||
}
|
||
removeObsidianComments(text2) {
|
||
return __async(this, null, function* () {
|
||
const obsidianCommentsRegex = new RegExp("%%.+?%%", "gms");
|
||
const obsidianCommentsMatches = text2.match(obsidianCommentsRegex);
|
||
const codeBlocks = text2.match(this.codeBlockRegex) || [];
|
||
const codeFences = text2.match(this.codeFenceRegex) || [];
|
||
const excalidraw2 = text2.match(this.excaliDrawRegex) || [];
|
||
if (obsidianCommentsMatches) {
|
||
for (const commentMatch of obsidianCommentsMatches) {
|
||
if (codeBlocks.findIndex((x) => x.contains(commentMatch)) > -1) {
|
||
continue;
|
||
}
|
||
if (codeFences.findIndex((x) => x.contains(commentMatch)) > -1) {
|
||
continue;
|
||
}
|
||
if (excalidraw2.findIndex((x) => x.contains(commentMatch)) > -1) {
|
||
continue;
|
||
}
|
||
text2 = text2.replace(commentMatch, "");
|
||
}
|
||
}
|
||
return text2;
|
||
});
|
||
}
|
||
convertFrontMatter(text2, file) {
|
||
return __async(this, null, function* () {
|
||
const publishedFrontMatter = this.getProcessedFrontMatter(file);
|
||
const replaced = text2.replace(this.frontmatterRegex, (_match, _p1) => {
|
||
return publishedFrontMatter;
|
||
});
|
||
return replaced;
|
||
});
|
||
}
|
||
convertDataViews(text2, path) {
|
||
return __async(this, null, function* () {
|
||
let replacedText = text2;
|
||
const dataViewRegex = new RegExp("```dataview\\s(.+?)```", "gms");
|
||
const dvApi = (0, import_obsidian_dataview.getAPI)();
|
||
if (!dvApi)
|
||
return replacedText;
|
||
const matches = text2.matchAll(dataViewRegex);
|
||
const dataviewJsPrefix = dvApi.settings.dataviewJsKeyword;
|
||
const dataViewJsRegex = new RegExp(
|
||
"```" + escapeRegExp(dataviewJsPrefix) + "\\s(.+?)```",
|
||
"gsm"
|
||
);
|
||
const dataviewJsMatches = text2.matchAll(dataViewJsRegex);
|
||
const inlineQueryPrefix = dvApi.settings.inlineQueryPrefix;
|
||
const inlineDataViewRegex = new RegExp(
|
||
"`" + escapeRegExp(inlineQueryPrefix) + "(.+?)`",
|
||
"gsm"
|
||
);
|
||
const inlineMatches = text2.matchAll(inlineDataViewRegex);
|
||
const inlineJsQueryPrefix = dvApi.settings.inlineJsQueryPrefix;
|
||
const inlineJsDataViewRegex = new RegExp(
|
||
"`" + escapeRegExp(inlineJsQueryPrefix) + "(.+?)`",
|
||
"gsm"
|
||
);
|
||
const inlineJsMatches = text2.matchAll(inlineJsDataViewRegex);
|
||
if (!matches && !inlineMatches && !dataviewJsMatches && !inlineJsMatches) {
|
||
return text2;
|
||
}
|
||
for (const queryBlock of matches) {
|
||
try {
|
||
const block = queryBlock[0];
|
||
const query = queryBlock[1];
|
||
const markdown = yield dvApi.tryQueryMarkdown(query, path);
|
||
replacedText = replacedText.replace(
|
||
block,
|
||
`${markdown}
|
||
{ .block-language-dataview}`
|
||
);
|
||
} catch (e) {
|
||
console.log(e);
|
||
new import_obsidian2.Notice(
|
||
"Unable to render dataview query. Please update the dataview plugin to the latest version."
|
||
);
|
||
return queryBlock[0];
|
||
}
|
||
}
|
||
for (const queryBlock of dataviewJsMatches) {
|
||
try {
|
||
const block = queryBlock[0];
|
||
const query = queryBlock[1];
|
||
const div = createEl("div");
|
||
const component = new import_obsidian2.Component();
|
||
yield dvApi.executeJs(query, div, component, path);
|
||
component.load();
|
||
replacedText = replacedText.replace(block, div.innerHTML);
|
||
} catch (e) {
|
||
console.log(e);
|
||
new import_obsidian2.Notice(
|
||
"Unable to render dataviewjs query. Please update the dataview plugin to the latest version."
|
||
);
|
||
return queryBlock[0];
|
||
}
|
||
}
|
||
for (const inlineQuery of inlineMatches) {
|
||
try {
|
||
const code = inlineQuery[0];
|
||
const query = inlineQuery[1];
|
||
const dataviewResult = dvApi.tryEvaluate(query, {
|
||
// @ts-expect-error errors are caught
|
||
this: dvApi.page(path)
|
||
});
|
||
if (dataviewResult) {
|
||
replacedText = replacedText.replace(
|
||
code,
|
||
// @ts-expect-error errors are caught
|
||
dataviewResult.toString()
|
||
);
|
||
}
|
||
} catch (e) {
|
||
console.log(e);
|
||
new import_obsidian2.Notice(
|
||
"Unable to render inline dataview query. Please update the dataview plugin to the latest version."
|
||
);
|
||
return inlineQuery[0];
|
||
}
|
||
}
|
||
for (const inlineJsQuery of inlineJsMatches) {
|
||
try {
|
||
const code = inlineJsQuery[0];
|
||
const query = inlineJsQuery[1];
|
||
const div = createEl("div");
|
||
const component = new import_obsidian2.Component();
|
||
yield dvApi.executeJs(query, div, component, path);
|
||
component.load();
|
||
replacedText = replacedText.replace(code, div.innerHTML);
|
||
} catch (e) {
|
||
console.log(e);
|
||
new import_obsidian2.Notice(
|
||
"Unable to render inline dataviewjs query. Please update the dataview plugin to the latest version."
|
||
);
|
||
return inlineJsQuery[0];
|
||
}
|
||
}
|
||
return replacedText;
|
||
});
|
||
}
|
||
getProcessedFrontMatter(file) {
|
||
var _a2;
|
||
const fileFrontMatter = __spreadValues({}, (_a2 = this.metadataCache.getCache(file.path)) == null ? void 0 : _a2.frontmatter);
|
||
delete fileFrontMatter["position"];
|
||
let publishedFrontMatter = {
|
||
"dg-publish": true
|
||
};
|
||
publishedFrontMatter = this.addPermalink(
|
||
fileFrontMatter,
|
||
publishedFrontMatter,
|
||
file.path
|
||
);
|
||
publishedFrontMatter = this.addDefaultPassThrough(
|
||
fileFrontMatter,
|
||
publishedFrontMatter
|
||
);
|
||
publishedFrontMatter = this.addContentClasses(
|
||
fileFrontMatter,
|
||
publishedFrontMatter
|
||
);
|
||
publishedFrontMatter = this.addPageTags(
|
||
fileFrontMatter,
|
||
publishedFrontMatter
|
||
);
|
||
publishedFrontMatter = this.addFrontMatterSettings(
|
||
fileFrontMatter,
|
||
publishedFrontMatter
|
||
);
|
||
publishedFrontMatter = this.addNoteIconFrontMatter(
|
||
fileFrontMatter,
|
||
publishedFrontMatter
|
||
);
|
||
publishedFrontMatter = this.addTimestampsFrontmatter(
|
||
fileFrontMatter,
|
||
publishedFrontMatter,
|
||
file
|
||
);
|
||
const fullFrontMatter = (publishedFrontMatter == null ? void 0 : publishedFrontMatter.dgPassFrontmatter) ? __spreadValues(__spreadValues({}, fileFrontMatter), publishedFrontMatter) : publishedFrontMatter;
|
||
const frontMatterString = JSON.stringify(fullFrontMatter);
|
||
return `---
|
||
${frontMatterString}
|
||
---
|
||
`;
|
||
}
|
||
addDefaultPassThrough(baseFrontMatter, newFrontMatter) {
|
||
const publishedFrontMatter = __spreadValues({}, newFrontMatter);
|
||
if (baseFrontMatter) {
|
||
if (baseFrontMatter["title"]) {
|
||
publishedFrontMatter["title"] = baseFrontMatter["title"];
|
||
}
|
||
if (baseFrontMatter["dg-metatags"]) {
|
||
publishedFrontMatter["metatags"] = baseFrontMatter["dg-metatags"];
|
||
}
|
||
if (baseFrontMatter["dg-hide"]) {
|
||
publishedFrontMatter["hide"] = baseFrontMatter["dg-hide"];
|
||
}
|
||
if (baseFrontMatter["dg-hide-in-graph"]) {
|
||
publishedFrontMatter["hideInGraph"] = baseFrontMatter["dg-hide-in-graph"];
|
||
}
|
||
if (baseFrontMatter["dg-pinned"]) {
|
||
publishedFrontMatter["pinned"] = baseFrontMatter["dg-pinned"];
|
||
}
|
||
}
|
||
return publishedFrontMatter;
|
||
}
|
||
addPermalink(baseFrontMatter, newFrontMatter, filePath) {
|
||
const publishedFrontMatter = __spreadValues({}, newFrontMatter);
|
||
const gardenPath = baseFrontMatter && baseFrontMatter["dg-path"] ? baseFrontMatter["dg-path"] : getGardenPathForNote(filePath, this.rewriteRules);
|
||
if (gardenPath != filePath) {
|
||
publishedFrontMatter["dg-path"] = gardenPath;
|
||
}
|
||
if (baseFrontMatter && baseFrontMatter["dg-permalink"]) {
|
||
publishedFrontMatter["dg-permalink"] = baseFrontMatter["dg-permalink"];
|
||
publishedFrontMatter["permalink"] = sanitizePermalink(
|
||
baseFrontMatter["dg-permalink"]
|
||
);
|
||
} else {
|
||
publishedFrontMatter["permalink"] = "/" + generateUrlPath(gardenPath, this.settings.slugifyEnabled);
|
||
}
|
||
return publishedFrontMatter;
|
||
}
|
||
addPageTags(fileFrontMatter, publishedFrontMatterWithoutTags) {
|
||
const publishedFrontMatter = __spreadValues({}, publishedFrontMatterWithoutTags);
|
||
if (fileFrontMatter) {
|
||
const tags = (typeof fileFrontMatter["tags"] === "string" ? fileFrontMatter["tags"].split(/,\s*/) : fileFrontMatter["tags"]) || [];
|
||
if (fileFrontMatter["dg-home"]) {
|
||
tags.push("gardenEntry");
|
||
}
|
||
if (tags.length > 0) {
|
||
publishedFrontMatter["tags"] = tags;
|
||
}
|
||
}
|
||
return publishedFrontMatter;
|
||
}
|
||
addContentClasses(baseFrontMatter, newFrontMatter) {
|
||
const publishedFrontMatter = __spreadValues({}, newFrontMatter);
|
||
if (baseFrontMatter) {
|
||
const contentClassesKey = this.settings.contentClassesKey;
|
||
const contentClasses = baseFrontMatter[contentClassesKey];
|
||
if (contentClassesKey && contentClasses) {
|
||
if (typeof contentClasses == "string") {
|
||
publishedFrontMatter["contentClasses"] = contentClasses;
|
||
} else if (Array.isArray(contentClasses)) {
|
||
publishedFrontMatter["contentClasses"] = contentClasses.join(" ");
|
||
} else {
|
||
publishedFrontMatter["contentClasses"] = "";
|
||
}
|
||
}
|
||
}
|
||
return publishedFrontMatter;
|
||
}
|
||
addTimestampsFrontmatter(baseFrontMatter, newFrontMatter, file) {
|
||
if (!baseFrontMatter) {
|
||
baseFrontMatter = {};
|
||
}
|
||
if (!this.settings.showCreatedTimestamp && !this.settings.showUpdatedTimestamp) {
|
||
return newFrontMatter;
|
||
}
|
||
const publishedFrontMatter = __spreadValues({}, newFrontMatter);
|
||
const createdKey = this.settings.createdTimestampKey;
|
||
const updatedKey = this.settings.updatedTimestampKey;
|
||
if (createdKey.length) {
|
||
if (typeof baseFrontMatter[createdKey] == "string") {
|
||
publishedFrontMatter["created"] = baseFrontMatter[createdKey];
|
||
} else {
|
||
publishedFrontMatter["created"] = "";
|
||
}
|
||
} else {
|
||
publishedFrontMatter["created"] = DateTime.fromMillis(
|
||
file.stat.ctime
|
||
).toISO();
|
||
}
|
||
if (updatedKey.length) {
|
||
if (typeof baseFrontMatter[updatedKey] == "string") {
|
||
publishedFrontMatter["updated"] = baseFrontMatter[updatedKey];
|
||
} else {
|
||
publishedFrontMatter["updated"] = "";
|
||
}
|
||
} else {
|
||
publishedFrontMatter["updated"] = DateTime.fromMillis(
|
||
file.stat.mtime
|
||
).toISO();
|
||
}
|
||
return publishedFrontMatter;
|
||
}
|
||
addNoteIconFrontMatter(baseFrontMatter, newFrontMatter) {
|
||
if (!baseFrontMatter) {
|
||
baseFrontMatter = {};
|
||
}
|
||
if (!this.settings.showNoteIconInFileTree && !this.settings.showNoteIconOnInternalLink && !this.settings.showNoteIconOnTitle && !this.settings.showNoteIconOnBackLink) {
|
||
return newFrontMatter;
|
||
}
|
||
const publishedFrontMatter = __spreadValues({}, newFrontMatter);
|
||
const noteIconKey = this.settings.noteIconKey;
|
||
if (baseFrontMatter[noteIconKey] !== void 0) {
|
||
publishedFrontMatter["noteIcon"] = baseFrontMatter[noteIconKey];
|
||
} else {
|
||
publishedFrontMatter["noteIcon"] = this.settings.defaultNoteIcon;
|
||
}
|
||
return publishedFrontMatter;
|
||
}
|
||
addFrontMatterSettings(baseFrontMatter, newFrontMatter) {
|
||
if (!baseFrontMatter) {
|
||
baseFrontMatter = {};
|
||
}
|
||
const publishedFrontMatter = __spreadValues({}, newFrontMatter);
|
||
for (const key of Object.keys(this.settings.defaultNoteSettings)) {
|
||
const settingValue = baseFrontMatter[kebabize(key)];
|
||
if (settingValue) {
|
||
publishedFrontMatter[key] = settingValue;
|
||
}
|
||
}
|
||
const dgPassFrontmatter = this.settings.defaultNoteSettings.dgPassFrontmatter;
|
||
if (dgPassFrontmatter) {
|
||
publishedFrontMatter.dgPassFrontmatter = dgPassFrontmatter;
|
||
}
|
||
return publishedFrontMatter;
|
||
}
|
||
convertLinksToFullPath(text2, filePath) {
|
||
return __async(this, null, function* () {
|
||
let convertedText = text2;
|
||
const textToBeProcessed = this.stripAwayCodeFencesAndFrontmatter(text2);
|
||
const linkedFileRegex = /\[\[(.+?)\]\]/g;
|
||
const linkedFileMatches = textToBeProcessed.match(linkedFileRegex);
|
||
if (linkedFileMatches) {
|
||
for (const linkMatch of linkedFileMatches) {
|
||
try {
|
||
const textInsideBrackets = linkMatch.substring(
|
||
linkMatch.indexOf("[") + 2,
|
||
linkMatch.lastIndexOf("]") - 1
|
||
);
|
||
let [linkedFileName, prettyName] = textInsideBrackets.split("|");
|
||
if (linkedFileName.endsWith("\\")) {
|
||
linkedFileName = linkedFileName.substring(
|
||
0,
|
||
linkedFileName.length - 1
|
||
);
|
||
}
|
||
prettyName = prettyName || linkedFileName;
|
||
let headerPath = "";
|
||
if (linkedFileName.includes("#")) {
|
||
const headerSplit = linkedFileName.split("#");
|
||
linkedFileName = headerSplit[0];
|
||
headerPath = headerSplit.length > 1 ? `#${headerSplit[1]}` : "";
|
||
}
|
||
const fullLinkedFilePath = (0, import_obsidian2.getLinkpath)(linkedFileName);
|
||
const linkedFile = this.metadataCache.getFirstLinkpathDest(
|
||
fullLinkedFilePath,
|
||
filePath
|
||
);
|
||
if (!linkedFile) {
|
||
convertedText = convertedText.replace(
|
||
linkMatch,
|
||
`[[${linkedFileName}${headerPath}\\|${prettyName}]]`
|
||
);
|
||
}
|
||
if ((linkedFile == null ? void 0 : linkedFile.extension) === "md") {
|
||
const extensionlessPath = linkedFile.path.substring(
|
||
0,
|
||
linkedFile.path.lastIndexOf(".")
|
||
);
|
||
convertedText = convertedText.replace(
|
||
linkMatch,
|
||
`[[${extensionlessPath}${headerPath}\\|${prettyName}]]`
|
||
);
|
||
}
|
||
} catch (e) {
|
||
console.log(e);
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
return convertedText;
|
||
});
|
||
}
|
||
createTranscludedText(text2, filePath, currentDepth) {
|
||
return __async(this, null, function* () {
|
||
var _a2, _b, _c;
|
||
if (currentDepth >= 4) {
|
||
return text2;
|
||
}
|
||
const { notes: publishedFiles } = yield this.getFilesMarkedForPublishing();
|
||
let transcludedText = text2;
|
||
const transcludedRegex = /!\[\[(.+?)\]\]/g;
|
||
const transclusionMatches = text2.match(transcludedRegex);
|
||
let numberOfExcaliDraws = 0;
|
||
if (transclusionMatches) {
|
||
for (let i = 0; i < transclusionMatches.length; i++) {
|
||
try {
|
||
const transclusionMatch = transclusionMatches[i];
|
||
const [transclusionFileName, headerName] = transclusionMatch.substring(
|
||
transclusionMatch.indexOf("[") + 2,
|
||
transclusionMatch.indexOf("]")
|
||
).split("|");
|
||
const transclusionFilePath = (0, import_obsidian2.getLinkpath)(transclusionFileName);
|
||
const linkedFile = this.metadataCache.getFirstLinkpathDest(
|
||
transclusionFilePath,
|
||
filePath
|
||
);
|
||
if (!linkedFile) {
|
||
continue;
|
||
}
|
||
let sectionID = "";
|
||
if (linkedFile.name.endsWith(".excalidraw.md")) {
|
||
const firstDrawing = ++numberOfExcaliDraws === 1;
|
||
const excaliDrawCode = yield this.generateExcalidrawMarkdown(
|
||
linkedFile,
|
||
firstDrawing,
|
||
`${numberOfExcaliDraws}`,
|
||
false
|
||
);
|
||
transcludedText = transcludedText.replace(
|
||
transclusionMatch,
|
||
excaliDrawCode
|
||
);
|
||
} else if (linkedFile.extension === "md") {
|
||
let fileText = yield this.vault.cachedRead(linkedFile);
|
||
const metadata = this.metadataCache.getFileCache(linkedFile);
|
||
if (transclusionFileName.includes("#^")) {
|
||
const refBlock = transclusionFileName.split("#^")[1];
|
||
sectionID = `#${(0, import_slugify2.default)(refBlock)}`;
|
||
const blockInFile = (metadata == null ? void 0 : metadata.blocks) && metadata.blocks[refBlock];
|
||
if (blockInFile) {
|
||
fileText = fileText.split("\n").slice(
|
||
blockInFile.position.start.line,
|
||
blockInFile.position.end.line + 1
|
||
).join("\n").replace(`^${refBlock}`, "");
|
||
}
|
||
} else if (transclusionFileName.includes("#")) {
|
||
const refHeader = transclusionFileName.split("#")[1];
|
||
const headerInFile = (_a2 = metadata == null ? void 0 : metadata.headings) == null ? void 0 : _a2.find(
|
||
(header2) => header2.heading === refHeader
|
||
);
|
||
sectionID = `#${(0, import_slugify2.default)(refHeader)}`;
|
||
if (headerInFile && (metadata == null ? void 0 : metadata.headings)) {
|
||
const headerPosition = metadata.headings.indexOf(headerInFile);
|
||
const cutTo = metadata.headings.slice(headerPosition + 1).find(
|
||
(header2) => header2.level <= headerInFile.level
|
||
);
|
||
if (cutTo) {
|
||
const cutToLine = (_c = (_b = cutTo == null ? void 0 : cutTo.position) == null ? void 0 : _b.start) == null ? void 0 : _c.line;
|
||
fileText = fileText.split("\n").slice(
|
||
headerInFile.position.start.line,
|
||
cutToLine
|
||
).join("\n");
|
||
} else {
|
||
fileText = fileText.split("\n").slice(headerInFile.position.start.line).join("\n");
|
||
}
|
||
}
|
||
}
|
||
fileText = fileText.replace(this.frontmatterRegex, "");
|
||
fileText = yield this.convertCustomFilters(fileText);
|
||
fileText = fileText.replace(this.blockrefRegex, "");
|
||
const header = this.generateTransclusionHeader(
|
||
headerName,
|
||
linkedFile
|
||
);
|
||
const headerSection = header ? `$<div class="markdown-embed-title">
|
||
|
||
${header}
|
||
|
||
</div>
|
||
` : "";
|
||
let embedded_link = "";
|
||
const publishedFilesContainsLinkedFile = publishedFiles.find(
|
||
(f) => f.path == linkedFile.path
|
||
);
|
||
if (publishedFilesContainsLinkedFile) {
|
||
const permalink = (metadata == null ? void 0 : metadata.frontmatter) && metadata.frontmatter["dg-permalink"];
|
||
const gardenPath = permalink ? sanitizePermalink(permalink) : `/${generateUrlPath(
|
||
getGardenPathForNote(
|
||
linkedFile.path,
|
||
this.rewriteRules
|
||
)
|
||
)}`;
|
||
embedded_link = `<a class="markdown-embed-link" href="${gardenPath}${sectionID}" aria-label="Open link"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a>`;
|
||
}
|
||
fileText = `
|
||
<div class="transclusion internal-embed is-loaded">${embedded_link}<div class="markdown-embed">
|
||
|
||
${headerSection}
|
||
|
||
` + fileText + "\n\n</div></div>\n";
|
||
if (fileText.match(transcludedRegex)) {
|
||
fileText = yield this.createTranscludedText(
|
||
fileText,
|
||
linkedFile.path,
|
||
currentDepth + 1
|
||
);
|
||
}
|
||
transcludedText = transcludedText.replace(
|
||
transclusionMatch,
|
||
fileText
|
||
);
|
||
}
|
||
} catch (e) {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
return transcludedText;
|
||
});
|
||
}
|
||
createSvgEmbeds(text2, filePath) {
|
||
return __async(this, null, function* () {
|
||
function setWidth(svgText, size) {
|
||
const parser = new DOMParser();
|
||
const svgDoc = parser.parseFromString(svgText, "image/svg+xml");
|
||
const svgElement = svgDoc.getElementsByTagName("svg")[0];
|
||
svgElement.setAttribute("width", size);
|
||
fixSvgForXmlSerializer(svgElement);
|
||
const svgSerializer = new XMLSerializer();
|
||
return svgSerializer.serializeToString(svgDoc);
|
||
}
|
||
const transcludedSvgRegex = /!\[\[(.*?)(\.(svg))\|(.*?)\]\]|!\[\[(.*?)(\.(svg))\]\]/g;
|
||
const transcludedSvgs = text2.match(transcludedSvgRegex);
|
||
if (transcludedSvgs) {
|
||
for (const svg of transcludedSvgs) {
|
||
try {
|
||
const [imageName, size] = svg.substring(svg.indexOf("[") + 2, svg.indexOf("]")).split("|");
|
||
const imagePath = (0, import_obsidian2.getLinkpath)(imageName);
|
||
const linkedFile = this.metadataCache.getFirstLinkpathDest(
|
||
imagePath,
|
||
filePath
|
||
);
|
||
if (!linkedFile) {
|
||
continue;
|
||
}
|
||
let svgText = yield this.vault.read(linkedFile);
|
||
if (svgText && size) {
|
||
svgText = setWidth(svgText, size);
|
||
}
|
||
text2 = text2.replace(svg, svgText);
|
||
} catch (e) {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
const linkedSvgRegex = /!\[(.*?)\]\((.*?)(\.(svg))\)/g;
|
||
const linkedSvgMatches = text2.match(linkedSvgRegex);
|
||
if (linkedSvgMatches) {
|
||
for (const svg of linkedSvgMatches) {
|
||
try {
|
||
const [_imageName, size] = svg.substring(svg.indexOf("[") + 2, svg.indexOf("]")).split("|");
|
||
const pathStart = svg.lastIndexOf("(") + 1;
|
||
const pathEnd = svg.lastIndexOf(")");
|
||
const imagePath = svg.substring(pathStart, pathEnd);
|
||
if (imagePath.startsWith("http")) {
|
||
continue;
|
||
}
|
||
const linkedFile = this.metadataCache.getFirstLinkpathDest(
|
||
imagePath,
|
||
filePath
|
||
);
|
||
if (!linkedFile) {
|
||
continue;
|
||
}
|
||
let svgText = yield this.vault.read(linkedFile);
|
||
if (svgText && size) {
|
||
svgText = setWidth(svgText, size);
|
||
}
|
||
text2 = text2.replace(svg, svgText);
|
||
} catch (e) {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
return text2;
|
||
});
|
||
}
|
||
extractImageLinks(text2, filePath) {
|
||
return __async(this, null, function* () {
|
||
const assets = [];
|
||
const transcludedImageRegex = /!\[\[(.*?)(\.(png|jpg|jpeg|gif))\|(.*?)\]\]|!\[\[(.*?)(\.(png|jpg|jpeg|gif))\]\]/g;
|
||
const transcludedImageMatches = text2.match(transcludedImageRegex);
|
||
if (transcludedImageMatches) {
|
||
for (let i = 0; i < transcludedImageMatches.length; i++) {
|
||
try {
|
||
const imageMatch = transcludedImageMatches[i];
|
||
const [imageName, _] = imageMatch.substring(
|
||
imageMatch.indexOf("[") + 2,
|
||
imageMatch.indexOf("]")
|
||
).split("|");
|
||
const imagePath = (0, import_obsidian2.getLinkpath)(imageName);
|
||
const linkedFile = this.metadataCache.getFirstLinkpathDest(
|
||
imagePath,
|
||
filePath
|
||
);
|
||
if (!linkedFile) {
|
||
continue;
|
||
}
|
||
assets.push(linkedFile.path);
|
||
} catch (e) {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
const imageRegex = /!\[(.*?)\]\((.*?)(\.(png|jpg|jpeg|gif))\)/g;
|
||
const imageMatches = text2.match(imageRegex);
|
||
if (imageMatches) {
|
||
for (let i = 0; i < imageMatches.length; i++) {
|
||
try {
|
||
const imageMatch = imageMatches[i];
|
||
const pathStart = imageMatch.lastIndexOf("(") + 1;
|
||
const pathEnd = imageMatch.lastIndexOf(")");
|
||
const imagePath = imageMatch.substring(pathStart, pathEnd);
|
||
if (imagePath.startsWith("http")) {
|
||
continue;
|
||
}
|
||
const decodedImagePath = decodeURI(imagePath);
|
||
const linkedFile = this.metadataCache.getFirstLinkpathDest(
|
||
decodedImagePath,
|
||
filePath
|
||
);
|
||
if (!linkedFile) {
|
||
continue;
|
||
}
|
||
assets.push(linkedFile.path);
|
||
} catch (e) {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
return assets;
|
||
});
|
||
}
|
||
convertImageLinks(text2, filePath) {
|
||
return __async(this, null, function* () {
|
||
const assets = [];
|
||
let imageText = text2;
|
||
const transcludedImageRegex = /!\[\[(.*?)(\.(png|jpg|jpeg|gif))\|(.*?)\]\]|!\[\[(.*?)(\.(png|jpg|jpeg|gif))\]\]/g;
|
||
const transcludedImageMatches = text2.match(transcludedImageRegex);
|
||
if (transcludedImageMatches) {
|
||
for (let i = 0; i < transcludedImageMatches.length; i++) {
|
||
try {
|
||
const imageMatch = transcludedImageMatches[i];
|
||
const [imageName, size] = imageMatch.substring(
|
||
imageMatch.indexOf("[") + 2,
|
||
imageMatch.indexOf("]")
|
||
).split("|");
|
||
const imagePath = (0, import_obsidian2.getLinkpath)(imageName);
|
||
const linkedFile = this.metadataCache.getFirstLinkpathDest(
|
||
imagePath,
|
||
filePath
|
||
);
|
||
if (!linkedFile) {
|
||
continue;
|
||
}
|
||
const image = yield this.vault.readBinary(linkedFile);
|
||
const imageBase64 = arrayBufferToBase64(image);
|
||
const cmsImgPath = `/img/user/${linkedFile.path}`;
|
||
const name = size ? `${imageName}|${size}` : imageName;
|
||
const imageMarkdown = `})`;
|
||
assets.push({ path: cmsImgPath, content: imageBase64 });
|
||
imageText = imageText.replace(imageMatch, imageMarkdown);
|
||
} catch (e) {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
const imageRegex = /!\[(.*?)\]\((.*?)(\.(png|jpg|jpeg|gif))\)/g;
|
||
const imageMatches = text2.match(imageRegex);
|
||
if (imageMatches) {
|
||
for (let i = 0; i < imageMatches.length; i++) {
|
||
try {
|
||
const imageMatch = imageMatches[i];
|
||
const nameStart = imageMatch.indexOf("[") + 1;
|
||
const nameEnd = imageMatch.indexOf("]");
|
||
const imageName = imageMatch.substring(nameStart, nameEnd);
|
||
const pathStart = imageMatch.lastIndexOf("(") + 1;
|
||
const pathEnd = imageMatch.lastIndexOf(")");
|
||
const imagePath = imageMatch.substring(pathStart, pathEnd);
|
||
if (imagePath.startsWith("http")) {
|
||
continue;
|
||
}
|
||
const decodedImagePath = decodeURI(imagePath);
|
||
const linkedFile = this.metadataCache.getFirstLinkpathDest(
|
||
decodedImagePath,
|
||
filePath
|
||
);
|
||
if (!linkedFile) {
|
||
continue;
|
||
}
|
||
const image = yield this.vault.readBinary(linkedFile);
|
||
const imageBase64 = arrayBufferToBase64(image);
|
||
const cmsImgPath = `/img/user/${linkedFile.path}`;
|
||
const imageMarkdown = ``;
|
||
assets.push({ path: cmsImgPath, content: imageBase64 });
|
||
imageText = imageText.replace(imageMatch, imageMarkdown);
|
||
} catch (e) {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
return [imageText, assets];
|
||
});
|
||
}
|
||
generateTransclusionHeader(headerName, transcludedFile) {
|
||
if (!headerName) {
|
||
return headerName;
|
||
}
|
||
const titleVariable = "{{title}}";
|
||
if (headerName.includes(titleVariable)) {
|
||
headerName = headerName.replace(
|
||
titleVariable,
|
||
transcludedFile.basename
|
||
);
|
||
}
|
||
return fixMarkdownHeaderSyntax(headerName);
|
||
}
|
||
generateExcalidrawMarkdown(file, includeExcaliDrawJs, idAppendage = "", includeFrontMatter = true) {
|
||
return __async(this, null, function* () {
|
||
if (!file.name.endsWith(".excalidraw.md"))
|
||
return "";
|
||
const fileText = yield this.vault.cachedRead(file);
|
||
const frontMatter = yield this.getProcessedFrontMatter(file);
|
||
const isCompressed = fileText.includes("```compressed-json");
|
||
const start2 = fileText.indexOf(isCompressed ? "```compressed-json" : "```json") + (isCompressed ? "```compressed-json" : "```json").length;
|
||
const end2 = fileText.lastIndexOf("```");
|
||
const excaliDrawJson = JSON.parse(
|
||
isCompressed ? import_lz_string.default.decompressFromBase64(
|
||
fileText.slice(start2, end2).replace(/[\n\r]/g, "")
|
||
) : fileText.slice(start2, end2)
|
||
);
|
||
const drawingId = file.name.split(" ").join("_").replace(".", "") + idAppendage;
|
||
let excaliDrawCode = "";
|
||
if (includeExcaliDrawJs) {
|
||
excaliDrawCode += excaliDrawBundle;
|
||
}
|
||
excaliDrawCode += excalidraw(JSON.stringify(excaliDrawJson), drawingId);
|
||
return `${includeFrontMatter ? frontMatter : ""}${excaliDrawCode}`;
|
||
});
|
||
}
|
||
};
|
||
|
||
// src/ui/PublishStatusBar.ts
|
||
var PublishStatusBar = class {
|
||
constructor(statusBarItem, numberOfNotesToPublish) {
|
||
this.statusBarItem = statusBarItem;
|
||
this.counter = 0;
|
||
this.numberOfNotesToPublish = numberOfNotesToPublish;
|
||
this.statusBarItem.createEl("span", { text: "Digital Garden: " });
|
||
this.status = this.statusBarItem.createEl("span", {
|
||
text: `${this.numberOfNotesToPublish} files marked for publishing`
|
||
});
|
||
}
|
||
increment() {
|
||
this.status.innerText = `\u231BPublishing files: ${++this.counter}/${this.numberOfNotesToPublish}`;
|
||
}
|
||
finish(displayDurationMillisec) {
|
||
this.status.innerText = `\u2705 Published files: ${this.counter}/${this.numberOfNotesToPublish}`;
|
||
setTimeout(() => {
|
||
this.statusBarItem.remove();
|
||
}, displayDurationMillisec);
|
||
}
|
||
error() {
|
||
this.statusBarItem.remove();
|
||
}
|
||
};
|
||
|
||
// src/ui/PublishModal.ts
|
||
var import_obsidian5 = require("obsidian");
|
||
|
||
// node_modules/svelte/src/runtime/internal/utils.js
|
||
function noop() {
|
||
}
|
||
function run(fn2) {
|
||
return fn2();
|
||
}
|
||
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;
|
||
}
|
||
|
||
// 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 _ResizeObserverSingleton {
|
||
/** @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 _a2;
|
||
return (_a2 = this._observer) != null ? _a2 : this._observer = new ResizeObserver((entries) => {
|
||
var _a3;
|
||
for (const entry of entries) {
|
||
_ResizeObserverSingleton.entries.set(entry.target, entry);
|
||
(_a3 = this._listeners.get(entry.target)) == null ? void 0 : _a3(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 attr(node, attribute, value) {
|
||
if (value == null)
|
||
node.removeAttribute(attribute);
|
||
else if (node.getAttribute(attribute) !== value)
|
||
node.setAttribute(attribute, value);
|
||
}
|
||
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_style(node, key, value, important) {
|
||
if (value == null) {
|
||
node.style.removeProperty(key);
|
||
} else {
|
||
node.style.setProperty(key, value, important ? "important" : "");
|
||
}
|
||
}
|
||
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 });
|
||
}
|
||
var HtmlTag = class {
|
||
constructor(is_svg = false) {
|
||
/**
|
||
* @private
|
||
* @default false
|
||
*/
|
||
__publicField(this, "is_svg", false);
|
||
/** parent for creating node */
|
||
__publicField(this, "e");
|
||
/** html tag nodes */
|
||
__publicField(this, "n");
|
||
/** target */
|
||
__publicField(this, "t");
|
||
/** anchor */
|
||
__publicField(this, "a");
|
||
this.is_svg = is_svg;
|
||
this.e = this.n = null;
|
||
}
|
||
/**
|
||
* @param {string} html
|
||
* @returns {void}
|
||
*/
|
||
c(html) {
|
||
this.h(html);
|
||
}
|
||
/**
|
||
* @param {string} html
|
||
* @param {HTMLElement | SVGElement} target
|
||
* @param {HTMLElement | SVGElement} anchor
|
||
* @returns {void}
|
||
*/
|
||
m(html, target, anchor = null) {
|
||
if (!this.e) {
|
||
if (this.is_svg)
|
||
this.e = svg_element(
|
||
/** @type {keyof SVGElementTagNameMap} */
|
||
target.nodeName
|
||
);
|
||
else
|
||
this.e = element(
|
||
/** @type {keyof HTMLElementTagNameMap} */
|
||
target.nodeType === 11 ? "TEMPLATE" : target.nodeName
|
||
);
|
||
this.t = target.tagName !== "TEMPLATE" ? target : (
|
||
/** @type {HTMLTemplateElement} */
|
||
target.content
|
||
);
|
||
this.c(html);
|
||
}
|
||
this.i(anchor);
|
||
}
|
||
/**
|
||
* @param {string} html
|
||
* @returns {void}
|
||
*/
|
||
h(html) {
|
||
this.e.innerHTML = html;
|
||
this.n = Array.from(
|
||
this.e.nodeName === "TEMPLATE" ? this.e.content.childNodes : this.e.childNodes
|
||
);
|
||
}
|
||
/**
|
||
* @returns {void} */
|
||
i(anchor) {
|
||
for (let i = 0; i < this.n.length; i += 1) {
|
||
insert(this.t, this.n[i], anchor);
|
||
}
|
||
}
|
||
/**
|
||
* @param {string} html
|
||
* @returns {void}
|
||
*/
|
||
p(html) {
|
||
this.d();
|
||
this.h(html);
|
||
this.i(this.a);
|
||
}
|
||
/**
|
||
* @returns {void} */
|
||
d() {
|
||
this.n.forEach(detach);
|
||
}
|
||
};
|
||
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 onMount(fn2) {
|
||
get_current_component().$$.on_mount.push(fn2);
|
||
}
|
||
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((fn2) => {
|
||
fn2.call(component, event);
|
||
});
|
||
return !event.defaultPrevented;
|
||
}
|
||
return true;
|
||
};
|
||
}
|
||
|
||
// 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(fn2) {
|
||
render_callbacks.push(fn2);
|
||
}
|
||
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/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 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, instance5, create_fragment5, 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 = instance5 ? instance5(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_fragment5 ? create_fragment5($$.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);
|
||
}
|
||
}
|
||
}
|
||
connectedCallback() {
|
||
return __async(this, null, function* () {
|
||
this.$$cn = true;
|
||
if (!this.$$c) {
|
||
let create_slot = 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;
|
||
};
|
||
};
|
||
yield 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_slot(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: __spreadProps(__spreadValues({}, 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 _a2;
|
||
if (this.$$r)
|
||
return;
|
||
attr2 = this.$$g_p(attr2);
|
||
this.$$d[attr2] = get_custom_element_value(attr2, newValue, this.$$p_d, "toProp");
|
||
(_a2 = this.$$c) == null ? void 0 : _a2.$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 _a2;
|
||
const type = (_a2 = props_definition[prop]) == null ? void 0 : _a2.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);
|
||
|
||
// node_modules/tslib/tslib.es6.mjs
|
||
function __awaiter(thisArg, _arguments, P, generator) {
|
||
function adopt(value) {
|
||
return value instanceof P ? value : new P(function(resolve) {
|
||
resolve(value);
|
||
});
|
||
}
|
||
return new (P || (P = Promise))(function(resolve, reject) {
|
||
function fulfilled(value) {
|
||
try {
|
||
step(generator.next(value));
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
}
|
||
function rejected(value) {
|
||
try {
|
||
step(generator["throw"](value));
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
}
|
||
function step(result) {
|
||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
||
}
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
}
|
||
|
||
// src/ui/PublicationCenter.svelte
|
||
var import_obsidian4 = require("obsidian");
|
||
|
||
// src/ui/TreeView/TreeNode.svelte
|
||
var import_obsidian3 = require("obsidian");
|
||
function add_css(target) {
|
||
append_styles(target, "svelte-gsbdto", `ul.svelte-gsbdto{margin:0;list-style:none;padding-left:1.2rem;user-select:none}li.svelte-gsbdto{margin:0.2rem 0}.no-arrow.svelte-gsbdto{padding-left:calc(var(--icon-size) + 2px)}.arrow.svelte-gsbdto{cursor:pointer;display:inline-block}.arrowDown.svelte-gsbdto{transform:rotate(90deg)}ul.isRoot.svelte-gsbdto{padding-left:0}.root-header.svelte-gsbdto{font-weight:bold;font-size:1.2rem}input.svelte-gsbdto:indeterminate{background-color:var(--checkbox-color);border-color:var(--checkbox-color)}input[type="checkbox"].svelte-gsbdto:indeterminate:after{content:"";top:-1px;left:-1px;position:absolute;width:var(--checkbox-size);height:var(--checkbox-size);display:block;background-color:var(--checkbox-marker-color);-webkit-mask-position:52% 52%;mask-position:52% 52%;-webkit-mask-size:65%;mask-size:65%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-image:url('data:image/svg+xml; utf8,<svg fill="none" width="12px" height="12px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><rect fill="%23000000" x="4" y="4" width="24" height="24"/></svg>');mask-image:url('data:image/svg+xml; utf8,<svg fill="none" width="12px" height="12px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><rect fill="%23000000" x="4" y="4" width="24" height="24"/></svg>')}.diff.svelte-gsbdto{cursor:pointer;display:inline-block;margin-left:4px}`);
|
||
}
|
||
function get_each_context(ctx, list, i) {
|
||
const child_ctx = ctx.slice();
|
||
child_ctx[13] = list[i];
|
||
return child_ctx;
|
||
}
|
||
function create_if_block_5(ctx) {
|
||
var _a2;
|
||
let span1;
|
||
let span0;
|
||
let t0;
|
||
let html_tag;
|
||
let raw_value = ((_a2 = (0, import_obsidian3.getIcon)("file")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let t1;
|
||
let t2;
|
||
let t3_value = (
|
||
/*tree*/
|
||
ctx[0].name + ""
|
||
);
|
||
let t3;
|
||
let t4;
|
||
let if_block0 = !/*readOnly*/
|
||
ctx[1] && create_if_block_7(ctx);
|
||
let if_block1 = (
|
||
/*enableShowDiff*/
|
||
ctx[2] && create_if_block_6(ctx)
|
||
);
|
||
return {
|
||
c() {
|
||
span1 = element("span");
|
||
span0 = element("span");
|
||
t0 = space();
|
||
html_tag = new HtmlTag(false);
|
||
t1 = space();
|
||
if (if_block0)
|
||
if_block0.c();
|
||
t2 = space();
|
||
t3 = text(t3_value);
|
||
t4 = space();
|
||
if (if_block1)
|
||
if_block1.c();
|
||
attr(span0, "class", "no-arrow svelte-gsbdto");
|
||
html_tag.a = t1;
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, span1, anchor);
|
||
append(span1, span0);
|
||
append(span1, t0);
|
||
html_tag.m(raw_value, span1);
|
||
append(span1, t1);
|
||
if (if_block0)
|
||
if_block0.m(span1, null);
|
||
append(span1, t2);
|
||
append(span1, t3);
|
||
append(span1, t4);
|
||
if (if_block1)
|
||
if_block1.m(span1, null);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (!/*readOnly*/
|
||
ctx2[1]) {
|
||
if (if_block0) {
|
||
if_block0.p(ctx2, dirty);
|
||
} else {
|
||
if_block0 = create_if_block_7(ctx2);
|
||
if_block0.c();
|
||
if_block0.m(span1, t2);
|
||
}
|
||
} else if (if_block0) {
|
||
if_block0.d(1);
|
||
if_block0 = null;
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && t3_value !== (t3_value = /*tree*/
|
||
ctx2[0].name + ""))
|
||
set_data(t3, t3_value);
|
||
if (
|
||
/*enableShowDiff*/
|
||
ctx2[2]
|
||
) {
|
||
if (if_block1) {
|
||
if_block1.p(ctx2, dirty);
|
||
} else {
|
||
if_block1 = create_if_block_6(ctx2);
|
||
if_block1.c();
|
||
if_block1.m(span1, null);
|
||
}
|
||
} else if (if_block1) {
|
||
if_block1.d(1);
|
||
if_block1 = null;
|
||
}
|
||
},
|
||
i: noop,
|
||
o: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(span1);
|
||
}
|
||
if (if_block0)
|
||
if_block0.d();
|
||
if (if_block1)
|
||
if_block1.d();
|
||
}
|
||
};
|
||
}
|
||
function create_if_block(ctx) {
|
||
var _a2;
|
||
let span1;
|
||
let span0;
|
||
let raw_value = ((_a2 = (0, import_obsidian3.getIcon)("chevron-right")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let t0;
|
||
let t1;
|
||
let if_block1_anchor;
|
||
let current;
|
||
let mounted;
|
||
let dispose;
|
||
function select_block_type_1(ctx2, dirty) {
|
||
if (!/*isRoot*/
|
||
ctx2[5])
|
||
return create_if_block_2;
|
||
return create_else_block;
|
||
}
|
||
let current_block_type = select_block_type_1(ctx, -1);
|
||
let if_block0 = current_block_type(ctx);
|
||
let if_block1 = (
|
||
/*expanded*/
|
||
ctx[3] && create_if_block_1(ctx)
|
||
);
|
||
return {
|
||
c() {
|
||
span1 = element("span");
|
||
span0 = element("span");
|
||
t0 = space();
|
||
if_block0.c();
|
||
t1 = space();
|
||
if (if_block1)
|
||
if_block1.c();
|
||
if_block1_anchor = empty();
|
||
attr(span0, "class", "arrow svelte-gsbdto");
|
||
toggle_class(
|
||
span0,
|
||
"arrowDown",
|
||
/*arrowDown*/
|
||
ctx[4]
|
||
);
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, span1, anchor);
|
||
append(span1, span0);
|
||
span0.innerHTML = raw_value;
|
||
append(span1, t0);
|
||
if_block0.m(span1, null);
|
||
insert(target, t1, anchor);
|
||
if (if_block1)
|
||
if_block1.m(target, anchor);
|
||
insert(target, if_block1_anchor, anchor);
|
||
current = true;
|
||
if (!mounted) {
|
||
dispose = listen(
|
||
span0,
|
||
"click",
|
||
/*toggleExpansion*/
|
||
ctx[6]
|
||
);
|
||
mounted = true;
|
||
}
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (!current || dirty & /*arrowDown*/
|
||
16) {
|
||
toggle_class(
|
||
span0,
|
||
"arrowDown",
|
||
/*arrowDown*/
|
||
ctx2[4]
|
||
);
|
||
}
|
||
if_block0.p(ctx2, dirty);
|
||
if (
|
||
/*expanded*/
|
||
ctx2[3]
|
||
) {
|
||
if (if_block1) {
|
||
if_block1.p(ctx2, dirty);
|
||
if (dirty & /*expanded*/
|
||
8) {
|
||
transition_in(if_block1, 1);
|
||
}
|
||
} else {
|
||
if_block1 = create_if_block_1(ctx2);
|
||
if_block1.c();
|
||
transition_in(if_block1, 1);
|
||
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
|
||
}
|
||
} else if (if_block1) {
|
||
group_outros();
|
||
transition_out(if_block1, 1, 1, () => {
|
||
if_block1 = null;
|
||
});
|
||
check_outros();
|
||
}
|
||
},
|
||
i(local) {
|
||
if (current)
|
||
return;
|
||
transition_in(if_block1);
|
||
current = true;
|
||
},
|
||
o(local) {
|
||
transition_out(if_block1);
|
||
current = false;
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(span1);
|
||
detach(t1);
|
||
detach(if_block1_anchor);
|
||
}
|
||
if_block0.d();
|
||
if (if_block1)
|
||
if_block1.d(detaching);
|
||
mounted = false;
|
||
dispose();
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_7(ctx) {
|
||
let input;
|
||
let input_data_label_value;
|
||
let input_checked_value;
|
||
let input_indeterminate_value;
|
||
let mounted;
|
||
let dispose;
|
||
return {
|
||
c() {
|
||
input = element("input");
|
||
attr(input, "type", "checkbox");
|
||
attr(input, "data-label", input_data_label_value = /*tree*/
|
||
ctx[0].name);
|
||
input.checked = input_checked_value = /*tree*/
|
||
ctx[0].checked;
|
||
input.indeterminate = input_indeterminate_value = /*tree*/
|
||
ctx[0].indeterminate;
|
||
attr(input, "class", "svelte-gsbdto");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, input, anchor);
|
||
if (!mounted) {
|
||
dispose = listen(
|
||
input,
|
||
"click",
|
||
/*toggleCheck*/
|
||
ctx[7]
|
||
);
|
||
mounted = true;
|
||
}
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*tree*/
|
||
1 && input_data_label_value !== (input_data_label_value = /*tree*/
|
||
ctx2[0].name)) {
|
||
attr(input, "data-label", input_data_label_value);
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && input_checked_value !== (input_checked_value = /*tree*/
|
||
ctx2[0].checked)) {
|
||
input.checked = input_checked_value;
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && input_indeterminate_value !== (input_indeterminate_value = /*tree*/
|
||
ctx2[0].indeterminate)) {
|
||
input.indeterminate = input_indeterminate_value;
|
||
}
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(input);
|
||
}
|
||
mounted = false;
|
||
dispose();
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_6(ctx) {
|
||
var _a2;
|
||
let span;
|
||
let raw_value = ((_a2 = (0, import_obsidian3.getIcon)("file-diff")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let mounted;
|
||
let dispose;
|
||
return {
|
||
c() {
|
||
span = element("span");
|
||
attr(span, "title", "Show diff");
|
||
attr(span, "class", "diff svelte-gsbdto");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, span, anchor);
|
||
span.innerHTML = raw_value;
|
||
if (!mounted) {
|
||
dispose = listen(
|
||
span,
|
||
"click",
|
||
/*showDiff*/
|
||
ctx[9]
|
||
);
|
||
mounted = true;
|
||
}
|
||
},
|
||
p: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(span);
|
||
}
|
||
mounted = false;
|
||
dispose();
|
||
}
|
||
};
|
||
}
|
||
function create_else_block(ctx) {
|
||
let t0;
|
||
let span;
|
||
let t1_value = (
|
||
/*tree*/
|
||
ctx[0].name + ""
|
||
);
|
||
let t1;
|
||
let if_block = !/*readOnly*/
|
||
ctx[1] && create_if_block_4(ctx);
|
||
return {
|
||
c() {
|
||
if (if_block)
|
||
if_block.c();
|
||
t0 = space();
|
||
span = element("span");
|
||
t1 = text(t1_value);
|
||
attr(span, "class", "root-header svelte-gsbdto");
|
||
},
|
||
m(target, anchor) {
|
||
if (if_block)
|
||
if_block.m(target, anchor);
|
||
insert(target, t0, anchor);
|
||
insert(target, span, anchor);
|
||
append(span, t1);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (!/*readOnly*/
|
||
ctx2[1]) {
|
||
if (if_block) {
|
||
if_block.p(ctx2, dirty);
|
||
} else {
|
||
if_block = create_if_block_4(ctx2);
|
||
if_block.c();
|
||
if_block.m(t0.parentNode, t0);
|
||
}
|
||
} else if (if_block) {
|
||
if_block.d(1);
|
||
if_block = null;
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && t1_value !== (t1_value = /*tree*/
|
||
ctx2[0].name + ""))
|
||
set_data(t1, t1_value);
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(t0);
|
||
detach(span);
|
||
}
|
||
if (if_block)
|
||
if_block.d(detaching);
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_2(ctx) {
|
||
var _a2;
|
||
let html_tag;
|
||
let raw_value = ((_a2 = (0, import_obsidian3.getIcon)("folder")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let t0;
|
||
let t1;
|
||
let t2_value = (
|
||
/*tree*/
|
||
ctx[0].name + ""
|
||
);
|
||
let t2;
|
||
let if_block = !/*readOnly*/
|
||
ctx[1] && create_if_block_3(ctx);
|
||
return {
|
||
c() {
|
||
html_tag = new HtmlTag(false);
|
||
t0 = space();
|
||
if (if_block)
|
||
if_block.c();
|
||
t1 = space();
|
||
t2 = text(t2_value);
|
||
html_tag.a = t0;
|
||
},
|
||
m(target, anchor) {
|
||
html_tag.m(raw_value, target, anchor);
|
||
insert(target, t0, anchor);
|
||
if (if_block)
|
||
if_block.m(target, anchor);
|
||
insert(target, t1, anchor);
|
||
insert(target, t2, anchor);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (!/*readOnly*/
|
||
ctx2[1]) {
|
||
if (if_block) {
|
||
if_block.p(ctx2, dirty);
|
||
} else {
|
||
if_block = create_if_block_3(ctx2);
|
||
if_block.c();
|
||
if_block.m(t1.parentNode, t1);
|
||
}
|
||
} else if (if_block) {
|
||
if_block.d(1);
|
||
if_block = null;
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && t2_value !== (t2_value = /*tree*/
|
||
ctx2[0].name + ""))
|
||
set_data(t2, t2_value);
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
html_tag.d();
|
||
detach(t0);
|
||
detach(t1);
|
||
detach(t2);
|
||
}
|
||
if (if_block)
|
||
if_block.d(detaching);
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_4(ctx) {
|
||
let input;
|
||
let input_data_label_value;
|
||
let input_checked_value;
|
||
let input_indeterminate_value;
|
||
let mounted;
|
||
let dispose;
|
||
return {
|
||
c() {
|
||
input = element("input");
|
||
attr(input, "type", "checkbox");
|
||
attr(input, "data-label", input_data_label_value = /*tree*/
|
||
ctx[0].name);
|
||
input.checked = input_checked_value = /*tree*/
|
||
ctx[0].checked;
|
||
input.indeterminate = input_indeterminate_value = /*tree*/
|
||
ctx[0].indeterminate;
|
||
attr(input, "class", "svelte-gsbdto");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, input, anchor);
|
||
if (!mounted) {
|
||
dispose = listen(
|
||
input,
|
||
"click",
|
||
/*toggleCheck*/
|
||
ctx[7]
|
||
);
|
||
mounted = true;
|
||
}
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*tree*/
|
||
1 && input_data_label_value !== (input_data_label_value = /*tree*/
|
||
ctx2[0].name)) {
|
||
attr(input, "data-label", input_data_label_value);
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && input_checked_value !== (input_checked_value = /*tree*/
|
||
ctx2[0].checked)) {
|
||
input.checked = input_checked_value;
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && input_indeterminate_value !== (input_indeterminate_value = /*tree*/
|
||
ctx2[0].indeterminate)) {
|
||
input.indeterminate = input_indeterminate_value;
|
||
}
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(input);
|
||
}
|
||
mounted = false;
|
||
dispose();
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_3(ctx) {
|
||
let input;
|
||
let input_data_label_value;
|
||
let input_checked_value;
|
||
let input_indeterminate_value;
|
||
let mounted;
|
||
let dispose;
|
||
return {
|
||
c() {
|
||
input = element("input");
|
||
attr(input, "type", "checkbox");
|
||
attr(input, "data-label", input_data_label_value = /*tree*/
|
||
ctx[0].name);
|
||
input.checked = input_checked_value = /*tree*/
|
||
ctx[0].checked;
|
||
input.indeterminate = input_indeterminate_value = /*tree*/
|
||
ctx[0].indeterminate;
|
||
attr(input, "class", "svelte-gsbdto");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, input, anchor);
|
||
if (!mounted) {
|
||
dispose = listen(
|
||
input,
|
||
"click",
|
||
/*toggleCheck*/
|
||
ctx[7]
|
||
);
|
||
mounted = true;
|
||
}
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*tree*/
|
||
1 && input_data_label_value !== (input_data_label_value = /*tree*/
|
||
ctx2[0].name)) {
|
||
attr(input, "data-label", input_data_label_value);
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && input_checked_value !== (input_checked_value = /*tree*/
|
||
ctx2[0].checked)) {
|
||
input.checked = input_checked_value;
|
||
}
|
||
if (dirty & /*tree*/
|
||
1 && input_indeterminate_value !== (input_indeterminate_value = /*tree*/
|
||
ctx2[0].indeterminate)) {
|
||
input.indeterminate = input_indeterminate_value;
|
||
}
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(input);
|
||
}
|
||
mounted = false;
|
||
dispose();
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_1(ctx) {
|
||
let each_1_anchor;
|
||
let current;
|
||
let each_value = ensure_array_like(
|
||
/*tree*/
|
||
ctx[0].children
|
||
);
|
||
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));
|
||
}
|
||
const out = (i) => transition_out(each_blocks[i], 1, 1, () => {
|
||
each_blocks[i] = null;
|
||
});
|
||
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);
|
||
current = true;
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*enableShowDiff, readOnly, tree, dispatchChecked, dispatchShowDiff*/
|
||
1287) {
|
||
each_value = ensure_array_like(
|
||
/*tree*/
|
||
ctx2[0].children
|
||
);
|
||
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);
|
||
transition_in(each_blocks[i], 1);
|
||
} else {
|
||
each_blocks[i] = create_each_block(child_ctx);
|
||
each_blocks[i].c();
|
||
transition_in(each_blocks[i], 1);
|
||
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
|
||
}
|
||
}
|
||
group_outros();
|
||
for (i = each_value.length; i < each_blocks.length; i += 1) {
|
||
out(i);
|
||
}
|
||
check_outros();
|
||
}
|
||
},
|
||
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(each_1_anchor);
|
||
}
|
||
destroy_each(each_blocks, detaching);
|
||
}
|
||
};
|
||
}
|
||
function create_each_block(ctx) {
|
||
let treenode;
|
||
let current;
|
||
treenode = new TreeNode({
|
||
props: {
|
||
enableShowDiff: (
|
||
/*enableShowDiff*/
|
||
ctx[2]
|
||
),
|
||
readOnly: (
|
||
/*readOnly*/
|
||
ctx[1]
|
||
),
|
||
tree: (
|
||
/*child*/
|
||
ctx[13]
|
||
)
|
||
}
|
||
});
|
||
treenode.$on(
|
||
"toggle",
|
||
/*dispatchChecked*/
|
||
ctx[8]
|
||
);
|
||
treenode.$on(
|
||
"showDiff",
|
||
/*showDiff_handler*/
|
||
ctx[11]
|
||
);
|
||
return {
|
||
c() {
|
||
create_component(treenode.$$.fragment);
|
||
},
|
||
m(target, anchor) {
|
||
mount_component(treenode, target, anchor);
|
||
current = true;
|
||
},
|
||
p(ctx2, dirty) {
|
||
const treenode_changes = {};
|
||
if (dirty & /*enableShowDiff*/
|
||
4)
|
||
treenode_changes.enableShowDiff = /*enableShowDiff*/
|
||
ctx2[2];
|
||
if (dirty & /*readOnly*/
|
||
2)
|
||
treenode_changes.readOnly = /*readOnly*/
|
||
ctx2[1];
|
||
if (dirty & /*tree*/
|
||
1)
|
||
treenode_changes.tree = /*child*/
|
||
ctx2[13];
|
||
treenode.$set(treenode_changes);
|
||
},
|
||
i(local) {
|
||
if (current)
|
||
return;
|
||
transition_in(treenode.$$.fragment, local);
|
||
current = true;
|
||
},
|
||
o(local) {
|
||
transition_out(treenode.$$.fragment, local);
|
||
current = false;
|
||
},
|
||
d(detaching) {
|
||
destroy_component(treenode, detaching);
|
||
}
|
||
};
|
||
}
|
||
function create_fragment(ctx) {
|
||
let ul;
|
||
let li;
|
||
let current_block_type_index;
|
||
let if_block;
|
||
let current;
|
||
const if_block_creators = [create_if_block, create_if_block_5];
|
||
const if_blocks = [];
|
||
function select_block_type(ctx2, dirty) {
|
||
if (
|
||
/*tree*/
|
||
ctx2[0].children
|
||
)
|
||
return 0;
|
||
if (!/*isRoot*/
|
||
ctx2[5])
|
||
return 1;
|
||
return -1;
|
||
}
|
||
if (~(current_block_type_index = select_block_type(ctx, -1))) {
|
||
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
||
}
|
||
return {
|
||
c() {
|
||
ul = element("ul");
|
||
li = element("li");
|
||
if (if_block)
|
||
if_block.c();
|
||
attr(li, "class", "svelte-gsbdto");
|
||
attr(ul, "class", "svelte-gsbdto");
|
||
toggle_class(
|
||
ul,
|
||
"isRoot",
|
||
/*isRoot*/
|
||
ctx[5]
|
||
);
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, ul, anchor);
|
||
append(ul, li);
|
||
if (~current_block_type_index) {
|
||
if_blocks[current_block_type_index].m(li, null);
|
||
}
|
||
current = true;
|
||
},
|
||
p(ctx2, [dirty]) {
|
||
let previous_block_index = current_block_type_index;
|
||
current_block_type_index = select_block_type(ctx2, dirty);
|
||
if (current_block_type_index === previous_block_index) {
|
||
if (~current_block_type_index) {
|
||
if_blocks[current_block_type_index].p(ctx2, dirty);
|
||
}
|
||
} else {
|
||
if (if_block) {
|
||
group_outros();
|
||
transition_out(if_blocks[previous_block_index], 1, 1, () => {
|
||
if_blocks[previous_block_index] = null;
|
||
});
|
||
check_outros();
|
||
}
|
||
if (~current_block_type_index) {
|
||
if_block = if_blocks[current_block_type_index];
|
||
if (!if_block) {
|
||
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
|
||
if_block.c();
|
||
} else {
|
||
if_block.p(ctx2, dirty);
|
||
}
|
||
transition_in(if_block, 1);
|
||
if_block.m(li, null);
|
||
} else {
|
||
if_block = null;
|
||
}
|
||
}
|
||
},
|
||
i(local) {
|
||
if (current)
|
||
return;
|
||
transition_in(if_block);
|
||
current = true;
|
||
},
|
||
o(local) {
|
||
transition_out(if_block);
|
||
current = false;
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(ul);
|
||
}
|
||
if (~current_block_type_index) {
|
||
if_blocks[current_block_type_index].d();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
var _expansionState = {};
|
||
function instance($$self, $$props, $$invalidate) {
|
||
let arrowDown;
|
||
let { tree } = $$props;
|
||
let { readOnly = false } = $$props;
|
||
let { enableShowDiff = false } = $$props;
|
||
const dispatch = createEventDispatcher();
|
||
let { isRoot } = tree;
|
||
let expanded = _expansionState[tree.path] || false;
|
||
const toggleExpansion = () => {
|
||
$$invalidate(3, expanded = _expansionState[tree.path] = !expanded);
|
||
};
|
||
const toggleCheck = () => {
|
||
$$invalidate(0, tree.checked = !tree.checked, tree);
|
||
dispatch("toggle", { node: tree });
|
||
};
|
||
const dispatchChecked = (e) => {
|
||
dispatch("toggle", { node: e.detail.node });
|
||
};
|
||
const showDiff = (e) => {
|
||
e.stopPropagation();
|
||
dispatch("showDiff", { node: tree });
|
||
};
|
||
const dispatchShowDiff = (node) => {
|
||
dispatch("showDiff", { node });
|
||
};
|
||
const showDiff_handler = (e) => dispatchShowDiff(e.detail.node);
|
||
$$self.$$set = ($$props2) => {
|
||
if ("tree" in $$props2)
|
||
$$invalidate(0, tree = $$props2.tree);
|
||
if ("readOnly" in $$props2)
|
||
$$invalidate(1, readOnly = $$props2.readOnly);
|
||
if ("enableShowDiff" in $$props2)
|
||
$$invalidate(2, enableShowDiff = $$props2.enableShowDiff);
|
||
};
|
||
$$self.$$.update = () => {
|
||
if ($$self.$$.dirty & /*expanded*/
|
||
8) {
|
||
$:
|
||
$$invalidate(4, arrowDown = expanded);
|
||
}
|
||
};
|
||
return [
|
||
tree,
|
||
readOnly,
|
||
enableShowDiff,
|
||
expanded,
|
||
arrowDown,
|
||
isRoot,
|
||
toggleExpansion,
|
||
toggleCheck,
|
||
dispatchChecked,
|
||
showDiff,
|
||
dispatchShowDiff,
|
||
showDiff_handler
|
||
];
|
||
}
|
||
var TreeNode = class extends SvelteComponent {
|
||
constructor(options) {
|
||
super();
|
||
init(this, options, instance, create_fragment, safe_not_equal, { tree: 0, readOnly: 1, enableShowDiff: 2 }, add_css);
|
||
}
|
||
};
|
||
var TreeNode_default = TreeNode;
|
||
|
||
// src/ui/TreeView/TreeView.svelte
|
||
function create_fragment2(ctx) {
|
||
let div;
|
||
let node;
|
||
let current;
|
||
node = new TreeNode_default({
|
||
props: {
|
||
tree: (
|
||
/*tree*/
|
||
ctx[0]
|
||
),
|
||
readOnly: (
|
||
/*readOnly*/
|
||
ctx[1]
|
||
),
|
||
enableShowDiff: (
|
||
/*enableShowDiff*/
|
||
ctx[2]
|
||
)
|
||
}
|
||
});
|
||
node.$on(
|
||
"toggle",
|
||
/*rebuildTree*/
|
||
ctx[4]
|
||
);
|
||
node.$on(
|
||
"showDiff",
|
||
/*showDiff_handler*/
|
||
ctx[5]
|
||
);
|
||
return {
|
||
c() {
|
||
div = element("div");
|
||
create_component(node.$$.fragment);
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, div, anchor);
|
||
mount_component(node, div, null);
|
||
current = true;
|
||
},
|
||
p(ctx2, [dirty]) {
|
||
const node_changes = {};
|
||
if (dirty & /*tree*/
|
||
1)
|
||
node_changes.tree = /*tree*/
|
||
ctx2[0];
|
||
if (dirty & /*readOnly*/
|
||
2)
|
||
node_changes.readOnly = /*readOnly*/
|
||
ctx2[1];
|
||
if (dirty & /*enableShowDiff*/
|
||
4)
|
||
node_changes.enableShowDiff = /*enableShowDiff*/
|
||
ctx2[2];
|
||
node.$set(node_changes);
|
||
},
|
||
i(local) {
|
||
if (current)
|
||
return;
|
||
transition_in(node.$$.fragment, local);
|
||
current = true;
|
||
},
|
||
o(local) {
|
||
transition_out(node.$$.fragment, local);
|
||
current = false;
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div);
|
||
}
|
||
destroy_component(node);
|
||
}
|
||
};
|
||
}
|
||
function rebuildChildren(node, checkAsParent = true) {
|
||
if (node.children) {
|
||
for (const child of node.children) {
|
||
if (checkAsParent)
|
||
child.checked = !!node.checked;
|
||
rebuildChildren(child, checkAsParent);
|
||
}
|
||
node.indeterminate = node.children.some((c) => c.indeterminate) || node.children.some((c) => !!c.checked) && node.children.some((c) => !c.checked);
|
||
}
|
||
}
|
||
function instance2($$self, $$props, $$invalidate) {
|
||
let { tree } = $$props;
|
||
let { readOnly = false } = $$props;
|
||
let { enableShowDiff = false } = $$props;
|
||
let { showDiff } = $$props;
|
||
const treeMap = {};
|
||
function initTreeMap(tree2) {
|
||
if (tree2.children) {
|
||
for (const child of tree2.children) {
|
||
treeMap[child.path] = tree2;
|
||
initTreeMap(child);
|
||
}
|
||
}
|
||
}
|
||
;
|
||
initTreeMap(tree);
|
||
;
|
||
function rebuildTree(e, checkAsParent = true) {
|
||
var _a2, _b;
|
||
const node = e.detail.node;
|
||
let parent = treeMap[node.path];
|
||
rebuildChildren(node, checkAsParent);
|
||
while (parent) {
|
||
const allCheck = (_a2 = parent === null || parent === void 0 ? void 0 : parent.children) === null || _a2 === void 0 ? void 0 : _a2.every((c) => !!c.checked);
|
||
if (allCheck) {
|
||
parent.indeterminate = false;
|
||
parent.checked = true;
|
||
} else {
|
||
const haveCheckedOrIndetermine = (_b = parent === null || parent === void 0 ? void 0 : parent.children) === null || _b === void 0 ? void 0 : _b.some((c) => !!c.checked || c.indeterminate);
|
||
if (haveCheckedOrIndetermine) {
|
||
parent.indeterminate = true;
|
||
} else {
|
||
parent.indeterminate = false;
|
||
}
|
||
parent.checked = false;
|
||
}
|
||
parent = treeMap[parent.path];
|
||
}
|
||
$$invalidate(0, tree);
|
||
}
|
||
rebuildTree({ detail: { node: tree } }, false);
|
||
const showDiff_handler = (e) => showDiff(e.detail.node.path);
|
||
$$self.$$set = ($$props2) => {
|
||
if ("tree" in $$props2)
|
||
$$invalidate(0, tree = $$props2.tree);
|
||
if ("readOnly" in $$props2)
|
||
$$invalidate(1, readOnly = $$props2.readOnly);
|
||
if ("enableShowDiff" in $$props2)
|
||
$$invalidate(2, enableShowDiff = $$props2.enableShowDiff);
|
||
if ("showDiff" in $$props2)
|
||
$$invalidate(3, showDiff = $$props2.showDiff);
|
||
};
|
||
return [tree, readOnly, enableShowDiff, showDiff, rebuildTree, showDiff_handler];
|
||
}
|
||
var TreeView = class extends SvelteComponent {
|
||
constructor(options) {
|
||
super();
|
||
init(this, options, instance2, create_fragment2, safe_not_equal, {
|
||
tree: 0,
|
||
readOnly: 1,
|
||
enableShowDiff: 2,
|
||
showDiff: 3
|
||
});
|
||
}
|
||
};
|
||
var TreeView_default = TreeView;
|
||
|
||
// src/ui/PublicationCenter.svelte
|
||
function add_css2(target) {
|
||
append_styles(target, "svelte-1bp95kw", ".title-separator.svelte-1bp95kw{margin-top:0px;margin-bottom:15px}.footer-separator.svelte-1bp95kw{margin-top:15px;margin-bottom:15px}.footer.svelte-1bp95kw{display:flex;justify-content:flex-end}.loading-msg.svelte-1bp95kw{font-size:1.2rem;display:flex;align-items:center;flex-direction:column}button.svelte-1bp95kw{background-color:var(--interactive-accent);color:var(--text-on-accent);cursor:pointer;font-weight:bold;;}.loading-container.svelte-1bp95kw{width:100%;height:5px;margin-top:10px}.loading-bar.svelte-1bp95kw{background-color:var(--interactive-accent);height:100%;transition:all 0.5s ease-in-out}.published.svelte-1bp95kw{color:#8bff8b}.deleted.svelte-1bp95kw{color:#ff5757}");
|
||
}
|
||
function get_each_context2(ctx, list, i) {
|
||
const child_ctx = ctx.slice();
|
||
child_ctx[23] = list[i];
|
||
return child_ctx;
|
||
}
|
||
function get_each_context_1(ctx, list, i) {
|
||
const child_ctx = ctx.slice();
|
||
child_ctx[26] = list[i];
|
||
return child_ctx;
|
||
}
|
||
function create_else_block2(ctx) {
|
||
let div6;
|
||
let div4;
|
||
let div0;
|
||
let t1;
|
||
let div1;
|
||
let t2_value = `${/*publishedPaths*/
|
||
ctx[6].length} of ${/*unpublishedToPublish*/
|
||
ctx[3].length + /*changedToPublish*/
|
||
ctx[4].length + /*pathsToDelete*/
|
||
ctx[5].length} notes published`;
|
||
let t2;
|
||
let t3;
|
||
let t4;
|
||
let div3;
|
||
let div2;
|
||
let t5;
|
||
let t6;
|
||
let t7;
|
||
let hr;
|
||
let t8;
|
||
let div5;
|
||
let button;
|
||
let mounted;
|
||
let dispose;
|
||
let if_block = (
|
||
/*failedPublish*/
|
||
ctx[7].length > 0 && create_if_block_9(ctx)
|
||
);
|
||
let each_value_1 = ensure_array_like(
|
||
/*unpublishedToPublish*/
|
||
ctx[3].concat(
|
||
/*changedToPublish*/
|
||
ctx[4]
|
||
)
|
||
);
|
||
let each_blocks_1 = [];
|
||
for (let i = 0; i < each_value_1.length; i += 1) {
|
||
each_blocks_1[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i));
|
||
}
|
||
let each_value = ensure_array_like(
|
||
/*pathsToDelete*/
|
||
ctx[5]
|
||
);
|
||
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() {
|
||
div6 = element("div");
|
||
div4 = element("div");
|
||
div0 = element("div");
|
||
div0.textContent = "Publishing Notes";
|
||
t1 = space();
|
||
div1 = element("div");
|
||
t2 = text(t2_value);
|
||
t3 = space();
|
||
if (if_block)
|
||
if_block.c();
|
||
t4 = space();
|
||
div3 = element("div");
|
||
div2 = element("div");
|
||
t5 = space();
|
||
for (let i = 0; i < each_blocks_1.length; i += 1) {
|
||
each_blocks_1[i].c();
|
||
}
|
||
t6 = space();
|
||
for (let i = 0; i < each_blocks.length; i += 1) {
|
||
each_blocks[i].c();
|
||
}
|
||
t7 = space();
|
||
hr = element("hr");
|
||
t8 = space();
|
||
div5 = element("div");
|
||
button = element("button");
|
||
button.textContent = "DONE";
|
||
attr(div0, "class", "callout-title-inner");
|
||
attr(div2, "class", "loading-bar svelte-1bp95kw");
|
||
set_style(
|
||
div2,
|
||
"width",
|
||
/*publishProgress*/
|
||
ctx[13] + "%"
|
||
);
|
||
attr(div3, "class", "loading-container svelte-1bp95kw");
|
||
attr(div4, "class", "callout");
|
||
attr(hr, "class", "footer-separator svelte-1bp95kw");
|
||
attr(button, "class", "svelte-1bp95kw");
|
||
attr(div5, "class", "footer svelte-1bp95kw");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, div6, anchor);
|
||
append(div6, div4);
|
||
append(div4, div0);
|
||
append(div4, t1);
|
||
append(div4, div1);
|
||
append(div1, t2);
|
||
append(div4, t3);
|
||
if (if_block)
|
||
if_block.m(div4, null);
|
||
append(div4, t4);
|
||
append(div4, div3);
|
||
append(div3, div2);
|
||
append(div6, t5);
|
||
for (let i = 0; i < each_blocks_1.length; i += 1) {
|
||
if (each_blocks_1[i]) {
|
||
each_blocks_1[i].m(div6, null);
|
||
}
|
||
}
|
||
append(div6, t6);
|
||
for (let i = 0; i < each_blocks.length; i += 1) {
|
||
if (each_blocks[i]) {
|
||
each_blocks[i].m(div6, null);
|
||
}
|
||
}
|
||
append(div6, t7);
|
||
append(div6, hr);
|
||
append(div6, t8);
|
||
append(div6, div5);
|
||
append(div5, button);
|
||
if (!mounted) {
|
||
dispose = listen(button, "click", function() {
|
||
if (is_function(
|
||
/*close*/
|
||
ctx[1]
|
||
))
|
||
ctx[1].apply(this, arguments);
|
||
});
|
||
mounted = true;
|
||
}
|
||
},
|
||
p(new_ctx, dirty) {
|
||
ctx = new_ctx;
|
||
if (dirty & /*publishedPaths, unpublishedToPublish, changedToPublish, pathsToDelete*/
|
||
120 && t2_value !== (t2_value = `${/*publishedPaths*/
|
||
ctx[6].length} of ${/*unpublishedToPublish*/
|
||
ctx[3].length + /*changedToPublish*/
|
||
ctx[4].length + /*pathsToDelete*/
|
||
ctx[5].length} notes published`))
|
||
set_data(t2, t2_value);
|
||
if (
|
||
/*failedPublish*/
|
||
ctx[7].length > 0
|
||
) {
|
||
if (if_block) {
|
||
if_block.p(ctx, dirty);
|
||
} else {
|
||
if_block = create_if_block_9(ctx);
|
||
if_block.c();
|
||
if_block.m(div4, t4);
|
||
}
|
||
} else if (if_block) {
|
||
if_block.d(1);
|
||
if_block = null;
|
||
}
|
||
if (dirty & /*publishProgress*/
|
||
8192) {
|
||
set_style(
|
||
div2,
|
||
"width",
|
||
/*publishProgress*/
|
||
ctx[13] + "%"
|
||
);
|
||
}
|
||
if (dirty & /*publishedPaths, unpublishedToPublish, changedToPublish, rotatingCog, processingPaths, failedPublish*/
|
||
33496) {
|
||
each_value_1 = ensure_array_like(
|
||
/*unpublishedToPublish*/
|
||
ctx[3].concat(
|
||
/*changedToPublish*/
|
||
ctx[4]
|
||
)
|
||
);
|
||
let i;
|
||
for (i = 0; i < each_value_1.length; i += 1) {
|
||
const child_ctx = get_each_context_1(ctx, 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_1(child_ctx);
|
||
each_blocks_1[i].c();
|
||
each_blocks_1[i].m(div6, t6);
|
||
}
|
||
}
|
||
for (; i < each_blocks_1.length; i += 1) {
|
||
each_blocks_1[i].d(1);
|
||
}
|
||
each_blocks_1.length = each_value_1.length;
|
||
}
|
||
if (dirty & /*publishedPaths, pathsToDelete, rotatingCog, processingPaths*/
|
||
33376) {
|
||
each_value = ensure_array_like(
|
||
/*pathsToDelete*/
|
||
ctx[5]
|
||
);
|
||
let i;
|
||
for (i = 0; i < each_value.length; i += 1) {
|
||
const child_ctx = get_each_context2(ctx, 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(div6, t7);
|
||
}
|
||
}
|
||
for (; i < each_blocks.length; i += 1) {
|
||
each_blocks[i].d(1);
|
||
}
|
||
each_blocks.length = each_value.length;
|
||
}
|
||
},
|
||
i: noop,
|
||
o: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div6);
|
||
}
|
||
if (if_block)
|
||
if_block.d();
|
||
destroy_each(each_blocks_1, detaching);
|
||
destroy_each(each_blocks, detaching);
|
||
mounted = false;
|
||
dispose();
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_12(ctx) {
|
||
var _a2, _b, _c, _d;
|
||
let treeview0;
|
||
let t0;
|
||
let treeview1;
|
||
let t1;
|
||
let treeview2;
|
||
let t2;
|
||
let treeview3;
|
||
let t3;
|
||
let hr;
|
||
let t4;
|
||
let div;
|
||
let button;
|
||
let current;
|
||
let mounted;
|
||
let dispose;
|
||
treeview0 = new TreeView_default({
|
||
props: {
|
||
tree: (
|
||
/*unpublishedNoteTree*/
|
||
(_a2 = ctx[12]) != null ? _a2 : (
|
||
/*emptyNode*/
|
||
ctx[18]
|
||
)
|
||
),
|
||
showDiff: (
|
||
/*showDiff*/
|
||
ctx[0]
|
||
)
|
||
}
|
||
});
|
||
treeview1 = new TreeView_default({
|
||
props: {
|
||
tree: (
|
||
/*changedNotesTree*/
|
||
(_b = ctx[11]) != null ? _b : (
|
||
/*emptyNode*/
|
||
ctx[18]
|
||
)
|
||
),
|
||
showDiff: (
|
||
/*showDiff*/
|
||
ctx[0]
|
||
),
|
||
enableShowDiff: true
|
||
}
|
||
});
|
||
treeview2 = new TreeView_default({
|
||
props: {
|
||
tree: (
|
||
/*deletedNoteTree*/
|
||
(_c = ctx[10]) != null ? _c : (
|
||
/*emptyNode*/
|
||
ctx[18]
|
||
)
|
||
),
|
||
showDiff: (
|
||
/*showDiff*/
|
||
ctx[0]
|
||
)
|
||
}
|
||
});
|
||
treeview3 = new TreeView_default({
|
||
props: {
|
||
readOnly: true,
|
||
tree: (
|
||
/*publishedNotesTree*/
|
||
(_d = ctx[14]) != null ? _d : (
|
||
/*emptyNode*/
|
||
ctx[18]
|
||
)
|
||
),
|
||
showDiff: (
|
||
/*showDiff*/
|
||
ctx[0]
|
||
)
|
||
}
|
||
});
|
||
return {
|
||
c() {
|
||
create_component(treeview0.$$.fragment);
|
||
t0 = space();
|
||
create_component(treeview1.$$.fragment);
|
||
t1 = space();
|
||
create_component(treeview2.$$.fragment);
|
||
t2 = space();
|
||
create_component(treeview3.$$.fragment);
|
||
t3 = space();
|
||
hr = element("hr");
|
||
t4 = space();
|
||
div = element("div");
|
||
button = element("button");
|
||
button.textContent = "PUBLISH SELECTED";
|
||
attr(hr, "class", "footer-separator svelte-1bp95kw");
|
||
attr(button, "class", "svelte-1bp95kw");
|
||
attr(div, "class", "footer svelte-1bp95kw");
|
||
},
|
||
m(target, anchor) {
|
||
mount_component(treeview0, target, anchor);
|
||
insert(target, t0, anchor);
|
||
mount_component(treeview1, target, anchor);
|
||
insert(target, t1, anchor);
|
||
mount_component(treeview2, target, anchor);
|
||
insert(target, t2, anchor);
|
||
mount_component(treeview3, target, anchor);
|
||
insert(target, t3, anchor);
|
||
insert(target, hr, anchor);
|
||
insert(target, t4, anchor);
|
||
insert(target, div, anchor);
|
||
append(div, button);
|
||
current = true;
|
||
if (!mounted) {
|
||
dispose = listen(
|
||
button,
|
||
"click",
|
||
/*publishMarkedNotes*/
|
||
ctx[17]
|
||
);
|
||
mounted = true;
|
||
}
|
||
},
|
||
p(ctx2, dirty) {
|
||
var _a3, _b2, _c2, _d2;
|
||
const treeview0_changes = {};
|
||
if (dirty & /*unpublishedNoteTree*/
|
||
4096)
|
||
treeview0_changes.tree = /*unpublishedNoteTree*/
|
||
(_a3 = ctx2[12]) != null ? _a3 : (
|
||
/*emptyNode*/
|
||
ctx2[18]
|
||
);
|
||
if (dirty & /*showDiff*/
|
||
1)
|
||
treeview0_changes.showDiff = /*showDiff*/
|
||
ctx2[0];
|
||
treeview0.$set(treeview0_changes);
|
||
const treeview1_changes = {};
|
||
if (dirty & /*changedNotesTree*/
|
||
2048)
|
||
treeview1_changes.tree = /*changedNotesTree*/
|
||
(_b2 = ctx2[11]) != null ? _b2 : (
|
||
/*emptyNode*/
|
||
ctx2[18]
|
||
);
|
||
if (dirty & /*showDiff*/
|
||
1)
|
||
treeview1_changes.showDiff = /*showDiff*/
|
||
ctx2[0];
|
||
treeview1.$set(treeview1_changes);
|
||
const treeview2_changes = {};
|
||
if (dirty & /*deletedNoteTree*/
|
||
1024)
|
||
treeview2_changes.tree = /*deletedNoteTree*/
|
||
(_c2 = ctx2[10]) != null ? _c2 : (
|
||
/*emptyNode*/
|
||
ctx2[18]
|
||
);
|
||
if (dirty & /*showDiff*/
|
||
1)
|
||
treeview2_changes.showDiff = /*showDiff*/
|
||
ctx2[0];
|
||
treeview2.$set(treeview2_changes);
|
||
const treeview3_changes = {};
|
||
if (dirty & /*publishedNotesTree*/
|
||
16384)
|
||
treeview3_changes.tree = /*publishedNotesTree*/
|
||
(_d2 = ctx2[14]) != null ? _d2 : (
|
||
/*emptyNode*/
|
||
ctx2[18]
|
||
);
|
||
if (dirty & /*showDiff*/
|
||
1)
|
||
treeview3_changes.showDiff = /*showDiff*/
|
||
ctx2[0];
|
||
treeview3.$set(treeview3_changes);
|
||
},
|
||
i(local) {
|
||
if (current)
|
||
return;
|
||
transition_in(treeview0.$$.fragment, local);
|
||
transition_in(treeview1.$$.fragment, local);
|
||
transition_in(treeview2.$$.fragment, local);
|
||
transition_in(treeview3.$$.fragment, local);
|
||
current = true;
|
||
},
|
||
o(local) {
|
||
transition_out(treeview0.$$.fragment, local);
|
||
transition_out(treeview1.$$.fragment, local);
|
||
transition_out(treeview2.$$.fragment, local);
|
||
transition_out(treeview3.$$.fragment, local);
|
||
current = false;
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(t0);
|
||
detach(t1);
|
||
detach(t2);
|
||
detach(t3);
|
||
detach(hr);
|
||
detach(t4);
|
||
detach(div);
|
||
}
|
||
destroy_component(treeview0, detaching);
|
||
destroy_component(treeview1, detaching);
|
||
destroy_component(treeview2, detaching);
|
||
destroy_component(treeview3, detaching);
|
||
mounted = false;
|
||
dispose();
|
||
}
|
||
};
|
||
}
|
||
function create_if_block2(ctx) {
|
||
var _a2;
|
||
let div1;
|
||
let html_tag;
|
||
let raw_value = (
|
||
/*bigRotatingCog*/
|
||
((_a2 = ctx[16]()) == null ? void 0 : _a2.outerHTML) + ""
|
||
);
|
||
let t0;
|
||
let div0;
|
||
return {
|
||
c() {
|
||
div1 = element("div");
|
||
html_tag = new HtmlTag(false);
|
||
t0 = space();
|
||
div0 = element("div");
|
||
div0.textContent = "Calculating publication status from GitHub";
|
||
html_tag.a = t0;
|
||
attr(div1, "class", "loading-msg svelte-1bp95kw");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, div1, anchor);
|
||
html_tag.m(raw_value, div1);
|
||
append(div1, t0);
|
||
append(div1, div0);
|
||
},
|
||
p: noop,
|
||
i: noop,
|
||
o: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div1);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_9(ctx) {
|
||
let div;
|
||
let t_value = `(${/*failedPublish*/
|
||
ctx[7].length} failed)`;
|
||
let t;
|
||
return {
|
||
c() {
|
||
div = element("div");
|
||
t = text(t_value);
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, div, anchor);
|
||
append(div, t);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*failedPublish*/
|
||
128 && t_value !== (t_value = `(${/*failedPublish*/
|
||
ctx2[7].length} failed)`))
|
||
set_data(t, t_value);
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_else_block_2(ctx) {
|
||
var _a2;
|
||
let html_tag;
|
||
let raw_value = ((_a2 = (0, import_obsidian4.getIcon)("clock")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let html_anchor;
|
||
return {
|
||
c() {
|
||
html_tag = new HtmlTag(false);
|
||
html_anchor = empty();
|
||
html_tag.a = html_anchor;
|
||
},
|
||
m(target, anchor) {
|
||
html_tag.m(raw_value, target, anchor);
|
||
insert(target, html_anchor, anchor);
|
||
},
|
||
p: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(html_anchor);
|
||
html_tag.d();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_8(ctx) {
|
||
var _a2;
|
||
let html_tag;
|
||
let raw_value = ((_a2 = (0, import_obsidian4.getIcon)("cross")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let html_anchor;
|
||
return {
|
||
c() {
|
||
html_tag = new HtmlTag(false);
|
||
html_anchor = empty();
|
||
html_tag.a = html_anchor;
|
||
},
|
||
m(target, anchor) {
|
||
html_tag.m(raw_value, target, anchor);
|
||
insert(target, html_anchor, anchor);
|
||
},
|
||
p: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(html_anchor);
|
||
html_tag.d();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_72(ctx) {
|
||
var _a2;
|
||
let html_tag;
|
||
let raw_value = ((_a2 = (0, import_obsidian4.getIcon)("check")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let html_anchor;
|
||
return {
|
||
c() {
|
||
html_tag = new HtmlTag(false);
|
||
html_anchor = empty();
|
||
html_tag.a = html_anchor;
|
||
},
|
||
m(target, anchor) {
|
||
html_tag.m(raw_value, target, anchor);
|
||
insert(target, html_anchor, anchor);
|
||
},
|
||
p: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(html_anchor);
|
||
html_tag.d();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_62(ctx) {
|
||
var _a2;
|
||
let html_tag;
|
||
let raw_value = (
|
||
/*rotatingCog*/
|
||
((_a2 = ctx[15]()) == null ? void 0 : _a2.outerHTML) + ""
|
||
);
|
||
let html_anchor;
|
||
return {
|
||
c() {
|
||
html_tag = new HtmlTag(false);
|
||
html_anchor = empty();
|
||
html_tag.a = html_anchor;
|
||
},
|
||
m(target, anchor) {
|
||
html_tag.m(raw_value, target, anchor);
|
||
insert(target, html_anchor, anchor);
|
||
},
|
||
p: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(html_anchor);
|
||
html_tag.d();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_52(ctx) {
|
||
let span;
|
||
return {
|
||
c() {
|
||
span = element("span");
|
||
span.textContent = "- PUBLISHED";
|
||
attr(span, "class", "published svelte-1bp95kw");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, span, anchor);
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(span);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_each_block_1(ctx) {
|
||
let div;
|
||
let show_if_1;
|
||
let show_if_2;
|
||
let show_if_3;
|
||
let t0;
|
||
let t1_value = (
|
||
/*note*/
|
||
ctx[26].name + ""
|
||
);
|
||
let t1;
|
||
let t2;
|
||
let show_if = (
|
||
/*publishedPaths*/
|
||
ctx[6].includes(
|
||
/*note*/
|
||
ctx[26].path
|
||
)
|
||
);
|
||
function select_block_type_1(ctx2, dirty) {
|
||
if (dirty & /*processingPaths, unpublishedToPublish, changedToPublish*/
|
||
536)
|
||
show_if_1 = null;
|
||
if (dirty & /*publishedPaths, unpublishedToPublish, changedToPublish*/
|
||
88)
|
||
show_if_2 = null;
|
||
if (dirty & /*failedPublish, unpublishedToPublish, changedToPublish*/
|
||
152)
|
||
show_if_3 = null;
|
||
if (show_if_1 == null)
|
||
show_if_1 = !!/*processingPaths*/
|
||
ctx2[9].includes(
|
||
/*note*/
|
||
ctx2[26].path
|
||
);
|
||
if (show_if_1)
|
||
return create_if_block_62;
|
||
if (show_if_2 == null)
|
||
show_if_2 = !!/*publishedPaths*/
|
||
ctx2[6].includes(
|
||
/*note*/
|
||
ctx2[26].path
|
||
);
|
||
if (show_if_2)
|
||
return create_if_block_72;
|
||
if (show_if_3 == null)
|
||
show_if_3 = !!/*failedPublish*/
|
||
ctx2[7].includes(
|
||
/*note*/
|
||
ctx2[26].path
|
||
);
|
||
if (show_if_3)
|
||
return create_if_block_8;
|
||
return create_else_block_2;
|
||
}
|
||
let current_block_type = select_block_type_1(ctx, -1);
|
||
let if_block0 = current_block_type(ctx);
|
||
let if_block1 = show_if && create_if_block_52(ctx);
|
||
return {
|
||
c() {
|
||
div = element("div");
|
||
if_block0.c();
|
||
t0 = space();
|
||
t1 = text(t1_value);
|
||
t2 = space();
|
||
if (if_block1)
|
||
if_block1.c();
|
||
attr(div, "class", "note-list");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, div, anchor);
|
||
if_block0.m(div, null);
|
||
append(div, t0);
|
||
append(div, t1);
|
||
append(div, t2);
|
||
if (if_block1)
|
||
if_block1.m(div, null);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (current_block_type === (current_block_type = select_block_type_1(ctx2, dirty)) && if_block0) {
|
||
if_block0.p(ctx2, dirty);
|
||
} else {
|
||
if_block0.d(1);
|
||
if_block0 = current_block_type(ctx2);
|
||
if (if_block0) {
|
||
if_block0.c();
|
||
if_block0.m(div, t0);
|
||
}
|
||
}
|
||
if (dirty & /*unpublishedToPublish, changedToPublish*/
|
||
24 && t1_value !== (t1_value = /*note*/
|
||
ctx2[26].name + ""))
|
||
set_data(t1, t1_value);
|
||
if (dirty & /*publishedPaths, unpublishedToPublish, changedToPublish*/
|
||
88)
|
||
show_if = /*publishedPaths*/
|
||
ctx2[6].includes(
|
||
/*note*/
|
||
ctx2[26].path
|
||
);
|
||
if (show_if) {
|
||
if (if_block1) {
|
||
} else {
|
||
if_block1 = create_if_block_52(ctx2);
|
||
if_block1.c();
|
||
if_block1.m(div, null);
|
||
}
|
||
} else if (if_block1) {
|
||
if_block1.d(1);
|
||
if_block1 = null;
|
||
}
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div);
|
||
}
|
||
if_block0.d();
|
||
if (if_block1)
|
||
if_block1.d();
|
||
}
|
||
};
|
||
}
|
||
function create_else_block_1(ctx) {
|
||
var _a2;
|
||
let html_tag;
|
||
let raw_value = ((_a2 = (0, import_obsidian4.getIcon)("clock")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let html_anchor;
|
||
return {
|
||
c() {
|
||
html_tag = new HtmlTag(false);
|
||
html_anchor = empty();
|
||
html_tag.a = html_anchor;
|
||
},
|
||
m(target, anchor) {
|
||
html_tag.m(raw_value, target, anchor);
|
||
insert(target, html_anchor, anchor);
|
||
},
|
||
p: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(html_anchor);
|
||
html_tag.d();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_42(ctx) {
|
||
var _a2;
|
||
let html_tag;
|
||
let raw_value = ((_a2 = (0, import_obsidian4.getIcon)("check")) == null ? void 0 : _a2.outerHTML) + "";
|
||
let html_anchor;
|
||
return {
|
||
c() {
|
||
html_tag = new HtmlTag(false);
|
||
html_anchor = empty();
|
||
html_tag.a = html_anchor;
|
||
},
|
||
m(target, anchor) {
|
||
html_tag.m(raw_value, target, anchor);
|
||
insert(target, html_anchor, anchor);
|
||
},
|
||
p: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(html_anchor);
|
||
html_tag.d();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_32(ctx) {
|
||
var _a2;
|
||
let html_tag;
|
||
let raw_value = (
|
||
/*rotatingCog*/
|
||
((_a2 = ctx[15]()) == null ? void 0 : _a2.outerHTML) + ""
|
||
);
|
||
let html_anchor;
|
||
return {
|
||
c() {
|
||
html_tag = new HtmlTag(false);
|
||
html_anchor = empty();
|
||
html_tag.a = html_anchor;
|
||
},
|
||
m(target, anchor) {
|
||
html_tag.m(raw_value, target, anchor);
|
||
insert(target, html_anchor, anchor);
|
||
},
|
||
p: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(html_anchor);
|
||
html_tag.d();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_22(ctx) {
|
||
let span;
|
||
return {
|
||
c() {
|
||
span = element("span");
|
||
span.textContent = "- DELETED";
|
||
attr(span, "class", "deleted svelte-1bp95kw");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, span, anchor);
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(span);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_each_block2(ctx) {
|
||
let div;
|
||
let show_if_1;
|
||
let show_if_2;
|
||
let t0;
|
||
let t1_value = (
|
||
/*path*/
|
||
ctx[23].split("/").last() + ""
|
||
);
|
||
let t1;
|
||
let t2;
|
||
let show_if = (
|
||
/*publishedPaths*/
|
||
ctx[6].includes(
|
||
/*path*/
|
||
ctx[23]
|
||
)
|
||
);
|
||
function select_block_type_2(ctx2, dirty) {
|
||
if (dirty & /*processingPaths, pathsToDelete*/
|
||
544)
|
||
show_if_1 = null;
|
||
if (dirty & /*publishedPaths, pathsToDelete*/
|
||
96)
|
||
show_if_2 = null;
|
||
if (show_if_1 == null)
|
||
show_if_1 = !!/*processingPaths*/
|
||
ctx2[9].includes(
|
||
/*path*/
|
||
ctx2[23]
|
||
);
|
||
if (show_if_1)
|
||
return create_if_block_32;
|
||
if (show_if_2 == null)
|
||
show_if_2 = !!/*publishedPaths*/
|
||
ctx2[6].includes(
|
||
/*path*/
|
||
ctx2[23]
|
||
);
|
||
if (show_if_2)
|
||
return create_if_block_42;
|
||
return create_else_block_1;
|
||
}
|
||
let current_block_type = select_block_type_2(ctx, -1);
|
||
let if_block0 = current_block_type(ctx);
|
||
let if_block1 = show_if && create_if_block_22(ctx);
|
||
return {
|
||
c() {
|
||
div = element("div");
|
||
if_block0.c();
|
||
t0 = space();
|
||
t1 = text(t1_value);
|
||
t2 = space();
|
||
if (if_block1)
|
||
if_block1.c();
|
||
attr(div, "class", "note-list");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, div, anchor);
|
||
if_block0.m(div, null);
|
||
append(div, t0);
|
||
append(div, t1);
|
||
append(div, t2);
|
||
if (if_block1)
|
||
if_block1.m(div, null);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (current_block_type === (current_block_type = select_block_type_2(ctx2, dirty)) && if_block0) {
|
||
if_block0.p(ctx2, dirty);
|
||
} else {
|
||
if_block0.d(1);
|
||
if_block0 = current_block_type(ctx2);
|
||
if (if_block0) {
|
||
if_block0.c();
|
||
if_block0.m(div, t0);
|
||
}
|
||
}
|
||
if (dirty & /*pathsToDelete*/
|
||
32 && t1_value !== (t1_value = /*path*/
|
||
ctx2[23].split("/").last() + ""))
|
||
set_data(t1, t1_value);
|
||
if (dirty & /*publishedPaths, pathsToDelete*/
|
||
96)
|
||
show_if = /*publishedPaths*/
|
||
ctx2[6].includes(
|
||
/*path*/
|
||
ctx2[23]
|
||
);
|
||
if (show_if) {
|
||
if (if_block1) {
|
||
} else {
|
||
if_block1 = create_if_block_22(ctx2);
|
||
if_block1.c();
|
||
if_block1.m(div, null);
|
||
}
|
||
} else if (if_block1) {
|
||
if_block1.d(1);
|
||
if_block1 = null;
|
||
}
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div);
|
||
}
|
||
if_block0.d();
|
||
if (if_block1)
|
||
if_block1.d();
|
||
}
|
||
};
|
||
}
|
||
function create_fragment3(ctx) {
|
||
let div;
|
||
let hr;
|
||
let t;
|
||
let current_block_type_index;
|
||
let if_block;
|
||
let current;
|
||
const if_block_creators = [create_if_block2, create_if_block_12, create_else_block2];
|
||
const if_blocks = [];
|
||
function select_block_type(ctx2, dirty) {
|
||
if (!/*publishStatus*/
|
||
ctx2[2])
|
||
return 0;
|
||
if (!/*showPublishingView*/
|
||
ctx2[8])
|
||
return 1;
|
||
return 2;
|
||
}
|
||
current_block_type_index = select_block_type(ctx, -1);
|
||
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
||
return {
|
||
c() {
|
||
div = element("div");
|
||
hr = element("hr");
|
||
t = space();
|
||
if_block.c();
|
||
attr(hr, "class", "title-separator svelte-1bp95kw");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, div, anchor);
|
||
append(div, hr);
|
||
append(div, t);
|
||
if_blocks[current_block_type_index].m(div, null);
|
||
current = true;
|
||
},
|
||
p(ctx2, [dirty]) {
|
||
let previous_block_index = current_block_type_index;
|
||
current_block_type_index = select_block_type(ctx2, dirty);
|
||
if (current_block_type_index === previous_block_index) {
|
||
if_blocks[current_block_type_index].p(ctx2, dirty);
|
||
} else {
|
||
group_outros();
|
||
transition_out(if_blocks[previous_block_index], 1, 1, () => {
|
||
if_blocks[previous_block_index] = null;
|
||
});
|
||
check_outros();
|
||
if_block = if_blocks[current_block_type_index];
|
||
if (!if_block) {
|
||
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
|
||
if_block.c();
|
||
} else {
|
||
if_block.p(ctx2, dirty);
|
||
}
|
||
transition_in(if_block, 1);
|
||
if_block.m(div, null);
|
||
}
|
||
},
|
||
i(local) {
|
||
if (current)
|
||
return;
|
||
transition_in(if_block);
|
||
current = true;
|
||
},
|
||
o(local) {
|
||
transition_out(if_block);
|
||
current = false;
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div);
|
||
}
|
||
if_blocks[current_block_type_index].d();
|
||
}
|
||
};
|
||
}
|
||
function insertIntoTree(tree, pathComponents) {
|
||
let currentNode = tree;
|
||
for (let i = 0; i < pathComponents.length; i++) {
|
||
const part = pathComponents[i];
|
||
if (!currentNode.children) {
|
||
currentNode.children = [];
|
||
}
|
||
let childNode = currentNode.children.find((child) => child.name === part);
|
||
if (!childNode) {
|
||
childNode = {
|
||
name: part,
|
||
isRoot: false,
|
||
path: pathComponents.slice(0, i + 1).join("/"),
|
||
indeterminate: false,
|
||
checked: false
|
||
};
|
||
currentNode.children.push(childNode);
|
||
}
|
||
currentNode = childNode;
|
||
}
|
||
}
|
||
function filePathsToTree(filePaths, rootName = "root") {
|
||
const root = {
|
||
name: rootName,
|
||
isRoot: true,
|
||
path: "/",
|
||
indeterminate: false,
|
||
checked: false
|
||
};
|
||
for (const filePath of filePaths) {
|
||
const pathComponents = filePath.split("/");
|
||
insertIntoTree(root, pathComponents);
|
||
}
|
||
return root;
|
||
}
|
||
function instance3($$self, $$props, $$invalidate) {
|
||
let publishedNotesTree;
|
||
let changedNotesTree;
|
||
let deletedNoteTree;
|
||
let unpublishedNoteTree;
|
||
let publishProgress;
|
||
let { publishStatusManager } = $$props;
|
||
let { publisher } = $$props;
|
||
let { showDiff } = $$props;
|
||
let { close } = $$props;
|
||
let publishStatus;
|
||
let showPublishingView = false;
|
||
function getPublishStatus() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
$$invalidate(2, publishStatus = yield publishStatusManager.getPublishStatus());
|
||
});
|
||
}
|
||
onMount(getPublishStatus);
|
||
const rotatingCog = () => {
|
||
let cog = (0, import_obsidian4.getIcon)("cog");
|
||
cog === null || cog === void 0 ? void 0 : cog.classList.add("dg-rotate");
|
||
cog === null || cog === void 0 ? void 0 : cog.style.setProperty("margin-right", "3px");
|
||
return cog;
|
||
};
|
||
const bigRotatingCog = () => {
|
||
let cog = (0, import_obsidian4.getIcon)("cog");
|
||
cog === null || cog === void 0 ? void 0 : cog.classList.add("dg-rotate");
|
||
cog === null || cog === void 0 ? void 0 : cog.style.setProperty("margin-right", "3px");
|
||
cog === null || cog === void 0 ? void 0 : cog.style.setProperty("width", "40px");
|
||
cog === null || cog === void 0 ? void 0 : cog.style.setProperty("height", "40px");
|
||
return cog;
|
||
};
|
||
const traverseTree = (tree) => {
|
||
const paths = [];
|
||
if (tree.children) {
|
||
for (const child of tree.children) {
|
||
paths.push(...traverseTree(child));
|
||
}
|
||
} else {
|
||
if (tree.checked) {
|
||
paths.push(tree.path);
|
||
}
|
||
}
|
||
return paths;
|
||
};
|
||
let unpublishedToPublish = [];
|
||
let changedToPublish = [];
|
||
let pathsToDelete = [];
|
||
let processingPaths = [];
|
||
let publishedPaths = [];
|
||
let failedPublish = [];
|
||
const publishMarkedNotes = () => __awaiter(void 0, void 0, void 0, function* () {
|
||
var _a2, _b;
|
||
if (!unpublishedNoteTree || !changedNotesTree)
|
||
return;
|
||
const unpublishedPaths = traverseTree(unpublishedNoteTree);
|
||
const changedPaths = traverseTree(changedNotesTree);
|
||
$$invalidate(5, pathsToDelete = traverseTree(deletedNoteTree));
|
||
$$invalidate(3, unpublishedToPublish = (_a2 = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.unpublishedNotes.filter((note) => unpublishedPaths.includes(note.path))) !== null && _a2 !== void 0 ? _a2 : []);
|
||
$$invalidate(4, changedToPublish = (_b = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.changedNotes.filter((note) => changedPaths.includes(note.path))) !== null && _b !== void 0 ? _b : []);
|
||
$$invalidate(8, showPublishingView = true);
|
||
for (const note of changedToPublish.concat(unpublishedToPublish)) {
|
||
processingPaths.push(note.path);
|
||
let isPublished = yield publisher.publish(note);
|
||
$$invalidate(9, processingPaths = processingPaths.filter((path) => path !== note.path));
|
||
if (isPublished) {
|
||
$$invalidate(6, publishedPaths = [...publishedPaths, note.path]);
|
||
} else {
|
||
$$invalidate(7, failedPublish = [...failedPublish, note.path]);
|
||
}
|
||
}
|
||
for (const path of pathsToDelete) {
|
||
processingPaths.push(path);
|
||
let isDeleted = yield publisher.deleteNote(path);
|
||
$$invalidate(9, processingPaths = processingPaths.filter((p) => p !== path));
|
||
if (isDeleted) {
|
||
$$invalidate(6, publishedPaths = [...publishedPaths, path]);
|
||
} else {
|
||
$$invalidate(7, failedPublish = [...failedPublish, path]);
|
||
}
|
||
}
|
||
});
|
||
const emptyNode = {
|
||
name: "",
|
||
isRoot: false,
|
||
path: "",
|
||
indeterminate: false,
|
||
checked: false
|
||
};
|
||
$$self.$$set = ($$props2) => {
|
||
if ("publishStatusManager" in $$props2)
|
||
$$invalidate(19, publishStatusManager = $$props2.publishStatusManager);
|
||
if ("publisher" in $$props2)
|
||
$$invalidate(20, publisher = $$props2.publisher);
|
||
if ("showDiff" in $$props2)
|
||
$$invalidate(0, showDiff = $$props2.showDiff);
|
||
if ("close" in $$props2)
|
||
$$invalidate(1, close = $$props2.close);
|
||
};
|
||
$$self.$$.update = () => {
|
||
if ($$self.$$.dirty & /*publishStatus*/
|
||
4) {
|
||
$:
|
||
$$invalidate(14, publishedNotesTree = publishStatus ? filePathsToTree(publishStatus.publishedNotes.map((note) => note.path), "Published Notes") : null);
|
||
}
|
||
if ($$self.$$.dirty & /*publishStatus*/
|
||
4) {
|
||
$:
|
||
$$invalidate(11, changedNotesTree = publishStatus ? filePathsToTree(publishStatus.changedNotes.map((note) => note.path), "Changed Notes") : null);
|
||
}
|
||
if ($$self.$$.dirty & /*publishStatus*/
|
||
4) {
|
||
$:
|
||
$$invalidate(10, deletedNoteTree = publishStatus ? filePathsToTree(publishStatus.deletedNotePaths, "Deleted Notes") : null);
|
||
}
|
||
if ($$self.$$.dirty & /*publishStatus*/
|
||
4) {
|
||
$:
|
||
$$invalidate(12, unpublishedNoteTree = publishStatus ? filePathsToTree(publishStatus.unpublishedNotes.map((note) => note.path), "Unpublished Notes") : null);
|
||
}
|
||
if ($$self.$$.dirty & /*publishedPaths, failedPublish, unpublishedToPublish, changedToPublish, pathsToDelete*/
|
||
248) {
|
||
$:
|
||
$$invalidate(13, publishProgress = (publishedPaths.length + failedPublish.length) / (unpublishedToPublish.length + changedToPublish.length + pathsToDelete.length) * 100);
|
||
}
|
||
};
|
||
return [
|
||
showDiff,
|
||
close,
|
||
publishStatus,
|
||
unpublishedToPublish,
|
||
changedToPublish,
|
||
pathsToDelete,
|
||
publishedPaths,
|
||
failedPublish,
|
||
showPublishingView,
|
||
processingPaths,
|
||
deletedNoteTree,
|
||
changedNotesTree,
|
||
unpublishedNoteTree,
|
||
publishProgress,
|
||
publishedNotesTree,
|
||
rotatingCog,
|
||
bigRotatingCog,
|
||
publishMarkedNotes,
|
||
emptyNode,
|
||
publishStatusManager,
|
||
publisher
|
||
];
|
||
}
|
||
var PublicationCenter = class extends SvelteComponent {
|
||
constructor(options) {
|
||
super();
|
||
init(
|
||
this,
|
||
options,
|
||
instance3,
|
||
create_fragment3,
|
||
safe_not_equal,
|
||
{
|
||
publishStatusManager: 19,
|
||
publisher: 20,
|
||
showDiff: 0,
|
||
close: 1
|
||
},
|
||
add_css2
|
||
);
|
||
}
|
||
};
|
||
var PublicationCenter_default = PublicationCenter;
|
||
|
||
// src/ui/DiffView.svelte
|
||
function add_css3(target) {
|
||
append_styles(target, "svelte-1mfa8dd", "pre.svelte-1mfa8dd{display:block;white-space:pre-wrap;word-wrap:break-word}");
|
||
}
|
||
function get_each_context3(ctx, list, i) {
|
||
const child_ctx = ctx.slice();
|
||
child_ctx[1] = list[i];
|
||
return child_ctx;
|
||
}
|
||
function create_if_block3(ctx) {
|
||
let div;
|
||
let each_value = ensure_array_like(
|
||
/*diff*/
|
||
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));
|
||
}
|
||
return {
|
||
c() {
|
||
div = element("div");
|
||
for (let i = 0; i < each_blocks.length; i += 1) {
|
||
each_blocks[i].c();
|
||
}
|
||
},
|
||
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);
|
||
}
|
||
}
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*diff*/
|
||
1) {
|
||
each_value = ensure_array_like(
|
||
/*diff*/
|
||
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);
|
||
} else {
|
||
each_blocks[i] = create_each_block3(child_ctx);
|
||
each_blocks[i].c();
|
||
each_blocks[i].m(div, null);
|
||
}
|
||
}
|
||
for (; i < each_blocks.length; i += 1) {
|
||
each_blocks[i].d(1);
|
||
}
|
||
each_blocks.length = each_value.length;
|
||
}
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div);
|
||
}
|
||
destroy_each(each_blocks, detaching);
|
||
}
|
||
};
|
||
}
|
||
function create_else_block3(ctx) {
|
||
let pre;
|
||
let t_value = (
|
||
/*part*/
|
||
ctx[1].value + ""
|
||
);
|
||
let t;
|
||
return {
|
||
c() {
|
||
pre = element("pre");
|
||
t = text(t_value);
|
||
attr(pre, "class", "svelte-1mfa8dd");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, pre, anchor);
|
||
append(pre, t);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*diff*/
|
||
1 && t_value !== (t_value = /*part*/
|
||
ctx2[1].value + ""))
|
||
set_data(t, t_value);
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(pre);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_23(ctx) {
|
||
let pre;
|
||
let t_value = (
|
||
/*part*/
|
||
ctx[1].value + ""
|
||
);
|
||
let t;
|
||
return {
|
||
c() {
|
||
pre = element("pre");
|
||
t = text(t_value);
|
||
set_style(pre, "display", "block");
|
||
set_style(pre, "background-color", "rgba(255, 170, 170, 0.5)");
|
||
set_style(pre, "color", "var(--text-on-accent)");
|
||
attr(pre, "class", "svelte-1mfa8dd");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, pre, anchor);
|
||
append(pre, t);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*diff*/
|
||
1 && t_value !== (t_value = /*part*/
|
||
ctx2[1].value + ""))
|
||
set_data(t, t_value);
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(pre);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_if_block_13(ctx) {
|
||
let pre;
|
||
let t_value = (
|
||
/*part*/
|
||
ctx[1].value + ""
|
||
);
|
||
let t;
|
||
return {
|
||
c() {
|
||
pre = element("pre");
|
||
t = text(t_value);
|
||
set_style(pre, "display", "block");
|
||
set_style(pre, "background-color", "rgba(170, 255, 170, 0.5)");
|
||
set_style(pre, "color", "var(--text-on-accent)");
|
||
attr(pre, "class", "svelte-1mfa8dd");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, pre, anchor);
|
||
append(pre, t);
|
||
},
|
||
p(ctx2, dirty) {
|
||
if (dirty & /*diff*/
|
||
1 && t_value !== (t_value = /*part*/
|
||
ctx2[1].value + ""))
|
||
set_data(t, t_value);
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(pre);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function create_each_block3(ctx) {
|
||
let if_block_anchor;
|
||
function select_block_type(ctx2, dirty) {
|
||
if (
|
||
/*part*/
|
||
ctx2[1].added
|
||
)
|
||
return create_if_block_13;
|
||
if (
|
||
/*part*/
|
||
ctx2[1].removed
|
||
)
|
||
return create_if_block_23;
|
||
return create_else_block3;
|
||
}
|
||
let current_block_type = select_block_type(ctx, -1);
|
||
let if_block = current_block_type(ctx);
|
||
return {
|
||
c() {
|
||
if_block.c();
|
||
if_block_anchor = empty();
|
||
},
|
||
m(target, 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);
|
||
}
|
||
}
|
||
},
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(if_block_anchor);
|
||
}
|
||
if_block.d(detaching);
|
||
}
|
||
};
|
||
}
|
||
function create_fragment4(ctx) {
|
||
let div1;
|
||
let div0;
|
||
let t2;
|
||
let hr;
|
||
let t3;
|
||
let if_block = (
|
||
/*diff*/
|
||
ctx[0] && create_if_block3(ctx)
|
||
);
|
||
return {
|
||
c() {
|
||
div1 = element("div");
|
||
div0 = element("div");
|
||
div0.innerHTML = `Differences between your local file and the published file.
|
||
<br/>
|
||
The content may look a bit different from your note. This is because it shows the note after being processed by the plugin.`;
|
||
t2 = space();
|
||
hr = element("hr");
|
||
t3 = space();
|
||
if (if_block)
|
||
if_block.c();
|
||
attr(div0, "class", "info callout");
|
||
},
|
||
m(target, anchor) {
|
||
insert(target, div1, anchor);
|
||
append(div1, div0);
|
||
append(div1, t2);
|
||
append(div1, hr);
|
||
append(div1, t3);
|
||
if (if_block)
|
||
if_block.m(div1, null);
|
||
},
|
||
p(ctx2, [dirty]) {
|
||
if (
|
||
/*diff*/
|
||
ctx2[0]
|
||
) {
|
||
if (if_block) {
|
||
if_block.p(ctx2, dirty);
|
||
} else {
|
||
if_block = create_if_block3(ctx2);
|
||
if_block.c();
|
||
if_block.m(div1, null);
|
||
}
|
||
} else if (if_block) {
|
||
if_block.d(1);
|
||
if_block = null;
|
||
}
|
||
},
|
||
i: noop,
|
||
o: noop,
|
||
d(detaching) {
|
||
if (detaching) {
|
||
detach(div1);
|
||
}
|
||
if (if_block)
|
||
if_block.d();
|
||
}
|
||
};
|
||
}
|
||
function instance4($$self, $$props, $$invalidate) {
|
||
let { diff: diff2 } = $$props;
|
||
$$self.$$set = ($$props2) => {
|
||
if ("diff" in $$props2)
|
||
$$invalidate(0, diff2 = $$props2.diff);
|
||
};
|
||
return [diff2];
|
||
}
|
||
var DiffView = class extends SvelteComponent {
|
||
constructor(options) {
|
||
super();
|
||
init(this, options, instance4, create_fragment4, safe_not_equal, { diff: 0 }, add_css3);
|
||
}
|
||
};
|
||
var DiffView_default = DiffView;
|
||
|
||
// node_modules/diff/lib/index.mjs
|
||
function Diff() {
|
||
}
|
||
Diff.prototype = {
|
||
diff: function diff(oldString, newString) {
|
||
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
||
var callback = options.callback;
|
||
if (typeof options === "function") {
|
||
callback = options;
|
||
options = {};
|
||
}
|
||
this.options = options;
|
||
var self2 = this;
|
||
function done(value) {
|
||
if (callback) {
|
||
setTimeout(function() {
|
||
callback(void 0, value);
|
||
}, 0);
|
||
return true;
|
||
} else {
|
||
return value;
|
||
}
|
||
}
|
||
oldString = this.castInput(oldString);
|
||
newString = this.castInput(newString);
|
||
oldString = this.removeEmpty(this.tokenize(oldString));
|
||
newString = this.removeEmpty(this.tokenize(newString));
|
||
var newLen = newString.length, oldLen = oldString.length;
|
||
var editLength = 1;
|
||
var maxEditLength = newLen + oldLen;
|
||
if (options.maxEditLength) {
|
||
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
||
}
|
||
var bestPath = [{
|
||
newPos: -1,
|
||
components: []
|
||
}];
|
||
var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
|
||
if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
|
||
return done([{
|
||
value: this.join(newString),
|
||
count: newString.length
|
||
}]);
|
||
}
|
||
function execEditLength() {
|
||
for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
|
||
var basePath = void 0;
|
||
var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
|
||
if (addPath) {
|
||
bestPath[diagonalPath - 1] = void 0;
|
||
}
|
||
var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
|
||
if (!canAdd && !canRemove) {
|
||
bestPath[diagonalPath] = void 0;
|
||
continue;
|
||
}
|
||
if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
|
||
basePath = clonePath(removePath);
|
||
self2.pushComponent(basePath.components, void 0, true);
|
||
} else {
|
||
basePath = addPath;
|
||
basePath.newPos++;
|
||
self2.pushComponent(basePath.components, true, void 0);
|
||
}
|
||
_oldPos = self2.extractCommon(basePath, newString, oldString, diagonalPath);
|
||
if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
|
||
return done(buildValues(self2, basePath.components, newString, oldString, self2.useLongestToken));
|
||
} else {
|
||
bestPath[diagonalPath] = basePath;
|
||
}
|
||
}
|
||
editLength++;
|
||
}
|
||
if (callback) {
|
||
(function exec() {
|
||
setTimeout(function() {
|
||
if (editLength > maxEditLength) {
|
||
return callback();
|
||
}
|
||
if (!execEditLength()) {
|
||
exec();
|
||
}
|
||
}, 0);
|
||
})();
|
||
} else {
|
||
while (editLength <= maxEditLength) {
|
||
var ret = execEditLength();
|
||
if (ret) {
|
||
return ret;
|
||
}
|
||
}
|
||
}
|
||
},
|
||
pushComponent: function pushComponent(components, added, removed) {
|
||
var last = components[components.length - 1];
|
||
if (last && last.added === added && last.removed === removed) {
|
||
components[components.length - 1] = {
|
||
count: last.count + 1,
|
||
added,
|
||
removed
|
||
};
|
||
} else {
|
||
components.push({
|
||
count: 1,
|
||
added,
|
||
removed
|
||
});
|
||
}
|
||
},
|
||
extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
|
||
var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0;
|
||
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
|
||
newPos++;
|
||
oldPos++;
|
||
commonCount++;
|
||
}
|
||
if (commonCount) {
|
||
basePath.components.push({
|
||
count: commonCount
|
||
});
|
||
}
|
||
basePath.newPos = newPos;
|
||
return oldPos;
|
||
},
|
||
equals: function equals(left2, right2) {
|
||
if (this.options.comparator) {
|
||
return this.options.comparator(left2, right2);
|
||
} else {
|
||
return left2 === right2 || this.options.ignoreCase && left2.toLowerCase() === right2.toLowerCase();
|
||
}
|
||
},
|
||
removeEmpty: function removeEmpty(array) {
|
||
var ret = [];
|
||
for (var i = 0; i < array.length; i++) {
|
||
if (array[i]) {
|
||
ret.push(array[i]);
|
||
}
|
||
}
|
||
return ret;
|
||
},
|
||
castInput: function castInput(value) {
|
||
return value;
|
||
},
|
||
tokenize: function tokenize(value) {
|
||
return value.split("");
|
||
},
|
||
join: function join(chars) {
|
||
return chars.join("");
|
||
}
|
||
};
|
||
function buildValues(diff2, components, newString, oldString, useLongestToken) {
|
||
var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
|
||
for (; componentPos < componentLen; componentPos++) {
|
||
var component = components[componentPos];
|
||
if (!component.removed) {
|
||
if (!component.added && useLongestToken) {
|
||
var value = newString.slice(newPos, newPos + component.count);
|
||
value = value.map(function(value2, i) {
|
||
var oldValue = oldString[oldPos + i];
|
||
return oldValue.length > value2.length ? oldValue : value2;
|
||
});
|
||
component.value = diff2.join(value);
|
||
} else {
|
||
component.value = diff2.join(newString.slice(newPos, newPos + component.count));
|
||
}
|
||
newPos += component.count;
|
||
if (!component.added) {
|
||
oldPos += component.count;
|
||
}
|
||
} else {
|
||
component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
|
||
oldPos += component.count;
|
||
if (componentPos && components[componentPos - 1].added) {
|
||
var tmp = components[componentPos - 1];
|
||
components[componentPos - 1] = components[componentPos];
|
||
components[componentPos] = tmp;
|
||
}
|
||
}
|
||
}
|
||
var lastComponent = components[componentLen - 1];
|
||
if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff2.equals("", lastComponent.value)) {
|
||
components[componentLen - 2].value += lastComponent.value;
|
||
components.pop();
|
||
}
|
||
return components;
|
||
}
|
||
function clonePath(path) {
|
||
return {
|
||
newPos: path.newPos,
|
||
components: path.components.slice(0)
|
||
};
|
||
}
|
||
var characterDiff = new Diff();
|
||
var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
|
||
var reWhitespace = /\S/;
|
||
var wordDiff = new Diff();
|
||
wordDiff.equals = function(left2, right2) {
|
||
if (this.options.ignoreCase) {
|
||
left2 = left2.toLowerCase();
|
||
right2 = right2.toLowerCase();
|
||
}
|
||
return left2 === right2 || this.options.ignoreWhitespace && !reWhitespace.test(left2) && !reWhitespace.test(right2);
|
||
};
|
||
wordDiff.tokenize = function(value) {
|
||
var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
|
||
for (var i = 0; i < tokens.length - 1; i++) {
|
||
if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
|
||
tokens[i] += tokens[i + 2];
|
||
tokens.splice(i + 1, 2);
|
||
i--;
|
||
}
|
||
}
|
||
return tokens;
|
||
};
|
||
var lineDiff = new Diff();
|
||
lineDiff.tokenize = function(value) {
|
||
var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
||
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
||
linesAndNewlines.pop();
|
||
}
|
||
for (var i = 0; i < linesAndNewlines.length; i++) {
|
||
var line = linesAndNewlines[i];
|
||
if (i % 2 && !this.options.newlineIsToken) {
|
||
retLines[retLines.length - 1] += line;
|
||
} else {
|
||
if (this.options.ignoreWhitespace) {
|
||
line = line.trim();
|
||
}
|
||
retLines.push(line);
|
||
}
|
||
}
|
||
return retLines;
|
||
};
|
||
function diffLines(oldStr, newStr, callback) {
|
||
return lineDiff.diff(oldStr, newStr, callback);
|
||
}
|
||
var sentenceDiff = new Diff();
|
||
sentenceDiff.tokenize = function(value) {
|
||
return value.split(/(\S.+?[.!?])(?=\s+|$)/);
|
||
};
|
||
var cssDiff = new Diff();
|
||
cssDiff.tokenize = function(value) {
|
||
return value.split(/([{}:;,]|\s+)/);
|
||
};
|
||
function _typeof(obj) {
|
||
"@babel/helpers - typeof";
|
||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||
_typeof = function(obj2) {
|
||
return typeof obj2;
|
||
};
|
||
} else {
|
||
_typeof = function(obj2) {
|
||
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
||
};
|
||
}
|
||
return _typeof(obj);
|
||
}
|
||
var objectPrototypeToString = Object.prototype.toString;
|
||
var jsonDiff = new Diff();
|
||
jsonDiff.useLongestToken = true;
|
||
jsonDiff.tokenize = lineDiff.tokenize;
|
||
jsonDiff.castInput = function(value) {
|
||
var _this$options = this.options, undefinedReplacement = _this$options.undefinedReplacement, _this$options$stringi = _this$options.stringifyReplacer, stringifyReplacer = _this$options$stringi === void 0 ? function(k, v) {
|
||
return typeof v === "undefined" ? undefinedReplacement : v;
|
||
} : _this$options$stringi;
|
||
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, " ");
|
||
};
|
||
jsonDiff.equals = function(left2, right2) {
|
||
return Diff.prototype.equals.call(jsonDiff, left2.replace(/,([\r\n])/g, "$1"), right2.replace(/,([\r\n])/g, "$1"));
|
||
};
|
||
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
||
stack = stack || [];
|
||
replacementStack = replacementStack || [];
|
||
if (replacer) {
|
||
obj = replacer(key, obj);
|
||
}
|
||
var i;
|
||
for (i = 0; i < stack.length; i += 1) {
|
||
if (stack[i] === obj) {
|
||
return replacementStack[i];
|
||
}
|
||
}
|
||
var canonicalizedObj;
|
||
if ("[object Array]" === objectPrototypeToString.call(obj)) {
|
||
stack.push(obj);
|
||
canonicalizedObj = new Array(obj.length);
|
||
replacementStack.push(canonicalizedObj);
|
||
for (i = 0; i < obj.length; i += 1) {
|
||
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
|
||
}
|
||
stack.pop();
|
||
replacementStack.pop();
|
||
return canonicalizedObj;
|
||
}
|
||
if (obj && obj.toJSON) {
|
||
obj = obj.toJSON();
|
||
}
|
||
if (_typeof(obj) === "object" && obj !== null) {
|
||
stack.push(obj);
|
||
canonicalizedObj = {};
|
||
replacementStack.push(canonicalizedObj);
|
||
var sortedKeys = [], _key;
|
||
for (_key in obj) {
|
||
if (obj.hasOwnProperty(_key)) {
|
||
sortedKeys.push(_key);
|
||
}
|
||
}
|
||
sortedKeys.sort();
|
||
for (i = 0; i < sortedKeys.length; i += 1) {
|
||
_key = sortedKeys[i];
|
||
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
||
}
|
||
stack.pop();
|
||
replacementStack.pop();
|
||
} else {
|
||
canonicalizedObj = obj;
|
||
}
|
||
return canonicalizedObj;
|
||
}
|
||
var arrayDiff = new Diff();
|
||
arrayDiff.tokenize = function(value) {
|
||
return value.slice();
|
||
};
|
||
arrayDiff.join = arrayDiff.removeEmpty = function(value) {
|
||
return value;
|
||
};
|
||
|
||
// src/ui/PublishModal.ts
|
||
var PublishModal = class {
|
||
constructor(app, publishStatusManager, publisher, siteManager, settings) {
|
||
this.showDiff = (notePath) => __async(this, null, function* () {
|
||
try {
|
||
const remoteContent = yield this.siteManager.getNoteContent(notePath);
|
||
const localFile = this.vault.getAbstractFileByPath(notePath);
|
||
console.log(localFile);
|
||
if (localFile instanceof import_obsidian5.TFile) {
|
||
const [localContent, _] = yield this.publisher.generateMarkdown(localFile);
|
||
const diff2 = diffLines(remoteContent, localContent);
|
||
let diffView;
|
||
const diffModal = new import_obsidian5.Modal(this.modal.app);
|
||
diffModal.titleEl.createEl("span", { text: `${localFile.basename}` }).prepend(this.getIcon("file-diff"));
|
||
diffModal.onOpen = () => {
|
||
diffView = new DiffView_default({
|
||
target: diffModal.contentEl,
|
||
props: { diff: diff2 }
|
||
});
|
||
};
|
||
this.modal.onClose = () => {
|
||
if (diffView) {
|
||
diffView.$destroy();
|
||
}
|
||
};
|
||
diffModal.open();
|
||
}
|
||
} catch (e) {
|
||
console.error(e);
|
||
}
|
||
});
|
||
this.open = () => {
|
||
this.modal.onClose = () => {
|
||
this.publicationCenterUi.$destroy();
|
||
};
|
||
this.modal.onOpen = () => {
|
||
this.modal.contentEl.empty();
|
||
this.publicationCenterUi = new PublicationCenter_default({
|
||
target: this.modal.contentEl,
|
||
props: {
|
||
publishStatusManager: this.publishStatusManager,
|
||
publisher: this.publisher,
|
||
showDiff: this.showDiff,
|
||
close: () => {
|
||
this.modal.close();
|
||
}
|
||
}
|
||
});
|
||
};
|
||
this.modal.open();
|
||
};
|
||
this.modal = new import_obsidian5.Modal(app);
|
||
this.settings = settings;
|
||
this.publishStatusManager = publishStatusManager;
|
||
this.publisher = publisher;
|
||
this.siteManager = siteManager;
|
||
this.vault = app.vault;
|
||
this.modal.titleEl.createEl("span", { text: "Publication Center" }).prepend(this.getIcon("book-up"));
|
||
}
|
||
getIcon(name) {
|
||
var _a2;
|
||
const icon = (_a2 = (0, import_obsidian5.getIcon)(name)) != null ? _a2 : document.createElement("span");
|
||
if (icon instanceof SVGSVGElement) {
|
||
icon.style.marginRight = "4px";
|
||
}
|
||
return icon;
|
||
}
|
||
};
|
||
|
||
// src/publisher/PublishStatusManager.ts
|
||
var PublishStatusManager = class {
|
||
constructor(siteManager, publisher) {
|
||
this.siteManager = siteManager;
|
||
this.publisher = publisher;
|
||
}
|
||
getDeletedNotePaths() {
|
||
return __async(this, null, function* () {
|
||
const remoteNoteHashes = yield this.siteManager.getNoteHashes();
|
||
const marked = yield this.publisher.getFilesMarkedForPublishing();
|
||
return this.generateDeletedContentPaths(
|
||
remoteNoteHashes,
|
||
marked.notes.map((f) => f.path)
|
||
);
|
||
});
|
||
}
|
||
getDeletedImagesPaths() {
|
||
return __async(this, null, function* () {
|
||
const remoteImageHashes = yield this.siteManager.getImageHashes();
|
||
const marked = yield this.publisher.getFilesMarkedForPublishing();
|
||
return this.generateDeletedContentPaths(
|
||
remoteImageHashes,
|
||
marked.images
|
||
);
|
||
});
|
||
}
|
||
generateDeletedContentPaths(remoteNoteHashes, marked) {
|
||
const deletedContentPaths = [];
|
||
Object.keys(remoteNoteHashes).forEach((key) => {
|
||
if (!key.endsWith(".js") && !marked.find((f) => f === key)) {
|
||
deletedContentPaths.push(key);
|
||
}
|
||
});
|
||
return deletedContentPaths;
|
||
}
|
||
getPublishStatus() {
|
||
return __async(this, null, function* () {
|
||
const unpublishedNotes = [];
|
||
const publishedNotes = [];
|
||
const changedNotes = [];
|
||
const remoteNoteHashes = yield this.siteManager.getNoteHashes();
|
||
const remoteImageHashes = yield this.siteManager.getImageHashes();
|
||
const marked = yield this.publisher.getFilesMarkedForPublishing();
|
||
for (const file of marked.notes) {
|
||
const [content, _] = yield this.publisher.generateMarkdown(file);
|
||
const localHash = generateBlobHash(content);
|
||
const remoteHash = remoteNoteHashes[file.path];
|
||
if (!remoteHash) {
|
||
unpublishedNotes.push(file);
|
||
} else if (remoteHash === localHash) {
|
||
publishedNotes.push(file);
|
||
} else {
|
||
changedNotes.push(file);
|
||
}
|
||
}
|
||
const deletedNotePaths = this.generateDeletedContentPaths(
|
||
remoteNoteHashes,
|
||
marked.notes.map((f) => f.path)
|
||
);
|
||
const deletedImagePaths = this.generateDeletedContentPaths(
|
||
remoteImageHashes,
|
||
marked.images
|
||
);
|
||
unpublishedNotes.sort((a, b) => a.path > b.path ? 1 : -1);
|
||
publishedNotes.sort((a, b) => a.path > b.path ? 1 : -1);
|
||
changedNotes.sort((a, b) => a.path > b.path ? 1 : -1);
|
||
deletedNotePaths.sort((a, b) => a > b ? 1 : -1);
|
||
return {
|
||
unpublishedNotes,
|
||
publishedNotes,
|
||
changedNotes,
|
||
deletedNotePaths,
|
||
deletedImagePaths
|
||
};
|
||
});
|
||
}
|
||
};
|
||
|
||
// src/publisher/ObsidianFrontMatterEngine.ts
|
||
var ObsidianFrontMatterEngine = class {
|
||
constructor(vault, metadataCache, file) {
|
||
this.generatedFrontMatter = {};
|
||
this.metadataCache = metadataCache;
|
||
this.vault = vault;
|
||
this.file = file;
|
||
}
|
||
set(key, value) {
|
||
this.generatedFrontMatter[key] = value;
|
||
return this;
|
||
}
|
||
remove(key) {
|
||
this.generatedFrontMatter[key] = void 0;
|
||
return this;
|
||
}
|
||
get(key) {
|
||
return this.getFrontMatterSnapshot()[key];
|
||
}
|
||
apply() {
|
||
return __async(this, null, function* () {
|
||
const newFrontMatter = this.getFrontMatterSnapshot();
|
||
const content = yield this.vault.cachedRead(this.file);
|
||
const frontmatterRegex = /^\s*?---\n([\s\S]*?)\n---/g;
|
||
const yaml = this.frontMatterToYaml(newFrontMatter);
|
||
let newContent = "";
|
||
if (content.match(frontmatterRegex)) {
|
||
newContent = content.replace(frontmatterRegex, (_match) => {
|
||
return yaml;
|
||
});
|
||
} else {
|
||
newContent = `${yaml}
|
||
${content}`;
|
||
}
|
||
yield this.vault.modify(this.file, newContent);
|
||
});
|
||
}
|
||
frontMatterToYaml(frontMatter) {
|
||
for (const key of Object.keys(frontMatter)) {
|
||
if (frontMatter[key] === void 0) {
|
||
delete frontMatter[key];
|
||
}
|
||
}
|
||
if (Object.keys(frontMatter).length === 0) {
|
||
return "";
|
||
}
|
||
let yaml = "---\n";
|
||
for (const key of Object.keys(frontMatter)) {
|
||
yaml += `${key}: ${frontMatter[key]}
|
||
`;
|
||
}
|
||
yaml += "---";
|
||
return yaml;
|
||
}
|
||
getFrontMatterSnapshot() {
|
||
var _a2, _b;
|
||
const cachedFrontMatter = __spreadValues({}, (_b = this.metadataCache.getCache((_a2 = this.file) == null ? void 0 : _a2.path)) == null ? void 0 : _b.frontmatter);
|
||
delete cachedFrontMatter["position"];
|
||
return __spreadValues(__spreadValues({}, cachedFrontMatter), this.generatedFrontMatter);
|
||
}
|
||
};
|
||
|
||
// src/publisher/DigitalGardenSiteManager.ts
|
||
var import_obsidian6 = require("obsidian");
|
||
var DigitalGardenSiteManager = class {
|
||
constructor(metadataCache, settings) {
|
||
this.settings = settings;
|
||
this.metadataCache = metadataCache;
|
||
this.rewriteRules = getRewriteRules(settings.pathRewriteRules);
|
||
}
|
||
updateEnv() {
|
||
return __async(this, null, function* () {
|
||
const octokit = new Octokit({ auth: this.settings.githubToken });
|
||
const theme = JSON.parse(this.settings.theme);
|
||
const baseTheme = this.settings.baseTheme;
|
||
const siteName = this.settings.siteName;
|
||
let gardenBaseUrl = "";
|
||
if (this.settings.gardenBaseUrl && !this.settings.gardenBaseUrl.startsWith("ghp_") && !this.settings.gardenBaseUrl.startsWith("github_pat") && this.settings.gardenBaseUrl.contains(".")) {
|
||
gardenBaseUrl = this.settings.gardenBaseUrl;
|
||
}
|
||
let envSettings = "";
|
||
if (theme.name !== "default") {
|
||
envSettings = `THEME=${theme.cssUrl}
|
||
BASE_THEME=${baseTheme}`;
|
||
}
|
||
envSettings += `
|
||
SITE_NAME_HEADER=${siteName}`;
|
||
envSettings += `
|
||
SITE_BASE_URL=${gardenBaseUrl}`;
|
||
envSettings += `
|
||
SHOW_CREATED_TIMESTAMP=${this.settings.showCreatedTimestamp}`;
|
||
envSettings += `
|
||
TIMESTAMP_FORMAT=${this.settings.timestampFormat}`;
|
||
envSettings += `
|
||
SHOW_UPDATED_TIMESTAMP=${this.settings.showUpdatedTimestamp}`;
|
||
envSettings += `
|
||
NOTE_ICON_DEFAULT=${this.settings.defaultNoteIcon}`;
|
||
envSettings += `
|
||
NOTE_ICON_TITLE=${this.settings.showNoteIconOnTitle}`;
|
||
envSettings += `
|
||
NOTE_ICON_FILETREE=${this.settings.showNoteIconInFileTree}`;
|
||
envSettings += `
|
||
NOTE_ICON_INTERNAL_LINKS=${this.settings.showNoteIconOnInternalLink}`;
|
||
envSettings += `
|
||
NOTE_ICON_BACK_LINKS=${this.settings.showNoteIconOnBackLink}`;
|
||
envSettings += `
|
||
STYLE_SETTINGS_CSS="${this.settings.styleSettingsCss}"`;
|
||
const defaultNoteSettings = __spreadValues({}, this.settings.defaultNoteSettings);
|
||
for (const [key, value] of Object.entries(defaultNoteSettings)) {
|
||
envSettings += `
|
||
${key}=${value}`;
|
||
}
|
||
const base64Settings = gBase64.encode(envSettings);
|
||
let fileExists = true;
|
||
let currentFile = null;
|
||
try {
|
||
currentFile = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: ".env"
|
||
}
|
||
);
|
||
} catch (error) {
|
||
fileExists = false;
|
||
}
|
||
yield octokit.request("PUT /repos/{owner}/{repo}/contents/{path}", {
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: ".env",
|
||
message: "Update settings",
|
||
content: base64Settings,
|
||
// @ts-expect-error data is not yet type-guarded
|
||
sha: fileExists ? currentFile.data.sha : null
|
||
});
|
||
});
|
||
}
|
||
getNoteUrl(file) {
|
||
var _a2;
|
||
if (!this.settings.gardenBaseUrl) {
|
||
new import_obsidian6.Notice("Please set the garden base url in the settings");
|
||
throw new Error("Garden base url not set");
|
||
}
|
||
const baseUrl = `https://${extractBaseUrl(
|
||
this.settings.gardenBaseUrl
|
||
)}`;
|
||
const noteUrlPath = generateUrlPath(
|
||
getGardenPathForNote(file.path, this.rewriteRules),
|
||
this.settings.slugifyEnabled
|
||
);
|
||
let urlPath = `/${noteUrlPath}`;
|
||
const frontMatter = (_a2 = this.metadataCache.getCache(file.path)) == null ? void 0 : _a2.frontmatter;
|
||
if (frontMatter && frontMatter["dg-home"] === true) {
|
||
urlPath = "/";
|
||
} else if (frontMatter == null ? void 0 : frontMatter.permalink) {
|
||
urlPath = `/${frontMatter.permalink}`;
|
||
} else if (frontMatter == null ? void 0 : frontMatter["dg-permalink"]) {
|
||
urlPath = `/${frontMatter["dg-permalink"]}`;
|
||
}
|
||
return `${baseUrl}${urlPath}`;
|
||
}
|
||
getNoteContent(path) {
|
||
return __async(this, null, function* () {
|
||
if (path.startsWith("/")) {
|
||
path = path.substring(1);
|
||
}
|
||
const octokit = new Octokit({ auth: this.settings.githubToken });
|
||
const response = yield octokit.request(
|
||
`GET /repos/{owner}/{repo}/contents/{path}`,
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: "src/site/notes/" + path
|
||
}
|
||
);
|
||
const content = gBase64.decode(response.data.content);
|
||
return content;
|
||
});
|
||
}
|
||
getNoteHashes() {
|
||
return __async(this, null, function* () {
|
||
const octokit = new Octokit({ auth: this.settings.githubToken });
|
||
const response = yield octokit.request(
|
||
`GET /repos/{owner}/{repo}/git/trees/{tree_sha}?recursive=${Math.ceil(
|
||
Math.random() * 1e3
|
||
)}`,
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
tree_sha: "HEAD"
|
||
}
|
||
);
|
||
const files = response.data.tree;
|
||
const notes = files.filter(
|
||
(x) => x.path.startsWith("src/site/notes/") && x.type === "blob" && x.path !== "src/site/notes/notes.json"
|
||
);
|
||
const hashes = {};
|
||
for (const note of notes) {
|
||
const vaultPath = note.path.replace("src/site/notes/", "");
|
||
hashes[vaultPath] = note.sha;
|
||
}
|
||
return hashes;
|
||
});
|
||
}
|
||
getImageHashes() {
|
||
return __async(this, null, function* () {
|
||
const octokit = new Octokit({ auth: this.settings.githubToken });
|
||
const response = yield octokit.request(
|
||
`GET /repos/{owner}/{repo}/git/trees/{tree_sha}?recursive=${Math.ceil(
|
||
Math.random() * 1e3
|
||
)}`,
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
tree_sha: "HEAD"
|
||
}
|
||
);
|
||
const files = response.data.tree;
|
||
const images = files.filter(
|
||
(x) => x.path.startsWith("src/site/img/user/") && x.type === "blob"
|
||
);
|
||
const hashes = {};
|
||
for (const img of images) {
|
||
const vaultPath = decodeURI(
|
||
img.path.replace("src/site/img/user/", "")
|
||
);
|
||
hashes[vaultPath] = img.sha;
|
||
}
|
||
return hashes;
|
||
});
|
||
}
|
||
/**
|
||
*
|
||
* @returns {Promise<string>} The url of the created PR. Null if unable to create PR.
|
||
*/
|
||
createPullRequestWithSiteChanges() {
|
||
return __async(this, null, function* () {
|
||
const octokit = new Octokit({ auth: this.settings.githubToken });
|
||
const latestRelease = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/releases/latest",
|
||
{
|
||
owner: "oleeskild",
|
||
repo: "digitalgarden"
|
||
}
|
||
);
|
||
const templateVersion = latestRelease.data.tag_name;
|
||
const uuid = crypto.randomUUID();
|
||
const branchName = "update-template-to-v" + templateVersion + "-" + uuid;
|
||
const latestCommit = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/commits/HEAD",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo
|
||
}
|
||
);
|
||
yield this.createNewBranch(octokit, branchName, latestCommit.data.sha);
|
||
yield this.deleteFiles(octokit, branchName);
|
||
yield this.addFilesIfMissing(octokit, branchName);
|
||
yield this.modifyFiles(octokit, branchName);
|
||
const prUrl = yield this.createPullRequest(
|
||
octokit,
|
||
branchName,
|
||
templateVersion
|
||
);
|
||
return prUrl;
|
||
});
|
||
}
|
||
createPullRequest(octokit, branchName, templateVersion) {
|
||
return __async(this, null, function* () {
|
||
try {
|
||
const repoInfo = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo
|
||
}
|
||
);
|
||
const defaultBranch = repoInfo.data.default_branch;
|
||
const pr = yield octokit.request(
|
||
"POST /repos/{owner}/{repo}/pulls",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
title: `Update template to version ${templateVersion}`,
|
||
head: branchName,
|
||
base: defaultBranch,
|
||
body: `Update to latest template version.
|
||
[Release Notes](https://github.com/oleeskild/digitalgarden/releases/tag/${templateVersion})`
|
||
}
|
||
);
|
||
return pr.data.html_url;
|
||
} catch (e) {
|
||
throw new Error("Unable to create PR");
|
||
}
|
||
});
|
||
}
|
||
deleteFiles(octokit, branchName) {
|
||
return __async(this, null, function* () {
|
||
const pluginInfo = yield this.getPluginInfo(octokit);
|
||
const filesToDelete = pluginInfo.filesToDelete;
|
||
for (const file of filesToDelete) {
|
||
try {
|
||
const latestFile = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: file,
|
||
ref: branchName
|
||
}
|
||
);
|
||
yield octokit.request(
|
||
"DELETE /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: file,
|
||
// @ts-expect-error data is not yet type-guarded
|
||
sha: latestFile.data.sha,
|
||
message: `Delete ${file}`,
|
||
branch: branchName
|
||
}
|
||
);
|
||
} catch (e) {
|
||
}
|
||
}
|
||
});
|
||
}
|
||
modifyFiles(octokit, branchName) {
|
||
return __async(this, null, function* () {
|
||
var _a2;
|
||
const pluginInfo = yield this.getPluginInfo(octokit);
|
||
const filesToModify = pluginInfo.filesToModify;
|
||
for (const file of filesToModify) {
|
||
const latestFile = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: "oleeskild",
|
||
repo: "digitalgarden",
|
||
path: file
|
||
}
|
||
);
|
||
let currentFile = {};
|
||
let fileExists = true;
|
||
try {
|
||
currentFile = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: file,
|
||
ref: branchName
|
||
}
|
||
);
|
||
} catch (error) {
|
||
fileExists = false;
|
||
}
|
||
const fileHasChanged = (
|
||
// @ts-expect-error data is not yet type-guarded
|
||
latestFile.data.sha !== ((_a2 = currentFile == null ? void 0 : currentFile.data) == null ? void 0 : _a2.sha)
|
||
);
|
||
if (!fileExists || fileHasChanged) {
|
||
yield octokit.request(
|
||
"PUT /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: file,
|
||
branch: branchName,
|
||
message: `Update file ${file}`,
|
||
// @ts-expect-error data is not yet type-guarded
|
||
content: latestFile.data.content,
|
||
// @ts-expect-error data is not yet type-guarded
|
||
sha: fileExists ? currentFile.data.sha : null
|
||
}
|
||
);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
createNewBranch(octokit, branchName, sha) {
|
||
return __async(this, null, function* () {
|
||
try {
|
||
yield octokit.request("POST /repos/{owner}/{repo}/git/refs", {
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
ref: `refs/heads/${branchName}`,
|
||
sha
|
||
});
|
||
} catch (e) {
|
||
}
|
||
});
|
||
}
|
||
addFilesIfMissing(octokit, branchName) {
|
||
return __async(this, null, function* () {
|
||
const pluginInfo = yield this.getPluginInfo(octokit);
|
||
const filesToAdd = pluginInfo.filesToAdd;
|
||
for (const filePath of filesToAdd) {
|
||
try {
|
||
yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: filePath,
|
||
ref: branchName
|
||
}
|
||
);
|
||
} catch (e) {
|
||
const initialFile = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: "oleeskild",
|
||
repo: "digitalgarden",
|
||
path: filePath
|
||
}
|
||
);
|
||
yield octokit.request(
|
||
"PUT /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: filePath,
|
||
branch: branchName,
|
||
message: "Update template file",
|
||
// @ts-expect-error data is not yet type-guarded
|
||
content: initialFile.data.content
|
||
}
|
||
);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
getPluginInfo(octokit) {
|
||
return __async(this, null, function* () {
|
||
const pluginInfoResponse = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: "oleeskild",
|
||
repo: "digitalgarden",
|
||
path: "plugin-info.json"
|
||
}
|
||
);
|
||
const pluginInfo = JSON.parse(
|
||
// @ts-expect-error data is not yet type-guarded
|
||
gBase64.decode(pluginInfoResponse.data.content)
|
||
);
|
||
return pluginInfo;
|
||
});
|
||
}
|
||
};
|
||
|
||
// src/ui/DigitalGardenSettingTab.ts
|
||
var import_obsidian13 = require("obsidian");
|
||
|
||
// src/ui/SettingsView/SettingView.ts
|
||
var import_obsidian11 = require("obsidian");
|
||
|
||
// node_modules/axios/lib/helpers/bind.js
|
||
function bind(fn2, thisArg) {
|
||
return function wrap() {
|
||
return fn2.apply(thisArg, arguments);
|
||
};
|
||
}
|
||
|
||
// node_modules/axios/lib/utils.js
|
||
var { toString } = Object.prototype;
|
||
var { getPrototypeOf } = Object;
|
||
var kindOf = ((cache) => (thing) => {
|
||
const str = toString.call(thing);
|
||
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
||
})(/* @__PURE__ */ Object.create(null));
|
||
var kindOfTest = (type) => {
|
||
type = type.toLowerCase();
|
||
return (thing) => kindOf(thing) === type;
|
||
};
|
||
var typeOfTest = (type) => (thing) => typeof thing === type;
|
||
var { isArray } = Array;
|
||
var isUndefined2 = typeOfTest("undefined");
|
||
function isBuffer(val) {
|
||
return val !== null && !isUndefined2(val) && val.constructor !== null && !isUndefined2(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
||
}
|
||
var isArrayBuffer = kindOfTest("ArrayBuffer");
|
||
function isArrayBufferView(val) {
|
||
let result;
|
||
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
||
result = ArrayBuffer.isView(val);
|
||
} else {
|
||
result = val && val.buffer && isArrayBuffer(val.buffer);
|
||
}
|
||
return result;
|
||
}
|
||
var isString2 = typeOfTest("string");
|
||
var isFunction = typeOfTest("function");
|
||
var isNumber2 = typeOfTest("number");
|
||
var isObject2 = (thing) => thing !== null && typeof thing === "object";
|
||
var isBoolean = (thing) => thing === true || thing === false;
|
||
var isPlainObject2 = (val) => {
|
||
if (kindOf(val) !== "object") {
|
||
return false;
|
||
}
|
||
const prototype3 = getPrototypeOf(val);
|
||
return (prototype3 === null || prototype3 === Object.prototype || Object.getPrototypeOf(prototype3) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
||
};
|
||
var isDate2 = kindOfTest("Date");
|
||
var isFile = kindOfTest("File");
|
||
var isBlob = kindOfTest("Blob");
|
||
var isFileList = kindOfTest("FileList");
|
||
var isStream = (val) => isObject2(val) && isFunction(val.pipe);
|
||
var isFormData = (thing) => {
|
||
let kind;
|
||
return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
|
||
kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
|
||
};
|
||
var isURLSearchParams = kindOfTest("URLSearchParams");
|
||
var trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
||
function forEach(obj, fn2, { allOwnKeys = false } = {}) {
|
||
if (obj === null || typeof obj === "undefined") {
|
||
return;
|
||
}
|
||
let i;
|
||
let l2;
|
||
if (typeof obj !== "object") {
|
||
obj = [obj];
|
||
}
|
||
if (isArray(obj)) {
|
||
for (i = 0, l2 = obj.length; i < l2; i++) {
|
||
fn2.call(null, obj[i], i, obj);
|
||
}
|
||
} else {
|
||
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
||
const len = keys.length;
|
||
let key;
|
||
for (i = 0; i < len; i++) {
|
||
key = keys[i];
|
||
fn2.call(null, obj[key], key, obj);
|
||
}
|
||
}
|
||
}
|
||
function findKey(obj, key) {
|
||
key = key.toLowerCase();
|
||
const keys = Object.keys(obj);
|
||
let i = keys.length;
|
||
let _key;
|
||
while (i-- > 0) {
|
||
_key = keys[i];
|
||
if (key === _key.toLowerCase()) {
|
||
return _key;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
var _global = (() => {
|
||
if (typeof globalThis !== "undefined")
|
||
return globalThis;
|
||
return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
|
||
})();
|
||
var isContextDefined = (context) => !isUndefined2(context) && context !== _global;
|
||
function merge2() {
|
||
const { caseless } = isContextDefined(this) && this || {};
|
||
const result = {};
|
||
const assignValue = (val, key) => {
|
||
const targetKey = caseless && findKey(result, key) || key;
|
||
if (isPlainObject2(result[targetKey]) && isPlainObject2(val)) {
|
||
result[targetKey] = merge2(result[targetKey], val);
|
||
} else if (isPlainObject2(val)) {
|
||
result[targetKey] = merge2({}, val);
|
||
} else if (isArray(val)) {
|
||
result[targetKey] = val.slice();
|
||
} else {
|
||
result[targetKey] = val;
|
||
}
|
||
};
|
||
for (let i = 0, l2 = arguments.length; i < l2; i++) {
|
||
arguments[i] && forEach(arguments[i], assignValue);
|
||
}
|
||
return result;
|
||
}
|
||
var extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
||
forEach(b, (val, key) => {
|
||
if (thisArg && isFunction(val)) {
|
||
a[key] = bind(val, thisArg);
|
||
} else {
|
||
a[key] = val;
|
||
}
|
||
}, { allOwnKeys });
|
||
return a;
|
||
};
|
||
var stripBOM = (content) => {
|
||
if (content.charCodeAt(0) === 65279) {
|
||
content = content.slice(1);
|
||
}
|
||
return content;
|
||
};
|
||
var inherits = (constructor, superConstructor, props, descriptors2) => {
|
||
constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
|
||
constructor.prototype.constructor = constructor;
|
||
Object.defineProperty(constructor, "super", {
|
||
value: superConstructor.prototype
|
||
});
|
||
props && Object.assign(constructor.prototype, props);
|
||
};
|
||
var toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
|
||
let props;
|
||
let i;
|
||
let prop;
|
||
const merged = {};
|
||
destObj = destObj || {};
|
||
if (sourceObj == null)
|
||
return destObj;
|
||
do {
|
||
props = Object.getOwnPropertyNames(sourceObj);
|
||
i = props.length;
|
||
while (i-- > 0) {
|
||
prop = props[i];
|
||
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
||
destObj[prop] = sourceObj[prop];
|
||
merged[prop] = true;
|
||
}
|
||
}
|
||
sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
|
||
} while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
||
return destObj;
|
||
};
|
||
var endsWith = (str, searchString, position) => {
|
||
str = String(str);
|
||
if (position === void 0 || position > str.length) {
|
||
position = str.length;
|
||
}
|
||
position -= searchString.length;
|
||
const lastIndex = str.indexOf(searchString, position);
|
||
return lastIndex !== -1 && lastIndex === position;
|
||
};
|
||
var toArray = (thing) => {
|
||
if (!thing)
|
||
return null;
|
||
if (isArray(thing))
|
||
return thing;
|
||
let i = thing.length;
|
||
if (!isNumber2(i))
|
||
return null;
|
||
const arr = new Array(i);
|
||
while (i-- > 0) {
|
||
arr[i] = thing[i];
|
||
}
|
||
return arr;
|
||
};
|
||
var isTypedArray = ((TypedArray) => {
|
||
return (thing) => {
|
||
return TypedArray && thing instanceof TypedArray;
|
||
};
|
||
})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
|
||
var forEachEntry = (obj, fn2) => {
|
||
const generator = obj && obj[Symbol.iterator];
|
||
const iterator = generator.call(obj);
|
||
let result;
|
||
while ((result = iterator.next()) && !result.done) {
|
||
const pair = result.value;
|
||
fn2.call(obj, pair[0], pair[1]);
|
||
}
|
||
};
|
||
var matchAll = (regExp, str) => {
|
||
let matches;
|
||
const arr = [];
|
||
while ((matches = regExp.exec(str)) !== null) {
|
||
arr.push(matches);
|
||
}
|
||
return arr;
|
||
};
|
||
var isHTMLForm = kindOfTest("HTMLFormElement");
|
||
var toCamelCase = (str) => {
|
||
return str.toLowerCase().replace(
|
||
/[-_\s]([a-z\d])(\w*)/g,
|
||
function replacer(m, p1, p2) {
|
||
return p1.toUpperCase() + p2;
|
||
}
|
||
);
|
||
};
|
||
var hasOwnProperty2 = (({ hasOwnProperty: hasOwnProperty3 }) => (obj, prop) => hasOwnProperty3.call(obj, prop))(Object.prototype);
|
||
var isRegExp = kindOfTest("RegExp");
|
||
var reduceDescriptors = (obj, reducer) => {
|
||
const descriptors2 = Object.getOwnPropertyDescriptors(obj);
|
||
const reducedDescriptors = {};
|
||
forEach(descriptors2, (descriptor, name) => {
|
||
let ret;
|
||
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
||
reducedDescriptors[name] = ret || descriptor;
|
||
}
|
||
});
|
||
Object.defineProperties(obj, reducedDescriptors);
|
||
};
|
||
var freezeMethods = (obj) => {
|
||
reduceDescriptors(obj, (descriptor, name) => {
|
||
if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
|
||
return false;
|
||
}
|
||
const value = obj[name];
|
||
if (!isFunction(value))
|
||
return;
|
||
descriptor.enumerable = false;
|
||
if ("writable" in descriptor) {
|
||
descriptor.writable = false;
|
||
return;
|
||
}
|
||
if (!descriptor.set) {
|
||
descriptor.set = () => {
|
||
throw Error("Can not rewrite read-only method '" + name + "'");
|
||
};
|
||
}
|
||
});
|
||
};
|
||
var toObjectSet = (arrayOrString, delimiter) => {
|
||
const obj = {};
|
||
const define2 = (arr) => {
|
||
arr.forEach((value) => {
|
||
obj[value] = true;
|
||
});
|
||
};
|
||
isArray(arrayOrString) ? define2(arrayOrString) : define2(String(arrayOrString).split(delimiter));
|
||
return obj;
|
||
};
|
||
var noop2 = () => {
|
||
};
|
||
var toFiniteNumber = (value, defaultValue) => {
|
||
value = +value;
|
||
return Number.isFinite(value) ? value : defaultValue;
|
||
};
|
||
var ALPHA = "abcdefghijklmnopqrstuvwxyz";
|
||
var DIGIT = "0123456789";
|
||
var ALPHABET = {
|
||
DIGIT,
|
||
ALPHA,
|
||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
||
};
|
||
var generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
||
let str = "";
|
||
const { length } = alphabet;
|
||
while (size--) {
|
||
str += alphabet[Math.random() * length | 0];
|
||
}
|
||
return str;
|
||
};
|
||
function isSpecCompliantForm(thing) {
|
||
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator]);
|
||
}
|
||
var toJSONObject = (obj) => {
|
||
const stack = new Array(10);
|
||
const visit = (source, i) => {
|
||
if (isObject2(source)) {
|
||
if (stack.indexOf(source) >= 0) {
|
||
return;
|
||
}
|
||
if (!("toJSON" in source)) {
|
||
stack[i] = source;
|
||
const target = isArray(source) ? [] : {};
|
||
forEach(source, (value, key) => {
|
||
const reducedValue = visit(value, i + 1);
|
||
!isUndefined2(reducedValue) && (target[key] = reducedValue);
|
||
});
|
||
stack[i] = void 0;
|
||
return target;
|
||
}
|
||
}
|
||
return source;
|
||
};
|
||
return visit(obj, 0);
|
||
};
|
||
var isAsyncFn = kindOfTest("AsyncFunction");
|
||
var isThenable = (thing) => thing && (isObject2(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
||
var utils_default = {
|
||
isArray,
|
||
isArrayBuffer,
|
||
isBuffer,
|
||
isFormData,
|
||
isArrayBufferView,
|
||
isString: isString2,
|
||
isNumber: isNumber2,
|
||
isBoolean,
|
||
isObject: isObject2,
|
||
isPlainObject: isPlainObject2,
|
||
isUndefined: isUndefined2,
|
||
isDate: isDate2,
|
||
isFile,
|
||
isBlob,
|
||
isRegExp,
|
||
isFunction,
|
||
isStream,
|
||
isURLSearchParams,
|
||
isTypedArray,
|
||
isFileList,
|
||
forEach,
|
||
merge: merge2,
|
||
extend,
|
||
trim,
|
||
stripBOM,
|
||
inherits,
|
||
toFlatObject,
|
||
kindOf,
|
||
kindOfTest,
|
||
endsWith,
|
||
toArray,
|
||
forEachEntry,
|
||
matchAll,
|
||
isHTMLForm,
|
||
hasOwnProperty: hasOwnProperty2,
|
||
hasOwnProp: hasOwnProperty2,
|
||
// an alias to avoid ESLint no-prototype-builtins detection
|
||
reduceDescriptors,
|
||
freezeMethods,
|
||
toObjectSet,
|
||
toCamelCase,
|
||
noop: noop2,
|
||
toFiniteNumber,
|
||
findKey,
|
||
global: _global,
|
||
isContextDefined,
|
||
ALPHABET,
|
||
generateString,
|
||
isSpecCompliantForm,
|
||
toJSONObject,
|
||
isAsyncFn,
|
||
isThenable
|
||
};
|
||
|
||
// node_modules/axios/lib/core/AxiosError.js
|
||
function AxiosError(message, code, config, request2, response) {
|
||
Error.call(this);
|
||
if (Error.captureStackTrace) {
|
||
Error.captureStackTrace(this, this.constructor);
|
||
} else {
|
||
this.stack = new Error().stack;
|
||
}
|
||
this.message = message;
|
||
this.name = "AxiosError";
|
||
code && (this.code = code);
|
||
config && (this.config = config);
|
||
request2 && (this.request = request2);
|
||
response && (this.response = response);
|
||
}
|
||
utils_default.inherits(AxiosError, Error, {
|
||
toJSON: function toJSON() {
|
||
return {
|
||
// Standard
|
||
message: this.message,
|
||
name: this.name,
|
||
// Microsoft
|
||
description: this.description,
|
||
number: this.number,
|
||
// Mozilla
|
||
fileName: this.fileName,
|
||
lineNumber: this.lineNumber,
|
||
columnNumber: this.columnNumber,
|
||
stack: this.stack,
|
||
// Axios
|
||
config: utils_default.toJSONObject(this.config),
|
||
code: this.code,
|
||
status: this.response && this.response.status ? this.response.status : null
|
||
};
|
||
}
|
||
});
|
||
var prototype = AxiosError.prototype;
|
||
var descriptors = {};
|
||
[
|
||
"ERR_BAD_OPTION_VALUE",
|
||
"ERR_BAD_OPTION",
|
||
"ECONNABORTED",
|
||
"ETIMEDOUT",
|
||
"ERR_NETWORK",
|
||
"ERR_FR_TOO_MANY_REDIRECTS",
|
||
"ERR_DEPRECATED",
|
||
"ERR_BAD_RESPONSE",
|
||
"ERR_BAD_REQUEST",
|
||
"ERR_CANCELED",
|
||
"ERR_NOT_SUPPORT",
|
||
"ERR_INVALID_URL"
|
||
// eslint-disable-next-line func-names
|
||
].forEach((code) => {
|
||
descriptors[code] = { value: code };
|
||
});
|
||
Object.defineProperties(AxiosError, descriptors);
|
||
Object.defineProperty(prototype, "isAxiosError", { value: true });
|
||
AxiosError.from = (error, code, config, request2, response, customProps) => {
|
||
const axiosError = Object.create(prototype);
|
||
utils_default.toFlatObject(error, axiosError, function filter2(obj) {
|
||
return obj !== Error.prototype;
|
||
}, (prop) => {
|
||
return prop !== "isAxiosError";
|
||
});
|
||
AxiosError.call(axiosError, error.message, code, config, request2, response);
|
||
axiosError.cause = error;
|
||
axiosError.name = error.name;
|
||
customProps && Object.assign(axiosError, customProps);
|
||
return axiosError;
|
||
};
|
||
var AxiosError_default = AxiosError;
|
||
|
||
// node_modules/axios/lib/helpers/null.js
|
||
var null_default = null;
|
||
|
||
// node_modules/axios/lib/helpers/toFormData.js
|
||
function isVisitable(thing) {
|
||
return utils_default.isPlainObject(thing) || utils_default.isArray(thing);
|
||
}
|
||
function removeBrackets(key) {
|
||
return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
|
||
}
|
||
function renderKey(path, key, dots) {
|
||
if (!path)
|
||
return key;
|
||
return path.concat(key).map(function each(token, i) {
|
||
token = removeBrackets(token);
|
||
return !dots && i ? "[" + token + "]" : token;
|
||
}).join(dots ? "." : "");
|
||
}
|
||
function isFlatArray(arr) {
|
||
return utils_default.isArray(arr) && !arr.some(isVisitable);
|
||
}
|
||
var predicates = utils_default.toFlatObject(utils_default, {}, null, function filter(prop) {
|
||
return /^is[A-Z]/.test(prop);
|
||
});
|
||
function toFormData(obj, formData, options) {
|
||
if (!utils_default.isObject(obj)) {
|
||
throw new TypeError("target must be an object");
|
||
}
|
||
formData = formData || new (null_default || FormData)();
|
||
options = utils_default.toFlatObject(options, {
|
||
metaTokens: true,
|
||
dots: false,
|
||
indexes: false
|
||
}, false, function defined(option, source) {
|
||
return !utils_default.isUndefined(source[option]);
|
||
});
|
||
const metaTokens = options.metaTokens;
|
||
const visitor = options.visitor || defaultVisitor;
|
||
const dots = options.dots;
|
||
const indexes = options.indexes;
|
||
const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
|
||
const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
|
||
if (!utils_default.isFunction(visitor)) {
|
||
throw new TypeError("visitor must be a function");
|
||
}
|
||
function convertValue(value) {
|
||
if (value === null)
|
||
return "";
|
||
if (utils_default.isDate(value)) {
|
||
return value.toISOString();
|
||
}
|
||
if (!useBlob && utils_default.isBlob(value)) {
|
||
throw new AxiosError_default("Blob is not supported. Use a Buffer instead.");
|
||
}
|
||
if (utils_default.isArrayBuffer(value) || utils_default.isTypedArray(value)) {
|
||
return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
|
||
}
|
||
return value;
|
||
}
|
||
function defaultVisitor(value, key, path) {
|
||
let arr = value;
|
||
if (value && !path && typeof value === "object") {
|
||
if (utils_default.endsWith(key, "{}")) {
|
||
key = metaTokens ? key : key.slice(0, -2);
|
||
value = JSON.stringify(value);
|
||
} else if (utils_default.isArray(value) && isFlatArray(value) || (utils_default.isFileList(value) || utils_default.endsWith(key, "[]")) && (arr = utils_default.toArray(value))) {
|
||
key = removeBrackets(key);
|
||
arr.forEach(function each(el, index) {
|
||
!(utils_default.isUndefined(el) || el === null) && formData.append(
|
||
// eslint-disable-next-line no-nested-ternary
|
||
indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
|
||
convertValue(el)
|
||
);
|
||
});
|
||
return false;
|
||
}
|
||
}
|
||
if (isVisitable(value)) {
|
||
return true;
|
||
}
|
||
formData.append(renderKey(path, key, dots), convertValue(value));
|
||
return false;
|
||
}
|
||
const stack = [];
|
||
const exposedHelpers = Object.assign(predicates, {
|
||
defaultVisitor,
|
||
convertValue,
|
||
isVisitable
|
||
});
|
||
function build(value, path) {
|
||
if (utils_default.isUndefined(value))
|
||
return;
|
||
if (stack.indexOf(value) !== -1) {
|
||
throw Error("Circular reference detected in " + path.join("."));
|
||
}
|
||
stack.push(value);
|
||
utils_default.forEach(value, function each(el, key) {
|
||
const result = !(utils_default.isUndefined(el) || el === null) && visitor.call(
|
||
formData,
|
||
el,
|
||
utils_default.isString(key) ? key.trim() : key,
|
||
path,
|
||
exposedHelpers
|
||
);
|
||
if (result === true) {
|
||
build(el, path ? path.concat(key) : [key]);
|
||
}
|
||
});
|
||
stack.pop();
|
||
}
|
||
if (!utils_default.isObject(obj)) {
|
||
throw new TypeError("data must be an object");
|
||
}
|
||
build(obj);
|
||
return formData;
|
||
}
|
||
var toFormData_default = toFormData;
|
||
|
||
// node_modules/axios/lib/helpers/AxiosURLSearchParams.js
|
||
function encode2(str) {
|
||
const charMap = {
|
||
"!": "%21",
|
||
"'": "%27",
|
||
"(": "%28",
|
||
")": "%29",
|
||
"~": "%7E",
|
||
"%20": "+",
|
||
"%00": "\0"
|
||
};
|
||
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match2) {
|
||
return charMap[match2];
|
||
});
|
||
}
|
||
function AxiosURLSearchParams(params, options) {
|
||
this._pairs = [];
|
||
params && toFormData_default(params, this, options);
|
||
}
|
||
var prototype2 = AxiosURLSearchParams.prototype;
|
||
prototype2.append = function append2(name, value) {
|
||
this._pairs.push([name, value]);
|
||
};
|
||
prototype2.toString = function toString2(encoder) {
|
||
const _encode2 = encoder ? function(value) {
|
||
return encoder.call(this, value, encode2);
|
||
} : encode2;
|
||
return this._pairs.map(function each(pair) {
|
||
return _encode2(pair[0]) + "=" + _encode2(pair[1]);
|
||
}, "").join("&");
|
||
};
|
||
var AxiosURLSearchParams_default = AxiosURLSearchParams;
|
||
|
||
// node_modules/axios/lib/helpers/buildURL.js
|
||
function encode3(val) {
|
||
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
||
}
|
||
function buildURL(url, params, options) {
|
||
if (!params) {
|
||
return url;
|
||
}
|
||
const _encode2 = options && options.encode || encode3;
|
||
const serializeFn = options && options.serialize;
|
||
let serializedParams;
|
||
if (serializeFn) {
|
||
serializedParams = serializeFn(params, options);
|
||
} else {
|
||
serializedParams = utils_default.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams_default(params, options).toString(_encode2);
|
||
}
|
||
if (serializedParams) {
|
||
const hashmarkIndex = url.indexOf("#");
|
||
if (hashmarkIndex !== -1) {
|
||
url = url.slice(0, hashmarkIndex);
|
||
}
|
||
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
||
}
|
||
return url;
|
||
}
|
||
|
||
// node_modules/axios/lib/core/InterceptorManager.js
|
||
var InterceptorManager = class {
|
||
constructor() {
|
||
this.handlers = [];
|
||
}
|
||
/**
|
||
* Add a new interceptor to the stack
|
||
*
|
||
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
||
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
||
*
|
||
* @return {Number} An ID used to remove interceptor later
|
||
*/
|
||
use(fulfilled, rejected, options) {
|
||
this.handlers.push({
|
||
fulfilled,
|
||
rejected,
|
||
synchronous: options ? options.synchronous : false,
|
||
runWhen: options ? options.runWhen : null
|
||
});
|
||
return this.handlers.length - 1;
|
||
}
|
||
/**
|
||
* Remove an interceptor from the stack
|
||
*
|
||
* @param {Number} id The ID that was returned by `use`
|
||
*
|
||
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
||
*/
|
||
eject(id) {
|
||
if (this.handlers[id]) {
|
||
this.handlers[id] = null;
|
||
}
|
||
}
|
||
/**
|
||
* Clear all interceptors from the stack
|
||
*
|
||
* @returns {void}
|
||
*/
|
||
clear() {
|
||
if (this.handlers) {
|
||
this.handlers = [];
|
||
}
|
||
}
|
||
/**
|
||
* Iterate over all the registered interceptors
|
||
*
|
||
* This method is particularly useful for skipping over any
|
||
* interceptors that may have become `null` calling `eject`.
|
||
*
|
||
* @param {Function} fn The function to call for each interceptor
|
||
*
|
||
* @returns {void}
|
||
*/
|
||
forEach(fn2) {
|
||
utils_default.forEach(this.handlers, function forEachHandler(h) {
|
||
if (h !== null) {
|
||
fn2(h);
|
||
}
|
||
});
|
||
}
|
||
};
|
||
var InterceptorManager_default = InterceptorManager;
|
||
|
||
// node_modules/axios/lib/defaults/transitional.js
|
||
var transitional_default = {
|
||
silentJSONParsing: true,
|
||
forcedJSONParsing: true,
|
||
clarifyTimeoutError: false
|
||
};
|
||
|
||
// node_modules/axios/lib/platform/browser/classes/URLSearchParams.js
|
||
var URLSearchParams_default = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams_default;
|
||
|
||
// node_modules/axios/lib/platform/browser/classes/FormData.js
|
||
var FormData_default = typeof FormData !== "undefined" ? FormData : null;
|
||
|
||
// node_modules/axios/lib/platform/browser/classes/Blob.js
|
||
var Blob_default = typeof Blob !== "undefined" ? Blob : null;
|
||
|
||
// node_modules/axios/lib/platform/browser/index.js
|
||
var isStandardBrowserEnv = (() => {
|
||
let product;
|
||
if (typeof navigator !== "undefined" && ((product = navigator.product) === "ReactNative" || product === "NativeScript" || product === "NS")) {
|
||
return false;
|
||
}
|
||
return typeof window !== "undefined" && typeof document !== "undefined";
|
||
})();
|
||
var isStandardBrowserWebWorkerEnv = (() => {
|
||
return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
|
||
self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
|
||
})();
|
||
var browser_default = {
|
||
isBrowser: true,
|
||
classes: {
|
||
URLSearchParams: URLSearchParams_default,
|
||
FormData: FormData_default,
|
||
Blob: Blob_default
|
||
},
|
||
isStandardBrowserEnv,
|
||
isStandardBrowserWebWorkerEnv,
|
||
protocols: ["http", "https", "file", "blob", "url", "data"]
|
||
};
|
||
|
||
// node_modules/axios/lib/helpers/toURLEncodedForm.js
|
||
function toURLEncodedForm(data, options) {
|
||
return toFormData_default(data, new browser_default.classes.URLSearchParams(), Object.assign({
|
||
visitor: function(value, key, path, helpers) {
|
||
if (browser_default.isNode && utils_default.isBuffer(value)) {
|
||
this.append(key, value.toString("base64"));
|
||
return false;
|
||
}
|
||
return helpers.defaultVisitor.apply(this, arguments);
|
||
}
|
||
}, options));
|
||
}
|
||
|
||
// node_modules/axios/lib/helpers/formDataToJSON.js
|
||
function parsePropPath(name) {
|
||
return utils_default.matchAll(/\w+|\[(\w*)]/g, name).map((match2) => {
|
||
return match2[0] === "[]" ? "" : match2[1] || match2[0];
|
||
});
|
||
}
|
||
function arrayToObject(arr) {
|
||
const obj = {};
|
||
const keys = Object.keys(arr);
|
||
let i;
|
||
const len = keys.length;
|
||
let key;
|
||
for (i = 0; i < len; i++) {
|
||
key = keys[i];
|
||
obj[key] = arr[key];
|
||
}
|
||
return obj;
|
||
}
|
||
function formDataToJSON(formData) {
|
||
function buildPath(path, value, target, index) {
|
||
let name = path[index++];
|
||
const isNumericKey = Number.isFinite(+name);
|
||
const isLast = index >= path.length;
|
||
name = !name && utils_default.isArray(target) ? target.length : name;
|
||
if (isLast) {
|
||
if (utils_default.hasOwnProp(target, name)) {
|
||
target[name] = [target[name], value];
|
||
} else {
|
||
target[name] = value;
|
||
}
|
||
return !isNumericKey;
|
||
}
|
||
if (!target[name] || !utils_default.isObject(target[name])) {
|
||
target[name] = [];
|
||
}
|
||
const result = buildPath(path, value, target[name], index);
|
||
if (result && utils_default.isArray(target[name])) {
|
||
target[name] = arrayToObject(target[name]);
|
||
}
|
||
return !isNumericKey;
|
||
}
|
||
if (utils_default.isFormData(formData) && utils_default.isFunction(formData.entries)) {
|
||
const obj = {};
|
||
utils_default.forEachEntry(formData, (name, value) => {
|
||
buildPath(parsePropPath(name), value, obj, 0);
|
||
});
|
||
return obj;
|
||
}
|
||
return null;
|
||
}
|
||
var formDataToJSON_default = formDataToJSON;
|
||
|
||
// node_modules/axios/lib/defaults/index.js
|
||
function stringifySafely(rawValue, parser, encoder) {
|
||
if (utils_default.isString(rawValue)) {
|
||
try {
|
||
(parser || JSON.parse)(rawValue);
|
||
return utils_default.trim(rawValue);
|
||
} catch (e) {
|
||
if (e.name !== "SyntaxError") {
|
||
throw e;
|
||
}
|
||
}
|
||
}
|
||
return (encoder || JSON.stringify)(rawValue);
|
||
}
|
||
var defaults = {
|
||
transitional: transitional_default,
|
||
adapter: browser_default.isNode ? "http" : "xhr",
|
||
transformRequest: [function transformRequest(data, headers) {
|
||
const contentType = headers.getContentType() || "";
|
||
const hasJSONContentType = contentType.indexOf("application/json") > -1;
|
||
const isObjectPayload = utils_default.isObject(data);
|
||
if (isObjectPayload && utils_default.isHTMLForm(data)) {
|
||
data = new FormData(data);
|
||
}
|
||
const isFormData2 = utils_default.isFormData(data);
|
||
if (isFormData2) {
|
||
if (!hasJSONContentType) {
|
||
return data;
|
||
}
|
||
return hasJSONContentType ? JSON.stringify(formDataToJSON_default(data)) : data;
|
||
}
|
||
if (utils_default.isArrayBuffer(data) || utils_default.isBuffer(data) || utils_default.isStream(data) || utils_default.isFile(data) || utils_default.isBlob(data)) {
|
||
return data;
|
||
}
|
||
if (utils_default.isArrayBufferView(data)) {
|
||
return data.buffer;
|
||
}
|
||
if (utils_default.isURLSearchParams(data)) {
|
||
headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
|
||
return data.toString();
|
||
}
|
||
let isFileList2;
|
||
if (isObjectPayload) {
|
||
if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
|
||
return toURLEncodedForm(data, this.formSerializer).toString();
|
||
}
|
||
if ((isFileList2 = utils_default.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
|
||
const _FormData = this.env && this.env.FormData;
|
||
return toFormData_default(
|
||
isFileList2 ? { "files[]": data } : data,
|
||
_FormData && new _FormData(),
|
||
this.formSerializer
|
||
);
|
||
}
|
||
}
|
||
if (isObjectPayload || hasJSONContentType) {
|
||
headers.setContentType("application/json", false);
|
||
return stringifySafely(data);
|
||
}
|
||
return data;
|
||
}],
|
||
transformResponse: [function transformResponse(data) {
|
||
const transitional2 = this.transitional || defaults.transitional;
|
||
const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
|
||
const JSONRequested = this.responseType === "json";
|
||
if (data && utils_default.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
||
const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
|
||
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||
try {
|
||
return JSON.parse(data);
|
||
} catch (e) {
|
||
if (strictJSONParsing) {
|
||
if (e.name === "SyntaxError") {
|
||
throw AxiosError_default.from(e, AxiosError_default.ERR_BAD_RESPONSE, this, null, this.response);
|
||
}
|
||
throw e;
|
||
}
|
||
}
|
||
}
|
||
return data;
|
||
}],
|
||
/**
|
||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||
* timeout is not created.
|
||
*/
|
||
timeout: 0,
|
||
xsrfCookieName: "XSRF-TOKEN",
|
||
xsrfHeaderName: "X-XSRF-TOKEN",
|
||
maxContentLength: -1,
|
||
maxBodyLength: -1,
|
||
env: {
|
||
FormData: browser_default.classes.FormData,
|
||
Blob: browser_default.classes.Blob
|
||
},
|
||
validateStatus: function validateStatus(status) {
|
||
return status >= 200 && status < 300;
|
||
},
|
||
headers: {
|
||
common: {
|
||
"Accept": "application/json, text/plain, */*",
|
||
"Content-Type": void 0
|
||
}
|
||
}
|
||
};
|
||
utils_default.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
|
||
defaults.headers[method] = {};
|
||
});
|
||
var defaults_default = defaults;
|
||
|
||
// node_modules/axios/lib/helpers/parseHeaders.js
|
||
var ignoreDuplicateOf = utils_default.toObjectSet([
|
||
"age",
|
||
"authorization",
|
||
"content-length",
|
||
"content-type",
|
||
"etag",
|
||
"expires",
|
||
"from",
|
||
"host",
|
||
"if-modified-since",
|
||
"if-unmodified-since",
|
||
"last-modified",
|
||
"location",
|
||
"max-forwards",
|
||
"proxy-authorization",
|
||
"referer",
|
||
"retry-after",
|
||
"user-agent"
|
||
]);
|
||
var parseHeaders_default = (rawHeaders) => {
|
||
const parsed = {};
|
||
let key;
|
||
let val;
|
||
let i;
|
||
rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
|
||
i = line.indexOf(":");
|
||
key = line.substring(0, i).trim().toLowerCase();
|
||
val = line.substring(i + 1).trim();
|
||
if (!key || parsed[key] && ignoreDuplicateOf[key]) {
|
||
return;
|
||
}
|
||
if (key === "set-cookie") {
|
||
if (parsed[key]) {
|
||
parsed[key].push(val);
|
||
} else {
|
||
parsed[key] = [val];
|
||
}
|
||
} else {
|
||
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
||
}
|
||
});
|
||
return parsed;
|
||
};
|
||
|
||
// node_modules/axios/lib/core/AxiosHeaders.js
|
||
var $internals = Symbol("internals");
|
||
function normalizeHeader(header) {
|
||
return header && String(header).trim().toLowerCase();
|
||
}
|
||
function normalizeValue(value) {
|
||
if (value === false || value == null) {
|
||
return value;
|
||
}
|
||
return utils_default.isArray(value) ? value.map(normalizeValue) : String(value);
|
||
}
|
||
function parseTokens(str) {
|
||
const tokens = /* @__PURE__ */ Object.create(null);
|
||
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
||
let match2;
|
||
while (match2 = tokensRE.exec(str)) {
|
||
tokens[match2[1]] = match2[2];
|
||
}
|
||
return tokens;
|
||
}
|
||
var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
||
function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
|
||
if (utils_default.isFunction(filter2)) {
|
||
return filter2.call(this, value, header);
|
||
}
|
||
if (isHeaderNameFilter) {
|
||
value = header;
|
||
}
|
||
if (!utils_default.isString(value))
|
||
return;
|
||
if (utils_default.isString(filter2)) {
|
||
return value.indexOf(filter2) !== -1;
|
||
}
|
||
if (utils_default.isRegExp(filter2)) {
|
||
return filter2.test(value);
|
||
}
|
||
}
|
||
function formatHeader(header) {
|
||
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
||
return char.toUpperCase() + str;
|
||
});
|
||
}
|
||
function buildAccessors(obj, header) {
|
||
const accessorName = utils_default.toCamelCase(" " + header);
|
||
["get", "set", "has"].forEach((methodName) => {
|
||
Object.defineProperty(obj, methodName + accessorName, {
|
||
value: function(arg1, arg2, arg3) {
|
||
return this[methodName].call(this, header, arg1, arg2, arg3);
|
||
},
|
||
configurable: true
|
||
});
|
||
});
|
||
}
|
||
var AxiosHeaders = class {
|
||
constructor(headers) {
|
||
headers && this.set(headers);
|
||
}
|
||
set(header, valueOrRewrite, rewrite) {
|
||
const self2 = this;
|
||
function setHeader(_value, _header, _rewrite) {
|
||
const lHeader = normalizeHeader(_header);
|
||
if (!lHeader) {
|
||
throw new Error("header name must be a non-empty string");
|
||
}
|
||
const key = utils_default.findKey(self2, lHeader);
|
||
if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
|
||
self2[key || _header] = normalizeValue(_value);
|
||
}
|
||
}
|
||
const setHeaders = (headers, _rewrite) => utils_default.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
||
if (utils_default.isPlainObject(header) || header instanceof this.constructor) {
|
||
setHeaders(header, valueOrRewrite);
|
||
} else if (utils_default.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
||
setHeaders(parseHeaders_default(header), valueOrRewrite);
|
||
} else {
|
||
header != null && setHeader(valueOrRewrite, header, rewrite);
|
||
}
|
||
return this;
|
||
}
|
||
get(header, parser) {
|
||
header = normalizeHeader(header);
|
||
if (header) {
|
||
const key = utils_default.findKey(this, header);
|
||
if (key) {
|
||
const value = this[key];
|
||
if (!parser) {
|
||
return value;
|
||
}
|
||
if (parser === true) {
|
||
return parseTokens(value);
|
||
}
|
||
if (utils_default.isFunction(parser)) {
|
||
return parser.call(this, value, key);
|
||
}
|
||
if (utils_default.isRegExp(parser)) {
|
||
return parser.exec(value);
|
||
}
|
||
throw new TypeError("parser must be boolean|regexp|function");
|
||
}
|
||
}
|
||
}
|
||
has(header, matcher) {
|
||
header = normalizeHeader(header);
|
||
if (header) {
|
||
const key = utils_default.findKey(this, header);
|
||
return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
||
}
|
||
return false;
|
||
}
|
||
delete(header, matcher) {
|
||
const self2 = this;
|
||
let deleted = false;
|
||
function deleteHeader(_header) {
|
||
_header = normalizeHeader(_header);
|
||
if (_header) {
|
||
const key = utils_default.findKey(self2, _header);
|
||
if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
|
||
delete self2[key];
|
||
deleted = true;
|
||
}
|
||
}
|
||
}
|
||
if (utils_default.isArray(header)) {
|
||
header.forEach(deleteHeader);
|
||
} else {
|
||
deleteHeader(header);
|
||
}
|
||
return deleted;
|
||
}
|
||
clear(matcher) {
|
||
const keys = Object.keys(this);
|
||
let i = keys.length;
|
||
let deleted = false;
|
||
while (i--) {
|
||
const key = keys[i];
|
||
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
||
delete this[key];
|
||
deleted = true;
|
||
}
|
||
}
|
||
return deleted;
|
||
}
|
||
normalize(format) {
|
||
const self2 = this;
|
||
const headers = {};
|
||
utils_default.forEach(this, (value, header) => {
|
||
const key = utils_default.findKey(headers, header);
|
||
if (key) {
|
||
self2[key] = normalizeValue(value);
|
||
delete self2[header];
|
||
return;
|
||
}
|
||
const normalized = format ? formatHeader(header) : String(header).trim();
|
||
if (normalized !== header) {
|
||
delete self2[header];
|
||
}
|
||
self2[normalized] = normalizeValue(value);
|
||
headers[normalized] = true;
|
||
});
|
||
return this;
|
||
}
|
||
concat(...targets) {
|
||
return this.constructor.concat(this, ...targets);
|
||
}
|
||
toJSON(asStrings) {
|
||
const obj = /* @__PURE__ */ Object.create(null);
|
||
utils_default.forEach(this, (value, header) => {
|
||
value != null && value !== false && (obj[header] = asStrings && utils_default.isArray(value) ? value.join(", ") : value);
|
||
});
|
||
return obj;
|
||
}
|
||
[Symbol.iterator]() {
|
||
return Object.entries(this.toJSON())[Symbol.iterator]();
|
||
}
|
||
toString() {
|
||
return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
|
||
}
|
||
get [Symbol.toStringTag]() {
|
||
return "AxiosHeaders";
|
||
}
|
||
static from(thing) {
|
||
return thing instanceof this ? thing : new this(thing);
|
||
}
|
||
static concat(first, ...targets) {
|
||
const computed = new this(first);
|
||
targets.forEach((target) => computed.set(target));
|
||
return computed;
|
||
}
|
||
static accessor(header) {
|
||
const internals = this[$internals] = this[$internals] = {
|
||
accessors: {}
|
||
};
|
||
const accessors = internals.accessors;
|
||
const prototype3 = this.prototype;
|
||
function defineAccessor(_header) {
|
||
const lHeader = normalizeHeader(_header);
|
||
if (!accessors[lHeader]) {
|
||
buildAccessors(prototype3, _header);
|
||
accessors[lHeader] = true;
|
||
}
|
||
}
|
||
utils_default.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
||
return this;
|
||
}
|
||
};
|
||
AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
|
||
utils_default.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
||
let mapped = key[0].toUpperCase() + key.slice(1);
|
||
return {
|
||
get: () => value,
|
||
set(headerValue) {
|
||
this[mapped] = headerValue;
|
||
}
|
||
};
|
||
});
|
||
utils_default.freezeMethods(AxiosHeaders);
|
||
var AxiosHeaders_default = AxiosHeaders;
|
||
|
||
// node_modules/axios/lib/core/transformData.js
|
||
function transformData(fns, response) {
|
||
const config = this || defaults_default;
|
||
const context = response || config;
|
||
const headers = AxiosHeaders_default.from(context.headers);
|
||
let data = context.data;
|
||
utils_default.forEach(fns, function transform(fn2) {
|
||
data = fn2.call(config, data, headers.normalize(), response ? response.status : void 0);
|
||
});
|
||
headers.normalize();
|
||
return data;
|
||
}
|
||
|
||
// node_modules/axios/lib/cancel/isCancel.js
|
||
function isCancel(value) {
|
||
return !!(value && value.__CANCEL__);
|
||
}
|
||
|
||
// node_modules/axios/lib/cancel/CanceledError.js
|
||
function CanceledError(message, config, request2) {
|
||
AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED, config, request2);
|
||
this.name = "CanceledError";
|
||
}
|
||
utils_default.inherits(CanceledError, AxiosError_default, {
|
||
__CANCEL__: true
|
||
});
|
||
var CanceledError_default = CanceledError;
|
||
|
||
// node_modules/axios/lib/core/settle.js
|
||
function settle(resolve, reject, response) {
|
||
const validateStatus2 = response.config.validateStatus;
|
||
if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
|
||
resolve(response);
|
||
} else {
|
||
reject(new AxiosError_default(
|
||
"Request failed with status code " + response.status,
|
||
[AxiosError_default.ERR_BAD_REQUEST, AxiosError_default.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
||
response.config,
|
||
response.request,
|
||
response
|
||
));
|
||
}
|
||
}
|
||
|
||
// node_modules/axios/lib/helpers/cookies.js
|
||
var cookies_default = browser_default.isStandardBrowserEnv ? (
|
||
// Standard browser envs support document.cookie
|
||
function standardBrowserEnv() {
|
||
return {
|
||
write: function write2(name, value, expires, path, domain, secure) {
|
||
const cookie = [];
|
||
cookie.push(name + "=" + encodeURIComponent(value));
|
||
if (utils_default.isNumber(expires)) {
|
||
cookie.push("expires=" + new Date(expires).toGMTString());
|
||
}
|
||
if (utils_default.isString(path)) {
|
||
cookie.push("path=" + path);
|
||
}
|
||
if (utils_default.isString(domain)) {
|
||
cookie.push("domain=" + domain);
|
||
}
|
||
if (secure === true) {
|
||
cookie.push("secure");
|
||
}
|
||
document.cookie = cookie.join("; ");
|
||
},
|
||
read: function read2(name) {
|
||
const match2 = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
|
||
return match2 ? decodeURIComponent(match2[3]) : null;
|
||
},
|
||
remove: function remove(name) {
|
||
this.write(name, "", Date.now() - 864e5);
|
||
}
|
||
};
|
||
}()
|
||
) : (
|
||
// Non standard browser env (web workers, react-native) lack needed support.
|
||
function nonStandardBrowserEnv() {
|
||
return {
|
||
write: function write2() {
|
||
},
|
||
read: function read2() {
|
||
return null;
|
||
},
|
||
remove: function remove() {
|
||
}
|
||
};
|
||
}()
|
||
);
|
||
|
||
// node_modules/axios/lib/helpers/isAbsoluteURL.js
|
||
function isAbsoluteURL(url) {
|
||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||
}
|
||
|
||
// node_modules/axios/lib/helpers/combineURLs.js
|
||
function combineURLs(baseURL, relativeURL) {
|
||
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
||
}
|
||
|
||
// node_modules/axios/lib/core/buildFullPath.js
|
||
function buildFullPath(baseURL, requestedURL) {
|
||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||
return combineURLs(baseURL, requestedURL);
|
||
}
|
||
return requestedURL;
|
||
}
|
||
|
||
// node_modules/axios/lib/helpers/isURLSameOrigin.js
|
||
var isURLSameOrigin_default = browser_default.isStandardBrowserEnv ? (
|
||
// Standard browser envs have full support of the APIs needed to test
|
||
// whether the request URL is of the same origin as current location.
|
||
function standardBrowserEnv2() {
|
||
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
||
const urlParsingNode = document.createElement("a");
|
||
let originURL;
|
||
function resolveURL(url) {
|
||
let href = url;
|
||
if (msie) {
|
||
urlParsingNode.setAttribute("href", href);
|
||
href = urlParsingNode.href;
|
||
}
|
||
urlParsingNode.setAttribute("href", href);
|
||
return {
|
||
href: urlParsingNode.href,
|
||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
|
||
host: urlParsingNode.host,
|
||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
|
||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
|
||
hostname: urlParsingNode.hostname,
|
||
port: urlParsingNode.port,
|
||
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
|
||
};
|
||
}
|
||
originURL = resolveURL(window.location.href);
|
||
return function isURLSameOrigin(requestURL) {
|
||
const parsed = utils_default.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
||
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
||
};
|
||
}()
|
||
) : (
|
||
// Non standard browser envs (web workers, react-native) lack needed support.
|
||
function nonStandardBrowserEnv2() {
|
||
return function isURLSameOrigin() {
|
||
return true;
|
||
};
|
||
}()
|
||
);
|
||
|
||
// node_modules/axios/lib/helpers/parseProtocol.js
|
||
function parseProtocol(url) {
|
||
const match2 = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||
return match2 && match2[1] || "";
|
||
}
|
||
|
||
// node_modules/axios/lib/helpers/speedometer.js
|
||
function speedometer(samplesCount, min2) {
|
||
samplesCount = samplesCount || 10;
|
||
const bytes = new Array(samplesCount);
|
||
const timestamps = new Array(samplesCount);
|
||
let head = 0;
|
||
let tail = 0;
|
||
let firstSampleTS;
|
||
min2 = min2 !== void 0 ? min2 : 1e3;
|
||
return function push(chunkLength) {
|
||
const now3 = Date.now();
|
||
const startedAt = timestamps[tail];
|
||
if (!firstSampleTS) {
|
||
firstSampleTS = now3;
|
||
}
|
||
bytes[head] = chunkLength;
|
||
timestamps[head] = now3;
|
||
let i = tail;
|
||
let bytesCount = 0;
|
||
while (i !== head) {
|
||
bytesCount += bytes[i++];
|
||
i = i % samplesCount;
|
||
}
|
||
head = (head + 1) % samplesCount;
|
||
if (head === tail) {
|
||
tail = (tail + 1) % samplesCount;
|
||
}
|
||
if (now3 - firstSampleTS < min2) {
|
||
return;
|
||
}
|
||
const passed = startedAt && now3 - startedAt;
|
||
return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
|
||
};
|
||
}
|
||
var speedometer_default = speedometer;
|
||
|
||
// node_modules/axios/lib/adapters/xhr.js
|
||
function progressEventReducer(listener, isDownloadStream) {
|
||
let bytesNotified = 0;
|
||
const _speedometer = speedometer_default(50, 250);
|
||
return (e) => {
|
||
const loaded = e.loaded;
|
||
const total = e.lengthComputable ? e.total : void 0;
|
||
const progressBytes = loaded - bytesNotified;
|
||
const rate = _speedometer(progressBytes);
|
||
const inRange = loaded <= total;
|
||
bytesNotified = loaded;
|
||
const data = {
|
||
loaded,
|
||
total,
|
||
progress: total ? loaded / total : void 0,
|
||
bytes: progressBytes,
|
||
rate: rate ? rate : void 0,
|
||
estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
|
||
event: e
|
||
};
|
||
data[isDownloadStream ? "download" : "upload"] = true;
|
||
listener(data);
|
||
};
|
||
}
|
||
var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
||
var xhr_default = isXHRAdapterSupported && function(config) {
|
||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||
let requestData = config.data;
|
||
const requestHeaders = AxiosHeaders_default.from(config.headers).normalize();
|
||
const responseType = config.responseType;
|
||
let onCanceled;
|
||
function done() {
|
||
if (config.cancelToken) {
|
||
config.cancelToken.unsubscribe(onCanceled);
|
||
}
|
||
if (config.signal) {
|
||
config.signal.removeEventListener("abort", onCanceled);
|
||
}
|
||
}
|
||
if (utils_default.isFormData(requestData)) {
|
||
if (browser_default.isStandardBrowserEnv || browser_default.isStandardBrowserWebWorkerEnv) {
|
||
requestHeaders.setContentType(false);
|
||
} else {
|
||
requestHeaders.setContentType("multipart/form-data;", false);
|
||
}
|
||
}
|
||
let request2 = new XMLHttpRequest();
|
||
if (config.auth) {
|
||
const username = config.auth.username || "";
|
||
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
|
||
requestHeaders.set("Authorization", "Basic " + btoa(username + ":" + password));
|
||
}
|
||
const fullPath = buildFullPath(config.baseURL, config.url);
|
||
request2.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
||
request2.timeout = config.timeout;
|
||
function onloadend() {
|
||
if (!request2) {
|
||
return;
|
||
}
|
||
const responseHeaders = AxiosHeaders_default.from(
|
||
"getAllResponseHeaders" in request2 && request2.getAllResponseHeaders()
|
||
);
|
||
const responseData = !responseType || responseType === "text" || responseType === "json" ? request2.responseText : request2.response;
|
||
const response = {
|
||
data: responseData,
|
||
status: request2.status,
|
||
statusText: request2.statusText,
|
||
headers: responseHeaders,
|
||
config,
|
||
request: request2
|
||
};
|
||
settle(function _resolve(value) {
|
||
resolve(value);
|
||
done();
|
||
}, function _reject(err) {
|
||
reject(err);
|
||
done();
|
||
}, response);
|
||
request2 = null;
|
||
}
|
||
if ("onloadend" in request2) {
|
||
request2.onloadend = onloadend;
|
||
} else {
|
||
request2.onreadystatechange = function handleLoad() {
|
||
if (!request2 || request2.readyState !== 4) {
|
||
return;
|
||
}
|
||
if (request2.status === 0 && !(request2.responseURL && request2.responseURL.indexOf("file:") === 0)) {
|
||
return;
|
||
}
|
||
setTimeout(onloadend);
|
||
};
|
||
}
|
||
request2.onabort = function handleAbort() {
|
||
if (!request2) {
|
||
return;
|
||
}
|
||
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request2));
|
||
request2 = null;
|
||
};
|
||
request2.onerror = function handleError() {
|
||
reject(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request2));
|
||
request2 = null;
|
||
};
|
||
request2.ontimeout = function handleTimeout() {
|
||
let timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
|
||
const transitional2 = config.transitional || transitional_default;
|
||
if (config.timeoutErrorMessage) {
|
||
timeoutErrorMessage = config.timeoutErrorMessage;
|
||
}
|
||
reject(new AxiosError_default(
|
||
timeoutErrorMessage,
|
||
transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
||
config,
|
||
request2
|
||
));
|
||
request2 = null;
|
||
};
|
||
if (browser_default.isStandardBrowserEnv) {
|
||
const xsrfValue = (config.withCredentials || isURLSameOrigin_default(fullPath)) && config.xsrfCookieName && cookies_default.read(config.xsrfCookieName);
|
||
if (xsrfValue) {
|
||
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
||
}
|
||
}
|
||
requestData === void 0 && requestHeaders.setContentType(null);
|
||
if ("setRequestHeader" in request2) {
|
||
utils_default.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
||
request2.setRequestHeader(key, val);
|
||
});
|
||
}
|
||
if (!utils_default.isUndefined(config.withCredentials)) {
|
||
request2.withCredentials = !!config.withCredentials;
|
||
}
|
||
if (responseType && responseType !== "json") {
|
||
request2.responseType = config.responseType;
|
||
}
|
||
if (typeof config.onDownloadProgress === "function") {
|
||
request2.addEventListener("progress", progressEventReducer(config.onDownloadProgress, true));
|
||
}
|
||
if (typeof config.onUploadProgress === "function" && request2.upload) {
|
||
request2.upload.addEventListener("progress", progressEventReducer(config.onUploadProgress));
|
||
}
|
||
if (config.cancelToken || config.signal) {
|
||
onCanceled = (cancel) => {
|
||
if (!request2) {
|
||
return;
|
||
}
|
||
reject(!cancel || cancel.type ? new CanceledError_default(null, config, request2) : cancel);
|
||
request2.abort();
|
||
request2 = null;
|
||
};
|
||
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
||
if (config.signal) {
|
||
config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled);
|
||
}
|
||
}
|
||
const protocol = parseProtocol(fullPath);
|
||
if (protocol && browser_default.protocols.indexOf(protocol) === -1) {
|
||
reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST, config));
|
||
return;
|
||
}
|
||
request2.send(requestData || null);
|
||
});
|
||
};
|
||
|
||
// node_modules/axios/lib/adapters/adapters.js
|
||
var knownAdapters = {
|
||
http: null_default,
|
||
xhr: xhr_default
|
||
};
|
||
utils_default.forEach(knownAdapters, (fn2, value) => {
|
||
if (fn2) {
|
||
try {
|
||
Object.defineProperty(fn2, "name", { value });
|
||
} catch (e) {
|
||
}
|
||
Object.defineProperty(fn2, "adapterName", { value });
|
||
}
|
||
});
|
||
var adapters_default = {
|
||
getAdapter: (adapters) => {
|
||
adapters = utils_default.isArray(adapters) ? adapters : [adapters];
|
||
const { length } = adapters;
|
||
let nameOrAdapter;
|
||
let adapter;
|
||
for (let i = 0; i < length; i++) {
|
||
nameOrAdapter = adapters[i];
|
||
if (adapter = utils_default.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter) {
|
||
break;
|
||
}
|
||
}
|
||
if (!adapter) {
|
||
if (adapter === false) {
|
||
throw new AxiosError_default(
|
||
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
||
"ERR_NOT_SUPPORT"
|
||
);
|
||
}
|
||
throw new Error(
|
||
utils_default.hasOwnProp(knownAdapters, nameOrAdapter) ? `Adapter '${nameOrAdapter}' is not available in the build` : `Unknown adapter '${nameOrAdapter}'`
|
||
);
|
||
}
|
||
if (!utils_default.isFunction(adapter)) {
|
||
throw new TypeError("adapter is not a function");
|
||
}
|
||
return adapter;
|
||
},
|
||
adapters: knownAdapters
|
||
};
|
||
|
||
// node_modules/axios/lib/core/dispatchRequest.js
|
||
function throwIfCancellationRequested(config) {
|
||
if (config.cancelToken) {
|
||
config.cancelToken.throwIfRequested();
|
||
}
|
||
if (config.signal && config.signal.aborted) {
|
||
throw new CanceledError_default(null, config);
|
||
}
|
||
}
|
||
function dispatchRequest(config) {
|
||
throwIfCancellationRequested(config);
|
||
config.headers = AxiosHeaders_default.from(config.headers);
|
||
config.data = transformData.call(
|
||
config,
|
||
config.transformRequest
|
||
);
|
||
if (["post", "put", "patch"].indexOf(config.method) !== -1) {
|
||
config.headers.setContentType("application/x-www-form-urlencoded", false);
|
||
}
|
||
const adapter = adapters_default.getAdapter(config.adapter || defaults_default.adapter);
|
||
return adapter(config).then(function onAdapterResolution(response) {
|
||
throwIfCancellationRequested(config);
|
||
response.data = transformData.call(
|
||
config,
|
||
config.transformResponse,
|
||
response
|
||
);
|
||
response.headers = AxiosHeaders_default.from(response.headers);
|
||
return response;
|
||
}, function onAdapterRejection(reason) {
|
||
if (!isCancel(reason)) {
|
||
throwIfCancellationRequested(config);
|
||
if (reason && reason.response) {
|
||
reason.response.data = transformData.call(
|
||
config,
|
||
config.transformResponse,
|
||
reason.response
|
||
);
|
||
reason.response.headers = AxiosHeaders_default.from(reason.response.headers);
|
||
}
|
||
}
|
||
return Promise.reject(reason);
|
||
});
|
||
}
|
||
|
||
// node_modules/axios/lib/core/mergeConfig.js
|
||
var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? thing.toJSON() : thing;
|
||
function mergeConfig(config1, config2) {
|
||
config2 = config2 || {};
|
||
const config = {};
|
||
function getMergedValue(target, source, caseless) {
|
||
if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
|
||
return utils_default.merge.call({ caseless }, target, source);
|
||
} else if (utils_default.isPlainObject(source)) {
|
||
return utils_default.merge({}, source);
|
||
} else if (utils_default.isArray(source)) {
|
||
return source.slice();
|
||
}
|
||
return source;
|
||
}
|
||
function mergeDeepProperties(a, b, caseless) {
|
||
if (!utils_default.isUndefined(b)) {
|
||
return getMergedValue(a, b, caseless);
|
||
} else if (!utils_default.isUndefined(a)) {
|
||
return getMergedValue(void 0, a, caseless);
|
||
}
|
||
}
|
||
function valueFromConfig2(a, b) {
|
||
if (!utils_default.isUndefined(b)) {
|
||
return getMergedValue(void 0, b);
|
||
}
|
||
}
|
||
function defaultToConfig2(a, b) {
|
||
if (!utils_default.isUndefined(b)) {
|
||
return getMergedValue(void 0, b);
|
||
} else if (!utils_default.isUndefined(a)) {
|
||
return getMergedValue(void 0, a);
|
||
}
|
||
}
|
||
function mergeDirectKeys(a, b, prop) {
|
||
if (prop in config2) {
|
||
return getMergedValue(a, b);
|
||
} else if (prop in config1) {
|
||
return getMergedValue(void 0, a);
|
||
}
|
||
}
|
||
const mergeMap = {
|
||
url: valueFromConfig2,
|
||
method: valueFromConfig2,
|
||
data: valueFromConfig2,
|
||
baseURL: defaultToConfig2,
|
||
transformRequest: defaultToConfig2,
|
||
transformResponse: defaultToConfig2,
|
||
paramsSerializer: defaultToConfig2,
|
||
timeout: defaultToConfig2,
|
||
timeoutMessage: defaultToConfig2,
|
||
withCredentials: defaultToConfig2,
|
||
adapter: defaultToConfig2,
|
||
responseType: defaultToConfig2,
|
||
xsrfCookieName: defaultToConfig2,
|
||
xsrfHeaderName: defaultToConfig2,
|
||
onUploadProgress: defaultToConfig2,
|
||
onDownloadProgress: defaultToConfig2,
|
||
decompress: defaultToConfig2,
|
||
maxContentLength: defaultToConfig2,
|
||
maxBodyLength: defaultToConfig2,
|
||
beforeRedirect: defaultToConfig2,
|
||
transport: defaultToConfig2,
|
||
httpAgent: defaultToConfig2,
|
||
httpsAgent: defaultToConfig2,
|
||
cancelToken: defaultToConfig2,
|
||
socketPath: defaultToConfig2,
|
||
responseEncoding: defaultToConfig2,
|
||
validateStatus: mergeDirectKeys,
|
||
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
||
};
|
||
utils_default.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
||
const merge3 = mergeMap[prop] || mergeDeepProperties;
|
||
const configValue = merge3(config1[prop], config2[prop], prop);
|
||
utils_default.isUndefined(configValue) && merge3 !== mergeDirectKeys || (config[prop] = configValue);
|
||
});
|
||
return config;
|
||
}
|
||
|
||
// node_modules/axios/lib/env/data.js
|
||
var VERSION7 = "1.5.0";
|
||
|
||
// node_modules/axios/lib/helpers/validator.js
|
||
var validators = {};
|
||
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
||
validators[type] = function validator(thing) {
|
||
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
||
};
|
||
});
|
||
var deprecatedWarnings = {};
|
||
validators.transitional = function transitional(validator, version2, message) {
|
||
function formatMessage(opt, desc) {
|
||
return "[Axios v" + VERSION7 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
||
}
|
||
return (value, opt, opts) => {
|
||
if (validator === false) {
|
||
throw new AxiosError_default(
|
||
formatMessage(opt, " has been removed" + (version2 ? " in " + version2 : "")),
|
||
AxiosError_default.ERR_DEPRECATED
|
||
);
|
||
}
|
||
if (version2 && !deprecatedWarnings[opt]) {
|
||
deprecatedWarnings[opt] = true;
|
||
console.warn(
|
||
formatMessage(
|
||
opt,
|
||
" has been deprecated since v" + version2 + " and will be removed in the near future"
|
||
)
|
||
);
|
||
}
|
||
return validator ? validator(value, opt, opts) : true;
|
||
};
|
||
};
|
||
function assertOptions(options, schema, allowUnknown) {
|
||
if (typeof options !== "object") {
|
||
throw new AxiosError_default("options must be an object", AxiosError_default.ERR_BAD_OPTION_VALUE);
|
||
}
|
||
const keys = Object.keys(options);
|
||
let i = keys.length;
|
||
while (i-- > 0) {
|
||
const opt = keys[i];
|
||
const validator = schema[opt];
|
||
if (validator) {
|
||
const value = options[opt];
|
||
const result = value === void 0 || validator(value, opt, options);
|
||
if (result !== true) {
|
||
throw new AxiosError_default("option " + opt + " must be " + result, AxiosError_default.ERR_BAD_OPTION_VALUE);
|
||
}
|
||
continue;
|
||
}
|
||
if (allowUnknown !== true) {
|
||
throw new AxiosError_default("Unknown option " + opt, AxiosError_default.ERR_BAD_OPTION);
|
||
}
|
||
}
|
||
}
|
||
var validator_default = {
|
||
assertOptions,
|
||
validators
|
||
};
|
||
|
||
// node_modules/axios/lib/core/Axios.js
|
||
var validators2 = validator_default.validators;
|
||
var Axios = class {
|
||
constructor(instanceConfig) {
|
||
this.defaults = instanceConfig;
|
||
this.interceptors = {
|
||
request: new InterceptorManager_default(),
|
||
response: new InterceptorManager_default()
|
||
};
|
||
}
|
||
/**
|
||
* Dispatch a request
|
||
*
|
||
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
||
* @param {?Object} config
|
||
*
|
||
* @returns {Promise} The Promise to be fulfilled
|
||
*/
|
||
request(configOrUrl, config) {
|
||
if (typeof configOrUrl === "string") {
|
||
config = config || {};
|
||
config.url = configOrUrl;
|
||
} else {
|
||
config = configOrUrl || {};
|
||
}
|
||
config = mergeConfig(this.defaults, config);
|
||
const { transitional: transitional2, paramsSerializer, headers } = config;
|
||
if (transitional2 !== void 0) {
|
||
validator_default.assertOptions(transitional2, {
|
||
silentJSONParsing: validators2.transitional(validators2.boolean),
|
||
forcedJSONParsing: validators2.transitional(validators2.boolean),
|
||
clarifyTimeoutError: validators2.transitional(validators2.boolean)
|
||
}, false);
|
||
}
|
||
if (paramsSerializer != null) {
|
||
if (utils_default.isFunction(paramsSerializer)) {
|
||
config.paramsSerializer = {
|
||
serialize: paramsSerializer
|
||
};
|
||
} else {
|
||
validator_default.assertOptions(paramsSerializer, {
|
||
encode: validators2.function,
|
||
serialize: validators2.function
|
||
}, true);
|
||
}
|
||
}
|
||
config.method = (config.method || this.defaults.method || "get").toLowerCase();
|
||
let contextHeaders = headers && utils_default.merge(
|
||
headers.common,
|
||
headers[config.method]
|
||
);
|
||
headers && utils_default.forEach(
|
||
["delete", "get", "head", "post", "put", "patch", "common"],
|
||
(method) => {
|
||
delete headers[method];
|
||
}
|
||
);
|
||
config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
|
||
const requestInterceptorChain = [];
|
||
let synchronousRequestInterceptors = true;
|
||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
||
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
||
return;
|
||
}
|
||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
||
});
|
||
const responseInterceptorChain = [];
|
||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
||
});
|
||
let promise;
|
||
let i = 0;
|
||
let len;
|
||
if (!synchronousRequestInterceptors) {
|
||
const chain = [dispatchRequest.bind(this), void 0];
|
||
chain.unshift.apply(chain, requestInterceptorChain);
|
||
chain.push.apply(chain, responseInterceptorChain);
|
||
len = chain.length;
|
||
promise = Promise.resolve(config);
|
||
while (i < len) {
|
||
promise = promise.then(chain[i++], chain[i++]);
|
||
}
|
||
return promise;
|
||
}
|
||
len = requestInterceptorChain.length;
|
||
let newConfig = config;
|
||
i = 0;
|
||
while (i < len) {
|
||
const onFulfilled = requestInterceptorChain[i++];
|
||
const onRejected = requestInterceptorChain[i++];
|
||
try {
|
||
newConfig = onFulfilled(newConfig);
|
||
} catch (error) {
|
||
onRejected.call(this, error);
|
||
break;
|
||
}
|
||
}
|
||
try {
|
||
promise = dispatchRequest.call(this, newConfig);
|
||
} catch (error) {
|
||
return Promise.reject(error);
|
||
}
|
||
i = 0;
|
||
len = responseInterceptorChain.length;
|
||
while (i < len) {
|
||
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
||
}
|
||
return promise;
|
||
}
|
||
getUri(config) {
|
||
config = mergeConfig(this.defaults, config);
|
||
const fullPath = buildFullPath(config.baseURL, config.url);
|
||
return buildURL(fullPath, config.params, config.paramsSerializer);
|
||
}
|
||
};
|
||
utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
||
Axios.prototype[method] = function(url, config) {
|
||
return this.request(mergeConfig(config || {}, {
|
||
method,
|
||
url,
|
||
data: (config || {}).data
|
||
}));
|
||
};
|
||
});
|
||
utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
||
function generateHTTPMethod(isForm) {
|
||
return function httpMethod(url, data, config) {
|
||
return this.request(mergeConfig(config || {}, {
|
||
method,
|
||
headers: isForm ? {
|
||
"Content-Type": "multipart/form-data"
|
||
} : {},
|
||
url,
|
||
data
|
||
}));
|
||
};
|
||
}
|
||
Axios.prototype[method] = generateHTTPMethod();
|
||
Axios.prototype[method + "Form"] = generateHTTPMethod(true);
|
||
});
|
||
var Axios_default = Axios;
|
||
|
||
// node_modules/axios/lib/cancel/CancelToken.js
|
||
var CancelToken = class _CancelToken {
|
||
constructor(executor) {
|
||
if (typeof executor !== "function") {
|
||
throw new TypeError("executor must be a function.");
|
||
}
|
||
let resolvePromise;
|
||
this.promise = new Promise(function promiseExecutor(resolve) {
|
||
resolvePromise = resolve;
|
||
});
|
||
const token = this;
|
||
this.promise.then((cancel) => {
|
||
if (!token._listeners)
|
||
return;
|
||
let i = token._listeners.length;
|
||
while (i-- > 0) {
|
||
token._listeners[i](cancel);
|
||
}
|
||
token._listeners = null;
|
||
});
|
||
this.promise.then = (onfulfilled) => {
|
||
let _resolve;
|
||
const promise = new Promise((resolve) => {
|
||
token.subscribe(resolve);
|
||
_resolve = resolve;
|
||
}).then(onfulfilled);
|
||
promise.cancel = function reject() {
|
||
token.unsubscribe(_resolve);
|
||
};
|
||
return promise;
|
||
};
|
||
executor(function cancel(message, config, request2) {
|
||
if (token.reason) {
|
||
return;
|
||
}
|
||
token.reason = new CanceledError_default(message, config, request2);
|
||
resolvePromise(token.reason);
|
||
});
|
||
}
|
||
/**
|
||
* Throws a `CanceledError` if cancellation has been requested.
|
||
*/
|
||
throwIfRequested() {
|
||
if (this.reason) {
|
||
throw this.reason;
|
||
}
|
||
}
|
||
/**
|
||
* Subscribe to the cancel signal
|
||
*/
|
||
subscribe(listener) {
|
||
if (this.reason) {
|
||
listener(this.reason);
|
||
return;
|
||
}
|
||
if (this._listeners) {
|
||
this._listeners.push(listener);
|
||
} else {
|
||
this._listeners = [listener];
|
||
}
|
||
}
|
||
/**
|
||
* Unsubscribe from the cancel signal
|
||
*/
|
||
unsubscribe(listener) {
|
||
if (!this._listeners) {
|
||
return;
|
||
}
|
||
const index = this._listeners.indexOf(listener);
|
||
if (index !== -1) {
|
||
this._listeners.splice(index, 1);
|
||
}
|
||
}
|
||
/**
|
||
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
||
* cancels the `CancelToken`.
|
||
*/
|
||
static source() {
|
||
let cancel;
|
||
const token = new _CancelToken(function executor(c) {
|
||
cancel = c;
|
||
});
|
||
return {
|
||
token,
|
||
cancel
|
||
};
|
||
}
|
||
};
|
||
var CancelToken_default = CancelToken;
|
||
|
||
// node_modules/axios/lib/helpers/spread.js
|
||
function spread(callback) {
|
||
return function wrap(arr) {
|
||
return callback.apply(null, arr);
|
||
};
|
||
}
|
||
|
||
// node_modules/axios/lib/helpers/isAxiosError.js
|
||
function isAxiosError(payload) {
|
||
return utils_default.isObject(payload) && payload.isAxiosError === true;
|
||
}
|
||
|
||
// node_modules/axios/lib/helpers/HttpStatusCode.js
|
||
var HttpStatusCode = {
|
||
Continue: 100,
|
||
SwitchingProtocols: 101,
|
||
Processing: 102,
|
||
EarlyHints: 103,
|
||
Ok: 200,
|
||
Created: 201,
|
||
Accepted: 202,
|
||
NonAuthoritativeInformation: 203,
|
||
NoContent: 204,
|
||
ResetContent: 205,
|
||
PartialContent: 206,
|
||
MultiStatus: 207,
|
||
AlreadyReported: 208,
|
||
ImUsed: 226,
|
||
MultipleChoices: 300,
|
||
MovedPermanently: 301,
|
||
Found: 302,
|
||
SeeOther: 303,
|
||
NotModified: 304,
|
||
UseProxy: 305,
|
||
Unused: 306,
|
||
TemporaryRedirect: 307,
|
||
PermanentRedirect: 308,
|
||
BadRequest: 400,
|
||
Unauthorized: 401,
|
||
PaymentRequired: 402,
|
||
Forbidden: 403,
|
||
NotFound: 404,
|
||
MethodNotAllowed: 405,
|
||
NotAcceptable: 406,
|
||
ProxyAuthenticationRequired: 407,
|
||
RequestTimeout: 408,
|
||
Conflict: 409,
|
||
Gone: 410,
|
||
LengthRequired: 411,
|
||
PreconditionFailed: 412,
|
||
PayloadTooLarge: 413,
|
||
UriTooLong: 414,
|
||
UnsupportedMediaType: 415,
|
||
RangeNotSatisfiable: 416,
|
||
ExpectationFailed: 417,
|
||
ImATeapot: 418,
|
||
MisdirectedRequest: 421,
|
||
UnprocessableEntity: 422,
|
||
Locked: 423,
|
||
FailedDependency: 424,
|
||
TooEarly: 425,
|
||
UpgradeRequired: 426,
|
||
PreconditionRequired: 428,
|
||
TooManyRequests: 429,
|
||
RequestHeaderFieldsTooLarge: 431,
|
||
UnavailableForLegalReasons: 451,
|
||
InternalServerError: 500,
|
||
NotImplemented: 501,
|
||
BadGateway: 502,
|
||
ServiceUnavailable: 503,
|
||
GatewayTimeout: 504,
|
||
HttpVersionNotSupported: 505,
|
||
VariantAlsoNegotiates: 506,
|
||
InsufficientStorage: 507,
|
||
LoopDetected: 508,
|
||
NotExtended: 510,
|
||
NetworkAuthenticationRequired: 511
|
||
};
|
||
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
||
HttpStatusCode[value] = key;
|
||
});
|
||
var HttpStatusCode_default = HttpStatusCode;
|
||
|
||
// node_modules/axios/lib/axios.js
|
||
function createInstance(defaultConfig) {
|
||
const context = new Axios_default(defaultConfig);
|
||
const instance5 = bind(Axios_default.prototype.request, context);
|
||
utils_default.extend(instance5, Axios_default.prototype, context, { allOwnKeys: true });
|
||
utils_default.extend(instance5, context, null, { allOwnKeys: true });
|
||
instance5.create = function create(instanceConfig) {
|
||
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
||
};
|
||
return instance5;
|
||
}
|
||
var axios = createInstance(defaults_default);
|
||
axios.Axios = Axios_default;
|
||
axios.CanceledError = CanceledError_default;
|
||
axios.CancelToken = CancelToken_default;
|
||
axios.isCancel = isCancel;
|
||
axios.VERSION = VERSION7;
|
||
axios.toFormData = toFormData_default;
|
||
axios.AxiosError = AxiosError_default;
|
||
axios.Cancel = axios.CanceledError;
|
||
axios.all = function all(promises) {
|
||
return Promise.all(promises);
|
||
};
|
||
axios.spread = spread;
|
||
axios.isAxiosError = isAxiosError;
|
||
axios.mergeConfig = mergeConfig;
|
||
axios.AxiosHeaders = AxiosHeaders_default;
|
||
axios.formToJSON = (thing) => formDataToJSON_default(utils_default.isHTMLForm(thing) ? new FormData(thing) : thing);
|
||
axios.getAdapter = adapters_default.getAdapter;
|
||
axios.HttpStatusCode = HttpStatusCode_default;
|
||
axios.default = axios;
|
||
var axios_default = axios;
|
||
|
||
// node_modules/axios/index.js
|
||
var {
|
||
Axios: Axios2,
|
||
AxiosError: AxiosError2,
|
||
CanceledError: CanceledError2,
|
||
isCancel: isCancel2,
|
||
CancelToken: CancelToken2,
|
||
VERSION: VERSION8,
|
||
all: all2,
|
||
Cancel,
|
||
isAxiosError: isAxiosError2,
|
||
spread: spread2,
|
||
toFormData: toFormData2,
|
||
AxiosHeaders: AxiosHeaders2,
|
||
HttpStatusCode: HttpStatusCode2,
|
||
formToJSON,
|
||
getAdapter,
|
||
mergeConfig: mergeConfig2
|
||
} = axios_default;
|
||
|
||
// src/ui/suggest/file-suggest.ts
|
||
var import_obsidian8 = require("obsidian");
|
||
|
||
// node_modules/@popperjs/core/lib/enums.js
|
||
var top = "top";
|
||
var bottom = "bottom";
|
||
var right = "right";
|
||
var left = "left";
|
||
var auto = "auto";
|
||
var basePlacements = [top, bottom, right, left];
|
||
var start = "start";
|
||
var end = "end";
|
||
var clippingParents = "clippingParents";
|
||
var viewport = "viewport";
|
||
var popper = "popper";
|
||
var reference = "reference";
|
||
var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
|
||
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
||
}, []);
|
||
var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
|
||
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
||
}, []);
|
||
var beforeRead = "beforeRead";
|
||
var read = "read";
|
||
var afterRead = "afterRead";
|
||
var beforeMain = "beforeMain";
|
||
var main = "main";
|
||
var afterMain = "afterMain";
|
||
var beforeWrite = "beforeWrite";
|
||
var write = "write";
|
||
var afterWrite = "afterWrite";
|
||
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getNodeName.js
|
||
function getNodeName(element2) {
|
||
return element2 ? (element2.nodeName || "").toLowerCase() : null;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindow.js
|
||
function getWindow(node) {
|
||
if (node == null) {
|
||
return window;
|
||
}
|
||
if (node.toString() !== "[object Window]") {
|
||
var ownerDocument = node.ownerDocument;
|
||
return ownerDocument ? ownerDocument.defaultView || window : window;
|
||
}
|
||
return node;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/instanceOf.js
|
||
function isElement(node) {
|
||
var OwnElement = getWindow(node).Element;
|
||
return node instanceof OwnElement || node instanceof Element;
|
||
}
|
||
function isHTMLElement(node) {
|
||
var OwnElement = getWindow(node).HTMLElement;
|
||
return node instanceof OwnElement || node instanceof HTMLElement;
|
||
}
|
||
function isShadowRoot(node) {
|
||
if (typeof ShadowRoot === "undefined") {
|
||
return false;
|
||
}
|
||
var OwnElement = getWindow(node).ShadowRoot;
|
||
return node instanceof OwnElement || node instanceof ShadowRoot;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/applyStyles.js
|
||
function applyStyles(_ref) {
|
||
var state = _ref.state;
|
||
Object.keys(state.elements).forEach(function(name) {
|
||
var style = state.styles[name] || {};
|
||
var attributes = state.attributes[name] || {};
|
||
var element2 = state.elements[name];
|
||
if (!isHTMLElement(element2) || !getNodeName(element2)) {
|
||
return;
|
||
}
|
||
Object.assign(element2.style, style);
|
||
Object.keys(attributes).forEach(function(name2) {
|
||
var value = attributes[name2];
|
||
if (value === false) {
|
||
element2.removeAttribute(name2);
|
||
} else {
|
||
element2.setAttribute(name2, value === true ? "" : value);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
function effect(_ref2) {
|
||
var state = _ref2.state;
|
||
var initialStyles = {
|
||
popper: {
|
||
position: state.options.strategy,
|
||
left: "0",
|
||
top: "0",
|
||
margin: "0"
|
||
},
|
||
arrow: {
|
||
position: "absolute"
|
||
},
|
||
reference: {}
|
||
};
|
||
Object.assign(state.elements.popper.style, initialStyles.popper);
|
||
state.styles = initialStyles;
|
||
if (state.elements.arrow) {
|
||
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
||
}
|
||
return function() {
|
||
Object.keys(state.elements).forEach(function(name) {
|
||
var element2 = state.elements[name];
|
||
var attributes = state.attributes[name] || {};
|
||
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
|
||
var style = styleProperties.reduce(function(style2, property) {
|
||
style2[property] = "";
|
||
return style2;
|
||
}, {});
|
||
if (!isHTMLElement(element2) || !getNodeName(element2)) {
|
||
return;
|
||
}
|
||
Object.assign(element2.style, style);
|
||
Object.keys(attributes).forEach(function(attribute) {
|
||
element2.removeAttribute(attribute);
|
||
});
|
||
});
|
||
};
|
||
}
|
||
var applyStyles_default = {
|
||
name: "applyStyles",
|
||
enabled: true,
|
||
phase: "write",
|
||
fn: applyStyles,
|
||
effect,
|
||
requires: ["computeStyles"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getBasePlacement.js
|
||
function getBasePlacement(placement) {
|
||
return placement.split("-")[0];
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/math.js
|
||
var max = Math.max;
|
||
var min = Math.min;
|
||
var round = Math.round;
|
||
|
||
// node_modules/@popperjs/core/lib/utils/userAgent.js
|
||
function getUAString() {
|
||
var uaData = navigator.userAgentData;
|
||
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
||
return uaData.brands.map(function(item) {
|
||
return item.brand + "/" + item.version;
|
||
}).join(" ");
|
||
}
|
||
return navigator.userAgent;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js
|
||
function isLayoutViewport() {
|
||
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js
|
||
function getBoundingClientRect(element2, includeScale, isFixedStrategy) {
|
||
if (includeScale === void 0) {
|
||
includeScale = false;
|
||
}
|
||
if (isFixedStrategy === void 0) {
|
||
isFixedStrategy = false;
|
||
}
|
||
var clientRect = element2.getBoundingClientRect();
|
||
var scaleX = 1;
|
||
var scaleY = 1;
|
||
if (includeScale && isHTMLElement(element2)) {
|
||
scaleX = element2.offsetWidth > 0 ? round(clientRect.width) / element2.offsetWidth || 1 : 1;
|
||
scaleY = element2.offsetHeight > 0 ? round(clientRect.height) / element2.offsetHeight || 1 : 1;
|
||
}
|
||
var _ref = isElement(element2) ? getWindow(element2) : window, visualViewport = _ref.visualViewport;
|
||
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
||
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
||
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
||
var width = clientRect.width / scaleX;
|
||
var height = clientRect.height / scaleY;
|
||
return {
|
||
width,
|
||
height,
|
||
top: y,
|
||
right: x + width,
|
||
bottom: y + height,
|
||
left: x,
|
||
x,
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js
|
||
function getLayoutRect(element2) {
|
||
var clientRect = getBoundingClientRect(element2);
|
||
var width = element2.offsetWidth;
|
||
var height = element2.offsetHeight;
|
||
if (Math.abs(clientRect.width - width) <= 1) {
|
||
width = clientRect.width;
|
||
}
|
||
if (Math.abs(clientRect.height - height) <= 1) {
|
||
height = clientRect.height;
|
||
}
|
||
return {
|
||
x: element2.offsetLeft,
|
||
y: element2.offsetTop,
|
||
width,
|
||
height
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/contains.js
|
||
function contains(parent, child) {
|
||
var rootNode = child.getRootNode && child.getRootNode();
|
||
if (parent.contains(child)) {
|
||
return true;
|
||
} else if (rootNode && isShadowRoot(rootNode)) {
|
||
var next = child;
|
||
do {
|
||
if (next && parent.isSameNode(next)) {
|
||
return true;
|
||
}
|
||
next = next.parentNode || next.host;
|
||
} while (next);
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js
|
||
function getComputedStyle2(element2) {
|
||
return getWindow(element2).getComputedStyle(element2);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isTableElement.js
|
||
function isTableElement(element2) {
|
||
return ["table", "td", "th"].indexOf(getNodeName(element2)) >= 0;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js
|
||
function getDocumentElement(element2) {
|
||
return ((isElement(element2) ? element2.ownerDocument : (
|
||
// $FlowFixMe[prop-missing]
|
||
element2.document
|
||
)) || window.document).documentElement;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getParentNode.js
|
||
function getParentNode(element2) {
|
||
if (getNodeName(element2) === "html") {
|
||
return element2;
|
||
}
|
||
return (
|
||
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
||
// $FlowFixMe[incompatible-return]
|
||
// $FlowFixMe[prop-missing]
|
||
element2.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
||
element2.parentNode || // DOM Element detected
|
||
(isShadowRoot(element2) ? element2.host : null) || // ShadowRoot detected
|
||
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
||
getDocumentElement(element2)
|
||
);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js
|
||
function getTrueOffsetParent(element2) {
|
||
if (!isHTMLElement(element2) || // https://github.com/popperjs/popper-core/issues/837
|
||
getComputedStyle2(element2).position === "fixed") {
|
||
return null;
|
||
}
|
||
return element2.offsetParent;
|
||
}
|
||
function getContainingBlock(element2) {
|
||
var isFirefox = /firefox/i.test(getUAString());
|
||
var isIE = /Trident/i.test(getUAString());
|
||
if (isIE && isHTMLElement(element2)) {
|
||
var elementCss = getComputedStyle2(element2);
|
||
if (elementCss.position === "fixed") {
|
||
return null;
|
||
}
|
||
}
|
||
var currentNode = getParentNode(element2);
|
||
if (isShadowRoot(currentNode)) {
|
||
currentNode = currentNode.host;
|
||
}
|
||
while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
|
||
var css = getComputedStyle2(currentNode);
|
||
if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
|
||
return currentNode;
|
||
} else {
|
||
currentNode = currentNode.parentNode;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function getOffsetParent(element2) {
|
||
var window2 = getWindow(element2);
|
||
var offsetParent = getTrueOffsetParent(element2);
|
||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle2(offsetParent).position === "static") {
|
||
offsetParent = getTrueOffsetParent(offsetParent);
|
||
}
|
||
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle2(offsetParent).position === "static")) {
|
||
return window2;
|
||
}
|
||
return offsetParent || getContainingBlock(element2) || window2;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js
|
||
function getMainAxisFromPlacement(placement) {
|
||
return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/within.js
|
||
function within(min2, value, max2) {
|
||
return max(min2, min(value, max2));
|
||
}
|
||
function withinMaxClamp(min2, value, max2) {
|
||
var v = within(min2, value, max2);
|
||
return v > max2 ? max2 : v;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getFreshSideObject.js
|
||
function getFreshSideObject() {
|
||
return {
|
||
top: 0,
|
||
right: 0,
|
||
bottom: 0,
|
||
left: 0
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/mergePaddingObject.js
|
||
function mergePaddingObject(paddingObject) {
|
||
return Object.assign({}, getFreshSideObject(), paddingObject);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/expandToHashMap.js
|
||
function expandToHashMap(value, keys) {
|
||
return keys.reduce(function(hashMap, key) {
|
||
hashMap[key] = value;
|
||
return hashMap;
|
||
}, {});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/arrow.js
|
||
var toPaddingObject = function toPaddingObject2(padding, state) {
|
||
padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
|
||
placement: state.placement
|
||
})) : padding;
|
||
return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
||
};
|
||
function arrow(_ref) {
|
||
var _state$modifiersData$;
|
||
var state = _ref.state, name = _ref.name, options = _ref.options;
|
||
var arrowElement = state.elements.arrow;
|
||
var popperOffsets2 = state.modifiersData.popperOffsets;
|
||
var basePlacement = getBasePlacement(state.placement);
|
||
var axis = getMainAxisFromPlacement(basePlacement);
|
||
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
||
var len = isVertical ? "height" : "width";
|
||
if (!arrowElement || !popperOffsets2) {
|
||
return;
|
||
}
|
||
var paddingObject = toPaddingObject(options.padding, state);
|
||
var arrowRect = getLayoutRect(arrowElement);
|
||
var minProp = axis === "y" ? top : left;
|
||
var maxProp = axis === "y" ? bottom : right;
|
||
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
|
||
var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
|
||
var arrowOffsetParent = getOffsetParent(arrowElement);
|
||
var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
||
var centerToReference = endDiff / 2 - startDiff / 2;
|
||
var min2 = paddingObject[minProp];
|
||
var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
|
||
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
||
var offset3 = within(min2, center, max2);
|
||
var axisProp = axis;
|
||
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset3, _state$modifiersData$.centerOffset = offset3 - center, _state$modifiersData$);
|
||
}
|
||
function effect2(_ref2) {
|
||
var state = _ref2.state, options = _ref2.options;
|
||
var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
|
||
if (arrowElement == null) {
|
||
return;
|
||
}
|
||
if (typeof arrowElement === "string") {
|
||
arrowElement = state.elements.popper.querySelector(arrowElement);
|
||
if (!arrowElement) {
|
||
return;
|
||
}
|
||
}
|
||
if (!contains(state.elements.popper, arrowElement)) {
|
||
return;
|
||
}
|
||
state.elements.arrow = arrowElement;
|
||
}
|
||
var arrow_default = {
|
||
name: "arrow",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: arrow,
|
||
effect: effect2,
|
||
requires: ["popperOffsets"],
|
||
requiresIfExists: ["preventOverflow"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getVariation.js
|
||
function getVariation(placement) {
|
||
return placement.split("-")[1];
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/computeStyles.js
|
||
var unsetSides = {
|
||
top: "auto",
|
||
right: "auto",
|
||
bottom: "auto",
|
||
left: "auto"
|
||
};
|
||
function roundOffsetsByDPR(_ref, win) {
|
||
var x = _ref.x, y = _ref.y;
|
||
var dpr = win.devicePixelRatio || 1;
|
||
return {
|
||
x: round(x * dpr) / dpr || 0,
|
||
y: round(y * dpr) / dpr || 0
|
||
};
|
||
}
|
||
function mapToStyles(_ref2) {
|
||
var _Object$assign2;
|
||
var popper2 = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
|
||
var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
|
||
var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
|
||
x,
|
||
y
|
||
}) : {
|
||
x,
|
||
y
|
||
};
|
||
x = _ref3.x;
|
||
y = _ref3.y;
|
||
var hasX = offsets.hasOwnProperty("x");
|
||
var hasY = offsets.hasOwnProperty("y");
|
||
var sideX = left;
|
||
var sideY = top;
|
||
var win = window;
|
||
if (adaptive) {
|
||
var offsetParent = getOffsetParent(popper2);
|
||
var heightProp = "clientHeight";
|
||
var widthProp = "clientWidth";
|
||
if (offsetParent === getWindow(popper2)) {
|
||
offsetParent = getDocumentElement(popper2);
|
||
if (getComputedStyle2(offsetParent).position !== "static" && position === "absolute") {
|
||
heightProp = "scrollHeight";
|
||
widthProp = "scrollWidth";
|
||
}
|
||
}
|
||
offsetParent = offsetParent;
|
||
if (placement === top || (placement === left || placement === right) && variation === end) {
|
||
sideY = bottom;
|
||
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
|
||
// $FlowFixMe[prop-missing]
|
||
offsetParent[heightProp]
|
||
);
|
||
y -= offsetY - popperRect.height;
|
||
y *= gpuAcceleration ? 1 : -1;
|
||
}
|
||
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
||
sideX = right;
|
||
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
|
||
// $FlowFixMe[prop-missing]
|
||
offsetParent[widthProp]
|
||
);
|
||
x -= offsetX - popperRect.width;
|
||
x *= gpuAcceleration ? 1 : -1;
|
||
}
|
||
}
|
||
var commonStyles = Object.assign({
|
||
position
|
||
}, adaptive && unsetSides);
|
||
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
||
x,
|
||
y
|
||
}, getWindow(popper2)) : {
|
||
x,
|
||
y
|
||
};
|
||
x = _ref4.x;
|
||
y = _ref4.y;
|
||
if (gpuAcceleration) {
|
||
var _Object$assign;
|
||
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
||
}
|
||
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
|
||
}
|
||
function computeStyles(_ref5) {
|
||
var state = _ref5.state, options = _ref5.options;
|
||
var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
||
var commonStyles = {
|
||
placement: getBasePlacement(state.placement),
|
||
variation: getVariation(state.placement),
|
||
popper: state.elements.popper,
|
||
popperRect: state.rects.popper,
|
||
gpuAcceleration,
|
||
isFixed: state.options.strategy === "fixed"
|
||
};
|
||
if (state.modifiersData.popperOffsets != null) {
|
||
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
||
offsets: state.modifiersData.popperOffsets,
|
||
position: state.options.strategy,
|
||
adaptive,
|
||
roundOffsets
|
||
})));
|
||
}
|
||
if (state.modifiersData.arrow != null) {
|
||
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
||
offsets: state.modifiersData.arrow,
|
||
position: "absolute",
|
||
adaptive: false,
|
||
roundOffsets
|
||
})));
|
||
}
|
||
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
||
"data-popper-placement": state.placement
|
||
});
|
||
}
|
||
var computeStyles_default = {
|
||
name: "computeStyles",
|
||
enabled: true,
|
||
phase: "beforeWrite",
|
||
fn: computeStyles,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/eventListeners.js
|
||
var passive = {
|
||
passive: true
|
||
};
|
||
function effect3(_ref) {
|
||
var state = _ref.state, instance5 = _ref.instance, options = _ref.options;
|
||
var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
|
||
var window2 = getWindow(state.elements.popper);
|
||
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
||
if (scroll) {
|
||
scrollParents.forEach(function(scrollParent) {
|
||
scrollParent.addEventListener("scroll", instance5.update, passive);
|
||
});
|
||
}
|
||
if (resize) {
|
||
window2.addEventListener("resize", instance5.update, passive);
|
||
}
|
||
return function() {
|
||
if (scroll) {
|
||
scrollParents.forEach(function(scrollParent) {
|
||
scrollParent.removeEventListener("scroll", instance5.update, passive);
|
||
});
|
||
}
|
||
if (resize) {
|
||
window2.removeEventListener("resize", instance5.update, passive);
|
||
}
|
||
};
|
||
}
|
||
var eventListeners_default = {
|
||
name: "eventListeners",
|
||
enabled: true,
|
||
phase: "write",
|
||
fn: function fn() {
|
||
},
|
||
effect: effect3,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getOppositePlacement.js
|
||
var hash = {
|
||
left: "right",
|
||
right: "left",
|
||
bottom: "top",
|
||
top: "bottom"
|
||
};
|
||
function getOppositePlacement(placement) {
|
||
return placement.replace(/left|right|bottom|top/g, function(matched) {
|
||
return hash[matched];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js
|
||
var hash2 = {
|
||
start: "end",
|
||
end: "start"
|
||
};
|
||
function getOppositeVariationPlacement(placement) {
|
||
return placement.replace(/start|end/g, function(matched) {
|
||
return hash2[matched];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js
|
||
function getWindowScroll(node) {
|
||
var win = getWindow(node);
|
||
var scrollLeft = win.pageXOffset;
|
||
var scrollTop = win.pageYOffset;
|
||
return {
|
||
scrollLeft,
|
||
scrollTop
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js
|
||
function getWindowScrollBarX(element2) {
|
||
return getBoundingClientRect(getDocumentElement(element2)).left + getWindowScroll(element2).scrollLeft;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js
|
||
function getViewportRect(element2, strategy) {
|
||
var win = getWindow(element2);
|
||
var html = getDocumentElement(element2);
|
||
var visualViewport = win.visualViewport;
|
||
var width = html.clientWidth;
|
||
var height = html.clientHeight;
|
||
var x = 0;
|
||
var y = 0;
|
||
if (visualViewport) {
|
||
width = visualViewport.width;
|
||
height = visualViewport.height;
|
||
var layoutViewport = isLayoutViewport();
|
||
if (layoutViewport || !layoutViewport && strategy === "fixed") {
|
||
x = visualViewport.offsetLeft;
|
||
y = visualViewport.offsetTop;
|
||
}
|
||
}
|
||
return {
|
||
width,
|
||
height,
|
||
x: x + getWindowScrollBarX(element2),
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js
|
||
function getDocumentRect(element2) {
|
||
var _element$ownerDocumen;
|
||
var html = getDocumentElement(element2);
|
||
var winScroll = getWindowScroll(element2);
|
||
var body = (_element$ownerDocumen = element2.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
||
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
||
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
||
var x = -winScroll.scrollLeft + getWindowScrollBarX(element2);
|
||
var y = -winScroll.scrollTop;
|
||
if (getComputedStyle2(body || html).direction === "rtl") {
|
||
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
||
}
|
||
return {
|
||
width,
|
||
height,
|
||
x,
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js
|
||
function isScrollParent(element2) {
|
||
var _getComputedStyle = getComputedStyle2(element2), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
|
||
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js
|
||
function getScrollParent(node) {
|
||
if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
|
||
return node.ownerDocument.body;
|
||
}
|
||
if (isHTMLElement(node) && isScrollParent(node)) {
|
||
return node;
|
||
}
|
||
return getScrollParent(getParentNode(node));
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js
|
||
function listScrollParents(element2, list) {
|
||
var _element$ownerDocumen;
|
||
if (list === void 0) {
|
||
list = [];
|
||
}
|
||
var scrollParent = getScrollParent(element2);
|
||
var isBody = scrollParent === ((_element$ownerDocumen = element2.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
||
var win = getWindow(scrollParent);
|
||
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
||
var updatedList = list.concat(target);
|
||
return isBody ? updatedList : (
|
||
// $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
||
updatedList.concat(listScrollParents(getParentNode(target)))
|
||
);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/rectToClientRect.js
|
||
function rectToClientRect(rect) {
|
||
return Object.assign({}, rect, {
|
||
left: rect.x,
|
||
top: rect.y,
|
||
right: rect.x + rect.width,
|
||
bottom: rect.y + rect.height
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js
|
||
function getInnerBoundingClientRect(element2, strategy) {
|
||
var rect = getBoundingClientRect(element2, false, strategy === "fixed");
|
||
rect.top = rect.top + element2.clientTop;
|
||
rect.left = rect.left + element2.clientLeft;
|
||
rect.bottom = rect.top + element2.clientHeight;
|
||
rect.right = rect.left + element2.clientWidth;
|
||
rect.width = element2.clientWidth;
|
||
rect.height = element2.clientHeight;
|
||
rect.x = rect.left;
|
||
rect.y = rect.top;
|
||
return rect;
|
||
}
|
||
function getClientRectFromMixedType(element2, clippingParent, strategy) {
|
||
return clippingParent === viewport ? rectToClientRect(getViewportRect(element2, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element2)));
|
||
}
|
||
function getClippingParents(element2) {
|
||
var clippingParents2 = listScrollParents(getParentNode(element2));
|
||
var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle2(element2).position) >= 0;
|
||
var clipperElement = canEscapeClipping && isHTMLElement(element2) ? getOffsetParent(element2) : element2;
|
||
if (!isElement(clipperElement)) {
|
||
return [];
|
||
}
|
||
return clippingParents2.filter(function(clippingParent) {
|
||
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
|
||
});
|
||
}
|
||
function getClippingRect(element2, boundary, rootBoundary, strategy) {
|
||
var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element2) : [].concat(boundary);
|
||
var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
|
||
var firstClippingParent = clippingParents2[0];
|
||
var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
|
||
var rect = getClientRectFromMixedType(element2, clippingParent, strategy);
|
||
accRect.top = max(rect.top, accRect.top);
|
||
accRect.right = min(rect.right, accRect.right);
|
||
accRect.bottom = min(rect.bottom, accRect.bottom);
|
||
accRect.left = max(rect.left, accRect.left);
|
||
return accRect;
|
||
}, getClientRectFromMixedType(element2, firstClippingParent, strategy));
|
||
clippingRect.width = clippingRect.right - clippingRect.left;
|
||
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
||
clippingRect.x = clippingRect.left;
|
||
clippingRect.y = clippingRect.top;
|
||
return clippingRect;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/computeOffsets.js
|
||
function computeOffsets(_ref) {
|
||
var reference2 = _ref.reference, element2 = _ref.element, placement = _ref.placement;
|
||
var basePlacement = placement ? getBasePlacement(placement) : null;
|
||
var variation = placement ? getVariation(placement) : null;
|
||
var commonX = reference2.x + reference2.width / 2 - element2.width / 2;
|
||
var commonY = reference2.y + reference2.height / 2 - element2.height / 2;
|
||
var offsets;
|
||
switch (basePlacement) {
|
||
case top:
|
||
offsets = {
|
||
x: commonX,
|
||
y: reference2.y - element2.height
|
||
};
|
||
break;
|
||
case bottom:
|
||
offsets = {
|
||
x: commonX,
|
||
y: reference2.y + reference2.height
|
||
};
|
||
break;
|
||
case right:
|
||
offsets = {
|
||
x: reference2.x + reference2.width,
|
||
y: commonY
|
||
};
|
||
break;
|
||
case left:
|
||
offsets = {
|
||
x: reference2.x - element2.width,
|
||
y: commonY
|
||
};
|
||
break;
|
||
default:
|
||
offsets = {
|
||
x: reference2.x,
|
||
y: reference2.y
|
||
};
|
||
}
|
||
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
||
if (mainAxis != null) {
|
||
var len = mainAxis === "y" ? "height" : "width";
|
||
switch (variation) {
|
||
case start:
|
||
offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element2[len] / 2);
|
||
break;
|
||
case end:
|
||
offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element2[len] / 2);
|
||
break;
|
||
default:
|
||
}
|
||
}
|
||
return offsets;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/detectOverflow.js
|
||
function detectOverflow(state, options) {
|
||
if (options === void 0) {
|
||
options = {};
|
||
}
|
||
var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
|
||
var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
||
var altContext = elementContext === popper ? reference : popper;
|
||
var popperRect = state.rects.popper;
|
||
var element2 = state.elements[altBoundary ? altContext : elementContext];
|
||
var clippingClientRect = getClippingRect(isElement(element2) ? element2 : element2.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
||
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
||
var popperOffsets2 = computeOffsets({
|
||
reference: referenceClientRect,
|
||
element: popperRect,
|
||
strategy: "absolute",
|
||
placement
|
||
});
|
||
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
|
||
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
|
||
var overflowOffsets = {
|
||
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
||
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
||
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
||
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
||
};
|
||
var offsetData = state.modifiersData.offset;
|
||
if (elementContext === popper && offsetData) {
|
||
var offset3 = offsetData[placement];
|
||
Object.keys(overflowOffsets).forEach(function(key) {
|
||
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
||
var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
|
||
overflowOffsets[key] += offset3[axis] * multiply;
|
||
});
|
||
}
|
||
return overflowOffsets;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js
|
||
function computeAutoPlacement(state, options) {
|
||
if (options === void 0) {
|
||
options = {};
|
||
}
|
||
var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
||
var variation = getVariation(placement);
|
||
var placements2 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
|
||
return getVariation(placement2) === variation;
|
||
}) : basePlacements;
|
||
var allowedPlacements = placements2.filter(function(placement2) {
|
||
return allowedAutoPlacements.indexOf(placement2) >= 0;
|
||
});
|
||
if (allowedPlacements.length === 0) {
|
||
allowedPlacements = placements2;
|
||
}
|
||
var overflows = allowedPlacements.reduce(function(acc, placement2) {
|
||
acc[placement2] = detectOverflow(state, {
|
||
placement: placement2,
|
||
boundary,
|
||
rootBoundary,
|
||
padding
|
||
})[getBasePlacement(placement2)];
|
||
return acc;
|
||
}, {});
|
||
return Object.keys(overflows).sort(function(a, b) {
|
||
return overflows[a] - overflows[b];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/flip.js
|
||
function getExpandedFallbackPlacements(placement) {
|
||
if (getBasePlacement(placement) === auto) {
|
||
return [];
|
||
}
|
||
var oppositePlacement = getOppositePlacement(placement);
|
||
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
||
}
|
||
function flip(_ref) {
|
||
var state = _ref.state, options = _ref.options, name = _ref.name;
|
||
if (state.modifiersData[name]._skip) {
|
||
return;
|
||
}
|
||
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
|
||
var preferredPlacement = state.options.placement;
|
||
var basePlacement = getBasePlacement(preferredPlacement);
|
||
var isBasePlacement = basePlacement === preferredPlacement;
|
||
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
||
var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
|
||
return acc.concat(getBasePlacement(placement2) === auto ? computeAutoPlacement(state, {
|
||
placement: placement2,
|
||
boundary,
|
||
rootBoundary,
|
||
padding,
|
||
flipVariations,
|
||
allowedAutoPlacements
|
||
}) : placement2);
|
||
}, []);
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var checksMap = /* @__PURE__ */ new Map();
|
||
var makeFallbackChecks = true;
|
||
var firstFittingPlacement = placements2[0];
|
||
for (var i = 0; i < placements2.length; i++) {
|
||
var placement = placements2[i];
|
||
var _basePlacement = getBasePlacement(placement);
|
||
var isStartVariation = getVariation(placement) === start;
|
||
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
||
var len = isVertical ? "width" : "height";
|
||
var overflow = detectOverflow(state, {
|
||
placement,
|
||
boundary,
|
||
rootBoundary,
|
||
altBoundary,
|
||
padding
|
||
});
|
||
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
||
if (referenceRect[len] > popperRect[len]) {
|
||
mainVariationSide = getOppositePlacement(mainVariationSide);
|
||
}
|
||
var altVariationSide = getOppositePlacement(mainVariationSide);
|
||
var checks = [];
|
||
if (checkMainAxis) {
|
||
checks.push(overflow[_basePlacement] <= 0);
|
||
}
|
||
if (checkAltAxis) {
|
||
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
||
}
|
||
if (checks.every(function(check) {
|
||
return check;
|
||
})) {
|
||
firstFittingPlacement = placement;
|
||
makeFallbackChecks = false;
|
||
break;
|
||
}
|
||
checksMap.set(placement, checks);
|
||
}
|
||
if (makeFallbackChecks) {
|
||
var numberOfChecks = flipVariations ? 3 : 1;
|
||
var _loop = function _loop2(_i2) {
|
||
var fittingPlacement = placements2.find(function(placement2) {
|
||
var checks2 = checksMap.get(placement2);
|
||
if (checks2) {
|
||
return checks2.slice(0, _i2).every(function(check) {
|
||
return check;
|
||
});
|
||
}
|
||
});
|
||
if (fittingPlacement) {
|
||
firstFittingPlacement = fittingPlacement;
|
||
return "break";
|
||
}
|
||
};
|
||
for (var _i = numberOfChecks; _i > 0; _i--) {
|
||
var _ret = _loop(_i);
|
||
if (_ret === "break")
|
||
break;
|
||
}
|
||
}
|
||
if (state.placement !== firstFittingPlacement) {
|
||
state.modifiersData[name]._skip = true;
|
||
state.placement = firstFittingPlacement;
|
||
state.reset = true;
|
||
}
|
||
}
|
||
var flip_default = {
|
||
name: "flip",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: flip,
|
||
requiresIfExists: ["offset"],
|
||
data: {
|
||
_skip: false
|
||
}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/hide.js
|
||
function getSideOffsets(overflow, rect, preventedOffsets) {
|
||
if (preventedOffsets === void 0) {
|
||
preventedOffsets = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
}
|
||
return {
|
||
top: overflow.top - rect.height - preventedOffsets.y,
|
||
right: overflow.right - rect.width + preventedOffsets.x,
|
||
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
||
left: overflow.left - rect.width - preventedOffsets.x
|
||
};
|
||
}
|
||
function isAnySideFullyClipped(overflow) {
|
||
return [top, right, bottom, left].some(function(side) {
|
||
return overflow[side] >= 0;
|
||
});
|
||
}
|
||
function hide(_ref) {
|
||
var state = _ref.state, name = _ref.name;
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var preventedOffsets = state.modifiersData.preventOverflow;
|
||
var referenceOverflow = detectOverflow(state, {
|
||
elementContext: "reference"
|
||
});
|
||
var popperAltOverflow = detectOverflow(state, {
|
||
altBoundary: true
|
||
});
|
||
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
||
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
||
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
||
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
||
state.modifiersData[name] = {
|
||
referenceClippingOffsets,
|
||
popperEscapeOffsets,
|
||
isReferenceHidden,
|
||
hasPopperEscaped
|
||
};
|
||
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
||
"data-popper-reference-hidden": isReferenceHidden,
|
||
"data-popper-escaped": hasPopperEscaped
|
||
});
|
||
}
|
||
var hide_default = {
|
||
name: "hide",
|
||
enabled: true,
|
||
phase: "main",
|
||
requiresIfExists: ["preventOverflow"],
|
||
fn: hide
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/offset.js
|
||
function distanceAndSkiddingToXY(placement, rects, offset3) {
|
||
var basePlacement = getBasePlacement(placement);
|
||
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
||
var _ref = typeof offset3 === "function" ? offset3(Object.assign({}, rects, {
|
||
placement
|
||
})) : offset3, skidding = _ref[0], distance = _ref[1];
|
||
skidding = skidding || 0;
|
||
distance = (distance || 0) * invertDistance;
|
||
return [left, right].indexOf(basePlacement) >= 0 ? {
|
||
x: distance,
|
||
y: skidding
|
||
} : {
|
||
x: skidding,
|
||
y: distance
|
||
};
|
||
}
|
||
function offset2(_ref2) {
|
||
var state = _ref2.state, options = _ref2.options, name = _ref2.name;
|
||
var _options$offset = options.offset, offset3 = _options$offset === void 0 ? [0, 0] : _options$offset;
|
||
var data = placements.reduce(function(acc, placement) {
|
||
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset3);
|
||
return acc;
|
||
}, {});
|
||
var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
|
||
if (state.modifiersData.popperOffsets != null) {
|
||
state.modifiersData.popperOffsets.x += x;
|
||
state.modifiersData.popperOffsets.y += y;
|
||
}
|
||
state.modifiersData[name] = data;
|
||
}
|
||
var offset_default = {
|
||
name: "offset",
|
||
enabled: true,
|
||
phase: "main",
|
||
requires: ["popperOffsets"],
|
||
fn: offset2
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/popperOffsets.js
|
||
function popperOffsets(_ref) {
|
||
var state = _ref.state, name = _ref.name;
|
||
state.modifiersData[name] = computeOffsets({
|
||
reference: state.rects.reference,
|
||
element: state.rects.popper,
|
||
strategy: "absolute",
|
||
placement: state.placement
|
||
});
|
||
}
|
||
var popperOffsets_default = {
|
||
name: "popperOffsets",
|
||
enabled: true,
|
||
phase: "read",
|
||
fn: popperOffsets,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getAltAxis.js
|
||
function getAltAxis(axis) {
|
||
return axis === "x" ? "y" : "x";
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/preventOverflow.js
|
||
function preventOverflow(_ref) {
|
||
var state = _ref.state, options = _ref.options, name = _ref.name;
|
||
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
||
var overflow = detectOverflow(state, {
|
||
boundary,
|
||
rootBoundary,
|
||
padding,
|
||
altBoundary
|
||
});
|
||
var basePlacement = getBasePlacement(state.placement);
|
||
var variation = getVariation(state.placement);
|
||
var isBasePlacement = !variation;
|
||
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
||
var altAxis = getAltAxis(mainAxis);
|
||
var popperOffsets2 = state.modifiersData.popperOffsets;
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
|
||
placement: state.placement
|
||
})) : tetherOffset;
|
||
var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
|
||
mainAxis: tetherOffsetValue,
|
||
altAxis: tetherOffsetValue
|
||
} : Object.assign({
|
||
mainAxis: 0,
|
||
altAxis: 0
|
||
}, tetherOffsetValue);
|
||
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
||
var data = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
if (!popperOffsets2) {
|
||
return;
|
||
}
|
||
if (checkMainAxis) {
|
||
var _offsetModifierState$;
|
||
var mainSide = mainAxis === "y" ? top : left;
|
||
var altSide = mainAxis === "y" ? bottom : right;
|
||
var len = mainAxis === "y" ? "height" : "width";
|
||
var offset3 = popperOffsets2[mainAxis];
|
||
var min2 = offset3 + overflow[mainSide];
|
||
var max2 = offset3 - overflow[altSide];
|
||
var additive = tether ? -popperRect[len] / 2 : 0;
|
||
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
||
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
|
||
var arrowElement = state.elements.arrow;
|
||
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
||
width: 0,
|
||
height: 0
|
||
};
|
||
var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
|
||
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
||
var arrowPaddingMax = arrowPaddingObject[altSide];
|
||
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
||
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
||
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
||
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
||
var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
||
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
||
var tetherMin = offset3 + minOffset - offsetModifierValue - clientOffset;
|
||
var tetherMax = offset3 + maxOffset - offsetModifierValue;
|
||
var preventedOffset = within(tether ? min(min2, tetherMin) : min2, offset3, tether ? max(max2, tetherMax) : max2);
|
||
popperOffsets2[mainAxis] = preventedOffset;
|
||
data[mainAxis] = preventedOffset - offset3;
|
||
}
|
||
if (checkAltAxis) {
|
||
var _offsetModifierState$2;
|
||
var _mainSide = mainAxis === "x" ? top : left;
|
||
var _altSide = mainAxis === "x" ? bottom : right;
|
||
var _offset = popperOffsets2[altAxis];
|
||
var _len = altAxis === "y" ? "height" : "width";
|
||
var _min = _offset + overflow[_mainSide];
|
||
var _max = _offset - overflow[_altSide];
|
||
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
||
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
||
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
||
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
||
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
||
popperOffsets2[altAxis] = _preventedOffset;
|
||
data[altAxis] = _preventedOffset - _offset;
|
||
}
|
||
state.modifiersData[name] = data;
|
||
}
|
||
var preventOverflow_default = {
|
||
name: "preventOverflow",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: preventOverflow,
|
||
requiresIfExists: ["offset"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js
|
||
function getHTMLElementScroll(element2) {
|
||
return {
|
||
scrollLeft: element2.scrollLeft,
|
||
scrollTop: element2.scrollTop
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js
|
||
function getNodeScroll(node) {
|
||
if (node === getWindow(node) || !isHTMLElement(node)) {
|
||
return getWindowScroll(node);
|
||
} else {
|
||
return getHTMLElementScroll(node);
|
||
}
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js
|
||
function isElementScaled(element2) {
|
||
var rect = element2.getBoundingClientRect();
|
||
var scaleX = round(rect.width) / element2.offsetWidth || 1;
|
||
var scaleY = round(rect.height) / element2.offsetHeight || 1;
|
||
return scaleX !== 1 || scaleY !== 1;
|
||
}
|
||
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
||
if (isFixed === void 0) {
|
||
isFixed = false;
|
||
}
|
||
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
||
var documentElement = getDocumentElement(offsetParent);
|
||
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
||
var scroll = {
|
||
scrollLeft: 0,
|
||
scrollTop: 0
|
||
};
|
||
var offsets = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||
if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
|
||
isScrollParent(documentElement)) {
|
||
scroll = getNodeScroll(offsetParent);
|
||
}
|
||
if (isHTMLElement(offsetParent)) {
|
||
offsets = getBoundingClientRect(offsetParent, true);
|
||
offsets.x += offsetParent.clientLeft;
|
||
offsets.y += offsetParent.clientTop;
|
||
} else if (documentElement) {
|
||
offsets.x = getWindowScrollBarX(documentElement);
|
||
}
|
||
}
|
||
return {
|
||
x: rect.left + scroll.scrollLeft - offsets.x,
|
||
y: rect.top + scroll.scrollTop - offsets.y,
|
||
width: rect.width,
|
||
height: rect.height
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/orderModifiers.js
|
||
function order(modifiers) {
|
||
var map = /* @__PURE__ */ new Map();
|
||
var visited = /* @__PURE__ */ new Set();
|
||
var result = [];
|
||
modifiers.forEach(function(modifier) {
|
||
map.set(modifier.name, modifier);
|
||
});
|
||
function sort(modifier) {
|
||
visited.add(modifier.name);
|
||
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
||
requires.forEach(function(dep) {
|
||
if (!visited.has(dep)) {
|
||
var depModifier = map.get(dep);
|
||
if (depModifier) {
|
||
sort(depModifier);
|
||
}
|
||
}
|
||
});
|
||
result.push(modifier);
|
||
}
|
||
modifiers.forEach(function(modifier) {
|
||
if (!visited.has(modifier.name)) {
|
||
sort(modifier);
|
||
}
|
||
});
|
||
return result;
|
||
}
|
||
function orderModifiers(modifiers) {
|
||
var orderedModifiers = order(modifiers);
|
||
return modifierPhases.reduce(function(acc, phase) {
|
||
return acc.concat(orderedModifiers.filter(function(modifier) {
|
||
return modifier.phase === phase;
|
||
}));
|
||
}, []);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/debounce.js
|
||
function debounce(fn2) {
|
||
var pending;
|
||
return function() {
|
||
if (!pending) {
|
||
pending = new Promise(function(resolve) {
|
||
Promise.resolve().then(function() {
|
||
pending = void 0;
|
||
resolve(fn2());
|
||
});
|
||
});
|
||
}
|
||
return pending;
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/mergeByName.js
|
||
function mergeByName(modifiers) {
|
||
var merged = modifiers.reduce(function(merged2, current) {
|
||
var existing = merged2[current.name];
|
||
merged2[current.name] = existing ? Object.assign({}, existing, current, {
|
||
options: Object.assign({}, existing.options, current.options),
|
||
data: Object.assign({}, existing.data, current.data)
|
||
}) : current;
|
||
return merged2;
|
||
}, {});
|
||
return Object.keys(merged).map(function(key) {
|
||
return merged[key];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/createPopper.js
|
||
var DEFAULT_OPTIONS = {
|
||
placement: "bottom",
|
||
modifiers: [],
|
||
strategy: "absolute"
|
||
};
|
||
function areValidElements() {
|
||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||
args[_key] = arguments[_key];
|
||
}
|
||
return !args.some(function(element2) {
|
||
return !(element2 && typeof element2.getBoundingClientRect === "function");
|
||
});
|
||
}
|
||
function popperGenerator(generatorOptions) {
|
||
if (generatorOptions === void 0) {
|
||
generatorOptions = {};
|
||
}
|
||
var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
||
return function createPopper2(reference2, popper2, options) {
|
||
if (options === void 0) {
|
||
options = defaultOptions;
|
||
}
|
||
var state = {
|
||
placement: "bottom",
|
||
orderedModifiers: [],
|
||
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
||
modifiersData: {},
|
||
elements: {
|
||
reference: reference2,
|
||
popper: popper2
|
||
},
|
||
attributes: {},
|
||
styles: {}
|
||
};
|
||
var effectCleanupFns = [];
|
||
var isDestroyed = false;
|
||
var instance5 = {
|
||
state,
|
||
setOptions: function setOptions(setOptionsAction) {
|
||
var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
|
||
cleanupModifierEffects();
|
||
state.options = Object.assign({}, defaultOptions, state.options, options2);
|
||
state.scrollParents = {
|
||
reference: isElement(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
|
||
popper: listScrollParents(popper2)
|
||
};
|
||
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
|
||
state.orderedModifiers = orderedModifiers.filter(function(m) {
|
||
return m.enabled;
|
||
});
|
||
runModifierEffects();
|
||
return instance5.update();
|
||
},
|
||
// Sync update – it will always be executed, even if not necessary. This
|
||
// is useful for low frequency updates where sync behavior simplifies the
|
||
// logic.
|
||
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
||
// prefer the async Popper#update method
|
||
forceUpdate: function forceUpdate() {
|
||
if (isDestroyed) {
|
||
return;
|
||
}
|
||
var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
|
||
if (!areValidElements(reference3, popper3)) {
|
||
return;
|
||
}
|
||
state.rects = {
|
||
reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
|
||
popper: getLayoutRect(popper3)
|
||
};
|
||
state.reset = false;
|
||
state.placement = state.options.placement;
|
||
state.orderedModifiers.forEach(function(modifier) {
|
||
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
||
});
|
||
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
||
if (state.reset === true) {
|
||
state.reset = false;
|
||
index = -1;
|
||
continue;
|
||
}
|
||
var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
|
||
if (typeof fn2 === "function") {
|
||
state = fn2({
|
||
state,
|
||
options: _options,
|
||
name,
|
||
instance: instance5
|
||
}) || state;
|
||
}
|
||
}
|
||
},
|
||
// Async and optimistically optimized update – it will not be executed if
|
||
// not necessary (debounced to run at most once-per-tick)
|
||
update: debounce(function() {
|
||
return new Promise(function(resolve) {
|
||
instance5.forceUpdate();
|
||
resolve(state);
|
||
});
|
||
}),
|
||
destroy: function destroy() {
|
||
cleanupModifierEffects();
|
||
isDestroyed = true;
|
||
}
|
||
};
|
||
if (!areValidElements(reference2, popper2)) {
|
||
return instance5;
|
||
}
|
||
instance5.setOptions(options).then(function(state2) {
|
||
if (!isDestroyed && options.onFirstUpdate) {
|
||
options.onFirstUpdate(state2);
|
||
}
|
||
});
|
||
function runModifierEffects() {
|
||
state.orderedModifiers.forEach(function(_ref) {
|
||
var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect4 = _ref.effect;
|
||
if (typeof effect4 === "function") {
|
||
var cleanupFn = effect4({
|
||
state,
|
||
name,
|
||
instance: instance5,
|
||
options: options2
|
||
});
|
||
var noopFn = function noopFn2() {
|
||
};
|
||
effectCleanupFns.push(cleanupFn || noopFn);
|
||
}
|
||
});
|
||
}
|
||
function cleanupModifierEffects() {
|
||
effectCleanupFns.forEach(function(fn2) {
|
||
return fn2();
|
||
});
|
||
effectCleanupFns = [];
|
||
}
|
||
return instance5;
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/popper.js
|
||
var defaultModifiers = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default, offset_default, flip_default, preventOverflow_default, arrow_default, hide_default];
|
||
var createPopper = /* @__PURE__ */ popperGenerator({
|
||
defaultModifiers
|
||
});
|
||
|
||
// src/ui/suggest/suggest.ts
|
||
var import_obsidian7 = require("obsidian");
|
||
var Suggest = class {
|
||
constructor(owner, containerEl, scope) {
|
||
this.owner = owner;
|
||
this.containerEl = containerEl;
|
||
this.suggestions = [];
|
||
this.selectedItem = 0;
|
||
this.values = [];
|
||
containerEl.on(
|
||
"click",
|
||
".suggestion-item",
|
||
this.onSuggestionClick.bind(this)
|
||
);
|
||
containerEl.on(
|
||
"mousemove",
|
||
".suggestion-item",
|
||
this.onSuggestionMouseover.bind(this)
|
||
);
|
||
scope.register([], "ArrowUp", (event) => {
|
||
if (!event.isComposing) {
|
||
this.setSelectedItem(this.selectedItem - 1, true);
|
||
return false;
|
||
}
|
||
});
|
||
scope.register([], "ArrowDown", (event) => {
|
||
if (!event.isComposing) {
|
||
this.setSelectedItem(this.selectedItem + 1, true);
|
||
return false;
|
||
}
|
||
});
|
||
scope.register([], "Enter", (event) => {
|
||
if (!event.isComposing) {
|
||
this.useSelectedItem(event);
|
||
return false;
|
||
}
|
||
});
|
||
}
|
||
onSuggestionClick(event, el) {
|
||
event.preventDefault();
|
||
const item = this.suggestions.indexOf(el);
|
||
this.setSelectedItem(item, false);
|
||
this.useSelectedItem(event);
|
||
}
|
||
onSuggestionMouseover(_event, el) {
|
||
const item = this.suggestions.indexOf(el);
|
||
this.setSelectedItem(item, false);
|
||
}
|
||
setSuggestions(values) {
|
||
this.containerEl.empty();
|
||
const suggestionEls = [];
|
||
values.forEach((value) => {
|
||
const suggestionEl = this.containerEl.createDiv("suggestion-item");
|
||
this.owner.renderSuggestion(value, suggestionEl);
|
||
suggestionEls.push(suggestionEl);
|
||
});
|
||
this.values = values;
|
||
this.suggestions = suggestionEls;
|
||
this.setSelectedItem(0, false);
|
||
}
|
||
useSelectedItem(event) {
|
||
const currentValue = this.values[this.selectedItem];
|
||
if (currentValue) {
|
||
this.owner.selectSuggestion(currentValue, event);
|
||
}
|
||
}
|
||
setSelectedItem(selectedIndex, scrollIntoView) {
|
||
const normalizedIndex = wrapAround(
|
||
selectedIndex,
|
||
this.suggestions.length
|
||
);
|
||
const prevSelectedSuggestion = this.suggestions[this.selectedItem];
|
||
const selectedSuggestion = this.suggestions[normalizedIndex];
|
||
prevSelectedSuggestion == null ? void 0 : prevSelectedSuggestion.removeClass("is-selected");
|
||
selectedSuggestion == null ? void 0 : selectedSuggestion.addClass("is-selected");
|
||
this.selectedItem = normalizedIndex;
|
||
if (scrollIntoView) {
|
||
selectedSuggestion.scrollIntoView(false);
|
||
}
|
||
}
|
||
};
|
||
var TextInputSuggest = class {
|
||
constructor(app, inputEl) {
|
||
this.app = app;
|
||
this.inputEl = inputEl;
|
||
this.scope = new import_obsidian7.Scope();
|
||
this.suggestEl = createDiv("suggestion-container");
|
||
const suggestion = this.suggestEl.createDiv("suggestion");
|
||
this.suggest = new Suggest(this, suggestion, this.scope);
|
||
this.scope.register([], "Escape", this.close.bind(this));
|
||
this.inputEl.addEventListener("input", this.onInputChanged.bind(this));
|
||
this.inputEl.addEventListener("focus", this.onInputChanged.bind(this));
|
||
this.inputEl.addEventListener("blur", this.close.bind(this));
|
||
this.suggestEl.on(
|
||
"mousedown",
|
||
".suggestion-container",
|
||
(event) => {
|
||
event.preventDefault();
|
||
}
|
||
);
|
||
}
|
||
onInputChanged() {
|
||
const inputStr = this.inputEl.value;
|
||
const suggestions = this.getSuggestions(inputStr);
|
||
if (suggestions.length > 0) {
|
||
this.suggest.setSuggestions(suggestions);
|
||
this.open(this.app.dom.appContainerEl, this.inputEl);
|
||
}
|
||
}
|
||
open(container, inputEl) {
|
||
this.app.keymap.pushScope(this.scope);
|
||
container.appendChild(this.suggestEl);
|
||
this.popper = createPopper(inputEl, this.suggestEl, {
|
||
placement: "bottom-start",
|
||
modifiers: [
|
||
{
|
||
name: "sameWidth",
|
||
enabled: true,
|
||
fn: ({ state, instance: instance5 }) => {
|
||
const targetWidth = `${state.rects.reference.width}px`;
|
||
if (state.styles.popper.width === targetWidth) {
|
||
return;
|
||
}
|
||
state.styles.popper.width = targetWidth;
|
||
instance5.update();
|
||
},
|
||
phase: "beforeWrite",
|
||
requires: ["computeStyles"]
|
||
}
|
||
]
|
||
});
|
||
}
|
||
close() {
|
||
var _a2;
|
||
this.app.keymap.popScope(this.scope);
|
||
this.suggest.setSuggestions([]);
|
||
(_a2 = this.popper) == null ? void 0 : _a2.destroy();
|
||
this.suggestEl.detach();
|
||
}
|
||
};
|
||
|
||
// src/ui/suggest/file-suggest.ts
|
||
var SvgFileSuggest = class extends TextInputSuggest {
|
||
getSuggestions(inputStr) {
|
||
const abstractFiles = this.app.vault.getAllLoadedFiles();
|
||
const files = [];
|
||
const lowerCaseInputStr = inputStr.toLowerCase();
|
||
abstractFiles.forEach((file) => {
|
||
if (file instanceof import_obsidian8.TFile && file.extension === "svg" && file.path.toLowerCase().contains(lowerCaseInputStr)) {
|
||
files.push(file);
|
||
}
|
||
});
|
||
return files;
|
||
}
|
||
renderSuggestion(file, el) {
|
||
el.setText(file.path);
|
||
}
|
||
selectSuggestion(file) {
|
||
this.inputEl.value = file.path;
|
||
this.inputEl.trigger("input");
|
||
this.close();
|
||
}
|
||
};
|
||
|
||
// src/ui/SettingsView/addFilterInput.ts
|
||
var import_obsidian9 = require("obsidian");
|
||
function addFilterInput(filter2, el, idx, plugin) {
|
||
const item = el.createEl("li", {
|
||
attr: {
|
||
style: "list-style-type: none; position: relative; margin: 5px 0; padding-right: 45px"
|
||
}
|
||
});
|
||
const patternField = new import_obsidian9.TextComponent(el);
|
||
patternField.setPlaceholder("regex pattern").setValue(filter2.pattern).onChange((value) => __async(this, null, function* () {
|
||
if (!value) {
|
||
return;
|
||
}
|
||
plugin.settings.customFilters[idx].pattern = value;
|
||
yield plugin.saveSettings();
|
||
}));
|
||
const patternEl = patternField.inputEl;
|
||
patternEl.style.width = "250px";
|
||
item.appendChild(patternEl);
|
||
const replaceField = new import_obsidian9.TextComponent(el);
|
||
replaceField.setPlaceholder("replacement").setValue(filter2.replace).onChange((value) => __async(this, null, function* () {
|
||
if (!value) {
|
||
return;
|
||
}
|
||
plugin.settings.customFilters[idx].replace = value;
|
||
yield plugin.saveSettings();
|
||
}));
|
||
const replaceEl = replaceField.inputEl;
|
||
replaceEl.style.width = "250px";
|
||
replaceEl.style.marginLeft = "5px";
|
||
item.appendChild(replaceEl);
|
||
const flagField = new import_obsidian9.TextComponent(el);
|
||
flagField.setPlaceholder("flags").setValue(filter2.flags).onChange((value) => __async(this, null, function* () {
|
||
if (!value) {
|
||
return;
|
||
}
|
||
plugin.settings.customFilters[idx].flags = value;
|
||
yield plugin.saveSettings();
|
||
}));
|
||
const flagEl = flagField.inputEl;
|
||
flagEl.style.width = "50px";
|
||
flagEl.style.marginLeft = "5px";
|
||
item.appendChild(flagEl);
|
||
const removeButton = new import_obsidian9.ButtonComponent(el);
|
||
removeButton.setIcon("minus");
|
||
removeButton.setTooltip("Remove filter");
|
||
removeButton.onClick(() => __async(this, null, function* () {
|
||
plugin.settings.customFilters.splice(idx, 1);
|
||
el.empty();
|
||
for (let i = 0; i < plugin.settings.customFilters.length; i++) {
|
||
addFilterInput(plugin.settings.customFilters[i], el, i, plugin);
|
||
}
|
||
yield plugin.saveSettings();
|
||
}));
|
||
const removeButtonEl = removeButton.buttonEl;
|
||
removeButtonEl.style.marginLeft = "5px";
|
||
removeButtonEl.style.position = "absolute";
|
||
removeButtonEl.style.right = "0";
|
||
item.appendChild(removeButtonEl);
|
||
}
|
||
|
||
// src/ui/SettingsView/GithubSettings.ts
|
||
var import_obsidian10 = require("obsidian");
|
||
var GithubSettings = class {
|
||
constructor(settings, settingsRootElement) {
|
||
this.initializeHeader = () => {
|
||
this.connectionStatusElement.style.cssText = "margin-left: 10px;";
|
||
this.checkConnectionAndSaveSettings();
|
||
const githubSettingsHeader = createEl("h3", {
|
||
text: "GitHub Authentication (required)"
|
||
});
|
||
githubSettingsHeader.append(this.connectionStatusElement);
|
||
githubSettingsHeader.prepend(this.settings.getIcon("github"));
|
||
this.settingsRootElement.prepend(githubSettingsHeader);
|
||
};
|
||
this.checkConnectionAndSaveSettings = () => __async(this, null, function* () {
|
||
this.settings.saveSettings();
|
||
yield this.updateConnectionStatus();
|
||
});
|
||
this.updateConnectionStatus = () => __async(this, null, function* () {
|
||
var _a2;
|
||
const oktokit = new Octokit({
|
||
auth: this.settings.settings.githubToken
|
||
});
|
||
try {
|
||
const response = yield oktokit.request(
|
||
"GET /repos/{owner}/{repo}",
|
||
{
|
||
owner: this.settings.settings.githubUserName,
|
||
repo: this.settings.settings.githubRepo
|
||
}
|
||
);
|
||
if ((_a2 = response.data.permissions) == null ? void 0 : _a2.admin) {
|
||
this.connectionStatus = "connected";
|
||
}
|
||
} catch (error) {
|
||
this.connectionStatus = "error";
|
||
}
|
||
this.updateConnectionStatusIndicator();
|
||
});
|
||
this.updateConnectionStatusIndicator = () => {
|
||
if (this.connectionStatus === "loading") {
|
||
this.connectionStatusElement.innerText = "\u23F3";
|
||
}
|
||
if (this.connectionStatus === "connected") {
|
||
this.connectionStatusElement.innerText = "\u2705";
|
||
}
|
||
if (this.connectionStatus === "error") {
|
||
this.connectionStatusElement.innerText = "\u274C";
|
||
}
|
||
};
|
||
this.settings = settings;
|
||
this.settingsRootElement = settingsRootElement;
|
||
this.settingsRootElement.id = "github-settings";
|
||
this.settingsRootElement.classList.add("settings-tab-content");
|
||
this.connectionStatus = "loading";
|
||
this.connectionStatusElement = this.settingsRootElement.createEl(
|
||
"span",
|
||
{ cls: "connection-status" }
|
||
);
|
||
this.initializeHeader();
|
||
this.initializeGitHubRepoSetting();
|
||
this.initializeGitHubUserNameSetting();
|
||
this.initializeGitHubTokenSetting();
|
||
}
|
||
initializeGitHubRepoSetting() {
|
||
new import_obsidian10.Setting(this.settingsRootElement).setName("GitHub repo name").setDesc("The name of the GitHub repository").addText(
|
||
(text2) => text2.setPlaceholder("mydigitalgarden").setValue(this.settings.settings.githubRepo).onChange((value) => __async(this, null, function* () {
|
||
this.settings.settings.githubRepo = value;
|
||
yield this.checkConnectionAndSaveSettings();
|
||
}))
|
||
);
|
||
}
|
||
initializeGitHubUserNameSetting() {
|
||
new import_obsidian10.Setting(this.settingsRootElement).setName("GitHub Username").setDesc("Your GitHub Username").addText(
|
||
(text2) => text2.setPlaceholder("myusername").setValue(this.settings.settings.githubUserName).onChange((value) => __async(this, null, function* () {
|
||
this.settings.settings.githubUserName = value;
|
||
yield this.checkConnectionAndSaveSettings();
|
||
}))
|
||
);
|
||
}
|
||
initializeGitHubTokenSetting() {
|
||
const desc = document.createDocumentFragment();
|
||
desc.createEl("span", void 0, (span) => {
|
||
span.innerText = "A GitHub token with repo permissions. You can generate it ";
|
||
span.createEl("a", void 0, (link) => {
|
||
link.href = "https://github.com/settings/tokens/new?scopes=repo";
|
||
link.innerText = "here!";
|
||
});
|
||
});
|
||
new import_obsidian10.Setting(this.settingsRootElement).setName("GitHub token").setDesc(desc).addText(
|
||
(text2) => text2.setPlaceholder("Secret Token").setValue(this.settings.settings.githubToken).onChange((value) => __async(this, null, function* () {
|
||
this.settings.settings.githubToken = value;
|
||
yield this.checkConnectionAndSaveSettings();
|
||
}))
|
||
);
|
||
}
|
||
};
|
||
|
||
// src/ui/SettingsView/SettingView.ts
|
||
var OBSIDIAN_THEME_URL = "https://raw.githubusercontent.com/obsidianmd/obsidian-releases/master/community-css-themes.json";
|
||
var SettingView = class {
|
||
constructor(app, settingsRootElement, settings, saveSettings) {
|
||
this.debouncedSaveAndUpdate = (0, import_obsidian11.debounce)(
|
||
this.saveSiteSettingsAndUpdateEnv,
|
||
500,
|
||
true
|
||
);
|
||
this.app = app;
|
||
this.settingsRootElement = settingsRootElement;
|
||
this.settingsRootElement.classList.add("dg-settings");
|
||
this.settings = settings;
|
||
this.saveSettings = saveSettings;
|
||
}
|
||
getIcon(name) {
|
||
var _a2;
|
||
return (_a2 = (0, import_obsidian11.getIcon)(name)) != null ? _a2 : document.createElement("span");
|
||
}
|
||
initialize(prModal) {
|
||
return __async(this, null, function* () {
|
||
this.settingsRootElement.empty();
|
||
this.settingsRootElement.createEl("h1", {
|
||
text: "Digital Garden Settings"
|
||
});
|
||
const linkDiv = this.settingsRootElement.createEl("div", {
|
||
attr: { style: "margin-bottom: 10px;" }
|
||
});
|
||
linkDiv.createEl("span", {
|
||
text: "Remember to read the setup guide if you haven't already. It can be found "
|
||
});
|
||
linkDiv.createEl("a", {
|
||
text: "here.",
|
||
href: "https://dg-docs.ole.dev/getting-started/01-getting-started/"
|
||
});
|
||
const githubSettings = this.settingsRootElement.createEl("div", {
|
||
cls: "connection-status"
|
||
});
|
||
new GithubSettings(this, githubSettings);
|
||
this.settingsRootElement.createEl("h3", { text: "URL" }).prepend(this.getIcon("link"));
|
||
this.initializeGitHubBaseURLSetting();
|
||
this.initializeSlugifySetting();
|
||
this.settingsRootElement.createEl("h3", { text: "Features" }).prepend(this.getIcon("star"));
|
||
this.initializeDefaultNoteSettings();
|
||
this.settingsRootElement.createEl("h3", { text: "Appearance" }).prepend(this.getIcon("brush"));
|
||
this.initializeThemesSettings();
|
||
this.settingsRootElement.createEl("h3", { text: "Advanced" }).prepend(this.getIcon("cog"));
|
||
this.initializePathRewriteSettings();
|
||
this.initializeCustomFilterSettings();
|
||
prModal.titleEl.createEl("h1", "Site template settings");
|
||
});
|
||
}
|
||
initializeDefaultNoteSettings() {
|
||
return __async(this, null, function* () {
|
||
const noteSettingsModal = new import_obsidian11.Modal(this.app);
|
||
noteSettingsModal.titleEl.createEl("h1", {
|
||
text: "Default Note Settings"
|
||
});
|
||
const linkDiv = noteSettingsModal.contentEl.createEl("div", {
|
||
attr: { style: "margin-bottom: 20px; margin-top: -30px;" }
|
||
});
|
||
linkDiv.createEl("span", { text: "Note Setting Docs is available " });
|
||
linkDiv.createEl("a", {
|
||
text: "here.",
|
||
href: "https://dg-docs.ole.dev/getting-started/03-note-settings/"
|
||
});
|
||
new import_obsidian11.Setting(this.settingsRootElement).setName("Global Note Settings").setDesc(
|
||
`Default settings for each published note. These can be overwritten per note via frontmatter.`
|
||
).addButton((cb) => {
|
||
cb.setButtonText("Manage note settings");
|
||
cb.onClick(() => __async(this, null, function* () {
|
||
noteSettingsModal.open();
|
||
}));
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Show home link (dg-home-link)").setDesc(
|
||
"Determines whether to show a link back to the homepage or not."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgHomeLink);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgHomeLink = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Show local graph for notes (dg-show-local-graph)").setDesc(
|
||
"When turned on, notes will show its local graph in a sidebar on desktop and at the bottom of the page on mobile."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgShowLocalGraph);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgShowLocalGraph = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Show backlinks for notes (dg-show-backlinks)").setDesc(
|
||
"When turned on, notes will show backlinks in a sidebar on desktop and at the bottom of the page on mobile."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgShowBacklinks);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgShowBacklinks = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Show a table of content for notes (dg-show-toc)").setDesc(
|
||
"When turned on, notes will show all headers as a table of content in a sidebar on desktop. It will not be shown on mobile devices."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgShowToc);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgShowToc = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Show inline title (dg-show-inline-title)").setDesc(
|
||
"When turned on, the title of the note will show on top of the page."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgShowInlineTitle);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgShowInlineTitle = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Show filetree sidebar (dg-show-file-tree)").setDesc("When turned on, a filetree will be shown on your site.").addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgShowFileTree);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgShowFileTree = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Enable search (dg-enable-search)").setDesc(
|
||
"When turned on, users will be able to search through the content of your site."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgEnableSearch);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgEnableSearch = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Enable link preview (dg-link-preview)").setDesc(
|
||
"When turned on, hovering over links to notes in your garden shows a scrollable preview."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgLinkPreview);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgLinkPreview = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Show Tags (dg-show-tags)").setDesc(
|
||
"When turned on, tags in your frontmatter will be displayed on each note. If search is enabled, clicking on a tag will bring up a search for all notes containing that tag."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgShowTags);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgShowTags = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(noteSettingsModal.contentEl).setName("Let all frontmatter through (dg-pass-frontmatter)").setDesc(
|
||
"Determines whether to let all frontmatter data through to the site template. Be aware that this could break your site if you have data in a format not recognized by the template engine, 11ty."
|
||
).addToggle((t) => {
|
||
t.setValue(this.settings.defaultNoteSettings.dgPassFrontmatter);
|
||
t.onChange((val) => {
|
||
this.settings.defaultNoteSettings.dgPassFrontmatter = val;
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
});
|
||
});
|
||
});
|
||
}
|
||
initializeThemesSettings() {
|
||
return __async(this, null, function* () {
|
||
const themeModal = new import_obsidian11.Modal(this.app);
|
||
themeModal.containerEl.addClass("dg-settings");
|
||
themeModal.titleEl.createEl("h1", { text: "Appearance Settings" });
|
||
new import_obsidian11.Setting(this.settingsRootElement).setName("Appearance").setDesc("Manage themes, sitename and styling on your site").addButton((cb) => {
|
||
cb.setButtonText("Manage appearance");
|
||
cb.onClick(() => __async(this, null, function* () {
|
||
themeModal.open();
|
||
}));
|
||
});
|
||
try {
|
||
if (
|
||
// @ts-expect-error https://gist.github.com/aidenlx/6067c943fbec8ead230f2b163bfd3bc8 for typing example
|
||
this.app.plugins && // @ts-expect-error see above
|
||
this.app.plugins.plugins["obsidian-style-settings"]._loaded
|
||
) {
|
||
themeModal.contentEl.createEl("h2", { text: "Style Settings Plugin" }).prepend(this.getIcon("paintbrush"));
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Apply current style settings to site").setDesc(
|
||
"Click the apply button to use the current style settings from the Style Settings Plugin on your site."
|
||
).addButton((btn) => {
|
||
btn.setButtonText("Apply");
|
||
btn.onClick((_ev) => __async(this, null, function* () {
|
||
new import_obsidian11.Notice("Applying Style Settings...");
|
||
const styleSettingsNode = document.querySelector(
|
||
"#css-settings-manager"
|
||
);
|
||
if (!styleSettingsNode) {
|
||
new import_obsidian11.Notice("No Style Settings found");
|
||
return;
|
||
}
|
||
this.settings.styleSettingsCss = styleSettingsNode.innerHTML;
|
||
if (!this.settings.styleSettingsCss) {
|
||
new import_obsidian11.Notice("No Style Settings found");
|
||
return;
|
||
}
|
||
this.saveSiteSettingsAndUpdateEnv(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
new import_obsidian11.Notice("Style Settings applied to site");
|
||
}));
|
||
});
|
||
}
|
||
} catch (e) {
|
||
console.error("Error loading style settings plugin");
|
||
}
|
||
themeModal.contentEl.createEl("h2", { text: "Theme Settings" }).prepend(this.getIcon("palette"));
|
||
const themesListResponse = yield axios_default.get(OBSIDIAN_THEME_URL);
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Theme").addDropdown((dd) => {
|
||
dd.addOption('{"name": "default", "modes": ["dark"]}', "Default");
|
||
const sortedThemes = themesListResponse.data.sort(
|
||
(a, b) => a.name.localeCompare(b.name)
|
||
);
|
||
sortedThemes.map((x) => {
|
||
dd.addOption(
|
||
JSON.stringify(__spreadProps(__spreadValues({}, x), {
|
||
cssUrl: `https://raw.githubusercontent.com/${x.repo}/${x.branch || "HEAD"}/${x.legacy ? "obsidian.css" : "theme.css"}`
|
||
})),
|
||
x.name
|
||
);
|
||
dd.setValue(this.settings.theme);
|
||
dd.onChange((val) => __async(this, null, function* () {
|
||
this.settings.theme = val;
|
||
yield this.saveSettings();
|
||
}));
|
||
});
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Base theme").addDropdown((dd) => {
|
||
dd.addOption("dark", "Dark");
|
||
dd.addOption("light", "Light");
|
||
dd.setValue(this.settings.baseTheme);
|
||
dd.onChange((val) => __async(this, null, function* () {
|
||
this.settings.baseTheme = val;
|
||
yield this.saveSettings();
|
||
}));
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Sitename").setDesc(
|
||
"The name of your site. This will be displayed as the site header."
|
||
).addText(
|
||
(text2) => text2.setValue(this.settings.siteName).onChange((value) => __async(this, null, function* () {
|
||
this.settings.siteName = value;
|
||
yield this.saveSettings();
|
||
}))
|
||
);
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Favicon").setDesc(
|
||
"Path to an svg in your vault you wish to use as a favicon. Leave blank to use default."
|
||
).addText((tc) => {
|
||
tc.setPlaceholder("myfavicon.svg");
|
||
tc.setValue(this.settings.faviconPath);
|
||
tc.onChange((val) => __async(this, null, function* () {
|
||
this.settings.faviconPath = val;
|
||
yield this.saveSettings();
|
||
}));
|
||
new SvgFileSuggest(this.app, tc.inputEl);
|
||
});
|
||
themeModal.contentEl.createEl("h2", { text: "Timestamps Settings" }).prepend(this.getIcon("calendar-clock"));
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Timestamp format").setDesc(
|
||
"The format string to render timestamp on the garden. Must be luxon compatible"
|
||
).addText(
|
||
(text2) => text2.setValue(this.settings.timestampFormat).onChange((value) => __async(this, null, function* () {
|
||
this.settings.timestampFormat = value;
|
||
yield this.saveSettings();
|
||
}))
|
||
);
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Show created timestamp").addToggle((t) => {
|
||
t.setValue(this.settings.showCreatedTimestamp).onChange(
|
||
(value) => __async(this, null, function* () {
|
||
this.settings.showCreatedTimestamp = value;
|
||
yield this.saveSettings();
|
||
})
|
||
);
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Created timestamp Frontmatter Key").setDesc(
|
||
"Key to get the created timestamp from the frontmatter. Keep blank to get the value from file creation time. The value can be any value that luxon Datetime.fromISO can parse."
|
||
).addText(
|
||
(text2) => text2.setValue(this.settings.createdTimestampKey).onChange((value) => __async(this, null, function* () {
|
||
this.settings.createdTimestampKey = value;
|
||
yield this.saveSettings();
|
||
}))
|
||
);
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Show updated timestamp").addToggle((t) => {
|
||
t.setValue(this.settings.showUpdatedTimestamp).onChange(
|
||
(value) => __async(this, null, function* () {
|
||
this.settings.showUpdatedTimestamp = value;
|
||
yield this.saveSettings();
|
||
})
|
||
);
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Updated timestamp Frontmatter Key").setDesc(
|
||
"Key to get the updated timestamp from the frontmatter. Keep blank to get the value from file update time. The value can be any value that luxon Datetime.fromISO can parse."
|
||
).addText(
|
||
(text2) => text2.setValue(this.settings.updatedTimestampKey).onChange((value) => __async(this, null, function* () {
|
||
this.settings.updatedTimestampKey = value;
|
||
yield this.saveSettings();
|
||
}))
|
||
);
|
||
themeModal.contentEl.createEl("h2", { text: "CSS settings" }).prepend(this.getIcon("code"));
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Body Classes Key").setDesc(
|
||
"Key for setting css-classes to the note body from the frontmatter."
|
||
).addText(
|
||
(text2) => text2.setValue(this.settings.contentClassesKey).onChange((value) => __async(this, null, function* () {
|
||
this.settings.contentClassesKey = value;
|
||
yield this.saveSettings();
|
||
}))
|
||
);
|
||
themeModal.contentEl.createEl("h2", { text: "Note icons Settings" }).prepend(this.getIcon("image"));
|
||
themeModal.contentEl.createEl("div", { attr: { style: "margin-bottom: 10px;" } }).createEl("a", {
|
||
text: "Documentation on note icons",
|
||
href: "https://dg-docs.ole.dev/advanced/note-specific-settings/#note-icons"
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Note icon Frontmatter Key").setDesc("Key to get the note icon value from the frontmatter").addText(
|
||
(text2) => text2.setValue(this.settings.noteIconKey).onChange((value) => __async(this, null, function* () {
|
||
this.settings.noteIconKey = value;
|
||
yield this.saveSettings();
|
||
}))
|
||
);
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Default note icon Value").setDesc("The default value for note icon if not specified").addText((text2) => {
|
||
text2.setValue(this.settings.defaultNoteIcon).onChange(
|
||
(value) => __async(this, null, function* () {
|
||
this.settings.defaultNoteIcon = value;
|
||
yield this.saveSettings();
|
||
})
|
||
);
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Show note icon on Title").addToggle((t) => {
|
||
t.setValue(this.settings.showNoteIconOnTitle).onChange(
|
||
(value) => __async(this, null, function* () {
|
||
this.settings.showNoteIconOnTitle = value;
|
||
yield this.saveSettings();
|
||
})
|
||
);
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Show note icon in FileTree").addToggle((t) => {
|
||
t.setValue(this.settings.showNoteIconInFileTree).onChange(
|
||
(value) => __async(this, null, function* () {
|
||
this.settings.showNoteIconInFileTree = value;
|
||
yield this.saveSettings();
|
||
})
|
||
);
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Show note icon on Internal Links").addToggle((t) => {
|
||
t.setValue(this.settings.showNoteIconOnInternalLink).onChange(
|
||
(value) => __async(this, null, function* () {
|
||
this.settings.showNoteIconOnInternalLink = value;
|
||
yield this.saveSettings();
|
||
})
|
||
);
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).setName("Show note icon on Backlinks").addToggle((t) => {
|
||
t.setValue(this.settings.showNoteIconOnBackLink).onChange(
|
||
(value) => __async(this, null, function* () {
|
||
this.settings.showNoteIconOnBackLink = value;
|
||
yield this.saveSettings();
|
||
})
|
||
);
|
||
});
|
||
new import_obsidian11.Setting(themeModal.contentEl).addButton((cb) => {
|
||
cb.setButtonText("Apply settings to site");
|
||
cb.onClick((_ev) => __async(this, null, function* () {
|
||
const octokit = new Octokit({
|
||
auth: this.settings.githubToken
|
||
});
|
||
yield this.saveSettingsAndUpdateEnv();
|
||
yield this.addFavicon(octokit);
|
||
}));
|
||
});
|
||
});
|
||
}
|
||
saveSettingsAndUpdateEnv() {
|
||
return __async(this, null, function* () {
|
||
const theme = JSON.parse(this.settings.theme);
|
||
const baseTheme = this.settings.baseTheme;
|
||
if (theme.modes.indexOf(baseTheme) < 0) {
|
||
new import_obsidian11.Notice(
|
||
`The ${theme.name} theme doesn't support ${baseTheme} mode.`
|
||
);
|
||
return;
|
||
}
|
||
const gardenManager = new DigitalGardenSiteManager(
|
||
this.app.metadataCache,
|
||
this.settings
|
||
);
|
||
yield gardenManager.updateEnv();
|
||
new import_obsidian11.Notice("Successfully applied settings");
|
||
});
|
||
}
|
||
saveSiteSettingsAndUpdateEnv(metadataCache, settings, saveSettings) {
|
||
return __async(this, null, function* () {
|
||
let updateFailed = false;
|
||
try {
|
||
const gardenManager = new DigitalGardenSiteManager(
|
||
metadataCache,
|
||
settings
|
||
);
|
||
yield gardenManager.updateEnv();
|
||
} catch (e) {
|
||
new import_obsidian11.Notice(
|
||
"Failed to update settings. Make sure you have an internet connection."
|
||
);
|
||
updateFailed = true;
|
||
}
|
||
if (!updateFailed) {
|
||
yield saveSettings();
|
||
}
|
||
});
|
||
}
|
||
addFavicon(octokit) {
|
||
return __async(this, null, function* () {
|
||
let base64SettingsFaviconContent = "";
|
||
if (this.settings.faviconPath) {
|
||
const faviconFile = this.app.vault.getAbstractFileByPath(
|
||
this.settings.faviconPath
|
||
);
|
||
if (!(faviconFile instanceof import_obsidian11.TFile)) {
|
||
new import_obsidian11.Notice(`${this.settings.faviconPath} is not a valid file.`);
|
||
return;
|
||
}
|
||
const faviconContent = yield this.app.vault.readBinary(faviconFile);
|
||
base64SettingsFaviconContent = arrayBufferToBase64(faviconContent);
|
||
} else {
|
||
const defaultFavicon = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: "oleeskild",
|
||
repo: "digitalgarden",
|
||
path: "src/site/favicon.svg"
|
||
}
|
||
);
|
||
base64SettingsFaviconContent = defaultFavicon.data.content;
|
||
}
|
||
let faviconExists = true;
|
||
let faviconsAreIdentical = false;
|
||
let currentFaviconOnSite = null;
|
||
try {
|
||
currentFaviconOnSite = yield octokit.request(
|
||
"GET /repos/{owner}/{repo}/contents/{path}",
|
||
{
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: "src/site/favicon.svg"
|
||
}
|
||
);
|
||
faviconsAreIdentical = // @ts-expect-error TODO: abstract octokit response
|
||
currentFaviconOnSite.data.content.replaceAll("\n", "").replaceAll(" ", "") === base64SettingsFaviconContent;
|
||
} catch (error) {
|
||
faviconExists = false;
|
||
}
|
||
if (!faviconExists || !faviconsAreIdentical) {
|
||
yield octokit.request("PUT /repos/{owner}/{repo}/contents/{path}", {
|
||
owner: this.settings.githubUserName,
|
||
repo: this.settings.githubRepo,
|
||
path: "src/site/favicon.svg",
|
||
message: `Update favicon.svg`,
|
||
content: base64SettingsFaviconContent,
|
||
// @ts-expect-error TODO: abstract octokit response
|
||
sha: faviconExists ? currentFaviconOnSite.data.sha : null
|
||
});
|
||
}
|
||
});
|
||
}
|
||
initializeGitHubBaseURLSetting() {
|
||
new import_obsidian11.Setting(this.settingsRootElement).setName("Base URL").setDesc(
|
||
`This is optional, but recommended. It is used for the "Copy Garden URL" command, generating a sitemap.xml for better SEO and an RSS feed located at /feed.xml. `
|
||
).addText(
|
||
(text2) => text2.setPlaceholder("https://my-garden.vercel.app").setValue(this.settings.gardenBaseUrl).onChange((value) => __async(this, null, function* () {
|
||
this.settings.gardenBaseUrl = value;
|
||
this.debouncedSaveAndUpdate(
|
||
this.app.metadataCache,
|
||
this.settings,
|
||
this.saveSettings
|
||
);
|
||
}))
|
||
);
|
||
}
|
||
initializeSlugifySetting() {
|
||
new import_obsidian11.Setting(this.settingsRootElement).setName("Slugify Note URL").setDesc(
|
||
'Transform the URL from "/My Folder/My Note/" to "/my-folder/my-note". If your note titles contains non-English characters, this should be disabled.'
|
||
).addToggle(
|
||
(toggle) => toggle.setValue(this.settings.slugifyEnabled).onChange((value) => __async(this, null, function* () {
|
||
this.settings.slugifyEnabled = value;
|
||
yield this.saveSettings();
|
||
}))
|
||
);
|
||
}
|
||
initializePathRewriteSettings() {
|
||
const rewriteRulesModal = new import_obsidian11.Modal(this.app);
|
||
rewriteRulesModal.titleEl.createEl("h1", {
|
||
text: "Path Rewrite Rules"
|
||
});
|
||
rewriteRulesModal.modalEl.style.width = "fit-content";
|
||
new import_obsidian11.Setting(this.settingsRootElement).setName("Path Rewrite Rules").setDesc(
|
||
"Define rules to rewrite note folder structure in the garden. See the modal for more information."
|
||
).addButton((cb) => {
|
||
cb.setButtonText("Manage Rewrite Rules");
|
||
cb.onClick(() => {
|
||
rewriteRulesModal.open();
|
||
});
|
||
});
|
||
const rewriteSettingContainer = rewriteRulesModal.contentEl.createEl(
|
||
"div",
|
||
{
|
||
attr: {
|
||
class: "",
|
||
style: "align-items:flex-start; flex-direction: column;"
|
||
}
|
||
}
|
||
);
|
||
rewriteSettingContainer.createEl("div", {
|
||
text: `Define rules to rewrite note paths/folder structure, using following syntax:`
|
||
});
|
||
const list = rewriteSettingContainer.createEl("ol");
|
||
list.createEl("li", { text: `One rule-per line` });
|
||
list.createEl("li", {
|
||
text: `The format is [from_vault_path]:[to_garden_path]`
|
||
});
|
||
list.createEl("li", { text: `Matching will exit on first match` });
|
||
rewriteSettingContainer.createEl("div", {
|
||
text: `Example: If you want the vault folder "Personal/Journal" to be shown as only "Journal" in the left file sidebar in the garden, add the line "Personal/Journal:Journal"`,
|
||
attr: { class: "setting-item-description" }
|
||
});
|
||
rewriteSettingContainer.createEl("div", {
|
||
text: `Note: rewriting a folder to the base path "[from_vault_path]:" is not supported at the moment.`,
|
||
attr: { class: "setting-item-description" }
|
||
});
|
||
rewriteSettingContainer.createEl("div", {
|
||
text: `Any affected notes will show up as changed in the publication center`,
|
||
attr: { class: "setting-item-description" }
|
||
});
|
||
new import_obsidian11.Setting(rewriteSettingContainer).setName("Rules").addTextArea((field) => {
|
||
field.setPlaceholder("Personal/Journal:Journal");
|
||
field.inputEl.rows = 5;
|
||
field.inputEl.cols = 100;
|
||
field.setValue(this.settings.pathRewriteRules).onChange((value) => __async(this, null, function* () {
|
||
this.settings.pathRewriteRules = value;
|
||
yield this.saveSettings();
|
||
}));
|
||
});
|
||
rewriteSettingContainer.createEl("div", {
|
||
text: `Type a path below to test that your rules are working as expected`,
|
||
attr: { class: "test-rewrite-rules-description" }
|
||
});
|
||
const rewriteSettingsPreviewContainer = rewriteSettingContainer.createEl("div", {
|
||
attr: {
|
||
style: "display: flex; align-items: center; margin-top: 10px;"
|
||
}
|
||
});
|
||
const previewInput = rewriteSettingsPreviewContainer.createEl("input", {
|
||
attr: {
|
||
type: "text",
|
||
placeholder: "type a vault path",
|
||
style: "margin-right: 10px;"
|
||
}
|
||
});
|
||
previewInput.addEventListener("input", () => {
|
||
const testPath = previewInput.value;
|
||
const rewriteTestResult = getGardenPathForNote(
|
||
testPath,
|
||
getRewriteRules(this.settings.pathRewriteRules)
|
||
);
|
||
testResultDiv.innerHTML = `Garden path: "${rewriteTestResult}"`;
|
||
});
|
||
const testResultDiv = rewriteSettingsPreviewContainer.createEl("div", {
|
||
text: `Garden path: ""`,
|
||
attr: { class: "test-rewrite-rules-new-path" }
|
||
});
|
||
}
|
||
initializeCustomFilterSettings() {
|
||
const customFilterModal = new import_obsidian11.Modal(this.app);
|
||
customFilterModal.titleEl.createEl("h1", { text: "Custom Filters" });
|
||
customFilterModal.modalEl.style.width = "fit-content";
|
||
new import_obsidian11.Setting(this.settingsRootElement).setName("Custom Filters").setDesc(
|
||
"Define custom rules to replace parts of the note before publishing."
|
||
).addButton((cb) => {
|
||
cb.setButtonText("Manage Custom Filters");
|
||
cb.onClick(() => {
|
||
customFilterModal.open();
|
||
});
|
||
});
|
||
const rewriteSettingsContainer = customFilterModal.contentEl.createEl(
|
||
"div",
|
||
{
|
||
attr: {
|
||
class: "",
|
||
style: "align-items:flex-start; flex-direction: column; margin: 5px;"
|
||
}
|
||
}
|
||
);
|
||
rewriteSettingsContainer.createEl(
|
||
"div"
|
||
).innerHTML = `Define regex filters to replace note content before publishing.`;
|
||
rewriteSettingsContainer.createEl("div", {
|
||
attr: { class: "setting-item-description" }
|
||
}).innerHTML = `Format: [<code>regex pattern</code>, <code>replacement</code>, <code>regex flags</code>]`;
|
||
rewriteSettingsContainer.createEl("div", {
|
||
attr: {
|
||
class: "setting-item-description",
|
||
style: "margin-bottom: 15px"
|
||
}
|
||
}).innerHTML = `Example: filter [<code>:smile:</code>, <code>\u{1F600}</code>, <code>g</code>] will replace text with real emojis`;
|
||
const customFilters = this.settings.customFilters;
|
||
new import_obsidian11.Setting(rewriteSettingsContainer).setName("Filters").addButton((button) => {
|
||
button.setButtonText("Add");
|
||
button.setTooltip("Add a filter");
|
||
button.setIcon("plus");
|
||
button.onClick(() => __async(this, null, function* () {
|
||
const customFilters2 = this.settings.customFilters;
|
||
customFilters2.push({
|
||
pattern: "",
|
||
flags: "g",
|
||
replace: ""
|
||
});
|
||
filterList.empty();
|
||
for (let i = 0; i < customFilters2.length; i++) {
|
||
addFilterInput(customFilters2[i], filterList, i, this);
|
||
}
|
||
}));
|
||
});
|
||
const filterList = rewriteSettingsContainer.createDiv("custom-filter-list");
|
||
for (let i = 0; i < customFilters.length; i++) {
|
||
addFilterInput(customFilters[i], filterList, i, this);
|
||
}
|
||
}
|
||
renderCreatePr(modal, handlePR) {
|
||
var _a2;
|
||
this.settingsRootElement.createEl("h3", { text: "Update site" }).prepend((_a2 = (0, import_obsidian11.getIcon)("sync")) != null ? _a2 : "");
|
||
new import_obsidian11.Setting(this.settingsRootElement).setName("Site Template").setDesc(
|
||
"Manage updates to the base template. You should try updating the template when you update the plugin to make sure your garden support all features."
|
||
).addButton((button) => {
|
||
button.setButtonText("Manage site template");
|
||
button.onClick(() => {
|
||
modal.open();
|
||
});
|
||
});
|
||
modal.titleEl.createEl("h2", { text: "Update site" });
|
||
new import_obsidian11.Setting(modal.contentEl).setName("Update site to latest template").setDesc(
|
||
`
|
||
This will create a pull request with the latest template changes, which you'll need to use all plugin features.
|
||
It will not publish any changes before you approve them.
|
||
`
|
||
).addButton(
|
||
(button) => button.setButtonText("Create PR").onClick(() => handlePR(button))
|
||
);
|
||
this.settingsRootElement.createEl("h3", { text: "Support" }).prepend(this.getIcon("heart"));
|
||
this.settingsRootElement.createDiv({
|
||
attr: {
|
||
style: "display:flex; align-items:center; justify-content:center; margin-top: 20px;"
|
||
}
|
||
}).createEl("a", {
|
||
attr: { href: "https://ko-fi.com/oleeskild", target: "_blank" }
|
||
}).createEl("img", {
|
||
attr: {
|
||
src: "https://cdn.ko-fi.com/cdn/kofi3.png?v=3",
|
||
width: "200"
|
||
}
|
||
});
|
||
}
|
||
renderPullRequestHistory(modal, previousPrUrls) {
|
||
if (previousPrUrls.length === 0) {
|
||
return;
|
||
}
|
||
const header = modal.contentEl.createEl("h2", {
|
||
text: "\u2795 Recent Pull Request History"
|
||
});
|
||
const prsContainer = modal.contentEl.createEl("ul", {});
|
||
prsContainer.hide();
|
||
header.onClickEvent(() => {
|
||
if (prsContainer.isShown()) {
|
||
prsContainer.hide();
|
||
header.textContent = "\u2795 Recent Pull Request History";
|
||
} else {
|
||
prsContainer.show();
|
||
header.textContent = "\u2796 Recent Pull Request History";
|
||
}
|
||
});
|
||
previousPrUrls.map((prUrl) => {
|
||
const li = prsContainer.createEl("li", {
|
||
attr: { style: "margin-bottom: 10px" }
|
||
});
|
||
const prUrlElement = document.createElement("a");
|
||
prUrlElement.href = prUrl;
|
||
prUrlElement.textContent = prUrl;
|
||
li.appendChild(prUrlElement);
|
||
});
|
||
}
|
||
};
|
||
|
||
// src/ui/SettingsModal.ts
|
||
var import_obsidian12 = require("obsidian");
|
||
var UpdateGardenRepositoryModal = class extends import_obsidian12.Modal {
|
||
constructor(app) {
|
||
super(app);
|
||
this.progressViewTop = this.contentEl.createDiv();
|
||
}
|
||
renderLoading() {
|
||
var _a2;
|
||
this.loading = this.progressViewTop.createDiv();
|
||
this.loading.show();
|
||
const text2 = "Creating PR. This should take about 30-60 seconds";
|
||
const loadingText = (_a2 = this.loading) == null ? void 0 : _a2.createEl("h5", { text: text2 });
|
||
this.loadingInterval = setInterval(() => {
|
||
if (loadingText.innerText === `${text2}`) {
|
||
loadingText.innerText = `${text2}.`;
|
||
} else if (loadingText.innerText === `${text2}.`) {
|
||
loadingText.innerText = `${text2}..`;
|
||
} else if (loadingText.innerText === `${text2}..`) {
|
||
loadingText.innerText = `${text2}...`;
|
||
} else {
|
||
loadingText.innerText = `${text2}`;
|
||
}
|
||
}, 400);
|
||
}
|
||
renderSuccess(prUrl) {
|
||
var _a2;
|
||
(_a2 = this.loading) == null ? void 0 : _a2.remove();
|
||
clearInterval(this.loadingInterval);
|
||
const successmessage = prUrl ? { text: `\u{1F389} Done! Approve your PR to make the changes go live.` } : {
|
||
text: "You already have the latest template \u{1F389} No need to create a PR."
|
||
};
|
||
const linkText = { text: `${prUrl}`, href: prUrl };
|
||
this.progressViewTop.createEl("h2", successmessage);
|
||
if (prUrl) {
|
||
this.progressViewTop.createEl("a", linkText);
|
||
}
|
||
this.progressViewTop.createEl("br");
|
||
}
|
||
renderError() {
|
||
var _a2;
|
||
(_a2 = this.loading) == null ? void 0 : _a2.remove();
|
||
clearInterval(this.loadingInterval);
|
||
const errorMsg = {
|
||
text: "\u274C Something went wrong. Try deleting the branch in GitHub.",
|
||
attr: {}
|
||
};
|
||
this.progressViewTop.createEl("p", errorMsg);
|
||
}
|
||
};
|
||
|
||
// src/ui/DigitalGardenSettingTab.ts
|
||
var DigitalGardenSettingTab = class extends import_obsidian13.PluginSettingTab {
|
||
constructor(app, plugin) {
|
||
super(app, plugin);
|
||
this.plugin = plugin;
|
||
if (!this.plugin.settings.noteSettingsIsInitialized) {
|
||
const siteManager = new DigitalGardenSiteManager(
|
||
this.app.metadataCache,
|
||
this.plugin.settings
|
||
);
|
||
siteManager.updateEnv();
|
||
this.plugin.settings.noteSettingsIsInitialized = true;
|
||
this.plugin.saveData(this.plugin.settings);
|
||
}
|
||
}
|
||
display() {
|
||
return __async(this, null, function* () {
|
||
const { containerEl } = this;
|
||
const settingView = new SettingView(
|
||
this.app,
|
||
containerEl,
|
||
this.plugin.settings,
|
||
() => __async(this, null, function* () {
|
||
return yield this.plugin.saveData(this.plugin.settings);
|
||
})
|
||
);
|
||
const prModal = new UpdateGardenRepositoryModal(this.app);
|
||
yield settingView.initialize(prModal);
|
||
const handlePR = (button) => __async(this, null, function* () {
|
||
prModal.renderLoading();
|
||
button.setDisabled(true);
|
||
try {
|
||
const siteManager = new DigitalGardenSiteManager(
|
||
this.plugin.app.metadataCache,
|
||
this.plugin.settings
|
||
);
|
||
const prUrl = yield siteManager.createPullRequestWithSiteChanges();
|
||
if (prUrl) {
|
||
this.plugin.settings.prHistory.push(prUrl);
|
||
yield this.plugin.saveSettings();
|
||
}
|
||
prModal.renderSuccess(prUrl);
|
||
button.setDisabled(false);
|
||
} catch (e) {
|
||
prModal.renderError();
|
||
}
|
||
});
|
||
settingView.renderCreatePr(prModal, handlePR);
|
||
settingView.renderPullRequestHistory(
|
||
prModal,
|
||
this.plugin.settings.prHistory.reverse().slice(0, 10)
|
||
);
|
||
});
|
||
}
|
||
};
|
||
|
||
// main.ts
|
||
var DEFAULT_SETTINGS = {
|
||
githubRepo: "",
|
||
githubToken: "",
|
||
githubUserName: "",
|
||
gardenBaseUrl: "",
|
||
prHistory: [],
|
||
baseTheme: "dark",
|
||
theme: '{"name": "default", "modes": ["dark"]}',
|
||
faviconPath: "",
|
||
noteSettingsIsInitialized: false,
|
||
siteName: "Digital Garden",
|
||
slugifyEnabled: true,
|
||
// Note Icon Related Settings
|
||
noteIconKey: "dg-note-icon",
|
||
defaultNoteIcon: "",
|
||
showNoteIconOnTitle: false,
|
||
showNoteIconInFileTree: false,
|
||
showNoteIconOnInternalLink: false,
|
||
showNoteIconOnBackLink: false,
|
||
// Timestamp related settings
|
||
showCreatedTimestamp: false,
|
||
createdTimestampKey: "dg-created",
|
||
showUpdatedTimestamp: false,
|
||
updatedTimestampKey: "dg-updated",
|
||
timestampFormat: "MMM dd, yyyy h:mm a",
|
||
styleSettingsCss: "",
|
||
pathRewriteRules: "",
|
||
customFilters: [],
|
||
contentClassesKey: "dg-content-classes",
|
||
defaultNoteSettings: {
|
||
dgHomeLink: true,
|
||
dgPassFrontmatter: false,
|
||
dgShowBacklinks: false,
|
||
dgShowLocalGraph: false,
|
||
dgShowInlineTitle: false,
|
||
dgShowFileTree: false,
|
||
dgEnableSearch: false,
|
||
dgShowToc: false,
|
||
dgLinkPreview: false,
|
||
dgShowTags: false
|
||
}
|
||
};
|
||
var DigitalGarden = class extends import_obsidian14.Plugin {
|
||
onload() {
|
||
return __async(this, null, function* () {
|
||
this.appVersion = this.manifest.version;
|
||
console.log("Initializing DigitalGarden plugin v" + this.appVersion);
|
||
yield this.loadSettings();
|
||
this.addSettingTab(new DigitalGardenSettingTab(this.app, this));
|
||
yield this.addCommands();
|
||
(0, import_obsidian14.addIcon)("digital-garden-icon", seedling);
|
||
this.addRibbonIcon(
|
||
"digital-garden-icon",
|
||
"Digital Garden Publication Center",
|
||
() => __async(this, null, function* () {
|
||
this.openPublishModal();
|
||
})
|
||
);
|
||
});
|
||
}
|
||
onunload() {
|
||
}
|
||
loadSettings() {
|
||
return __async(this, null, function* () {
|
||
this.settings = Object.assign(
|
||
{},
|
||
DEFAULT_SETTINGS,
|
||
yield this.loadData()
|
||
);
|
||
});
|
||
}
|
||
saveSettings() {
|
||
return __async(this, null, function* () {
|
||
yield this.saveData(this.settings);
|
||
});
|
||
}
|
||
addCommands() {
|
||
return __async(this, null, function* () {
|
||
this.addCommand({
|
||
id: "quick-publish-and-share-note",
|
||
name: "Quick Publish And Share Note",
|
||
callback: () => __async(this, null, function* () {
|
||
new import_obsidian14.Notice("Adding publish flag to note and publishing it.");
|
||
yield this.addPublishFlag();
|
||
const activeFile = this.app.workspace.getActiveFile();
|
||
const event = this.app.metadataCache.on(
|
||
"changed",
|
||
(file, _data, _cache) => __async(this, null, function* () {
|
||
if (file.path === (activeFile == null ? void 0 : activeFile.path)) {
|
||
const successfullyPublished = yield this.publishSingleNote();
|
||
if (successfullyPublished) {
|
||
yield this.copyGardenUrlToClipboard();
|
||
}
|
||
this.app.metadataCache.offref(event);
|
||
}
|
||
})
|
||
);
|
||
setTimeout(() => {
|
||
this.app.metadataCache.offref(event);
|
||
}, 5e3);
|
||
})
|
||
});
|
||
this.addCommand({
|
||
id: "publish-note",
|
||
name: "Publish Single Note",
|
||
callback: () => __async(this, null, function* () {
|
||
yield this.publishSingleNote();
|
||
})
|
||
});
|
||
this.addCommand({
|
||
id: "publish-multiple-notes",
|
||
name: "Publish Multiple Notes",
|
||
callback: () => __async(this, null, function* () {
|
||
const statusBarItem = this.addStatusBarItem();
|
||
try {
|
||
new import_obsidian14.Notice("Processing files to publish...");
|
||
const { vault, metadataCache } = this.app;
|
||
const publisher = new Publisher(
|
||
vault,
|
||
metadataCache,
|
||
this.settings
|
||
);
|
||
const siteManager = new DigitalGardenSiteManager(
|
||
metadataCache,
|
||
this.settings
|
||
);
|
||
const publishStatusManager = new PublishStatusManager(
|
||
siteManager,
|
||
publisher
|
||
);
|
||
const publishStatus = yield publishStatusManager.getPublishStatus();
|
||
const filesToPublish = publishStatus.changedNotes.concat(
|
||
publishStatus.unpublishedNotes
|
||
);
|
||
const filesToDelete = publishStatus.deletedNotePaths;
|
||
const imagesToDelete = publishStatus.deletedImagePaths;
|
||
const statusBar = new PublishStatusBar(
|
||
statusBarItem,
|
||
filesToPublish.length + filesToDelete.length + imagesToDelete.length
|
||
);
|
||
let errorFiles = 0;
|
||
let errorDeleteFiles = 0;
|
||
let errorDeleteImage = 0;
|
||
new import_obsidian14.Notice(
|
||
`Publishing ${filesToPublish.length} notes, deleting ${filesToDelete.length} notes and ${imagesToDelete.length} images. See the status bar in lower right corner for progress.`,
|
||
8e3
|
||
);
|
||
for (const file of filesToPublish) {
|
||
try {
|
||
statusBar.increment();
|
||
yield publisher.publish(file);
|
||
} catch (e) {
|
||
errorFiles++;
|
||
new import_obsidian14.Notice(
|
||
`Unable to publish note ${file.name}, skipping it.`
|
||
);
|
||
}
|
||
}
|
||
for (const filePath of filesToDelete) {
|
||
try {
|
||
statusBar.increment();
|
||
yield publisher.deleteNote(filePath);
|
||
} catch (e) {
|
||
errorDeleteFiles++;
|
||
new import_obsidian14.Notice(
|
||
`Unable to delete note ${filePath}, skipping it.`
|
||
);
|
||
}
|
||
}
|
||
for (const filePath of imagesToDelete) {
|
||
try {
|
||
statusBar.increment();
|
||
yield publisher.deleteImage(filePath);
|
||
} catch (e) {
|
||
errorDeleteImage++;
|
||
new import_obsidian14.Notice(
|
||
`Unable to delete image ${filePath}, skipping it.`
|
||
);
|
||
}
|
||
}
|
||
statusBar.finish(8e3);
|
||
new import_obsidian14.Notice(
|
||
`Successfully published ${filesToPublish.length - errorFiles} notes to your garden.`
|
||
);
|
||
if (filesToDelete.length > 0) {
|
||
new import_obsidian14.Notice(
|
||
`Successfully deleted ${filesToDelete.length - errorDeleteFiles} notes from your garden.`
|
||
);
|
||
}
|
||
if (imagesToDelete.length > 0) {
|
||
new import_obsidian14.Notice(
|
||
`Successfully deleted ${imagesToDelete.length - errorDeleteImage} images from your garden.`
|
||
);
|
||
}
|
||
} catch (e) {
|
||
statusBarItem.remove();
|
||
console.error(e);
|
||
new import_obsidian14.Notice(
|
||
"Unable to publish multiple notes, something went wrong."
|
||
);
|
||
}
|
||
})
|
||
});
|
||
this.addCommand({
|
||
id: "copy-garden-url",
|
||
name: "Copy Garden URL",
|
||
callback: () => __async(this, null, function* () {
|
||
this.copyGardenUrlToClipboard();
|
||
})
|
||
});
|
||
this.addCommand({
|
||
id: "dg-open-publish-modal",
|
||
name: "Open Publication Center",
|
||
callback: () => __async(this, null, function* () {
|
||
this.openPublishModal();
|
||
})
|
||
});
|
||
this.addCommand({
|
||
id: "dg-mark-note-for-publish",
|
||
name: "Add publish flag",
|
||
callback: () => __async(this, null, function* () {
|
||
this.addPublishFlag();
|
||
})
|
||
});
|
||
});
|
||
}
|
||
copyGardenUrlToClipboard() {
|
||
return __async(this, null, function* () {
|
||
try {
|
||
const { metadataCache, workspace } = this.app;
|
||
const currentFile = workspace.getActiveFile();
|
||
if (!currentFile) {
|
||
new import_obsidian14.Notice(
|
||
"No file is open/active. Please open a file and try again."
|
||
);
|
||
return;
|
||
}
|
||
const siteManager = new DigitalGardenSiteManager(
|
||
metadataCache,
|
||
this.settings
|
||
);
|
||
const fullUrl = siteManager.getNoteUrl(currentFile);
|
||
yield navigator.clipboard.writeText(fullUrl);
|
||
new import_obsidian14.Notice(`Note URL copied to clipboard`);
|
||
} catch (e) {
|
||
console.log(e);
|
||
new import_obsidian14.Notice(
|
||
"Unable to copy note URL to clipboard, something went wrong."
|
||
);
|
||
}
|
||
});
|
||
}
|
||
publishSingleNote() {
|
||
return __async(this, null, function* () {
|
||
try {
|
||
const { vault, workspace, metadataCache } = this.app;
|
||
const currentFile = workspace.getActiveFile();
|
||
if (!currentFile) {
|
||
new import_obsidian14.Notice(
|
||
"No file is open/active. Please open a file and try again."
|
||
);
|
||
return;
|
||
}
|
||
if (currentFile.extension !== "md") {
|
||
new import_obsidian14.Notice(
|
||
"The current file is not a markdown file. Please open a markdown file and try again."
|
||
);
|
||
return;
|
||
}
|
||
new import_obsidian14.Notice("Publishing note...");
|
||
const publisher = new Publisher(
|
||
vault,
|
||
metadataCache,
|
||
this.settings
|
||
);
|
||
const publishSuccessful = yield publisher.publish(currentFile);
|
||
if (publishSuccessful) {
|
||
new import_obsidian14.Notice(`Successfully published note to your garden.`);
|
||
}
|
||
return publishSuccessful;
|
||
} catch (e) {
|
||
console.error(e);
|
||
new import_obsidian14.Notice("Unable to publish note, something went wrong.");
|
||
return false;
|
||
}
|
||
});
|
||
}
|
||
addPublishFlag() {
|
||
return __async(this, null, function* () {
|
||
const activeFile = this.app.workspace.getActiveFile();
|
||
if (activeFile === null) {
|
||
new import_obsidian14.Notice("No active file!");
|
||
return;
|
||
}
|
||
const engine = new ObsidianFrontMatterEngine(
|
||
this.app.vault,
|
||
this.app.metadataCache,
|
||
activeFile
|
||
);
|
||
engine.set("dg-publish", true).apply();
|
||
});
|
||
}
|
||
openPublishModal() {
|
||
if (!this.publishModal) {
|
||
const siteManager = new DigitalGardenSiteManager(
|
||
this.app.metadataCache,
|
||
this.settings
|
||
);
|
||
const publisher = new Publisher(
|
||
this.app.vault,
|
||
this.app.metadataCache,
|
||
this.settings
|
||
);
|
||
const publishStatusManager = new PublishStatusManager(
|
||
siteManager,
|
||
publisher
|
||
);
|
||
this.publishModal = new PublishModal(
|
||
this.app,
|
||
publishStatusManager,
|
||
publisher,
|
||
siteManager,
|
||
this.settings
|
||
);
|
||
}
|
||
this.publishModal.open();
|
||
}
|
||
};
|
||
//![[image.svg]]
|
||
//!()[image.svg]
|
||
//![[image.png]]
|
||
//
|
||
/*! Bundled license information:
|
||
|
||
is-plain-object/dist/is-plain-object.mjs:
|
||
(*!
|
||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||
*
|
||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||
* Released under the MIT License.
|
||
*)
|
||
*/
|