Notepad/enter/.obsidian/plugins/obsidian-latex-suite/main.js

8687 lines
381 KiB
JavaScript
Raw Permalink Normal View History

2023-07-05 18:29:11 +00:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module2) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
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/json5/dist/index.js
var require_dist = __commonJS({
"node_modules/json5/dist/index.js"(exports, module2) {
(function(global, factory) {
typeof exports === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global.JSON5 = factory();
})(exports, function() {
"use strict";
function createCommonjsModule(fn2, module3) {
return module3 = { exports: {} }, fn2(module3, module3.exports), module3.exports;
}
var _global = createCommonjsModule(function(module3) {
var global = module3.exports = typeof window != "undefined" && window.Math == Math ? window : typeof self != "undefined" && self.Math == Math ? self : Function("return this")();
if (typeof __g == "number") {
__g = global;
}
});
var _core = createCommonjsModule(function(module3) {
var core = module3.exports = { version: "2.6.5" };
if (typeof __e == "number") {
__e = core;
}
});
var _core_1 = _core.version;
var _isObject = function(it) {
return typeof it === "object" ? it !== null : typeof it === "function";
};
var _anObject = function(it) {
if (!_isObject(it)) {
throw TypeError(it + " is not an object!");
}
return it;
};
var _fails = function(exec) {
try {
return !!exec();
} catch (e) {
return true;
}
};
var _descriptors = !_fails(function() {
return Object.defineProperty({}, "a", { get: function() {
return 7;
} }).a != 7;
});
var document2 = _global.document;
var is = _isObject(document2) && _isObject(document2.createElement);
var _domCreate = function(it) {
return is ? document2.createElement(it) : {};
};
var _ie8DomDefine = !_descriptors && !_fails(function() {
return Object.defineProperty(_domCreate("div"), "a", { get: function() {
return 7;
} }).a != 7;
});
var _toPrimitive = function(it, S) {
if (!_isObject(it)) {
return it;
}
var fn2, val;
if (S && typeof (fn2 = it.toString) == "function" && !_isObject(val = fn2.call(it))) {
return val;
}
if (typeof (fn2 = it.valueOf) == "function" && !_isObject(val = fn2.call(it))) {
return val;
}
if (!S && typeof (fn2 = it.toString) == "function" && !_isObject(val = fn2.call(it))) {
return val;
}
throw TypeError("Can't convert object to primitive value");
};
var dP = Object.defineProperty;
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
_anObject(O);
P = _toPrimitive(P, true);
_anObject(Attributes);
if (_ie8DomDefine) {
try {
return dP(O, P, Attributes);
} catch (e) {
}
}
if ("get" in Attributes || "set" in Attributes) {
throw TypeError("Accessors not supported!");
}
if ("value" in Attributes) {
O[P] = Attributes.value;
}
return O;
};
var _objectDp = {
f
};
var _propertyDesc = function(bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value
};
};
var _hide = _descriptors ? function(object, key2, value) {
return _objectDp.f(object, key2, _propertyDesc(1, value));
} : function(object, key2, value) {
object[key2] = value;
return object;
};
var hasOwnProperty = {}.hasOwnProperty;
var _has = function(it, key2) {
return hasOwnProperty.call(it, key2);
};
var id2 = 0;
var px = Math.random();
var _uid = function(key2) {
return "Symbol(".concat(key2 === void 0 ? "" : key2, ")_", (++id2 + px).toString(36));
};
var _library = false;
var _shared = createCommonjsModule(function(module3) {
var SHARED = "__core-js_shared__";
var store = _global[SHARED] || (_global[SHARED] = {});
(module3.exports = function(key2, value) {
return store[key2] || (store[key2] = value !== void 0 ? value : {});
})("versions", []).push({
version: _core.version,
mode: _library ? "pure" : "global",
copyright: "\xA9 2019 Denis Pushkarev (zloirock.ru)"
});
});
var _functionToString = _shared("native-function-to-string", Function.toString);
var _redefine = createCommonjsModule(function(module3) {
var SRC = _uid("src");
var TO_STRING = "toString";
var TPL = ("" + _functionToString).split(TO_STRING);
_core.inspectSource = function(it) {
return _functionToString.call(it);
};
(module3.exports = function(O, key2, val, safe) {
var isFunction = typeof val == "function";
if (isFunction) {
_has(val, "name") || _hide(val, "name", key2);
}
if (O[key2] === val) {
return;
}
if (isFunction) {
_has(val, SRC) || _hide(val, SRC, O[key2] ? "" + O[key2] : TPL.join(String(key2)));
}
if (O === _global) {
O[key2] = val;
} else if (!safe) {
delete O[key2];
_hide(O, key2, val);
} else if (O[key2]) {
O[key2] = val;
} else {
_hide(O, key2, val);
}
})(Function.prototype, TO_STRING, function toString() {
return typeof this == "function" && this[SRC] || _functionToString.call(this);
});
});
var _aFunction = function(it) {
if (typeof it != "function") {
throw TypeError(it + " is not a function!");
}
return it;
};
var _ctx = function(fn2, that, length) {
_aFunction(fn2);
if (that === void 0) {
return fn2;
}
switch (length) {
case 1:
return function(a) {
return fn2.call(that, a);
};
case 2:
return function(a, b) {
return fn2.call(that, a, b);
};
case 3:
return function(a, b, c2) {
return fn2.call(that, a, b, c2);
};
}
return function() {
return fn2.apply(that, arguments);
};
};
var PROTOTYPE = "prototype";
var $export = function(type, name, source2) {
var IS_FORCED = type & $export.F;
var IS_GLOBAL = type & $export.G;
var IS_STATIC = type & $export.S;
var IS_PROTO = type & $export.P;
var IS_BIND = type & $export.B;
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
var exports2 = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
var expProto = exports2[PROTOTYPE] || (exports2[PROTOTYPE] = {});
var key2, own, out, exp;
if (IS_GLOBAL) {
source2 = name;
}
for (key2 in source2) {
own = !IS_FORCED && target && target[key2] !== void 0;
out = (own ? target : source2)[key2];
exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == "function" ? _ctx(Function.call, out) : out;
if (target) {
_redefine(target, key2, out, type & $export.U);
}
if (exports2[key2] != out) {
_hide(exports2, key2, exp);
}
if (IS_PROTO && expProto[key2] != out) {
expProto[key2] = out;
}
}
};
_global.core = _core;
$export.F = 1;
$export.G = 2;
$export.S = 4;
$export.P = 8;
$export.B = 16;
$export.W = 32;
$export.U = 64;
$export.R = 128;
var _export = $export;
var ceil = Math.ceil;
var floor = Math.floor;
var _toInteger = function(it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
var _defined = function(it) {
if (it == void 0) {
throw TypeError("Can't call method on " + it);
}
return it;
};
var _stringAt = function(TO_STRING) {
return function(that, pos2) {
var s = String(_defined(that));
var i = _toInteger(pos2);
var l = s.length;
var a, b;
if (i < 0 || i >= l) {
return TO_STRING ? "" : void 0;
}
a = s.charCodeAt(i);
return a < 55296 || a > 56319 || i + 1 === l || (b = s.charCodeAt(i + 1)) < 56320 || b > 57343 ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 55296 << 10) + (b - 56320) + 65536;
};
};
var $at = _stringAt(false);
_export(_export.P, "String", {
codePointAt: function codePointAt2(pos2) {
return $at(this, pos2);
}
});
var codePointAt = _core.String.codePointAt;
var max2 = Math.max;
var min2 = Math.min;
var _toAbsoluteIndex = function(index, length) {
index = _toInteger(index);
return index < 0 ? max2(index + length, 0) : min2(index, length);
};
var fromCharCode = String.fromCharCode;
var $fromCodePoint = String.fromCodePoint;
_export(_export.S + _export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), "String", {
fromCodePoint: function fromCodePoint2(x) {
var arguments$1 = arguments;
var res = [];
var aLen = arguments.length;
var i = 0;
var code;
while (aLen > i) {
code = +arguments$1[i++];
if (_toAbsoluteIndex(code, 1114111) !== code) {
throw RangeError(code + " is not a valid code point");
}
res.push(code < 65536 ? fromCharCode(code) : fromCharCode(((code -= 65536) >> 10) + 55296, code % 1024 + 56320));
}
return res.join("");
}
});
var fromCodePoint = _core.String.fromCodePoint;
var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uF
var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0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\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u31
var unicode = {
Space_Separator,
ID_Start,
ID_Continue
};
var util = {
isSpaceSeparator: function isSpaceSeparator(c2) {
return typeof c2 === "string" && unicode.Space_Separator.test(c2);
},
isIdStartChar: function isIdStartChar(c2) {
return typeof c2 === "string" && (c2 >= "a" && c2 <= "z" || c2 >= "A" && c2 <= "Z" || c2 === "$" || c2 === "_" || unicode.ID_Start.test(c2));
},
isIdContinueChar: function isIdContinueChar(c2) {
return typeof c2 === "string" && (c2 >= "a" && c2 <= "z" || c2 >= "A" && c2 <= "Z" || c2 >= "0" && c2 <= "9" || c2 === "$" || c2 === "_" || c2 === "\u200C" || c2 === "\u200D" || unicode.ID_Continue.test(c2));
},
isDigit: function isDigit(c2) {
return typeof c2 === "string" && /[0-9]/.test(c2);
},
isHexDigit: function isHexDigit(c2) {
return typeof c2 === "string" && /[0-9A-Fa-f]/.test(c2);
}
};
var source;
var parseState;
var stack;
var pos;
var line;
var column;
var token;
var key;
var root;
var parse2 = function parse3(text, reviver) {
source = String(text);
parseState = "start";
stack = [];
pos = 0;
line = 1;
column = 0;
token = void 0;
key = void 0;
root = void 0;
do {
token = lex();
parseStates[parseState]();
} while (token.type !== "eof");
if (typeof reviver === "function") {
return internalize({ "": root }, "", reviver);
}
return root;
};
function internalize(holder, name, reviver) {
var value = holder[name];
if (value != null && typeof value === "object") {
for (var key2 in value) {
var replacement = internalize(value, key2, reviver);
if (replacement === void 0) {
delete value[key2];
} else {
value[key2] = replacement;
}
}
}
return reviver.call(holder, name, value);
}
var lexState;
var buffer;
var doubleQuote;
var sign;
var c;
function lex() {
lexState = "default";
buffer = "";
doubleQuote = false;
sign = 1;
for (; ; ) {
c = peek();
var token2 = lexStates[lexState]();
if (token2) {
return token2;
}
}
}
function peek() {
if (source[pos]) {
return String.fromCodePoint(source.codePointAt(pos));
}
}
function read2() {
var c2 = peek();
if (c2 === "\n") {
line++;
column = 0;
} else if (c2) {
column += c2.length;
} else {
column++;
}
if (c2) {
pos += c2.length;
}
return c2;
}
var lexStates = {
default: function default$1() {
switch (c) {
case " ":
case "\v":
case "\f":
case " ":
case "\xA0":
case "\uFEFF":
case "\n":
case "\r":
case "\u2028":
case "\u2029":
read2();
return;
case "/":
read2();
lexState = "comment";
return;
case void 0:
read2();
return newToken("eof");
}
if (util.isSpaceSeparator(c)) {
read2();
return;
}
return lexStates[parseState]();
},
comment: function comment() {
switch (c) {
case "*":
read2();
lexState = "multiLineComment";
return;
case "/":
read2();
lexState = "singleLineComment";
return;
}
throw invalidChar(read2());
},
multiLineComment: function multiLineComment() {
switch (c) {
case "*":
read2();
lexState = "multiLineCommentAsterisk";
return;
case void 0:
throw invalidChar(read2());
}
read2();
},
multiLineCommentAsterisk: function multiLineCommentAsterisk() {
switch (c) {
case "*":
read2();
return;
case "/":
read2();
lexState = "default";
return;
case void 0:
throw invalidChar(read2());
}
read2();
lexState = "multiLineComment";
},
singleLineComment: function singleLineComment() {
switch (c) {
case "\n":
case "\r":
case "\u2028":
case "\u2029":
read2();
lexState = "default";
return;
case void 0:
read2();
return newToken("eof");
}
read2();
},
value: function value() {
switch (c) {
case "{":
case "[":
return newToken("punctuator", read2());
case "n":
read2();
literal("ull");
return newToken("null", null);
case "t":
read2();
literal("rue");
return newToken("boolean", true);
case "f":
read2();
literal("alse");
return newToken("boolean", false);
case "-":
case "+":
if (read2() === "-") {
sign = -1;
}
lexState = "sign";
return;
case ".":
buffer = read2();
lexState = "decimalPointLeading";
return;
case "0":
buffer = read2();
lexState = "zero";
return;
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
buffer = read2();
lexState = "decimalInteger";
return;
case "I":
read2();
literal("nfinity");
return newToken("numeric", Infinity);
case "N":
read2();
literal("aN");
return newToken("numeric", NaN);
case '"':
case "'":
doubleQuote = read2() === '"';
buffer = "";
lexState = "string";
return;
}
throw invalidChar(read2());
},
identifierNameStartEscape: function identifierNameStartEscape() {
if (c !== "u") {
throw invalidChar(read2());
}
read2();
var u = unicodeEscape();
switch (u) {
case "$":
case "_":
break;
default:
if (!util.isIdStartChar(u)) {
throw invalidIdentifier();
}
break;
}
buffer += u;
lexState = "identifierName";
},
identifierName: function identifierName() {
switch (c) {
case "$":
case "_":
case "\u200C":
case "\u200D":
buffer += read2();
return;
case "\\":
read2();
lexState = "identifierNameEscape";
return;
}
if (util.isIdContinueChar(c)) {
buffer += read2();
return;
}
return newToken("identifier", buffer);
},
identifierNameEscape: function identifierNameEscape() {
if (c !== "u") {
throw invalidChar(read2());
}
read2();
var u = unicodeEscape();
switch (u) {
case "$":
case "_":
case "\u200C":
case "\u200D":
break;
default:
if (!util.isIdContinueChar(u)) {
throw invalidIdentifier();
}
break;
}
buffer += u;
lexState = "identifierName";
},
sign: function sign$1() {
switch (c) {
case ".":
buffer = read2();
lexState = "decimalPointLeading";
return;
case "0":
buffer = read2();
lexState = "zero";
return;
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
buffer = read2();
lexState = "decimalInteger";
return;
case "I":
read2();
literal("nfinity");
return newToken("numeric", sign * Infinity);
case "N":
read2();
literal("aN");
return newToken("numeric", NaN);
}
throw invalidChar(read2());
},
zero: function zero() {
switch (c) {
case ".":
buffer += read2();
lexState = "decimalPoint";
return;
case "e":
case "E":
buffer += read2();
lexState = "decimalExponent";
return;
case "x":
case "X":
buffer += read2();
lexState = "hexadecimal";
return;
}
return newToken("numeric", sign * 0);
},
decimalInteger: function decimalInteger() {
switch (c) {
case ".":
buffer += read2();
lexState = "decimalPoint";
return;
case "e":
case "E":
buffer += read2();
lexState = "decimalExponent";
return;
}
if (util.isDigit(c)) {
buffer += read2();
return;
}
return newToken("numeric", sign * Number(buffer));
},
decimalPointLeading: function decimalPointLeading() {
if (util.isDigit(c)) {
buffer += read2();
lexState = "decimalFraction";
return;
}
throw invalidChar(read2());
},
decimalPoint: function decimalPoint() {
switch (c) {
case "e":
case "E":
buffer += read2();
lexState = "decimalExponent";
return;
}
if (util.isDigit(c)) {
buffer += read2();
lexState = "decimalFraction";
return;
}
return newToken("numeric", sign * Number(buffer));
},
decimalFraction: function decimalFraction() {
switch (c) {
case "e":
case "E":
buffer += read2();
lexState = "decimalExponent";
return;
}
if (util.isDigit(c)) {
buffer += read2();
return;
}
return newToken("numeric", sign * Number(buffer));
},
decimalExponent: function decimalExponent() {
switch (c) {
case "+":
case "-":
buffer += read2();
lexState = "decimalExponentSign";
return;
}
if (util.isDigit(c)) {
buffer += read2();
lexState = "decimalExponentInteger";
return;
}
throw invalidChar(read2());
},
decimalExponentSign: function decimalExponentSign() {
if (util.isDigit(c)) {
buffer += read2();
lexState = "decimalExponentInteger";
return;
}
throw invalidChar(read2());
},
decimalExponentInteger: function decimalExponentInteger() {
if (util.isDigit(c)) {
buffer += read2();
return;
}
return newToken("numeric", sign * Number(buffer));
},
hexadecimal: function hexadecimal() {
if (util.isHexDigit(c)) {
buffer += read2();
lexState = "hexadecimalInteger";
return;
}
throw invalidChar(read2());
},
hexadecimalInteger: function hexadecimalInteger() {
if (util.isHexDigit(c)) {
buffer += read2();
return;
}
return newToken("numeric", sign * Number(buffer));
},
string: function string() {
switch (c) {
case "\\":
read2();
buffer += escape();
return;
case '"':
if (doubleQuote) {
read2();
return newToken("string", buffer);
}
buffer += read2();
return;
case "'":
if (!doubleQuote) {
read2();
return newToken("string", buffer);
}
buffer += read2();
return;
case "\n":
case "\r":
throw invalidChar(read2());
case "\u2028":
case "\u2029":
separatorChar(c);
break;
case void 0:
throw invalidChar(read2());
}
buffer += read2();
},
start: function start2() {
switch (c) {
case "{":
case "[":
return newToken("punctuator", read2());
}
lexState = "value";
},
beforePropertyName: function beforePropertyName() {
switch (c) {
case "$":
case "_":
buffer = read2();
lexState = "identifierName";
return;
case "\\":
read2();
lexState = "identifierNameStartEscape";
return;
case "}":
return newToken("punctuator", read2());
case '"':
case "'":
doubleQuote = read2() === '"';
lexState = "string";
return;
}
if (util.isIdStartChar(c)) {
buffer += read2();
lexState = "identifierName";
return;
}
throw invalidChar(read2());
},
afterPropertyName: function afterPropertyName() {
if (c === ":") {
return newToken("punctuator", read2());
}
throw invalidChar(read2());
},
beforePropertyValue: function beforePropertyValue() {
lexState = "value";
},
afterPropertyValue: function afterPropertyValue() {
switch (c) {
case ",":
case "}":
return newToken("punctuator", read2());
}
throw invalidChar(read2());
},
beforeArrayValue: function beforeArrayValue() {
if (c === "]") {
return newToken("punctuator", read2());
}
lexState = "value";
},
afterArrayValue: function afterArrayValue() {
switch (c) {
case ",":
case "]":
return newToken("punctuator", read2());
}
throw invalidChar(read2());
},
end: function end2() {
throw invalidChar(read2());
}
};
function newToken(type, value) {
return {
type,
value,
line,
column
};
}
function literal(s) {
for (var i = 0, list = s; i < list.length; i += 1) {
var c2 = list[i];
var p = peek();
if (p !== c2) {
throw invalidChar(read2());
}
read2();
}
}
function escape() {
var c2 = peek();
switch (c2) {
case "b":
read2();
return "\b";
case "f":
read2();
return "\f";
case "n":
read2();
return "\n";
case "r":
read2();
return "\r";
case "t":
read2();
return " ";
case "v":
read2();
return "\v";
case "0":
read2();
if (util.isDigit(peek())) {
throw invalidChar(read2());
}
return "\0";
case "x":
read2();
return hexEscape();
case "u":
read2();
return unicodeEscape();
case "\n":
case "\u2028":
case "\u2029":
read2();
return "";
case "\r":
read2();
if (peek() === "\n") {
read2();
}
return "";
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
throw invalidChar(read2());
case void 0:
throw invalidChar(read2());
}
return read2();
}
function hexEscape() {
var buffer2 = "";
var c2 = peek();
if (!util.isHexDigit(c2)) {
throw invalidChar(read2());
}
buffer2 += read2();
c2 = peek();
if (!util.isHexDigit(c2)) {
throw invalidChar(read2());
}
buffer2 += read2();
return String.fromCodePoint(parseInt(buffer2, 16));
}
function unicodeEscape() {
var buffer2 = "";
var count = 4;
while (count-- > 0) {
var c2 = peek();
if (!util.isHexDigit(c2)) {
throw invalidChar(read2());
}
buffer2 += read2();
}
return String.fromCodePoint(parseInt(buffer2, 16));
}
var parseStates = {
start: function start2() {
if (token.type === "eof") {
throw invalidEOF();
}
push();
},
beforePropertyName: function beforePropertyName() {
switch (token.type) {
case "identifier":
case "string":
key = token.value;
parseState = "afterPropertyName";
return;
case "punctuator":
pop();
return;
case "eof":
throw invalidEOF();
}
},
afterPropertyName: function afterPropertyName() {
if (token.type === "eof") {
throw invalidEOF();
}
parseState = "beforePropertyValue";
},
beforePropertyValue: function beforePropertyValue() {
if (token.type === "eof") {
throw invalidEOF();
}
push();
},
beforeArrayValue: function beforeArrayValue() {
if (token.type === "eof") {
throw invalidEOF();
}
if (token.type === "punctuator" && token.value === "]") {
pop();
return;
}
push();
},
afterPropertyValue: function afterPropertyValue() {
if (token.type === "eof") {
throw invalidEOF();
}
switch (token.value) {
case ",":
parseState = "beforePropertyName";
return;
case "}":
pop();
}
},
afterArrayValue: function afterArrayValue() {
if (token.type === "eof") {
throw invalidEOF();
}
switch (token.value) {
case ",":
parseState = "beforeArrayValue";
return;
case "]":
pop();
}
},
end: function end2() {
}
};
function push() {
var value;
switch (token.type) {
case "punctuator":
switch (token.value) {
case "{":
value = {};
break;
case "[":
value = [];
break;
}
break;
case "null":
case "boolean":
case "numeric":
case "string":
value = token.value;
break;
}
if (root === void 0) {
root = value;
} else {
var parent = stack[stack.length - 1];
if (Array.isArray(parent)) {
parent.push(value);
} else {
parent[key] = value;
}
}
if (value !== null && typeof value === "object") {
stack.push(value);
if (Array.isArray(value)) {
parseState = "beforeArrayValue";
} else {
parseState = "beforePropertyName";
}
} else {
var current = stack[stack.length - 1];
if (current == null) {
parseState = "end";
} else if (Array.isArray(current)) {
parseState = "afterArrayValue";
} else {
parseState = "afterPropertyValue";
}
}
}
function pop() {
stack.pop();
var current = stack[stack.length - 1];
if (current == null) {
parseState = "end";
} else if (Array.isArray(current)) {
parseState = "afterArrayValue";
} else {
parseState = "afterPropertyValue";
}
}
function invalidChar(c2) {
if (c2 === void 0) {
return syntaxError("JSON5: invalid end of input at " + line + ":" + column);
}
return syntaxError("JSON5: invalid character '" + formatChar(c2) + "' at " + line + ":" + column);
}
function invalidEOF() {
return syntaxError("JSON5: invalid end of input at " + line + ":" + column);
}
function invalidIdentifier() {
column -= 5;
return syntaxError("JSON5: invalid identifier character at " + line + ":" + column);
}
function separatorChar(c2) {
console.warn("JSON5: '" + formatChar(c2) + "' in strings is not valid ECMAScript; consider escaping");
}
function formatChar(c2) {
var replacements = {
"'": "\\'",
'"': '\\"',
"\\": "\\\\",
"\b": "\\b",
"\f": "\\f",
"\n": "\\n",
"\r": "\\r",
" ": "\\t",
"\v": "\\v",
"\0": "\\0",
"\u2028": "\\u2028",
"\u2029": "\\u2029"
};
if (replacements[c2]) {
return replacements[c2];
}
if (c2 < " ") {
var hexString = c2.charCodeAt(0).toString(16);
return "\\x" + ("00" + hexString).substring(hexString.length);
}
return c2;
}
function syntaxError(message) {
var err = new SyntaxError(message);
err.lineNumber = line;
err.columnNumber = column;
return err;
}
var stringify = function stringify2(value, replacer, space2) {
var stack2 = [];
var indent = "";
var propertyList;
var replacerFunc;
var gap = "";
var quote;
if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) {
space2 = replacer.space;
quote = replacer.quote;
replacer = replacer.replacer;
}
if (typeof replacer === "function") {
replacerFunc = replacer;
} else if (Array.isArray(replacer)) {
propertyList = [];
for (var i = 0, list = replacer; i < list.length; i += 1) {
var v = list[i];
var item = void 0;
if (typeof v === "string") {
item = v;
} else if (typeof v === "number" || v instanceof String || v instanceof Number) {
item = String(v);
}
if (item !== void 0 && propertyList.indexOf(item) < 0) {
propertyList.push(item);
}
}
}
if (space2 instanceof Number) {
space2 = Number(space2);
} else if (space2 instanceof String) {
space2 = String(space2);
}
if (typeof space2 === "number") {
if (space2 > 0) {
space2 = Math.min(10, Math.floor(space2));
gap = " ".substr(0, space2);
}
} else if (typeof space2 === "string") {
gap = space2.substr(0, 10);
}
return serializeProperty("", { "": value });
function serializeProperty(key2, holder) {
var value2 = holder[key2];
if (value2 != null) {
if (typeof value2.toJSON5 === "function") {
value2 = value2.toJSON5(key2);
} else if (typeof value2.toJSON === "function") {
value2 = value2.toJSON(key2);
}
}
if (replacerFunc) {
value2 = replacerFunc.call(holder, key2, value2);
}
if (value2 instanceof Number) {
value2 = Number(value2);
} else if (value2 instanceof String) {
value2 = String(value2);
} else if (value2 instanceof Boolean) {
value2 = value2.valueOf();
}
switch (value2) {
case null:
return "null";
case true:
return "true";
case false:
return "false";
}
if (typeof value2 === "string") {
return quoteString(value2, false);
}
if (typeof value2 === "number") {
return String(value2);
}
if (typeof value2 === "object") {
return Array.isArray(value2) ? serializeArray(value2) : serializeObject(value2);
}
return void 0;
}
function quoteString(value2) {
var quotes = {
"'": 0.1,
'"': 0.2
};
var replacements = {
"'": "\\'",
'"': '\\"',
"\\": "\\\\",
"\b": "\\b",
"\f": "\\f",
"\n": "\\n",
"\r": "\\r",
" ": "\\t",
"\v": "\\v",
"\0": "\\0",
"\u2028": "\\u2028",
"\u2029": "\\u2029"
};
var product = "";
for (var i2 = 0; i2 < value2.length; i2++) {
var c2 = value2[i2];
switch (c2) {
case "'":
case '"':
quotes[c2]++;
product += c2;
continue;
case "\0":
if (util.isDigit(value2[i2 + 1])) {
product += "\\x00";
continue;
}
}
if (replacements[c2]) {
product += replacements[c2];
continue;
}
if (c2 < " ") {
var hexString = c2.charCodeAt(0).toString(16);
product += "\\x" + ("00" + hexString).substring(hexString.length);
continue;
}
product += c2;
}
var quoteChar = quote || Object.keys(quotes).reduce(function(a, b) {
return quotes[a] < quotes[b] ? a : b;
});
product = product.replace(new RegExp(quoteChar, "g"), replacements[quoteChar]);
return quoteChar + product + quoteChar;
}
function serializeObject(value2) {
if (stack2.indexOf(value2) >= 0) {
throw TypeError("Converting circular structure to JSON5");
}
stack2.push(value2);
var stepback = indent;
indent = indent + gap;
var keys = propertyList || Object.keys(value2);
var partial = [];
for (var i2 = 0, list2 = keys; i2 < list2.length; i2 += 1) {
var key2 = list2[i2];
var propertyString = serializeProperty(key2, value2);
if (propertyString !== void 0) {
var member = serializeKey(key2) + ":";
if (gap !== "") {
member += " ";
}
member += propertyString;
partial.push(member);
}
}
var final;
if (partial.length === 0) {
final = "{}";
} else {
var properties;
if (gap === "") {
properties = partial.join(",");
final = "{" + properties + "}";
} else {
var separator = ",\n" + indent;
properties = partial.join(separator);
final = "{\n" + indent + properties + ",\n" + stepback + "}";
}
}
stack2.pop();
indent = stepback;
return final;
}
function serializeKey(key2) {
if (key2.length === 0) {
return quoteString(key2, true);
}
var firstChar = String.fromCodePoint(key2.codePointAt(0));
if (!util.isIdStartChar(firstChar)) {
return quoteString(key2, true);
}
for (var i2 = firstChar.length; i2 < key2.length; i2++) {
if (!util.isIdContinueChar(String.fromCodePoint(key2.codePointAt(i2)))) {
return quoteString(key2, true);
}
}
return key2;
}
function serializeArray(value2) {
if (stack2.indexOf(value2) >= 0) {
throw TypeError("Converting circular structure to JSON5");
}
stack2.push(value2);
var stepback = indent;
indent = indent + gap;
var partial = [];
for (var i2 = 0; i2 < value2.length; i2++) {
var propertyString = serializeProperty(String(i2), value2);
partial.push(propertyString !== void 0 ? propertyString : "null");
}
var final;
if (partial.length === 0) {
final = "[]";
} else {
if (gap === "") {
var properties = partial.join(",");
final = "[" + properties + "]";
} else {
var separator = ",\n" + indent;
var properties$1 = partial.join(separator);
final = "[\n" + indent + properties$1 + ",\n" + stepback + "]";
}
}
stack2.pop();
indent = stepback;
return final;
}
};
var JSON5 = {
parse: parse2,
stringify
};
var lib = JSON5;
var es5 = lib;
return es5;
});
}
});
// src/main.ts
__export(exports, {
default: () => LatexSuitePlugin
});
var import_obsidian7 = __toModule(require("obsidian"));
// src/settings.ts
var import_obsidian6 = __toModule(require("obsidian"));
var import_view9 = __toModule(require("@codemirror/view"));
var import_state7 = __toModule(require("@codemirror/state"));
// src/snippets_editor/extensions.ts
var import_view3 = __toModule(require("@codemirror/view"));
var import_state2 = __toModule(require("@codemirror/state"));
// node_modules/@lezer/common/dist/index.js
var DefaultBufferLength = 1024;
var nextPropID = 0;
var Range = class {
constructor(from, to) {
this.from = from;
this.to = to;
}
};
var NodeProp = class {
constructor(config2 = {}) {
this.id = nextPropID++;
this.perNode = !!config2.perNode;
this.deserialize = config2.deserialize || (() => {
throw new Error("This node type doesn't define a deserialize function");
});
}
add(match) {
if (this.perNode)
throw new RangeError("Can't add per-node props to node types");
if (typeof match != "function")
match = NodeType.match(match);
return (type) => {
let result = match(type);
return result === void 0 ? null : [this, result];
};
}
};
NodeProp.closedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
NodeProp.openedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
NodeProp.group = new NodeProp({ deserialize: (str) => str.split(" ") });
NodeProp.contextHash = new NodeProp({ perNode: true });
NodeProp.lookAhead = new NodeProp({ perNode: true });
NodeProp.mounted = new NodeProp({ perNode: true });
var noProps = Object.create(null);
var NodeType = class {
constructor(name, props, id2, flags = 0) {
this.name = name;
this.props = props;
this.id = id2;
this.flags = flags;
}
static define(spec) {
let props = spec.props && spec.props.length ? Object.create(null) : noProps;
let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
let type = new NodeType(spec.name || "", props, spec.id, flags);
if (spec.props)
for (let src of spec.props) {
if (!Array.isArray(src))
src = src(type);
if (src) {
if (src[0].perNode)
throw new RangeError("Can't store a per-node prop on a node type");
props[src[0].id] = src[1];
}
}
return type;
}
prop(prop) {
return this.props[prop.id];
}
get isTop() {
return (this.flags & 1) > 0;
}
get isSkipped() {
return (this.flags & 2) > 0;
}
get isError() {
return (this.flags & 4) > 0;
}
get isAnonymous() {
return (this.flags & 8) > 0;
}
is(name) {
if (typeof name == "string") {
if (this.name == name)
return true;
let group = this.prop(NodeProp.group);
return group ? group.indexOf(name) > -1 : false;
}
return this.id == name;
}
static match(map) {
let direct = Object.create(null);
for (let prop in map)
for (let name of prop.split(" "))
direct[name] = map[prop];
return (node) => {
for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
let found = direct[i < 0 ? node.name : groups[i]];
if (found)
return found;
}
};
}
};
NodeType.none = new NodeType("", Object.create(null), 0, 8);
var NodeSet = class {
constructor(types) {
this.types = types;
for (let i = 0; i < types.length; i++)
if (types[i].id != i)
throw new RangeError("Node type ids should correspond to array positions when creating a node set");
}
extend(...props) {
let newTypes = [];
for (let type of this.types) {
let newProps = null;
for (let source of props) {
let add = source(type);
if (add) {
if (!newProps)
newProps = Object.assign({}, type.props);
newProps[add[0].id] = add[1];
}
}
newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
}
return new NodeSet(newTypes);
}
};
var CachedNode = new WeakMap();
var CachedInnerNode = new WeakMap();
var IterMode;
(function(IterMode2) {
IterMode2[IterMode2["ExcludeBuffers"] = 1] = "ExcludeBuffers";
IterMode2[IterMode2["IncludeAnonymous"] = 2] = "IncludeAnonymous";
IterMode2[IterMode2["IgnoreMounts"] = 4] = "IgnoreMounts";
IterMode2[IterMode2["IgnoreOverlays"] = 8] = "IgnoreOverlays";
})(IterMode || (IterMode = {}));
var Tree = class {
constructor(type, children, positions, length, props) {
this.type = type;
this.children = children;
this.positions = positions;
this.length = length;
this.props = null;
if (props && props.length) {
this.props = Object.create(null);
for (let [prop, value] of props)
this.props[typeof prop == "number" ? prop : prop.id] = value;
}
}
toString() {
let mounted = this.prop(NodeProp.mounted);
if (mounted && !mounted.overlay)
return mounted.tree.toString();
let children = "";
for (let ch of this.children) {
let str = ch.toString();
if (str) {
if (children)
children += ",";
children += str;
}
}
return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
}
cursor(mode = 0) {
return new TreeCursor(this.topNode, mode);
}
cursorAt(pos, side = 0, mode = 0) {
let scope = CachedNode.get(this) || this.topNode;
let cursor = new TreeCursor(scope);
cursor.moveTo(pos, side);
CachedNode.set(this, cursor._tree);
return cursor;
}
get topNode() {
return new TreeNode(this, 0, 0, null);
}
resolve(pos, side = 0) {
let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
CachedNode.set(this, node);
return node;
}
resolveInner(pos, side = 0) {
let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
CachedInnerNode.set(this, node);
return node;
}
iterate(spec) {
let { enter, leave, from = 0, to = this.length } = spec;
for (let c = this.cursor((spec.mode || 0) | IterMode.IncludeAnonymous); ; ) {
let entered = false;
if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
if (c.firstChild())
continue;
entered = true;
}
for (; ; ) {
if (entered && leave && !c.type.isAnonymous)
leave(c);
if (c.nextSibling())
break;
if (!c.parent())
return;
entered = true;
}
}
}
prop(prop) {
return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
}
get propValues() {
let result = [];
if (this.props)
for (let id2 in this.props)
result.push([+id2, this.props[id2]]);
return result;
}
balance(config2 = {}) {
return this.children.length <= 8 ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config2.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
}
static build(data) {
return buildTree(data);
}
};
Tree.empty = new Tree(NodeType.none, [], [], 0);
var FlatBufferCursor = class {
constructor(buffer, index) {
this.buffer = buffer;
this.index = index;
}
get id() {
return this.buffer[this.index - 4];
}
get start() {
return this.buffer[this.index - 3];
}
get end() {
return this.buffer[this.index - 2];
}
get size() {
return this.buffer[this.index - 1];
}
get pos() {
return this.index;
}
next() {
this.index -= 4;
}
fork() {
return new FlatBufferCursor(this.buffer, this.index);
}
};
var TreeBuffer = class {
constructor(buffer, length, set) {
this.buffer = buffer;
this.length = length;
this.set = set;
}
get type() {
return NodeType.none;
}
toString() {
let result = [];
for (let index = 0; index < this.buffer.length; ) {
result.push(this.childString(index));
index = this.buffer[index + 3];
}
return result.join(",");
}
childString(index) {
let id2 = this.buffer[index], endIndex = this.buffer[index + 3];
let type = this.set.types[id2], result = type.name;
if (/\W/.test(result) && !type.isError)
result = JSON.stringify(result);
index += 4;
if (endIndex == index)
return result;
let children = [];
while (index < endIndex) {
children.push(this.childString(index));
index = this.buffer[index + 3];
}
return result + "(" + children.join(",") + ")";
}
findChild(startIndex, endIndex, dir, pos, side) {
let { buffer } = this, pick = -1;
for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
pick = i;
if (dir > 0)
break;
}
}
return pick;
}
slice(startI, endI, from, to) {
let b = this.buffer;
let copy = new Uint16Array(endI - startI);
for (let i = startI, j = 0; i < endI; ) {
copy[j++] = b[i++];
copy[j++] = b[i++] - from;
copy[j++] = b[i++] - from;
copy[j++] = b[i++] - startI;
}
return new TreeBuffer(copy, to - from, this.set);
}
};
function checkSide(side, pos, from, to) {
switch (side) {
case -2:
return from < pos;
case -1:
return to >= pos && from < pos;
case 0:
return from < pos && to > pos;
case 1:
return from <= pos && to > pos;
case 2:
return to > pos;
case 4:
return true;
}
}
function enterUnfinishedNodesBefore(node, pos) {
let scan = node.childBefore(pos);
while (scan) {
let last = scan.lastChild;
if (!last || last.to != scan.to)
break;
if (last.type.isError && last.from == last.to) {
node = scan;
scan = last.prevSibling;
} else {
scan = last;
}
}
return node;
}
function resolveNode(node, pos, side, overlays) {
var _a;
while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
if (!parent)
return node;
node = parent;
}
let mode = overlays ? 0 : IterMode.IgnoreOverlays;
if (overlays)
for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
node = parent;
}
for (; ; ) {
let inner = node.enter(pos, side, mode);
if (!inner)
return node;
node = inner;
}
}
var TreeNode = class {
constructor(_tree, from, index, _parent) {
this._tree = _tree;
this.from = from;
this.index = index;
this._parent = _parent;
}
get type() {
return this._tree.type;
}
get name() {
return this._tree.type.name;
}
get to() {
return this.from + this._tree.length;
}
nextChild(i, dir, pos, side, mode = 0) {
for (let parent = this; ; ) {
for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
let next = children[i], start2 = positions[i] + parent.from;
if (!checkSide(side, pos, start2, start2 + next.length))
continue;
if (next instanceof TreeBuffer) {
if (mode & IterMode.ExcludeBuffers)
continue;
let index = next.findChild(0, next.buffer.length, dir, pos - start2, side);
if (index > -1)
return new BufferNode(new BufferContext(parent, next, i, start2), null, index);
} else if (mode & IterMode.IncludeAnonymous || (!next.type.isAnonymous || hasChild(next))) {
let mounted;
if (!(mode & IterMode.IgnoreMounts) && next.props && (mounted = next.prop(NodeProp.mounted)) && !mounted.overlay)
return new TreeNode(mounted.tree, start2, i, parent);
let inner = new TreeNode(next, start2, i, parent);
return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
}
}
if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous)
return null;
if (parent.index >= 0)
i = parent.index + dir;
else
i = dir < 0 ? -1 : parent._parent._tree.children.length;
parent = parent._parent;
if (!parent)
return null;
}
}
get firstChild() {
return this.nextChild(0, 1, 0, 4);
}
get lastChild() {
return this.nextChild(this._tree.children.length - 1, -1, 0, 4);
}
childAfter(pos) {
return this.nextChild(0, 1, pos, 2);
}
childBefore(pos) {
return this.nextChild(this._tree.children.length - 1, -1, pos, -2);
}
enter(pos, side, mode = 0) {
let mounted;
if (!(mode & IterMode.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp.mounted)) && mounted.overlay) {
let rPos = pos - this.from;
for (let { from, to } of mounted.overlay) {
if ((side > 0 ? from <= rPos : from < rPos) && (side < 0 ? to >= rPos : to > rPos))
return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
}
}
return this.nextChild(0, 1, pos, side, mode);
}
nextSignificantParent() {
let val = this;
while (val.type.isAnonymous && val._parent)
val = val._parent;
return val;
}
get parent() {
return this._parent ? this._parent.nextSignificantParent() : null;
}
get nextSibling() {
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4) : null;
}
get prevSibling() {
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4) : null;
}
cursor(mode = 0) {
return new TreeCursor(this, mode);
}
get tree() {
return this._tree;
}
toTree() {
return this._tree;
}
resolve(pos, side = 0) {
return resolveNode(this, pos, side, false);
}
resolveInner(pos, side = 0) {
return resolveNode(this, pos, side, true);
}
enterUnfinishedNodesBefore(pos) {
return enterUnfinishedNodesBefore(this, pos);
}
getChild(type, before = null, after = null) {
let r = getChildren(this, type, before, after);
return r.length ? r[0] : null;
}
getChildren(type, before = null, after = null) {
return getChildren(this, type, before, after);
}
toString() {
return this._tree.toString();
}
get node() {
return this;
}
matchContext(context) {
return matchNodeContext(this, context);
}
};
function getChildren(node, type, before, after) {
let cur = node.cursor(), result = [];
if (!cur.firstChild())
return result;
if (before != null) {
while (!cur.type.is(before))
if (!cur.nextSibling())
return result;
}
for (; ; ) {
if (after != null && cur.type.is(after))
return result;
if (cur.type.is(type))
result.push(cur.node);
if (!cur.nextSibling())
return after == null ? result : [];
}
}
function matchNodeContext(node, context, i = context.length - 1) {
for (let p = node.parent; i >= 0; p = p.parent) {
if (!p)
return false;
if (!p.type.isAnonymous) {
if (context[i] && context[i] != p.name)
return false;
i--;
}
}
return true;
}
var BufferContext = class {
constructor(parent, buffer, index, start2) {
this.parent = parent;
this.buffer = buffer;
this.index = index;
this.start = start2;
}
};
var BufferNode = class {
constructor(context, _parent, index) {
this.context = context;
this._parent = _parent;
this.index = index;
this.type = context.buffer.set.types[context.buffer.buffer[index]];
}
get name() {
return this.type.name;
}
get from() {
return this.context.start + this.context.buffer.buffer[this.index + 1];
}
get to() {
return this.context.start + this.context.buffer.buffer[this.index + 2];
}
child(dir, pos, side) {
let { buffer } = this.context;
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
return index < 0 ? null : new BufferNode(this.context, this, index);
}
get firstChild() {
return this.child(1, 0, 4);
}
get lastChild() {
return this.child(-1, 0, 4);
}
childAfter(pos) {
return this.child(1, pos, 2);
}
childBefore(pos) {
return this.child(-1, pos, -2);
}
enter(pos, side, mode = 0) {
if (mode & IterMode.ExcludeBuffers)
return null;
let { buffer } = this.context;
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
return index < 0 ? null : new BufferNode(this.context, this, index);
}
get parent() {
return this._parent || this.context.parent.nextSignificantParent();
}
externalSibling(dir) {
return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4);
}
get nextSibling() {
let { buffer } = this.context;
let after = buffer.buffer[this.index + 3];
if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
return new BufferNode(this.context, this._parent, after);
return this.externalSibling(1);
}
get prevSibling() {
let { buffer } = this.context;
let parentStart = this._parent ? this._parent.index + 4 : 0;
if (this.index == parentStart)
return this.externalSibling(-1);
return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4));
}
cursor(mode = 0) {
return new TreeCursor(this, mode);
}
get tree() {
return null;
}
toTree() {
let children = [], positions = [];
let { buffer } = this.context;
let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
if (endI > startI) {
let from = buffer.buffer[this.index + 1], to = buffer.buffer[this.index + 2];
children.push(buffer.slice(startI, endI, from, to));
positions.push(0);
}
return new Tree(this.type, children, positions, this.to - this.from);
}
resolve(pos, side = 0) {
return resolveNode(this, pos, side, false);
}
resolveInner(pos, side = 0) {
return resolveNode(this, pos, side, true);
}
enterUnfinishedNodesBefore(pos) {
return enterUnfinishedNodesBefore(this, pos);
}
toString() {
return this.context.buffer.childString(this.index);
}
getChild(type, before = null, after = null) {
let r = getChildren(this, type, before, after);
return r.length ? r[0] : null;
}
getChildren(type, before = null, after = null) {
return getChildren(this, type, before, after);
}
get node() {
return this;
}
matchContext(context) {
return matchNodeContext(this, context);
}
};
var TreeCursor = class {
constructor(node, mode = 0) {
this.mode = mode;
this.buffer = null;
this.stack = [];
this.index = 0;
this.bufferNode = null;
if (node instanceof TreeNode) {
this.yieldNode(node);
} else {
this._tree = node.context.parent;
this.buffer = node.context;
for (let n = node._parent; n; n = n._parent)
this.stack.unshift(n.index);
this.bufferNode = node;
this.yieldBuf(node.index);
}
}
get name() {
return this.type.name;
}
yieldNode(node) {
if (!node)
return false;
this._tree = node;
this.type = node.type;
this.from = node.from;
this.to = node.to;
return true;
}
yieldBuf(index, type) {
this.index = index;
let { start: start2, buffer } = this.buffer;
this.type = type || buffer.set.types[buffer.buffer[index]];
this.from = start2 + buffer.buffer[index + 1];
this.to = start2 + buffer.buffer[index + 2];
return true;
}
yield(node) {
if (!node)
return false;
if (node instanceof TreeNode) {
this.buffer = null;
return this.yieldNode(node);
}
this.buffer = node.context;
return this.yieldBuf(node.index, node.type);
}
toString() {
return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
}
enterChild(dir, pos, side) {
if (!this.buffer)
return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
let { buffer } = this.buffer;
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
if (index < 0)
return false;
this.stack.push(this.index);
return this.yieldBuf(index);
}
firstChild() {
return this.enterChild(1, 0, 4);
}
lastChild() {
return this.enterChild(-1, 0, 4);
}
childAfter(pos) {
return this.enterChild(1, pos, 2);
}
childBefore(pos) {
return this.enterChild(-1, pos, -2);
}
enter(pos, side, mode = this.mode) {
if (!this.buffer)
return this.yield(this._tree.enter(pos, side, mode));
return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
}
parent() {
if (!this.buffer)
return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
if (this.stack.length)
return this.yieldBuf(this.stack.pop());
let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
this.buffer = null;
return this.yieldNode(parent);
}
sibling(dir) {
if (!this.buffer)
return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
let { buffer } = this.buffer, d = this.stack.length - 1;
if (dir < 0) {
let parentStart = d < 0 ? 0 : this.stack[d] + 4;
if (this.index != parentStart)
return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4));
} else {
let after = buffer.buffer[this.index + 3];
if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
return this.yieldBuf(after);
}
return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
}
nextSibling() {
return this.sibling(1);
}
prevSibling() {
return this.sibling(-1);
}
atLastNode(dir) {
let index, parent, { buffer } = this;
if (buffer) {
if (dir > 0) {
if (this.index < buffer.buffer.buffer.length)
return false;
} else {
for (let i = 0; i < this.index; i++)
if (buffer.buffer.buffer[i + 3] < this.index)
return false;
}
({ index, parent } = buffer);
} else {
({ index, _parent: parent } = this._tree);
}
for (; parent; { index, _parent: parent } = parent) {
if (index > -1)
for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
let child = parent._tree.children[i];
if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child))
return false;
}
}
return true;
}
move(dir, enter) {
if (enter && this.enterChild(dir, 0, 4))
return true;
for (; ; ) {
if (this.sibling(dir))
return true;
if (this.atLastNode(dir) || !this.parent())
return false;
}
}
next(enter = true) {
return this.move(1, enter);
}
prev(enter = true) {
return this.move(-1, enter);
}
moveTo(pos, side = 0) {
while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos))
if (!this.parent())
break;
while (this.enterChild(1, pos, side)) {
}
return this;
}
get node() {
if (!this.buffer)
return this._tree;
let cache2 = this.bufferNode, result = null, depth = 0;
if (cache2 && cache2.context == this.buffer) {
scan:
for (let index = this.index, d = this.stack.length; d >= 0; ) {
for (let c = cache2; c; c = c._parent)
if (c.index == index) {
if (index == this.index)
return c;
result = c;
depth = d + 1;
break scan;
}
index = this.stack[--d];
}
}
for (let i = depth; i < this.stack.length; i++)
result = new BufferNode(this.buffer, result, this.stack[i]);
return this.bufferNode = new BufferNode(this.buffer, result, this.index);
}
get tree() {
return this.buffer ? null : this._tree._tree;
}
iterate(enter, leave) {
for (let depth = 0; ; ) {
let mustLeave = false;
if (this.type.isAnonymous || enter(this) !== false) {
if (this.firstChild()) {
depth++;
continue;
}
if (!this.type.isAnonymous)
mustLeave = true;
}
for (; ; ) {
if (mustLeave && leave)
leave(this);
mustLeave = this.type.isAnonymous;
if (this.nextSibling())
break;
if (!depth)
return;
this.parent();
depth--;
mustLeave = true;
}
}
}
matchContext(context) {
if (!this.buffer)
return matchNodeContext(this.node, context);
let { buffer } = this.buffer, { types } = buffer.set;
for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
if (d < 0)
return matchNodeContext(this.node, context, i);
let type = types[buffer.buffer[this.stack[d]]];
if (!type.isAnonymous) {
if (context[i] && context[i] != type.name)
return false;
i--;
}
}
return true;
}
};
function hasChild(tree) {
return tree.children.some((ch) => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
}
function buildTree(data) {
var _a;
let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
let types = nodeSet.types;
let contextHash = 0, lookAhead = 0;
function takeNode(parentStart, minPos, children2, positions2, inRepeat) {
let { id: id2, start: start2, end: end2, size } = cursor;
let lookAheadAtStart = lookAhead;
while (size < 0) {
cursor.next();
if (size == -1) {
let node2 = reused[id2];
children2.push(node2);
positions2.push(start2 - parentStart);
return;
} else if (size == -3) {
contextHash = id2;
return;
} else if (size == -4) {
lookAhead = id2;
return;
} else {
throw new RangeError(`Unrecognized record size: ${size}`);
}
}
let type = types[id2], node, buffer2;
let startPos = start2 - parentStart;
if (end2 - start2 <= maxBufferLength && (buffer2 = findBufferSize(cursor.pos - minPos, inRepeat))) {
let data2 = new Uint16Array(buffer2.size - buffer2.skip);
let endPos = cursor.pos - buffer2.size, index = data2.length;
while (cursor.pos > endPos)
index = copyToBuffer(buffer2.start, data2, index);
node = new TreeBuffer(data2, end2 - buffer2.start, nodeSet);
startPos = buffer2.start - parentStart;
} else {
let endPos = cursor.pos - size;
cursor.next();
let localChildren = [], localPositions = [];
let localInRepeat = id2 >= minRepeatType ? id2 : -1;
let lastGroup = 0, lastEnd = end2;
while (cursor.pos > endPos) {
if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
if (cursor.end <= lastEnd - maxBufferLength) {
makeRepeatLeaf(localChildren, localPositions, start2, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
lastGroup = localChildren.length;
lastEnd = cursor.end;
}
cursor.next();
} else {
takeNode(start2, endPos, localChildren, localPositions, localInRepeat);
}
}
if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
makeRepeatLeaf(localChildren, localPositions, start2, lastGroup, start2, lastEnd, localInRepeat, lookAheadAtStart);
localChildren.reverse();
localPositions.reverse();
if (localInRepeat > -1 && lastGroup > 0) {
let make = makeBalanced(type);
node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end2 - start2, make, make);
} else {
node = makeTree(type, localChildren, localPositions, end2 - start2, lookAheadAtStart - end2);
}
}
children2.push(node);
positions2.push(startPos);
}
function makeBalanced(type) {
return (children2, positions2, length2) => {
let lookAhead2 = 0, lastI = children2.length - 1, last, lookAheadProp;
if (lastI >= 0 && (last = children2[lastI]) instanceof Tree) {
if (!lastI && last.type == type && last.length == length2)
return last;
if (lookAheadProp = last.prop(NodeProp.lookAhead))
lookAhead2 = positions2[lastI] + last.length + lookAheadProp;
}
return makeTree(type, children2, positions2, length2, lookAhead2);
};
}
function makeRepeatLeaf(children2, positions2, base, i, from, to, type, lookAhead2) {
let localChildren = [], localPositions = [];
while (children2.length > i) {
localChildren.push(children2.pop());
localPositions.push(positions2.pop() + base - from);
}
children2.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead2 - to));
positions2.push(from - base);
}
function makeTree(type, children2, positions2, length2, lookAhead2 = 0, props) {
if (contextHash) {
let pair2 = [NodeProp.contextHash, contextHash];
props = props ? [pair2].concat(props) : [pair2];
}
if (lookAhead2 > 25) {
let pair2 = [NodeProp.lookAhead, lookAhead2];
props = props ? [pair2].concat(props) : [pair2];
}
return new Tree(type, children2, positions2, length2, props);
}
function findBufferSize(maxSize, inRepeat) {
let fork = cursor.fork();
let size = 0, start2 = 0, skip = 0, minStart = fork.end - maxBufferLength;
let result = { size: 0, start: 0, skip: 0 };
scan:
for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
let nodeSize2 = fork.size;
if (fork.id == inRepeat && nodeSize2 >= 0) {
result.size = size;
result.start = start2;
result.skip = skip;
skip += 4;
size += 4;
fork.next();
continue;
}
let startPos = fork.pos - nodeSize2;
if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
break;
let localSkipped = fork.id >= minRepeatType ? 4 : 0;
let nodeStart = fork.start;
fork.next();
while (fork.pos > startPos) {
if (fork.size < 0) {
if (fork.size == -3)
localSkipped += 4;
else
break scan;
} else if (fork.id >= minRepeatType) {
localSkipped += 4;
}
fork.next();
}
start2 = nodeStart;
size += nodeSize2;
skip += localSkipped;
}
if (inRepeat < 0 || size == maxSize) {
result.size = size;
result.start = start2;
result.skip = skip;
}
return result.size > 4 ? result : void 0;
}
function copyToBuffer(bufferStart, buffer2, index) {
let { id: id2, start: start2, end: end2, size } = cursor;
cursor.next();
if (size >= 0 && id2 < minRepeatType) {
let startIndex = index;
if (size > 4) {
let endPos = cursor.pos - (size - 4);
while (cursor.pos > endPos)
index = copyToBuffer(bufferStart, buffer2, index);
}
buffer2[--index] = startIndex;
buffer2[--index] = end2 - bufferStart;
buffer2[--index] = start2 - bufferStart;
buffer2[--index] = id2;
} else if (size == -3) {
contextHash = id2;
} else if (size == -4) {
lookAhead = id2;
}
return index;
}
let children = [], positions = [];
while (cursor.pos > 0)
takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
}
var nodeSizeCache = new WeakMap();
function nodeSize(balanceType, node) {
if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
return 1;
let size = nodeSizeCache.get(node);
if (size == null) {
size = 1;
for (let child of node.children) {
if (child.type != balanceType || !(child instanceof Tree)) {
size = 1;
break;
}
size += nodeSize(balanceType, child);
}
nodeSizeCache.set(node, size);
}
return size;
}
function balanceRange(balanceType, children, positions, from, to, start2, length, mkTop, mkTree) {
let total = 0;
for (let i = from; i < to; i++)
total += nodeSize(balanceType, children[i]);
let maxChild = Math.ceil(total * 1.5 / 8);
let localChildren = [], localPositions = [];
function divide(children2, positions2, from2, to2, offset2) {
for (let i = from2; i < to2; ) {
let groupFrom = i, groupStart = positions2[i], groupSize = nodeSize(balanceType, children2[i]);
i++;
for (; i < to2; i++) {
let nextSize = nodeSize(balanceType, children2[i]);
if (groupSize + nextSize >= maxChild)
break;
groupSize += nextSize;
}
if (i == groupFrom + 1) {
if (groupSize > maxChild) {
let only = children2[groupFrom];
divide(only.children, only.positions, 0, only.children.length, positions2[groupFrom] + offset2);
continue;
}
localChildren.push(children2[groupFrom]);
} else {
let length2 = positions2[i - 1] + children2[i - 1].length - groupStart;
localChildren.push(balanceRange(balanceType, children2, positions2, groupFrom, i, groupStart, length2, null, mkTree));
}
localPositions.push(groupStart + offset2 - start2);
}
}
divide(children, positions, from, to, 0);
return (mkTop || mkTree)(localChildren, localPositions, length);
}
var NodeWeakMap = class {
constructor() {
this.map = new WeakMap();
}
setBuffer(buffer, index, value) {
let inner = this.map.get(buffer);
if (!inner)
this.map.set(buffer, inner = new Map());
inner.set(index, value);
}
getBuffer(buffer, index) {
let inner = this.map.get(buffer);
return inner && inner.get(index);
}
set(node, value) {
if (node instanceof BufferNode)
this.setBuffer(node.context.buffer, node.index, value);
else if (node instanceof TreeNode)
this.map.set(node.tree, value);
}
get(node) {
return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index) : node instanceof TreeNode ? this.map.get(node.tree) : void 0;
}
cursorSet(cursor, value) {
if (cursor.buffer)
this.setBuffer(cursor.buffer.buffer, cursor.index, value);
else
this.map.set(cursor.tree, value);
}
cursorGet(cursor) {
return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);
}
};
var Parser = class {
startParse(input, fragments, ranges) {
if (typeof input == "string")
input = new StringInput(input);
ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map((r) => new Range(r.from, r.to)) : [new Range(0, 0)];
return this.createParse(input, fragments || [], ranges);
}
parse(input, fragments, ranges) {
let parse2 = this.startParse(input, fragments, ranges);
for (; ; ) {
let done = parse2.advance();
if (done)
return done;
}
}
};
var StringInput = class {
constructor(string) {
this.string = string;
}
get length() {
return this.string.length;
}
chunk(from) {
return this.string.slice(from);
}
get lineChunks() {
return false;
}
read(from, to) {
return this.string.slice(from, to);
}
};
var stoppedInner = new NodeProp({ perNode: true });
// node_modules/@lezer/lr/dist/index.js
var Stack = class {
constructor(p, stack, state, reducePos, pos, score, buffer, bufferBase, curContext, lookAhead = 0, parent) {
this.p = p;
this.stack = stack;
this.state = state;
this.reducePos = reducePos;
this.pos = pos;
this.score = score;
this.buffer = buffer;
this.bufferBase = bufferBase;
this.curContext = curContext;
this.lookAhead = lookAhead;
this.parent = parent;
}
toString() {
return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
}
static start(p, state, pos = 0) {
let cx = p.parser.context;
return new Stack(p, [], state, pos, pos, 0, [], 0, cx ? new StackContext(cx, cx.start) : null, 0, null);
}
get context() {
return this.curContext ? this.curContext.context : null;
}
pushState(state, start2) {
this.stack.push(this.state, start2, this.bufferBase + this.buffer.length);
this.state = state;
}
reduce(action) {
let depth = action >> 19, type = action & 65535;
let { parser: parser2 } = this.p;
let dPrec = parser2.dynamicPrecedence(type);
if (dPrec)
this.score += dPrec;
if (depth == 0) {
this.pushState(parser2.getGoto(this.state, type, true), this.reducePos);
if (type < parser2.minRepeatTerm)
this.storeNode(type, this.reducePos, this.reducePos, 4, true);
this.reduceContext(type, this.reducePos);
return;
}
let base = this.stack.length - (depth - 1) * 3 - (action & 262144 ? 6 : 0);
let start2 = this.stack[base - 2];
let bufferBase = this.stack[base - 1], count = this.bufferBase + this.buffer.length - bufferBase;
if (type < parser2.minRepeatTerm || action & 131072) {
let pos = parser2.stateFlag(this.state, 1) ? this.pos : this.reducePos;
this.storeNode(type, start2, pos, count + 4, true);
}
if (action & 262144) {
this.state = this.stack[base];
} else {
let baseStateID = this.stack[base - 3];
this.state = parser2.getGoto(baseStateID, type, true);
}
while (this.stack.length > base)
this.stack.pop();
this.reduceContext(type, start2);
}
storeNode(term, start2, end2, size = 4, isReduce = false) {
if (term == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
let cur = this, top2 = this.buffer.length;
if (top2 == 0 && cur.parent) {
top2 = cur.bufferBase - cur.parent.bufferBase;
cur = cur.parent;
}
if (top2 > 0 && cur.buffer[top2 - 4] == 0 && cur.buffer[top2 - 1] > -1) {
if (start2 == end2)
return;
if (cur.buffer[top2 - 2] >= start2) {
cur.buffer[top2 - 2] = end2;
return;
}
}
}
if (!isReduce || this.pos == end2) {
this.buffer.push(term, start2, end2, size);
} else {
let index = this.buffer.length;
if (index > 0 && this.buffer[index - 4] != 0)
while (index > 0 && this.buffer[index - 2] > end2) {
this.buffer[index] = this.buffer[index - 4];
this.buffer[index + 1] = this.buffer[index - 3];
this.buffer[index + 2] = this.buffer[index - 2];
this.buffer[index + 3] = this.buffer[index - 1];
index -= 4;
if (size > 4)
size -= 4;
}
this.buffer[index] = term;
this.buffer[index + 1] = start2;
this.buffer[index + 2] = end2;
this.buffer[index + 3] = size;
}
}
shift(action, next, nextEnd) {
let start2 = this.pos;
if (action & 131072) {
this.pushState(action & 65535, this.pos);
} else if ((action & 262144) == 0) {
let nextState = action, { parser: parser2 } = this.p;
if (nextEnd > this.pos || next <= parser2.maxNode) {
this.pos = nextEnd;
if (!parser2.stateFlag(nextState, 1))
this.reducePos = nextEnd;
}
this.pushState(nextState, start2);
this.shiftContext(next, start2);
if (next <= parser2.maxNode)
this.buffer.push(next, start2, nextEnd, 4);
} else {
this.pos = nextEnd;
this.shiftContext(next, start2);
if (next <= this.p.parser.maxNode)
this.buffer.push(next, start2, nextEnd, 4);
}
}
apply(action, next, nextEnd) {
if (action & 65536)
this.reduce(action);
else
this.shift(action, next, nextEnd);
}
useNode(value, next) {
let index = this.p.reused.length - 1;
if (index < 0 || this.p.reused[index] != value) {
this.p.reused.push(value);
index++;
}
let start2 = this.pos;
this.reducePos = this.pos = start2 + value.length;
this.pushState(next, start2);
this.buffer.push(index, start2, this.reducePos, -1);
if (this.curContext)
this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
}
split() {
let parent = this;
let off = parent.buffer.length;
while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
off -= 4;
let buffer = parent.buffer.slice(off), base = parent.bufferBase + off;
while (parent && base == parent.bufferBase)
parent = parent.parent;
return new Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
}
recoverByDelete(next, nextEnd) {
let isNode = next <= this.p.parser.maxNode;
if (isNode)
this.storeNode(next, this.pos, nextEnd, 4);
this.storeNode(0, this.pos, nextEnd, isNode ? 8 : 4);
this.pos = this.reducePos = nextEnd;
this.score -= 190;
}
canShift(term) {
for (let sim = new SimulatedStack(this); ; ) {
let action = this.p.parser.stateSlot(sim.state, 4) || this.p.parser.hasAction(sim.state, term);
if ((action & 65536) == 0)
return true;
if (action == 0)
return false;
sim.reduce(action);
}
}
recoverByInsert(next) {
if (this.stack.length >= 300)
return [];
let nextStates = this.p.parser.nextStates(this.state);
if (nextStates.length > 4 << 1 || this.stack.length >= 120) {
let best = [];
for (let i = 0, s; i < nextStates.length; i += 2) {
if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
best.push(nextStates[i], s);
}
if (this.stack.length < 120)
for (let i = 0; best.length < 4 << 1 && i < nextStates.length; i += 2) {
let s = nextStates[i + 1];
if (!best.some((v, i2) => i2 & 1 && v == s))
best.push(nextStates[i], s);
}
nextStates = best;
}
let result = [];
for (let i = 0; i < nextStates.length && result.length < 4; i += 2) {
let s = nextStates[i + 1];
if (s == this.state)
continue;
let stack = this.split();
stack.pushState(s, this.pos);
stack.storeNode(0, stack.pos, stack.pos, 4, true);
stack.shiftContext(nextStates[i], this.pos);
stack.score -= 200;
result.push(stack);
}
return result;
}
forceReduce() {
let reduce = this.p.parser.stateSlot(this.state, 5);
if ((reduce & 65536) == 0)
return false;
let { parser: parser2 } = this.p;
if (!parser2.validAction(this.state, reduce)) {
let depth = reduce >> 19, term = reduce & 65535;
let target = this.stack.length - depth * 3;
if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0)
return false;
this.storeNode(0, this.reducePos, this.reducePos, 4, true);
this.score -= 100;
}
this.reducePos = this.pos;
this.reduce(reduce);
return true;
}
forceAll() {
while (!this.p.parser.stateFlag(this.state, 2)) {
if (!this.forceReduce()) {
this.storeNode(0, this.pos, this.pos, 4, true);
break;
}
}
return this;
}
get deadEnd() {
if (this.stack.length != 3)
return false;
let { parser: parser2 } = this.p;
return parser2.data[parser2.stateSlot(this.state, 1)] == 65535 && !parser2.stateSlot(this.state, 4);
}
restart() {
this.state = this.stack[0];
this.stack.length = 0;
}
sameState(other) {
if (this.state != other.state || this.stack.length != other.stack.length)
return false;
for (let i = 0; i < this.stack.length; i += 3)
if (this.stack[i] != other.stack[i])
return false;
return true;
}
get parser() {
return this.p.parser;
}
dialectEnabled(dialectID) {
return this.p.parser.dialect.flags[dialectID];
}
shiftContext(term, start2) {
if (this.curContext)
this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start2)));
}
reduceContext(term, start2) {
if (this.curContext)
this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start2)));
}
emitContext() {
let last = this.buffer.length - 1;
if (last < 0 || this.buffer[last] != -3)
this.buffer.push(this.curContext.hash, this.reducePos, this.reducePos, -3);
}
emitLookAhead() {
let last = this.buffer.length - 1;
if (last < 0 || this.buffer[last] != -4)
this.buffer.push(this.lookAhead, this.reducePos, this.reducePos, -4);
}
updateContext(context) {
if (context != this.curContext.context) {
let newCx = new StackContext(this.curContext.tracker, context);
if (newCx.hash != this.curContext.hash)
this.emitContext();
this.curContext = newCx;
}
}
setLookAhead(lookAhead) {
if (lookAhead > this.lookAhead) {
this.emitLookAhead();
this.lookAhead = lookAhead;
}
}
close() {
if (this.curContext && this.curContext.tracker.strict)
this.emitContext();
if (this.lookAhead > 0)
this.emitLookAhead();
}
};
var StackContext = class {
constructor(tracker, context) {
this.tracker = tracker;
this.context = context;
this.hash = tracker.strict ? tracker.hash(context) : 0;
}
};
var Recover;
(function(Recover2) {
Recover2[Recover2["Insert"] = 200] = "Insert";
Recover2[Recover2["Delete"] = 190] = "Delete";
Recover2[Recover2["Reduce"] = 100] = "Reduce";
Recover2[Recover2["MaxNext"] = 4] = "MaxNext";
Recover2[Recover2["MaxInsertStackDepth"] = 300] = "MaxInsertStackDepth";
Recover2[Recover2["DampenInsertStackDepth"] = 120] = "DampenInsertStackDepth";
})(Recover || (Recover = {}));
var SimulatedStack = class {
constructor(start2) {
this.start = start2;
this.state = start2.state;
this.stack = start2.stack;
this.base = this.stack.length;
}
reduce(action) {
let term = action & 65535, depth = action >> 19;
if (depth == 0) {
if (this.stack == this.start.stack)
this.stack = this.stack.slice();
this.stack.push(this.state, 0, 0);
this.base += 3;
} else {
this.base -= (depth - 1) * 3;
}
let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
this.state = goto;
}
};
var StackBufferCursor = class {
constructor(stack, pos, index) {
this.stack = stack;
this.pos = pos;
this.index = index;
this.buffer = stack.buffer;
if (this.index == 0)
this.maybeNext();
}
static create(stack, pos = stack.bufferBase + stack.buffer.length) {
return new StackBufferCursor(stack, pos, pos - stack.bufferBase);
}
maybeNext() {
let next = this.stack.parent;
if (next != null) {
this.index = this.stack.bufferBase - next.bufferBase;
this.stack = next;
this.buffer = next.buffer;
}
}
get id() {
return this.buffer[this.index - 4];
}
get start() {
return this.buffer[this.index - 3];
}
get end() {
return this.buffer[this.index - 2];
}
get size() {
return this.buffer[this.index - 1];
}
next() {
this.index -= 4;
this.pos -= 4;
if (this.index == 0)
this.maybeNext();
}
fork() {
return new StackBufferCursor(this.stack, this.pos, this.index);
}
};
var CachedToken = class {
constructor() {
this.start = -1;
this.value = -1;
this.end = -1;
this.extended = -1;
this.lookAhead = 0;
this.mask = 0;
this.context = 0;
}
};
var nullToken = new CachedToken();
var InputStream = class {
constructor(input, ranges) {
this.input = input;
this.ranges = ranges;
this.chunk = "";
this.chunkOff = 0;
this.chunk2 = "";
this.chunk2Pos = 0;
this.next = -1;
this.token = nullToken;
this.rangeIndex = 0;
this.pos = this.chunkPos = ranges[0].from;
this.range = ranges[0];
this.end = ranges[ranges.length - 1].to;
this.readNext();
}
resolveOffset(offset2, assoc) {
let range = this.range, index = this.rangeIndex;
let pos = this.pos + offset2;
while (pos < range.from) {
if (!index)
return null;
let next = this.ranges[--index];
pos -= range.from - next.to;
range = next;
}
while (assoc < 0 ? pos > range.to : pos >= range.to) {
if (index == this.ranges.length - 1)
return null;
let next = this.ranges[++index];
pos += next.from - range.to;
range = next;
}
return pos;
}
peek(offset2) {
let idx = this.chunkOff + offset2, pos, result;
if (idx >= 0 && idx < this.chunk.length) {
pos = this.pos + offset2;
result = this.chunk.charCodeAt(idx);
} else {
let resolved = this.resolveOffset(offset2, 1);
if (resolved == null)
return -1;
pos = resolved;
if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
} else {
let i = this.rangeIndex, range = this.range;
while (range.to <= pos)
range = this.ranges[++i];
this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
if (pos + this.chunk2.length > range.to)
this.chunk2 = this.chunk2.slice(0, range.to - pos);
result = this.chunk2.charCodeAt(0);
}
}
if (pos >= this.token.lookAhead)
this.token.lookAhead = pos + 1;
return result;
}
acceptToken(token, endOffset = 0) {
let end2 = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
if (end2 == null || end2 < this.token.start)
throw new RangeError("Token end out of bounds");
this.token.value = token;
this.token.end = end2;
}
getChunk() {
if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
let { chunk, chunkPos } = this;
this.chunk = this.chunk2;
this.chunkPos = this.chunk2Pos;
this.chunk2 = chunk;
this.chunk2Pos = chunkPos;
this.chunkOff = this.pos - this.chunkPos;
} else {
this.chunk2 = this.chunk;
this.chunk2Pos = this.chunkPos;
let nextChunk = this.input.chunk(this.pos);
let end2 = this.pos + nextChunk.length;
this.chunk = end2 > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
this.chunkPos = this.pos;
this.chunkOff = 0;
}
}
readNext() {
if (this.chunkOff >= this.chunk.length) {
this.getChunk();
if (this.chunkOff == this.chunk.length)
return this.next = -1;
}
return this.next = this.chunk.charCodeAt(this.chunkOff);
}
advance(n = 1) {
this.chunkOff += n;
while (this.pos + n >= this.range.to) {
if (this.rangeIndex == this.ranges.length - 1)
return this.setDone();
n -= this.range.to - this.pos;
this.range = this.ranges[++this.rangeIndex];
this.pos = this.range.from;
}
this.pos += n;
if (this.pos >= this.token.lookAhead)
this.token.lookAhead = this.pos + 1;
return this.readNext();
}
setDone() {
this.pos = this.chunkPos = this.end;
this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
this.chunk = "";
return this.next = -1;
}
reset(pos, token) {
if (token) {
this.token = token;
token.start = pos;
token.lookAhead = pos + 1;
token.value = token.extended = -1;
} else {
this.token = nullToken;
}
if (this.pos != pos) {
this.pos = pos;
if (pos == this.end) {
this.setDone();
return this;
}
while (pos < this.range.from)
this.range = this.ranges[--this.rangeIndex];
while (pos >= this.range.to)
this.range = this.ranges[++this.rangeIndex];
if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
this.chunkOff = pos - this.chunkPos;
} else {
this.chunk = "";
this.chunkOff = 0;
}
this.readNext();
}
return this;
}
read(from, to) {
if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
if (from >= this.range.from && to <= this.range.to)
return this.input.read(from, to);
let result = "";
for (let r of this.ranges) {
if (r.from >= to)
break;
if (r.to > from)
result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
}
return result;
}
};
var TokenGroup = class {
constructor(data, id2) {
this.data = data;
this.id = id2;
}
token(input, stack) {
readToken(this.data, input, stack, this.id);
}
};
TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
var ExternalTokenizer = class {
constructor(token, options = {}) {
this.token = token;
this.contextual = !!options.contextual;
this.fallback = !!options.fallback;
this.extend = !!options.extend;
}
};
function readToken(data, input, stack, group) {
let state = 0, groupMask = 1 << group, { parser: parser2 } = stack.p, { dialect } = parser2;
scan:
for (; ; ) {
if ((groupMask & data[state]) == 0)
break;
let accEnd = data[state + 1];
for (let i = state + 3; i < accEnd; i += 2)
if ((data[i + 1] & groupMask) > 0) {
let term = data[i];
if (dialect.allows(term) && (input.token.value == -1 || input.token.value == term || parser2.overrides(term, input.token.value))) {
input.acceptToken(term);
break;
}
}
let next = input.next, low = 0, high = data[state + 2];
if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535) {
state = data[accEnd + high * 3 - 1];
continue scan;
}
for (; low < high; ) {
let mid = low + high >> 1;
let index = accEnd + mid + (mid << 1);
let from = data[index], to = data[index + 1];
if (next < from)
high = mid;
else if (next >= to)
low = mid + 1;
else {
state = data[index + 2];
input.advance();
continue scan;
}
}
break;
}
}
function decodeArray(input, Type = Uint16Array) {
if (typeof input != "string")
return input;
let array = null;
for (let pos = 0, out = 0; pos < input.length; ) {
let value = 0;
for (; ; ) {
let next = input.charCodeAt(pos++), stop = false;
if (next == 126) {
value = 65535;
break;
}
if (next >= 92)
next--;
if (next >= 34)
next--;
let digit = next - 32;
if (digit >= 46) {
digit -= 46;
stop = true;
}
value += digit;
if (stop)
break;
value *= 46;
}
if (array)
array[out++] = value;
else
array = new Type(value);
}
return array;
}
var verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
var stackIDs = null;
var Safety;
(function(Safety2) {
Safety2[Safety2["Margin"] = 25] = "Margin";
})(Safety || (Safety = {}));
function cutAt(tree, pos, side) {
let cursor = tree.cursor(IterMode.IncludeAnonymous);
cursor.moveTo(pos);
for (; ; ) {
if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
for (; ; ) {
if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
return side < 0 ? Math.max(0, Math.min(cursor.to - 1, pos - 25)) : Math.min(tree.length, Math.max(cursor.from + 1, pos + 25));
if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
break;
if (!cursor.parent())
return side < 0 ? 0 : tree.length;
}
}
}
var FragmentCursor = class {
constructor(fragments, nodeSet) {
this.fragments = fragments;
this.nodeSet = nodeSet;
this.i = 0;
this.fragment = null;
this.safeFrom = -1;
this.safeTo = -1;
this.trees = [];
this.start = [];
this.index = [];
this.nextFragment();
}
nextFragment() {
let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
if (fr) {
this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
while (this.trees.length) {
this.trees.pop();
this.start.pop();
this.index.pop();
}
this.trees.push(fr.tree);
this.start.push(-fr.offset);
this.index.push(0);
this.nextStart = this.safeFrom;
} else {
this.nextStart = 1e9;
}
}
nodeAt(pos) {
if (pos < this.nextStart)
return null;
while (this.fragment && this.safeTo <= pos)
this.nextFragment();
if (!this.fragment)
return null;
for (; ; ) {
let last = this.trees.length - 1;
if (last < 0) {
this.nextFragment();
return null;
}
let top2 = this.trees[last], index = this.index[last];
if (index == top2.children.length) {
this.trees.pop();
this.start.pop();
this.index.pop();
continue;
}
let next = top2.children[index];
let start2 = this.start[last] + top2.positions[index];
if (start2 > pos) {
this.nextStart = start2;
return null;
}
if (next instanceof Tree) {
if (start2 == pos) {
if (start2 < this.safeFrom)
return null;
let end2 = start2 + next.length;
if (end2 <= this.safeTo) {
let lookAhead = next.prop(NodeProp.lookAhead);
if (!lookAhead || end2 + lookAhead < this.fragment.to)
return next;
}
}
this.index[last]++;
if (start2 + next.length >= Math.max(this.safeFrom, pos)) {
this.trees.push(next);
this.start.push(start2);
this.index.push(0);
}
} else {
this.index[last]++;
this.nextStart = start2 + next.length;
}
}
}
};
var TokenCache = class {
constructor(parser2, stream) {
this.stream = stream;
this.tokens = [];
this.mainToken = null;
this.actions = [];
this.tokens = parser2.tokenizers.map((_) => new CachedToken());
}
getActions(stack) {
let actionIndex = 0;
let main2 = null;
let { parser: parser2 } = stack.p, { tokenizers } = parser2;
let mask = parser2.stateSlot(stack.state, 3);
let context = stack.curContext ? stack.curContext.hash : 0;
let lookAhead = 0;
for (let i = 0; i < tokenizers.length; i++) {
if ((1 << i & mask) == 0)
continue;
let tokenizer = tokenizers[i], token = this.tokens[i];
if (main2 && !tokenizer.fallback)
continue;
if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
this.updateCachedToken(token, tokenizer, stack);
token.mask = mask;
token.context = context;
}
if (token.lookAhead > token.end + 25)
lookAhead = Math.max(token.lookAhead, lookAhead);
if (token.value != 0) {
let startIndex = actionIndex;
if (token.extended > -1)
actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
if (!tokenizer.extend) {
main2 = token;
if (actionIndex > startIndex)
break;
}
}
}
while (this.actions.length > actionIndex)
this.actions.pop();
if (lookAhead)
stack.setLookAhead(lookAhead);
if (!main2 && stack.pos == this.stream.end) {
main2 = new CachedToken();
main2.value = stack.p.parser.eofTerm;
main2.start = main2.end = stack.pos;
actionIndex = this.addActions(stack, main2.value, main2.end, actionIndex);
}
this.mainToken = main2;
return this.actions;
}
getMainToken(stack) {
if (this.mainToken)
return this.mainToken;
let main2 = new CachedToken(), { pos, p } = stack;
main2.start = pos;
main2.end = Math.min(pos + 1, p.stream.end);
main2.value = pos == p.stream.end ? p.parser.eofTerm : 0;
return main2;
}
updateCachedToken(token, tokenizer, stack) {
tokenizer.token(this.stream.reset(stack.pos, token), stack);
if (token.value > -1) {
let { parser: parser2 } = stack.p;
for (let i = 0; i < parser2.specialized.length; i++)
if (parser2.specialized[i] == token.value) {
let result = parser2.specializers[i](this.stream.read(token.start, token.end), stack);
if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
if ((result & 1) == 0)
token.value = result >> 1;
else
token.extended = result >> 1;
break;
}
}
} else {
token.value = 0;
token.end = Math.min(stack.p.stream.end, stack.pos + 1);
}
}
putAction(action, token, end2, index) {
for (let i = 0; i < index; i += 3)
if (this.actions[i] == action)
return index;
this.actions[index++] = action;
this.actions[index++] = token;
this.actions[index++] = end2;
return index;
}
addActions(stack, token, end2, index) {
let { state } = stack, { parser: parser2 } = stack.p, { data } = parser2;
for (let set = 0; set < 2; set++) {
for (let i = parser2.stateSlot(state, set ? 2 : 1); ; i += 3) {
if (data[i] == 65535) {
if (data[i + 1] == 1) {
i = pair(data, i + 2);
} else {
if (index == 0 && data[i + 1] == 2)
index = this.putAction(pair(data, i + 2), token, end2, index);
break;
}
}
if (data[i] == token)
index = this.putAction(pair(data, i + 1), token, end2, index);
}
}
return index;
}
};
var Rec;
(function(Rec2) {
Rec2[Rec2["Distance"] = 5] = "Distance";
Rec2[Rec2["MaxRemainingPerStep"] = 3] = "MaxRemainingPerStep";
Rec2[Rec2["MinBufferLengthPrune"] = 500] = "MinBufferLengthPrune";
Rec2[Rec2["ForceReduceLimit"] = 10] = "ForceReduceLimit";
Rec2[Rec2["CutDepth"] = 15e3] = "CutDepth";
Rec2[Rec2["CutTo"] = 9e3] = "CutTo";
})(Rec || (Rec = {}));
var Parse = class {
constructor(parser2, input, fragments, ranges) {
this.parser = parser2;
this.input = input;
this.ranges = ranges;
this.recovering = 0;
this.nextStackID = 9812;
this.minStackPos = 0;
this.reused = [];
this.stoppedAt = null;
this.stream = new InputStream(input, ranges);
this.tokens = new TokenCache(parser2, this.stream);
this.topTerm = parser2.top[1];
let { from } = ranges[0];
this.stacks = [Stack.start(this, parser2.top[0], from)];
this.fragments = fragments.length && this.stream.end - from > parser2.bufferLength * 4 ? new FragmentCursor(fragments, parser2.nodeSet) : null;
}
get parsedPos() {
return this.minStackPos;
}
advance() {
let stacks = this.stacks, pos = this.minStackPos;
let newStacks = this.stacks = [];
let stopped, stoppedTokens;
for (let i = 0; i < stacks.length; i++) {
let stack = stacks[i];
for (; ; ) {
this.tokens.mainToken = null;
if (stack.pos > pos) {
newStacks.push(stack);
} else if (this.advanceStack(stack, newStacks, stacks)) {
continue;
} else {
if (!stopped) {
stopped = [];
stoppedTokens = [];
}
stopped.push(stack);
let tok = this.tokens.getMainToken(stack);
stoppedTokens.push(tok.value, tok.end);
}
break;
}
}
if (!newStacks.length) {
let finished = stopped && findFinished(stopped);
if (finished)
return this.stackToTree(finished);
if (this.parser.strict) {
if (verbose && stopped)
console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
throw new SyntaxError("No parse at " + pos);
}
if (!this.recovering)
this.recovering = 5;
}
if (this.recovering && stopped) {
let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0] : this.runRecovery(stopped, stoppedTokens, newStacks);
if (finished)
return this.stackToTree(finished.forceAll());
}
if (this.recovering) {
let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3;
if (newStacks.length > maxRemaining) {
newStacks.sort((a, b) => b.score - a.score);
while (newStacks.length > maxRemaining)
newStacks.pop();
}
if (newStacks.some((s) => s.reducePos > pos))
this.recovering--;
} else if (newStacks.length > 1) {
outer:
for (let i = 0; i < newStacks.length - 1; i++) {
let stack = newStacks[i];
for (let j = i + 1; j < newStacks.length; j++) {
let other = newStacks[j];
if (stack.sameState(other) || stack.buffer.length > 500 && other.buffer.length > 500) {
if ((stack.score - other.score || stack.buffer.length - other.buffer.length) > 0) {
newStacks.splice(j--, 1);
} else {
newStacks.splice(i--, 1);
continue outer;
}
}
}
}
}
this.minStackPos = newStacks[0].pos;
for (let i = 1; i < newStacks.length; i++)
if (newStacks[i].pos < this.minStackPos)
this.minStackPos = newStacks[i].pos;
return null;
}
stopAt(pos) {
if (this.stoppedAt != null && this.stoppedAt < pos)
throw new RangeError("Can't move stoppedAt forward");
this.stoppedAt = pos;
}
advanceStack(stack, stacks, split) {
let start2 = stack.pos, { parser: parser2 } = this;
let base = verbose ? this.stackID(stack) + " -> " : "";
if (this.stoppedAt != null && start2 > this.stoppedAt)
return stack.forceReduce() ? stack : null;
if (this.fragments) {
let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
for (let cached = this.fragments.nodeAt(start2); cached; ) {
let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser2.getGoto(stack.state, cached.type.id) : -1;
if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp.contextHash) || 0) == cxHash)) {
stack.useNode(cached, match);
if (verbose)
console.log(base + this.stackID(stack) + ` (via reuse of ${parser2.getName(cached.type.id)})`);
return true;
}
if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
break;
let inner = cached.children[0];
if (inner instanceof Tree && cached.positions[0] == 0)
cached = inner;
else
break;
}
}
let defaultReduce = parser2.stateSlot(stack.state, 4);
if (defaultReduce > 0) {
stack.reduce(defaultReduce);
if (verbose)
console.log(base + this.stackID(stack) + ` (via always-reduce ${parser2.getName(defaultReduce & 65535)})`);
return true;
}
if (stack.stack.length >= 15e3) {
while (stack.stack.length > 9e3 && stack.forceReduce()) {
}
}
let actions = this.tokens.getActions(stack);
for (let i = 0; i < actions.length; ) {
let action = actions[i++], term = actions[i++], end2 = actions[i++];
let last = i == actions.length || !split;
let localStack = last ? stack : stack.split();
localStack.apply(action, term, end2);
if (verbose)
console.log(base + this.stackID(localStack) + ` (via ${(action & 65536) == 0 ? "shift" : `reduce of ${parser2.getName(action & 65535)}`} for ${parser2.getName(term)} @ ${start2}${localStack == stack ? "" : ", split"})`);
if (last)
return true;
else if (localStack.pos > start2)
stacks.push(localStack);
else
split.push(localStack);
}
return false;
}
advanceFully(stack, newStacks) {
let pos = stack.pos;
for (; ; ) {
if (!this.advanceStack(stack, null, null))
return false;
if (stack.pos > pos) {
pushStackDedup(stack, newStacks);
return true;
}
}
}
runRecovery(stacks, tokens, newStacks) {
let finished = null, restarted = false;
for (let i = 0; i < stacks.length; i++) {
let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
let base = verbose ? this.stackID(stack) + " -> " : "";
if (stack.deadEnd) {
if (restarted)
continue;
restarted = true;
stack.restart();
if (verbose)
console.log(base + this.stackID(stack) + " (restarted)");
let done = this.advanceFully(stack, newStacks);
if (done)
continue;
}
let force = stack.split(), forceBase = base;
for (let j = 0; force.forceReduce() && j < 10; j++) {
if (verbose)
console.log(forceBase + this.stackID(force) + " (via force-reduce)");
let done = this.advanceFully(force, newStacks);
if (done)
break;
if (verbose)
forceBase = this.stackID(force) + " -> ";
}
for (let insert of stack.recoverByInsert(token)) {
if (verbose)
console.log(base + this.stackID(insert) + " (via recover-insert)");
this.advanceFully(insert, newStacks);
}
if (this.stream.end > stack.pos) {
if (tokenEnd == stack.pos) {
tokenEnd++;
token = 0;
}
stack.recoverByDelete(token, tokenEnd);
if (verbose)
console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
pushStackDedup(stack, newStacks);
} else if (!finished || finished.score < stack.score) {
finished = stack;
}
}
return finished;
}
stackToTree(stack) {
stack.close();
return Tree.build({
buffer: StackBufferCursor.create(stack),
nodeSet: this.parser.nodeSet,
topID: this.topTerm,
maxBufferLength: this.parser.bufferLength,
reused: this.reused,
start: this.ranges[0].from,
length: stack.pos - this.ranges[0].from,
minRepeatType: this.parser.minRepeatTerm
});
}
stackID(stack) {
let id2 = (stackIDs || (stackIDs = new WeakMap())).get(stack);
if (!id2)
stackIDs.set(stack, id2 = String.fromCodePoint(this.nextStackID++));
return id2 + stack;
}
};
function pushStackDedup(stack, newStacks) {
for (let i = 0; i < newStacks.length; i++) {
let other = newStacks[i];
if (other.pos == stack.pos && other.sameState(stack)) {
if (newStacks[i].score < stack.score)
newStacks[i] = stack;
return;
}
}
newStacks.push(stack);
}
var Dialect = class {
constructor(source, flags, disabled) {
this.source = source;
this.flags = flags;
this.disabled = disabled;
}
allows(term) {
return !this.disabled || this.disabled[term] == 0;
}
};
var id = (x) => x;
var ContextTracker = class {
constructor(spec) {
this.start = spec.start;
this.shift = spec.shift || id;
this.reduce = spec.reduce || id;
this.reuse = spec.reuse || id;
this.hash = spec.hash || (() => 0);
this.strict = spec.strict !== false;
}
};
var LRParser = class extends Parser {
constructor(spec) {
super();
this.wrappers = [];
if (spec.version != 14)
throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14})`);
let nodeNames = spec.nodeNames.split(" ");
this.minRepeatTerm = nodeNames.length;
for (let i = 0; i < spec.repeatNodeCount; i++)
nodeNames.push("");
let topTerms = Object.keys(spec.topRules).map((r) => spec.topRules[r][1]);
let nodeProps = [];
for (let i = 0; i < nodeNames.length; i++)
nodeProps.push([]);
function setProp(nodeID, prop, value) {
nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
}
if (spec.nodeProps)
for (let propSpec of spec.nodeProps) {
let prop = propSpec[0];
if (typeof prop == "string")
prop = NodeProp[prop];
for (let i = 1; i < propSpec.length; ) {
let next = propSpec[i++];
if (next >= 0) {
setProp(next, prop, propSpec[i++]);
} else {
let value = propSpec[i + -next];
for (let j = -next; j > 0; j--)
setProp(propSpec[i++], prop, value);
i++;
}
}
}
this.nodeSet = new NodeSet(nodeNames.map((name, i) => NodeType.define({
name: i >= this.minRepeatTerm ? void 0 : name,
id: i,
props: nodeProps[i],
top: topTerms.indexOf(i) > -1,
error: i == 0,
skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
})));
if (spec.propSources)
this.nodeSet = this.nodeSet.extend(...spec.propSources);
this.strict = false;
this.bufferLength = DefaultBufferLength;
let tokenArray = decodeArray(spec.tokenData);
this.context = spec.context;
this.specializerSpecs = spec.specialized || [];
this.specialized = new Uint16Array(this.specializerSpecs.length);
for (let i = 0; i < this.specializerSpecs.length; i++)
this.specialized[i] = this.specializerSpecs[i].term;
this.specializers = this.specializerSpecs.map(getSpecializer);
this.states = decodeArray(spec.states, Uint32Array);
this.data = decodeArray(spec.stateData);
this.goto = decodeArray(spec.goto);
this.maxTerm = spec.maxTerm;
this.tokenizers = spec.tokenizers.map((value) => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
this.topRules = spec.topRules;
this.dialects = spec.dialects || {};
this.dynamicPrecedences = spec.dynamicPrecedences || null;
this.tokenPrecTable = spec.tokenPrec;
this.termNames = spec.termNames || null;
this.maxNode = this.nodeSet.types.length - 1;
this.dialect = this.parseDialect();
this.top = this.topRules[Object.keys(this.topRules)[0]];
}
createParse(input, fragments, ranges) {
let parse2 = new Parse(this, input, fragments, ranges);
for (let w of this.wrappers)
parse2 = w(parse2, input, fragments, ranges);
return parse2;
}
getGoto(state, term, loose = false) {
let table = this.goto;
if (term >= table[0])
return -1;
for (let pos = table[term + 1]; ; ) {
let groupTag = table[pos++], last = groupTag & 1;
let target = table[pos++];
if (last && loose)
return target;
for (let end2 = pos + (groupTag >> 1); pos < end2; pos++)
if (table[pos] == state)
return target;
if (last)
return -1;
}
}
hasAction(state, terminal) {
let data = this.data;
for (let set = 0; set < 2; set++) {
for (let i = this.stateSlot(state, set ? 2 : 1), next; ; i += 3) {
if ((next = data[i]) == 65535) {
if (data[i + 1] == 1)
next = data[i = pair(data, i + 2)];
else if (data[i + 1] == 2)
return pair(data, i + 2);
else
break;
}
if (next == terminal || next == 0)
return pair(data, i + 1);
}
}
return 0;
}
stateSlot(state, slot) {
return this.states[state * 6 + slot];
}
stateFlag(state, flag) {
return (this.stateSlot(state, 0) & flag) > 0;
}
validAction(state, action) {
if (action == this.stateSlot(state, 4))
return true;
for (let i = this.stateSlot(state, 1); ; i += 3) {
if (this.data[i] == 65535) {
if (this.data[i + 1] == 1)
i = pair(this.data, i + 2);
else
return false;
}
if (action == pair(this.data, i + 1))
return true;
}
}
nextStates(state) {
let result = [];
for (let i = this.stateSlot(state, 1); ; i += 3) {
if (this.data[i] == 65535) {
if (this.data[i + 1] == 1)
i = pair(this.data, i + 2);
else
break;
}
if ((this.data[i + 2] & 65536 >> 16) == 0) {
let value = this.data[i + 1];
if (!result.some((v, i2) => i2 & 1 && v == value))
result.push(this.data[i], value);
}
}
return result;
}
overrides(token, prev) {
let iPrev = findOffset(this.data, this.tokenPrecTable, prev);
return iPrev < 0 || findOffset(this.data, this.tokenPrecTable, token) < iPrev;
}
configure(config2) {
let copy = Object.assign(Object.create(LRParser.prototype), this);
if (config2.props)
copy.nodeSet = this.nodeSet.extend(...config2.props);
if (config2.top) {
let info = this.topRules[config2.top];
if (!info)
throw new RangeError(`Invalid top rule name ${config2.top}`);
copy.top = info;
}
if (config2.tokenizers)
copy.tokenizers = this.tokenizers.map((t2) => {
let found = config2.tokenizers.find((r) => r.from == t2);
return found ? found.to : t2;
});
if (config2.specializers) {
copy.specializers = this.specializers.slice();
copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
let found = config2.specializers.find((r) => r.from == s.external);
if (!found)
return s;
let spec = Object.assign(Object.assign({}, s), { external: found.to });
copy.specializers[i] = getSpecializer(spec);
return spec;
});
}
if (config2.contextTracker)
copy.context = config2.contextTracker;
if (config2.dialect)
copy.dialect = this.parseDialect(config2.dialect);
if (config2.strict != null)
copy.strict = config2.strict;
if (config2.wrap)
copy.wrappers = copy.wrappers.concat(config2.wrap);
if (config2.bufferLength != null)
copy.bufferLength = config2.bufferLength;
return copy;
}
hasWrappers() {
return this.wrappers.length > 0;
}
getName(term) {
return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
}
get eofTerm() {
return this.maxNode + 1;
}
get topNode() {
return this.nodeSet.types[this.top[1]];
}
dynamicPrecedence(term) {
let prec = this.dynamicPrecedences;
return prec == null ? 0 : prec[term] || 0;
}
parseDialect(dialect) {
let values = Object.keys(this.dialects), flags = values.map(() => false);
if (dialect)
for (let part of dialect.split(" ")) {
let id2 = values.indexOf(part);
if (id2 >= 0)
flags[id2] = true;
}
let disabled = null;
for (let i = 0; i < values.length; i++)
if (!flags[i]) {
for (let j = this.dialects[values[i]], id2; (id2 = this.data[j++]) != 65535; )
(disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id2] = 1;
}
return new Dialect(dialect, flags, disabled);
}
static deserialize(spec) {
return new LRParser(spec);
}
};
function pair(data, off) {
return data[off] | data[off + 1] << 16;
}
function findOffset(data, start2, term) {
for (let i = start2, next; (next = data[i]) != 65535; i++)
if (next == term)
return i - start2;
return -1;
}
function findFinished(stacks) {
let best = null;
for (let stack of stacks) {
let stopped = stack.p.stoppedAt;
if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) && stack.p.parser.stateFlag(stack.state, 2) && (!best || best.score < stack.score))
best = stack;
}
return best;
}
function getSpecializer(spec) {
if (spec.external) {
let mask = spec.extend ? 1 : 0;
return (value, stack) => spec.external(value, stack) << 1 | mask;
}
return spec.get;
}
// node_modules/@lezer/javascript/dist/index.es.js
var import_highlight = __toModule(require("@lezer/highlight"));
var TSExtends = 1;
var noSemi = 281;
var incdec = 2;
var incdecPrefix = 3;
var templateContent = 282;
var InterpolationStart = 4;
var templateEnd = 283;
var insertSemi = 284;
var spaces = 286;
var newline = 287;
var LineComment = 5;
var BlockComment = 6;
var Dialect_ts = 1;
var space = [
9,
10,
11,
12,
13,
32,
133,
160,
5760,
8192,
8193,
8194,
8195,
8196,
8197,
8198,
8199,
8200,
8201,
8202,
8232,
8233,
8239,
8287,
12288
];
var braceR = 125;
var braceL = 123;
var semicolon = 59;
var slash = 47;
var star = 42;
var plus = 43;
var minus = 45;
var dollar = 36;
var backtick = 96;
var backslash = 92;
var trackNewline = new ContextTracker({
start: false,
shift(context, term) {
return term == LineComment || term == BlockComment || term == spaces ? context : term == newline;
},
strict: false
});
var insertSemicolon = new ExternalTokenizer((input, stack) => {
let { next } = input;
if ((next == braceR || next == -1 || stack.context) && stack.canShift(insertSemi))
input.acceptToken(insertSemi);
}, { contextual: true, fallback: true });
var noSemicolon = new ExternalTokenizer((input, stack) => {
let { next } = input, after;
if (space.indexOf(next) > -1)
return;
if (next == slash && ((after = input.peek(1)) == slash || after == star))
return;
if (next != braceR && next != semicolon && next != -1 && !stack.context && stack.canShift(noSemi))
input.acceptToken(noSemi);
}, { contextual: true });
var incdecToken = new ExternalTokenizer((input, stack) => {
let { next } = input;
if (next == plus || next == minus) {
input.advance();
if (next == input.next) {
input.advance();
let mayPostfix = !stack.context && stack.canShift(incdec);
input.acceptToken(mayPostfix ? incdec : incdecPrefix);
}
}
}, { contextual: true });
var template = new ExternalTokenizer((input) => {
for (let afterDollar = false, i = 0; ; i++) {
let { next } = input;
if (next < 0) {
if (i)
input.acceptToken(templateContent);
break;
} else if (next == backtick) {
if (i)
input.acceptToken(templateContent);
else
input.acceptToken(templateEnd, 1);
break;
} else if (next == braceL && afterDollar) {
if (i == 1)
input.acceptToken(InterpolationStart, 1);
else
input.acceptToken(templateContent, -1);
break;
} else if (next == 10 && i) {
input.advance();
input.acceptToken(templateContent);
break;
} else if (next == backslash) {
input.advance();
}
afterDollar = next == dollar;
input.advance();
}
});
var tsExtends = new ExternalTokenizer((input, stack) => {
if (input.next != 101 || !stack.dialectEnabled(Dialect_ts))
return;
input.advance();
for (let i = 0; i < 6; i++) {
if (input.next != "xtends".charCodeAt(i))
return;
input.advance();
}
if (input.next >= 57 && input.next <= 65 || input.next >= 48 && input.next <= 90 || input.next == 95 || input.next >= 97 && input.next <= 122 || input.next > 160)
return;
input.acceptToken(TSExtends);
});
var jsHighlight = (0, import_highlight.styleTags)({
"get set async static": import_highlight.tags.modifier,
"for while do if else switch try catch finally return throw break continue default case": import_highlight.tags.controlKeyword,
"in of await yield void typeof delete instanceof": import_highlight.tags.operatorKeyword,
"let var const function class extends": import_highlight.tags.definitionKeyword,
"import export from": import_highlight.tags.moduleKeyword,
"with debugger as new": import_highlight.tags.keyword,
TemplateString: import_highlight.tags.special(import_highlight.tags.string),
super: import_highlight.tags.atom,
BooleanLiteral: import_highlight.tags.bool,
this: import_highlight.tags.self,
null: import_highlight.tags.null,
Star: import_highlight.tags.modifier,
VariableName: import_highlight.tags.variableName,
"CallExpression/VariableName TaggedTemplateExpression/VariableName": import_highlight.tags.function(import_highlight.tags.variableName),
VariableDefinition: import_highlight.tags.definition(import_highlight.tags.variableName),
Label: import_highlight.tags.labelName,
PropertyName: import_highlight.tags.propertyName,
PrivatePropertyName: import_highlight.tags.special(import_highlight.tags.propertyName),
"CallExpression/MemberExpression/PropertyName": import_highlight.tags.function(import_highlight.tags.propertyName),
"FunctionDeclaration/VariableDefinition": import_highlight.tags.function(import_highlight.tags.definition(import_highlight.tags.variableName)),
"ClassDeclaration/VariableDefinition": import_highlight.tags.definition(import_highlight.tags.className),
PropertyDefinition: import_highlight.tags.definition(import_highlight.tags.propertyName),
PrivatePropertyDefinition: import_highlight.tags.definition(import_highlight.tags.special(import_highlight.tags.propertyName)),
UpdateOp: import_highlight.tags.updateOperator,
LineComment: import_highlight.tags.lineComment,
BlockComment: import_highlight.tags.blockComment,
Number: import_highlight.tags.number,
String: import_highlight.tags.string,
ArithOp: import_highlight.tags.arithmeticOperator,
LogicOp: import_highlight.tags.logicOperator,
BitOp: import_highlight.tags.bitwiseOperator,
CompareOp: import_highlight.tags.compareOperator,
RegExp: import_highlight.tags.regexp,
Equals: import_highlight.tags.definitionOperator,
Arrow: import_highlight.tags.function(import_highlight.tags.punctuation),
": Spread": import_highlight.tags.punctuation,
"( )": import_highlight.tags.paren,
"[ ]": import_highlight.tags.squareBracket,
"{ }": import_highlight.tags.brace,
"InterpolationStart InterpolationEnd": import_highlight.tags.special(import_highlight.tags.brace),
".": import_highlight.tags.derefOperator,
", ;": import_highlight.tags.separator,
TypeName: import_highlight.tags.typeName,
TypeDefinition: import_highlight.tags.definition(import_highlight.tags.typeName),
"type enum interface implements namespace module declare": import_highlight.tags.definitionKeyword,
"abstract global Privacy readonly override": import_highlight.tags.modifier,
"is keyof unique infer": import_highlight.tags.operatorKeyword,
JSXAttributeValue: import_highlight.tags.attributeValue,
JSXText: import_highlight.tags.content,
"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": import_highlight.tags.angleBracket,
"JSXIdentifier JSXNameSpacedName": import_highlight.tags.tagName,
"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": import_highlight.tags.attributeName
});
var spec_identifier = { __proto__: null, export: 18, as: 23, from: 29, default: 32, async: 37, function: 38, this: 48, true: 56, false: 56, void: 66, typeof: 70, null: 86, super: 88, new: 122, await: 139, yield: 141, delete: 142, class: 152, extends: 154, public: 197, private: 197, protected: 197, readonly: 199, instanceof: 220, in: 222, const: 224, import: 256, keyof: 307, unique: 311, infer: 317, is: 351, abstract: 371, implements: 373, type: 375, let: 378, var: 380, interface: 387, enum: 391, namespace: 397, module: 399, declare: 403, global: 407, for: 428, of: 437, while: 440, with: 444, do: 448, if: 452, else: 454, switch: 458, case: 464, try: 470, catch: 474, finally: 478, return: 482, throw: 486, break: 490, continue: 494, debugger: 498 };
var spec_word = { __proto__: null, async: 109, get: 111, set: 113, public: 161, private: 161, protected: 161, static: 163, abstract: 165, override: 167, readonly: 173, new: 355 };
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c%e%f%g%i%m%x%z&S&W&_&f&p&}'R'w(R)V)^*k*o*t+T+X+[+x,P,b,h,m-u-z.S.].|/_/`/a/c/g/j/l/{0T0j0t1X2i2q3R3f3h3i3q3x5o5}6W6{7j8]8o9^9`9c9e9f9g9h9i9j9k9l9m9n9o9p9s:Q:R:T:_:`:g:h;aQ%f{Q%g|Q%i!OQ%j!PR/f*rQ&e!iQ)[$cQ+w&hS.Q)`)wS0c+u+vW2S-}.O.P.kS4T0d0eU4|2U2V2WU6s4{5Y5ZQ7v6tR8b7yT+l&d+mS+j&d+mU0W+k+o+pU0]+q+r+sS0b+t2xS2s.y2vU3{0Z0[0^Q4P0_Q4Q0aS5c2t2{S5f2y2zU6Z3|4O4RQ6`4SS7Q5g5hQ7S5iS7k6]6_S8P7R7TQ8^7mR8g8QS+l&d+mT2u.y2vS&r!q/dQ-U(_Q-b(kS0V+j2sQ1g-VS1p-
nodeNames: "\u26A0 extends ArithOp ArithOp InterpolationStart LineComment BlockComment Script ExportDeclaration export Star as VariableName String from ; default FunctionDeclaration async function VariableDefinition TypeParamList TypeDefinition ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation VoidType void TypeofType typeof MemberExpression . ?. PropertyName [ TemplateString Interpolation null super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewExpression new TypeArgList CompareOp < ) ( ArgList UnaryExpression await yield delete LogicOp BitOp ParenthesizedExpression ClassExpression class extends ClassBody MethodDeclaration Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression PrivatePropertyName BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXStartTag JSXSelfClosingTag JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody MethodDeclaration AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement",
maxTerm: 332,
context: trackNewline,
nodeProps: [
["closedBy", 4, "InterpolationEnd", 40, "]", 51, "}", 66, ")", 132, "JSXSelfCloseEndTag JSXEndTag", 146, "JSXEndTag"],
["group", -26, 8, 15, 17, 58, 184, 188, 191, 192, 194, 197, 200, 211, 213, 219, 221, 223, 225, 228, 234, 240, 242, 244, 246, 248, 250, 251, "Statement", -30, 12, 13, 24, 27, 28, 41, 43, 44, 45, 47, 52, 60, 68, 74, 75, 91, 92, 101, 103, 119, 122, 124, 125, 126, 127, 129, 130, 148, 149, 151, "Expression", -22, 23, 25, 29, 32, 34, 152, 154, 156, 157, 159, 160, 161, 163, 164, 165, 167, 168, 169, 178, 180, 182, 183, "Type", -3, 79, 85, 90, "Class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]Zz!!]z{!#Q{!P!!]!P!Q!&x!Q!}!!]!}#O!$`#O#P!&f#P~!!]7R!#VY}POY!!]YZM]Zz!!]z{!#Q{!P!!]!P!Q!#u!Q!}!!]!}#O!$`#O#P!&f#P~!!]7R!#|UU7R}P#Z#[Gd#]#^Gd#a#bGd#g#hGd#i#jGd#m#nGd7R!$cWOY!$`YZM]Zz!$`z{!${{#O!$`#O#P!&S#P#Q!!]#Q~!$`7R!%OY
tokenizers: [tsExtends, noSemicolon, incdecToken, template, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, insertSemicolon],
topRules: { "Script": [0, 7] },
dialects: { jsx: 12107, ts: 12109 },
dynamicPrecedences: { "149": 1, "176": 1 },
specialized: [{ term: 289, get: (value) => spec_identifier[value] || -1 }, { term: 299, get: (value) => spec_word[value] || -1 }, { term: 63, get: (value) => spec_LessThan[value] || -1 }],
tokenPrec: 12130
});
// node_modules/@codemirror/lang-javascript/dist/index.js
var import_language = __toModule(require("@codemirror/language"));
var import_state = __toModule(require("@codemirror/state"));
var import_view = __toModule(require("@codemirror/view"));
var import_autocomplete = __toModule(require("@codemirror/autocomplete"));
var snippets = [
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("function ${name}(${params}) {\n ${}\n}", {
label: "function",
detail: "definition",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}", {
label: "for",
detail: "loop",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("for (let ${name} of ${collection}) {\n ${}\n}", {
label: "for",
detail: "of loop",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("do {\n ${}\n} while (${})", {
label: "do",
detail: "loop",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("while (${}) {\n ${}\n}", {
label: "while",
detail: "loop",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("try {\n ${}\n} catch (${error}) {\n ${}\n}", {
label: "try",
detail: "/ catch block",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("if (${}) {\n ${}\n}", {
label: "if",
detail: "block",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("if (${}) {\n ${}\n} else {\n ${}\n}", {
label: "if",
detail: "/ else block",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)("class ${name} {\n constructor(${params}) {\n ${}\n }\n}", {
label: "class",
detail: "definition",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)('import {${names}} from "${module}"\n${}', {
label: "import",
detail: "named",
type: "keyword"
}),
/* @__PURE__ */ (0, import_autocomplete.snippetCompletion)('import ${name} from "${module}"\n${}', {
label: "import",
detail: "default",
type: "keyword"
})
];
var cache = /* @__PURE__ */ new NodeWeakMap();
var ScopeNodes = /* @__PURE__ */ new Set([
"Script",
"Block",
"FunctionExpression",
"FunctionDeclaration",
"ArrowFunction",
"MethodDeclaration",
"ForStatement"
]);
function defID(type) {
return (node, def) => {
let id2 = node.node.getChild("VariableDefinition");
if (id2)
def(id2, type);
return true;
};
}
var functionContext = ["FunctionDeclaration"];
var gatherCompletions = {
FunctionDeclaration: /* @__PURE__ */ defID("function"),
ClassDeclaration: /* @__PURE__ */ defID("class"),
ClassExpression: () => true,
EnumDeclaration: /* @__PURE__ */ defID("constant"),
TypeAliasDeclaration: /* @__PURE__ */ defID("type"),
NamespaceDeclaration: /* @__PURE__ */ defID("namespace"),
VariableDefinition(node, def) {
if (!node.matchContext(functionContext))
def(node, "variable");
},
TypeDefinition(node, def) {
def(node, "type");
},
__proto__: null
};
function getScope(doc, node) {
let cached = cache.get(node);
if (cached)
return cached;
let completions = [], top2 = true;
function def(node2, type) {
let name = doc.sliceString(node2.from, node2.to);
completions.push({ label: name, type });
}
node.cursor(IterMode.IncludeAnonymous).iterate((node2) => {
if (top2) {
top2 = false;
} else if (node2.name) {
let gather = gatherCompletions[node2.name];
if (gather && gather(node2, def) || ScopeNodes.has(node2.name))
return false;
} else if (node2.to - node2.from > 8192) {
for (let c of getScope(doc, node2.node))
completions.push(c);
return false;
}
});
cache.set(node, completions);
return completions;
}
var Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
var dontComplete = [
"TemplateString",
"String",
"RegExp",
"LineComment",
"BlockComment",
"VariableDefinition",
"TypeDefinition",
"Label",
"PropertyDefinition",
"PropertyName",
"PrivatePropertyDefinition",
"PrivatePropertyName"
];
function localCompletionSource(context) {
let inner = (0, import_language.syntaxTree)(context.state).resolveInner(context.pos, -1);
if (dontComplete.indexOf(inner.name) > -1)
return null;
let isWord = inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
if (!isWord && !context.explicit)
return null;
let options = [];
for (let pos = inner; pos; pos = pos.parent) {
if (ScopeNodes.has(pos.name))
options = options.concat(getScope(context.state.doc, pos));
}
return {
options,
from: isWord ? inner.from : context.pos,
validFor: Identifier
};
}
var javascriptLanguage = /* @__PURE__ */ import_language.LRLanguage.define({
parser: /* @__PURE__ */ parser.configure({
props: [
/* @__PURE__ */ import_language.indentNodeProp.add({
IfStatement: /* @__PURE__ */ (0, import_language.continuedIndent)({ except: /^\s*({|else\b)/ }),
TryStatement: /* @__PURE__ */ (0, import_language.continuedIndent)({ except: /^\s*({|catch\b|finally\b)/ }),
LabeledStatement: import_language.flatIndent,
SwitchBody: (context) => {
let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
},
Block: /* @__PURE__ */ (0, import_language.delimitedIndent)({ closing: "}" }),
ArrowFunction: (cx) => cx.baseIndent + cx.unit,
"TemplateString BlockComment": () => null,
"Statement Property": /* @__PURE__ */ (0, import_language.continuedIndent)({ except: /^{/ }),
JSXElement(context) {
let closed = /^\s*<\//.test(context.textAfter);
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
},
JSXEscape(context) {
let closed = /\s*\}/.test(context.textAfter);
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
},
"JSXOpenTag JSXSelfClosingTag"(context) {
return context.column(context.node.from) + context.unit;
}
}),
/* @__PURE__ */ import_language.foldNodeProp.add({
"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression": import_language.foldInside,
BlockComment(tree) {
return { from: tree.from + 2, to: tree.to - 2 };
}
})
]
}),
languageData: {
closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
wordChars: "$"
}
});
var typescriptLanguage = /* @__PURE__ */ javascriptLanguage.configure({ dialect: "ts" });
var jsxLanguage = /* @__PURE__ */ javascriptLanguage.configure({ dialect: "jsx" });
var tsxLanguage = /* @__PURE__ */ javascriptLanguage.configure({ dialect: "jsx ts" });
var keywords = /* @__PURE__ */ "break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map((kw) => ({ label: kw, type: "keyword" }));
function javascript(config2 = {}) {
let lang = config2.jsx ? config2.typescript ? tsxLanguage : jsxLanguage : config2.typescript ? typescriptLanguage : javascriptLanguage;
return new import_language.LanguageSupport(lang, [
javascriptLanguage.data.of({
autocomplete: (0, import_autocomplete.ifNotIn)(dontComplete, (0, import_autocomplete.completeFromList)(snippets.concat(keywords)))
}),
javascriptLanguage.data.of({
autocomplete: localCompletionSource
}),
config2.jsx ? autoCloseTags : []
]);
}
function elementName(doc, tree, max2 = doc.length) {
if (!tree)
return "";
let name = tree.getChild("JSXIdentifier");
return name ? doc.sliceString(name.from, Math.min(name.to, max2)) : "";
}
var android = typeof navigator == "object" && /* @__PURE__ */ /Android\b/.test(navigator.userAgent);
var autoCloseTags = /* @__PURE__ */ import_view.EditorView.inputHandler.of((view, from, to, text) => {
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly || from != to || text != ">" && text != "/" || !javascriptLanguage.isActiveAt(view.state, from, -1))
return false;
let { state } = view;
let changes = state.changeByRange((range) => {
var _a, _b, _c;
let { head } = range, around = (0, import_language.syntaxTree)(state).resolveInner(head, -1), name;
if (around.name == "JSXStartTag")
around = around.parent;
if (text == ">" && around.name == "JSXFragmentTag") {
return { range: import_state.EditorSelection.cursor(head + 1), changes: { from: head, insert: `><>` } };
} else if (text == ">" && around.name == "JSXIdentifier") {
if (((_b = (_a = around.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "JSXEndTag" && (name = elementName(state.doc, around.parent, head)))
return { range: import_state.EditorSelection.cursor(head + 1), changes: { from: head, insert: `></${name}>` } };
} else if (text == "/" && around.name == "JSXFragmentTag") {
let empty = around.parent, base = empty === null || empty === void 0 ? void 0 : empty.parent;
if (empty.from == head - 1 && ((_c = base.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "JSXEndTag" && (name = elementName(state.doc, base === null || base === void 0 ? void 0 : base.firstChild, head))) {
let insert = `/${name}>`;
return { range: import_state.EditorSelection.cursor(head + insert.length), changes: { from: head, insert } };
}
}
return { range };
});
if (changes.changes.empty)
return false;
view.dispatch(changes, { userEvent: "input.type", scrollIntoView: true });
return true;
});
// src/snippets_editor/extensions.ts
var import_language3 = __toModule(require("@codemirror/language"));
var import_commands = __toModule(require("@codemirror/commands"));
var import_autocomplete2 = __toModule(require("@codemirror/autocomplete"));
var import_search = __toModule(require("@codemirror/search"));
var import_lint = __toModule(require("@codemirror/lint"));
// src/snippets_editor/obsidian_theme.ts
var import_view2 = __toModule(require("@codemirror/view"));
var import_language2 = __toModule(require("@codemirror/language"));
var import_highlight2 = __toModule(require("@lezer/highlight"));
var config = {
name: "obsidian",
dark: false,
background: "var(--background-primary)",
foreground: "var(--text-normal)",
selection: "var(--text-selection)",
cursor: "var(--text-normal)",
dropdownBackground: "var(--background-primary)",
dropdownBorder: "var(--background-modifier-border)",
activeLine: "var(--background-primary)",
matchingBracket: "var(--background-modifier-accent)",
keyword: "#d73a49",
storage: "#d73a49",
variable: "var(--text-normal)",
parameter: "var(--text-accent-hover)",
function: "var(--text-accent-hover)",
string: "var(--text-accent)",
constant: "var(--text-accent-hover)",
type: "var(--text-accent-hover)",
class: "#6f42c1",
number: "var(--text-accent-hover)",
comment: "var(--text-faint)",
heading: "var(--text-accent-hover)",
invalid: "var(--text-error)",
regexp: "#032f62"
};
var obsidianTheme = import_view2.EditorView.theme({
"&": {
color: config.foreground,
backgroundColor: config.background
},
".cm-content": { caretColor: config.cursor },
"&.cm-focused .cm-cursor": { borderLeftColor: config.cursor },
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, & ::selection": { backgroundColor: config.selection },
".cm-panels": { backgroundColor: config.dropdownBackground, color: config.foreground },
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
".cm-searchMatch": {
backgroundColor: config.dropdownBackground,
outline: `1px solid ${config.dropdownBorder}`
},
".cm-searchMatch.cm-searchMatch-selected": {
backgroundColor: config.selection
},
".cm-activeLine": { backgroundColor: config.activeLine },
".cm-activeLineGutter": { backgroundColor: config.background },
".cm-selectionMatch": { backgroundColor: config.selection },
".cm-matchingBracket, .cm-nonmatchingBracket": {
backgroundColor: config.matchingBracket,
outline: "none"
},
".cm-gutters": {
backgroundColor: config.background,
color: config.comment,
borderRight: "1px solid var(--background-modifier-border)"
},
".cm-lineNumbers, .cm-gutterElement": { color: "inherit" },
".cm-foldPlaceholder": {
backgroundColor: "transparent",
border: "none",
color: config.foreground
},
".cm-tooltip": {
border: `1px solid ${config.dropdownBorder}`,
backgroundColor: config.dropdownBackground,
color: config.foreground
},
".cm-tooltip.cm-tooltip-autocomplete": {
"& > ul > li[aria-selected]": {
background: config.selection,
color: config.foreground
}
}
}, { dark: config.dark });
var obsidianHighlightStyle = import_language2.HighlightStyle.define([
{ tag: import_highlight2.tags.keyword, color: config.keyword },
{ tag: [import_highlight2.tags.name, import_highlight2.tags.deleted, import_highlight2.tags.character, import_highlight2.tags.macroName], color: config.variable },
{ tag: [import_highlight2.tags.propertyName], color: config.function },
{ tag: [import_highlight2.tags.processingInstruction, import_highlight2.tags.string, import_highlight2.tags.inserted, import_highlight2.tags.special(import_highlight2.tags.string)], color: config.string },
{ tag: [import_highlight2.tags.function(import_highlight2.tags.variableName), import_highlight2.tags.labelName], color: config.function },
{ tag: [import_highlight2.tags.color, import_highlight2.tags.constant(import_highlight2.tags.name), import_highlight2.tags.standard(import_highlight2.tags.name)], color: config.constant },
{ tag: [import_highlight2.tags.definition(import_highlight2.tags.name), import_highlight2.tags.separator], color: config.variable },
{ tag: [import_highlight2.tags.className], color: config.class },
{ tag: [import_highlight2.tags.number, import_highlight2.tags.changed, import_highlight2.tags.annotation, import_highlight2.tags.modifier, import_highlight2.tags.self, import_highlight2.tags.namespace], color: config.number },
{ tag: [import_highlight2.tags.typeName], color: config.type, fontStyle: config.type },
{ tag: [import_highlight2.tags.operator, import_highlight2.tags.operatorKeyword], color: config.keyword },
{ tag: [import_highlight2.tags.url, import_highlight2.tags.escape, import_highlight2.tags.regexp, import_highlight2.tags.link], color: config.regexp },
{ tag: [import_highlight2.tags.meta, import_highlight2.tags.comment], color: config.comment },
{ tag: import_highlight2.tags.strong, fontWeight: "bold" },
{ tag: import_highlight2.tags.emphasis, fontStyle: "italic" },
{ tag: import_highlight2.tags.link, textDecoration: "underline" },
{ tag: import_highlight2.tags.heading, fontWeight: "bold", color: config.heading },
{ tag: [import_highlight2.tags.atom, import_highlight2.tags.bool, import_highlight2.tags.special(import_highlight2.tags.variableName)], color: config.variable },
{ tag: import_highlight2.tags.invalid, color: config.invalid },
{ tag: import_highlight2.tags.strikethrough, textDecoration: "line-through" }
]);
var obsidian = [
obsidianTheme,
(0, import_language2.syntaxHighlighting)(obsidianHighlightStyle)
];
// src/snippets_editor/extensions.ts
var basicSetup = [
(0, import_view3.lineNumbers)(),
(0, import_view3.highlightSpecialChars)(),
(0, import_commands.history)(),
javascript(),
(0, import_view3.drawSelection)(),
(0, import_view3.dropCursor)(),
import_state2.EditorState.allowMultipleSelections.of(true),
(0, import_language3.indentOnInput)(),
import_language3.indentUnit.of(" "),
(0, import_language3.syntaxHighlighting)(import_language3.defaultHighlightStyle, { fallback: true }),
import_view3.EditorView.lineWrapping,
(0, import_language3.bracketMatching)(),
(0, import_autocomplete2.closeBrackets)(),
(0, import_view3.rectangularSelection)(),
(0, import_search.highlightSelectionMatches)(),
obsidian,
import_view3.keymap.of([
...import_autocomplete2.closeBracketsKeymap,
...import_commands.defaultKeymap,
...import_search.searchKeymap,
...import_commands.historyKeymap,
import_commands.indentWithTab,
...import_lint.lintKeymap
])
].filter((ext) => ext);
// src/default_snippets.ts
var DEFAULT_SNIPPETS = '[\n // Math mode\n {trigger: "mk", replacement: "$$0$", options: "tA"},\n {trigger: "dm", replacement: "$$\\n$0\\n$$", options: "tAw"},\n {trigger: "beg", replacement: "\\\\begin{$0}\\n$1\\n\\\\end{$0}", options: "mA"},\n\n\n // Dashes\n // {trigger: "--", replacement: "\u2013", options: "tA"},\n // {trigger: "\u2013-", replacement: "\u2014", options: "tA"},\n // {trigger: "\u2014-", replacement: "---", options: "tA"},\n\n\n // Greek letters\n {trigger: "@a", replacement: "\\\\alpha", options: "mA"},\n {trigger: "@A", replacement: "\\\\alpha", options: "mA"},\n {trigger: "@b", replacement: "\\\\beta", options: "mA"},\n {trigger: "@B", replacement: "\\\\beta", options: "mA"},\n {trigger: "@c", replacement: "\\\\chi", options: "mA"},\n {trigger: "@C", replacement: "\\\\chi", options: "mA"},\n {trigger: "@g", replacement: "\\\\gamma", options: "mA"},\n {trigger: "@G", replacement: "\\\\Gamma", options: "mA"},\n {trigger: "@d", replacement: "\\\\delta", options: "mA"},\n {trigger: "@D", replacement: "\\\\Delta", options: "mA"},\n {trigger: "@e", replacement: "\\\\epsilon", options: "mA"},\n {trigger: "@E", replacement: "\\\\epsilon", options: "mA"},\n {trigger: ":e", replacement: "\\\\varepsilon", options: "mA"},\n {trigger: ":E", replacement: "\\\\varepsilon", options: "mA"},\n {trigger: "@z", replacement: "\\\\zeta", options: "mA"},\n {trigger: "@Z", replacement: "\\\\zeta", options: "mA"},\n {trigger: "@t", replacement: "\\\\theta", options: "mA"},\n {trigger: "@T", replacement: "\\\\Theta", options: "mA"},\n {trigger: "@k", replacement: "\\\\kappa", options: "mA"},\n {trigger: "@K", replacement: "\\\\kappa", options: "mA"},\n {trigger: "@l", replacement: "\\\\lambda", options: "mA"},\n {trigger: "@L", replacement: "\\\\Lambda", options: "mA"},\n {trigger: "@m", replacement: "\\\\mu", options: "mA"},\n {trigger: "@M", replacement: "\\\\mu", options: "mA"},\n {trigger: "@r", replacement: "\\\\rho", options: "mA"},\n {trigger: "@R", replacement: "\\\\rho", options: "mA"},\n {trigger: "@s", replacement: "\\\\sigma", options: "mA"},\n {trigger: "@S", replacement: "\\\\Sigma", options: "mA"},\n {trigger: "ome", replacement: "\\\\omega", options: "mA"},\n {trigger: "@o", replacement: "\\\\omega", options: "mA"},\n {trigger: "@O", replacement: "\\\\Omega", options: "mA"},\n {trigger: "([^\\\\\\\\])(${GREEK}|${SYMBOL})", replacement: "[[0]]\\\\[[1]]", options: "rmA", description: "Add backslash before greek letters and symbols"},\n\n\n // Insert space after greek letters and symbols, etc\n {trigger: "\\\\\\\\(${GREEK}|${SYMBOL})([A-Za-z])", replacement: "\\\\[[0]] [[1]]", options: "rmA"},\n {trigger: "\\\\\\\\(${GREEK}|${SYMBOL}) sr", replacement: "\\\\[[0]]^{2}", options: "rmA"},\n {trigger: "\\\\\\\\(${GREEK}|${SYMBOL}) cb", replacement: "\\\\[[0]]^{3}", options: "rmA"},\n {trigger: "\\\\\\\\(${GREEK}|${SYMBOL}) rd", replacement: "\\\\[[0]]^{$0}$1", options: "rmA"},\n {trigger: "\\\\\\\\(${GREEK}|${SYMBOL}) hat", replacement: "\\\\hat{\\\\[[0]]}", options: "rmA"},\n {trigger: "\\\\\\\\(${GREEK}|${SYMBOL}) dot", replacement: "\\\\dot{\\\\[[0]]}", options: "rmA"},\n {trigger: "\\\\\\\\(${GREEK}|${SYMBOL}) bar", replacement: "\\\\bar{\\\\[[0]]}", options: "rmA"},\n {trigger: "\\\\\\\\(${GREEK}),\\\\.", replacement: "\\\\mathbf{\\\\[[0]]}", options: "rmA"},\n {trigger: "\\\\\\\\(${GREEK})\\\\.,", replacement: "\\\\mathbf{\\\\[[0]]}", options: "rmA"},\n\n\n // Operations\n {trigger: "te", replacement: "\\\\text{$0}", options: "m"},\n {trigger: "bf", replacement: "\\\\mathbf{$0}", options: "mA"},\n {trigger: "sr", replacement: "^{2}", options: "mA"},\n {trigger: "cb", replacement: "^{3}", options: "mA"},\n {trigger: "rd", replacement: "^{$0}$1", options: "mA"},\n {trigger: "_", replacement: "_{$0}$1", options: "mA"},\n {trigger: "sts", replacement: "_\\\\text{$0}", options: "rmA"},\n {trigger: "sq", replacement: "\\\\sqrt{ $0 }$1",
// src/editor_extensions/conceal.ts
var import_view5 = __toModule(require("@codemirror/view"));
var import_language5 = __toModule(require("@codemirror/language"));
// src/editor_helpers.ts
var import_obsidian = __toModule(require("obsidian"));
var import_view4 = __toModule(require("@codemirror/view"));
var import_state3 = __toModule(require("@codemirror/state"));
var import_language4 = __toModule(require("@codemirror/language"));
function replaceRange(view, start2, end2, replacement) {
view.dispatch({
changes: { from: start2, to: end2, insert: replacement }
});
}
function getCharacterAtPos(view, pos) {
const doc = view.state.doc;
return doc.slice(pos, pos + 1).toString();
}
function setCursor(view, pos) {
view.dispatch({
selection: { anchor: pos, head: pos }
});
resetCursorBlink();
}
function setSelection(view, start2, end2) {
view.dispatch({
selection: { anchor: start2, head: end2 }
});
resetCursorBlink();
}
function setSelections(view, ranges) {
view.dispatch({
selection: import_state3.EditorSelection.create(ranges)
});
resetCursorBlink();
}
function resetCursorBlink() {
if (import_obsidian.Platform.isMobile)
return;
const cursorLayer = document.getElementsByClassName("cm-cursorLayer")[0];
const curAnim = cursorLayer.style.animationName;
cursorLayer.style.animationName = curAnim === "cm-blink" ? "cm-blink2" : "cm-blink";
}
function isWithinEquation(view) {
const s = view instanceof import_view4.EditorView ? view.state : view;
const pos = s.selection.main.to - 1;
const tree = (0, import_language4.syntaxTree)(s);
const token = tree.resolveInner(pos, 1).name;
let withinEquation = token.contains("math");
if (!withinEquation) {
const tokenLeft = tree.resolveInner(pos - 1, 1).name;
const tokenRight = tree.resolveInner(pos + 1, 1).name;
if (tokenLeft.contains("math") && tokenRight.contains("math")) {
withinEquation = true;
}
} else {
if (token.contains("end")) {
withinEquation = false;
}
}
return withinEquation;
}
function isWithinInlineEquation(view) {
const result = getEquationBounds(view);
if (!result)
return false;
const end2 = result.end;
const d = view.state.doc;
const inlineMath = d.sliceString(end2, end2 + 2) != "$$";
return inlineMath;
}
function isWithinInlineEquationState(state) {
const result = getEquationBounds(state);
if (!result)
return false;
const end2 = result.end;
const d = state.doc;
const inlineMath = d.sliceString(end2, end2 + 2) != "$$";
return inlineMath;
}
function isTouchingInlineEquation(state, pos) {
const tree = (0, import_language4.syntaxTree)(state);
const prevToken = tree.resolveInner(pos - 1, 1).name;
const token = tree.resolveInner(pos, 1).name;
const nextToken = tree.resolveInner(pos + 1, 1).name;
if (token.contains("math-end") && !prevToken.contains("math-end") && !nextToken.contains("math-end")) {
return -1;
} else if (!token.contains("math-begin") && nextToken.contains("math-begin")) {
const nextNextToken = tree.resolveInner(pos + 2, 1).name;
if (!nextNextToken.contains("math-begin")) {
return 1;
}
}
return 0;
}
function getEquationBounds(view, pos) {
const s = view instanceof import_view4.EditorView ? view.state : view;
const text = s.doc.toString();
if (typeof pos === "undefined") {
pos = s.selection.main.from;
}
const left2 = text.lastIndexOf("$", pos - 1);
const right2 = text.indexOf("$", pos);
if (left2 === -1 || right2 === -1)
return;
return { start: left2 + 1, end: right2 };
}
function isInsideEnvironment(view, pos, env) {
const result = getEquationBounds(view);
if (!result)
return false;
const { start: start2, end: end2 } = result;
const text = view.state.doc.toString();
const { openSymbol, closeSymbol } = env;
const curText = text.slice(start2, end2);
const openBracket = openSymbol.slice(-1);
const closeBracket = getCloseBracket(openBracket);
let offset2;
let openSearchSymbol;
if (["{", "[", "("].contains(openBracket) && closeSymbol === closeBracket) {
offset2 = openSymbol.length - 1;
openSearchSymbol = openBracket;
} else {
offset2 = 0;
openSearchSymbol = openSymbol;
}
let left2 = curText.lastIndexOf(openSymbol, pos - start2 - 1);
while (left2 != -1) {
const right2 = findMatchingBracket(curText, left2 + offset2, openSearchSymbol, closeSymbol, false);
if (right2 === -1)
return false;
if (right2 >= pos - start2 && pos - start2 >= left2 + openSymbol.length) {
return true;
}
if (left2 <= 0)
return false;
left2 = curText.lastIndexOf(openSymbol, left2 - 1);
}
return false;
}
function getEnclosingBracketsPos(view, pos) {
const result = getEquationBounds(view);
if (!result)
return -1;
const { start: start2, end: end2 } = result;
const text = view.state.doc.sliceString(start2, end2);
for (let i = pos - start2; i > 0; i--) {
let curChar = text.charAt(i);
if ([")", "]", "}"].contains(curChar)) {
const closeBracket = curChar;
const openBracket = getOpenBracket(closeBracket);
const j = findMatchingBracket(text, i, openBracket, closeBracket, true);
if (j === -1)
return -1;
i = j;
curChar = text.charAt(i);
} else {
if (!["{", "(", "["].contains(curChar))
continue;
const j = findMatchingBracket(text, i, curChar, getCloseBracket(curChar), false);
if (j === -1)
continue;
return { left: i + start2, right: j + start2 };
}
}
return -1;
}
function reverse(s) {
return s.split("").reverse().join("");
}
function findMatchingBracket(text, start2, openBracket, closeBracket, searchBackwards, end2) {
if (searchBackwards) {
const reversedIndex = findMatchingBracket(reverse(text), text.length - (start2 + closeBracket.length), reverse(closeBracket), reverse(openBracket), false);
if (reversedIndex === -1)
return -1;
return text.length - (reversedIndex + openBracket.length);
}
let brackets2 = 0;
const stop = end2 ? end2 : text.length;
for (let i = start2; i < stop; i++) {
if (text.slice(i, i + openBracket.length) === openBracket) {
brackets2++;
} else if (text.slice(i, i + closeBracket.length) === closeBracket) {
brackets2--;
if (brackets2 === 0) {
return i;
}
}
}
return -1;
}
function getOpenBracket(closeBracket) {
const openBrackets = { ")": "(", "]": "[", "}": "{" };
return openBrackets[closeBracket];
}
function getCloseBracket(openBracket) {
const closeBrackets2 = { "(": ")", "[": "]", "{": "}" };
return closeBrackets2[openBracket];
}
// src/editor_extensions/conceal_maps.ts
var cmd_symbols = {
"aleph": "\u2135",
"amalg": "\u2210",
"angle": "\u2220",
"approx": "\u2248",
"ast": "\u2217",
"asymp": "\u224D",
"backslash": "\u2216",
"bigcap": "\u2229",
"bigcirc": "\u25CB",
"bigcup": "\u222A",
"bigodot": "\u2299",
"bigoplus": "\u2295",
"bigotimes": "\u2297",
"bigsqcup": "\u2294",
"bigtriangledown": "\u2207",
"bigtriangleup": "\u2206",
"bigvee": "\u22C1",
"bigwedge": "\u22C0",
"bot": "\u22A5",
"bowtie": "\u22C8",
"bullet": "\u2022",
"cap": "\u2229",
"cdots": "\u22EF",
"cdot": "\xB7",
"circ": "\u2218",
"clubsuit": "\u2663",
"cong": "\u2245",
"coprod": "\u2210",
"copyright": "\xA9",
"cup": "\u222A",
"dagger": "\u2020",
"dashv": "\u22A3",
"ddagger": "\u2021",
"ddots": "\u22F1",
"diamond": "\u22C4",
"diamondsuit": "\u2662",
"div": "\xF7",
"doteq": "\u2250",
"dots": "\u2026",
"downarrow": "\u2193",
"Downarrow": "\u21D3",
"ell": "\u2113",
"emptyset": "\xD8",
"equiv": "\u2261",
"exists": "\u2203",
"flat": "\u266D",
"forall": "\u2200",
"frown": "\u2054",
"geqslant": "\u2265",
"geq": "\u2265",
"ge": "\u2265",
"gets": "\u2190",
"gg": "\u27EB",
"hbar": "\u210F",
"heartsuit": "\u2661",
"hookleftarrow": "\u21A9",
"hookrightarrow": "\u21AA",
"iff": "\u21D4",
"Im": "\u2111",
"imath": "\u0269",
"infty": "\u221E",
"iiint": "\u222D",
"iint": "\u222C",
"int": "\u222B",
"in": "\u2208",
"jmath": "\u{1D6A5}",
"land": "\u2227",
"lnot": "\xAC",
"lceil": "\u2308",
"ldots": "\u2026",
"leftharpoondown": "\u21BD",
"leftharpoonup": "\u21BC",
"leftrightarrow": "\u2194",
"Leftrightarrow": "\u21D4",
"lhd": "\u25C1",
"rhd": "\u25B7",
"leftarrow": "\u2190",
"Leftarrow": "\u21D0",
"left": "",
"leq": "\u2264",
"le": "\u2264",
"ll": "\u226A",
"lmoustache": "\u256D",
"lor": "\u2228",
"mapsto": "\u21A6",
"mid": "\u2223",
"models": "\u22A8",
"mp": "\u2213",
"nabla": "\u2207",
"natural": "\u266E",
"nearrow": "\u2197",
"neg": "\xAC",
"neqslant": "\u2260",
"neq": "\u2260",
"ne": "\u2260",
"ni": "\u220B",
"notin": "\u2209",
"nwarrow": "\u2196",
"odot": "\u2299",
"oint": "\u222E",
"ominus": "\u2296",
"oplus": "\u2295",
"oslash": "\u2298",
"otimes": "\u2297",
"owns": "\u220B",
"P": "\xB6",
"parallel": "\u2551",
"partial": "\u2202",
"perp": "\u22A5",
"pm": "\xB1",
"preceq": "\u2AAF",
"prec": "\u227A",
"prime": "\u2032",
"prod": "\u220F",
"propto": "\u221D",
"rceil": "\u2309",
"Re": "\u211C",
"right": "",
"qquad": "\u2001",
"quad": "\u2000",
"rightarrow": "\u2192",
"Rightarrow": "\u21D2",
"rightleftharpoons": "\u21CC",
"rmoustache": "\u256E",
"S": "\xA7",
"searrow": "\u2198",
"setminus": "\u29F5",
"sharp": "\u266F",
"simeq": "\u22CD",
"sim": "\u223C",
"smile": "\u203F",
"spadesuit": "\u2660",
"sqcap": "\u2293",
"sqcup": "\u2294",
"sqsubseteq": "\u2291",
"sqsubset": "\u228F",
"sqsupseteq": "\u2292",
"sqsupset": "\u2290",
"square": "\u25A1",
"star": "\u272B",
"subseteq": "\u2286",
"subset": "\u2282",
"succeq": "\u2AB0",
"succ": "\u227B",
"sum\\limits": "\u2211",
"sum": "\u2211",
"lim\\limits": "lim",
"supseteq": "\u2287",
"supset": "\u2283",
"surd": "\u221A",
"swarrow": "\u2199",
"times": "\xD7",
"top": "\u22A4",
"to": "\u2192",
"triangleleft": "\u22B2",
"triangleright": "\u22B3",
"triangle": "\u2206",
"uparrow": "\u2191",
"Uparrow": "\u21D1",
"updownarrow": "\u2195",
"Updownarrow": "\u21D5",
"vdash": "\u22A2",
"vdots": "\u22EE",
"vee": "\u2228",
"wedge": "\u2227",
"wp": "\u2118",
"wr": "\u2240",
"implies": "\u21D2",
"choose": "C",
"sqrt": "\u221A",
"coloneqq": "\u2254",
"colon": ":",
"displaystyle": " ",
",": " ",
":": " ",
";": " "
};
var operators = [
"arcsin",
"arccos",
"arctan",
"sinh",
"cosh",
"tanh",
"coth",
"sin",
"cos",
"tan",
"sec",
"csc",
"cot",
"exp",
"ker",
"limsup",
"lim",
"sup",
"deg",
"gcd",
"log",
"lg",
"ln",
"Pr",
"det",
"hom",
"arg",
"dim",
"liminf",
"min",
"max",
"inf"
];
var fractions = {
"{1}{2}": "\xBD",
"{1}{3}": "\u2153",
"{2}{3}": "\u2154",
"{1}{4}": "\xBC",
"{1}{5}": "\u2155",
"{2}{5}": "\u2156",
"{3}{5}": "\u2157",
"{4}{5}": "\u2158",
"{1}{6}": "\u2159",
"{5}{6}": "\u215A",
"{1}{8}": "\u215B",
"{3}{8}": "\u215C",
"{5}{8}": "\u215D",
"{7}{8}": "\u215E"
};
var greek = {
"alpha": "\u03B1",
"beta": "\u03B2",
"gamma": "\u03B3",
"delta": "\u03B4",
"epsilon": "\u03F5",
"varepsilon": "\u03B5",
"zeta": "\u03B6",
"eta": "\u03B7",
"theta": "\u03B8",
"vartheta": "\u03D1",
"iota": "\u03B9",
"kappa": "\u03BA",
"lambda": "\u03BB",
"mu": "\u03BC",
"nu": "\u03BD",
"xi": "\u03BE",
"pi": "\u03C0",
"varpi": "\u03D6",
"rho": "\u03C1",
"varrho": "\u03F1",
"sigma": "\u03C3",
"varsigma": "\u03C2",
"tau": "\u03C4",
"upsilon": "\u03C5",
"phi": "\u03D5",
"varphi": "\u03C6",
"chi": "\u03C7",
"psi": "\u03C8",
"omega": "\u03C9",
"Gamma": "\u0393",
"Delta": "\u0394",
"Theta": "\u0398",
"Lambda": "\u039B",
"Xi": "\u039E",
"Pi": "\u03A0",
"Sigma": "\u03A3",
"Upsilon": "\u03A5",
"Phi": "\u03A6",
"Chi": "\u03A7",
"Psi": "\u03A8",
"Omega": "\u03A9"
};
var map_super = {
"(": "\u207D",
")": "\u207E",
"+": "\u207A",
"-": "\u207B",
"=": "\u207C",
":": "\uFE13",
";": "\uFE14",
"<": "\u02C2",
">": "\u02C3",
"0": "\u2070",
"1": "\xB9",
"2": "\xB2",
"3": "\xB3",
"4": "\u2074",
"5": "\u2075",
"6": "\u2076",
"7": "\u2077",
"8": "\u2078",
"9": "\u2079",
"a": "\u1D43",
"b": "\u1D47",
"c": "\u1D9C",
"d": "\u1D48",
"e": "\u1D49",
"f": "\u1DA0",
"g": "\u1D4D",
"h": "\u02B0",
"i": "\u2071",
"j": "\u02B2",
"k": "\u1D4F",
"l": "\u02E1",
"m": "\u1D50",
"n": "\u207F",
"o": "\u1D52",
"p": "\u1D56",
"r": "\u02B3",
"s": "\u02E2",
"t": "\u1D57",
"u": "\u1D58",
"v": "\u1D5B",
"w": "\u02B7",
"x": "\u02E3",
"y": "\u02B8",
"z": "\u1DBB",
"A": "\u1D2C",
"B": "\u1D2E",
"D": "\u1D30",
"E": "\u1D31",
"G": "\u1D33",
"H": "\u1D34",
"I": "\u1D35",
"J": "\u1D36",
"K": "\u1D37",
"L": "\u1D38",
"M": "\u1D39",
"N": "\u1D3A",
"O": "\u1D3C",
"P": "\u1D3E",
"R": "\u1D3F",
"T": "\u1D40",
"U": "\u1D41",
"V": "\u2C7D",
"W": "\u1D42"
};
var map_sub = {
"(": "\u208D",
")": "\u208E",
"+": "\u208A",
"-": "\u208B",
"=": "\u208C",
"0": "\u2080",
"1": "\u2081",
"2": "\u2082",
"3": "\u2083",
"4": "\u2084",
"5": "\u2085",
"6": "\u2086",
"7": "\u2087",
"8": "\u2088",
"9": "\u2089",
"a": "\u2090",
"e": "\u2091",
"h": "\u2095",
"i": "\u1D62",
"j": "\u2C7C",
"k": "\u2096",
"l": "\u2097",
"m": "\u2098",
"n": "\u2099",
"o": "\u2092",
"p": "\u209A",
"r": "\u1D63",
"s": "\u209B",
"t": "\u209C",
"u": "\u1D64",
"v": "\u1D65",
"x": "\u2093"
};
var brackets = {
"left<": "\u3008",
"right>": "\u3009",
"langle": "\u3008",
"rangle": "\u3009",
"lvert": "|",
"rvert": "|",
"vert": "|"
};
var mathbb = {
"0": "\u{1D7D8}",
"1": "\u{1D7D9}",
"2": "\u{1D7DA}",
"3": "\u{1D7DB}",
"4": "\u{1D7DC}",
"5": "\u{1D7DD}",
"6": "\u{1D7DE}",
"7": "\u{1D7DF}",
"8": "\u{1D7E0}",
"9": "\u{1D7E1}",
"A": "\u{1D538}",
"B": "\u{1D539}",
"C": "\u2102",
"D": "\u{1D53B}",
"E": "\u{1D53C}",
"F": "\u{1D53D}",
"G": "\u{1D53E}",
"H": "\u210D",
"I": "\u{1D540}",
"J": "\u{1D541}",
"K": "\u{1D542}",
"L": "\u{1D543}",
"M": "\u{1D544}",
"N": "\u2115",
"O": "\u{1D546}",
"P": "\u2119",
"Q": "\u211A",
"R": "\u211D",
"S": "\u{1D54A}",
"T": "\u{1D54B}",
"U": "\u{1D54C}",
"V": "\u{1D54D}",
"W": "\u{1D54E}",
"X": "\u{1D54F}",
"Y": "\u{1D550}",
"Z": "\u2124",
"a": "\u{1D552}",
"b": "\u{1D553}",
"c": "\u{1D554}",
"d": "\u{1D555}",
"e": "\u{1D556}",
"f": "\u{1D557}",
"g": "\u{1D558}",
"h": "\u{1D559}",
"i": "\u{1D55A}",
"j": "\u{1D55B}",
"k": "\u{1D55C}",
"l": "\u{1D55D}",
"m": "\u{1D55E}",
"n": "\u{1D55F}",
"o": "\u{1D560}",
"p": "\u{1D561}",
"q": "\u{1D562}",
"r": "\u{1D563}",
"s": "\u{1D564}",
"t": "\u{1D565}",
"u": "\u{1D566}",
"v": "\u{1D567}",
"w": "\u{1D568}",
"x": "\u{1D569}",
"y": "\u{1D56A}",
"z": "\u{1D56B}"
};
var mathscrcal = {
"A": "\u{1D4D0}",
"B": "\u{1D4D1}",
"C": "\u{1D4D2}",
"D": "\u{1D4D3}",
"E": "\u{1D4D4}",
"F": "\u{1D4D5}",
"G": "\u{1D4D6}",
"H": "\u{1D4D7}",
"I": "\u{1D4D8}",
"J": "\u{1D4D9}",
"K": "\u{1D4DA}",
"L": "\u{1D4DB}",
"M": "\u{1D4DC}",
"N": "\u{1D4DD}",
"O": "\u{1D4DE}",
"P": "\u{1D4DF}",
"Q": "\u{1D4E0}",
"R": "\u{1D4E1}",
"S": "\u{1D4E2}",
"T": "\u{1D4E3}",
"U": "\u{1D4E4}",
"V": "\u{1D4E5}",
"W": "\u{1D4E6}",
"X": "\u{1D4E7}",
"Y": "\u{1D4E8}",
"Z": "\u{1D4E9}"
};
// src/editor_extensions/conceal.ts
var ConcealWidget = class extends import_view5.WidgetType {
constructor(symbol, className, elementType) {
super();
this.symbol = symbol;
this.className = className ? className : "";
this.elementType = elementType ? elementType : "span";
}
eq(other) {
return other.symbol == this.symbol && other.elementType === this.elementType;
}
toDOM() {
const span = document.createElement(this.elementType);
span.className = "cm-math " + this.className;
span.textContent = this.symbol;
return span;
}
ignoreEvent() {
return false;
}
};
var TextWidget = class extends import_view5.WidgetType {
constructor(symbol) {
super();
this.symbol = symbol;
}
eq(other) {
return other.symbol == this.symbol;
}
toDOM() {
const span = document.createElement("span");
span.className = "cm-math";
span.textContent = this.symbol;
return span;
}
ignoreEvent() {
return false;
}
};
function selectionAndRangeOverlap(selection, rangeFrom, rangeTo) {
for (const range of selection.ranges) {
if (range.from <= rangeTo && range.to >= rangeFrom) {
return true;
}
}
return false;
}
function escapeRegex(regex) {
const escapeChars = ["\\", "(", ")", "+", "-", "[", "]", "{", "}"];
for (const escapeChar of escapeChars) {
regex = regex.replaceAll(escapeChar, "\\" + escapeChar);
}
return regex;
}
function concealSymbols(eqn, prefix, suffix, symbolMap, className) {
const symbolNames = Object.keys(symbolMap);
const regexStr = prefix + "(" + escapeRegex(symbolNames.join("|")) + ")" + suffix;
const symbolRegex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(symbolRegex)];
const concealments = [];
for (const match of matches) {
const symbol = match[1];
concealments.push({ start: match.index, end: match.index + match[0].length, replacement: symbolMap[symbol], class: className });
}
return concealments;
}
function concealModifier(eqn, modifier, combiningCharacter) {
const regexStr = "\\\\" + modifier + "{([A-Za-z])}";
const symbolRegex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(symbolRegex)];
const concealments = [];
for (const match of matches) {
const symbol = match[1];
concealments.push({ start: match.index, end: match.index + match[0].length, replacement: symbol + combiningCharacter, class: "latex-suite-unicode" });
}
return concealments;
}
function concealSupSub(eqn, superscript, symbolMap) {
const prefix = superscript ? "\\^" : "_";
const regexStr = prefix + "{([A-Za-z0-9\\()\\[\\]/+-=<>':;\\\\ *]+)}";
const regex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(regex)];
const concealments = [];
for (const match of matches) {
const exponent = match[1];
const elementType = superscript ? "sup" : "sub";
const symbolNames = Object.keys(symbolMap);
const symbolRegexStr = "\\\\(" + escapeRegex(symbolNames.join("|")) + ")";
const symbolRegex = new RegExp(symbolRegexStr, "g");
const replacement = exponent.replace(symbolRegex, (a, b) => {
return symbolMap[b];
});
concealments.push({ start: match.index, end: match.index + match[0].length, replacement, class: "cm-number", elementType });
}
return concealments;
}
function concealBoldMathBbMathRm(eqn, symbolMap) {
const regexStr = "\\\\(mathbf|boldsymbol|mathbb|mathrm){([A-Za-z0-9]+)}";
const regex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(regex)];
const concealments = [];
for (const match of matches) {
const type = match[1];
const value = match[2];
const start2 = match.index;
const end2 = start2 + match[0].length;
if (type === "mathbf" || type === "boldsymbol") {
concealments.push({ start: start2, end: end2, replacement: value, class: "cm-concealed-bold cm-variable-1" });
} else if (type === "mathbb") {
const letters = Array.from(value);
const replacement = letters.map((el) => symbolMap[el]).join("");
concealments.push({ start: start2, end: end2, replacement });
} else {
concealments.push({ start: start2, end: end2, replacement: value, class: "cm-concealed-mathrm cm-variable-2" });
}
}
return concealments;
}
function concealText(eqn) {
const regexStr = "\\\\text{([A-Za-z0-9-.!?() ]+)}";
const regex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(regex)];
const concealments = [];
for (const match of matches) {
const value = match[1];
const start2 = match.index;
const end2 = start2 + match[0].length;
concealments.push({ start: start2, end: end2, replacement: value, class: "cm-concealed-mathrm cm-variable-2" });
}
return concealments;
}
function concealOperators(eqn, symbols) {
const regexStr = "\\\\(" + symbols.join("|") + ")";
const regex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(regex)];
const concealments = [];
for (const match of matches) {
const value = match[1];
const start2 = match.index;
const end2 = start2 + match[0].length;
concealments.push({ start: start2, end: end2, replacement: value, class: "cm-concealed-mathrm cm-variable-2" });
}
return concealments;
}
function concealAtoZ(eqn, prefix, suffix, symbolMap, className) {
const regexStr = prefix + "([A-Z]+)" + suffix;
const symbolRegex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(symbolRegex)];
const concealments = [];
for (const match of matches) {
const symbol = match[1];
const letters = Array.from(symbol);
const replacement = letters.map((el) => symbolMap[el]).join("");
concealments.push({ start: match.index, end: match.index + match[0].length, replacement, class: className });
}
return concealments;
}
function concealBraKet(eqn, selection, eqnStartBound) {
const langle = "\u3008";
const rangle = "\u3009";
const vert = "|";
const regexStr = "\\\\(braket|bra|ket){";
const symbolRegex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(symbolRegex)];
const concealments = [];
for (const match of matches) {
const loc = match.index + match[0].length;
const j = findMatchingBracket(eqn, loc - 1, "{", "}", false);
if (j === -1)
continue;
const start2 = match.index;
const end2 = start2 + match[0].length;
if (selectionAndRangeOverlap(selection, eqnStartBound + start2, eqnStartBound + end2))
continue;
if (selectionAndRangeOverlap(selection, eqnStartBound + j, eqnStartBound + j + 1))
continue;
const type = match[1];
const left2 = type === "ket" ? vert : langle;
const right2 = type === "bra" ? vert : rangle;
concealments.push({ start: start2, end: end2 - 1, replacement: "" });
concealments.push({ start: end2 - 1, end: end2, replacement: left2, class: "cm-bracket" });
concealments.push({ start: j, end: j + 1, replacement: right2, class: "cm-bracket" });
}
return concealments;
}
function concealFraction(eqn, selection, eqnStartBound) {
const regexStr = "\\\\(frac){";
const symbolRegex = new RegExp(regexStr, "g");
const matches = [...eqn.matchAll(symbolRegex)];
const concealments = [];
for (const match of matches) {
const loc = match.index + match[0].length;
const j = findMatchingBracket(eqn, loc - 1, "{", "}", false);
if (j === -1)
continue;
const charAfterFirstBracket = eqn.charAt(j + 1);
if (charAfterFirstBracket != "{")
continue;
const k = findMatchingBracket(eqn, j + 1, "{", "}", false);
if (k === -1)
continue;
const start2 = match.index;
const end2 = start2 + match[0].length;
if (selectionAndRangeOverlap(selection, eqnStartBound + start2, eqnStartBound + end2))
continue;
if (selectionAndRangeOverlap(selection, eqnStartBound + j, eqnStartBound + j + 2))
continue;
if (selectionAndRangeOverlap(selection, eqnStartBound + k, eqnStartBound + k + 1))
continue;
concealments.push({ start: start2, end: end2 - 1, replacement: "" });
concealments.push({ start: end2 - 1, end: end2, replacement: "(", class: "cm-bracket" });
concealments.push({ start: j, end: j + 1, replacement: ")", class: "cm-bracket" });
concealments.push({ start: j + 1, end: j + 1, replacement: "/", class: "cm-bracket" });
concealments.push({ start: j + 1, end: j + 2, replacement: "(", class: "cm-bracket" });
concealments.push({ start: k, end: k + 1, replacement: ")", class: "cm-bracket" });
}
return concealments;
}
function conceal(view) {
const widgets = [];
const selection = view.state.selection;
for (const { from, to } of view.visibleRanges) {
(0, import_language5.syntaxTree)(view.state).iterate({
from,
to,
enter: (node) => {
const type = node.type;
const to2 = node.to;
if (!(type.name.contains("begin") && type.name.contains("math"))) {
return;
}
const bounds = getEquationBounds(view, to2 + 1);
if (!bounds)
return;
const eqn = view.state.doc.sliceString(bounds.start, bounds.end);
const ALL_SYMBOLS = __spreadValues(__spreadValues({}, greek), cmd_symbols);
const concealments = [
...concealSymbols(eqn, "\\^", "", map_super),
...concealSymbols(eqn, "_", "", map_sub),
...concealSymbols(eqn, "\\\\frac", "", fractions),
...concealSymbols(eqn, "\\\\", "", ALL_SYMBOLS),
...concealSupSub(eqn, true, ALL_SYMBOLS),
...concealSupSub(eqn, false, ALL_SYMBOLS),
...concealModifier(eqn, "hat", "\u0302"),
...concealModifier(eqn, "dot", "\u0307"),
...concealModifier(eqn, "ddot", "\u0308"),
...concealModifier(eqn, "overline", "\u0304"),
...concealModifier(eqn, "bar", "\u0304"),
...concealSymbols(eqn, "\\\\", "", brackets, "cm-bracket"),
...concealAtoZ(eqn, "\\\\mathcal{", "}", mathscrcal),
...concealBoldMathBbMathRm(eqn, mathbb),
...concealText(eqn),
...concealBraKet(eqn, selection, bounds.start),
...concealFraction(eqn, selection, bounds.start),
...concealOperators(eqn, operators)
];
for (const concealment of concealments) {
const start2 = bounds.start + concealment.start;
const end2 = bounds.start + concealment.end;
const symbol = concealment.replacement;
if (selectionAndRangeOverlap(selection, start2, end2))
continue;
if (start2 === end2) {
widgets.push(import_view5.Decoration.widget({
widget: new TextWidget(symbol),
block: false
}).range(start2, end2));
} else {
widgets.push(import_view5.Decoration.replace({
widget: new ConcealWidget(symbol, concealment.class, concealment.elementType),
inclusive: false,
block: false
}).range(start2, end2));
}
}
}
});
}
return import_view5.Decoration.set(widgets, true);
}
var concealPlugin = import_view5.ViewPlugin.fromClass(class {
constructor(view) {
this.decorations = conceal(view);
}
update(update) {
if (update.docChanged || update.viewportChanged || update.selectionSet)
this.decorations = conceal(update.view);
}
}, { decorations: (v) => v.decorations });
// src/editor_extensions/highlight_brackets.ts
var import_view6 = __toModule(require("@codemirror/view"));
var import_state4 = __toModule(require("@codemirror/state"));
var import_language6 = __toModule(require("@codemirror/language"));
var Ncolors = 3;
function getHighlightBracketMark(pos, className) {
return import_view6.Decoration.mark({
inclusive: true,
attributes: {},
class: className
}).range(pos, pos + 1);
}
function colorPairedBrackets(view) {
const widgets = [];
for (const { from, to } of view.visibleRanges) {
(0, import_language6.syntaxTree)(view.state).iterate({
from,
to,
enter: (node) => {
const type = node.type;
const to2 = node.to;
if (!(type.name.contains("begin") && type.name.contains("math"))) {
return;
}
const bounds = getEquationBounds(view, to2 + 1);
if (!bounds)
return;
const eqn = view.state.doc.sliceString(bounds.start, bounds.end);
const openBrackets = ["{", "[", "("];
const closeBrackets2 = ["}", "]", ")"];
const bracketsStack = [];
const bracketsPosStack = [];
for (let i = 0; i < eqn.length; i++) {
const char = eqn.charAt(i);
if (openBrackets.contains(char)) {
bracketsStack.push(char);
bracketsPosStack.push(i);
} else if (closeBrackets2.contains(char)) {
const lastBracket = bracketsStack.at(-1);
if (getCloseBracket(lastBracket) === char) {
bracketsStack.pop();
const lastBracketPos = bracketsPosStack.pop();
const depth = bracketsStack.length % Ncolors;
const className = "latex-suite-color-bracket-" + depth;
const j = lastBracketPos + bounds.start;
const k = i + bounds.start;
widgets.push(getHighlightBracketMark(j, className));
widgets.push(getHighlightBracketMark(k, className));
}
}
}
}
});
}
return import_view6.Decoration.set(widgets, true);
}
function highlightCursorBrackets(view) {
const widgets = [];
const selection = view.state.selection;
const ranges = selection.ranges;
const text = view.state.doc.toString();
if (!isWithinEquation(view)) {
return import_view6.Decoration.set(widgets, true);
}
const bounds = getEquationBounds(view, selection.main.to);
if (!bounds)
return import_view6.Decoration.set(widgets, true);
const eqn = view.state.doc.sliceString(bounds.start, bounds.end);
const openBrackets = ["{", "[", "("];
const brackets2 = ["{", "[", "(", "}", "]", ")"];
let done = false;
for (const range of ranges) {
for (let i = range.to; i > range.from - 2; i--) {
const char = text.charAt(i);
if (!brackets2.contains(char))
continue;
let openBracket, closeBracket;
let backwards = false;
if (openBrackets.contains(char)) {
openBracket = char;
closeBracket = getCloseBracket(openBracket);
} else {
closeBracket = char;
openBracket = getOpenBracket(char);
backwards = true;
}
let j = findMatchingBracket(eqn, i - bounds.start, openBracket, closeBracket, backwards);
if (j === -1)
continue;
j = j + bounds.start;
widgets.push(getHighlightBracketMark(i, "latex-suite-highlighted-bracket"));
widgets.push(getHighlightBracketMark(j, "latex-suite-highlighted-bracket"));
done = true;
break;
}
if (done)
break;
if (range.empty) {
const pos = range.from - 1;
const result = getEnclosingBracketsPos(view, pos);
if (result === -1)
continue;
widgets.push(getHighlightBracketMark(result.left, "latex-suite-highlighted-bracket"));
widgets.push(getHighlightBracketMark(result.right, "latex-suite-highlighted-bracket"));
done = true;
break;
}
if (done)
break;
}
return import_view6.Decoration.set(widgets, true);
}
var colorPairedBracketsPlugin = import_view6.ViewPlugin.fromClass(class {
constructor(view) {
this.decorations = colorPairedBrackets(view);
}
update(update) {
if (update.docChanged || update.viewportChanged) {
this.decorations = colorPairedBrackets(update.view);
}
}
}, { decorations: (v) => v.decorations });
var colorPairedBracketsPluginLowestPrec = import_state4.Prec.lowest(colorPairedBracketsPlugin.extension);
var highlightCursorBracketsPlugin = import_view6.ViewPlugin.fromClass(class {
constructor(view) {
this.decorations = highlightCursorBrackets(view);
}
update(update) {
if (update.docChanged || update.selectionSet)
this.decorations = highlightCursorBrackets(update.view);
}
}, { decorations: (v) => v.decorations });
// src/editor_extensions/inline_math_tooltip.ts
var import_view7 = __toModule(require("@codemirror/view"));
var import_state5 = __toModule(require("@codemirror/state"));
var import_obsidian2 = __toModule(require("obsidian"));
var cursorTooltipField = import_state5.StateField.define({
create: getCursorTooltips,
update(tooltips2, tr) {
if (!tr.docChanged && !tr.selection)
return tooltips2;
return getCursorTooltips(tr.state);
},
provide: (f) => import_view7.showTooltip.computeN([f], (state) => state.field(f))
});
function getCursorTooltips(state) {
const isInsideInlineEqn = isWithinEquation(state) && isWithinInlineEquationState(state);
let shouldShowTooltip = isInsideInlineEqn;
let isTouchingInlineEqn;
let pos = state.selection.main.from;
if (!isInsideInlineEqn) {
isTouchingInlineEqn = isTouchingInlineEquation(state, pos - 1);
if (isTouchingInlineEqn != 0) {
pos += isTouchingInlineEqn;
shouldShowTooltip = true;
}
}
if (shouldShowTooltip) {
const bounds = getEquationBounds(state, pos);
if (!bounds)
return [];
if (bounds.start === bounds.end)
return [];
const eqn = state.sliceDoc(bounds.start, bounds.end);
return [
{
pos: bounds.start,
above: true,
strictSide: true,
arrow: true,
create: () => {
let dom = document.createElement("div");
dom.className = "cm-tooltip-cursor";
import_obsidian2.MarkdownRenderer.renderMarkdown("$" + eqn + "$", dom, "", null);
return { dom };
}
}
];
} else {
return [];
}
}
var cursorTooltipBaseTheme = import_view7.EditorView.baseTheme({
".cm-tooltip.cm-tooltip-cursor": {
backgroundColor: "var(--background-primary)",
color: "var(--text-normal)",
border: "1px solid var(--background-modifier-border)",
padding: "2px 7px",
borderRadius: "6px",
"& .cm-tooltip-arrow:before": {
borderTopColor: "var(--background-modifier-border)"
},
"& .cm-tooltip-arrow:after": {
borderTopColor: "var(--background-primary)"
},
"& p": {
marginTop: "2px",
marginBottom: "2px"
}
}
});
// src/ui/file_suggest.ts
var import_obsidian4 = __toModule(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(element) {
return element ? (element.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 element = state.elements[name];
if (!isHTMLElement(element) || !getNodeName(element)) {
return;
}
Object.assign(element.style, style);
Object.keys(attributes).forEach(function(name2) {
var value = attributes[name2];
if (value === false) {
element.removeAttribute(name2);
} else {
element.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 element = 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(element) || !getNodeName(element)) {
return;
}
Object.assign(element.style, style);
Object.keys(attributes).forEach(function(attribute) {
element.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/dom-utils/getBoundingClientRect.js
function getBoundingClientRect(element, includeScale) {
if (includeScale === void 0) {
includeScale = false;
}
var rect = element.getBoundingClientRect();
var scaleX = 1;
var scaleY = 1;
if (isHTMLElement(element) && includeScale) {
var offsetHeight = element.offsetHeight;
var offsetWidth = element.offsetWidth;
if (offsetWidth > 0) {
scaleX = round(rect.width) / offsetWidth || 1;
}
if (offsetHeight > 0) {
scaleY = round(rect.height) / offsetHeight || 1;
}
}
return {
width: rect.width / scaleX,
height: rect.height / scaleY,
top: rect.top / scaleY,
right: rect.right / scaleX,
bottom: rect.bottom / scaleY,
left: rect.left / scaleX,
x: rect.left / scaleX,
y: rect.top / scaleY
};
}
// node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js
function getLayoutRect(element) {
var clientRect = getBoundingClientRect(element);
var width = element.offsetWidth;
var height = element.offsetHeight;
if (Math.abs(clientRect.width - width) <= 1) {
width = clientRect.width;
}
if (Math.abs(clientRect.height - height) <= 1) {
height = clientRect.height;
}
return {
x: element.offsetLeft,
y: element.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 getComputedStyle(element) {
return getWindow(element).getComputedStyle(element);
}
// node_modules/@popperjs/core/lib/dom-utils/isTableElement.js
function isTableElement(element) {
return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
}
// node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js
function getDocumentElement(element) {
return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
}
// node_modules/@popperjs/core/lib/dom-utils/getParentNode.js
function getParentNode(element) {
if (getNodeName(element) === "html") {
return element;
}
return element.assignedSlot || element.parentNode || (isShadowRoot(element) ? element.host : null) || getDocumentElement(element);
}
// node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js
function getTrueOffsetParent(element) {
if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
return null;
}
return element.offsetParent;
}
function getContainingBlock(element) {
var isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") !== -1;
var isIE = navigator.userAgent.indexOf("Trident") !== -1;
if (isIE && isHTMLElement(element)) {
var elementCss = getComputedStyle(element);
if (elementCss.position === "fixed") {
return null;
}
}
var currentNode = getParentNode(element);
if (isShadowRoot(currentNode)) {
currentNode = currentNode.host;
}
while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
var css = getComputedStyle(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(element) {
var window2 = getWindow(element);
var offsetParent = getTrueOffsetParent(element);
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
offsetParent = getTrueOffsetParent(offsetParent);
}
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static")) {
return window2;
}
return offsetParent || getContainingBlock(element) || 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 offset2 = within(min2, center, max2);
var axisProp = axis;
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - 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 (true) {
if (!isHTMLElement(arrowElement)) {
console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', "To use an SVG arrow, wrap it in an HTMLElement that will be used as", "the arrow."].join(" "));
}
}
if (!contains(state.elements.popper, arrowElement)) {
if (true) {
console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', "element."].join(" "));
}
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) {
var x = _ref.x, y = _ref.y;
var win = window;
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 (getComputedStyle(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 : 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 : offsetParent[widthProp];
x -= offsetX - popperRect.width;
x *= gpuAcceleration ? 1 : -1;
}
}
var commonStyles = Object.assign({
position
}, adaptive && unsetSides);
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
x,
y
}) : {
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;
if (true) {
var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || "";
if (adaptive && ["transform", "top", "right", "bottom", "left"].some(function(property) {
return transitionProperty.indexOf(property) >= 0;
})) {
console.warn(["Popper: Detected CSS transitions on at least one of the following", 'CSS properties: "transform", "top", "right", "bottom", "left".', "\n\n", 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', "for smooth transitions, or remove these properties from the CSS", "transition declaration on the popper element if only transitioning", "opacity or background-color for example.", "\n\n", "We recommend using the popper element as a wrapper around an inner", "element that can have any CSS property transitioned for animations."].join(" "));
}
}
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, instance = _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", instance.update, passive);
});
}
if (resize) {
window2.addEventListener("resize", instance.update, passive);
}
return function() {
if (scroll) {
scrollParents.forEach(function(scrollParent) {
scrollParent.removeEventListener("scroll", instance.update, passive);
});
}
if (resize) {
window2.removeEventListener("resize", instance.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(element) {
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
}
// node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js
function getViewportRect(element) {
var win = getWindow(element);
var html = getDocumentElement(element);
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;
if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
x = visualViewport.offsetLeft;
y = visualViewport.offsetTop;
}
}
return {
width,
height,
x: x + getWindowScrollBarX(element),
y
};
}
// node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js
function getDocumentRect(element) {
var _element$ownerDocumen;
var html = getDocumentElement(element);
var winScroll = getWindowScroll(element);
var body = (_element$ownerDocumen = element.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(element);
var y = -winScroll.scrollTop;
if (getComputedStyle(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(element) {
var _getComputedStyle = getComputedStyle(element), 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(element, list) {
var _element$ownerDocumen;
if (list === void 0) {
list = [];
}
var scrollParent = getScrollParent(element);
var isBody = scrollParent === ((_element$ownerDocumen = element.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 : 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(element) {
var rect = getBoundingClientRect(element);
rect.top = rect.top + element.clientTop;
rect.left = rect.left + element.clientLeft;
rect.bottom = rect.top + element.clientHeight;
rect.right = rect.left + element.clientWidth;
rect.width = element.clientWidth;
rect.height = element.clientHeight;
rect.x = rect.left;
rect.y = rect.top;
return rect;
}
function getClientRectFromMixedType(element, clippingParent) {
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
}
function getClippingParents(element) {
var clippingParents2 = listScrollParents(getParentNode(element));
var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle(element).position) >= 0;
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
if (!isElement(clipperElement)) {
return [];
}
return clippingParents2.filter(function(clippingParent) {
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
});
}
function getClippingRect(element, boundary, rootBoundary) {
var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
var firstClippingParent = clippingParents2[0];
var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
var rect = getClientRectFromMixedType(element, clippingParent);
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(element, firstClippingParent));
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, element = _ref.element, placement = _ref.placement;
var basePlacement = placement ? getBasePlacement(placement) : null;
var variation = placement ? getVariation(placement) : null;
var commonX = reference2.x + reference2.width / 2 - element.width / 2;
var commonY = reference2.y + reference2.height / 2 - element.height / 2;
var offsets;
switch (basePlacement) {
case top:
offsets = {
x: commonX,
y: reference2.y - element.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 - element.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 - element[len] / 2);
break;
case end:
offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[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$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 element = state.elements[altBoundary ? altContext : elementContext];
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
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 offset2 = 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] += offset2[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;
if (true) {
console.error(["Popper: The `allowedAutoPlacements` option did not allow any", "placements. Ensure the `placement` option matches the variation", "of the allowed placements.", 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(" "));
}
}
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 = 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, offset2) {
var basePlacement = getBasePlacement(placement);
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
placement
})) : offset2, 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 offset(_ref2) {
var state = _ref2.state, options = _ref2.options, name = _ref2.name;
var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
var data = placements.reduce(function(acc, placement) {
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
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: offset
};
// 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 offset2 = popperOffsets2[mainAxis];
var min2 = offset2 + overflow[mainSide];
var max2 = offset2 - 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 = offset2 + minOffset - offsetModifierValue - clientOffset;
var tetherMax = offset2 + maxOffset - offsetModifierValue;
var preventedOffset = within(tether ? min(min2, tetherMin) : min2, offset2, tether ? max(max2, tetherMax) : max2);
popperOffsets2[mainAxis] = preventedOffset;
data[mainAxis] = preventedOffset - offset2;
}
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(element) {
return {
scrollLeft: element.scrollLeft,
scrollTop: element.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(element) {
var rect = element.getBoundingClientRect();
var scaleX = round(rect.width) / element.offsetWidth || 1;
var scaleY = round(rect.height) / element.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);
var scroll = {
scrollLeft: 0,
scrollTop: 0
};
var offsets = {
x: 0,
y: 0
};
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
if (getNodeName(offsetParent) !== "body" || 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 = new Map();
var visited = 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/format.js
function format(str) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return [].concat(args).reduce(function(p, c) {
return p.replace(/%s/, c);
}, str);
}
// node_modules/@popperjs/core/lib/utils/validateModifiers.js
var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
var VALID_PROPERTIES = ["name", "enabled", "phase", "fn", "effect", "requires", "options"];
function validateModifiers(modifiers) {
modifiers.forEach(function(modifier) {
[].concat(Object.keys(modifier), VALID_PROPERTIES).filter(function(value, index, self2) {
return self2.indexOf(value) === index;
}).forEach(function(key) {
switch (key) {
case "name":
if (typeof modifier.name !== "string") {
console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', '"' + String(modifier.name) + '"'));
}
break;
case "enabled":
if (typeof modifier.enabled !== "boolean") {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', '"' + String(modifier.enabled) + '"'));
}
break;
case "phase":
if (modifierPhases.indexOf(modifier.phase) < 0) {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(", "), '"' + String(modifier.phase) + '"'));
}
break;
case "fn":
if (typeof modifier.fn !== "function") {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', '"' + String(modifier.fn) + '"'));
}
break;
case "effect":
if (modifier.effect != null && typeof modifier.effect !== "function") {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', '"' + String(modifier.fn) + '"'));
}
break;
case "requires":
if (modifier.requires != null && !Array.isArray(modifier.requires)) {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', '"' + String(modifier.requires) + '"'));
}
break;
case "requiresIfExists":
if (!Array.isArray(modifier.requiresIfExists)) {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', '"' + String(modifier.requiresIfExists) + '"'));
}
break;
case "options":
case "data":
break;
default:
console.error('PopperJS: an invalid property has been provided to the "' + modifier.name + '" modifier, valid properties are ' + VALID_PROPERTIES.map(function(s) {
return '"' + s + '"';
}).join(", ") + '; but "' + key + '" was provided.');
}
modifier.requires && modifier.requires.forEach(function(requirement) {
if (modifiers.find(function(mod) {
return mod.name === requirement;
}) == null) {
console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
}
});
});
});
}
// node_modules/@popperjs/core/lib/utils/uniqueBy.js
function uniqueBy(arr, fn2) {
var identifiers = new Set();
return arr.filter(function(item) {
var identifier = fn2(item);
if (!identifiers.has(identifier)) {
identifiers.add(identifier);
return true;
}
});
}
// 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 INVALID_ELEMENT_ERROR = "Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.";
var INFINITE_LOOP_ERROR = "Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.";
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(element) {
return !(element && typeof element.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 instance = {
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;
});
if (true) {
var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function(_ref) {
var name = _ref.name;
return name;
});
validateModifiers(modifiers);
if (getBasePlacement(state.options.placement) === auto) {
var flipModifier = state.orderedModifiers.find(function(_ref2) {
var name = _ref2.name;
return name === "flip";
});
if (!flipModifier) {
console.error(['Popper: "auto" placements require the "flip" modifier be', "present and enabled to work."].join(" "));
}
}
var _getComputedStyle = getComputedStyle(popper2), marginTop = _getComputedStyle.marginTop, marginRight = _getComputedStyle.marginRight, marginBottom = _getComputedStyle.marginBottom, marginLeft = _getComputedStyle.marginLeft;
if ([marginTop, marginRight, marginBottom, marginLeft].some(function(margin) {
return parseFloat(margin);
})) {
console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', "between the popper and its reference element or boundary.", "To replicate margin, use the `offset` modifier, as well as", "the `padding` option in the `preventOverflow` and `flip`", "modifiers."].join(" "));
}
}
runModifierEffects();
return instance.update();
},
forceUpdate: function forceUpdate() {
if (isDestroyed) {
return;
}
var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
if (!areValidElements(reference3, popper3)) {
if (true) {
console.error(INVALID_ELEMENT_ERROR);
}
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);
});
var __debug_loops__ = 0;
for (var index = 0; index < state.orderedModifiers.length; index++) {
if (true) {
__debug_loops__ += 1;
if (__debug_loops__ > 100) {
console.error(INFINITE_LOOP_ERROR);
break;
}
}
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
}) || state;
}
}
},
update: debounce(function() {
return new Promise(function(resolve) {
instance.forceUpdate();
resolve(state);
});
}),
destroy: function destroy() {
cleanupModifierEffects();
isDestroyed = true;
}
};
if (!areValidElements(reference2, popper2)) {
if (true) {
console.error(INVALID_ELEMENT_ERROR);
}
return instance;
}
instance.setOptions(options).then(function(state2) {
if (!isDestroyed && options.onFirstUpdate) {
options.onFirstUpdate(state2);
}
});
function runModifierEffects() {
state.orderedModifiers.forEach(function(_ref3) {
var name = _ref3.name, _ref3$options = _ref3.options, options2 = _ref3$options === void 0 ? {} : _ref3$options, effect4 = _ref3.effect;
if (typeof effect4 === "function") {
var cleanupFn = effect4({
state,
name,
instance,
options: options2
});
var noopFn = function noopFn2() {
};
effectCleanupFns.push(cleanupFn || noopFn);
}
});
}
function cleanupModifierEffects() {
effectCleanupFns.forEach(function(fn2) {
return fn2();
});
effectCleanupFns = [];
}
return instance;
};
}
// 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.ts
var import_obsidian3 = __toModule(require("obsidian"));
var wrapAround = (value, size) => {
return (value % size + size) % size;
};
var Suggest = class {
constructor(owner, containerEl, scope) {
this.owner = owner;
this.containerEl = containerEl;
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_obsidian3.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 }) => {
const targetWidth = `${state.rects.reference.width}px`;
if (state.styles.popper.width === targetWidth) {
return;
}
state.styles.popper.width = targetWidth;
instance.update();
},
phase: "beforeWrite",
requires: ["computeStyles"]
}
]
});
}
close() {
this.app.keymap.popScope(this.scope);
this.suggest.setSuggestions([]);
this.popper.destroy();
this.suggestEl.detach();
}
};
// src/ui/file_suggest.ts
var FileSuggest = class extends TextInputSuggest {
getSuggestions(inputStr) {
const files = [];
const lowerCaseInputStr = inputStr.toLowerCase();
import_obsidian4.Vault.recurseChildren(this.app.vault.getRoot(), (file) => {
if (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/snippets/snippet_helper_functions.ts
var import_obsidian5 = __toModule(require("obsidian"));
var import_commands2 = __toModule(require("@codemirror/commands"));
// src/snippets/marker_state_field.ts
var import_state6 = __toModule(require("@codemirror/state"));
var import_view8 = __toModule(require("@codemirror/view"));
var addMark = import_state6.StateEffect.define();
var removeMark = import_state6.StateEffect.define();
var clearMarks = import_state6.StateEffect.define();
var removeMarkBySpecAttribute = import_state6.StateEffect.define();
var startSnippet = import_state6.StateEffect.define();
var endSnippet = import_state6.StateEffect.define();
var undidStartSnippet = import_state6.StateEffect.define();
var undidEndSnippet = import_state6.StateEffect.define();
var markerStateField = import_state6.StateField.define({
create() {
return import_view8.Decoration.none;
},
update(value, tr) {
value = value.map(tr.changes);
for (const effect4 of tr.effects) {
if (effect4.is(addMark)) {
value = value.update({ add: [effect4.value] });
} else if (effect4.is(removeMark)) {
value = value.update({ filter: (from, to, value2) => {
return !value2.eq(effect4.value.value);
} });
} else if (effect4.is(clearMarks)) {
value = value.update({ filter: () => false });
} else if (effect4.is(removeMarkBySpecAttribute)) {
value = value.update({ filter: (from, to, ref) => ref.spec[effect4.value.attribute] !== effect4.value.reference });
}
}
return value;
},
provide: (f) => import_view8.EditorView.decorations.from(f)
});
// src/snippets/snippet_helper_functions.ts
var import_json5 = __toModule(require_dist());
function sortSnippets(snippets2) {
function compareTriggerLength(a, b) {
const aTriggerLength = a.trigger.length;
const bTriggerLength = b.trigger.length;
if (aTriggerLength < bTriggerLength) {
return 1;
}
if (aTriggerLength > bTriggerLength) {
return -1;
}
return 0;
}
snippets2.sort(compareTriggerLength);
function compare(a, b) {
const aPriority = a.priority === void 0 ? 0 : a.priority;
const bPriority = b.priority === void 0 ? 0 : b.priority;
if (aPriority < bPriority) {
return 1;
}
if (aPriority > bPriority) {
return -1;
}
return 0;
}
snippets2.sort(compare);
}
function getSnippetsFromString(snippetsStr) {
const snippets2 = (0, import_json5.parse)(snippetsStr);
if (!validateSnippets(snippets2))
throw "Invalid snippet format.";
return snippets2;
}
function validateSnippets(snippets2) {
let valid = true;
for (const snippet of snippets2) {
if (!(snippet.trigger && snippet.replacement && snippet.options != void 0)) {
valid = false;
break;
}
}
return valid;
}
function isInFolder(file, dir) {
let cur = file.parent;
let cnt = 0;
while (cur && !cur.isRoot() && cnt < 100) {
if (cur.path === dir.path)
return true;
cur = cur.parent;
cnt++;
}
return false;
}
var snippetInvertedEffects = import_commands2.invertedEffects.of((tr) => {
const effects = [];
for (const effect4 of tr.effects) {
if (effect4.is(addMark)) {
effects.push(removeMark.of(effect4.value));
} else if (effect4.is(removeMark)) {
effects.push(addMark.of(effect4.value));
} else if (effect4.is(startSnippet)) {
effects.push(undidStartSnippet.of(null));
} else if (effect4.is(undidStartSnippet)) {
effects.push(startSnippet.of(null));
} else if (effect4.is(endSnippet)) {
effects.push(undidEndSnippet.of(null));
} else if (effect4.is(undidEndSnippet)) {
effects.push(endSnippet.of(null));
}
}
return effects;
});
function getSnippetsWithinFolder(folder) {
return __async(this, null, function* () {
let snippets2 = [];
for (const fileOrFolder of folder.children) {
if (fileOrFolder instanceof import_obsidian5.TFile) {
const content = yield this.app.vault.cachedRead(fileOrFolder);
try {
snippets2.push(...getSnippetsFromString(content));
} catch (e) {
console.log(`Failed to load snippet file ${fileOrFolder.path}:`, e);
new import_obsidian5.Notice(`Failed to load snippet file ${fileOrFolder.name}`);
}
;
} else {
const newSnippets = yield this.getSnippetsWithinFolder(fileOrFolder);
snippets2.push(...newSnippets);
}
}
return snippets2;
});
}
var debouncedSetSnippetsFromFileOrFolder = (0, import_obsidian5.debounce)((plugin, path) => __async(void 0, null, function* () {
if (!path)
path = plugin.settings.snippetsFileLocation;
let snippets2;
const fileOrFolder = plugin.app.vault.getAbstractFileByPath(path);
if (fileOrFolder instanceof import_obsidian5.TFolder) {
snippets2 = yield getSnippetsWithinFolder(fileOrFolder);
} else {
const content = yield plugin.app.vault.cachedRead(fileOrFolder);
snippets2 = yield getSnippetsFromString(content);
}
sortSnippets(snippets2);
plugin.snippets = snippets2;
new import_obsidian5.Notice("Successfully reloaded snippets.", 5e3);
}), 500, true);
// src/settings.ts
var DEFAULT_SETTINGS = {
snippets: DEFAULT_SNIPPETS,
snippetsEnabled: true,
loadSnippetsFromFile: false,
snippetsFileLocation: "",
concealEnabled: false,
colorPairedBracketsEnabled: true,
highlightCursorBracketsEnabled: true,
inlineMathPreviewEnabled: true,
autofractionEnabled: true,
autofractionExcludedEnvs: `[
["^{", "}"],
["\\\\pu{", "}"]
]`,
autofractionBreakingChars: "+-=",
matrixShortcutsEnabled: true,
matrixShortcutsEnvNames: "pmatrix, cases, align, bmatrix, Bmatrix, vmatrix, Vmatrix, array, matrix",
taboutEnabled: true,
autoEnlargeBrackets: true,
autoEnlargeBracketsTriggers: "sum, int, frac, prod",
wordDelimiters: "., -\\n:;!?\\/{}[]()=~"
};
var LatexSuiteSettingTab = class extends import_obsidian6.PluginSettingTab {
constructor(app, plugin) {
super(app, plugin);
this.plugin = plugin;
}
hide() {
var _a;
(_a = this.snippetsEditor) == null ? void 0 : _a.destroy();
}
display() {
const { containerEl } = this;
containerEl.empty();
containerEl.createEl("div", { text: "Snippets" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
new import_obsidian6.Setting(containerEl).setName("Enabled").setDesc("Whether snippets are enabled.").addToggle((toggle) => toggle.setValue(this.plugin.settings.snippetsEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.snippetsEnabled = value;
yield this.plugin.saveSettings();
})));
const snippetsSetting = new import_obsidian6.Setting(containerEl).setName("Snippets").setDesc('Enter snippets here. Remember to add a comma after each snippet, and escape all backslashes with an extra \\. Lines starting with "//" will be treated as comments and ignored.').setClass("snippets-text-area");
const customCSSWrapper = snippetsSetting.controlEl.createDiv("snippets-editor-wrapper");
const snippetsFooter = snippetsSetting.controlEl.createDiv("snippets-footer");
const validity = snippetsFooter.createDiv("snippets-editor-validity");
const validityIndicator = new import_obsidian6.ExtraButtonComponent(validity);
validityIndicator.setIcon("checkmark").extraSettingsEl.addClass("snippets-editor-validity-indicator");
const validityText = validity.createDiv("snippets-editor-validity-text");
validityText.addClass("setting-item-description");
validityText.style.padding = "0";
function updateValidityIndicator(success) {
validityIndicator.setIcon(success ? "checkmark" : "cross");
validityIndicator.extraSettingsEl.removeClass(success ? "invalid" : "valid");
validityIndicator.extraSettingsEl.addClass(success ? "valid" : "invalid");
validityText.setText(success ? "Saved" : "Invalid syntax. Changes not saved");
}
const extensions = basicSetup;
const change = import_view9.EditorView.updateListener.of((v) => __async(this, null, function* () {
if (v.docChanged) {
const value = v.state.doc.toString();
let success = true;
try {
this.plugin.setSnippets(value);
} catch (e) {
success = false;
}
updateValidityIndicator(success);
if (!success)
return;
this.plugin.settings.snippets = value;
yield this.plugin.saveSettings();
}
}));
extensions.push(change);
this.snippetsEditor = createSnippetsEditor(this.plugin.settings.snippets, extensions);
customCSSWrapper.appendChild(this.snippetsEditor.dom);
const buttonsDiv = snippetsFooter.createDiv("snippets-editor-buttons");
const reset = new import_obsidian6.ButtonComponent(buttonsDiv);
reset.setIcon("switch").setTooltip("Reset to default snippets").onClick(() => __async(this, null, function* () {
new ConfirmationModal(this.plugin.app, "Are you sure? This will delete any custom snippets you have written.", (button) => button.setButtonText("Reset to default snippets").setWarning(), () => __async(this, null, function* () {
this.snippetsEditor.setState(import_state7.EditorState.create({ doc: DEFAULT_SNIPPETS, extensions }));
updateValidityIndicator(true);
this.plugin.setSnippets(DEFAULT_SNIPPETS);
this.plugin.settings.snippets = DEFAULT_SNIPPETS;
yield this.plugin.saveSettings();
})).open();
}));
const remove = new import_obsidian6.ButtonComponent(buttonsDiv);
remove.setIcon("trash").setTooltip("Remove all snippets").onClick(() => __async(this, null, function* () {
new ConfirmationModal(this.plugin.app, "Are you sure? This will delete any custom snippets you have written.", (button) => button.setButtonText("Remove all snippets").setWarning(), () => __async(this, null, function* () {
const value = `[
]`;
this.snippetsEditor.setState(import_state7.EditorState.create({ doc: value, extensions }));
updateValidityIndicator(true);
this.plugin.setSnippets(value);
this.plugin.settings.snippets = value;
yield this.plugin.saveSettings();
})).open();
}));
let snippetsFileLocEl;
new import_obsidian6.Setting(containerEl).setName("Load snippets from file or folder").setDesc("Whether to load snippets from a specified file, or from all files within a folder (instead of from the plugin settings).").addToggle((toggle) => toggle.setValue(this.plugin.settings.loadSnippetsFromFile).onChange((value) => __async(this, null, function* () {
this.plugin.settings.loadSnippetsFromFile = value;
snippetsSetting.settingEl.toggleClass("hidden", value);
snippetsFileLocEl.toggleClass("hidden", !value);
if (value) {
debouncedSetSnippetsFromFileOrFolder(this.plugin);
} else {
this.plugin.setSnippets(this.plugin.settings.snippets);
}
yield this.plugin.saveSettings();
})));
const snippetsFileLoc = new import_obsidian6.Setting(containerEl).setName("Snippets file or folder location").setDesc("The file or folder to load snippets from.");
let inputEl;
snippetsFileLoc.addText((text) => {
text.setPlaceholder(DEFAULT_SETTINGS.snippetsFileLocation).setValue(this.plugin.settings.snippetsFileLocation).onChange((value) => __async(this, null, function* () {
this.plugin.settings.snippetsFileLocation = value;
debouncedSetSnippetsFromFileOrFolder(this.plugin);
yield this.plugin.saveSettings();
}));
inputEl = text.inputEl;
});
snippetsFileLocEl = snippetsFileLoc.settingEl;
new FileSuggest(this.app, inputEl);
const loadSnippetsFromFile = this.plugin.settings.loadSnippetsFromFile;
snippetsSetting.settingEl.toggleClass("hidden", loadSnippetsFromFile);
snippetsFileLocEl.toggleClass("hidden", !loadSnippetsFromFile);
containerEl.createEl("div", { text: "Conceal" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
const fragment = document.createDocumentFragment();
const line1 = document.createElement("div");
line1.setText("Make equations more readable by hiding LaTeX markup and instead displaying it in a pretty format.");
const line2 = document.createElement("div");
line2.setText("e.g. \\dot{x}^{2} + \\dot{y}^{2} will display as \u1E8B\xB2 + \u1E8F\xB2, and \\sqrt{ 1-\\beta^{2} } will display as \u221A{ 1-\u03B2\xB2 }.");
const line3 = document.createElement("div");
line3.setText("LaTeX beneath the cursor will be revealed.");
const space2 = document.createElement("br");
const line4 = document.createElement("div");
line4.setText("Disabled by default to not confuse new users. However, I recommend turning this on once you are comfortable with the plugin!");
fragment.append(line1, line2, line3, space2, line4);
new import_obsidian6.Setting(containerEl).setName("Enabled").setDesc(fragment).addToggle((toggle) => toggle.setValue(this.plugin.settings.concealEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.concealEnabled = value;
if (value) {
this.plugin.enableExtension(concealPlugin.extension);
} else {
this.plugin.disableExtension(concealPlugin.extension);
}
yield this.plugin.saveSettings();
})));
containerEl.createEl("div", { text: "Highlight and color brackets" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
new import_obsidian6.Setting(containerEl).setName("Color paired brackets").setDesc("Whether to colorize matching brackets.").addToggle((toggle) => toggle.setValue(this.plugin.settings.colorPairedBracketsEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.colorPairedBracketsEnabled = value;
if (value) {
this.plugin.enableExtension(colorPairedBracketsPluginLowestPrec);
} else {
this.plugin.disableExtension(colorPairedBracketsPluginLowestPrec);
}
yield this.plugin.saveSettings();
})));
new import_obsidian6.Setting(containerEl).setName("Highlight matching bracket beneath cursor").setDesc("When the cursor is adjacent to a bracket, highlight the matching bracket.").addToggle((toggle) => toggle.setValue(this.plugin.settings.highlightCursorBracketsEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.highlightCursorBracketsEnabled = value;
if (value) {
this.plugin.enableExtension(highlightCursorBracketsPlugin.extension);
} else {
this.plugin.disableExtension(highlightCursorBracketsPlugin.extension);
}
yield this.plugin.saveSettings();
})));
containerEl.createEl("div", { text: "Inline math preview" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
new import_obsidian6.Setting(containerEl).setName("Enabled").setDesc("When inside inline math, show a popup preview window of the rendered math.").addToggle((toggle) => toggle.setValue(this.plugin.settings.inlineMathPreviewEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.inlineMathPreviewEnabled = value;
if (value) {
this.plugin.enableExtension(cursorTooltipField);
this.plugin.enableExtension(cursorTooltipBaseTheme);
} else {
this.plugin.disableExtension(cursorTooltipField);
this.plugin.disableExtension(cursorTooltipBaseTheme);
}
yield this.plugin.saveSettings();
})));
containerEl.createEl("div", { text: "Auto-fraction" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
new import_obsidian6.Setting(containerEl).setName("Enabled").setDesc("Whether auto-fraction is enabled.").addToggle((toggle) => toggle.setValue(this.plugin.settings.autofractionEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.autofractionEnabled = value;
yield this.plugin.saveSettings();
})));
new import_obsidian6.Setting(containerEl).setName("Excluded environments").setDesc('A list of environments to exclude auto-fraction from running in. For example, to exclude auto-fraction from running while inside an exponent, such as e^{...}, use ["^{", "}"]').addTextArea((text) => text.setPlaceholder('[ ["^{", "}] ]').setValue(this.plugin.settings.autofractionExcludedEnvs).onChange((value) => __async(this, null, function* () {
this.plugin.setAutofractionExcludedEnvs(value);
this.plugin.settings.autofractionExcludedEnvs = value;
yield this.plugin.saveSettings();
})));
new import_obsidian6.Setting(containerEl).setName("Breaking characters").setDesc(`A list of characters that denote the start/end of a fraction. e.g. if + is included in the list, "a+b/c" will expand to "a+\\frac{b}{c}". If + is not in the list, it will expand to "\\frac{a+b}{c}".`).addText((text) => text.setPlaceholder(DEFAULT_SETTINGS.autofractionBreakingChars).setValue(this.plugin.settings.autofractionBreakingChars).onChange((value) => __async(this, null, function* () {
this.plugin.settings.autofractionBreakingChars = value;
yield this.plugin.saveSettings();
})));
containerEl.createEl("div", { text: "Matrix shortcuts" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
new import_obsidian6.Setting(containerEl).setName("Enabled").setDesc("Whether matrix shortcuts are enabled.").addToggle((toggle) => toggle.setValue(this.plugin.settings.matrixShortcutsEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.matrixShortcutsEnabled = value;
yield this.plugin.saveSettings();
})));
new import_obsidian6.Setting(containerEl).setName("Environments").setDesc("A list of environment names to run the matrix shortcuts in, separated by commas.").addText((text) => text.setPlaceholder(DEFAULT_SETTINGS.matrixShortcutsEnvNames).setValue(this.plugin.settings.matrixShortcutsEnvNames).onChange((value) => __async(this, null, function* () {
this.plugin.settings.matrixShortcutsEnvNames = value;
this.plugin.matrixShortcutsEnvNames = value.replace(/\s/g, "").split(",");
yield this.plugin.saveSettings();
})));
containerEl.createEl("div", { text: "Tabout" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
new import_obsidian6.Setting(containerEl).setName("Enabled").setDesc("Whether tabout is enabled.").addToggle((toggle) => toggle.setValue(this.plugin.settings.taboutEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.taboutEnabled = value;
yield this.plugin.saveSettings();
})));
containerEl.createEl("div", { text: "Auto-enlarge brackets" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
new import_obsidian6.Setting(containerEl).setName("Enabled").setDesc("Whether to automatically enlarge brackets containing e.g. sum, int, frac.").addToggle((toggle) => toggle.setValue(this.plugin.settings.autoEnlargeBrackets).onChange((value) => __async(this, null, function* () {
this.plugin.settings.autoEnlargeBrackets = value;
yield this.plugin.saveSettings();
})));
new import_obsidian6.Setting(containerEl).setName("Triggers").setDesc("A list of symbols that should trigger auto-enlarge brackets, separated by commas.").addText((text) => text.setPlaceholder(DEFAULT_SETTINGS.autoEnlargeBracketsTriggers).setValue(this.plugin.settings.autoEnlargeBracketsTriggers).onChange((value) => __async(this, null, function* () {
this.plugin.settings.autoEnlargeBracketsTriggers = value;
this.plugin.autoEnlargeBracketsTriggers = value.replace(/\s/g, "").split(",");
yield this.plugin.saveSettings();
})));
containerEl.createEl("div", { text: "Misc" }).addClasses(["setting-item", "setting-item-heading", "setting-item-name"]);
new import_obsidian6.Setting(containerEl).setName("Word delimiters").setDesc('Symbols that will be treated as word delimiters, for use with the "w" snippet option.').addText((text) => text.setPlaceholder(DEFAULT_SETTINGS.wordDelimiters).setValue(this.plugin.settings.wordDelimiters).onChange((value) => __async(this, null, function* () {
this.plugin.settings.wordDelimiters = value;
yield this.plugin.saveSettings();
})));
}
};
var ConfirmationModal = class extends import_obsidian6.Modal {
constructor(app, body, buttonCallback, clickCallback) {
super(app);
this.contentEl.addClass("latex-suite-confirmation-modal");
this.contentEl.createEl("p", { text: body });
new import_obsidian6.Setting(this.contentEl).addButton((button) => {
buttonCallback(button);
button.onClick(() => __async(this, null, function* () {
yield clickCallback();
this.close();
}));
}).addButton((button) => button.setButtonText("Cancel").onClick(() => this.close()));
}
};
function createSnippetsEditor(content, extensions) {
const view = new import_view9.EditorView({
state: import_state7.EditorState.create({ doc: content, extensions })
});
return view;
}
// src/main.ts
var import_view11 = __toModule(require("@codemirror/view"));
var import_state9 = __toModule(require("@codemirror/state"));
var import_commands4 = __toModule(require("@codemirror/commands"));
// src/snippets/snippets.ts
var SNIPPET_VARIABLES = {
"${GREEK}": "alpha|beta|gamma|Gamma|delta|Delta|epsilon|varepsilon|zeta|eta|theta|Theta|iota|kappa|lambda|Lambda|mu|nu|xi|Xi|pi|Pi|rho|sigma|Sigma|tau|upsilon|varphi|phi|Phi|chi|psi|Psi|omega|Omega",
"${SYMBOL}": "hbar|ell|nabla|infty|dots|to|leftrightarrow|mapsto|setminus|mid|cap|cup|land|lor|subseteq|subset|implies|impliedby|iff|exists|equiv|square|neq|geq|leq|gg|ll|sim|simeq|approx|propto|cdot|oplus|otimes|times|star|perp|det|exp|ln|log|partial"
};
var EXCLUSIONS = {
"([A-Za-z])(\\d)": { openSymbol: "\\pu{", closeSymbol: "}" },
"->": { openSymbol: "\\ce{", closeSymbol: "}" }
};
// src/snippets/snippet_manager.ts
var import_view10 = __toModule(require("@codemirror/view"));
var import_state8 = __toModule(require("@codemirror/state"));
var import_commands3 = __toModule(require("@codemirror/commands"));
var COLORS = ["lightskyblue", "orange", "lime", "pink", "cornsilk", "magenta", "navajowhite"];
var TabstopReference = class {
constructor(view, colorIndex) {
this.view = view;
this.colorIndex = colorIndex;
}
getColorIndex() {
return this.colorIndex;
}
get markers() {
const state = this.view.state;
const iter = state.field(markerStateField).iter();
const markers = [];
while (iter.value) {
if (iter.value.spec.reference === this) {
markers.push({
from: iter.from,
to: iter.to,
value: iter.value
});
}
iter.next();
}
return markers;
}
get ranges() {
const state = this.view.state;
const iter = state.field(markerStateField).iter();
const ranges = [];
while (iter.value) {
if (iter.value.spec.reference === this) {
ranges.push(import_state8.EditorSelection.range(iter.from, iter.to));
}
iter.next();
}
return ranges;
}
removeFromEditor() {
this.view.dispatch({
effects: removeMarkBySpecAttribute.of({ attribute: "reference", reference: this })
});
}
};
var SnippetManager = class {
constructor() {
this.currentTabstopReferences = [];
this.snippetsToAdd = [];
}
getColorIndex() {
let colorIndex = 0;
for (; colorIndex < COLORS.length; colorIndex++) {
if (!this.currentTabstopReferences.find((p) => p.getColorIndex() === colorIndex))
break;
}
if (colorIndex === COLORS.length) {
colorIndex = Math.floor(Math.random() * COLORS.length);
}
return colorIndex;
}
getColorClass(colorIndex) {
const prefix = "latex-suite-suggestion-placeholder";
const markerClass = prefix + " " + prefix + colorIndex;
return markerClass;
}
getTabstopsFromSnippet(view, start2, replacement) {
const tabstops = [];
const text = view.state.doc.toString();
for (let i = start2; i < start2 + replacement.length; i++) {
if (!(text.charAt(i) === "$")) {
continue;
}
let number = parseInt(text.charAt(i + 1));
const tabstopStart = i;
let tabstopEnd = tabstopStart + 2;
let tabstopReplacement = "";
if (isNaN(number)) {
if (!(text.charAt(i + 1) === "{" && text.charAt(i + 3) === ":"))
continue;
number = parseInt(text.charAt(i + 2));
if (isNaN(number))
continue;
const closingIndex = findMatchingBracket(text, i + 1, "{", "}", false, start2 + replacement.length);
if (closingIndex === -1)
continue;
tabstopReplacement = text.slice(i + 4, closingIndex);
tabstopEnd = closingIndex + 1;
i = closingIndex;
}
const tabstop = { number, from: tabstopStart, to: tabstopEnd, replacement: tabstopReplacement };
tabstops.push(tabstop);
}
return tabstops;
}
queueSnippet(snippet) {
this.snippetsToAdd.push(snippet);
}
expandSnippets(view) {
if (this.snippetsToAdd.length === 0)
return false;
const docLength = view.state.doc.length;
const snippets2 = this.snippetsToAdd;
const changes = snippets2;
let keyPresses = [];
for (const snippet of snippets2) {
if (snippet.keyPressed && snippet.keyPressed.length === 1) {
const prevChar = view.state.doc.sliceString(snippet.to - 1, snippet.to);
const from = snippet.to === 0 ? 0 : snippet.to - 1;
keyPresses.push({ from, to: snippet.to, insert: prevChar + snippet.keyPressed });
}
}
view.dispatch({
changes: keyPresses,
annotations: import_commands3.isolateHistory.of("full")
});
const undoKeyPresses = import_state8.ChangeSet.of(keyPresses, docLength).invert(view.state.doc);
const changesAsChangeSet = import_state8.ChangeSet.of(changes, docLength);
const combinedChanges = undoKeyPresses.compose(changesAsChangeSet);
view.dispatch({
changes: combinedChanges,
effects: startSnippet.of(null)
});
const changeSet = import_state8.ChangeSet.of(changes, docLength);
const oldPositions = snippets2.map((change) => change.from);
const newPositions = oldPositions.map((pos) => changeSet.mapPos(pos));
let tabstopsToAdd = [];
for (let i = 0; i < snippets2.length; i++) {
tabstopsToAdd = tabstopsToAdd.concat(this.getTabstopsFromSnippet(view, newPositions[i], snippets2[i].insert));
}
if (tabstopsToAdd.length === 0) {
this.snippetsToAdd = [];
return true;
}
this.insertTabstopReferences(view, tabstopsToAdd);
this.insertTabstopsTransaction(view, tabstopsToAdd);
this.snippetsToAdd = [];
return true;
}
insertTabstopReferences(view, tabstops, append = false) {
const numbers = Array.from(new Set(tabstops.map((tabstop) => tabstop.number))).sort().reverse();
if (!append) {
const colorIndex = this.getColorIndex();
for (let i = 0; i < numbers.length; i++) {
const reference2 = new TabstopReference(view, colorIndex);
this.currentTabstopReferences.unshift(reference2);
}
}
}
insertTabstopsTransaction(view, tabstops) {
const effects = tabstops.map((tabstop) => {
const reference2 = this.currentTabstopReferences[tabstop.number];
const mark = import_view10.Decoration.mark({
inclusive: true,
attributes: {},
class: this.getColorClass(reference2.colorIndex),
reference: reference2
}).range(tabstop.from, tabstop.to);
return addMark.of(mark);
});
view.dispatch({
effects
});
const changes = tabstops.map((tabstop) => {
return { from: tabstop.from, to: tabstop.to, insert: tabstop.replacement };
});
view.dispatch({
changes
});
const firstRef = this.currentTabstopReferences[0];
const selection = import_state8.EditorSelection.create(firstRef.ranges);
view.dispatch({
selection,
effects: endSnippet.of(null)
});
resetCursorBlink();
firstRef.removeFromEditor();
this.removeOnlyTabstop();
}
selectTabstopReference(reference2) {
setSelections(reference2.view, reference2.ranges);
reference2.removeFromEditor();
this.removeOnlyTabstop();
}
removeOnlyTabstop() {
if (this.currentTabstopReferences.length === 1) {
let shouldClear = true;
const reference2 = this.currentTabstopReferences[0];
const markers = reference2.markers;
for (const marker of markers) {
if (!(marker.from === marker.to)) {
shouldClear = false;
break;
}
}
if (shouldClear)
this.clearAllTabstops(reference2.view);
}
}
isInsideATabstop(pos) {
if (this.currentTabstopReferences.length === 0)
return false;
let isInside = false;
for (const tabstopReference of this.currentTabstopReferences) {
for (const range of tabstopReference.ranges) {
if (pos >= range.from && pos <= range.to) {
isInside = true;
break;
}
}
if (isInside)
break;
}
return isInside;
}
isInsideLastTabstop(view) {
if (this.currentTabstopReferences.length === 0)
return false;
let isInside = false;
const lastTabstopRef = this.currentTabstopReferences.slice(-1)[0];
const ranges = lastTabstopRef.ranges;
const lastRange = ranges[0];
const sel = view.state.selection.main;
isInside = sel.eq(lastRange);
return isInside;
}
consumeAndGotoNextTabstop(view) {
if (this.currentTabstopReferences.length === 0)
return false;
const oldCursor = view.state.selection.main;
this.currentTabstopReferences.shift();
if (this.currentTabstopReferences.length === 0) {
setCursor(view, oldCursor.to);
return true;
}
const newTabstop = this.currentTabstopReferences[0];
const newMarkers = newTabstop.markers;
const cursor = view.state.selection.main;
const newMarker = newMarkers[0];
if (newMarkers.length === 0)
return this.consumeAndGotoNextTabstop(view);
if (newTabstop.markers.length === 1) {
if (newMarker.from <= cursor.from && newMarker.to >= cursor.to) {
setCursor(view, newMarker.to);
} else {
this.selectTabstopReference(newTabstop);
}
} else {
this.selectTabstopReference(newTabstop);
}
const newCursor = view.state.selection.main;
if (oldCursor.eq(newCursor))
return this.consumeAndGotoNextTabstop(view);
return true;
}
tidyTabstopReferences() {
this.currentTabstopReferences = this.currentTabstopReferences.filter((tabstopReference) => tabstopReference.markers.length > 0);
}
clearAllTabstops(view) {
if (view) {
view.dispatch({
effects: clearMarks.of(null)
});
}
this.currentTabstopReferences = [];
}
onunload() {
this.clearAllTabstops();
}
};
// src/editor_commands.ts
function boxCurrentEquation(view) {
const result = getEquationBounds(view);
if (!result)
return false;
const { start: start2, end: end2 } = result;
let equation = "\\boxed{" + view.state.sliceDoc(start2, end2) + "}";
const insideBlockEqn = view.state.sliceDoc(start2 - 2, start2) === "$$" && view.state.sliceDoc(end2, end2 + 2) === "$$";
if (insideBlockEqn)
equation = "\n" + equation + "\n";
const pos = view.state.selection.main.to;
replaceRange(view, start2, end2, equation);
setCursor(view, pos + "\\boxed{".length + (insideBlockEqn ? 1 : 0));
}
function getBoxEquationCommand() {
return {
id: "latex-suite-box-equation",
name: "Box current equation",
editorCheckCallback: (checking, editor, markdownView) => {
const view = editor.cm;
const withinEquation = isWithinEquation(view);
if (checking)
return withinEquation;
if (!withinEquation)
return;
boxCurrentEquation(view);
return;
}
};
}
function getSelectEquationCommand() {
return {
id: "latex-suite-select-equation",
name: "Select current equation",
editorCheckCallback: (checking, editor, markdownView) => {
const view = editor.cm;
const withinEquation = isWithinEquation(view);
if (checking)
return withinEquation;
if (!withinEquation)
return;
const result = getEquationBounds(view);
if (!result)
return false;
let { start: start2, end: end2 } = result;
const doc = view.state.doc.toString();
if (doc.charAt(start2) === "\n")
start2++;
if (doc.charAt(end2 - 1) === "\n")
end2--;
setSelection(view, start2, end2);
return;
}
};
}
var editorCommands = [
getBoxEquationCommand(),
getSelectEquationCommand()
];
// src/main.ts
var LatexSuitePlugin = class extends import_obsidian7.Plugin {
constructor() {
super(...arguments);
this.cursorTriggeredByChange = false;
this.shouldAutoEnlargeBrackets = false;
this.editorExtensions = [];
this.fileIsInSnippetsFolder = (file) => {
const snippetDir = this.app.vault.getAbstractFileByPath(this.settings.snippetsFileLocation);
const isFolder = snippetDir instanceof import_obsidian7.TFolder;
return isFolder && isInFolder(file, snippetDir);
};
this.handleDocChange = () => {
this.cursorTriggeredByChange = true;
};
this.handleCursorActivity = (view, pos) => {
if (this.cursorTriggeredByChange) {
this.cursorTriggeredByChange = false;
return;
}
if (!this.snippetManager.isInsideATabstop(pos) || this.snippetManager.isInsideLastTabstop(view)) {
this.snippetManager.clearAllTabstops(view);
}
};
this.handleUndoRedo = (update) => {
const undoTr = update.transactions.find((tr) => tr.isUserEvent("undo"));
const redoTr = update.transactions.find((tr) => tr.isUserEvent("redo"));
for (const tr of update.transactions) {
for (const effect4 of tr.effects) {
if (effect4.is(startSnippet)) {
if (redoTr) {
(0, import_commands4.redo)(update.view);
(0, import_commands4.redo)(update.view);
(0, import_commands4.redo)(update.view);
}
} else if (effect4.is(undidEndSnippet)) {
if (undoTr) {
(0, import_commands4.undo)(update.view);
(0, import_commands4.undo)(update.view);
(0, import_commands4.undo)(update.view);
}
}
}
}
if (undoTr) {
this.snippetManager.tidyTabstopReferences();
}
};
this.addEditorCommands = () => {
for (const command of editorCommands) {
this.addCommand(command);
}
this.addCommand({
id: "latex-suite-enable-all-features",
name: "Enable all features",
callback: () => __async(this, null, function* () {
this.settings.snippetsEnabled = true;
this.settings.autofractionEnabled = true;
this.settings.matrixShortcutsEnabled = true;
this.settings.taboutEnabled = true;
this.settings.autoEnlargeBrackets = true;
yield this.saveSettings();
})
});
this.addCommand({
id: "latex-suite-disable-all-features",
name: "Disable all features",
callback: () => __async(this, null, function* () {
this.settings.snippetsEnabled = false;
this.settings.autofractionEnabled = false;
this.settings.matrixShortcutsEnabled = false;
this.settings.taboutEnabled = false;
this.settings.autoEnlargeBrackets = false;
yield this.saveSettings();
})
});
};
this.onKeydown = (event, view) => {
const success = this.handleKeydown(event.key, event.shiftKey, event.ctrlKey, view);
if (success)
event.preventDefault();
};
this.handleKeydown = (key, shiftKey, ctrlKey, view) => {
const s = view.state.selection;
const pos = s.main.to;
const ranges = Array.from(s.ranges).reverse();
const withinEquation = isWithinEquation(view);
let withinMath = false;
if (withinEquation)
withinMath = !isInsideEnvironment(view, pos, { openSymbol: "\\text{", closeSymbol: "}" });
let success = false;
if (this.settings.snippetsEnabled) {
if (!ctrlKey) {
success = this.runSnippets(view, key, withinMath, ranges);
if (success)
return true;
}
}
const shouldTaboutByCloseBracket = this.shouldTaboutByCloseBracket(view, key);
if (key === "Tab" || shouldTaboutByCloseBracket) {
success = this.handleTabstops(view);
if (success)
return true;
}
if (this.settings.autofractionEnabled && withinMath) {
if (key === "/") {
success = this.runAutoFraction(view, ranges);
if (success)
return true;
}
}
if (this.settings.matrixShortcutsEnabled && withinMath) {
if (["Tab", "Enter"].contains(key)) {
success = this.runMatrixShortcuts(view, key, shiftKey, pos);
if (success)
return true;
}
}
if (this.settings.taboutEnabled) {
if (key === "Tab") {
success = this.tabout(view, withinEquation);
if (success)
return true;
}
}
return false;
};
this.checkSnippet = (snippet, effectiveLine, range, sel) => {
let triggerPos;
let trigger = snippet.trigger;
trigger = this.insertSnippetVariables(trigger);
let replacement = snippet.replacement;
if (snippet.replacement.contains("${VISUAL}")) {
if (!sel)
return null;
if (!(effectiveLine.slice(-trigger.length) === trigger))
return null;
triggerPos = range.from;
replacement = snippet.replacement.replace("${VISUAL}", sel);
} else if (sel) {
return null;
} else if (!snippet.options.contains("r")) {
if (!(effectiveLine.slice(-trigger.length) === trigger))
return null;
triggerPos = effectiveLine.length - trigger.length;
} else {
const regex = new RegExp(trigger + "$");
const result = regex.exec(effectiveLine);
if (!result) {
return null;
}
for (let i = 1; i < result.length; i++) {
replacement = replacement.replaceAll("[[" + (i - 1) + "]]", result[i]);
}
triggerPos = result.index;
}
return { triggerPos, replacement };
};
this.insertSnippetVariables = (trigger) => {
for (const [variable, replacement] of Object.entries(SNIPPET_VARIABLES)) {
trigger = trigger.replace(variable, replacement);
}
return trigger;
};
this.runSnippets = (view, key, withinMath, ranges) => {
this.shouldAutoEnlargeBrackets = false;
for (const range of ranges) {
this.runSnippetCursor(view, key, withinMath, range);
}
const success = this.snippetManager.expandSnippets(view);
if (this.shouldAutoEnlargeBrackets) {
this.autoEnlargeBrackets(view);
}
return success;
};
this.runSnippetCursor = (view, key, withinMath, range) => {
const { from, to } = range;
const sel = view.state.sliceDoc(from, to);
for (const snippet of this.snippets) {
let effectiveLine = view.state.sliceDoc(0, to);
if (snippet.options.contains("m") && !withinMath) {
continue;
} else if (snippet.options.contains("t") && withinMath) {
continue;
}
if (snippet.options.contains("A") || snippet.replacement.contains("${VISUAL}")) {
if (!(key.length === 1))
continue;
effectiveLine += key;
} else if (!(key === "Tab")) {
continue;
}
if (snippet.trigger in EXCLUSIONS) {
const environment = EXCLUSIONS[snippet.trigger];
if (isInsideEnvironment(view, to, environment))
continue;
}
const result = this.checkSnippet(snippet, effectiveLine, range, sel);
if (result === null)
continue;
const triggerPos = result.triggerPos;
if (snippet.options.contains("w")) {
const prevChar = view.state.sliceDoc(triggerPos - 1, triggerPos);
const nextChar = view.state.sliceDoc(to, to + 1);
const wordDelimiters = this.settings.wordDelimiters.replace("\\n", "\n");
const prevCharIsWordDelimiter = wordDelimiters.contains(prevChar);
const nextCharIsWordDelimiter = wordDelimiters.contains(nextChar);
if (!(prevCharIsWordDelimiter && nextCharIsWordDelimiter)) {
continue;
}
}
let replacement = result.replacement;
if (withinMath) {
let spaceIndex = 0;
if (replacement.endsWith(" ")) {
spaceIndex = -1;
} else {
const lastThreeChars = replacement.slice(-3);
const lastChar = lastThreeChars.slice(-1);
if (lastThreeChars.slice(0, 2) === " $" && !isNaN(parseInt(lastChar))) {
spaceIndex = -3;
}
}
if (spaceIndex != 0) {
const inlineMath = isWithinInlineEquation(view);
if (inlineMath) {
if (spaceIndex === -1) {
replacement = replacement.trimEnd();
} else if (spaceIndex === -3) {
replacement = replacement.slice(0, -3) + replacement.slice(-2);
}
}
}
}
const start2 = triggerPos;
this.snippetManager.queueSnippet({ from: start2, to, insert: replacement, keyPressed: key });
const containsTrigger = this.autoEnlargeBracketsTriggers.some((word) => replacement.contains("\\" + word));
if (containsTrigger)
this.shouldAutoEnlargeBrackets = true;
return true;
}
return false;
};
this.handleTabstops = (view) => {
const success = this.snippetManager.consumeAndGotoNextTabstop(view);
return success;
};
this.runAutoFraction = (view, ranges) => {
for (const range of ranges) {
this.runAutoFractionCursor(view, range);
}
const success = this.snippetManager.expandSnippets(view);
if (success) {
this.autoEnlargeBrackets(view);
}
return success;
};
this.runAutoFractionCursor = (view, range) => {
const { from, to } = range;
for (const env of this.autofractionExcludedEnvs) {
if (isInsideEnvironment(view, to, env)) {
return false;
}
}
const result = getEquationBounds(view);
if (!result)
return false;
const eqnStart = result.start;
let curLine = view.state.sliceDoc(0, to);
let start2 = eqnStart;
if (from != to) {
start2 = from;
} else {
const regex = new RegExp("(" + SNIPPET_VARIABLES["${GREEK}"] + ") ([^ ])", "g");
curLine = curLine.replace(regex, "$1#$2");
for (let i = curLine.length - 1; i >= eqnStart; i--) {
const curChar = curLine.charAt(i);
if ([")", "]", "}"].contains(curChar)) {
const closeBracket = curChar;
const openBracket = getOpenBracket(closeBracket);
const j = findMatchingBracket(curLine, i, openBracket, closeBracket, true);
if (j === -1)
return false;
i = j;
if (i < eqnStart) {
start2 = eqnStart;
break;
}
}
if (" $([{\n".concat(this.settings.autofractionBreakingChars).contains(curChar)) {
start2 = i + 1;
break;
}
}
}
let numerator = view.state.sliceDoc(start2, to);
if (numerator === "")
return false;
if (curLine.charAt(start2) === "(" && curLine.charAt(to - 1) === ")") {
numerator = numerator.slice(1, -1);
}
const replacement = "\\frac{" + numerator + "}{$0}$1";
this.snippetManager.queueSnippet({ from: start2, to, insert: replacement, keyPressed: "/" });
return true;
};
this.autoEnlargeBrackets = (view) => {
if (!this.settings.autoEnlargeBrackets)
return;
const result = getEquationBounds(view);
if (!result)
return false;
const { start: start2, end: end2 } = result;
const text = view.state.doc.toString();
const left2 = "\\left";
const right2 = "\\right";
for (let i = start2; i < end2; i++) {
const brackets2 = { "(": ")", "[": "]", "\\{": "\\}", "\\langle": "\\rangle", "\\lvert": "\\rvert" };
const openBrackets = Object.keys(brackets2);
let found = false;
let open = "";
for (const openBracket of openBrackets) {
if (text.slice(i, i + openBracket.length) === openBracket) {
found = true;
open = openBracket;
break;
}
}
if (!found)
continue;
const bracketSize = open.length;
const close = brackets2[open];
const j = findMatchingBracket(text, i, open, close, false, end2);
if (j === -1)
continue;
if (text.slice(i - left2.length, i) === left2 && text.slice(j - right2.length, j) === right2)
continue;
const bracketContents = text.slice(i + 1, j);
const containsTrigger = this.autoEnlargeBracketsTriggers.some((word) => bracketContents.contains("\\" + word));
if (!containsTrigger) {
i = j;
continue;
}
this.snippetManager.queueSnippet({ from: i, to: i + bracketSize, insert: left2 + open + " " });
this.snippetManager.queueSnippet({ from: j, to: j + bracketSize, insert: " " + right2 + close });
}
this.snippetManager.expandSnippets(view);
};
this.tabout = (view, withinEquation) => {
if (!withinEquation)
return false;
const pos = view.state.selection.main.to;
const result = getEquationBounds(view);
if (!result)
return false;
const end2 = result.end;
const d = view.state.doc;
const text = d.toString();
const rangle = "\\rangle";
for (let i = pos; i < end2; i++) {
if (["}", ")", "]", ">", "|"].contains(text.charAt(i))) {
setCursor(view, i + 1);
return true;
} else if (text.slice(i, i + rangle.length) === rangle) {
setCursor(view, i + rangle.length);
return true;
}
}
const textBtwnCursorAndEnd = d.sliceString(pos, end2);
const atEnd = textBtwnCursorAndEnd.trim().length === 0;
if (!atEnd)
return false;
const inlineMath = d.sliceString(end2, end2 + 2) != "$$";
if (inlineMath) {
setCursor(view, end2 + 1);
} else {
const dollarLine = d.lineAt(end2 + 2);
if (dollarLine.number === d.lines) {
replaceRange(view, dollarLine.to, dollarLine.to, "\n");
}
setCursor(view, dollarLine.to + 1);
const line = d.lineAt(pos);
replaceRange(view, line.from, line.to, line.text.trim());
}
return true;
};
this.runMatrixShortcuts = (view, key, shiftKey, pos) => {
let isInsideAnEnv = false;
for (const envName of this.matrixShortcutsEnvNames) {
const env = { openSymbol: "\\begin{" + envName + "}", closeSymbol: "\\end{" + envName + "}" };
isInsideAnEnv = isInsideEnvironment(view, pos, env);
if (isInsideAnEnv)
break;
}
if (!isInsideAnEnv)
return false;
if (key === "Tab") {
view.dispatch(view.state.replaceSelection(" & "));
return true;
} else if (key === "Enter") {
if (shiftKey) {
const d = view.state.doc;
const nextLineNo = d.lineAt(pos).number + 1;
const nextLine = d.line(nextLineNo);
setCursor(view, nextLine.to);
} else {
view.dispatch(view.state.replaceSelection(" \\\\\n"));
}
return true;
} else {
return false;
}
};
this.shouldTaboutByCloseBracket = (view, keyPressed) => {
const sel = view.state.selection.main;
if (!sel.empty)
return;
const pos = sel.from;
const c = getCharacterAtPos(view, pos);
const brackets2 = [")", "]", "}"];
if (c === keyPressed && brackets2.contains(c)) {
return true;
} else {
return false;
}
};
}
onload() {
return __async(this, null, function* () {
var _a;
yield this.loadSettings();
this.registerEditorExtension(import_state9.Prec.highest(import_view11.keymap.of([
{
key: "Tab",
run: (view) => {
const success = this.handleKeydown("Tab", false, false, view);
return success;
}
},
{
key: "Enter",
run: (view) => {
const success = this.handleKeydown("Enter", false, false, view);
return success;
},
shift: (view) => {
const success = this.handleKeydown("Enter", true, false, view);
return success;
}
}
])));
if ((_a = this.app.vault.config) == null ? void 0 : _a.legacyEditor) {
const message = "Obsidian Latex Suite: This plugin does not support the legacy editor. Switch to Live Preview mode to use this plugin.";
new import_obsidian7.Notice(message, 1e5);
console.log(message);
return;
}
this.addSettingTab(new LatexSuiteSettingTab(this.app, this));
this.snippetManager = new SnippetManager();
this.registerEditorExtension(markerStateField);
this.registerEditorExtension(snippetInvertedEffects);
this.registerEditorExtension(import_state9.Prec.highest(import_view11.EditorView.domEventHandlers({
"keydown": this.onKeydown
})));
this.registerEditorExtension(import_view11.EditorView.updateListener.of((update) => {
if (update.docChanged) {
this.handleDocChange();
}
if (update.selectionSet) {
const pos = update.state.selection.main.head;
this.handleCursorActivity(update.view, pos);
}
this.handleUndoRedo(update);
}));
this.registerEditorExtension((0, import_view11.tooltips)({ position: "absolute" }));
this.registerEditorExtension(this.editorExtensions);
this.addEditorCommands();
this.registerEvent(this.app.vault.on("modify", this.onFileChange.bind(this)));
this.registerEvent(this.app.vault.on("delete", (file) => {
const snippetDir = this.app.vault.getAbstractFileByPath(this.settings.snippetsFileLocation);
const isFolder = snippetDir instanceof import_obsidian7.TFolder;
if (file instanceof import_obsidian7.TFile && (isFolder && file.path.contains(snippetDir.path))) {
debouncedSetSnippetsFromFileOrFolder(this);
}
}));
this.registerEvent(this.app.vault.on("create", (file) => {
if (file instanceof import_obsidian7.TFile && this.fileIsInSnippetsFolder(file)) {
debouncedSetSnippetsFromFileOrFolder(this);
}
}));
});
}
onunload() {
this.snippetManager.onunload();
}
onFileChange(file) {
return __async(this, null, function* () {
if (!this.settings.loadSnippetsFromFile) {
return;
}
if (file.path === this.settings.snippetsFileLocation || this.fileIsInSnippetsFolder(file)) {
try {
yield debouncedSetSnippetsFromFileOrFolder(this);
} catch (e) {
new import_obsidian7.Notice("Failed to load snippets.", 5e3);
}
}
});
}
enableExtension(extension) {
this.editorExtensions.push(extension);
this.app.workspace.updateOptions();
}
disableExtension(extension) {
this.editorExtensions.remove(extension);
this.app.workspace.updateOptions();
}
loadSettings() {
return __async(this, null, function* () {
this.settings = Object.assign({}, DEFAULT_SETTINGS, yield this.loadData());
if (this.settings.loadSnippetsFromFile) {
this.app.workspace.onLayoutReady(() => {
debouncedSetSnippetsFromFileOrFolder(this);
});
} else {
this.setSnippets(this.settings.snippets);
}
this.setAutofractionExcludedEnvs(this.settings.autofractionExcludedEnvs);
this.matrixShortcutsEnvNames = this.settings.matrixShortcutsEnvNames.replace(/\s/g, "").split(",");
this.autoEnlargeBracketsTriggers = this.settings.autoEnlargeBracketsTriggers.replace(/\s/g, "").split(",");
if (this.settings.concealEnabled)
this.enableExtension(concealPlugin.extension);
if (this.settings.colorPairedBracketsEnabled)
this.enableExtension(colorPairedBracketsPluginLowestPrec);
if (this.settings.highlightCursorBracketsEnabled)
this.enableExtension(highlightCursorBracketsPlugin.extension);
if (this.settings.inlineMathPreviewEnabled) {
this.enableExtension(cursorTooltipField);
this.enableExtension(cursorTooltipBaseTheme);
}
});
}
saveSettings() {
return __async(this, null, function* () {
yield this.saveData(this.settings);
});
}
setSnippets(snippetsStr) {
const snippets2 = getSnippetsFromString(snippetsStr);
sortSnippets(snippets2);
this.snippets = snippets2;
}
setAutofractionExcludedEnvs(envsStr) {
const envsJSON = JSON.parse(envsStr);
const envs = envsJSON.map(function(env) {
return { openSymbol: env[0], closeSymbol: env[1] };
});
this.autofractionExcludedEnvs = envs;
}
};