remark-typography
Version:
Remark plugin to fix typography: quotes, dashes and so on.
1,038 lines • 70.7 kB
JavaScript
/**
* @name remark-typography
* @fileoverview Remark plugin to fix typography: quotes, dashes and so on.
* @version 0.6.25
* @author Roy Revelt, Codsen Ltd
* @license MIT
* {@link https://codsen.com/os/remark-typography/}
*/
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// ../../node_modules/fp-ts/lib/function.js
var require_function = __commonJS({
"../../node_modules/fp-ts/lib/function.js"(exports2) {
"use strict";
var __spreadArray = exports2 && exports2.__spreadArray || function(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l2 = from.length, ar; i < l2; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.dual = exports2.getEndomorphismMonoid = exports2.SK = exports2.hole = exports2.constVoid = exports2.constUndefined = exports2.constNull = exports2.constFalse = exports2.constTrue = exports2.unsafeCoerce = exports2.apply = exports2.getRing = exports2.getSemiring = exports2.getMonoid = exports2.getSemigroup = exports2.getBooleanAlgebra = void 0;
exports2.identity = identity;
exports2.constant = constant;
exports2.flip = flip;
exports2.flow = flow;
exports2.tuple = tuple;
exports2.increment = increment;
exports2.decrement = decrement;
exports2.absurd = absurd;
exports2.tupled = tupled;
exports2.untupled = untupled;
exports2.pipe = pipe2;
exports2.not = not;
var getBooleanAlgebra = function(B2) {
return function() {
return {
meet: function(x3, y4) {
return function(a2) {
return B2.meet(x3(a2), y4(a2));
};
},
join: function(x3, y4) {
return function(a2) {
return B2.join(x3(a2), y4(a2));
};
},
zero: function() {
return B2.zero;
},
one: function() {
return B2.one;
},
implies: function(x3, y4) {
return function(a2) {
return B2.implies(x3(a2), y4(a2));
};
},
not: function(x3) {
return function(a2) {
return B2.not(x3(a2));
};
}
};
};
};
exports2.getBooleanAlgebra = getBooleanAlgebra;
var getSemigroup = function(S3) {
return function() {
return {
concat: function(f4, g2) {
return function(a2) {
return S3.concat(f4(a2), g2(a2));
};
}
};
};
};
exports2.getSemigroup = getSemigroup;
var getMonoid = function(M2) {
var getSemigroupM = (0, exports2.getSemigroup)(M2);
return function() {
return {
concat: getSemigroupM().concat,
empty: function() {
return M2.empty;
}
};
};
};
exports2.getMonoid = getMonoid;
var getSemiring = function(S3) {
return {
add: function(f4, g2) {
return function(x3) {
return S3.add(f4(x3), g2(x3));
};
},
zero: function() {
return S3.zero;
},
mul: function(f4, g2) {
return function(x3) {
return S3.mul(f4(x3), g2(x3));
};
},
one: function() {
return S3.one;
}
};
};
exports2.getSemiring = getSemiring;
var getRing = function(R) {
var S3 = (0, exports2.getSemiring)(R);
return {
add: S3.add,
mul: S3.mul,
one: S3.one,
zero: S3.zero,
sub: function(f4, g2) {
return function(x3) {
return R.sub(f4(x3), g2(x3));
};
}
};
};
exports2.getRing = getRing;
var apply = function(a2) {
return function(f4) {
return f4(a2);
};
};
exports2.apply = apply;
function identity(a2) {
return a2;
}
exports2.unsafeCoerce = identity;
function constant(a2) {
return function() {
return a2;
};
}
exports2.constTrue = constant(true);
exports2.constFalse = constant(false);
exports2.constNull = constant(null);
exports2.constUndefined = constant(void 0);
exports2.constVoid = exports2.constUndefined;
function flip(f4) {
return function() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (args.length > 1) {
return f4(args[1], args[0]);
}
return function(a2) {
return f4(a2)(args[0]);
};
};
}
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
switch (arguments.length) {
case 1:
return ab;
case 2:
return function() {
return bc(ab.apply(this, arguments));
};
case 3:
return function() {
return cd(bc(ab.apply(this, arguments)));
};
case 4:
return function() {
return de(cd(bc(ab.apply(this, arguments))));
};
case 5:
return function() {
return ef(de(cd(bc(ab.apply(this, arguments)))));
};
case 6:
return function() {
return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
};
case 7:
return function() {
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
};
case 8:
return function() {
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
};
case 9:
return function() {
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
};
}
return;
}
function tuple() {
var t = [];
for (var _i = 0; _i < arguments.length; _i++) {
t[_i] = arguments[_i];
}
return t;
}
function increment(n) {
return n + 1;
}
function decrement(n) {
return n - 1;
}
function absurd(_3) {
throw new Error("Called `absurd` function which should be uncallable");
}
function tupled(f4) {
return function(a2) {
return f4.apply(void 0, a2);
};
}
function untupled(f4) {
return function() {
var a2 = [];
for (var _i = 0; _i < arguments.length; _i++) {
a2[_i] = arguments[_i];
}
return f4(a2);
};
}
function pipe2(a2, ab, bc, cd, de, ef, fg, gh, hi) {
switch (arguments.length) {
case 1:
return a2;
case 2:
return ab(a2);
case 3:
return bc(ab(a2));
case 4:
return cd(bc(ab(a2)));
case 5:
return de(cd(bc(ab(a2))));
case 6:
return ef(de(cd(bc(ab(a2)))));
case 7:
return fg(ef(de(cd(bc(ab(a2))))));
case 8:
return gh(fg(ef(de(cd(bc(ab(a2)))))));
case 9:
return hi(gh(fg(ef(de(cd(bc(ab(a2))))))));
default: {
var ret = arguments[0];
for (var i = 1; i < arguments.length; i++) {
ret = arguments[i](ret);
}
return ret;
}
}
}
exports2.hole = absurd;
var SK = function(_3, b3) {
return b3;
};
exports2.SK = SK;
function not(predicate) {
return function(a2) {
return !predicate(a2);
};
}
var getEndomorphismMonoid = function() {
return {
concat: function(first, second) {
return flow(first, second);
},
empty: identity
};
};
exports2.getEndomorphismMonoid = getEndomorphismMonoid;
var dual = function(arity, body) {
var isDataFirst = typeof arity === "number" ? function(args) {
return args.length >= arity;
} : arity;
return function() {
var args = Array.from(arguments);
if (isDataFirst(arguments)) {
return body.apply(this, args);
}
return function(self) {
return body.apply(void 0, __spreadArray([self], args, false));
};
};
};
exports2.dual = dual;
}
});
// ../../node_modules/rfdc/index.js
var require_rfdc = __commonJS({
"../../node_modules/rfdc/index.js"(exports2, module2) {
"use strict";
module2.exports = rfdc;
function copyBuffer(cur) {
if (cur instanceof Buffer) {
return Buffer.from(cur);
}
return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length);
}
function rfdc(opts) {
opts = opts || {};
if (opts.circles) return rfdcCircles(opts);
const constructorHandlers = /* @__PURE__ */ new Map();
constructorHandlers.set(Date, (o) => new Date(o));
constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
if (opts.constructorHandlers) {
for (const handler2 of opts.constructorHandlers) {
constructorHandlers.set(handler2[0], handler2[1]);
}
}
let handler = null;
return opts.proto ? cloneProto : clone;
function cloneArray(a2, fn) {
const keys = Object.keys(a2);
const a22 = new Array(keys.length);
for (let i = 0; i < keys.length; i++) {
const k2 = keys[i];
const cur = a2[k2];
if (typeof cur !== "object" || cur === null) {
a22[k2] = cur;
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
a22[k2] = handler(cur, fn);
} else if (ArrayBuffer.isView(cur)) {
a22[k2] = copyBuffer(cur);
} else {
a22[k2] = fn(cur);
}
}
return a22;
}
function clone(o) {
if (typeof o !== "object" || o === null) return o;
if (Array.isArray(o)) return cloneArray(o, clone);
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
return handler(o, clone);
}
const o2 = {};
for (const k2 in o) {
if (Object.hasOwnProperty.call(o, k2) === false) continue;
const cur = o[k2];
if (typeof cur !== "object" || cur === null) {
o2[k2] = cur;
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
o2[k2] = handler(cur, clone);
} else if (ArrayBuffer.isView(cur)) {
o2[k2] = copyBuffer(cur);
} else {
o2[k2] = clone(cur);
}
}
return o2;
}
function cloneProto(o) {
if (typeof o !== "object" || o === null) return o;
if (Array.isArray(o)) return cloneArray(o, cloneProto);
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
return handler(o, cloneProto);
}
const o2 = {};
for (const k2 in o) {
const cur = o[k2];
if (typeof cur !== "object" || cur === null) {
o2[k2] = cur;
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
o2[k2] = handler(cur, cloneProto);
} else if (ArrayBuffer.isView(cur)) {
o2[k2] = copyBuffer(cur);
} else {
o2[k2] = cloneProto(cur);
}
}
return o2;
}
}
function rfdcCircles(opts) {
const refs = [];
const refsNew = [];
const constructorHandlers = /* @__PURE__ */ new Map();
constructorHandlers.set(Date, (o) => new Date(o));
constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
if (opts.constructorHandlers) {
for (const handler2 of opts.constructorHandlers) {
constructorHandlers.set(handler2[0], handler2[1]);
}
}
let handler = null;
return opts.proto ? cloneProto : clone;
function cloneArray(a2, fn) {
const keys = Object.keys(a2);
const a22 = new Array(keys.length);
for (let i = 0; i < keys.length; i++) {
const k2 = keys[i];
const cur = a2[k2];
if (typeof cur !== "object" || cur === null) {
a22[k2] = cur;
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
a22[k2] = handler(cur, fn);
} else if (ArrayBuffer.isView(cur)) {
a22[k2] = copyBuffer(cur);
} else {
const index = refs.indexOf(cur);
if (index !== -1) {
a22[k2] = refsNew[index];
} else {
a22[k2] = fn(cur);
}
}
}
return a22;
}
function clone(o) {
if (typeof o !== "object" || o === null) return o;
if (Array.isArray(o)) return cloneArray(o, clone);
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
return handler(o, clone);
}
const o2 = {};
refs.push(o);
refsNew.push(o2);
for (const k2 in o) {
if (Object.hasOwnProperty.call(o, k2) === false) continue;
const cur = o[k2];
if (typeof cur !== "object" || cur === null) {
o2[k2] = cur;
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
o2[k2] = handler(cur, clone);
} else if (ArrayBuffer.isView(cur)) {
o2[k2] = copyBuffer(cur);
} else {
const i = refs.indexOf(cur);
if (i !== -1) {
o2[k2] = refsNew[i];
} else {
o2[k2] = clone(cur);
}
}
}
refs.pop();
refsNew.pop();
return o2;
}
function cloneProto(o) {
if (typeof o !== "object" || o === null) return o;
if (Array.isArray(o)) return cloneArray(o, cloneProto);
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
return handler(o, cloneProto);
}
const o2 = {};
refs.push(o);
refsNew.push(o2);
for (const k2 in o) {
const cur = o[k2];
if (typeof cur !== "object" || cur === null) {
o2[k2] = cur;
} else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
o2[k2] = handler(cur, cloneProto);
} else if (ArrayBuffer.isView(cur)) {
o2[k2] = copyBuffer(cur);
} else {
const i = refs.indexOf(cur);
if (i !== -1) {
o2[k2] = refsNew[i];
} else {
o2[k2] = cloneProto(cur);
}
}
}
refs.pop();
refsNew.pop();
return o2;
}
}
}
});
// src/main.ts
var main_exports = {};
__export(main_exports, {
default: () => main_default
});
var import_function = __toESM(require_function(), 1);
// ../../node_modules/unist-util-is/lib/index.js
var convert = (
// Note: overloads in JSDoc can’t yet use different `@template`s.
/**
* @type {(
* (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
* (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
* ((test?: Test) => Check)
* )}
*/
/**
* @param {Test} [test]
* @returns {Check}
*/
function(test) {
if (test === null || test === void 0) {
return ok;
}
if (typeof test === "function") {
return castFactory(test);
}
if (typeof test === "object") {
return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
}
if (typeof test === "string") {
return typeFactory(test);
}
throw new Error("Expected function, string, or object as test");
}
);
function anyFactory(tests) {
const checks = [];
let index = -1;
while (++index < tests.length) {
checks[index] = convert(tests[index]);
}
return castFactory(any);
function any(...parameters) {
let index2 = -1;
while (++index2 < checks.length) {
if (checks[index2].apply(this, parameters)) return true;
}
return false;
}
}
function propsFactory(check) {
const checkAsRecord = (
/** @type {Record<string, unknown>} */
check
);
return castFactory(all);
function all(node) {
const nodeAsRecord = (
/** @type {Record<string, unknown>} */
/** @type {unknown} */
node
);
let key;
for (key in check) {
if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
}
return true;
}
}
function typeFactory(check) {
return castFactory(type);
function type(node) {
return node && node.type === check;
}
}
function castFactory(testFunction) {
return check;
function check(value, index, parent) {
return Boolean(
looksLikeANode(value) && testFunction.call(
this,
value,
typeof index === "number" ? index : void 0,
parent || void 0
)
);
}
}
function ok() {
return true;
}
function looksLikeANode(value) {
return value !== null && typeof value === "object" && "type" in value;
}
// ../../node_modules/unist-util-visit-parents/lib/color.node.js
function color(d5) {
return "\x1B[33m" + d5 + "\x1B[39m";
}
// ../../node_modules/unist-util-visit-parents/lib/index.js
var empty = [];
var CONTINUE = true;
var EXIT = false;
var SKIP = "skip";
function visitParents(tree, test, visitor, reverse) {
let check;
if (typeof test === "function" && typeof visitor !== "function") {
reverse = visitor;
visitor = test;
} else {
check = test;
}
const is2 = convert(check);
const step = reverse ? -1 : 1;
factory(tree, void 0, [])();
function factory(node, index, parents) {
const value = (
/** @type {Record<string, unknown>} */
node && typeof node === "object" ? node : {}
);
if (typeof value.type === "string") {
const name = (
// `hast`
typeof value.tagName === "string" ? value.tagName : (
// `xast`
typeof value.name === "string" ? value.name : void 0
)
);
Object.defineProperty(visit2, "name", {
value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")"
});
}
return visit2;
function visit2() {
let result = empty;
let subresult;
let offset;
let grandparents;
if (!test || is2(node, index, parents[parents.length - 1] || void 0)) {
result = toResult(visitor(node, parents));
if (result[0] === EXIT) {
return result;
}
}
if ("children" in node && node.children) {
const nodeAsParent = (
/** @type {UnistParent} */
node
);
if (nodeAsParent.children && result[0] !== SKIP) {
offset = (reverse ? nodeAsParent.children.length : -1) + step;
grandparents = parents.concat(nodeAsParent);
while (offset > -1 && offset < nodeAsParent.children.length) {
const child = nodeAsParent.children[offset];
subresult = factory(child, offset, grandparents)();
if (subresult[0] === EXIT) {
return subresult;
}
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
}
}
}
return result;
}
}
}
function toResult(value) {
if (Array.isArray(value)) {
return value;
}
if (typeof value === "number") {
return [CONTINUE, value];
}
return value === null || value === void 0 ? empty : [value];
}
// ../../node_modules/unist-util-visit/lib/index.js
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
let reverse;
let test;
let visitor;
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
test = void 0;
visitor = testOrVisitor;
reverse = visitorOrReverse;
} else {
test = testOrVisitor;
visitor = visitorOrReverse;
reverse = maybeReverse;
}
visitParents(tree, test, overload, reverse);
function overload(node, parents) {
const parent = parents[parents.length - 1];
const index = parent ? parent.children.indexOf(node) : void 0;
return visitor(node, index, parent);
}
}
// ../ranges-sort/dist/ranges-sort.esm.js
var d = { strictlyTwoElementsInRangeArrays: false, progressFn: null };
function g(t, u2) {
if (!Array.isArray(t) || !t.length) return t;
let n = { ...d, ...u2 }, s2, o;
if (n.strictlyTwoElementsInRangeArrays && !t.every((e, r3) => !Array.isArray(e) || e.length !== 2 ? (s2 = r3, o = e.length, false) : true)) throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${s2}th range (${JSON.stringify(t[s2], null, 4)}) has not two but ${o} elements!`);
if (!t.every((e, r3) => !Array.isArray(e) || !Number.isInteger(e[0]) || e[0] < 0 || !Number.isInteger(e[1]) || e[1] < 0 ? (s2 = r3, false) : true)) throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${s2}th range (${JSON.stringify(t[s2], null, 4)}) does not consist of only natural numbers!`);
let p2 = t.length ** 2, i = 0;
return Array.from(t).sort((e, r3) => (n.progressFn && (i += 1, n.progressFn(Math.floor(i * 100 / p2))), e[0] === r3[0] ? e[1] < r3[1] ? -1 : e[1] > r3[1] ? 1 : 0 : e[0] < r3[0] ? -1 : 1));
}
// ../ranges-merge/dist/ranges-merge.esm.js
var d2 = { mergeType: 1, progressFn: null, joinRangesThatTouchEdges: true };
function b(i, r3) {
function l2(e) {
return !!e && typeof e == "object" && !Array.isArray(e);
}
if (!Array.isArray(i) || !i.length) return null;
let n;
if (r3) if (l2(r3)) {
if (n = { ...d2, ...r3 }, n.progressFn && l2(n.progressFn) && !Object.keys(n.progressFn).length) n.progressFn = null;
else if (n.progressFn && typeof n.progressFn != "function") throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn, null, 4)}`);
if (![1, 2, "1", "2"].includes(n.mergeType)) throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType, null, 4)}`);
if (typeof n.joinRangesThatTouchEdges != "boolean") throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges, null, 4)}`);
} else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
${JSON.stringify(r3, null, 4)} (type ${typeof r3})`);
else n = { ...d2 };
let g2 = i.filter((e) => Array.isArray(e)).map((e) => [...e]).filter((e) => e[2] !== void 0 || e[0] !== e[1]), s2, o, t;
n.progressFn ? s2 = g(g2, { progressFn: (e) => {
t = Math.floor(e / 5), t !== o && (o = t, n.progressFn(t));
} }) : s2 = g(g2);
let a2 = s2.length - 1;
for (let e = a2; e > 0; e--) n.progressFn && (t = Math.floor((1 - e / a2) * 78) + 21, t !== o && t > o && (o = t, n.progressFn(t))), (s2[e][0] <= s2[e - 1][0] || !n.joinRangesThatTouchEdges && s2[e][0] < s2[e - 1][1] || n.joinRangesThatTouchEdges && s2[e][0] <= s2[e - 1][1]) && (s2[e - 1][0] = Math.min(s2[e][0], s2[e - 1][0]), s2[e - 1][1] = Math.max(s2[e][1], s2[e - 1][1]), s2[e][2] !== void 0 && (s2[e - 1][0] >= s2[e][0] || s2[e - 1][1] <= s2[e][1]) && s2[e - 1][2] !== null && (s2[e][2] === null && s2[e - 1][2] !== null ? s2[e - 1][2] = null : s2[e - 1][2] != null ? +n.mergeType == 2 && s2[e - 1][0] === s2[e][0] ? s2[e - 1][2] = s2[e][2] : s2[e - 1][2] += s2[e][2] : s2[e - 1][2] = s2[e][2]), s2.splice(e, 1), e = s2.length);
return s2.length ? s2 : null;
}
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
var isProduction = process.env.NODE_ENV === "production";
var prefix = "Invariant failed";
function invariant(condition, message) {
if (condition) {
return;
}
if (isProduction) {
throw new Error(prefix);
}
var provided = typeof message === "function" ? message() : message;
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
throw new Error(value);
}
// ../ranges-apply/dist/ranges-apply.esm.js
function _(s2, n, r3) {
let t = 0, p2 = 0;
if (arguments.length === 0) throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");
if (typeof s2 != "string") throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof s2}, equal to: ${JSON.stringify(s2, null, 4)}`);
if (n && !Array.isArray(n)) throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof n}, equal to: ${JSON.stringify(n, null, 4)}`);
if (r3 && typeof r3 != "function") throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r3}, equal to: ${JSON.stringify(r3, null, 4)}`);
if (!n?.filter((e) => e).length) return s2;
let i;
Array.isArray(n) && Number.isInteger(n[0]) && Number.isInteger(n[1]) ? i = [Array.from(n)] : i = Array.from(n);
let f4 = i.length, c2 = 0;
i.filter((e) => e).forEach((e, a2) => {
if (r3 && (t = Math.floor(c2 / f4 * 10), t !== p2 && (p2 = t, r3(t))), !Array.isArray(e)) throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${a2}th element not an array: ${JSON.stringify(e, null, 4)}, which is ${typeof e}`);
if (!Number.isInteger(e[0])) {
if (!Number.isInteger(+e[0]) || +e[0] < 0) throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${a2}th element, array ${JSON.stringify(e, null, 0)}. Its first element is not an integer, string index, but ${typeof e[0]}, equal to: ${JSON.stringify(e[0], null, 4)}.`);
i[a2][0] = +i[a2][0];
}
if (!Number.isInteger(e[1])) {
if (!Number.isInteger(+e[1]) || +e[1] < 0) throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${a2}th element, array ${JSON.stringify(e, null, 0)}. Its second element is not an integer, string index, but ${typeof e[1]}, equal to: ${JSON.stringify(e[1], null, 4)}.`);
i[a2][1] = +i[a2][1];
}
c2 += 1;
});
let o = b(i, { progressFn: (e) => {
r3 && (t = 10 + Math.floor(e / 10), t !== p2 && (p2 = t, r3(t)));
} });
invariant(o);
let u2 = o.length;
if (u2 > 0) {
let e = s2.slice(o[u2 - 1][1]);
s2 = o.reduce((a2, $3, l2, y4) => {
r3 && (t = 20 + Math.floor(l2 / u2 * 80), t !== p2 && (p2 = t, r3(t)));
let g2 = l2 === 0 ? 0 : y4[l2 - 1][1], d5 = y4[l2][0];
return `${a2}${s2.slice(g2, d5)}${y4[l2][2] || ""}`;
}, ""), s2 += e;
}
return s2;
}
// ../codsen-utils/dist/codsen-utils.esm.js
var import_rfdc = __toESM(require_rfdc(), 1);
var l = (0, import_rfdc.default)();
var a = "\u2018";
var f = "\u2019";
var d3 = "\u201C";
var m = "\u201D";
var S = "\u2013";
var O = "\u2014";
var C = "\xA0";
var N = "\u2026";
var E = "\u2032";
var T = "\u2033";
var L = "\xD7";
var D = [".", ",", ";", "!", "?"];
function U(t) {
return r(t) && t.charCodeAt(0) >= 48 && t.charCodeAt(0) <= 57;
}
function x(t) {
return r(t) && "\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4".includes(t);
}
function s(t) {
return r(t) && t.length === 1 && t.toUpperCase() !== t.toLowerCase();
}
function P(t) {
return r(t) && (t === '"' || t === "'" || t === a || t === f || t === d3 || t === m);
}
function Q(t) {
return !r(t) || !s(t) ? false : t === t.toUpperCase() && t !== t.toLowerCase();
}
function V(t) {
return !r(t) || !t ? false : !t[0].trim();
}
function u(t) {
if (t == null || typeof t != "object") return false;
let e = Object.getPrototypeOf(t);
return e !== null && e !== Object.prototype && Object.getPrototypeOf(e) !== null ? false : !(Symbol.iterator in t) && !(Symbol.toStringTag in t);
}
function r(t) {
return typeof t == "string";
}
function q(t) {
return Number.isSafeInteger(t) && t >= 0;
}
function G(t) {
return t != null;
}
function v(t, e) {
return u(t) && r(e) && e in t;
}
// ../string-apostrophes/dist/string-apostrophes.esm.js
var d4 = { convertEntities: false, convertApostrophes: true };
function V2(o, $3) {
if (typeof o != "string") throw new Error(`string-apostrophes/convertOne(): [THROW_ID_01] first input argument should be string! It's been passed as ${o} (its typeof ${typeof o})`);
if (typeof $3 != "object" || Array.isArray($3)) throw new Error(`string-apostrophes/convertOne(): [THROW_ID_02] options object should be a plain object. It has was passed as ${JSON.stringify($3, null, 4)} (its typeof is ${typeof $3})`);
if (!Number.isInteger($3.from) || $3.from < 0) throw new Error(`string-apostrophes/convertOne(): [THROW_ID_03] options objects key "to", a starting string index, should be a natural number! It was given as ${$3.from} (its typeof is ${typeof $3.from})`);
if ($3.from >= o.length) throw new Error(`string-apostrophes/convertOne(): [THROW_ID_04] opts.from is beyond str length! opts.from was passed as ${$3.from} and str.length is ${o.length}`);
let { from: s2 = 0, to: e, value: u2, convertEntities: n, convertApostrophes: r3, offsetBy: a2 } = { ...d4, ...$3 };
Number.isInteger(e) || (e = s2 + 1);
let i = [];
return u2 && ["'", a, f, E].includes(u2) || e === s2 + 1 && ["'", a, f, E].includes(o[s2]) ? o[s2 - 1] && o[e] && U(o[s2 - 1]) && !s(o[e]) ? r3 && o.slice(s2, e) !== (n ? "′" : E) && u2 !== (n ? "′" : E) ? i.push([s2, e, n ? "′" : E]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : o[e] && o[e + 1] && o[e] === "n" && o.slice(s2, e) === o.slice(e + 1, e + 1 + (e - s2)) ? r3 && o.slice(s2, e + 2) !== (n ? "’n’" : `${f}n${f}`) && u2 !== (n ? "’n’" : `${f}n${f}`) ? (i.push([s2, e + 2, n ? "’n’" : `${f}n${f}`]), typeof a2 == "function" && a2(2)) : !r3 && o.slice(s2, e + 2) !== "'n'" && u2 !== "'n'" && (i.push([s2, e + 2, "'n'"]), typeof a2 == "function" && a2(2)) : o[e] && o[e].toLowerCase() === "t" && (!o[e + 1]?.trim() || o[e + 1].toLowerCase() === "i") || o[e] && o[e + 2] && o[e].toLowerCase() === "t" && o[e + 1].toLowerCase() === "w" && (o[e + 2].toLowerCase() === "a" || o[e + 2].toLowerCase() === "e" || o[e + 2].toLowerCase() === "i" || o[e + 2].toLowerCase() === "o") || o[e] && o[e + 1] && o[e].toLowerCase() === "e" && o[e + 1].toLowerCase() === "m" || o[e] && o[e + 4] && o[e].toLowerCase() === "c" && o[e + 1].toLowerCase() === "a" && o[e + 2].toLowerCase() === "u" && o[e + 3].toLowerCase() === "s" && o[e + 4].toLowerCase() === "e" || o[e] && U(o[e]) ? r3 && o.slice(s2, e) !== (n ? "’" : f) && u2 !== (n ? "’" : f) ? i.push([s2, e, n ? "’" : f]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : o[s2 - 1] && o[e] && D.includes(o[s2 - 1]) ? o[e].trim() ? o[e] === '"' && o[e + 1] && !o[e + 1].trim() && (r3 && o.slice(s2, e + 1) !== (n ? "’”" : `${f}${m}`) && u2 !== (n ? "’”" : `${f}${m}`) ? (i.push([s2, e + 1, `${n ? "’”" : `${f}${m}`}`]), typeof a2 == "function" && a2(1)) : !r3 && o.slice(s2, e + 1) !== `'"` && u2 !== `'"` && (i.push([s2, e + 1, `'"`]), typeof a2 == "function" && a2(1))) : r3 && o.slice(s2, e) !== (n ? "’" : f) && u2 !== (n ? "’" : f) ? i.push([s2, e, n ? "’" : f]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : s2 === 0 && o.slice(e).trim() ? r3 && o.slice(s2, e) !== (n ? "‘" : a) && u2 !== (n ? "‘" : a) ? i.push([s2, e, n ? "‘" : a]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : !o[e] && o.slice(0, s2).trim() ? r3 && o.slice(s2, e) !== (n ? "’" : f) && u2 !== (n ? "’" : f) ? i.push([s2, e, n ? "’" : f]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : o[s2 - 1] && o[e] && (s(o[s2 - 1]) || U(o[s2 - 1])) && (s(o[e]) || U(o[e])) ? r3 ? (o[e] && o[s2 - 5] && o[s2 - 5].toLowerCase() === "h" && o[s2 - 4].toLowerCase() === "a" && o[s2 - 3].toLowerCase() === "w" && o[s2 - 2].toLowerCase() === "a" && o[s2 - 1].toLowerCase() === "i" && o[e].toLowerCase() === "i" || o[s2 - 1] && o[s2 - 1].toLowerCase() === "o" && o[e + 2] && o[e].toLowerCase() === "a" && o[e + 1].toLowerCase() === "h" && o[e + 2].toLowerCase() === "u") && o.slice(s2, e) !== (n ? "‘" : a) && u2 !== (n ? "‘" : a) ? i.push([s2, e, n ? "‘" : a]) : o.slice(s2, e) !== (n ? "’" : f) && u2 !== (n ? "’" : f) && i.push([s2, e, n ? "’" : f]) : o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : o[e] && (s(o[e]) || U(o[e])) ? r3 && o.slice(s2, e) !== (n ? "‘" : a) && u2 !== (n ? "‘" : a) ? i.push([s2, e, n ? "‘" : a]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : s(o[s2 - 1]) || U(o[s2 - 1]) ? r3 && o.slice(s2, e) !== (n ? "’" : f) && u2 !== (n ? "’" : f) ? i.push([s2, e, n ? "’" : f]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : o[s2 - 1] && !o[s2 - 1].trim() ? r3 && o.slice(s2, e) !== (n ? "‘" : a) && u2 !== (n ? "‘" : a) ? i.push([s2, e, n ? "‘" : a]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"]) : o[e] && !o[e].trim() && (r3 && o.slice(s2, e) !== (n ? "’" : f) && u2 !== (n ? "’" : f) ? i.push([s2, e, n ? "’" : f]) : !r3 && o.slice(s2, e) !== "'" && u2 !== "'" && i.push([s2, e, "'"])) : (['"', d3, m, T].includes(u2) || e === s2 + 1 && ['"', d3, m, T].includes(o[s2])) && (o[s2 - 1] && U(o[s2 - 1]) && o[e] && o[e] !== "'" && o[e] !== '"' && o[e] !== f && o[e] !== m && o[e] !== a && o[e] !== d3 ? r3 && o.slice(s2, e) !== (n ? "″" : T) && u2 !== (n ? "″" : T) ? i.push([s2, e, n ? "″" : T]) : !r3 && o.slice(s2, e) !== '"' && u2 !== '"' && i.push([s2, e, '"']) : o[s2 - 1] && o[e] && D.includes(o[s2 - 1]) ? o[e].trim() ? o[e] === "'" && o[e + 1] && !o[e + 1].trim() && (r3 && o.slice(s2, e + 1) !== (n ? "”’" : `${m}${f}`) && u2 !== (n ? "”’" : `${m}${f}`) ? (i.push([s2, e + 1, n ? "”’" : `${m}${f}`]), typeof a2 == "function" && a2(1)) : !r3 && o.slice(s2, e + 1) !== `"'` && u2 !== `"'` && (i.push([s2, e + 1, `"'`]), typeof a2 == "function" && a2(1))) : r3 && o.slice(s2, e) !== (n ? "”" : m) && u2 !== (n ? "”" : m) ? i.push([s2, e, n ? "”" : m]) : !r3 && o.slice(s2, e) !== '"' && u2 !== '"' && i.push([s2, e, '"']) : s2 === 0 && o[e] && o.slice(e).trim() ? r3 && o.slice(s2, e) !== (n ? "“" : d3) && u2 !== (n ? "“" : d3) ? i.push([s2, e, n ? "“" : d3]) : !r3 && o.slice(s2, e) !== '"' && u2 !== '"' && i.push([s2, e, '"']) : !o[e] && o.slice(0, s2).trim() ? r3 && o.slice(s2, e) !== (n ? "”" : m) && u2 !== (n ? "”" : m) ? i.push([s2, e, n ? "”" : m]) : !r3 && o.slice(s2, e) !== '"' && u2 !== '"' && i.push([s2, e, '"']) : o[e] && (s(o[e]) || U(o[e])) ? r3 && o.slice(s2, e) !== (n ? "“" : d3) && u2 !== (n ? "“" : d3) ? i.push([s2, e, n ? "“" : d3]) : !r3 && o.slice(s2, e) !== '"' && u2 !== '"' && i.push([s2, e, '"']) : o[s2 - 1] && (s(o[s2 - 1]) || U(o[s2 - 1])) ? r3 && o.slice(s2, e) !== (n ? "”" : m) && u2 !== (n ? "”" : m) ? i.push([s2, e, n ? "”" : m]) : !r3 && o.slice(s2, e) !== '"' && u2 !== '"' && i.push([s2, e, '"']) : o[s2 - 1] && !o[s2 - 1].trim() ? r3 && o.slice(s2, e) !== (n ? "“" : d3) && u2 !== (n ? "“" : d3) ? i.push([s2, e, n ? "“" : d3]) : !r3 && o.slice(s2, e) !== '"' && u2 !== '"' && i.push([s2, e, '"']) : o[e] && !o[e].trim() && (r3 && o.slice(s2, e) !== (n ? "”" : m) && u2 !== (n ? "”" : m) ? i.push([s2, e, n ? "”" : m]) : !r3 && o.slice(s2, e) !== '"' && u2 !== '"' && i.push([s2, e, '"']))), i;
}
function H(o, $3) {
if (typeof o != "string") throw new Error(`string-apostrophes: [THROW_ID_10] first input argument should be string! It's been passed as ${o} (its typeof ${typeof o})`);
if ($3 && (typeof $3 != "object" || Array.isArray($3))) throw new Error(`string-apostrophes: [THROW_ID_11] options object should be a plain object! It was passed as ${JSON.stringify($3, null, 4)} (its typeof is ${typeof $3})`);
if (!o) return { result: o, ranges: null };
let s2 = [], e = { ...d4, ...$3 }, u2 = o.length;
for (let n = 0; n < u2; n++) {
e.from = n, e.offsetBy = (a2) => {
n += a2;
};
let r3 = V2(o, e);
Array.isArray(r3) && r3.length && (s2 = s2.concat(r3));
}
return { result: _(o, s2), ranges: s2 };
}
// ../string-left-right/dist/string-left-right.esm.js
var import_rfdc2 = __toESM(require_rfdc(), 1);
var $ = (0, import_rfdc2.default)();
var c = "\xA0";
function D2({ str: n, idx: e = 0, stopAtNewlines: l2 = false, stopAtRawNbsp: o = false }) {
if (typeof n != "string" || !n.length || ((!e || typeof e != "number") && (e = 0), !n[e + 1])) return null;
if (n[e + 1] && (n[e + 1].trim() || l2 && `
\r`.includes(n[e + 1]) || o && n[e + 1] === c)) return e + 1;
if (n[e + 2] && (n[e + 2].trim() || l2 && `
\r`.includes(n[e + 2]) || o && n[e + 2] === c)) return e + 2;
for (let t = e + 1, m2 = n.length; t < m2; t++) if (n[t].trim() || l2 && `
\r`.includes(n[t]) || o && n[t] === c) return t;
return null;
}
function E2(n, e = 0) {
return D2({ str: n, idx: e, stopAtNewlines: false, stopAtRawNbsp: false });
}
function V3({ str: n, idx: e, stopAtNewlines: l2, stopAtRawNbsp: o }) {
if (typeof n != "string" || !n.length || ((!e || typeof e != "number") && (e = 0), e < 1)) return null;
if (n[~-e] && (n[~-e].trim() || l2 && `
\r`.includes(n[~-e]) || o && n[~-e] === c)) return ~-e;
if (n[e - 2] && (n[e - 2].trim() || l2 && `
\r`.includes(n[e - 2]) || o && n[e - 2] === c)) return e - 2;
for (let t = e; t--; ) if (n[t] && (n[t].trim() || l2 && `
\r`.includes(n[t]) || o && n[t] === c)) return t;
return null;
}
function y(n, e = 0) {
return V3({ str: n, idx: e, stopAtNewlines: false, stopAtRawNbsp: false });
}
// ../string-dashes/dist/string-dashes.esm.js
var y2 = { convertEntities: false, convertDashes: true };
function x2(e, t) {
if (typeof e != "string") throw new Error(`string-dashes/convertOne(): [THROW_ID_01] first input argument should be string! It's been passed as ${e} (its typeof ${typeof e})`);
if (typeof t != "object" || Array.isArray(t)) throw new Error(`string-dashes/convertOne(): [THROW_ID_02] options object should be a plain object. It has was passed as ${JSON.stringify(t, null, 4)} (its typeof is ${typeof t})`);
if (!Number.isInteger(t.from) || t.from < 0) throw new Error(`string-dashes/convertOne(): [THROW_ID_03] options objects key "to", a starting string index, should be a natural number! It was given as ${t.from} (its typeof is ${typeof t.from})`);
if (t.from >= e.length) throw new Error(`string-dashes/convertOne(): [THROW_ID_04] opts.from is beyond str length! opts.from was passed as ${t.from} and str.length is ${e.length}`);
let { from: n = 0, to: s2, value: r3, convertEntities: o, convertDashes: u2, offsetBy: g2 } = { ...y2, ...t };
Number.isInteger(s2) || (s2 = n + 1);
let i = [];
if (!u2) return null;
if ((r3 && ["-", O].includes(r3) || s2 === n + 1 && ["-", O].includes(e[n])) && (e[n - 1] && e[s2] && U(e[n - 1]) && U(e[s2]) || !s(e[n - 2]) && !s(e[s2 + 1]) && Q(e[n - 1]) && Q(e[s2])) && i.push([n, s2, o ? "–" : S]), r3 && ["-", S].includes(r3) || s2 === n + 1 && ["-", S].includes(e[n])) if (e[n - 1] && e[s2] && V(e[n - 1]) && V(e[s2])) {
let $3 = null, a2 = null;
e[n - 2] && (e[n - 2].trim() ? $3 = n - 2 : $3 = y(e, n)), e[s2 + 1] && (e[s2 + 1].trim() ? a2 = s2 + 1 : a2 = E2(e, n)), U(e[$3]) && U(e[a2]) || U(e[$3]) && x(e[a2]) || x(e[$3]) && U(e[a2]) ? i.push([n, s2, o ? "–" : S]) : i.push([n, s2, o ? "—" : O]);
} else e[n - 1] && s(e[n - 1]) && e[s2] && P(e[s2]) && i.push([n, s2, o ? "—" : O]);
return i.length ? i : null;
}
function j(e, t) {
if (typeof e != "string") throw new Error(`string-dashes: [THROW_ID_10] first input argument should be string! It's been passed as ${e} (its typeof ${typeof e})`);
if (t && (typeof t != "object" || Array.isArray(t))) throw new Error(`string-dashes: [THROW_ID_11] options object should be a plain object! It was passed as ${JSON.stringify(t, null, 4)} (its typeof is ${typeof t})`);
if (!e) return { result: e, ranges: null };
let n = [], s2 = { ...y2, ...t }, r3 = e.length;
for (let o = 0; o < r3; o++) {
s2.from = o, s2.offsetBy = (g2) => {
o += g2;
};
let u2 = x2(e, s2);
Array.isArray(u2) && u2.length && (n = n.concat(u2));
}
return { result: _(e, n), ranges: n };
}
// ../arrayiffy-if-string/dist/arrayiffy-if-string.esm.js
function r2(n) {
return typeof n != "string" ? n : n.length ? [n] : [];
}
// ../string-match-left-right/dist/string-match-left-right.esm.js
var w = { cb: void 0, i: false, trimBeforeMatching: false, trimCharsBeforeMatching: [], maxMismatches: 0, firstMustMatch: false, lastMustMatch: false, hungry: false };
var L2 = (t) => t + 1;
function A(t, s2, n, a2, u2 = false, o = L2) {
let l2 = typeof n == "function" ? n() : n;
if (+s2 < 0 && u2 && l2 === "EOL") return l2;
let r3 = { ...w, ...a2 };
if (s2 >= t.length && !u2) return false;
let c2 = u2 ? 1 : n.length, E4 = 0, h = false, i = false, g2 = false, b3 = r3.maxMismatches, e = s2, $3 = false, f4 = false, m2 = false;
function p2() {
return E4 === 1 && b3 < r3.maxMismatches - 1;
}
for (; t[e]; ) {
let T2 = o(e);
if (r3.trimBeforeMatching && t[e].trim() === "") {
if (!t[T2] && u2 && n === "EOL") return true;
e = o(e);
continue;
}
if (r3 && !r3.i && r3?.trimCharsBeforeMatching?.includes(t[e]) || r3?.i && r3.trimCharsBeforeMatching && r3.trimCharsBeforeMatching.map((D4) => D4.toLowerCase()).includes(t[e].toLowerCase())) {
if (u2 && n === "EOL" && !t[T2]) return true;
e = o(e);
continue;
}
let y4 = T2 > e ? n[n.length - c2] : n[c2 - 1];
if (!r3.i && t[e] === y4 || r3.i && t[e].toLowerCase() === y4.toLowerCase()) {
if ($3 || ($3 = true), g2 || (g2 = true), c2 === n.length) {
if (f4 = true, b3 !== r3.maxMismatches) return false;
} else c2 === 1 && (m2 = true);
if (c2 -= 1, E4++, p2()) return false;
if (!c2) return E4 !== n.length || b3 === r3.maxMismatches || !h ? e : false;
} else if (!h && !E4 && (h = true), r3.maxMismatches && b3 && e) {
b3 -= 1;
for (let D4 = 0; D4 <= b3; D4++) {
let C3 = T2 > e ? n[n.length - c2 + 1 + D4] : n[c2 - 2 - D4], M2 = t[o(e)];
if (C3 && (!r3.i && t[e] === C3 || r3.i && t[e].toLowerCase() === C3.toLowerCase()) && (!r3.firstMustMatch || c2 !== n.length)) {
if (E4++, p2()) return false;
c2 -= 2, $3 = true;
break;
} else if (M2 && C3 && (!r3.i && M2 === C3 || r3.i && M2.toLowerCase() === C3.toLowerCase()) && (!r3.firstMustMatch || c2 !== n.length)) {
if (!E4 && !r3.hungry) return false;
c2 -= 1, $3 = true;
break;
} else if (C3 === void 0 && b3 >= 0 && $3 && (!r3.firstMustMatch || f4) && (!r3.lastMustMatch || m2)) return e;
}
$3 || (i = e);
} else return e === 0 && c2 === 1 && !r3.lastMustMatch && g2 ? 0 : false;
if (i !== false && i !== e && (i = false), c2 < 1) return e;
e = o(e);
}
if (c2 > 0) return u2 && l2 === "EOL" ? true : r3 && r3.maxMismatches >= c2 && g2 ? i || 0 : false;
}
function V4(t, s2, n, a2, u2) {
if (u(u2) && v(u2, "trimBeforeMatching") && u2 && typeof u2.trimBeforeMatching != "boolean") throw new Error(`string-match-left-right/${t}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(u2.trimBeforeMatching) ? " Did you mean to use opts.trimCharsBeforeMatching?" : ""}`);
let o = { ...w, ...u2 };
if (typeof o.trimCharsBeforeMatching == "string" && (o.trimCharsBeforeMatching = r2(o.trimCharsBeforeMatching)), o.trimCharsBeforeMatching = o.trimCharsBeforeMatching.map((h) => r(h) ? h : String(h)), !r(s2) || !s2.length) return false;
if (!Number.isInteger(n) || n < 0) throw new Error(`string-match-left-right/${t}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof n}, equal to:
${JSON.stringify(n, null, 4)}`);
let l2, r3;
if (r(a2)) l2 = [a2];
else if (Array.isArray(a2)) l2 = a2;
else if (!a2) l2 = a2;
else if (typeof a2 == "function") l2 = [], l2.push(a2);
else throw new Error(`string-match-left-right/${t}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof a2}, equal to:
${JSON.stringify(a2, null, 4)}`);
if (u2 && !u(u2)) throw new Error(`string-match-left-right/${t}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof u2}", and equal to:
${JSON.stringify(u2, null, 4)}`);
let c2 = 0, E4 = "";
if (o?.trimCharsBeforeMatching?.some((h, i) => h.length > 1 ? (c2 = i, E4 = h, true) : false)) throw new Error(`string-match-left-right/${t}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${c2} is longer than 1 character, ${E4.length} (equals to ${E4}). Please split it into separate characters and put into array as separate elements.`);
if (!l2 || !Array.isArray(l2) || Array.isArray(l2) && !l2.length || Array.isArray(l2) && l2.length === 1 && r(l2[0]) && !l2[0].trim()) {
if (typeof o.cb == "function") {
let i, g2 = n;
if ((t === "matchLeftIncl" || t === "matchRight") && (g2 += 1), t[5] === "L") for (let f4 = g2; f4--; ) {
let m2 = s2[f4];
if ((!o.trimBeforeMatching || o.trimBeforeMatching && m2?.trim()) && (!o.trimCharsBeforeMatching?.length || m2 !== void 0 && !o.trimCharsBeforeMatching.includes(m2))) {
i = f4;
break;
}
}
else if (t.startsWith("matchRight")) for (let f4 = g2; f4 < s2.length; f4++) {
let m2 = s2[f4];
if ((!o.trimBeforeMatching || o.trimBeforeMatching && m2.trim()) && (!o.trimCharsBeforeMatching?.length || !o.trimCharsBeforeMatching.includes(m2))) {
i = f4;
break;
}
}
if (i === void 0) return false;
let b3 = s2[i], e = i + 1, $3 = "";
return e && e > 0 && ($3 = s2.slice(0, e)), t[5] === "L" || i && i > 0 && ($3 = s2.slice(i)), o.cb(b3, $3, i);
}
let h = "";
throw u2 || (h = " More so, the whole options object, the fourth input argument, is missing!"), new Error(`string-match-left-right/${t}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${h}`);
}
for (let h = 0, i = l2.length; h < i; h++) {
r3 = typeof l2[h] == "function";
let g2 = l2[h], b3, e, $3 = "", f4 = n;
t === "matchRight" ? f4 += 1 : t === "matchLeft" && (f4 -= 1);
let m2 = A(s2, f4, g2, o, r3, (p2) => t[5] ===