@forsakringskassan/docs-generator 2.15.6 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7332,16 +7332,6 @@ function ucs2decode(string) {
7332
7332
  return output;
7333
7333
  }
7334
7334
 
7335
- /**
7336
- * Creates a string based on an array of numeric code points.
7337
- * @see `punycode.ucs2.decode`
7338
- * @memberOf punycode.ucs2
7339
- * @name encode
7340
- * @param {Array} codePoints The array of numeric code points.
7341
- * @returns {String} The new Unicode string (UCS-2).
7342
- */
7343
- const ucs2encode = codePoints => String.fromCodePoint(...codePoints);
7344
-
7345
7335
  /**
7346
7336
  * Converts a basic code point into a digit/integer.
7347
7337
  * @see `digitToBasic()`
@@ -7627,25 +7617,6 @@ const toASCII = function(input) {
7627
7617
 
7628
7618
  /** Define the public API */
7629
7619
  const punycode = {
7630
- /**
7631
- * A string representing the current Punycode.js version number.
7632
- * @memberOf punycode
7633
- * @type String
7634
- */
7635
- 'version': '2.3.1',
7636
- /**
7637
- * An object of methods to convert from JavaScript's internal character
7638
- * representation (UCS-2) to Unicode code points, and back.
7639
- * @see <https://mathiasbynens.be/notes/javascript-encoding>
7640
- * @memberOf punycode
7641
- * @type Object
7642
- */
7643
- 'ucs2': {
7644
- 'decode': ucs2decode,
7645
- 'encode': ucs2encode
7646
- },
7647
- 'decode': decode,
7648
- 'encode': encode,
7649
7620
  'toASCII': toASCII,
7650
7621
  'toUnicode': toUnicode
7651
7622
  };
@@ -16326,11 +16297,11 @@ function requireRegisterTs () {
16326
16297
 
16327
16298
  requireRegisterTs();
16328
16299
 
16329
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16330
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16331
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16332
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16333
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16300
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16301
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16302
+ function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16303
+ function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16304
+ function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16334
16305
  const dedent = createDedent({});
16335
16306
  function createDedent(options) {
16336
16307
  dedent.withOptions = newOptions => createDedent(_objectSpread(_objectSpread({}, options), newOptions));
@@ -20616,6 +20587,144 @@ function requireFrontMatter () {
20616
20587
  var frontMatterExports = requireFrontMatter();
20617
20588
  var fm = /*@__PURE__*/getDefaultExportFromCjs(frontMatterExports);
20618
20589
 
20590
+ const peq = new Uint32Array(0x10000);
20591
+ const myers_32 = (a, b) => {
20592
+ const n = a.length;
20593
+ const m = b.length;
20594
+ const lst = 1 << (n - 1);
20595
+ let pv = -1;
20596
+ let mv = 0;
20597
+ let sc = n;
20598
+ let i = n;
20599
+ while (i--) {
20600
+ peq[a.charCodeAt(i)] |= 1 << i;
20601
+ }
20602
+ for (i = 0; i < m; i++) {
20603
+ let eq = peq[b.charCodeAt(i)];
20604
+ const xv = eq | mv;
20605
+ eq |= ((eq & pv) + pv) ^ pv;
20606
+ mv |= ~(eq | pv);
20607
+ pv &= eq;
20608
+ if (mv & lst) {
20609
+ sc++;
20610
+ }
20611
+ if (pv & lst) {
20612
+ sc--;
20613
+ }
20614
+ mv = (mv << 1) | 1;
20615
+ pv = (pv << 1) | ~(xv | mv);
20616
+ mv &= xv;
20617
+ }
20618
+ i = n;
20619
+ while (i--) {
20620
+ peq[a.charCodeAt(i)] = 0;
20621
+ }
20622
+ return sc;
20623
+ };
20624
+ const myers_x = (b, a) => {
20625
+ const n = a.length;
20626
+ const m = b.length;
20627
+ const mhc = [];
20628
+ const phc = [];
20629
+ const hsize = Math.ceil(n / 32);
20630
+ const vsize = Math.ceil(m / 32);
20631
+ for (let i = 0; i < hsize; i++) {
20632
+ phc[i] = -1;
20633
+ mhc[i] = 0;
20634
+ }
20635
+ let j = 0;
20636
+ for (; j < vsize - 1; j++) {
20637
+ let mv = 0;
20638
+ let pv = -1;
20639
+ const start = j * 32;
20640
+ const vlen = Math.min(32, m) + start;
20641
+ for (let k = start; k < vlen; k++) {
20642
+ peq[b.charCodeAt(k)] |= 1 << k;
20643
+ }
20644
+ for (let i = 0; i < n; i++) {
20645
+ const eq = peq[a.charCodeAt(i)];
20646
+ const pb = (phc[(i / 32) | 0] >>> i) & 1;
20647
+ const mb = (mhc[(i / 32) | 0] >>> i) & 1;
20648
+ const xv = eq | mv;
20649
+ const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
20650
+ let ph = mv | ~(xh | pv);
20651
+ let mh = pv & xh;
20652
+ if ((ph >>> 31) ^ pb) {
20653
+ phc[(i / 32) | 0] ^= 1 << i;
20654
+ }
20655
+ if ((mh >>> 31) ^ mb) {
20656
+ mhc[(i / 32) | 0] ^= 1 << i;
20657
+ }
20658
+ ph = (ph << 1) | pb;
20659
+ mh = (mh << 1) | mb;
20660
+ pv = mh | ~(xv | ph);
20661
+ mv = ph & xv;
20662
+ }
20663
+ for (let k = start; k < vlen; k++) {
20664
+ peq[b.charCodeAt(k)] = 0;
20665
+ }
20666
+ }
20667
+ let mv = 0;
20668
+ let pv = -1;
20669
+ const start = j * 32;
20670
+ const vlen = Math.min(32, m - start) + start;
20671
+ for (let k = start; k < vlen; k++) {
20672
+ peq[b.charCodeAt(k)] |= 1 << k;
20673
+ }
20674
+ let score = m;
20675
+ for (let i = 0; i < n; i++) {
20676
+ const eq = peq[a.charCodeAt(i)];
20677
+ const pb = (phc[(i / 32) | 0] >>> i) & 1;
20678
+ const mb = (mhc[(i / 32) | 0] >>> i) & 1;
20679
+ const xv = eq | mv;
20680
+ const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
20681
+ let ph = mv | ~(xh | pv);
20682
+ let mh = pv & xh;
20683
+ score += (ph >>> (m - 1)) & 1;
20684
+ score -= (mh >>> (m - 1)) & 1;
20685
+ if ((ph >>> 31) ^ pb) {
20686
+ phc[(i / 32) | 0] ^= 1 << i;
20687
+ }
20688
+ if ((mh >>> 31) ^ mb) {
20689
+ mhc[(i / 32) | 0] ^= 1 << i;
20690
+ }
20691
+ ph = (ph << 1) | pb;
20692
+ mh = (mh << 1) | mb;
20693
+ pv = mh | ~(xv | ph);
20694
+ mv = ph & xv;
20695
+ }
20696
+ for (let k = start; k < vlen; k++) {
20697
+ peq[b.charCodeAt(k)] = 0;
20698
+ }
20699
+ return score;
20700
+ };
20701
+ const distance = (a, b) => {
20702
+ if (a.length < b.length) {
20703
+ const tmp = b;
20704
+ b = a;
20705
+ a = tmp;
20706
+ }
20707
+ if (b.length === 0) {
20708
+ return a.length;
20709
+ }
20710
+ if (a.length <= 32) {
20711
+ return myers_32(a, b);
20712
+ }
20713
+ return myers_x(a, b);
20714
+ };
20715
+ const closest = (str, arr) => {
20716
+ let min_distance = Infinity;
20717
+ let min_index = 0;
20718
+ for (let i = 0; i < arr.length; i++) {
20719
+ const dist = distance(str, arr[i]);
20720
+ if (dist < min_distance) {
20721
+ min_distance = dist;
20722
+ min_index = i;
20723
+ }
20724
+ }
20725
+ return arr[min_index];
20726
+ };
20727
+
20619
20728
  var fs = {};
20620
20729
 
20621
20730
  var universalify = {};
@@ -25400,6 +25509,1049 @@ function deflist_plugin (md) {
25400
25509
  md.block.ruler.before('paragraph', 'deflist', deflist, { alt: ['paragraph', 'reference', 'blockquote'] });
25401
25510
  }
25402
25511
 
25512
+ function Diff() {}
25513
+ Diff.prototype = {
25514
+ diff: function diff(oldString, newString) {
25515
+ var _options$timeout;
25516
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
25517
+ var callback = options.callback;
25518
+ if (typeof options === 'function') {
25519
+ callback = options;
25520
+ options = {};
25521
+ }
25522
+ var self = this;
25523
+ function done(value) {
25524
+ value = self.postProcess(value, options);
25525
+ if (callback) {
25526
+ setTimeout(function () {
25527
+ callback(value);
25528
+ }, 0);
25529
+ return true;
25530
+ } else {
25531
+ return value;
25532
+ }
25533
+ }
25534
+
25535
+ // Allow subclasses to massage the input prior to running
25536
+ oldString = this.castInput(oldString, options);
25537
+ newString = this.castInput(newString, options);
25538
+ oldString = this.removeEmpty(this.tokenize(oldString, options));
25539
+ newString = this.removeEmpty(this.tokenize(newString, options));
25540
+ var newLen = newString.length,
25541
+ oldLen = oldString.length;
25542
+ var editLength = 1;
25543
+ var maxEditLength = newLen + oldLen;
25544
+ if (options.maxEditLength != null) {
25545
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
25546
+ }
25547
+ var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== undefined ? _options$timeout : Infinity;
25548
+ var abortAfterTimestamp = Date.now() + maxExecutionTime;
25549
+ var bestPath = [{
25550
+ oldPos: -1,
25551
+ lastComponent: undefined
25552
+ }];
25553
+
25554
+ // Seed editLength = 0, i.e. the content starts with the same values
25555
+ var newPos = this.extractCommon(bestPath[0], newString, oldString, 0, options);
25556
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
25557
+ // Identity per the equality and tokenizer
25558
+ return done(buildValues(self, bestPath[0].lastComponent, newString, oldString, self.useLongestToken));
25559
+ }
25560
+
25561
+ // Once we hit the right edge of the edit graph on some diagonal k, we can
25562
+ // definitely reach the end of the edit graph in no more than k edits, so
25563
+ // there's no point in considering any moves to diagonal k+1 any more (from
25564
+ // which we're guaranteed to need at least k+1 more edits).
25565
+ // Similarly, once we've reached the bottom of the edit graph, there's no
25566
+ // point considering moves to lower diagonals.
25567
+ // We record this fact by setting minDiagonalToConsider and
25568
+ // maxDiagonalToConsider to some finite value once we've hit the edge of
25569
+ // the edit graph.
25570
+ // This optimization is not faithful to the original algorithm presented in
25571
+ // Myers's paper, which instead pointlessly extends D-paths off the end of
25572
+ // the edit graph - see page 7 of Myers's paper which notes this point
25573
+ // explicitly and illustrates it with a diagram. This has major performance
25574
+ // implications for some common scenarios. For instance, to compute a diff
25575
+ // where the new text simply appends d characters on the end of the
25576
+ // original text of length n, the true Myers algorithm will take O(n+d^2)
25577
+ // time while this optimization needs only O(n+d) time.
25578
+ var minDiagonalToConsider = -Infinity,
25579
+ maxDiagonalToConsider = Infinity;
25580
+
25581
+ // Main worker method. checks all permutations of a given edit length for acceptance.
25582
+ function execEditLength() {
25583
+ for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
25584
+ var basePath = undefined;
25585
+ var removePath = bestPath[diagonalPath - 1],
25586
+ addPath = bestPath[diagonalPath + 1];
25587
+ if (removePath) {
25588
+ // No one else is going to attempt to use this value, clear it
25589
+ bestPath[diagonalPath - 1] = undefined;
25590
+ }
25591
+ var canAdd = false;
25592
+ if (addPath) {
25593
+ // what newPos will be after we do an insertion:
25594
+ var addPathNewPos = addPath.oldPos - diagonalPath;
25595
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
25596
+ }
25597
+ var canRemove = removePath && removePath.oldPos + 1 < oldLen;
25598
+ if (!canAdd && !canRemove) {
25599
+ // If this path is a terminal then prune
25600
+ bestPath[diagonalPath] = undefined;
25601
+ continue;
25602
+ }
25603
+
25604
+ // Select the diagonal that we want to branch from. We select the prior
25605
+ // path whose position in the old string is the farthest from the origin
25606
+ // and does not pass the bounds of the diff graph
25607
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
25608
+ basePath = self.addToPath(addPath, true, false, 0, options);
25609
+ } else {
25610
+ basePath = self.addToPath(removePath, false, true, 1, options);
25611
+ }
25612
+ newPos = self.extractCommon(basePath, newString, oldString, diagonalPath, options);
25613
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
25614
+ // If we have hit the end of both strings, then we are done
25615
+ return done(buildValues(self, basePath.lastComponent, newString, oldString, self.useLongestToken));
25616
+ } else {
25617
+ bestPath[diagonalPath] = basePath;
25618
+ if (basePath.oldPos + 1 >= oldLen) {
25619
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
25620
+ }
25621
+ if (newPos + 1 >= newLen) {
25622
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
25623
+ }
25624
+ }
25625
+ }
25626
+ editLength++;
25627
+ }
25628
+
25629
+ // Performs the length of edit iteration. Is a bit fugly as this has to support the
25630
+ // sync and async mode which is never fun. Loops over execEditLength until a value
25631
+ // is produced, or until the edit length exceeds options.maxEditLength (if given),
25632
+ // in which case it will return undefined.
25633
+ if (callback) {
25634
+ (function exec() {
25635
+ setTimeout(function () {
25636
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
25637
+ return callback();
25638
+ }
25639
+ if (!execEditLength()) {
25640
+ exec();
25641
+ }
25642
+ }, 0);
25643
+ })();
25644
+ } else {
25645
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
25646
+ var ret = execEditLength();
25647
+ if (ret) {
25648
+ return ret;
25649
+ }
25650
+ }
25651
+ }
25652
+ },
25653
+ addToPath: function addToPath(path, added, removed, oldPosInc, options) {
25654
+ var last = path.lastComponent;
25655
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
25656
+ return {
25657
+ oldPos: path.oldPos + oldPosInc,
25658
+ lastComponent: {
25659
+ count: last.count + 1,
25660
+ added: added,
25661
+ removed: removed,
25662
+ previousComponent: last.previousComponent
25663
+ }
25664
+ };
25665
+ } else {
25666
+ return {
25667
+ oldPos: path.oldPos + oldPosInc,
25668
+ lastComponent: {
25669
+ count: 1,
25670
+ added: added,
25671
+ removed: removed,
25672
+ previousComponent: last
25673
+ }
25674
+ };
25675
+ }
25676
+ },
25677
+ extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath, options) {
25678
+ var newLen = newString.length,
25679
+ oldLen = oldString.length,
25680
+ oldPos = basePath.oldPos,
25681
+ newPos = oldPos - diagonalPath,
25682
+ commonCount = 0;
25683
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldString[oldPos + 1], newString[newPos + 1], options)) {
25684
+ newPos++;
25685
+ oldPos++;
25686
+ commonCount++;
25687
+ if (options.oneChangePerToken) {
25688
+ basePath.lastComponent = {
25689
+ count: 1,
25690
+ previousComponent: basePath.lastComponent,
25691
+ added: false,
25692
+ removed: false
25693
+ };
25694
+ }
25695
+ }
25696
+ if (commonCount && !options.oneChangePerToken) {
25697
+ basePath.lastComponent = {
25698
+ count: commonCount,
25699
+ previousComponent: basePath.lastComponent,
25700
+ added: false,
25701
+ removed: false
25702
+ };
25703
+ }
25704
+ basePath.oldPos = oldPos;
25705
+ return newPos;
25706
+ },
25707
+ equals: function equals(left, right, options) {
25708
+ if (options.comparator) {
25709
+ return options.comparator(left, right);
25710
+ } else {
25711
+ return left === right || options.ignoreCase && left.toLowerCase() === right.toLowerCase();
25712
+ }
25713
+ },
25714
+ removeEmpty: function removeEmpty(array) {
25715
+ var ret = [];
25716
+ for (var i = 0; i < array.length; i++) {
25717
+ if (array[i]) {
25718
+ ret.push(array[i]);
25719
+ }
25720
+ }
25721
+ return ret;
25722
+ },
25723
+ castInput: function castInput(value) {
25724
+ return value;
25725
+ },
25726
+ tokenize: function tokenize(value) {
25727
+ return Array.from(value);
25728
+ },
25729
+ join: function join(chars) {
25730
+ return chars.join('');
25731
+ },
25732
+ postProcess: function postProcess(changeObjects) {
25733
+ return changeObjects;
25734
+ }
25735
+ };
25736
+ function buildValues(diff, lastComponent, newString, oldString, useLongestToken) {
25737
+ // First we convert our linked list of components in reverse order to an
25738
+ // array in the right order:
25739
+ var components = [];
25740
+ var nextComponent;
25741
+ while (lastComponent) {
25742
+ components.push(lastComponent);
25743
+ nextComponent = lastComponent.previousComponent;
25744
+ delete lastComponent.previousComponent;
25745
+ lastComponent = nextComponent;
25746
+ }
25747
+ components.reverse();
25748
+ var componentPos = 0,
25749
+ componentLen = components.length,
25750
+ newPos = 0,
25751
+ oldPos = 0;
25752
+ for (; componentPos < componentLen; componentPos++) {
25753
+ var component = components[componentPos];
25754
+ if (!component.removed) {
25755
+ if (!component.added && useLongestToken) {
25756
+ var value = newString.slice(newPos, newPos + component.count);
25757
+ value = value.map(function (value, i) {
25758
+ var oldValue = oldString[oldPos + i];
25759
+ return oldValue.length > value.length ? oldValue : value;
25760
+ });
25761
+ component.value = diff.join(value);
25762
+ } else {
25763
+ component.value = diff.join(newString.slice(newPos, newPos + component.count));
25764
+ }
25765
+ newPos += component.count;
25766
+
25767
+ // Common case
25768
+ if (!component.added) {
25769
+ oldPos += component.count;
25770
+ }
25771
+ } else {
25772
+ component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
25773
+ oldPos += component.count;
25774
+ }
25775
+ }
25776
+ return components;
25777
+ }
25778
+
25779
+ function longestCommonPrefix(str1, str2) {
25780
+ var i;
25781
+ for (i = 0; i < str1.length && i < str2.length; i++) {
25782
+ if (str1[i] != str2[i]) {
25783
+ return str1.slice(0, i);
25784
+ }
25785
+ }
25786
+ return str1.slice(0, i);
25787
+ }
25788
+ function longestCommonSuffix(str1, str2) {
25789
+ var i;
25790
+
25791
+ // Unlike longestCommonPrefix, we need a special case to handle all scenarios
25792
+ // where we return the empty string since str1.slice(-0) will return the
25793
+ // entire string.
25794
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
25795
+ return '';
25796
+ }
25797
+ for (i = 0; i < str1.length && i < str2.length; i++) {
25798
+ if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
25799
+ return str1.slice(-i);
25800
+ }
25801
+ }
25802
+ return str1.slice(-i);
25803
+ }
25804
+ function replacePrefix(string, oldPrefix, newPrefix) {
25805
+ if (string.slice(0, oldPrefix.length) != oldPrefix) {
25806
+ throw Error("string ".concat(JSON.stringify(string), " doesn't start with prefix ").concat(JSON.stringify(oldPrefix), "; this is a bug"));
25807
+ }
25808
+ return newPrefix + string.slice(oldPrefix.length);
25809
+ }
25810
+ function replaceSuffix(string, oldSuffix, newSuffix) {
25811
+ if (!oldSuffix) {
25812
+ return string + newSuffix;
25813
+ }
25814
+ if (string.slice(-oldSuffix.length) != oldSuffix) {
25815
+ throw Error("string ".concat(JSON.stringify(string), " doesn't end with suffix ").concat(JSON.stringify(oldSuffix), "; this is a bug"));
25816
+ }
25817
+ return string.slice(0, -oldSuffix.length) + newSuffix;
25818
+ }
25819
+ function removePrefix(string, oldPrefix) {
25820
+ return replacePrefix(string, oldPrefix, '');
25821
+ }
25822
+ function removeSuffix(string, oldSuffix) {
25823
+ return replaceSuffix(string, oldSuffix, '');
25824
+ }
25825
+ function maximumOverlap(string1, string2) {
25826
+ return string2.slice(0, overlapCount(string1, string2));
25827
+ }
25828
+
25829
+ // Nicked from https://stackoverflow.com/a/60422853/1709587
25830
+ function overlapCount(a, b) {
25831
+ // Deal with cases where the strings differ in length
25832
+ var startA = 0;
25833
+ if (a.length > b.length) {
25834
+ startA = a.length - b.length;
25835
+ }
25836
+ var endB = b.length;
25837
+ if (a.length < b.length) {
25838
+ endB = a.length;
25839
+ }
25840
+ // Create a back-reference for each index
25841
+ // that should be followed in case of a mismatch.
25842
+ // We only need B to make these references:
25843
+ var map = Array(endB);
25844
+ var k = 0; // Index that lags behind j
25845
+ map[0] = 0;
25846
+ for (var j = 1; j < endB; j++) {
25847
+ if (b[j] == b[k]) {
25848
+ map[j] = map[k]; // skip over the same character (optional optimisation)
25849
+ } else {
25850
+ map[j] = k;
25851
+ }
25852
+ while (k > 0 && b[j] != b[k]) {
25853
+ k = map[k];
25854
+ }
25855
+ if (b[j] == b[k]) {
25856
+ k++;
25857
+ }
25858
+ }
25859
+ // Phase 2: use these references while iterating over A
25860
+ k = 0;
25861
+ for (var i = startA; i < a.length; i++) {
25862
+ while (k > 0 && a[i] != b[k]) {
25863
+ k = map[k];
25864
+ }
25865
+ if (a[i] == b[k]) {
25866
+ k++;
25867
+ }
25868
+ }
25869
+ return k;
25870
+ }
25871
+
25872
+ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
25873
+ //
25874
+ // Ranges and exceptions:
25875
+ // Latin-1 Supplement, 0080–00FF
25876
+ // - U+00D7 × Multiplication sign
25877
+ // - U+00F7 ÷ Division sign
25878
+ // Latin Extended-A, 0100–017F
25879
+ // Latin Extended-B, 0180–024F
25880
+ // IPA Extensions, 0250–02AF
25881
+ // Spacing Modifier Letters, 02B0–02FF
25882
+ // - U+02C7 ˇ &#711; Caron
25883
+ // - U+02D8 ˘ &#728; Breve
25884
+ // - U+02D9 ˙ &#729; Dot Above
25885
+ // - U+02DA ˚ &#730; Ring Above
25886
+ // - U+02DB ˛ &#731; Ogonek
25887
+ // - U+02DC ˜ &#732; Small Tilde
25888
+ // - U+02DD ˝ &#733; Double Acute Accent
25889
+ // Latin Extended Additional, 1E00–1EFF
25890
+ var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
25891
+
25892
+ // Each token is one of the following:
25893
+ // - A punctuation mark plus the surrounding whitespace
25894
+ // - A word plus the surrounding whitespace
25895
+ // - Pure whitespace (but only in the special case where this the entire text
25896
+ // is just whitespace)
25897
+ //
25898
+ // We have to include surrounding whitespace in the tokens because the two
25899
+ // alternative approaches produce horribly broken results:
25900
+ // * If we just discard the whitespace, we can't fully reproduce the original
25901
+ // text from the sequence of tokens and any attempt to render the diff will
25902
+ // get the whitespace wrong.
25903
+ // * If we have separate tokens for whitespace, then in a typical text every
25904
+ // second token will be a single space character. But this often results in
25905
+ // the optimal diff between two texts being a perverse one that preserves
25906
+ // the spaces between words but deletes and reinserts actual common words.
25907
+ // See https://github.com/kpdecker/jsdiff/issues/160#issuecomment-1866099640
25908
+ // for an example.
25909
+ //
25910
+ // Keeping the surrounding whitespace of course has implications for .equals
25911
+ // and .join, not just .tokenize.
25912
+
25913
+ // This regex does NOT fully implement the tokenization rules described above.
25914
+ // Instead, it gives runs of whitespace their own "token". The tokenize method
25915
+ // then handles stitching whitespace tokens onto adjacent word or punctuation
25916
+ // tokens.
25917
+ var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), 'ug');
25918
+ var wordDiff = new Diff();
25919
+ wordDiff.equals = function (left, right, options) {
25920
+ if (options.ignoreCase) {
25921
+ left = left.toLowerCase();
25922
+ right = right.toLowerCase();
25923
+ }
25924
+ return left.trim() === right.trim();
25925
+ };
25926
+ wordDiff.tokenize = function (value) {
25927
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25928
+ var parts;
25929
+ if (options.intlSegmenter) {
25930
+ if (options.intlSegmenter.resolvedOptions().granularity != 'word') {
25931
+ throw new Error('The segmenter passed must have a granularity of "word"');
25932
+ }
25933
+ parts = Array.from(options.intlSegmenter.segment(value), function (segment) {
25934
+ return segment.segment;
25935
+ });
25936
+ } else {
25937
+ parts = value.match(tokenizeIncludingWhitespace) || [];
25938
+ }
25939
+ var tokens = [];
25940
+ var prevPart = null;
25941
+ parts.forEach(function (part) {
25942
+ if (/\s/.test(part)) {
25943
+ if (prevPart == null) {
25944
+ tokens.push(part);
25945
+ } else {
25946
+ tokens.push(tokens.pop() + part);
25947
+ }
25948
+ } else if (/\s/.test(prevPart)) {
25949
+ if (tokens[tokens.length - 1] == prevPart) {
25950
+ tokens.push(tokens.pop() + part);
25951
+ } else {
25952
+ tokens.push(prevPart + part);
25953
+ }
25954
+ } else {
25955
+ tokens.push(part);
25956
+ }
25957
+ prevPart = part;
25958
+ });
25959
+ return tokens;
25960
+ };
25961
+ wordDiff.join = function (tokens) {
25962
+ // Tokens being joined here will always have appeared consecutively in the
25963
+ // same text, so we can simply strip off the leading whitespace from all the
25964
+ // tokens except the first (and except any whitespace-only tokens - but such
25965
+ // a token will always be the first and only token anyway) and then join them
25966
+ // and the whitespace around words and punctuation will end up correct.
25967
+ return tokens.map(function (token, i) {
25968
+ if (i == 0) {
25969
+ return token;
25970
+ } else {
25971
+ return token.replace(/^\s+/, '');
25972
+ }
25973
+ }).join('');
25974
+ };
25975
+ wordDiff.postProcess = function (changes, options) {
25976
+ if (!changes || options.oneChangePerToken) {
25977
+ return changes;
25978
+ }
25979
+ var lastKeep = null;
25980
+ // Change objects representing any insertion or deletion since the last
25981
+ // "keep" change object. There can be at most one of each.
25982
+ var insertion = null;
25983
+ var deletion = null;
25984
+ changes.forEach(function (change) {
25985
+ if (change.added) {
25986
+ insertion = change;
25987
+ } else if (change.removed) {
25988
+ deletion = change;
25989
+ } else {
25990
+ if (insertion || deletion) {
25991
+ // May be false at start of text
25992
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
25993
+ }
25994
+ lastKeep = change;
25995
+ insertion = null;
25996
+ deletion = null;
25997
+ }
25998
+ });
25999
+ if (insertion || deletion) {
26000
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
26001
+ }
26002
+ return changes;
26003
+ };
26004
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
26005
+ // Before returning, we tidy up the leading and trailing whitespace of the
26006
+ // change objects to eliminate cases where trailing whitespace in one object
26007
+ // is repeated as leading whitespace in the next.
26008
+ // Below are examples of the outcomes we want here to explain the code.
26009
+ // I=insert, K=keep, D=delete
26010
+ // 1. diffing 'foo bar baz' vs 'foo baz'
26011
+ // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'
26012
+ // After cleanup, we want: K:'foo ' D:'bar ' K:'baz'
26013
+ //
26014
+ // 2. Diffing 'foo bar baz' vs 'foo qux baz'
26015
+ // Prior to cleanup, we have K:'foo ' D:' bar ' I:' qux ' K:' baz'
26016
+ // After cleanup, we want K:'foo ' D:'bar' I:'qux' K:' baz'
26017
+ //
26018
+ // 3. Diffing 'foo\nbar baz' vs 'foo baz'
26019
+ // Prior to cleanup, we have K:'foo ' D:'\nbar ' K:' baz'
26020
+ // After cleanup, we want K'foo' D:'\nbar' K:' baz'
26021
+ //
26022
+ // 4. Diffing 'foo baz' vs 'foo\nbar baz'
26023
+ // Prior to cleanup, we have K:'foo\n' I:'\nbar ' K:' baz'
26024
+ // After cleanup, we ideally want K'foo' I:'\nbar' K:' baz'
26025
+ // but don't actually manage this currently (the pre-cleanup change
26026
+ // objects don't contain enough information to make it possible).
26027
+ //
26028
+ // 5. Diffing 'foo bar baz' vs 'foo baz'
26029
+ // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'
26030
+ // After cleanup, we want K:'foo ' D:' bar ' K:'baz'
26031
+ //
26032
+ // Our handling is unavoidably imperfect in the case where there's a single
26033
+ // indel between keeps and the whitespace has changed. For instance, consider
26034
+ // diffing 'foo\tbar\nbaz' vs 'foo baz'. Unless we create an extra change
26035
+ // object to represent the insertion of the space character (which isn't even
26036
+ // a token), we have no way to avoid losing information about the texts'
26037
+ // original whitespace in the result we return. Still, we do our best to
26038
+ // output something that will look sensible if we e.g. print it with
26039
+ // insertions in green and deletions in red.
26040
+
26041
+ // Between two "keep" change objects (or before the first or after the last
26042
+ // change object), we can have either:
26043
+ // * A "delete" followed by an "insert"
26044
+ // * Just an "insert"
26045
+ // * Just a "delete"
26046
+ // We handle the three cases separately.
26047
+ if (deletion && insertion) {
26048
+ var oldWsPrefix = deletion.value.match(/^\s*/)[0];
26049
+ var oldWsSuffix = deletion.value.match(/\s*$/)[0];
26050
+ var newWsPrefix = insertion.value.match(/^\s*/)[0];
26051
+ var newWsSuffix = insertion.value.match(/\s*$/)[0];
26052
+ if (startKeep) {
26053
+ var commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
26054
+ startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
26055
+ deletion.value = removePrefix(deletion.value, commonWsPrefix);
26056
+ insertion.value = removePrefix(insertion.value, commonWsPrefix);
26057
+ }
26058
+ if (endKeep) {
26059
+ var commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
26060
+ endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
26061
+ deletion.value = removeSuffix(deletion.value, commonWsSuffix);
26062
+ insertion.value = removeSuffix(insertion.value, commonWsSuffix);
26063
+ }
26064
+ } else if (insertion) {
26065
+ // The whitespaces all reflect what was in the new text rather than
26066
+ // the old, so we essentially have no information about whitespace
26067
+ // insertion or deletion. We just want to dedupe the whitespace.
26068
+ // We do that by having each change object keep its trailing
26069
+ // whitespace and deleting duplicate leading whitespace where
26070
+ // present.
26071
+ if (startKeep) {
26072
+ insertion.value = insertion.value.replace(/^\s*/, '');
26073
+ }
26074
+ if (endKeep) {
26075
+ endKeep.value = endKeep.value.replace(/^\s*/, '');
26076
+ }
26077
+ // otherwise we've got a deletion and no insertion
26078
+ } else if (startKeep && endKeep) {
26079
+ var newWsFull = endKeep.value.match(/^\s*/)[0],
26080
+ delWsStart = deletion.value.match(/^\s*/)[0],
26081
+ delWsEnd = deletion.value.match(/\s*$/)[0];
26082
+
26083
+ // Any whitespace that comes straight after startKeep in both the old and
26084
+ // new texts, assign to startKeep and remove from the deletion.
26085
+ var newWsStart = longestCommonPrefix(newWsFull, delWsStart);
26086
+ deletion.value = removePrefix(deletion.value, newWsStart);
26087
+
26088
+ // Any whitespace that comes straight before endKeep in both the old and
26089
+ // new texts, and hasn't already been assigned to startKeep, assign to
26090
+ // endKeep and remove from the deletion.
26091
+ var newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
26092
+ deletion.value = removeSuffix(deletion.value, newWsEnd);
26093
+ endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
26094
+
26095
+ // If there's any whitespace from the new text that HASN'T already been
26096
+ // assigned, assign it to the start:
26097
+ startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
26098
+ } else if (endKeep) {
26099
+ // We are at the start of the text. Preserve all the whitespace on
26100
+ // endKeep, and just remove whitespace from the end of deletion to the
26101
+ // extent that it overlaps with the start of endKeep.
26102
+ var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
26103
+ var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
26104
+ var overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
26105
+ deletion.value = removeSuffix(deletion.value, overlap);
26106
+ } else if (startKeep) {
26107
+ // We are at the END of the text. Preserve all the whitespace on
26108
+ // startKeep, and just remove whitespace from the start of deletion to
26109
+ // the extent that it overlaps with the end of startKeep.
26110
+ var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
26111
+ var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
26112
+ var _overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
26113
+ deletion.value = removePrefix(deletion.value, _overlap);
26114
+ }
26115
+ }
26116
+ var wordWithSpaceDiff = new Diff();
26117
+ wordWithSpaceDiff.tokenize = function (value) {
26118
+ // Slightly different to the tokenizeIncludingWhitespace regex used above in
26119
+ // that this one treats each individual newline as a distinct tokens, rather
26120
+ // than merging them into other surrounding whitespace. This was requested
26121
+ // in https://github.com/kpdecker/jsdiff/issues/180 &
26122
+ // https://github.com/kpdecker/jsdiff/issues/211
26123
+ var regex = new RegExp("(\\r?\\n)|[".concat(extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), 'ug');
26124
+ return value.match(regex) || [];
26125
+ };
26126
+
26127
+ var lineDiff = new Diff();
26128
+ lineDiff.tokenize = function (value, options) {
26129
+ if (options.stripTrailingCr) {
26130
+ // remove one \r before \n to match GNU diff's --strip-trailing-cr behavior
26131
+ value = value.replace(/\r\n/g, '\n');
26132
+ }
26133
+ var retLines = [],
26134
+ linesAndNewlines = value.split(/(\n|\r\n)/);
26135
+
26136
+ // Ignore the final empty token that occurs if the string ends with a new line
26137
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
26138
+ linesAndNewlines.pop();
26139
+ }
26140
+
26141
+ // Merge the content and line separators into single tokens
26142
+ for (var i = 0; i < linesAndNewlines.length; i++) {
26143
+ var line = linesAndNewlines[i];
26144
+ if (i % 2 && !options.newlineIsToken) {
26145
+ retLines[retLines.length - 1] += line;
26146
+ } else {
26147
+ retLines.push(line);
26148
+ }
26149
+ }
26150
+ return retLines;
26151
+ };
26152
+ lineDiff.equals = function (left, right, options) {
26153
+ // If we're ignoring whitespace, we need to normalise lines by stripping
26154
+ // whitespace before checking equality. (This has an annoying interaction
26155
+ // with newlineIsToken that requires special handling: if newlines get their
26156
+ // own token, then we DON'T want to trim the *newline* tokens down to empty
26157
+ // strings, since this would cause us to treat whitespace-only line content
26158
+ // as equal to a separator between lines, which would be weird and
26159
+ // inconsistent with the documented behavior of the options.)
26160
+ if (options.ignoreWhitespace) {
26161
+ if (!options.newlineIsToken || !left.includes('\n')) {
26162
+ left = left.trim();
26163
+ }
26164
+ if (!options.newlineIsToken || !right.includes('\n')) {
26165
+ right = right.trim();
26166
+ }
26167
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
26168
+ if (left.endsWith('\n')) {
26169
+ left = left.slice(0, -1);
26170
+ }
26171
+ if (right.endsWith('\n')) {
26172
+ right = right.slice(0, -1);
26173
+ }
26174
+ }
26175
+ return Diff.prototype.equals.call(this, left, right, options);
26176
+ };
26177
+ function diffLines(oldStr, newStr, callback) {
26178
+ return lineDiff.diff(oldStr, newStr, callback);
26179
+ }
26180
+
26181
+ var sentenceDiff = new Diff();
26182
+ sentenceDiff.tokenize = function (value) {
26183
+ return value.split(/(\S.+?[.!?])(?=\s+|$)/);
26184
+ };
26185
+
26186
+ var cssDiff = new Diff();
26187
+ cssDiff.tokenize = function (value) {
26188
+ return value.split(/([{}:;,]|\s+)/);
26189
+ };
26190
+
26191
+ function ownKeys(e, r) {
26192
+ var t = Object.keys(e);
26193
+ if (Object.getOwnPropertySymbols) {
26194
+ var o = Object.getOwnPropertySymbols(e);
26195
+ r && (o = o.filter(function (r) {
26196
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
26197
+ })), t.push.apply(t, o);
26198
+ }
26199
+ return t;
26200
+ }
26201
+ function _objectSpread2(e) {
26202
+ for (var r = 1; r < arguments.length; r++) {
26203
+ var t = null != arguments[r] ? arguments[r] : {};
26204
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
26205
+ _defineProperty(e, r, t[r]);
26206
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
26207
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
26208
+ });
26209
+ }
26210
+ return e;
26211
+ }
26212
+ function _toPrimitive(t, r) {
26213
+ if ("object" != typeof t || !t) return t;
26214
+ var e = t[Symbol.toPrimitive];
26215
+ if (undefined !== e) {
26216
+ var i = e.call(t, r);
26217
+ if ("object" != typeof i) return i;
26218
+ throw new TypeError("@@toPrimitive must return a primitive value.");
26219
+ }
26220
+ return ("string" === r ? String : Number)(t);
26221
+ }
26222
+ function _toPropertyKey(t) {
26223
+ var i = _toPrimitive(t, "string");
26224
+ return "symbol" == typeof i ? i : i + "";
26225
+ }
26226
+ function _typeof(o) {
26227
+ "@babel/helpers - typeof";
26228
+
26229
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
26230
+ return typeof o;
26231
+ } : function (o) {
26232
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
26233
+ }, _typeof(o);
26234
+ }
26235
+ function _defineProperty(obj, key, value) {
26236
+ key = _toPropertyKey(key);
26237
+ if (key in obj) {
26238
+ Object.defineProperty(obj, key, {
26239
+ value: value,
26240
+ enumerable: true,
26241
+ configurable: true,
26242
+ writable: true
26243
+ });
26244
+ } else {
26245
+ obj[key] = value;
26246
+ }
26247
+ return obj;
26248
+ }
26249
+ function _toConsumableArray(arr) {
26250
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
26251
+ }
26252
+ function _arrayWithoutHoles(arr) {
26253
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
26254
+ }
26255
+ function _iterableToArray(iter) {
26256
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
26257
+ }
26258
+ function _unsupportedIterableToArray(o, minLen) {
26259
+ if (!o) return;
26260
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
26261
+ var n = Object.prototype.toString.call(o).slice(8, -1);
26262
+ if (n === "Object" && o.constructor) n = o.constructor.name;
26263
+ if (n === "Map" || n === "Set") return Array.from(o);
26264
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
26265
+ }
26266
+ function _arrayLikeToArray(arr, len) {
26267
+ if (len == null || len > arr.length) len = arr.length;
26268
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
26269
+ return arr2;
26270
+ }
26271
+ function _nonIterableSpread() {
26272
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
26273
+ }
26274
+
26275
+ var jsonDiff = new Diff();
26276
+ // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
26277
+ // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
26278
+ jsonDiff.useLongestToken = true;
26279
+ jsonDiff.tokenize = lineDiff.tokenize;
26280
+ jsonDiff.castInput = function (value, options) {
26281
+ var undefinedReplacement = options.undefinedReplacement,
26282
+ _options$stringifyRep = options.stringifyReplacer,
26283
+ stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) {
26284
+ return typeof v === 'undefined' ? undefinedReplacement : v;
26285
+ } : _options$stringifyRep;
26286
+ return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
26287
+ };
26288
+ jsonDiff.equals = function (left, right, options) {
26289
+ return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options);
26290
+ };
26291
+
26292
+ // This function handles the presence of circular references by bailing out when encountering an
26293
+ // object that is already on the "stack" of items being processed. Accepts an optional replacer
26294
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
26295
+ stack = stack || [];
26296
+ replacementStack = replacementStack || [];
26297
+ if (replacer) {
26298
+ obj = replacer(key, obj);
26299
+ }
26300
+ var i;
26301
+ for (i = 0; i < stack.length; i += 1) {
26302
+ if (stack[i] === obj) {
26303
+ return replacementStack[i];
26304
+ }
26305
+ }
26306
+ var canonicalizedObj;
26307
+ if ('[object Array]' === Object.prototype.toString.call(obj)) {
26308
+ stack.push(obj);
26309
+ canonicalizedObj = new Array(obj.length);
26310
+ replacementStack.push(canonicalizedObj);
26311
+ for (i = 0; i < obj.length; i += 1) {
26312
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
26313
+ }
26314
+ stack.pop();
26315
+ replacementStack.pop();
26316
+ return canonicalizedObj;
26317
+ }
26318
+ if (obj && obj.toJSON) {
26319
+ obj = obj.toJSON();
26320
+ }
26321
+ if (_typeof(obj) === 'object' && obj !== null) {
26322
+ stack.push(obj);
26323
+ canonicalizedObj = {};
26324
+ replacementStack.push(canonicalizedObj);
26325
+ var sortedKeys = [],
26326
+ _key;
26327
+ for (_key in obj) {
26328
+ /* istanbul ignore else */
26329
+ if (Object.prototype.hasOwnProperty.call(obj, _key)) {
26330
+ sortedKeys.push(_key);
26331
+ }
26332
+ }
26333
+ sortedKeys.sort();
26334
+ for (i = 0; i < sortedKeys.length; i += 1) {
26335
+ _key = sortedKeys[i];
26336
+ canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
26337
+ }
26338
+ stack.pop();
26339
+ replacementStack.pop();
26340
+ } else {
26341
+ canonicalizedObj = obj;
26342
+ }
26343
+ return canonicalizedObj;
26344
+ }
26345
+
26346
+ var arrayDiff = new Diff();
26347
+ arrayDiff.tokenize = function (value) {
26348
+ return value.slice();
26349
+ };
26350
+ arrayDiff.join = arrayDiff.removeEmpty = function (value) {
26351
+ return value;
26352
+ };
26353
+
26354
+ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
26355
+ if (!options) {
26356
+ options = {};
26357
+ }
26358
+ if (typeof options === 'function') {
26359
+ options = {
26360
+ callback: options
26361
+ };
26362
+ }
26363
+ if (typeof options.context === 'undefined') {
26364
+ options.context = 4;
26365
+ }
26366
+ if (options.newlineIsToken) {
26367
+ throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');
26368
+ }
26369
+ if (!options.callback) {
26370
+ return diffLinesResultToPatch(diffLines(oldStr, newStr, options));
26371
+ } else {
26372
+ var _options = options,
26373
+ _callback = _options.callback;
26374
+ diffLines(oldStr, newStr, _objectSpread2(_objectSpread2({}, options), {}, {
26375
+ callback: function callback(diff) {
26376
+ var patch = diffLinesResultToPatch(diff);
26377
+ _callback(patch);
26378
+ }
26379
+ }));
26380
+ }
26381
+ function diffLinesResultToPatch(diff) {
26382
+ // STEP 1: Build up the patch with no "" lines and with the arrays
26383
+ // of lines containing trailing newline characters. We'll tidy up later...
26384
+
26385
+ if (!diff) {
26386
+ return;
26387
+ }
26388
+ diff.push({
26389
+ value: '',
26390
+ lines: []
26391
+ }); // Append an empty value to make cleanup easier
26392
+
26393
+ function contextLines(lines) {
26394
+ return lines.map(function (entry) {
26395
+ return ' ' + entry;
26396
+ });
26397
+ }
26398
+ var hunks = [];
26399
+ var oldRangeStart = 0,
26400
+ newRangeStart = 0,
26401
+ curRange = [],
26402
+ oldLine = 1,
26403
+ newLine = 1;
26404
+ var _loop = function _loop() {
26405
+ var current = diff[i],
26406
+ lines = current.lines || splitLines(current.value);
26407
+ current.lines = lines;
26408
+ if (current.added || current.removed) {
26409
+ var _curRange;
26410
+ // If we have previous context, start with that
26411
+ if (!oldRangeStart) {
26412
+ var prev = diff[i - 1];
26413
+ oldRangeStart = oldLine;
26414
+ newRangeStart = newLine;
26415
+ if (prev) {
26416
+ curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
26417
+ oldRangeStart -= curRange.length;
26418
+ newRangeStart -= curRange.length;
26419
+ }
26420
+ }
26421
+
26422
+ // Output our changes
26423
+ (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
26424
+ return (current.added ? '+' : '-') + entry;
26425
+ })));
26426
+
26427
+ // Track the updated file position
26428
+ if (current.added) {
26429
+ newLine += lines.length;
26430
+ } else {
26431
+ oldLine += lines.length;
26432
+ }
26433
+ } else {
26434
+ // Identical context lines. Track line changes
26435
+ if (oldRangeStart) {
26436
+ // Close out any changes that have been output (or join overlapping)
26437
+ if (lines.length <= options.context * 2 && i < diff.length - 2) {
26438
+ var _curRange2;
26439
+ // Overlapping
26440
+ (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
26441
+ } else {
26442
+ var _curRange3;
26443
+ // end the range and output
26444
+ var contextSize = Math.min(lines.length, options.context);
26445
+ (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
26446
+ var _hunk = {
26447
+ oldStart: oldRangeStart,
26448
+ oldLines: oldLine - oldRangeStart + contextSize,
26449
+ newStart: newRangeStart,
26450
+ newLines: newLine - newRangeStart + contextSize,
26451
+ lines: curRange
26452
+ };
26453
+ hunks.push(_hunk);
26454
+ oldRangeStart = 0;
26455
+ newRangeStart = 0;
26456
+ curRange = [];
26457
+ }
26458
+ }
26459
+ oldLine += lines.length;
26460
+ newLine += lines.length;
26461
+ }
26462
+ };
26463
+ for (var i = 0; i < diff.length; i++) {
26464
+ _loop();
26465
+ }
26466
+
26467
+ // Step 2: eliminate the trailing `\n` from each line of each hunk, and, where needed, add
26468
+ // "".
26469
+ for (var _i = 0, _hunks = hunks; _i < _hunks.length; _i++) {
26470
+ var hunk = _hunks[_i];
26471
+ for (var _i2 = 0; _i2 < hunk.lines.length; _i2++) {
26472
+ if (hunk.lines[_i2].endsWith('\n')) {
26473
+ hunk.lines[_i2] = hunk.lines[_i2].slice(0, -1);
26474
+ } else {
26475
+ hunk.lines.splice(_i2 + 1, 0, '\');
26476
+ _i2++; // Skip the line we just added, then continue iterating
26477
+ }
26478
+ }
26479
+ }
26480
+ return {
26481
+ oldFileName: oldFileName,
26482
+ newFileName: newFileName,
26483
+ oldHeader: oldHeader,
26484
+ newHeader: newHeader,
26485
+ hunks: hunks
26486
+ };
26487
+ }
26488
+ }
26489
+ function formatPatch(diff) {
26490
+ if (Array.isArray(diff)) {
26491
+ return diff.map(formatPatch).join('\n');
26492
+ }
26493
+ var ret = [];
26494
+ if (diff.oldFileName == diff.newFileName) {
26495
+ ret.push('Index: ' + diff.oldFileName);
26496
+ }
26497
+ ret.push('===================================================================');
26498
+ ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
26499
+ ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
26500
+ for (var i = 0; i < diff.hunks.length; i++) {
26501
+ var hunk = diff.hunks[i];
26502
+ // Unified Diff Format quirk: If the chunk size is 0,
26503
+ // the first number is one lower than one would expect.
26504
+ // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
26505
+ if (hunk.oldLines === 0) {
26506
+ hunk.oldStart -= 1;
26507
+ }
26508
+ if (hunk.newLines === 0) {
26509
+ hunk.newStart -= 1;
26510
+ }
26511
+ ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
26512
+ ret.push.apply(ret, hunk.lines);
26513
+ }
26514
+ return ret.join('\n') + '\n';
26515
+ }
26516
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
26517
+ var _options2;
26518
+ if (!((_options2 = options) !== null && _options2 !== undefined && _options2.callback)) {
26519
+ var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
26520
+ if (!patchObj) {
26521
+ return;
26522
+ }
26523
+ return formatPatch(patchObj);
26524
+ } else {
26525
+ var _options3 = options,
26526
+ _callback2 = _options3.callback;
26527
+ structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, _objectSpread2(_objectSpread2({}, options), {}, {
26528
+ callback: function callback(patchObj) {
26529
+ if (!patchObj) {
26530
+ _callback2();
26531
+ } else {
26532
+ _callback2(formatPatch(patchObj));
26533
+ }
26534
+ }
26535
+ }));
26536
+ }
26537
+ }
26538
+
26539
+ /**
26540
+ * Split `text` into an array of lines, including the trailing newline character (where present)
26541
+ */
26542
+ function splitLines(text) {
26543
+ var hasTrailingNl = text.endsWith('\n');
26544
+ var result = text.split('\n').map(function (line) {
26545
+ return line + '\n';
26546
+ });
26547
+ if (hasTrailingNl) {
26548
+ result.pop();
26549
+ } else {
26550
+ result.push(result.pop().slice(0, -1));
26551
+ }
26552
+ return result;
26553
+ }
26554
+
25403
26555
  /* eslint-disable no-multi-assign */
25404
26556
 
25405
26557
  var core;
@@ -52117,8 +53269,11 @@ var tinylr = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
52117
53269
  exports.HighlightJS = HighlightJS;
52118
53270
  exports.MarkdownIt = MarkdownIt;
52119
53271
  exports.cliProgress = cliProgress;
53272
+ exports.closest = closest;
53273
+ exports.createTwoFilesPatch = createTwoFilesPatch;
52120
53274
  exports.dedent = dedent;
52121
53275
  exports.deflist_plugin = deflist_plugin;
53276
+ exports.distance = distance;
52122
53277
  exports.fm = fm;
52123
53278
  exports.fse = fse;
52124
53279
  exports.glob = glob;