atcoder-diff-submissions

AtCoderの提出一覧から、選択した2つの提出間の差分を表示します。

2021-09-19 기준 버전입니다. 최신 버전을 확인하세요.

  1. // ==UserScript==
  2. // @name atcoder-diff-submissions
  3. // @namespace https://github.com/ilplrr
  4. // @version 1.0.0
  5. // @description AtCoderの提出一覧から、選択した2つの提出間の差分を表示します。
  6. // @author ilplrr
  7. // @license MIT
  8. // @match https://atcoder.jp/contests/*/submissions
  9. // @match https://atcoder.jp/contests/*/submissions?*
  10. // @match https://atcoder.jp/contests/*/submissions/me
  11. // @match https://atcoder.jp/contests/*/submissions/me?*
  12. // @supportURL https://github.com/ilplrr/atcoder-diff-submissions/issues
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. /*! Dependent modules License
  17. * diff
  18. * 5.0.0
  19. * BSD-3-Clause
  20. * Software License Agreement (BSD License)
  21. *
  22. * Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
  23. *
  24. * All rights reserved.
  25. *
  26. * Redistribution and use of this software in source and binary forms, with or without modification,
  27. * are permitted provided that the following conditions are met:
  28. *
  29. * * Redistributions of source code must retain the above
  30. * copyright notice, this list of conditions and the
  31. * following disclaimer.
  32. *
  33. * * Redistributions in binary form must reproduce the above
  34. * copyright notice, this list of conditions and the
  35. * following disclaimer in the documentation and/or other
  36. * materials provided with the distribution.
  37. *
  38. * * Neither the name of Kevin Decker nor the names of its
  39. * contributors may be used to endorse or promote products
  40. * derived from this software without specific prior
  41. * written permission.
  42. *
  43. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  44. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  45. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  46. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  47. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  48. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  49. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  50. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  51. *
  52. *
  53. * diff2html
  54. * 3.4.11
  55. * MIT
  56. * Copyright 2014-2016 Rodrigo Fernandes https://rtfpessoa.github.io/
  57. *
  58. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  59. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  60. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
  61. * persons to whom the Software is furnished to do so, subject to the following conditions:
  62. *
  63. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  64. * Software.
  65. *
  66. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  67. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  68. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  69. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  70. *
  71. */
  72.  
  73. /******/ (() => { // webpackBootstrap
  74. /******/ var __webpack_modules__ = ({
  75.  
  76. /***/ 650:
  77. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  78.  
  79. "use strict";
  80. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  81. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  82. /* harmony export */ });
  83. /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(645);
  84. /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
  85. // Imports
  86.  
  87. var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
  88. // Module
  89. ___CSS_LOADER_EXPORT___.push([module.id, ".d2h-d-none{display:none}.d2h-wrapper{text-align:left}.d2h-file-header{background-color:#f7f7f7;border-bottom:1px solid #d8d8d8;font-family:Source Sans Pro,Helvetica Neue,Helvetica,Arial,sans-serif;height:35px;padding:5px 10px}.d2h-file-header,.d2h-file-stats{display:-webkit-box;display:-ms-flexbox;display:flex}.d2h-file-stats{font-size:14px;margin-left:auto}.d2h-lines-added{border:1px solid #b4e2b4;border-radius:5px 0 0 5px;color:#399839;padding:2px;text-align:right;vertical-align:middle}.d2h-lines-deleted{border:1px solid #e9aeae;border-radius:0 5px 5px 0;color:#c33;margin-left:1px;padding:2px;text-align:left;vertical-align:middle}.d2h-file-name-wrapper{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:15px;width:100%}.d2h-file-name{overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap}.d2h-file-wrapper{border:1px solid #ddd;border-radius:3px;margin-bottom:1em}.d2h-file-collapse{-webkit-box-pack:end;-ms-flex-pack:end;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border:1px solid #ddd;border-radius:3px;cursor:pointer;display:none;font-size:12px;justify-content:flex-end;padding:4px 8px}.d2h-file-collapse.d2h-selected{background-color:#c8e1ff}.d2h-file-collapse-input{margin:0 4px 0 0}.d2h-diff-table{border-collapse:collapse;font-family:Menlo,Consolas,monospace;font-size:13px;width:100%}.d2h-files-diff{width:100%}.d2h-file-diff{overflow-y:hidden}.d2h-file-side-diff{display:inline-block;margin-bottom:-8px;margin-right:-4px;overflow-x:scroll;overflow-y:hidden;width:50%}.d2h-code-line{padding:0 8em}.d2h-code-line,.d2h-code-side-line{display:inline-block;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;width:100%}.d2h-code-side-line{padding:0 4.5em}.d2h-code-line-ctn{word-wrap:normal;background:none;display:inline-block;padding:0;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;vertical-align:middle;white-space:pre;width:100%}.d2h-code-line del,.d2h-code-side-line del{background-color:#ffb6ba}.d2h-code-line del,.d2h-code-line ins,.d2h-code-side-line del,.d2h-code-side-line ins{border-radius:.2em;display:inline-block;margin-top:-1px;text-decoration:none;vertical-align:middle}.d2h-code-line ins,.d2h-code-side-line ins{background-color:#97f295;text-align:left}.d2h-code-line-prefix{word-wrap:normal;background:none;display:inline;padding:0;white-space:pre}.line-num1{float:left}.line-num1,.line-num2{-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;padding:0 .5em;text-overflow:ellipsis;width:3.5em}.line-num2{float:right}.d2h-code-linenumber{background-color:#fff;border:solid #eee;border-width:0 1px;-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0,0,0,.3);cursor:pointer;display:inline-block;position:absolute;text-align:right;width:7.5em}.d2h-code-linenumber:after{content:\"\\200b\"}.d2h-code-side-linenumber{background-color:#fff;border:solid #eee;border-width:0 1px;-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0,0,0,.3);cursor:pointer;display:inline-block;overflow:hidden;padding:0 .5em;position:absolute;text-align:right;text-overflow:ellipsis;width:4em}.d2h-code-side-linenumber:after{content:\"\\200b\"}.d2h-code-side-emptyplaceholder,.d2h-emptyplaceholder{background-color:#f1f1f1;border-color:#e1e1e1}.d2h-code-line-prefix,.d2h-code-linenumber,.d2h-code-side-linenumber,.d2h-emptyplaceholder{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.d2h-code-linenumber,.d2h-code-side-linenumber{direction:rtl}.d2h-del{background-color:#fee8e9;border-color:#e9aeae}.d2h-ins{background-color:#dfd;border-color:#b4e2b4}.d2h-info{background-color:#f8fafd;border-color:#d5e4f2;color:rgba(0,0,0,.3)}.d2h-file-diff .d2h-del.d2h-change{background-color:#fdf2d0}.d2h-file-diff .d2h-ins.d2h-change{background-color:#ded}.d2h-file-list-wrapper{margin-bottom:10px}.d2h-file-list-wrapper a{color:#3572b0;text-decoration:none}.d2h-file-list-wrapper a:visited{color:#3572b0}.d2h-file-list-header{text-align:left}.d2h-file-list-title{font-weight:700}.d2h-file-list-line{display:-webkit-box;display:-ms-flexbox;display:flex;text-align:left}.d2h-file-list{display:block;list-style:none;margin:0;padding:0}.d2h-file-list>li{border-bottom:1px solid #ddd;margin:0;padding:5px 10px}.d2h-file-list>li:last-child{border-bottom:none}.d2h-file-switch{cursor:pointer;display:none;font-size:10px}.d2h-icon{fill:currentColor;margin-right:10px;vertical-align:middle}.d2h-deleted{color:#c33}.d2h-added{color:#399839}.d2h-changed{color:#d0b44c}.d2h-moved{color:#3572b0}.d2h-tag{background-color:#fff;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:10px;margin-left:5px;padding:0 2px}.d2h-deleted-tag{border:1px solid #c33}.d2h-added-tag{border:1px solid #399839}.d2h-changed-tag{border:1px solid #d0b44c}.d2h-moved-tag{border:1px solid #3572b0}", ""]);
  90. // Exports
  91. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  92.  
  93.  
  94. /***/ }),
  95.  
  96. /***/ 645:
  97. /***/ ((module) => {
  98.  
  99. "use strict";
  100.  
  101.  
  102. /*
  103. MIT License http://www.opensource.org/licenses/mit-license.php
  104. Author Tobias Koppers @sokra
  105. */
  106. // css base code, injected by the css-loader
  107. // eslint-disable-next-line func-names
  108. module.exports = function (cssWithMappingToString) {
  109. var list = []; // return the list of modules as css string
  110.  
  111. list.toString = function toString() {
  112. return this.map(function (item) {
  113. var content = cssWithMappingToString(item);
  114.  
  115. if (item[2]) {
  116. return "@media ".concat(item[2], " {").concat(content, "}");
  117. }
  118.  
  119. return content;
  120. }).join("");
  121. }; // import a list of modules into the list
  122. // eslint-disable-next-line func-names
  123.  
  124.  
  125. list.i = function (modules, mediaQuery, dedupe) {
  126. if (typeof modules === "string") {
  127. // eslint-disable-next-line no-param-reassign
  128. modules = [[null, modules, ""]];
  129. }
  130.  
  131. var alreadyImportedModules = {};
  132.  
  133. if (dedupe) {
  134. for (var i = 0; i < this.length; i++) {
  135. // eslint-disable-next-line prefer-destructuring
  136. var id = this[i][0];
  137.  
  138. if (id != null) {
  139. alreadyImportedModules[id] = true;
  140. }
  141. }
  142. }
  143.  
  144. for (var _i = 0; _i < modules.length; _i++) {
  145. var item = [].concat(modules[_i]);
  146.  
  147. if (dedupe && alreadyImportedModules[item[0]]) {
  148. // eslint-disable-next-line no-continue
  149. continue;
  150. }
  151.  
  152. if (mediaQuery) {
  153. if (!item[2]) {
  154. item[2] = mediaQuery;
  155. } else {
  156. item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
  157. }
  158. }
  159.  
  160. list.push(item);
  161. }
  162. };
  163.  
  164. return list;
  165. };
  166.  
  167. /***/ }),
  168.  
  169. /***/ 397:
  170. /***/ ((__unused_webpack_module, exports) => {
  171.  
  172. /*
  173. * Copyright 2011 Twitter, Inc.
  174. * Licensed under the Apache License, Version 2.0 (the "License");
  175. * you may not use this file except in compliance with the License.
  176. * You may obtain a copy of the License at
  177. *
  178. * http://www.apache.org/licenses/LICENSE-2.0
  179. *
  180. * Unless required by applicable law or agreed to in writing, software
  181. * distributed under the License is distributed on an "AS IS" BASIS,
  182. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  183. * See the License for the specific language governing permissions and
  184. * limitations under the License.
  185. */
  186.  
  187. (function (Hogan) {
  188. // Setup regex assignments
  189. // remove whitespace according to Mustache spec
  190. var rIsWhitespace = /\S/,
  191. rQuot = /\"/g,
  192. rNewline = /\n/g,
  193. rCr = /\r/g,
  194. rSlash = /\\/g,
  195. rLineSep = /\u2028/,
  196. rParagraphSep = /\u2029/;
  197.  
  198. Hogan.tags = {
  199. '#': 1, '^': 2, '<': 3, '$': 4,
  200. '/': 5, '!': 6, '>': 7, '=': 8, '_v': 9,
  201. '{': 10, '&': 11, '_t': 12
  202. };
  203.  
  204. Hogan.scan = function scan(text, delimiters) {
  205. var len = text.length,
  206. IN_TEXT = 0,
  207. IN_TAG_TYPE = 1,
  208. IN_TAG = 2,
  209. state = IN_TEXT,
  210. tagType = null,
  211. tag = null,
  212. buf = '',
  213. tokens = [],
  214. seenTag = false,
  215. i = 0,
  216. lineStart = 0,
  217. otag = '{{',
  218. ctag = '}}';
  219.  
  220. function addBuf() {
  221. if (buf.length > 0) {
  222. tokens.push({tag: '_t', text: new String(buf)});
  223. buf = '';
  224. }
  225. }
  226.  
  227. function lineIsWhitespace() {
  228. var isAllWhitespace = true;
  229. for (var j = lineStart; j < tokens.length; j++) {
  230. isAllWhitespace =
  231. (Hogan.tags[tokens[j].tag] < Hogan.tags['_v']) ||
  232. (tokens[j].tag == '_t' && tokens[j].text.match(rIsWhitespace) === null);
  233. if (!isAllWhitespace) {
  234. return false;
  235. }
  236. }
  237.  
  238. return isAllWhitespace;
  239. }
  240.  
  241. function filterLine(haveSeenTag, noNewLine) {
  242. addBuf();
  243.  
  244. if (haveSeenTag && lineIsWhitespace()) {
  245. for (var j = lineStart, next; j < tokens.length; j++) {
  246. if (tokens[j].text) {
  247. if ((next = tokens[j+1]) && next.tag == '>') {
  248. // set indent to token value
  249. next.indent = tokens[j].text.toString()
  250. }
  251. tokens.splice(j, 1);
  252. }
  253. }
  254. } else if (!noNewLine) {
  255. tokens.push({tag:'\n'});
  256. }
  257.  
  258. seenTag = false;
  259. lineStart = tokens.length;
  260. }
  261.  
  262. function changeDelimiters(text, index) {
  263. var close = '=' + ctag,
  264. closeIndex = text.indexOf(close, index),
  265. delimiters = trim(
  266. text.substring(text.indexOf('=', index) + 1, closeIndex)
  267. ).split(' ');
  268.  
  269. otag = delimiters[0];
  270. ctag = delimiters[delimiters.length - 1];
  271.  
  272. return closeIndex + close.length - 1;
  273. }
  274.  
  275. if (delimiters) {
  276. delimiters = delimiters.split(' ');
  277. otag = delimiters[0];
  278. ctag = delimiters[1];
  279. }
  280.  
  281. for (i = 0; i < len; i++) {
  282. if (state == IN_TEXT) {
  283. if (tagChange(otag, text, i)) {
  284. --i;
  285. addBuf();
  286. state = IN_TAG_TYPE;
  287. } else {
  288. if (text.charAt(i) == '\n') {
  289. filterLine(seenTag);
  290. } else {
  291. buf += text.charAt(i);
  292. }
  293. }
  294. } else if (state == IN_TAG_TYPE) {
  295. i += otag.length - 1;
  296. tag = Hogan.tags[text.charAt(i + 1)];
  297. tagType = tag ? text.charAt(i + 1) : '_v';
  298. if (tagType == '=') {
  299. i = changeDelimiters(text, i);
  300. state = IN_TEXT;
  301. } else {
  302. if (tag) {
  303. i++;
  304. }
  305. state = IN_TAG;
  306. }
  307. seenTag = i;
  308. } else {
  309. if (tagChange(ctag, text, i)) {
  310. tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
  311. i: (tagType == '/') ? seenTag - otag.length : i + ctag.length});
  312. buf = '';
  313. i += ctag.length - 1;
  314. state = IN_TEXT;
  315. if (tagType == '{') {
  316. if (ctag == '}}') {
  317. i++;
  318. } else {
  319. cleanTripleStache(tokens[tokens.length - 1]);
  320. }
  321. }
  322. } else {
  323. buf += text.charAt(i);
  324. }
  325. }
  326. }
  327.  
  328. filterLine(seenTag, true);
  329.  
  330. return tokens;
  331. }
  332.  
  333. function cleanTripleStache(token) {
  334. if (token.n.substr(token.n.length - 1) === '}') {
  335. token.n = token.n.substring(0, token.n.length - 1);
  336. }
  337. }
  338.  
  339. function trim(s) {
  340. if (s.trim) {
  341. return s.trim();
  342. }
  343.  
  344. return s.replace(/^\s*|\s*$/g, '');
  345. }
  346.  
  347. function tagChange(tag, text, index) {
  348. if (text.charAt(index) != tag.charAt(0)) {
  349. return false;
  350. }
  351.  
  352. for (var i = 1, l = tag.length; i < l; i++) {
  353. if (text.charAt(index + i) != tag.charAt(i)) {
  354. return false;
  355. }
  356. }
  357.  
  358. return true;
  359. }
  360.  
  361. // the tags allowed inside super templates
  362. var allowedInSuper = {'_t': true, '\n': true, '$': true, '/': true};
  363.  
  364. function buildTree(tokens, kind, stack, customTags) {
  365. var instructions = [],
  366. opener = null,
  367. tail = null,
  368. token = null;
  369.  
  370. tail = stack[stack.length - 1];
  371.  
  372. while (tokens.length > 0) {
  373. token = tokens.shift();
  374.  
  375. if (tail && tail.tag == '<' && !(token.tag in allowedInSuper)) {
  376. throw new Error('Illegal content in < super tag.');
  377. }
  378.  
  379. if (Hogan.tags[token.tag] <= Hogan.tags['$'] || isOpener(token, customTags)) {
  380. stack.push(token);
  381. token.nodes = buildTree(tokens, token.tag, stack, customTags);
  382. } else if (token.tag == '/') {
  383. if (stack.length === 0) {
  384. throw new Error('Closing tag without opener: /' + token.n);
  385. }
  386. opener = stack.pop();
  387. if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
  388. throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
  389. }
  390. opener.end = token.i;
  391. return instructions;
  392. } else if (token.tag == '\n') {
  393. token.last = (tokens.length == 0) || (tokens[0].tag == '\n');
  394. }
  395.  
  396. instructions.push(token);
  397. }
  398.  
  399. if (stack.length > 0) {
  400. throw new Error('missing closing tag: ' + stack.pop().n);
  401. }
  402.  
  403. return instructions;
  404. }
  405.  
  406. function isOpener(token, tags) {
  407. for (var i = 0, l = tags.length; i < l; i++) {
  408. if (tags[i].o == token.n) {
  409. token.tag = '#';
  410. return true;
  411. }
  412. }
  413. }
  414.  
  415. function isCloser(close, open, tags) {
  416. for (var i = 0, l = tags.length; i < l; i++) {
  417. if (tags[i].c == close && tags[i].o == open) {
  418. return true;
  419. }
  420. }
  421. }
  422.  
  423. function stringifySubstitutions(obj) {
  424. var items = [];
  425. for (var key in obj) {
  426. items.push('"' + esc(key) + '": function(c,p,t,i) {' + obj[key] + '}');
  427. }
  428. return "{ " + items.join(",") + " }";
  429. }
  430.  
  431. function stringifyPartials(codeObj) {
  432. var partials = [];
  433. for (var key in codeObj.partials) {
  434. partials.push('"' + esc(key) + '":{name:"' + esc(codeObj.partials[key].name) + '", ' + stringifyPartials(codeObj.partials[key]) + "}");
  435. }
  436. return "partials: {" + partials.join(",") + "}, subs: " + stringifySubstitutions(codeObj.subs);
  437. }
  438.  
  439. Hogan.stringify = function(codeObj, text, options) {
  440. return "{code: function (c,p,i) { " + Hogan.wrapMain(codeObj.code) + " }," + stringifyPartials(codeObj) + "}";
  441. }
  442.  
  443. var serialNo = 0;
  444. Hogan.generate = function(tree, text, options) {
  445. serialNo = 0;
  446. var context = { code: '', subs: {}, partials: {} };
  447. Hogan.walk(tree, context);
  448.  
  449. if (options.asString) {
  450. return this.stringify(context, text, options);
  451. }
  452.  
  453. return this.makeTemplate(context, text, options);
  454. }
  455.  
  456. Hogan.wrapMain = function(code) {
  457. return 'var t=this;t.b(i=i||"");' + code + 'return t.fl();';
  458. }
  459.  
  460. Hogan.template = Hogan.Template;
  461.  
  462. Hogan.makeTemplate = function(codeObj, text, options) {
  463. var template = this.makePartials(codeObj);
  464. template.code = new Function('c', 'p', 'i', this.wrapMain(codeObj.code));
  465. return new this.template(template, text, this, options);
  466. }
  467.  
  468. Hogan.makePartials = function(codeObj) {
  469. var key, template = {subs: {}, partials: codeObj.partials, name: codeObj.name};
  470. for (key in template.partials) {
  471. template.partials[key] = this.makePartials(template.partials[key]);
  472. }
  473. for (key in codeObj.subs) {
  474. template.subs[key] = new Function('c', 'p', 't', 'i', codeObj.subs[key]);
  475. }
  476. return template;
  477. }
  478.  
  479. function esc(s) {
  480. return s.replace(rSlash, '\\\\')
  481. .replace(rQuot, '\\\"')
  482. .replace(rNewline, '\\n')
  483. .replace(rCr, '\\r')
  484. .replace(rLineSep, '\\u2028')
  485. .replace(rParagraphSep, '\\u2029');
  486. }
  487.  
  488. function chooseMethod(s) {
  489. return (~s.indexOf('.')) ? 'd' : 'f';
  490. }
  491.  
  492. function createPartial(node, context) {
  493. var prefix = "<" + (context.prefix || "");
  494. var sym = prefix + node.n + serialNo++;
  495. context.partials[sym] = {name: node.n, partials: {}};
  496. context.code += 't.b(t.rp("' + esc(sym) + '",c,p,"' + (node.indent || '') + '"));';
  497. return sym;
  498. }
  499.  
  500. Hogan.codegen = {
  501. '#': function(node, context) {
  502. context.code += 'if(t.s(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,1),' +
  503. 'c,p,0,' + node.i + ',' + node.end + ',"' + node.otag + " " + node.ctag + '")){' +
  504. 't.rs(c,p,' + 'function(c,p,t){';
  505. Hogan.walk(node.nodes, context);
  506. context.code += '});c.pop();}';
  507. },
  508.  
  509. '^': function(node, context) {
  510. context.code += 'if(!t.s(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,1),c,p,1,0,0,"")){';
  511. Hogan.walk(node.nodes, context);
  512. context.code += '};';
  513. },
  514.  
  515. '>': createPartial,
  516. '<': function(node, context) {
  517. var ctx = {partials: {}, code: '', subs: {}, inPartial: true};
  518. Hogan.walk(node.nodes, ctx);
  519. var template = context.partials[createPartial(node, context)];
  520. template.subs = ctx.subs;
  521. template.partials = ctx.partials;
  522. },
  523.  
  524. '$': function(node, context) {
  525. var ctx = {subs: {}, code: '', partials: context.partials, prefix: node.n};
  526. Hogan.walk(node.nodes, ctx);
  527. context.subs[node.n] = ctx.code;
  528. if (!context.inPartial) {
  529. context.code += 't.sub("' + esc(node.n) + '",c,p,i);';
  530. }
  531. },
  532.  
  533. '\n': function(node, context) {
  534. context.code += write('"\\n"' + (node.last ? '' : ' + i'));
  535. },
  536.  
  537. '_v': function(node, context) {
  538. context.code += 't.b(t.v(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,0)));';
  539. },
  540.  
  541. '_t': function(node, context) {
  542. context.code += write('"' + esc(node.text) + '"');
  543. },
  544.  
  545. '{': tripleStache,
  546.  
  547. '&': tripleStache
  548. }
  549.  
  550. function tripleStache(node, context) {
  551. context.code += 't.b(t.t(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,0)));';
  552. }
  553.  
  554. function write(s) {
  555. return 't.b(' + s + ');';
  556. }
  557.  
  558. Hogan.walk = function(nodelist, context) {
  559. var func;
  560. for (var i = 0, l = nodelist.length; i < l; i++) {
  561. func = Hogan.codegen[nodelist[i].tag];
  562. func && func(nodelist[i], context);
  563. }
  564. return context;
  565. }
  566.  
  567. Hogan.parse = function(tokens, text, options) {
  568. options = options || {};
  569. return buildTree(tokens, '', [], options.sectionTags || []);
  570. }
  571.  
  572. Hogan.cache = {};
  573.  
  574. Hogan.cacheKey = function(text, options) {
  575. return [text, !!options.asString, !!options.disableLambda, options.delimiters, !!options.modelGet].join('||');
  576. }
  577.  
  578. Hogan.compile = function(text, options) {
  579. options = options || {};
  580. var key = Hogan.cacheKey(text, options);
  581. var template = this.cache[key];
  582.  
  583. if (template) {
  584. var partials = template.partials;
  585. for (var name in partials) {
  586. delete partials[name].instance;
  587. }
  588. return template;
  589. }
  590.  
  591. template = this.generate(this.parse(this.scan(text, options.delimiters), text, options), text, options);
  592. return this.cache[key] = template;
  593. }
  594. })( true ? exports : 0);
  595.  
  596.  
  597. /***/ }),
  598.  
  599. /***/ 485:
  600. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  601.  
  602. /*
  603. * Copyright 2011 Twitter, Inc.
  604. * Licensed under the Apache License, Version 2.0 (the "License");
  605. * you may not use this file except in compliance with the License.
  606. * You may obtain a copy of the License at
  607. *
  608. * http://www.apache.org/licenses/LICENSE-2.0
  609. *
  610. * Unless required by applicable law or agreed to in writing, software
  611. * distributed under the License is distributed on an "AS IS" BASIS,
  612. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  613. * See the License for the specific language governing permissions and
  614. * limitations under the License.
  615. */
  616.  
  617. // This file is for use with Node.js. See dist/ for browser files.
  618.  
  619. var Hogan = __webpack_require__(397);
  620. Hogan.Template = __webpack_require__(882).Template;
  621. Hogan.template = Hogan.Template;
  622. module.exports = Hogan;
  623.  
  624.  
  625. /***/ }),
  626.  
  627. /***/ 882:
  628. /***/ ((__unused_webpack_module, exports) => {
  629.  
  630. /*
  631. * Copyright 2011 Twitter, Inc.
  632. * Licensed under the Apache License, Version 2.0 (the "License");
  633. * you may not use this file except in compliance with the License.
  634. * You may obtain a copy of the License at
  635. *
  636. * http://www.apache.org/licenses/LICENSE-2.0
  637. *
  638. * Unless required by applicable law or agreed to in writing, software
  639. * distributed under the License is distributed on an "AS IS" BASIS,
  640. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  641. * See the License for the specific language governing permissions and
  642. * limitations under the License.
  643. */
  644.  
  645. var Hogan = {};
  646.  
  647. (function (Hogan) {
  648. Hogan.Template = function (codeObj, text, compiler, options) {
  649. codeObj = codeObj || {};
  650. this.r = codeObj.code || this.r;
  651. this.c = compiler;
  652. this.options = options || {};
  653. this.text = text || '';
  654. this.partials = codeObj.partials || {};
  655. this.subs = codeObj.subs || {};
  656. this.buf = '';
  657. }
  658.  
  659. Hogan.Template.prototype = {
  660. // render: replaced by generated code.
  661. r: function (context, partials, indent) { return ''; },
  662.  
  663. // variable escaping
  664. v: hoganEscape,
  665.  
  666. // triple stache
  667. t: coerceToString,
  668.  
  669. render: function render(context, partials, indent) {
  670. return this.ri([context], partials || {}, indent);
  671. },
  672.  
  673. // render internal -- a hook for overrides that catches partials too
  674. ri: function (context, partials, indent) {
  675. return this.r(context, partials, indent);
  676. },
  677.  
  678. // ensurePartial
  679. ep: function(symbol, partials) {
  680. var partial = this.partials[symbol];
  681.  
  682. // check to see that if we've instantiated this partial before
  683. var template = partials[partial.name];
  684. if (partial.instance && partial.base == template) {
  685. return partial.instance;
  686. }
  687.  
  688. if (typeof template == 'string') {
  689. if (!this.c) {
  690. throw new Error("No compiler available.");
  691. }
  692. template = this.c.compile(template, this.options);
  693. }
  694.  
  695. if (!template) {
  696. return null;
  697. }
  698.  
  699. // We use this to check whether the partials dictionary has changed
  700. this.partials[symbol].base = template;
  701.  
  702. if (partial.subs) {
  703. // Make sure we consider parent template now
  704. if (!partials.stackText) partials.stackText = {};
  705. for (key in partial.subs) {
  706. if (!partials.stackText[key]) {
  707. partials.stackText[key] = (this.activeSub !== undefined && partials.stackText[this.activeSub]) ? partials.stackText[this.activeSub] : this.text;
  708. }
  709. }
  710. template = createSpecializedPartial(template, partial.subs, partial.partials,
  711. this.stackSubs, this.stackPartials, partials.stackText);
  712. }
  713. this.partials[symbol].instance = template;
  714.  
  715. return template;
  716. },
  717.  
  718. // tries to find a partial in the current scope and render it
  719. rp: function(symbol, context, partials, indent) {
  720. var partial = this.ep(symbol, partials);
  721. if (!partial) {
  722. return '';
  723. }
  724.  
  725. return partial.ri(context, partials, indent);
  726. },
  727.  
  728. // render a section
  729. rs: function(context, partials, section) {
  730. var tail = context[context.length - 1];
  731.  
  732. if (!isArray(tail)) {
  733. section(context, partials, this);
  734. return;
  735. }
  736.  
  737. for (var i = 0; i < tail.length; i++) {
  738. context.push(tail[i]);
  739. section(context, partials, this);
  740. context.pop();
  741. }
  742. },
  743.  
  744. // maybe start a section
  745. s: function(val, ctx, partials, inverted, start, end, tags) {
  746. var pass;
  747.  
  748. if (isArray(val) && val.length === 0) {
  749. return false;
  750. }
  751.  
  752. if (typeof val == 'function') {
  753. val = this.ms(val, ctx, partials, inverted, start, end, tags);
  754. }
  755.  
  756. pass = !!val;
  757.  
  758. if (!inverted && pass && ctx) {
  759. ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
  760. }
  761.  
  762. return pass;
  763. },
  764.  
  765. // find values with dotted names
  766. d: function(key, ctx, partials, returnFound) {
  767. var found,
  768. names = key.split('.'),
  769. val = this.f(names[0], ctx, partials, returnFound),
  770. doModelGet = this.options.modelGet,
  771. cx = null;
  772.  
  773. if (key === '.' && isArray(ctx[ctx.length - 2])) {
  774. val = ctx[ctx.length - 1];
  775. } else {
  776. for (var i = 1; i < names.length; i++) {
  777. found = findInScope(names[i], val, doModelGet);
  778. if (found !== undefined) {
  779. cx = val;
  780. val = found;
  781. } else {
  782. val = '';
  783. }
  784. }
  785. }
  786.  
  787. if (returnFound && !val) {
  788. return false;
  789. }
  790.  
  791. if (!returnFound && typeof val == 'function') {
  792. ctx.push(cx);
  793. val = this.mv(val, ctx, partials);
  794. ctx.pop();
  795. }
  796.  
  797. return val;
  798. },
  799.  
  800. // find values with normal names
  801. f: function(key, ctx, partials, returnFound) {
  802. var val = false,
  803. v = null,
  804. found = false,
  805. doModelGet = this.options.modelGet;
  806.  
  807. for (var i = ctx.length - 1; i >= 0; i--) {
  808. v = ctx[i];
  809. val = findInScope(key, v, doModelGet);
  810. if (val !== undefined) {
  811. found = true;
  812. break;
  813. }
  814. }
  815.  
  816. if (!found) {
  817. return (returnFound) ? false : "";
  818. }
  819.  
  820. if (!returnFound && typeof val == 'function') {
  821. val = this.mv(val, ctx, partials);
  822. }
  823.  
  824. return val;
  825. },
  826.  
  827. // higher order templates
  828. ls: function(func, cx, partials, text, tags) {
  829. var oldTags = this.options.delimiters;
  830.  
  831. this.options.delimiters = tags;
  832. this.b(this.ct(coerceToString(func.call(cx, text)), cx, partials));
  833. this.options.delimiters = oldTags;
  834.  
  835. return false;
  836. },
  837.  
  838. // compile text
  839. ct: function(text, cx, partials) {
  840. if (this.options.disableLambda) {
  841. throw new Error('Lambda features disabled.');
  842. }
  843. return this.c.compile(text, this.options).render(cx, partials);
  844. },
  845.  
  846. // template result buffering
  847. b: function(s) { this.buf += s; },
  848.  
  849. fl: function() { var r = this.buf; this.buf = ''; return r; },
  850.  
  851. // method replace section
  852. ms: function(func, ctx, partials, inverted, start, end, tags) {
  853. var textSource,
  854. cx = ctx[ctx.length - 1],
  855. result = func.call(cx);
  856.  
  857. if (typeof result == 'function') {
  858. if (inverted) {
  859. return true;
  860. } else {
  861. textSource = (this.activeSub && this.subsText && this.subsText[this.activeSub]) ? this.subsText[this.activeSub] : this.text;
  862. return this.ls(result, cx, partials, textSource.substring(start, end), tags);
  863. }
  864. }
  865.  
  866. return result;
  867. },
  868.  
  869. // method replace variable
  870. mv: function(func, ctx, partials) {
  871. var cx = ctx[ctx.length - 1];
  872. var result = func.call(cx);
  873.  
  874. if (typeof result == 'function') {
  875. return this.ct(coerceToString(result.call(cx)), cx, partials);
  876. }
  877.  
  878. return result;
  879. },
  880.  
  881. sub: function(name, context, partials, indent) {
  882. var f = this.subs[name];
  883. if (f) {
  884. this.activeSub = name;
  885. f(context, partials, this, indent);
  886. this.activeSub = false;
  887. }
  888. }
  889.  
  890. };
  891.  
  892. //Find a key in an object
  893. function findInScope(key, scope, doModelGet) {
  894. var val;
  895.  
  896. if (scope && typeof scope == 'object') {
  897.  
  898. if (scope[key] !== undefined) {
  899. val = scope[key];
  900.  
  901. // try lookup with get for backbone or similar model data
  902. } else if (doModelGet && scope.get && typeof scope.get == 'function') {
  903. val = scope.get(key);
  904. }
  905. }
  906.  
  907. return val;
  908. }
  909.  
  910. function createSpecializedPartial(instance, subs, partials, stackSubs, stackPartials, stackText) {
  911. function PartialTemplate() {};
  912. PartialTemplate.prototype = instance;
  913. function Substitutions() {};
  914. Substitutions.prototype = instance.subs;
  915. var key;
  916. var partial = new PartialTemplate();
  917. partial.subs = new Substitutions();
  918. partial.subsText = {}; //hehe. substext.
  919. partial.buf = '';
  920.  
  921. stackSubs = stackSubs || {};
  922. partial.stackSubs = stackSubs;
  923. partial.subsText = stackText;
  924. for (key in subs) {
  925. if (!stackSubs[key]) stackSubs[key] = subs[key];
  926. }
  927. for (key in stackSubs) {
  928. partial.subs[key] = stackSubs[key];
  929. }
  930.  
  931. stackPartials = stackPartials || {};
  932. partial.stackPartials = stackPartials;
  933. for (key in partials) {
  934. if (!stackPartials[key]) stackPartials[key] = partials[key];
  935. }
  936. for (key in stackPartials) {
  937. partial.partials[key] = stackPartials[key];
  938. }
  939.  
  940. return partial;
  941. }
  942.  
  943. var rAmp = /&/g,
  944. rLt = /</g,
  945. rGt = />/g,
  946. rApos = /\'/g,
  947. rQuot = /\"/g,
  948. hChars = /[&<>\"\']/;
  949.  
  950. function coerceToString(val) {
  951. return String((val === null || val === undefined) ? '' : val);
  952. }
  953.  
  954. function hoganEscape(str) {
  955. str = coerceToString(str);
  956. return hChars.test(str) ?
  957. str
  958. .replace(rAmp, '&amp;')
  959. .replace(rLt, '&lt;')
  960. .replace(rGt, '&gt;')
  961. .replace(rApos, '&#39;')
  962. .replace(rQuot, '&quot;') :
  963. str;
  964. }
  965.  
  966. var isArray = Array.isArray || function(a) {
  967. return Object.prototype.toString.call(a) === '[object Array]';
  968. };
  969.  
  970. })( true ? exports : 0);
  971.  
  972.  
  973. /***/ }),
  974.  
  975. /***/ 379:
  976. /***/ ((module) => {
  977.  
  978. "use strict";
  979.  
  980.  
  981. var stylesInDom = [];
  982.  
  983. function getIndexByIdentifier(identifier) {
  984. var result = -1;
  985.  
  986. for (var i = 0; i < stylesInDom.length; i++) {
  987. if (stylesInDom[i].identifier === identifier) {
  988. result = i;
  989. break;
  990. }
  991. }
  992.  
  993. return result;
  994. }
  995.  
  996. function modulesToDom(list, options) {
  997. var idCountMap = {};
  998. var identifiers = [];
  999.  
  1000. for (var i = 0; i < list.length; i++) {
  1001. var item = list[i];
  1002. var id = options.base ? item[0] + options.base : item[0];
  1003. var count = idCountMap[id] || 0;
  1004. var identifier = "".concat(id, " ").concat(count);
  1005. idCountMap[id] = count + 1;
  1006. var index = getIndexByIdentifier(identifier);
  1007. var obj = {
  1008. css: item[1],
  1009. media: item[2],
  1010. sourceMap: item[3]
  1011. };
  1012.  
  1013. if (index !== -1) {
  1014. stylesInDom[index].references++;
  1015. stylesInDom[index].updater(obj);
  1016. } else {
  1017. stylesInDom.push({
  1018. identifier: identifier,
  1019. updater: addStyle(obj, options),
  1020. references: 1
  1021. });
  1022. }
  1023.  
  1024. identifiers.push(identifier);
  1025. }
  1026.  
  1027. return identifiers;
  1028. }
  1029.  
  1030. function addStyle(obj, options) {
  1031. var api = options.domAPI(options);
  1032. api.update(obj);
  1033. return function updateStyle(newObj) {
  1034. if (newObj) {
  1035. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
  1036. return;
  1037. }
  1038.  
  1039. api.update(obj = newObj);
  1040. } else {
  1041. api.remove();
  1042. }
  1043. };
  1044. }
  1045.  
  1046. module.exports = function (list, options) {
  1047. options = options || {};
  1048. list = list || [];
  1049. var lastIdentifiers = modulesToDom(list, options);
  1050. return function update(newList) {
  1051. newList = newList || [];
  1052.  
  1053. for (var i = 0; i < lastIdentifiers.length; i++) {
  1054. var identifier = lastIdentifiers[i];
  1055. var index = getIndexByIdentifier(identifier);
  1056. stylesInDom[index].references--;
  1057. }
  1058.  
  1059. var newLastIdentifiers = modulesToDom(newList, options);
  1060.  
  1061. for (var _i = 0; _i < lastIdentifiers.length; _i++) {
  1062. var _identifier = lastIdentifiers[_i];
  1063.  
  1064. var _index = getIndexByIdentifier(_identifier);
  1065.  
  1066. if (stylesInDom[_index].references === 0) {
  1067. stylesInDom[_index].updater();
  1068.  
  1069. stylesInDom.splice(_index, 1);
  1070. }
  1071. }
  1072.  
  1073. lastIdentifiers = newLastIdentifiers;
  1074. };
  1075. };
  1076.  
  1077. /***/ }),
  1078.  
  1079. /***/ 569:
  1080. /***/ ((module) => {
  1081.  
  1082. "use strict";
  1083.  
  1084.  
  1085. var memo = {};
  1086. /* istanbul ignore next */
  1087.  
  1088. function getTarget(target) {
  1089. if (typeof memo[target] === "undefined") {
  1090. var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
  1091.  
  1092. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  1093. try {
  1094. // This will throw an exception if access to iframe is blocked
  1095. // due to cross-origin restrictions
  1096. styleTarget = styleTarget.contentDocument.head;
  1097. } catch (e) {
  1098. // istanbul ignore next
  1099. styleTarget = null;
  1100. }
  1101. }
  1102.  
  1103. memo[target] = styleTarget;
  1104. }
  1105.  
  1106. return memo[target];
  1107. }
  1108. /* istanbul ignore next */
  1109.  
  1110.  
  1111. function insertBySelector(insert, style) {
  1112. var target = getTarget(insert);
  1113.  
  1114. if (!target) {
  1115. throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
  1116. }
  1117.  
  1118. target.appendChild(style);
  1119. }
  1120.  
  1121. module.exports = insertBySelector;
  1122.  
  1123. /***/ }),
  1124.  
  1125. /***/ 216:
  1126. /***/ ((module) => {
  1127.  
  1128. "use strict";
  1129.  
  1130.  
  1131. /* istanbul ignore next */
  1132. function insertStyleElement(options) {
  1133. var style = document.createElement("style");
  1134. options.setAttributes(style, options.attributes);
  1135. options.insert(style);
  1136. return style;
  1137. }
  1138.  
  1139. module.exports = insertStyleElement;
  1140.  
  1141. /***/ }),
  1142.  
  1143. /***/ 565:
  1144. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1145.  
  1146. "use strict";
  1147.  
  1148.  
  1149. /* istanbul ignore next */
  1150. function setAttributesWithoutAttributes(style) {
  1151. var nonce = true ? __webpack_require__.nc : 0;
  1152.  
  1153. if (nonce) {
  1154. style.setAttribute("nonce", nonce);
  1155. }
  1156. }
  1157.  
  1158. module.exports = setAttributesWithoutAttributes;
  1159.  
  1160. /***/ }),
  1161.  
  1162. /***/ 795:
  1163. /***/ ((module) => {
  1164.  
  1165. "use strict";
  1166.  
  1167.  
  1168. /* istanbul ignore next */
  1169. function apply(style, options, obj) {
  1170. var css = obj.css;
  1171. var media = obj.media;
  1172. var sourceMap = obj.sourceMap;
  1173.  
  1174. if (media) {
  1175. style.setAttribute("media", media);
  1176. } else {
  1177. style.removeAttribute("media");
  1178. }
  1179.  
  1180. if (sourceMap && typeof btoa !== "undefined") {
  1181. css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
  1182. } // For old IE
  1183.  
  1184. /* istanbul ignore if */
  1185.  
  1186.  
  1187. options.styleTagTransform(css, style);
  1188. }
  1189.  
  1190. function removeStyleElement(style) {
  1191. // istanbul ignore if
  1192. if (style.parentNode === null) {
  1193. return false;
  1194. }
  1195.  
  1196. style.parentNode.removeChild(style);
  1197. }
  1198. /* istanbul ignore next */
  1199.  
  1200.  
  1201. function domAPI(options) {
  1202. var style = options.insertStyleElement(options);
  1203. return {
  1204. update: function update(obj) {
  1205. apply(style, options, obj);
  1206. },
  1207. remove: function remove() {
  1208. removeStyleElement(style);
  1209. }
  1210. };
  1211. }
  1212.  
  1213. module.exports = domAPI;
  1214.  
  1215. /***/ }),
  1216.  
  1217. /***/ 589:
  1218. /***/ ((module) => {
  1219.  
  1220. "use strict";
  1221.  
  1222.  
  1223. /* istanbul ignore next */
  1224. function styleTagTransform(css, style) {
  1225. if (style.styleSheet) {
  1226. style.styleSheet.cssText = css;
  1227. } else {
  1228. while (style.firstChild) {
  1229. style.removeChild(style.firstChild);
  1230. }
  1231.  
  1232. style.appendChild(document.createTextNode(css));
  1233. }
  1234. }
  1235.  
  1236. module.exports = styleTagTransform;
  1237.  
  1238. /***/ })
  1239.  
  1240. /******/ });
  1241. /************************************************************************/
  1242. /******/ // The module cache
  1243. /******/ var __webpack_module_cache__ = {};
  1244. /******/
  1245. /******/ // The require function
  1246. /******/ function __webpack_require__(moduleId) {
  1247. /******/ // Check if module is in cache
  1248. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  1249. /******/ if (cachedModule !== undefined) {
  1250. /******/ return cachedModule.exports;
  1251. /******/ }
  1252. /******/ // Create a new module (and put it into the cache)
  1253. /******/ var module = __webpack_module_cache__[moduleId] = {
  1254. /******/ id: moduleId,
  1255. /******/ // no module.loaded needed
  1256. /******/ exports: {}
  1257. /******/ };
  1258. /******/
  1259. /******/ // Execute the module function
  1260. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  1261. /******/
  1262. /******/ // Return the exports of the module
  1263. /******/ return module.exports;
  1264. /******/ }
  1265. /******/
  1266. /************************************************************************/
  1267. /******/ /* webpack/runtime/compat get default export */
  1268. /******/ (() => {
  1269. /******/ // getDefaultExport function for compatibility with non-harmony modules
  1270. /******/ __webpack_require__.n = (module) => {
  1271. /******/ var getter = module && module.__esModule ?
  1272. /******/ () => (module['default']) :
  1273. /******/ () => (module);
  1274. /******/ __webpack_require__.d(getter, { a: getter });
  1275. /******/ return getter;
  1276. /******/ };
  1277. /******/ })();
  1278. /******/
  1279. /******/ /* webpack/runtime/define property getters */
  1280. /******/ (() => {
  1281. /******/ // define getter functions for harmony exports
  1282. /******/ __webpack_require__.d = (exports, definition) => {
  1283. /******/ for(var key in definition) {
  1284. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  1285. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  1286. /******/ }
  1287. /******/ }
  1288. /******/ };
  1289. /******/ })();
  1290. /******/
  1291. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  1292. /******/ (() => {
  1293. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  1294. /******/ })();
  1295. /******/
  1296. /************************************************************************/
  1297. var __webpack_exports__ = {};
  1298. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  1299. (() => {
  1300. "use strict";
  1301.  
  1302. ;// CONCATENATED MODULE: ./node_modules/diff/lib/index.mjs
  1303. function Diff() {}
  1304. Diff.prototype = {
  1305. diff: function diff(oldString, newString) {
  1306. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1307. var callback = options.callback;
  1308.  
  1309. if (typeof options === 'function') {
  1310. callback = options;
  1311. options = {};
  1312. }
  1313.  
  1314. this.options = options;
  1315. var self = this;
  1316.  
  1317. function done(value) {
  1318. if (callback) {
  1319. setTimeout(function () {
  1320. callback(undefined, value);
  1321. }, 0);
  1322. return true;
  1323. } else {
  1324. return value;
  1325. }
  1326. } // Allow subclasses to massage the input prior to running
  1327.  
  1328.  
  1329. oldString = this.castInput(oldString);
  1330. newString = this.castInput(newString);
  1331. oldString = this.removeEmpty(this.tokenize(oldString));
  1332. newString = this.removeEmpty(this.tokenize(newString));
  1333. var newLen = newString.length,
  1334. oldLen = oldString.length;
  1335. var editLength = 1;
  1336. var maxEditLength = newLen + oldLen;
  1337. var bestPath = [{
  1338. newPos: -1,
  1339. components: []
  1340. }]; // Seed editLength = 0, i.e. the content starts with the same values
  1341.  
  1342. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  1343.  
  1344. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  1345. // Identity per the equality and tokenizer
  1346. return done([{
  1347. value: this.join(newString),
  1348. count: newString.length
  1349. }]);
  1350. } // Main worker method. checks all permutations of a given edit length for acceptance.
  1351.  
  1352.  
  1353. function execEditLength() {
  1354. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  1355. var basePath = void 0;
  1356.  
  1357. var addPath = bestPath[diagonalPath - 1],
  1358. removePath = bestPath[diagonalPath + 1],
  1359. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  1360.  
  1361. if (addPath) {
  1362. // No one else is going to attempt to use this value, clear it
  1363. bestPath[diagonalPath - 1] = undefined;
  1364. }
  1365.  
  1366. var canAdd = addPath && addPath.newPos + 1 < newLen,
  1367. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  1368.  
  1369. if (!canAdd && !canRemove) {
  1370. // If this path is a terminal then prune
  1371. bestPath[diagonalPath] = undefined;
  1372. continue;
  1373. } // Select the diagonal that we want to branch from. We select the prior
  1374. // path whose position in the new string is the farthest from the origin
  1375. // and does not pass the bounds of the diff graph
  1376.  
  1377.  
  1378. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  1379. basePath = clonePath(removePath);
  1380. self.pushComponent(basePath.components, undefined, true);
  1381. } else {
  1382. basePath = addPath; // No need to clone, we've pulled it from the list
  1383.  
  1384. basePath.newPos++;
  1385. self.pushComponent(basePath.components, true, undefined);
  1386. }
  1387.  
  1388. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  1389.  
  1390. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  1391. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  1392. } else {
  1393. // Otherwise track this path as a potential candidate and continue.
  1394. bestPath[diagonalPath] = basePath;
  1395. }
  1396. }
  1397.  
  1398. editLength++;
  1399. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  1400. // sync and async mode which is never fun. Loops over execEditLength until a value
  1401. // is produced.
  1402.  
  1403.  
  1404. if (callback) {
  1405. (function exec() {
  1406. setTimeout(function () {
  1407. // This should not happen, but we want to be safe.
  1408.  
  1409. /* istanbul ignore next */
  1410. if (editLength > maxEditLength) {
  1411. return callback();
  1412. }
  1413.  
  1414. if (!execEditLength()) {
  1415. exec();
  1416. }
  1417. }, 0);
  1418. })();
  1419. } else {
  1420. while (editLength <= maxEditLength) {
  1421. var ret = execEditLength();
  1422.  
  1423. if (ret) {
  1424. return ret;
  1425. }
  1426. }
  1427. }
  1428. },
  1429. pushComponent: function pushComponent(components, added, removed) {
  1430. var last = components[components.length - 1];
  1431.  
  1432. if (last && last.added === added && last.removed === removed) {
  1433. // We need to clone here as the component clone operation is just
  1434. // as shallow array clone
  1435. components[components.length - 1] = {
  1436. count: last.count + 1,
  1437. added: added,
  1438. removed: removed
  1439. };
  1440. } else {
  1441. components.push({
  1442. count: 1,
  1443. added: added,
  1444. removed: removed
  1445. });
  1446. }
  1447. },
  1448. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  1449. var newLen = newString.length,
  1450. oldLen = oldString.length,
  1451. newPos = basePath.newPos,
  1452. oldPos = newPos - diagonalPath,
  1453. commonCount = 0;
  1454.  
  1455. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  1456. newPos++;
  1457. oldPos++;
  1458. commonCount++;
  1459. }
  1460.  
  1461. if (commonCount) {
  1462. basePath.components.push({
  1463. count: commonCount
  1464. });
  1465. }
  1466.  
  1467. basePath.newPos = newPos;
  1468. return oldPos;
  1469. },
  1470. equals: function equals(left, right) {
  1471. if (this.options.comparator) {
  1472. return this.options.comparator(left, right);
  1473. } else {
  1474. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  1475. }
  1476. },
  1477. removeEmpty: function removeEmpty(array) {
  1478. var ret = [];
  1479.  
  1480. for (var i = 0; i < array.length; i++) {
  1481. if (array[i]) {
  1482. ret.push(array[i]);
  1483. }
  1484. }
  1485.  
  1486. return ret;
  1487. },
  1488. castInput: function castInput(value) {
  1489. return value;
  1490. },
  1491. tokenize: function tokenize(value) {
  1492. return value.split('');
  1493. },
  1494. join: function join(chars) {
  1495. return chars.join('');
  1496. }
  1497. };
  1498.  
  1499. function buildValues(diff, components, newString, oldString, useLongestToken) {
  1500. var componentPos = 0,
  1501. componentLen = components.length,
  1502. newPos = 0,
  1503. oldPos = 0;
  1504.  
  1505. for (; componentPos < componentLen; componentPos++) {
  1506. var component = components[componentPos];
  1507.  
  1508. if (!component.removed) {
  1509. if (!component.added && useLongestToken) {
  1510. var value = newString.slice(newPos, newPos + component.count);
  1511. value = value.map(function (value, i) {
  1512. var oldValue = oldString[oldPos + i];
  1513. return oldValue.length > value.length ? oldValue : value;
  1514. });
  1515. component.value = diff.join(value);
  1516. } else {
  1517. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  1518. }
  1519.  
  1520. newPos += component.count; // Common case
  1521.  
  1522. if (!component.added) {
  1523. oldPos += component.count;
  1524. }
  1525. } else {
  1526. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  1527. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  1528. // The diffing algorithm is tied to add then remove output and this is the simplest
  1529. // route to get the desired output with minimal overhead.
  1530.  
  1531. if (componentPos && components[componentPos - 1].added) {
  1532. var tmp = components[componentPos - 1];
  1533. components[componentPos - 1] = components[componentPos];
  1534. components[componentPos] = tmp;
  1535. }
  1536. }
  1537. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  1538. // For this case we merge the terminal into the prior string and drop the change.
  1539. // This is only available for string mode.
  1540.  
  1541.  
  1542. var lastComponent = components[componentLen - 1];
  1543.  
  1544. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  1545. components[componentLen - 2].value += lastComponent.value;
  1546. components.pop();
  1547. }
  1548.  
  1549. return components;
  1550. }
  1551.  
  1552. function clonePath(path) {
  1553. return {
  1554. newPos: path.newPos,
  1555. components: path.components.slice(0)
  1556. };
  1557. }
  1558.  
  1559. var characterDiff = new Diff();
  1560. function diffChars(oldStr, newStr, options) {
  1561. return characterDiff.diff(oldStr, newStr, options);
  1562. }
  1563.  
  1564. function generateOptions(options, defaults) {
  1565. if (typeof options === 'function') {
  1566. defaults.callback = options;
  1567. } else if (options) {
  1568. for (var name in options) {
  1569. /* istanbul ignore else */
  1570. if (options.hasOwnProperty(name)) {
  1571. defaults[name] = options[name];
  1572. }
  1573. }
  1574. }
  1575.  
  1576. return defaults;
  1577. }
  1578.  
  1579. //
  1580. // Ranges and exceptions:
  1581. // Latin-1 Supplement, 0080–00FF
  1582. // - U+00D7 × Multiplication sign
  1583. // - U+00F7 ÷ Division sign
  1584. // Latin Extended-A, 0100–017F
  1585. // Latin Extended-B, 0180–024F
  1586. // IPA Extensions, 0250–02AF
  1587. // Spacing Modifier Letters, 02B0–02FF
  1588. // - U+02C7 ˇ &#711; Caron
  1589. // - U+02D8 ˘ &#728; Breve
  1590. // - U+02D9 ˙ &#729; Dot Above
  1591. // - U+02DA ˚ &#730; Ring Above
  1592. // - U+02DB ˛ &#731; Ogonek
  1593. // - U+02DC ˜ &#732; Small Tilde
  1594. // - U+02DD ˝ &#733; Double Acute Accent
  1595. // Latin Extended Additional, 1E00–1EFF
  1596.  
  1597. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  1598. var reWhitespace = /\S/;
  1599. var wordDiff = new Diff();
  1600.  
  1601. wordDiff.equals = function (left, right) {
  1602. if (this.options.ignoreCase) {
  1603. left = left.toLowerCase();
  1604. right = right.toLowerCase();
  1605. }
  1606.  
  1607. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  1608. };
  1609.  
  1610. wordDiff.tokenize = function (value) {
  1611. // All whitespace symbols except newline group into one token, each newline - in separate token
  1612. var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  1613.  
  1614. for (var i = 0; i < tokens.length - 1; i++) {
  1615. // If we have an empty string in the next field and we have only word chars before and after, merge
  1616. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  1617. tokens[i] += tokens[i + 2];
  1618. tokens.splice(i + 1, 2);
  1619. i--;
  1620. }
  1621. }
  1622.  
  1623. return tokens;
  1624. };
  1625.  
  1626. function diffWords(oldStr, newStr, options) {
  1627. options = generateOptions(options, {
  1628. ignoreWhitespace: true
  1629. });
  1630. return wordDiff.diff(oldStr, newStr, options);
  1631. }
  1632. function diffWordsWithSpace(oldStr, newStr, options) {
  1633. return wordDiff.diff(oldStr, newStr, options);
  1634. }
  1635.  
  1636. var lineDiff = new Diff();
  1637.  
  1638. lineDiff.tokenize = function (value) {
  1639. var retLines = [],
  1640. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  1641.  
  1642. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  1643. linesAndNewlines.pop();
  1644. } // Merge the content and line separators into single tokens
  1645.  
  1646.  
  1647. for (var i = 0; i < linesAndNewlines.length; i++) {
  1648. var line = linesAndNewlines[i];
  1649.  
  1650. if (i % 2 && !this.options.newlineIsToken) {
  1651. retLines[retLines.length - 1] += line;
  1652. } else {
  1653. if (this.options.ignoreWhitespace) {
  1654. line = line.trim();
  1655. }
  1656.  
  1657. retLines.push(line);
  1658. }
  1659. }
  1660.  
  1661. return retLines;
  1662. };
  1663.  
  1664. function diffLines(oldStr, newStr, callback) {
  1665. return lineDiff.diff(oldStr, newStr, callback);
  1666. }
  1667. function diffTrimmedLines(oldStr, newStr, callback) {
  1668. var options = generateOptions(callback, {
  1669. ignoreWhitespace: true
  1670. });
  1671. return lineDiff.diff(oldStr, newStr, options);
  1672. }
  1673.  
  1674. var sentenceDiff = new Diff();
  1675.  
  1676. sentenceDiff.tokenize = function (value) {
  1677. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  1678. };
  1679.  
  1680. function diffSentences(oldStr, newStr, callback) {
  1681. return sentenceDiff.diff(oldStr, newStr, callback);
  1682. }
  1683.  
  1684. var cssDiff = new Diff();
  1685.  
  1686. cssDiff.tokenize = function (value) {
  1687. return value.split(/([{}:;,]|\s+)/);
  1688. };
  1689.  
  1690. function diffCss(oldStr, newStr, callback) {
  1691. return cssDiff.diff(oldStr, newStr, callback);
  1692. }
  1693.  
  1694. function _typeof(obj) {
  1695. "@babel/helpers - typeof";
  1696.  
  1697. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  1698. _typeof = function (obj) {
  1699. return typeof obj;
  1700. };
  1701. } else {
  1702. _typeof = function (obj) {
  1703. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1704. };
  1705. }
  1706.  
  1707. return _typeof(obj);
  1708. }
  1709.  
  1710. function _toConsumableArray(arr) {
  1711. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  1712. }
  1713.  
  1714. function _arrayWithoutHoles(arr) {
  1715. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  1716. }
  1717.  
  1718. function _iterableToArray(iter) {
  1719. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  1720. }
  1721.  
  1722. function _unsupportedIterableToArray(o, minLen) {
  1723. if (!o) return;
  1724. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  1725. var n = Object.prototype.toString.call(o).slice(8, -1);
  1726. if (n === "Object" && o.constructor) n = o.constructor.name;
  1727. if (n === "Map" || n === "Set") return Array.from(o);
  1728. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  1729. }
  1730.  
  1731. function _arrayLikeToArray(arr, len) {
  1732. if (len == null || len > arr.length) len = arr.length;
  1733.  
  1734. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  1735.  
  1736. return arr2;
  1737. }
  1738.  
  1739. function _nonIterableSpread() {
  1740. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1741. }
  1742.  
  1743. var objectPrototypeToString = Object.prototype.toString;
  1744. var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  1745. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  1746.  
  1747. jsonDiff.useLongestToken = true;
  1748. jsonDiff.tokenize = lineDiff.tokenize;
  1749.  
  1750. jsonDiff.castInput = function (value) {
  1751. var _this$options = this.options,
  1752. undefinedReplacement = _this$options.undefinedReplacement,
  1753. _this$options$stringi = _this$options.stringifyReplacer,
  1754. stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) {
  1755. return typeof v === 'undefined' ? undefinedReplacement : v;
  1756. } : _this$options$stringi;
  1757. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  1758. };
  1759.  
  1760. jsonDiff.equals = function (left, right) {
  1761. return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
  1762. };
  1763.  
  1764. function diffJson(oldObj, newObj, options) {
  1765. return jsonDiff.diff(oldObj, newObj, options);
  1766. } // This function handles the presence of circular references by bailing out when encountering an
  1767. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  1768.  
  1769. function canonicalize(obj, stack, replacementStack, replacer, key) {
  1770. stack = stack || [];
  1771. replacementStack = replacementStack || [];
  1772.  
  1773. if (replacer) {
  1774. obj = replacer(key, obj);
  1775. }
  1776.  
  1777. var i;
  1778.  
  1779. for (i = 0; i < stack.length; i += 1) {
  1780. if (stack[i] === obj) {
  1781. return replacementStack[i];
  1782. }
  1783. }
  1784.  
  1785. var canonicalizedObj;
  1786.  
  1787. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  1788. stack.push(obj);
  1789. canonicalizedObj = new Array(obj.length);
  1790. replacementStack.push(canonicalizedObj);
  1791.  
  1792. for (i = 0; i < obj.length; i += 1) {
  1793. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  1794. }
  1795.  
  1796. stack.pop();
  1797. replacementStack.pop();
  1798. return canonicalizedObj;
  1799. }
  1800.  
  1801. if (obj && obj.toJSON) {
  1802. obj = obj.toJSON();
  1803. }
  1804.  
  1805. if (_typeof(obj) === 'object' && obj !== null) {
  1806. stack.push(obj);
  1807. canonicalizedObj = {};
  1808. replacementStack.push(canonicalizedObj);
  1809.  
  1810. var sortedKeys = [],
  1811. _key;
  1812.  
  1813. for (_key in obj) {
  1814. /* istanbul ignore else */
  1815. if (obj.hasOwnProperty(_key)) {
  1816. sortedKeys.push(_key);
  1817. }
  1818. }
  1819.  
  1820. sortedKeys.sort();
  1821.  
  1822. for (i = 0; i < sortedKeys.length; i += 1) {
  1823. _key = sortedKeys[i];
  1824. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  1825. }
  1826.  
  1827. stack.pop();
  1828. replacementStack.pop();
  1829. } else {
  1830. canonicalizedObj = obj;
  1831. }
  1832.  
  1833. return canonicalizedObj;
  1834. }
  1835.  
  1836. var arrayDiff = new Diff();
  1837.  
  1838. arrayDiff.tokenize = function (value) {
  1839. return value.slice();
  1840. };
  1841.  
  1842. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  1843. return value;
  1844. };
  1845.  
  1846. function diffArrays(oldArr, newArr, callback) {
  1847. return arrayDiff.diff(oldArr, newArr, callback);
  1848. }
  1849.  
  1850. function parsePatch(uniDiff) {
  1851. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1852. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  1853. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1854. list = [],
  1855. i = 0;
  1856.  
  1857. function parseIndex() {
  1858. var index = {};
  1859. list.push(index); // Parse diff metadata
  1860.  
  1861. while (i < diffstr.length) {
  1862. var line = diffstr[i]; // File header found, end parsing diff metadata
  1863.  
  1864. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  1865. break;
  1866. } // Diff index
  1867.  
  1868.  
  1869. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  1870.  
  1871. if (header) {
  1872. index.index = header[1];
  1873. }
  1874.  
  1875. i++;
  1876. } // Parse file headers if they are defined. Unified diff requires them, but
  1877. // there's no technical issues to have an isolated hunk without file header
  1878.  
  1879.  
  1880. parseFileHeader(index);
  1881. parseFileHeader(index); // Parse hunks
  1882.  
  1883. index.hunks = [];
  1884.  
  1885. while (i < diffstr.length) {
  1886. var _line = diffstr[i];
  1887.  
  1888. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  1889. break;
  1890. } else if (/^@@/.test(_line)) {
  1891. index.hunks.push(parseHunk());
  1892. } else if (_line && options.strict) {
  1893. // Ignore unexpected content unless in strict mode
  1894. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  1895. } else {
  1896. i++;
  1897. }
  1898. }
  1899. } // Parses the --- and +++ headers, if none are found, no lines
  1900. // are consumed.
  1901.  
  1902.  
  1903. function parseFileHeader(index) {
  1904. var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
  1905.  
  1906. if (fileHeader) {
  1907. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  1908. var data = fileHeader[2].split('\t', 2);
  1909. var fileName = data[0].replace(/\\\\/g, '\\');
  1910.  
  1911. if (/^".*"$/.test(fileName)) {
  1912. fileName = fileName.substr(1, fileName.length - 2);
  1913. }
  1914.  
  1915. index[keyPrefix + 'FileName'] = fileName;
  1916. index[keyPrefix + 'Header'] = (data[1] || '').trim();
  1917. i++;
  1918. }
  1919. } // Parses a hunk
  1920. // This assumes that we are at the start of a hunk.
  1921.  
  1922.  
  1923. function parseHunk() {
  1924. var chunkHeaderIndex = i,
  1925. chunkHeaderLine = diffstr[i++],
  1926. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  1927. var hunk = {
  1928. oldStart: +chunkHeader[1],
  1929. oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2],
  1930. newStart: +chunkHeader[3],
  1931. newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4],
  1932. lines: [],
  1933. linedelimiters: []
  1934. }; // Unified Diff Format quirk: If the chunk size is 0,
  1935. // the first number is one lower than one would expect.
  1936. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  1937.  
  1938. if (hunk.oldLines === 0) {
  1939. hunk.oldStart += 1;
  1940. }
  1941.  
  1942. if (hunk.newLines === 0) {
  1943. hunk.newStart += 1;
  1944. }
  1945.  
  1946. var addCount = 0,
  1947. removeCount = 0;
  1948.  
  1949. for (; i < diffstr.length; i++) {
  1950. // Lines starting with '---' could be mistaken for the "remove line" operation
  1951. // But they could be the header for the next file. Therefore prune such cases out.
  1952. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  1953. break;
  1954. }
  1955.  
  1956. var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
  1957.  
  1958. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  1959. hunk.lines.push(diffstr[i]);
  1960. hunk.linedelimiters.push(delimiters[i] || '\n');
  1961.  
  1962. if (operation === '+') {
  1963. addCount++;
  1964. } else if (operation === '-') {
  1965. removeCount++;
  1966. } else if (operation === ' ') {
  1967. addCount++;
  1968. removeCount++;
  1969. }
  1970. } else {
  1971. break;
  1972. }
  1973. } // Handle the empty block count case
  1974.  
  1975.  
  1976. if (!addCount && hunk.newLines === 1) {
  1977. hunk.newLines = 0;
  1978. }
  1979.  
  1980. if (!removeCount && hunk.oldLines === 1) {
  1981. hunk.oldLines = 0;
  1982. } // Perform optional sanity checking
  1983.  
  1984.  
  1985. if (options.strict) {
  1986. if (addCount !== hunk.newLines) {
  1987. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1988. }
  1989.  
  1990. if (removeCount !== hunk.oldLines) {
  1991. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1992. }
  1993. }
  1994.  
  1995. return hunk;
  1996. }
  1997.  
  1998. while (i < diffstr.length) {
  1999. parseIndex();
  2000. }
  2001.  
  2002. return list;
  2003. }
  2004.  
  2005. // Iterator that traverses in the range of [min, max], stepping
  2006. // by distance from a given start position. I.e. for [0, 4], with
  2007. // start of 2, this will iterate 2, 3, 1, 4, 0.
  2008. function distanceIterator (start, minLine, maxLine) {
  2009. var wantForward = true,
  2010. backwardExhausted = false,
  2011. forwardExhausted = false,
  2012. localOffset = 1;
  2013. return function iterator() {
  2014. if (wantForward && !forwardExhausted) {
  2015. if (backwardExhausted) {
  2016. localOffset++;
  2017. } else {
  2018. wantForward = false;
  2019. } // Check if trying to fit beyond text length, and if not, check it fits
  2020. // after offset location (or desired location on first iteration)
  2021.  
  2022.  
  2023. if (start + localOffset <= maxLine) {
  2024. return localOffset;
  2025. }
  2026.  
  2027. forwardExhausted = true;
  2028. }
  2029.  
  2030. if (!backwardExhausted) {
  2031. if (!forwardExhausted) {
  2032. wantForward = true;
  2033. } // Check if trying to fit before text beginning, and if not, check it fits
  2034. // before offset location
  2035.  
  2036.  
  2037. if (minLine <= start - localOffset) {
  2038. return -localOffset++;
  2039. }
  2040.  
  2041. backwardExhausted = true;
  2042. return iterator();
  2043. } // We tried to fit hunk before text beginning and beyond text length, then
  2044. // hunk can't fit on the text. Return undefined
  2045.  
  2046. };
  2047. }
  2048.  
  2049. function applyPatch(source, uniDiff) {
  2050. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  2051.  
  2052. if (typeof uniDiff === 'string') {
  2053. uniDiff = parsePatch(uniDiff);
  2054. }
  2055.  
  2056. if (Array.isArray(uniDiff)) {
  2057. if (uniDiff.length > 1) {
  2058. throw new Error('applyPatch only works with a single input.');
  2059. }
  2060.  
  2061. uniDiff = uniDiff[0];
  2062. } // Apply the diff to the input
  2063.  
  2064.  
  2065. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  2066. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  2067. hunks = uniDiff.hunks,
  2068. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) {
  2069. return line === patchContent;
  2070. },
  2071. errorCount = 0,
  2072. fuzzFactor = options.fuzzFactor || 0,
  2073. minLine = 0,
  2074. offset = 0,
  2075. removeEOFNL,
  2076. addEOFNL;
  2077. /**
  2078. * Checks if the hunk exactly fits on the provided location
  2079. */
  2080.  
  2081.  
  2082. function hunkFits(hunk, toPos) {
  2083. for (var j = 0; j < hunk.lines.length; j++) {
  2084. var line = hunk.lines[j],
  2085. operation = line.length > 0 ? line[0] : ' ',
  2086. content = line.length > 0 ? line.substr(1) : line;
  2087.  
  2088. if (operation === ' ' || operation === '-') {
  2089. // Context sanity check
  2090. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  2091. errorCount++;
  2092.  
  2093. if (errorCount > fuzzFactor) {
  2094. return false;
  2095. }
  2096. }
  2097.  
  2098. toPos++;
  2099. }
  2100. }
  2101.  
  2102. return true;
  2103. } // Search best fit offsets for each hunk based on the previous ones
  2104.  
  2105.  
  2106. for (var i = 0; i < hunks.length; i++) {
  2107. var hunk = hunks[i],
  2108. maxLine = lines.length - hunk.oldLines,
  2109. localOffset = 0,
  2110. toPos = offset + hunk.oldStart - 1;
  2111. var iterator = distanceIterator(toPos, minLine, maxLine);
  2112.  
  2113. for (; localOffset !== undefined; localOffset = iterator()) {
  2114. if (hunkFits(hunk, toPos + localOffset)) {
  2115. hunk.offset = offset += localOffset;
  2116. break;
  2117. }
  2118. }
  2119.  
  2120. if (localOffset === undefined) {
  2121. return false;
  2122. } // Set lower text limit to end of the current hunk, so next ones don't try
  2123. // to fit over already patched text
  2124.  
  2125.  
  2126. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  2127. } // Apply patch hunks
  2128.  
  2129.  
  2130. var diffOffset = 0;
  2131.  
  2132. for (var _i = 0; _i < hunks.length; _i++) {
  2133. var _hunk = hunks[_i],
  2134. _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
  2135.  
  2136. diffOffset += _hunk.newLines - _hunk.oldLines;
  2137.  
  2138. for (var j = 0; j < _hunk.lines.length; j++) {
  2139. var line = _hunk.lines[j],
  2140. operation = line.length > 0 ? line[0] : ' ',
  2141. content = line.length > 0 ? line.substr(1) : line,
  2142. delimiter = _hunk.linedelimiters[j];
  2143.  
  2144. if (operation === ' ') {
  2145. _toPos++;
  2146. } else if (operation === '-') {
  2147. lines.splice(_toPos, 1);
  2148. delimiters.splice(_toPos, 1);
  2149. /* istanbul ignore else */
  2150. } else if (operation === '+') {
  2151. lines.splice(_toPos, 0, content);
  2152. delimiters.splice(_toPos, 0, delimiter);
  2153. _toPos++;
  2154. } else if (operation === '\\') {
  2155. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  2156.  
  2157. if (previousOperation === '+') {
  2158. removeEOFNL = true;
  2159. } else if (previousOperation === '-') {
  2160. addEOFNL = true;
  2161. }
  2162. }
  2163. }
  2164. } // Handle EOFNL insertion/removal
  2165.  
  2166.  
  2167. if (removeEOFNL) {
  2168. while (!lines[lines.length - 1]) {
  2169. lines.pop();
  2170. delimiters.pop();
  2171. }
  2172. } else if (addEOFNL) {
  2173. lines.push('');
  2174. delimiters.push('\n');
  2175. }
  2176.  
  2177. for (var _k = 0; _k < lines.length - 1; _k++) {
  2178. lines[_k] = lines[_k] + delimiters[_k];
  2179. }
  2180.  
  2181. return lines.join('');
  2182. } // Wrapper that supports multiple file patches via callbacks.
  2183.  
  2184. function applyPatches(uniDiff, options) {
  2185. if (typeof uniDiff === 'string') {
  2186. uniDiff = parsePatch(uniDiff);
  2187. }
  2188.  
  2189. var currentIndex = 0;
  2190.  
  2191. function processIndex() {
  2192. var index = uniDiff[currentIndex++];
  2193.  
  2194. if (!index) {
  2195. return options.complete();
  2196. }
  2197.  
  2198. options.loadFile(index, function (err, data) {
  2199. if (err) {
  2200. return options.complete(err);
  2201. }
  2202.  
  2203. var updatedContent = applyPatch(data, index, options);
  2204. options.patched(index, updatedContent, function (err) {
  2205. if (err) {
  2206. return options.complete(err);
  2207. }
  2208.  
  2209. processIndex();
  2210. });
  2211. });
  2212. }
  2213.  
  2214. processIndex();
  2215. }
  2216.  
  2217. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  2218. if (!options) {
  2219. options = {};
  2220. }
  2221.  
  2222. if (typeof options.context === 'undefined') {
  2223. options.context = 4;
  2224. }
  2225.  
  2226. var diff = diffLines(oldStr, newStr, options);
  2227. diff.push({
  2228. value: '',
  2229. lines: []
  2230. }); // Append an empty value to make cleanup easier
  2231.  
  2232. function contextLines(lines) {
  2233. return lines.map(function (entry) {
  2234. return ' ' + entry;
  2235. });
  2236. }
  2237.  
  2238. var hunks = [];
  2239. var oldRangeStart = 0,
  2240. newRangeStart = 0,
  2241. curRange = [],
  2242. oldLine = 1,
  2243. newLine = 1;
  2244.  
  2245. var _loop = function _loop(i) {
  2246. var current = diff[i],
  2247. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  2248. current.lines = lines;
  2249.  
  2250. if (current.added || current.removed) {
  2251. var _curRange;
  2252.  
  2253. // If we have previous context, start with that
  2254. if (!oldRangeStart) {
  2255. var prev = diff[i - 1];
  2256. oldRangeStart = oldLine;
  2257. newRangeStart = newLine;
  2258.  
  2259. if (prev) {
  2260. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  2261. oldRangeStart -= curRange.length;
  2262. newRangeStart -= curRange.length;
  2263. }
  2264. } // Output our changes
  2265.  
  2266.  
  2267. (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
  2268. return (current.added ? '+' : '-') + entry;
  2269. }))); // Track the updated file position
  2270.  
  2271.  
  2272. if (current.added) {
  2273. newLine += lines.length;
  2274. } else {
  2275. oldLine += lines.length;
  2276. }
  2277. } else {
  2278. // Identical context lines. Track line changes
  2279. if (oldRangeStart) {
  2280. // Close out any changes that have been output (or join overlapping)
  2281. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  2282. var _curRange2;
  2283.  
  2284. // Overlapping
  2285. (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
  2286. } else {
  2287. var _curRange3;
  2288.  
  2289. // end the range and output
  2290. var contextSize = Math.min(lines.length, options.context);
  2291.  
  2292. (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
  2293.  
  2294. var hunk = {
  2295. oldStart: oldRangeStart,
  2296. oldLines: oldLine - oldRangeStart + contextSize,
  2297. newStart: newRangeStart,
  2298. newLines: newLine - newRangeStart + contextSize,
  2299. lines: curRange
  2300. };
  2301.  
  2302. if (i >= diff.length - 2 && lines.length <= options.context) {
  2303. // EOF is inside this hunk
  2304. var oldEOFNewline = /\n$/.test(oldStr);
  2305. var newEOFNewline = /\n$/.test(newStr);
  2306. var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
  2307.  
  2308. if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
  2309. // special case: old has no eol and no trailing context; no-nl can end up before adds
  2310. // however, if the old file is empty, do not output the no-nl line
  2311. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  2312. }
  2313.  
  2314. if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
  2315. curRange.push('\\ No newline at end of file');
  2316. }
  2317. }
  2318.  
  2319. hunks.push(hunk);
  2320. oldRangeStart = 0;
  2321. newRangeStart = 0;
  2322. curRange = [];
  2323. }
  2324. }
  2325.  
  2326. oldLine += lines.length;
  2327. newLine += lines.length;
  2328. }
  2329. };
  2330.  
  2331. for (var i = 0; i < diff.length; i++) {
  2332. _loop(i);
  2333. }
  2334.  
  2335. return {
  2336. oldFileName: oldFileName,
  2337. newFileName: newFileName,
  2338. oldHeader: oldHeader,
  2339. newHeader: newHeader,
  2340. hunks: hunks
  2341. };
  2342. }
  2343. function formatPatch(diff) {
  2344. var ret = [];
  2345.  
  2346. if (diff.oldFileName == diff.newFileName) {
  2347. ret.push('Index: ' + diff.oldFileName);
  2348. }
  2349.  
  2350. ret.push('===================================================================');
  2351. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  2352. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  2353.  
  2354. for (var i = 0; i < diff.hunks.length; i++) {
  2355. var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0,
  2356. // the first number is one lower than one would expect.
  2357. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  2358.  
  2359. if (hunk.oldLines === 0) {
  2360. hunk.oldStart -= 1;
  2361. }
  2362.  
  2363. if (hunk.newLines === 0) {
  2364. hunk.newStart -= 1;
  2365. }
  2366.  
  2367. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  2368. ret.push.apply(ret, hunk.lines);
  2369. }
  2370.  
  2371. return ret.join('\n') + '\n';
  2372. }
  2373. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  2374. return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
  2375. }
  2376. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  2377. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  2378. }
  2379.  
  2380. function arrayEqual(a, b) {
  2381. if (a.length !== b.length) {
  2382. return false;
  2383. }
  2384.  
  2385. return arrayStartsWith(a, b);
  2386. }
  2387. function arrayStartsWith(array, start) {
  2388. if (start.length > array.length) {
  2389. return false;
  2390. }
  2391.  
  2392. for (var i = 0; i < start.length; i++) {
  2393. if (start[i] !== array[i]) {
  2394. return false;
  2395. }
  2396. }
  2397.  
  2398. return true;
  2399. }
  2400.  
  2401. function calcLineCount(hunk) {
  2402. var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines),
  2403. oldLines = _calcOldNewLineCount.oldLines,
  2404. newLines = _calcOldNewLineCount.newLines;
  2405.  
  2406. if (oldLines !== undefined) {
  2407. hunk.oldLines = oldLines;
  2408. } else {
  2409. delete hunk.oldLines;
  2410. }
  2411.  
  2412. if (newLines !== undefined) {
  2413. hunk.newLines = newLines;
  2414. } else {
  2415. delete hunk.newLines;
  2416. }
  2417. }
  2418. function merge(mine, theirs, base) {
  2419. mine = loadPatch(mine, base);
  2420. theirs = loadPatch(theirs, base);
  2421. var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
  2422. // Leaving sanity checks on this to the API consumer that may know more about the
  2423. // meaning in their own context.
  2424.  
  2425. if (mine.index || theirs.index) {
  2426. ret.index = mine.index || theirs.index;
  2427. }
  2428.  
  2429. if (mine.newFileName || theirs.newFileName) {
  2430. if (!fileNameChanged(mine)) {
  2431. // No header or no change in ours, use theirs (and ours if theirs does not exist)
  2432. ret.oldFileName = theirs.oldFileName || mine.oldFileName;
  2433. ret.newFileName = theirs.newFileName || mine.newFileName;
  2434. ret.oldHeader = theirs.oldHeader || mine.oldHeader;
  2435. ret.newHeader = theirs.newHeader || mine.newHeader;
  2436. } else if (!fileNameChanged(theirs)) {
  2437. // No header or no change in theirs, use ours
  2438. ret.oldFileName = mine.oldFileName;
  2439. ret.newFileName = mine.newFileName;
  2440. ret.oldHeader = mine.oldHeader;
  2441. ret.newHeader = mine.newHeader;
  2442. } else {
  2443. // Both changed... figure it out
  2444. ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
  2445. ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
  2446. ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
  2447. ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
  2448. }
  2449. }
  2450.  
  2451. ret.hunks = [];
  2452. var mineIndex = 0,
  2453. theirsIndex = 0,
  2454. mineOffset = 0,
  2455. theirsOffset = 0;
  2456.  
  2457. while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
  2458. var mineCurrent = mine.hunks[mineIndex] || {
  2459. oldStart: Infinity
  2460. },
  2461. theirsCurrent = theirs.hunks[theirsIndex] || {
  2462. oldStart: Infinity
  2463. };
  2464.  
  2465. if (hunkBefore(mineCurrent, theirsCurrent)) {
  2466. // This patch does not overlap with any of the others, yay.
  2467. ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
  2468. mineIndex++;
  2469. theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
  2470. } else if (hunkBefore(theirsCurrent, mineCurrent)) {
  2471. // This patch does not overlap with any of the others, yay.
  2472. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
  2473. theirsIndex++;
  2474. mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
  2475. } else {
  2476. // Overlap, merge as best we can
  2477. var mergedHunk = {
  2478. oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
  2479. oldLines: 0,
  2480. newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
  2481. newLines: 0,
  2482. lines: []
  2483. };
  2484. mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
  2485. theirsIndex++;
  2486. mineIndex++;
  2487. ret.hunks.push(mergedHunk);
  2488. }
  2489. }
  2490.  
  2491. return ret;
  2492. }
  2493.  
  2494. function loadPatch(param, base) {
  2495. if (typeof param === 'string') {
  2496. if (/^@@/m.test(param) || /^Index:/m.test(param)) {
  2497. return parsePatch(param)[0];
  2498. }
  2499.  
  2500. if (!base) {
  2501. throw new Error('Must provide a base reference or pass in a patch');
  2502. }
  2503.  
  2504. return structuredPatch(undefined, undefined, base, param);
  2505. }
  2506.  
  2507. return param;
  2508. }
  2509.  
  2510. function fileNameChanged(patch) {
  2511. return patch.newFileName && patch.newFileName !== patch.oldFileName;
  2512. }
  2513.  
  2514. function selectField(index, mine, theirs) {
  2515. if (mine === theirs) {
  2516. return mine;
  2517. } else {
  2518. index.conflict = true;
  2519. return {
  2520. mine: mine,
  2521. theirs: theirs
  2522. };
  2523. }
  2524. }
  2525.  
  2526. function hunkBefore(test, check) {
  2527. return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
  2528. }
  2529.  
  2530. function cloneHunk(hunk, offset) {
  2531. return {
  2532. oldStart: hunk.oldStart,
  2533. oldLines: hunk.oldLines,
  2534. newStart: hunk.newStart + offset,
  2535. newLines: hunk.newLines,
  2536. lines: hunk.lines
  2537. };
  2538. }
  2539.  
  2540. function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
  2541. // This will generally result in a conflicted hunk, but there are cases where the context
  2542. // is the only overlap where we can successfully merge the content here.
  2543. var mine = {
  2544. offset: mineOffset,
  2545. lines: mineLines,
  2546. index: 0
  2547. },
  2548. their = {
  2549. offset: theirOffset,
  2550. lines: theirLines,
  2551. index: 0
  2552. }; // Handle any leading content
  2553.  
  2554. insertLeading(hunk, mine, their);
  2555. insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
  2556.  
  2557. while (mine.index < mine.lines.length && their.index < their.lines.length) {
  2558. var mineCurrent = mine.lines[mine.index],
  2559. theirCurrent = their.lines[their.index];
  2560.  
  2561. if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
  2562. // Both modified ...
  2563. mutualChange(hunk, mine, their);
  2564. } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
  2565. var _hunk$lines;
  2566.  
  2567. // Mine inserted
  2568. (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine)));
  2569. } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
  2570. var _hunk$lines2;
  2571.  
  2572. // Theirs inserted
  2573. (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their)));
  2574. } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
  2575. // Mine removed or edited
  2576. removal(hunk, mine, their);
  2577. } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
  2578. // Their removed or edited
  2579. removal(hunk, their, mine, true);
  2580. } else if (mineCurrent === theirCurrent) {
  2581. // Context identity
  2582. hunk.lines.push(mineCurrent);
  2583. mine.index++;
  2584. their.index++;
  2585. } else {
  2586. // Context mismatch
  2587. conflict(hunk, collectChange(mine), collectChange(their));
  2588. }
  2589. } // Now push anything that may be remaining
  2590.  
  2591.  
  2592. insertTrailing(hunk, mine);
  2593. insertTrailing(hunk, their);
  2594. calcLineCount(hunk);
  2595. }
  2596.  
  2597. function mutualChange(hunk, mine, their) {
  2598. var myChanges = collectChange(mine),
  2599. theirChanges = collectChange(their);
  2600.  
  2601. if (allRemoves(myChanges) && allRemoves(theirChanges)) {
  2602. // Special case for remove changes that are supersets of one another
  2603. if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
  2604. var _hunk$lines3;
  2605.  
  2606. (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges));
  2607.  
  2608. return;
  2609. } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
  2610. var _hunk$lines4;
  2611.  
  2612. (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges));
  2613.  
  2614. return;
  2615. }
  2616. } else if (arrayEqual(myChanges, theirChanges)) {
  2617. var _hunk$lines5;
  2618.  
  2619. (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges));
  2620.  
  2621. return;
  2622. }
  2623.  
  2624. conflict(hunk, myChanges, theirChanges);
  2625. }
  2626.  
  2627. function removal(hunk, mine, their, swap) {
  2628. var myChanges = collectChange(mine),
  2629. theirChanges = collectContext(their, myChanges);
  2630.  
  2631. if (theirChanges.merged) {
  2632. var _hunk$lines6;
  2633.  
  2634. (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged));
  2635. } else {
  2636. conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
  2637. }
  2638. }
  2639.  
  2640. function conflict(hunk, mine, their) {
  2641. hunk.conflict = true;
  2642. hunk.lines.push({
  2643. conflict: true,
  2644. mine: mine,
  2645. theirs: their
  2646. });
  2647. }
  2648.  
  2649. function insertLeading(hunk, insert, their) {
  2650. while (insert.offset < their.offset && insert.index < insert.lines.length) {
  2651. var line = insert.lines[insert.index++];
  2652. hunk.lines.push(line);
  2653. insert.offset++;
  2654. }
  2655. }
  2656.  
  2657. function insertTrailing(hunk, insert) {
  2658. while (insert.index < insert.lines.length) {
  2659. var line = insert.lines[insert.index++];
  2660. hunk.lines.push(line);
  2661. }
  2662. }
  2663.  
  2664. function collectChange(state) {
  2665. var ret = [],
  2666. operation = state.lines[state.index][0];
  2667.  
  2668. while (state.index < state.lines.length) {
  2669. var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
  2670.  
  2671. if (operation === '-' && line[0] === '+') {
  2672. operation = '+';
  2673. }
  2674.  
  2675. if (operation === line[0]) {
  2676. ret.push(line);
  2677. state.index++;
  2678. } else {
  2679. break;
  2680. }
  2681. }
  2682.  
  2683. return ret;
  2684. }
  2685.  
  2686. function collectContext(state, matchChanges) {
  2687. var changes = [],
  2688. merged = [],
  2689. matchIndex = 0,
  2690. contextChanges = false,
  2691. conflicted = false;
  2692.  
  2693. while (matchIndex < matchChanges.length && state.index < state.lines.length) {
  2694. var change = state.lines[state.index],
  2695. match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
  2696.  
  2697. if (match[0] === '+') {
  2698. break;
  2699. }
  2700.  
  2701. contextChanges = contextChanges || change[0] !== ' ';
  2702. merged.push(match);
  2703. matchIndex++; // Consume any additions in the other block as a conflict to attempt
  2704. // to pull in the remaining context after this
  2705.  
  2706. if (change[0] === '+') {
  2707. conflicted = true;
  2708.  
  2709. while (change[0] === '+') {
  2710. changes.push(change);
  2711. change = state.lines[++state.index];
  2712. }
  2713. }
  2714.  
  2715. if (match.substr(1) === change.substr(1)) {
  2716. changes.push(change);
  2717. state.index++;
  2718. } else {
  2719. conflicted = true;
  2720. }
  2721. }
  2722.  
  2723. if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
  2724. conflicted = true;
  2725. }
  2726.  
  2727. if (conflicted) {
  2728. return changes;
  2729. }
  2730.  
  2731. while (matchIndex < matchChanges.length) {
  2732. merged.push(matchChanges[matchIndex++]);
  2733. }
  2734.  
  2735. return {
  2736. merged: merged,
  2737. changes: changes
  2738. };
  2739. }
  2740.  
  2741. function allRemoves(changes) {
  2742. return changes.reduce(function (prev, change) {
  2743. return prev && change[0] === '-';
  2744. }, true);
  2745. }
  2746.  
  2747. function skipRemoveSuperset(state, removeChanges, delta) {
  2748. for (var i = 0; i < delta; i++) {
  2749. var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
  2750.  
  2751. if (state.lines[state.index + i] !== ' ' + changeContent) {
  2752. return false;
  2753. }
  2754. }
  2755.  
  2756. state.index += delta;
  2757. return true;
  2758. }
  2759.  
  2760. function calcOldNewLineCount(lines) {
  2761. var oldLines = 0;
  2762. var newLines = 0;
  2763. lines.forEach(function (line) {
  2764. if (typeof line !== 'string') {
  2765. var myCount = calcOldNewLineCount(line.mine);
  2766. var theirCount = calcOldNewLineCount(line.theirs);
  2767.  
  2768. if (oldLines !== undefined) {
  2769. if (myCount.oldLines === theirCount.oldLines) {
  2770. oldLines += myCount.oldLines;
  2771. } else {
  2772. oldLines = undefined;
  2773. }
  2774. }
  2775.  
  2776. if (newLines !== undefined) {
  2777. if (myCount.newLines === theirCount.newLines) {
  2778. newLines += myCount.newLines;
  2779. } else {
  2780. newLines = undefined;
  2781. }
  2782. }
  2783. } else {
  2784. if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
  2785. newLines++;
  2786. }
  2787.  
  2788. if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
  2789. oldLines++;
  2790. }
  2791. }
  2792. });
  2793. return {
  2794. oldLines: oldLines,
  2795. newLines: newLines
  2796. };
  2797. }
  2798.  
  2799. // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  2800. function convertChangesToDMP(changes) {
  2801. var ret = [],
  2802. change,
  2803. operation;
  2804.  
  2805. for (var i = 0; i < changes.length; i++) {
  2806. change = changes[i];
  2807.  
  2808. if (change.added) {
  2809. operation = 1;
  2810. } else if (change.removed) {
  2811. operation = -1;
  2812. } else {
  2813. operation = 0;
  2814. }
  2815.  
  2816. ret.push([operation, change.value]);
  2817. }
  2818.  
  2819. return ret;
  2820. }
  2821.  
  2822. function convertChangesToXML(changes) {
  2823. var ret = [];
  2824.  
  2825. for (var i = 0; i < changes.length; i++) {
  2826. var change = changes[i];
  2827.  
  2828. if (change.added) {
  2829. ret.push('<ins>');
  2830. } else if (change.removed) {
  2831. ret.push('<del>');
  2832. }
  2833.  
  2834. ret.push(escapeHTML(change.value));
  2835.  
  2836. if (change.added) {
  2837. ret.push('</ins>');
  2838. } else if (change.removed) {
  2839. ret.push('</del>');
  2840. }
  2841. }
  2842.  
  2843. return ret.join('');
  2844. }
  2845.  
  2846. function escapeHTML(s) {
  2847. var n = s;
  2848. n = n.replace(/&/g, '&amp;');
  2849. n = n.replace(/</g, '&lt;');
  2850. n = n.replace(/>/g, '&gt;');
  2851. n = n.replace(/"/g, '&quot;');
  2852. return n;
  2853. }
  2854.  
  2855.  
  2856.  
  2857. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/types.js
  2858. var LineType;
  2859. (function (LineType) {
  2860. LineType["INSERT"] = "insert";
  2861. LineType["DELETE"] = "delete";
  2862. LineType["CONTEXT"] = "context";
  2863. })(LineType || (LineType = {}));
  2864. var OutputFormatType = {
  2865. LINE_BY_LINE: 'line-by-line',
  2866. SIDE_BY_SIDE: 'side-by-side',
  2867. };
  2868. var LineMatchingType = {
  2869. LINES: 'lines',
  2870. WORDS: 'words',
  2871. NONE: 'none',
  2872. };
  2873. var DiffStyleType = {
  2874. WORD: 'word',
  2875. CHAR: 'char',
  2876. };
  2877. //# sourceMappingURL=types.js.map
  2878. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/utils.js
  2879. var specials = [
  2880. '-',
  2881. '[',
  2882. ']',
  2883. '/',
  2884. '{',
  2885. '}',
  2886. '(',
  2887. ')',
  2888. '*',
  2889. '+',
  2890. '?',
  2891. '.',
  2892. '\\',
  2893. '^',
  2894. '$',
  2895. '|',
  2896. ];
  2897. var regex = RegExp('[' + specials.join('\\') + ']', 'g');
  2898. function escapeForRegExp(str) {
  2899. return str.replace(regex, '\\$&');
  2900. }
  2901. function unifyPath(path) {
  2902. return path ? path.replace(/\\/g, '/') : path;
  2903. }
  2904. function hashCode(text) {
  2905. var i, chr, len;
  2906. var hash = 0;
  2907. for (i = 0, len = text.length; i < len; i++) {
  2908. chr = text.charCodeAt(i);
  2909. hash = (hash << 5) - hash + chr;
  2910. hash |= 0;
  2911. }
  2912. return hash;
  2913. }
  2914. //# sourceMappingURL=utils.js.map
  2915. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff-parser.js
  2916. var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
  2917. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
  2918. to[j] = from[i];
  2919. return to;
  2920. };
  2921.  
  2922.  
  2923. function getExtension(filename, language) {
  2924. var filenameParts = filename.split('.');
  2925. return filenameParts.length > 1 ? filenameParts[filenameParts.length - 1] : language;
  2926. }
  2927. function startsWithAny(str, prefixes) {
  2928. return prefixes.reduce(function (startsWith, prefix) { return startsWith || str.startsWith(prefix); }, false);
  2929. }
  2930. var baseDiffFilenamePrefixes = ['a/', 'b/', 'i/', 'w/', 'c/', 'o/'];
  2931. function getFilename(line, linePrefix, extraPrefix) {
  2932. var prefixes = extraPrefix !== undefined ? __spreadArray(__spreadArray([], baseDiffFilenamePrefixes), [extraPrefix]) : baseDiffFilenamePrefixes;
  2933. var FilenameRegExp = linePrefix
  2934. ? new RegExp("^" + escapeForRegExp(linePrefix) + " \"?(.+?)\"?$")
  2935. : new RegExp('^"?(.+?)"?$');
  2936. var _a = FilenameRegExp.exec(line) || [], _b = _a[1], filename = _b === void 0 ? '' : _b;
  2937. var matchingPrefix = prefixes.find(function (p) { return filename.indexOf(p) === 0; });
  2938. var fnameWithoutPrefix = matchingPrefix ? filename.slice(matchingPrefix.length) : filename;
  2939. return fnameWithoutPrefix.replace(/\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [+-]\d{4}.*$/, '');
  2940. }
  2941. function getSrcFilename(line, srcPrefix) {
  2942. return getFilename(line, '---', srcPrefix);
  2943. }
  2944. function getDstFilename(line, dstPrefix) {
  2945. return getFilename(line, '+++', dstPrefix);
  2946. }
  2947. function parse(diffInput, config) {
  2948. if (config === void 0) { config = {}; }
  2949. var files = [];
  2950. var currentFile = null;
  2951. var currentBlock = null;
  2952. var oldLine = null;
  2953. var oldLine2 = null;
  2954. var newLine = null;
  2955. var possibleOldName = null;
  2956. var possibleNewName = null;
  2957. var oldFileNameHeader = '--- ';
  2958. var newFileNameHeader = '+++ ';
  2959. var hunkHeaderPrefix = '@@';
  2960. var oldMode = /^old mode (\d{6})/;
  2961. var newMode = /^new mode (\d{6})/;
  2962. var deletedFileMode = /^deleted file mode (\d{6})/;
  2963. var newFileMode = /^new file mode (\d{6})/;
  2964. var copyFrom = /^copy from "?(.+)"?/;
  2965. var copyTo = /^copy to "?(.+)"?/;
  2966. var renameFrom = /^rename from "?(.+)"?/;
  2967. var renameTo = /^rename to "?(.+)"?/;
  2968. var similarityIndex = /^similarity index (\d+)%/;
  2969. var dissimilarityIndex = /^dissimilarity index (\d+)%/;
  2970. var index = /^index ([\da-z]+)\.\.([\da-z]+)\s*(\d{6})?/;
  2971. var binaryFiles = /^Binary files (.*) and (.*) differ/;
  2972. var binaryDiff = /^GIT binary patch/;
  2973. var combinedIndex = /^index ([\da-z]+),([\da-z]+)\.\.([\da-z]+)/;
  2974. var combinedMode = /^mode (\d{6}),(\d{6})\.\.(\d{6})/;
  2975. var combinedNewFile = /^new file mode (\d{6})/;
  2976. var combinedDeletedFile = /^deleted file mode (\d{6}),(\d{6})/;
  2977. var diffLines = diffInput
  2978. .replace(/\\ No newline at end of file/g, '')
  2979. .replace(/\r\n?/g, '\n')
  2980. .split('\n');
  2981. function saveBlock() {
  2982. if (currentBlock !== null && currentFile !== null) {
  2983. currentFile.blocks.push(currentBlock);
  2984. currentBlock = null;
  2985. }
  2986. }
  2987. function saveFile() {
  2988. if (currentFile !== null) {
  2989. if (!currentFile.oldName && possibleOldName !== null) {
  2990. currentFile.oldName = possibleOldName;
  2991. }
  2992. if (!currentFile.newName && possibleNewName !== null) {
  2993. currentFile.newName = possibleNewName;
  2994. }
  2995. if (currentFile.newName) {
  2996. files.push(currentFile);
  2997. currentFile = null;
  2998. }
  2999. }
  3000. possibleOldName = null;
  3001. possibleNewName = null;
  3002. }
  3003. function startFile() {
  3004. saveBlock();
  3005. saveFile();
  3006. currentFile = {
  3007. blocks: [],
  3008. deletedLines: 0,
  3009. addedLines: 0,
  3010. };
  3011. }
  3012. function startBlock(line) {
  3013. saveBlock();
  3014. var values;
  3015. if (currentFile !== null) {
  3016. if ((values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line))) {
  3017. currentFile.isCombined = false;
  3018. oldLine = parseInt(values[1], 10);
  3019. newLine = parseInt(values[2], 10);
  3020. }
  3021. else if ((values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line))) {
  3022. currentFile.isCombined = true;
  3023. oldLine = parseInt(values[1], 10);
  3024. oldLine2 = parseInt(values[2], 10);
  3025. newLine = parseInt(values[3], 10);
  3026. }
  3027. else {
  3028. if (line.startsWith(hunkHeaderPrefix)) {
  3029. console.error('Failed to parse lines, starting in 0!');
  3030. }
  3031. oldLine = 0;
  3032. newLine = 0;
  3033. currentFile.isCombined = false;
  3034. }
  3035. }
  3036. currentBlock = {
  3037. lines: [],
  3038. oldStartLine: oldLine,
  3039. oldStartLine2: oldLine2,
  3040. newStartLine: newLine,
  3041. header: line,
  3042. };
  3043. }
  3044. function createLine(line) {
  3045. if (currentFile === null || currentBlock === null || oldLine === null || newLine === null)
  3046. return;
  3047. var currentLine = {
  3048. content: line,
  3049. };
  3050. var addedPrefixes = currentFile.isCombined ? ['+ ', ' +', '++'] : ['+'];
  3051. var deletedPrefixes = currentFile.isCombined ? ['- ', ' -', '--'] : ['-'];
  3052. if (startsWithAny(line, addedPrefixes)) {
  3053. currentFile.addedLines++;
  3054. currentLine.type = LineType.INSERT;
  3055. currentLine.oldNumber = undefined;
  3056. currentLine.newNumber = newLine++;
  3057. }
  3058. else if (startsWithAny(line, deletedPrefixes)) {
  3059. currentFile.deletedLines++;
  3060. currentLine.type = LineType.DELETE;
  3061. currentLine.oldNumber = oldLine++;
  3062. currentLine.newNumber = undefined;
  3063. }
  3064. else {
  3065. currentLine.type = LineType.CONTEXT;
  3066. currentLine.oldNumber = oldLine++;
  3067. currentLine.newNumber = newLine++;
  3068. }
  3069. currentBlock.lines.push(currentLine);
  3070. }
  3071. function existHunkHeader(line, lineIdx) {
  3072. var idx = lineIdx;
  3073. while (idx < diffLines.length - 3) {
  3074. if (line.startsWith('diff')) {
  3075. return false;
  3076. }
  3077. if (diffLines[idx].startsWith(oldFileNameHeader) &&
  3078. diffLines[idx + 1].startsWith(newFileNameHeader) &&
  3079. diffLines[idx + 2].startsWith(hunkHeaderPrefix)) {
  3080. return true;
  3081. }
  3082. idx++;
  3083. }
  3084. return false;
  3085. }
  3086. diffLines.forEach(function (line, lineIndex) {
  3087. if (!line || line.startsWith('*')) {
  3088. return;
  3089. }
  3090. var values;
  3091. var prevLine = diffLines[lineIndex - 1];
  3092. var nxtLine = diffLines[lineIndex + 1];
  3093. var afterNxtLine = diffLines[lineIndex + 2];
  3094. if (line.startsWith('diff')) {
  3095. startFile();
  3096. var gitDiffStart = /^diff --git "?([a-ciow]\/.+)"? "?([a-ciow]\/.+)"?/;
  3097. if ((values = gitDiffStart.exec(line))) {
  3098. possibleOldName = getFilename(values[1], undefined, config.dstPrefix);
  3099. possibleNewName = getFilename(values[2], undefined, config.srcPrefix);
  3100. }
  3101. if (currentFile === null) {
  3102. throw new Error('Where is my file !!!');
  3103. }
  3104. currentFile.isGitDiff = true;
  3105. return;
  3106. }
  3107. if (!currentFile ||
  3108. (!currentFile.isGitDiff &&
  3109. currentFile &&
  3110. line.startsWith(oldFileNameHeader) &&
  3111. nxtLine.startsWith(newFileNameHeader) &&
  3112. afterNxtLine.startsWith(hunkHeaderPrefix))) {
  3113. startFile();
  3114. }
  3115. if (currentFile === null || currentFile === void 0 ? void 0 : currentFile.isTooBig) {
  3116. return;
  3117. }
  3118. if (currentFile &&
  3119. ((typeof config.diffMaxChanges === 'number' &&
  3120. currentFile.addedLines + currentFile.deletedLines > config.diffMaxChanges) ||
  3121. (typeof config.diffMaxLineLength === 'number' && line.length > config.diffMaxLineLength))) {
  3122. currentFile.isTooBig = true;
  3123. currentFile.addedLines = 0;
  3124. currentFile.deletedLines = 0;
  3125. currentFile.blocks = [];
  3126. currentBlock = null;
  3127. var message = typeof config.diffTooBigMessage === 'function'
  3128. ? config.diffTooBigMessage(files.length)
  3129. : 'Diff too big to be displayed';
  3130. startBlock(message);
  3131. return;
  3132. }
  3133. if ((line.startsWith(oldFileNameHeader) && nxtLine.startsWith(newFileNameHeader)) ||
  3134. (line.startsWith(newFileNameHeader) && prevLine.startsWith(oldFileNameHeader))) {
  3135. if (currentFile &&
  3136. !currentFile.oldName &&
  3137. line.startsWith('--- ') &&
  3138. (values = getSrcFilename(line, config.srcPrefix))) {
  3139. currentFile.oldName = values;
  3140. currentFile.language = getExtension(currentFile.oldName, currentFile.language);
  3141. return;
  3142. }
  3143. if (currentFile &&
  3144. !currentFile.newName &&
  3145. line.startsWith('+++ ') &&
  3146. (values = getDstFilename(line, config.dstPrefix))) {
  3147. currentFile.newName = values;
  3148. currentFile.language = getExtension(currentFile.newName, currentFile.language);
  3149. return;
  3150. }
  3151. }
  3152. if (currentFile &&
  3153. (line.startsWith(hunkHeaderPrefix) ||
  3154. (currentFile.isGitDiff && currentFile.oldName && currentFile.newName && !currentBlock))) {
  3155. startBlock(line);
  3156. return;
  3157. }
  3158. if (currentBlock && (line.startsWith('+') || line.startsWith('-') || line.startsWith(' '))) {
  3159. createLine(line);
  3160. return;
  3161. }
  3162. var doesNotExistHunkHeader = !existHunkHeader(line, lineIndex);
  3163. if (currentFile === null) {
  3164. throw new Error('Where is my file !!!');
  3165. }
  3166. if ((values = oldMode.exec(line))) {
  3167. currentFile.oldMode = values[1];
  3168. }
  3169. else if ((values = newMode.exec(line))) {
  3170. currentFile.newMode = values[1];
  3171. }
  3172. else if ((values = deletedFileMode.exec(line))) {
  3173. currentFile.deletedFileMode = values[1];
  3174. currentFile.isDeleted = true;
  3175. }
  3176. else if ((values = newFileMode.exec(line))) {
  3177. currentFile.newFileMode = values[1];
  3178. currentFile.isNew = true;
  3179. }
  3180. else if ((values = copyFrom.exec(line))) {
  3181. if (doesNotExistHunkHeader) {
  3182. currentFile.oldName = values[1];
  3183. }
  3184. currentFile.isCopy = true;
  3185. }
  3186. else if ((values = copyTo.exec(line))) {
  3187. if (doesNotExistHunkHeader) {
  3188. currentFile.newName = values[1];
  3189. }
  3190. currentFile.isCopy = true;
  3191. }
  3192. else if ((values = renameFrom.exec(line))) {
  3193. if (doesNotExistHunkHeader) {
  3194. currentFile.oldName = values[1];
  3195. }
  3196. currentFile.isRename = true;
  3197. }
  3198. else if ((values = renameTo.exec(line))) {
  3199. if (doesNotExistHunkHeader) {
  3200. currentFile.newName = values[1];
  3201. }
  3202. currentFile.isRename = true;
  3203. }
  3204. else if ((values = binaryFiles.exec(line))) {
  3205. currentFile.isBinary = true;
  3206. currentFile.oldName = getFilename(values[1], undefined, config.srcPrefix);
  3207. currentFile.newName = getFilename(values[2], undefined, config.dstPrefix);
  3208. startBlock('Binary file');
  3209. }
  3210. else if (binaryDiff.test(line)) {
  3211. currentFile.isBinary = true;
  3212. startBlock(line);
  3213. }
  3214. else if ((values = similarityIndex.exec(line))) {
  3215. currentFile.unchangedPercentage = parseInt(values[1], 10);
  3216. }
  3217. else if ((values = dissimilarityIndex.exec(line))) {
  3218. currentFile.changedPercentage = parseInt(values[1], 10);
  3219. }
  3220. else if ((values = index.exec(line))) {
  3221. currentFile.checksumBefore = values[1];
  3222. currentFile.checksumAfter = values[2];
  3223. values[3] && (currentFile.mode = values[3]);
  3224. }
  3225. else if ((values = combinedIndex.exec(line))) {
  3226. currentFile.checksumBefore = [values[2], values[3]];
  3227. currentFile.checksumAfter = values[1];
  3228. }
  3229. else if ((values = combinedMode.exec(line))) {
  3230. currentFile.oldMode = [values[2], values[3]];
  3231. currentFile.newMode = values[1];
  3232. }
  3233. else if ((values = combinedNewFile.exec(line))) {
  3234. currentFile.newFileMode = values[1];
  3235. currentFile.isNew = true;
  3236. }
  3237. else if ((values = combinedDeletedFile.exec(line))) {
  3238. currentFile.deletedFileMode = values[1];
  3239. currentFile.isDeleted = true;
  3240. }
  3241. });
  3242. saveBlock();
  3243. saveFile();
  3244. return files;
  3245. }
  3246. //# sourceMappingURL=diff-parser.js.map
  3247. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/rematch.js
  3248. function levenshtein(a, b) {
  3249. if (a.length === 0) {
  3250. return b.length;
  3251. }
  3252. if (b.length === 0) {
  3253. return a.length;
  3254. }
  3255. var matrix = [];
  3256. var i;
  3257. for (i = 0; i <= b.length; i++) {
  3258. matrix[i] = [i];
  3259. }
  3260. var j;
  3261. for (j = 0; j <= a.length; j++) {
  3262. matrix[0][j] = j;
  3263. }
  3264. for (i = 1; i <= b.length; i++) {
  3265. for (j = 1; j <= a.length; j++) {
  3266. if (b.charAt(i - 1) === a.charAt(j - 1)) {
  3267. matrix[i][j] = matrix[i - 1][j - 1];
  3268. }
  3269. else {
  3270. matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
  3271. }
  3272. }
  3273. }
  3274. return matrix[b.length][a.length];
  3275. }
  3276. function newDistanceFn(str) {
  3277. return function (x, y) {
  3278. var xValue = str(x).trim();
  3279. var yValue = str(y).trim();
  3280. var lev = levenshtein(xValue, yValue);
  3281. return lev / (xValue.length + yValue.length);
  3282. };
  3283. }
  3284. function newMatcherFn(distance) {
  3285. function findBestMatch(a, b, cache) {
  3286. if (cache === void 0) { cache = new Map(); }
  3287. var bestMatchDist = Infinity;
  3288. var bestMatch;
  3289. for (var i = 0; i < a.length; ++i) {
  3290. for (var j = 0; j < b.length; ++j) {
  3291. var cacheKey = JSON.stringify([a[i], b[j]]);
  3292. var md = void 0;
  3293. if (!(cache.has(cacheKey) && (md = cache.get(cacheKey)))) {
  3294. md = distance(a[i], b[j]);
  3295. cache.set(cacheKey, md);
  3296. }
  3297. if (md < bestMatchDist) {
  3298. bestMatchDist = md;
  3299. bestMatch = { indexA: i, indexB: j, score: bestMatchDist };
  3300. }
  3301. }
  3302. }
  3303. return bestMatch;
  3304. }
  3305. function group(a, b, level, cache) {
  3306. if (level === void 0) { level = 0; }
  3307. if (cache === void 0) { cache = new Map(); }
  3308. var bm = findBestMatch(a, b, cache);
  3309. if (!bm || a.length + b.length < 3) {
  3310. return [[a, b]];
  3311. }
  3312. var a1 = a.slice(0, bm.indexA);
  3313. var b1 = b.slice(0, bm.indexB);
  3314. var aMatch = [a[bm.indexA]];
  3315. var bMatch = [b[bm.indexB]];
  3316. var tailA = bm.indexA + 1;
  3317. var tailB = bm.indexB + 1;
  3318. var a2 = a.slice(tailA);
  3319. var b2 = b.slice(tailB);
  3320. var group1 = group(a1, b1, level + 1, cache);
  3321. var groupMatch = group(aMatch, bMatch, level + 1, cache);
  3322. var group2 = group(a2, b2, level + 1, cache);
  3323. var result = groupMatch;
  3324. if (bm.indexA > 0 || bm.indexB > 0) {
  3325. result = group1.concat(result);
  3326. }
  3327. if (a.length > tailA || b.length > tailB) {
  3328. result = result.concat(group2);
  3329. }
  3330. return result;
  3331. }
  3332. return group;
  3333. }
  3334. //# sourceMappingURL=rematch.js.map
  3335. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/render-utils.js
  3336. var __assign = (undefined && undefined.__assign) || function () {
  3337. __assign = Object.assign || function(t) {
  3338. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3339. s = arguments[i];
  3340. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3341. t[p] = s[p];
  3342. }
  3343. return t;
  3344. };
  3345. return __assign.apply(this, arguments);
  3346. };
  3347.  
  3348.  
  3349.  
  3350.  
  3351. var CSSLineClass = {
  3352. INSERTS: 'd2h-ins',
  3353. DELETES: 'd2h-del',
  3354. CONTEXT: 'd2h-cntx',
  3355. INFO: 'd2h-info',
  3356. INSERT_CHANGES: 'd2h-ins d2h-change',
  3357. DELETE_CHANGES: 'd2h-del d2h-change',
  3358. };
  3359. var defaultRenderConfig = {
  3360. matching: LineMatchingType.NONE,
  3361. matchWordsThreshold: 0.25,
  3362. maxLineLengthHighlight: 10000,
  3363. diffStyle: DiffStyleType.WORD,
  3364. };
  3365. var separator = '/';
  3366. var distance = newDistanceFn(function (change) { return change.value; });
  3367. var matcher = newMatcherFn(distance);
  3368. function isDevNullName(name) {
  3369. return name.indexOf('dev/null') !== -1;
  3370. }
  3371. function removeInsElements(line) {
  3372. return line.replace(/(<ins[^>]*>((.|\n)*?)<\/ins>)/g, '');
  3373. }
  3374. function removeDelElements(line) {
  3375. return line.replace(/(<del[^>]*>((.|\n)*?)<\/del>)/g, '');
  3376. }
  3377. function toCSSClass(lineType) {
  3378. switch (lineType) {
  3379. case LineType.CONTEXT:
  3380. return CSSLineClass.CONTEXT;
  3381. case LineType.INSERT:
  3382. return CSSLineClass.INSERTS;
  3383. case LineType.DELETE:
  3384. return CSSLineClass.DELETES;
  3385. }
  3386. }
  3387. function prefixLength(isCombined) {
  3388. return isCombined ? 2 : 1;
  3389. }
  3390. function escapeForHtml(str) {
  3391. return str
  3392. .slice(0)
  3393. .replace(/&/g, '&amp;')
  3394. .replace(/</g, '&lt;')
  3395. .replace(/>/g, '&gt;')
  3396. .replace(/"/g, '&quot;')
  3397. .replace(/'/g, '&#x27;')
  3398. .replace(/\//g, '&#x2F;');
  3399. }
  3400. function deconstructLine(line, isCombined, escape) {
  3401. if (escape === void 0) { escape = true; }
  3402. var indexToSplit = prefixLength(isCombined);
  3403. return {
  3404. prefix: line.substring(0, indexToSplit),
  3405. content: escape ? escapeForHtml(line.substring(indexToSplit)) : line.substring(indexToSplit),
  3406. };
  3407. }
  3408. function filenameDiff(file) {
  3409. var oldFilename = unifyPath(file.oldName);
  3410. var newFilename = unifyPath(file.newName);
  3411. if (oldFilename !== newFilename && !isDevNullName(oldFilename) && !isDevNullName(newFilename)) {
  3412. var prefixPaths = [];
  3413. var suffixPaths = [];
  3414. var oldFilenameParts = oldFilename.split(separator);
  3415. var newFilenameParts = newFilename.split(separator);
  3416. var oldFilenamePartsSize = oldFilenameParts.length;
  3417. var newFilenamePartsSize = newFilenameParts.length;
  3418. var i = 0;
  3419. var j = oldFilenamePartsSize - 1;
  3420. var k = newFilenamePartsSize - 1;
  3421. while (i < j && i < k) {
  3422. if (oldFilenameParts[i] === newFilenameParts[i]) {
  3423. prefixPaths.push(newFilenameParts[i]);
  3424. i += 1;
  3425. }
  3426. else {
  3427. break;
  3428. }
  3429. }
  3430. while (j > i && k > i) {
  3431. if (oldFilenameParts[j] === newFilenameParts[k]) {
  3432. suffixPaths.unshift(newFilenameParts[k]);
  3433. j -= 1;
  3434. k -= 1;
  3435. }
  3436. else {
  3437. break;
  3438. }
  3439. }
  3440. var finalPrefix = prefixPaths.join(separator);
  3441. var finalSuffix = suffixPaths.join(separator);
  3442. var oldRemainingPath = oldFilenameParts.slice(i, j + 1).join(separator);
  3443. var newRemainingPath = newFilenameParts.slice(i, k + 1).join(separator);
  3444. if (finalPrefix.length && finalSuffix.length) {
  3445. return (finalPrefix + separator + '{' + oldRemainingPath + ' → ' + newRemainingPath + '}' + separator + finalSuffix);
  3446. }
  3447. else if (finalPrefix.length) {
  3448. return finalPrefix + separator + '{' + oldRemainingPath + ' → ' + newRemainingPath + '}';
  3449. }
  3450. else if (finalSuffix.length) {
  3451. return '{' + oldRemainingPath + ' → ' + newRemainingPath + '}' + separator + finalSuffix;
  3452. }
  3453. return oldFilename + ' → ' + newFilename;
  3454. }
  3455. else if (!isDevNullName(newFilename)) {
  3456. return newFilename;
  3457. }
  3458. else {
  3459. return oldFilename;
  3460. }
  3461. }
  3462. function getHtmlId(file) {
  3463. return "d2h-" + hashCode(filenameDiff(file)).toString().slice(-6);
  3464. }
  3465. function getFileIcon(file) {
  3466. var templateName = 'file-changed';
  3467. if (file.isRename) {
  3468. templateName = 'file-renamed';
  3469. }
  3470. else if (file.isCopy) {
  3471. templateName = 'file-renamed';
  3472. }
  3473. else if (file.isNew) {
  3474. templateName = 'file-added';
  3475. }
  3476. else if (file.isDeleted) {
  3477. templateName = 'file-deleted';
  3478. }
  3479. else if (file.newName !== file.oldName) {
  3480. templateName = 'file-renamed';
  3481. }
  3482. return templateName;
  3483. }
  3484. function diffHighlight(diffLine1, diffLine2, isCombined, config) {
  3485. if (config === void 0) { config = {}; }
  3486. var _a = __assign(__assign({}, defaultRenderConfig), config), matching = _a.matching, maxLineLengthHighlight = _a.maxLineLengthHighlight, matchWordsThreshold = _a.matchWordsThreshold, diffStyle = _a.diffStyle;
  3487. var line1 = deconstructLine(diffLine1, isCombined, false);
  3488. var line2 = deconstructLine(diffLine2, isCombined, false);
  3489. if (line1.content.length > maxLineLengthHighlight || line2.content.length > maxLineLengthHighlight) {
  3490. return {
  3491. oldLine: {
  3492. prefix: line1.prefix,
  3493. content: escapeForHtml(line1.content),
  3494. },
  3495. newLine: {
  3496. prefix: line2.prefix,
  3497. content: escapeForHtml(line2.content),
  3498. },
  3499. };
  3500. }
  3501. var diff = diffStyle === 'char'
  3502. ? diffChars(line1.content, line2.content)
  3503. : diffWordsWithSpace(line1.content, line2.content);
  3504. var changedWords = [];
  3505. if (diffStyle === 'word' && matching === 'words') {
  3506. var removed = diff.filter(function (element) { return element.removed; });
  3507. var added = diff.filter(function (element) { return element.added; });
  3508. var chunks = matcher(added, removed);
  3509. chunks.forEach(function (chunk) {
  3510. if (chunk[0].length === 1 && chunk[1].length === 1) {
  3511. var dist = distance(chunk[0][0], chunk[1][0]);
  3512. if (dist < matchWordsThreshold) {
  3513. changedWords.push(chunk[0][0]);
  3514. changedWords.push(chunk[1][0]);
  3515. }
  3516. }
  3517. });
  3518. }
  3519. var highlightedLine = diff.reduce(function (highlightedLine, part) {
  3520. var elemType = part.added ? 'ins' : part.removed ? 'del' : null;
  3521. var addClass = changedWords.indexOf(part) > -1 ? ' class="d2h-change"' : '';
  3522. var escapedValue = escapeForHtml(part.value);
  3523. return elemType !== null
  3524. ? highlightedLine + "<" + elemType + addClass + ">" + escapedValue + "</" + elemType + ">"
  3525. : "" + highlightedLine + escapedValue;
  3526. }, '');
  3527. return {
  3528. oldLine: {
  3529. prefix: line1.prefix,
  3530. content: removeInsElements(highlightedLine),
  3531. },
  3532. newLine: {
  3533. prefix: line2.prefix,
  3534. content: removeDelElements(highlightedLine),
  3535. },
  3536. };
  3537. }
  3538. //# sourceMappingURL=render-utils.js.map
  3539. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/file-list-renderer.js
  3540.  
  3541. var baseTemplatesPath = 'file-summary';
  3542. var iconsBaseTemplatesPath = 'icon';
  3543. function render(diffFiles, hoganUtils) {
  3544. var files = diffFiles
  3545. .map(function (file) {
  3546. return hoganUtils.render(baseTemplatesPath, 'line', {
  3547. fileHtmlId: getHtmlId(file),
  3548. oldName: file.oldName,
  3549. newName: file.newName,
  3550. fileName: filenameDiff(file),
  3551. deletedLines: '-' + file.deletedLines,
  3552. addedLines: '+' + file.addedLines,
  3553. }, {
  3554. fileIcon: hoganUtils.template(iconsBaseTemplatesPath, getFileIcon(file)),
  3555. });
  3556. })
  3557. .join('\n');
  3558. return hoganUtils.render(baseTemplatesPath, 'wrapper', {
  3559. filesNumber: diffFiles.length,
  3560. files: files,
  3561. });
  3562. }
  3563. //# sourceMappingURL=file-list-renderer.js.map
  3564. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/line-by-line-renderer.js
  3565. var line_by_line_renderer_assign = (undefined && undefined.__assign) || function () {
  3566. line_by_line_renderer_assign = Object.assign || function(t) {
  3567. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3568. s = arguments[i];
  3569. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3570. t[p] = s[p];
  3571. }
  3572. return t;
  3573. };
  3574. return line_by_line_renderer_assign.apply(this, arguments);
  3575. };
  3576.  
  3577.  
  3578.  
  3579. var defaultLineByLineRendererConfig = line_by_line_renderer_assign(line_by_line_renderer_assign({}, defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 });
  3580. var genericTemplatesPath = 'generic';
  3581. var line_by_line_renderer_baseTemplatesPath = 'line-by-line';
  3582. var line_by_line_renderer_iconsBaseTemplatesPath = 'icon';
  3583. var tagsBaseTemplatesPath = 'tag';
  3584. var LineByLineRenderer = (function () {
  3585. function LineByLineRenderer(hoganUtils, config) {
  3586. if (config === void 0) { config = {}; }
  3587. this.hoganUtils = hoganUtils;
  3588. this.config = line_by_line_renderer_assign(line_by_line_renderer_assign({}, defaultLineByLineRendererConfig), config);
  3589. }
  3590. LineByLineRenderer.prototype.render = function (diffFiles) {
  3591. var _this = this;
  3592. var diffsHtml = diffFiles
  3593. .map(function (file) {
  3594. var diffs;
  3595. if (file.blocks.length) {
  3596. diffs = _this.generateFileHtml(file);
  3597. }
  3598. else {
  3599. diffs = _this.generateEmptyDiff();
  3600. }
  3601. return _this.makeFileDiffHtml(file, diffs);
  3602. })
  3603. .join('\n');
  3604. return this.hoganUtils.render(genericTemplatesPath, 'wrapper', { content: diffsHtml });
  3605. };
  3606. LineByLineRenderer.prototype.makeFileDiffHtml = function (file, diffs) {
  3607. if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0)
  3608. return '';
  3609. var fileDiffTemplate = this.hoganUtils.template(line_by_line_renderer_baseTemplatesPath, 'file-diff');
  3610. var filePathTemplate = this.hoganUtils.template(genericTemplatesPath, 'file-path');
  3611. var fileIconTemplate = this.hoganUtils.template(line_by_line_renderer_iconsBaseTemplatesPath, 'file');
  3612. var fileTagTemplate = this.hoganUtils.template(tagsBaseTemplatesPath, getFileIcon(file));
  3613. return fileDiffTemplate.render({
  3614. file: file,
  3615. fileHtmlId: getHtmlId(file),
  3616. diffs: diffs,
  3617. filePath: filePathTemplate.render({
  3618. fileDiffName: filenameDiff(file),
  3619. }, {
  3620. fileIcon: fileIconTemplate,
  3621. fileTag: fileTagTemplate,
  3622. }),
  3623. });
  3624. };
  3625. LineByLineRenderer.prototype.generateEmptyDiff = function () {
  3626. return this.hoganUtils.render(genericTemplatesPath, 'empty-diff', {
  3627. contentClass: 'd2h-code-line',
  3628. CSSLineClass: CSSLineClass,
  3629. });
  3630. };
  3631. LineByLineRenderer.prototype.generateFileHtml = function (file) {
  3632. var _this = this;
  3633. var matcher = newMatcherFn(newDistanceFn(function (e) { return deconstructLine(e.content, file.isCombined).content; }));
  3634. return file.blocks
  3635. .map(function (block) {
  3636. var lines = _this.hoganUtils.render(genericTemplatesPath, 'block-header', {
  3637. CSSLineClass: CSSLineClass,
  3638. blockHeader: file.isTooBig ? block.header : escapeForHtml(block.header),
  3639. lineClass: 'd2h-code-linenumber',
  3640. contentClass: 'd2h-code-line',
  3641. });
  3642. _this.applyLineGroupping(block).forEach(function (_a) {
  3643. var contextLines = _a[0], oldLines = _a[1], newLines = _a[2];
  3644. if (oldLines.length && newLines.length && !contextLines.length) {
  3645. _this.applyRematchMatching(oldLines, newLines, matcher).map(function (_a) {
  3646. var oldLines = _a[0], newLines = _a[1];
  3647. var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
  3648. lines += left;
  3649. lines += right;
  3650. });
  3651. }
  3652. else if (contextLines.length) {
  3653. contextLines.forEach(function (line) {
  3654. var _a = deconstructLine(line.content, file.isCombined), prefix = _a.prefix, content = _a.content;
  3655. lines += _this.generateSingleLineHtml({
  3656. type: CSSLineClass.CONTEXT,
  3657. prefix: prefix,
  3658. content: content,
  3659. oldNumber: line.oldNumber,
  3660. newNumber: line.newNumber,
  3661. });
  3662. });
  3663. }
  3664. else if (oldLines.length || newLines.length) {
  3665. var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
  3666. lines += left;
  3667. lines += right;
  3668. }
  3669. else {
  3670. console.error('Unknown state reached while processing groups of lines', contextLines, oldLines, newLines);
  3671. }
  3672. });
  3673. return lines;
  3674. })
  3675. .join('\n');
  3676. };
  3677. LineByLineRenderer.prototype.applyLineGroupping = function (block) {
  3678. var blockLinesGroups = [];
  3679. var oldLines = [];
  3680. var newLines = [];
  3681. for (var i = 0; i < block.lines.length; i++) {
  3682. var diffLine = block.lines[i];
  3683. if ((diffLine.type !== LineType.INSERT && newLines.length) ||
  3684. (diffLine.type === LineType.CONTEXT && oldLines.length > 0)) {
  3685. blockLinesGroups.push([[], oldLines, newLines]);
  3686. oldLines = [];
  3687. newLines = [];
  3688. }
  3689. if (diffLine.type === LineType.CONTEXT) {
  3690. blockLinesGroups.push([[diffLine], [], []]);
  3691. }
  3692. else if (diffLine.type === LineType.INSERT && oldLines.length === 0) {
  3693. blockLinesGroups.push([[], [], [diffLine]]);
  3694. }
  3695. else if (diffLine.type === LineType.INSERT && oldLines.length > 0) {
  3696. newLines.push(diffLine);
  3697. }
  3698. else if (diffLine.type === LineType.DELETE) {
  3699. oldLines.push(diffLine);
  3700. }
  3701. }
  3702. if (oldLines.length || newLines.length) {
  3703. blockLinesGroups.push([[], oldLines, newLines]);
  3704. oldLines = [];
  3705. newLines = [];
  3706. }
  3707. return blockLinesGroups;
  3708. };
  3709. LineByLineRenderer.prototype.applyRematchMatching = function (oldLines, newLines, matcher) {
  3710. var comparisons = oldLines.length * newLines.length;
  3711. var maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map(function (elem) { return elem.content.length; })));
  3712. var doMatching = comparisons < this.config.matchingMaxComparisons &&
  3713. maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison &&
  3714. (this.config.matching === 'lines' || this.config.matching === 'words');
  3715. return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
  3716. };
  3717. LineByLineRenderer.prototype.processChangedLines = function (isCombined, oldLines, newLines) {
  3718. var fileHtml = {
  3719. right: '',
  3720. left: '',
  3721. };
  3722. var maxLinesNumber = Math.max(oldLines.length, newLines.length);
  3723. for (var i = 0; i < maxLinesNumber; i++) {
  3724. var oldLine = oldLines[i];
  3725. var newLine = newLines[i];
  3726. var diff = oldLine !== undefined && newLine !== undefined
  3727. ? diffHighlight(oldLine.content, newLine.content, isCombined, this.config)
  3728. : undefined;
  3729. var preparedOldLine = oldLine !== undefined && oldLine.oldNumber !== undefined
  3730. ? line_by_line_renderer_assign(line_by_line_renderer_assign({}, (diff !== undefined
  3731. ? {
  3732. prefix: diff.oldLine.prefix,
  3733. content: diff.oldLine.content,
  3734. type: CSSLineClass.DELETE_CHANGES,
  3735. }
  3736. : line_by_line_renderer_assign(line_by_line_renderer_assign({}, deconstructLine(oldLine.content, isCombined)), { type: toCSSClass(oldLine.type) }))), { oldNumber: oldLine.oldNumber, newNumber: oldLine.newNumber }) : undefined;
  3737. var preparedNewLine = newLine !== undefined && newLine.newNumber !== undefined
  3738. ? line_by_line_renderer_assign(line_by_line_renderer_assign({}, (diff !== undefined
  3739. ? {
  3740. prefix: diff.newLine.prefix,
  3741. content: diff.newLine.content,
  3742. type: CSSLineClass.INSERT_CHANGES,
  3743. }
  3744. : line_by_line_renderer_assign(line_by_line_renderer_assign({}, deconstructLine(newLine.content, isCombined)), { type: toCSSClass(newLine.type) }))), { oldNumber: newLine.oldNumber, newNumber: newLine.newNumber }) : undefined;
  3745. var _a = this.generateLineHtml(preparedOldLine, preparedNewLine), left = _a.left, right = _a.right;
  3746. fileHtml.left += left;
  3747. fileHtml.right += right;
  3748. }
  3749. return fileHtml;
  3750. };
  3751. LineByLineRenderer.prototype.generateLineHtml = function (oldLine, newLine) {
  3752. return {
  3753. left: this.generateSingleLineHtml(oldLine),
  3754. right: this.generateSingleLineHtml(newLine),
  3755. };
  3756. };
  3757. LineByLineRenderer.prototype.generateSingleLineHtml = function (line) {
  3758. if (line === undefined)
  3759. return '';
  3760. var lineNumberHtml = this.hoganUtils.render(line_by_line_renderer_baseTemplatesPath, 'numbers', {
  3761. oldNumber: line.oldNumber || '',
  3762. newNumber: line.newNumber || '',
  3763. });
  3764. return this.hoganUtils.render(genericTemplatesPath, 'line', {
  3765. type: line.type,
  3766. lineClass: 'd2h-code-linenumber',
  3767. contentClass: 'd2h-code-line',
  3768. prefix: line.prefix === ' ' ? '&nbsp;' : line.prefix,
  3769. content: line.content,
  3770. lineNumber: lineNumberHtml,
  3771. });
  3772. };
  3773. return LineByLineRenderer;
  3774. }());
  3775. /* harmony default export */ const line_by_line_renderer = (LineByLineRenderer);
  3776. //# sourceMappingURL=line-by-line-renderer.js.map
  3777. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/side-by-side-renderer.js
  3778. var side_by_side_renderer_assign = (undefined && undefined.__assign) || function () {
  3779. side_by_side_renderer_assign = Object.assign || function(t) {
  3780. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3781. s = arguments[i];
  3782. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3783. t[p] = s[p];
  3784. }
  3785. return t;
  3786. };
  3787. return side_by_side_renderer_assign.apply(this, arguments);
  3788. };
  3789.  
  3790.  
  3791.  
  3792. var defaultSideBySideRendererConfig = side_by_side_renderer_assign(side_by_side_renderer_assign({}, defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 });
  3793. var side_by_side_renderer_genericTemplatesPath = 'generic';
  3794. var side_by_side_renderer_baseTemplatesPath = 'side-by-side';
  3795. var side_by_side_renderer_iconsBaseTemplatesPath = 'icon';
  3796. var side_by_side_renderer_tagsBaseTemplatesPath = 'tag';
  3797. var SideBySideRenderer = (function () {
  3798. function SideBySideRenderer(hoganUtils, config) {
  3799. if (config === void 0) { config = {}; }
  3800. this.hoganUtils = hoganUtils;
  3801. this.config = side_by_side_renderer_assign(side_by_side_renderer_assign({}, defaultSideBySideRendererConfig), config);
  3802. }
  3803. SideBySideRenderer.prototype.render = function (diffFiles) {
  3804. var _this = this;
  3805. var diffsHtml = diffFiles
  3806. .map(function (file) {
  3807. var diffs;
  3808. if (file.blocks.length) {
  3809. diffs = _this.generateFileHtml(file);
  3810. }
  3811. else {
  3812. diffs = _this.generateEmptyDiff();
  3813. }
  3814. return _this.makeFileDiffHtml(file, diffs);
  3815. })
  3816. .join('\n');
  3817. return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'wrapper', { content: diffsHtml });
  3818. };
  3819. SideBySideRenderer.prototype.makeFileDiffHtml = function (file, diffs) {
  3820. if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0)
  3821. return '';
  3822. var fileDiffTemplate = this.hoganUtils.template(side_by_side_renderer_baseTemplatesPath, 'file-diff');
  3823. var filePathTemplate = this.hoganUtils.template(side_by_side_renderer_genericTemplatesPath, 'file-path');
  3824. var fileIconTemplate = this.hoganUtils.template(side_by_side_renderer_iconsBaseTemplatesPath, 'file');
  3825. var fileTagTemplate = this.hoganUtils.template(side_by_side_renderer_tagsBaseTemplatesPath, getFileIcon(file));
  3826. return fileDiffTemplate.render({
  3827. file: file,
  3828. fileHtmlId: getHtmlId(file),
  3829. diffs: diffs,
  3830. filePath: filePathTemplate.render({
  3831. fileDiffName: filenameDiff(file),
  3832. }, {
  3833. fileIcon: fileIconTemplate,
  3834. fileTag: fileTagTemplate,
  3835. }),
  3836. });
  3837. };
  3838. SideBySideRenderer.prototype.generateEmptyDiff = function () {
  3839. return {
  3840. right: '',
  3841. left: this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'empty-diff', {
  3842. contentClass: 'd2h-code-side-line',
  3843. CSSLineClass: CSSLineClass,
  3844. }),
  3845. };
  3846. };
  3847. SideBySideRenderer.prototype.generateFileHtml = function (file) {
  3848. var _this = this;
  3849. var matcher = newMatcherFn(newDistanceFn(function (e) { return deconstructLine(e.content, file.isCombined).content; }));
  3850. return file.blocks
  3851. .map(function (block) {
  3852. var fileHtml = {
  3853. left: _this.makeHeaderHtml(block.header, file),
  3854. right: _this.makeHeaderHtml(''),
  3855. };
  3856. _this.applyLineGroupping(block).forEach(function (_a) {
  3857. var contextLines = _a[0], oldLines = _a[1], newLines = _a[2];
  3858. if (oldLines.length && newLines.length && !contextLines.length) {
  3859. _this.applyRematchMatching(oldLines, newLines, matcher).map(function (_a) {
  3860. var oldLines = _a[0], newLines = _a[1];
  3861. var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
  3862. fileHtml.left += left;
  3863. fileHtml.right += right;
  3864. });
  3865. }
  3866. else if (contextLines.length) {
  3867. contextLines.forEach(function (line) {
  3868. var _a = deconstructLine(line.content, file.isCombined), prefix = _a.prefix, content = _a.content;
  3869. var _b = _this.generateLineHtml({
  3870. type: CSSLineClass.CONTEXT,
  3871. prefix: prefix,
  3872. content: content,
  3873. number: line.oldNumber,
  3874. }, {
  3875. type: CSSLineClass.CONTEXT,
  3876. prefix: prefix,
  3877. content: content,
  3878. number: line.newNumber,
  3879. }), left = _b.left, right = _b.right;
  3880. fileHtml.left += left;
  3881. fileHtml.right += right;
  3882. });
  3883. }
  3884. else if (oldLines.length || newLines.length) {
  3885. var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
  3886. fileHtml.left += left;
  3887. fileHtml.right += right;
  3888. }
  3889. else {
  3890. console.error('Unknown state reached while processing groups of lines', contextLines, oldLines, newLines);
  3891. }
  3892. });
  3893. return fileHtml;
  3894. })
  3895. .reduce(function (accomulated, html) {
  3896. return { left: accomulated.left + html.left, right: accomulated.right + html.right };
  3897. }, { left: '', right: '' });
  3898. };
  3899. SideBySideRenderer.prototype.applyLineGroupping = function (block) {
  3900. var blockLinesGroups = [];
  3901. var oldLines = [];
  3902. var newLines = [];
  3903. for (var i = 0; i < block.lines.length; i++) {
  3904. var diffLine = block.lines[i];
  3905. if ((diffLine.type !== LineType.INSERT && newLines.length) ||
  3906. (diffLine.type === LineType.CONTEXT && oldLines.length > 0)) {
  3907. blockLinesGroups.push([[], oldLines, newLines]);
  3908. oldLines = [];
  3909. newLines = [];
  3910. }
  3911. if (diffLine.type === LineType.CONTEXT) {
  3912. blockLinesGroups.push([[diffLine], [], []]);
  3913. }
  3914. else if (diffLine.type === LineType.INSERT && oldLines.length === 0) {
  3915. blockLinesGroups.push([[], [], [diffLine]]);
  3916. }
  3917. else if (diffLine.type === LineType.INSERT && oldLines.length > 0) {
  3918. newLines.push(diffLine);
  3919. }
  3920. else if (diffLine.type === LineType.DELETE) {
  3921. oldLines.push(diffLine);
  3922. }
  3923. }
  3924. if (oldLines.length || newLines.length) {
  3925. blockLinesGroups.push([[], oldLines, newLines]);
  3926. oldLines = [];
  3927. newLines = [];
  3928. }
  3929. return blockLinesGroups;
  3930. };
  3931. SideBySideRenderer.prototype.applyRematchMatching = function (oldLines, newLines, matcher) {
  3932. var comparisons = oldLines.length * newLines.length;
  3933. var maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map(function (elem) { return elem.content.length; })));
  3934. var doMatching = comparisons < this.config.matchingMaxComparisons &&
  3935. maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison &&
  3936. (this.config.matching === 'lines' || this.config.matching === 'words');
  3937. return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
  3938. };
  3939. SideBySideRenderer.prototype.makeHeaderHtml = function (blockHeader, file) {
  3940. return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'block-header', {
  3941. CSSLineClass: CSSLineClass,
  3942. blockHeader: (file === null || file === void 0 ? void 0 : file.isTooBig) ? blockHeader : escapeForHtml(blockHeader),
  3943. lineClass: 'd2h-code-side-linenumber',
  3944. contentClass: 'd2h-code-side-line',
  3945. });
  3946. };
  3947. SideBySideRenderer.prototype.processChangedLines = function (isCombined, oldLines, newLines) {
  3948. var fileHtml = {
  3949. right: '',
  3950. left: '',
  3951. };
  3952. var maxLinesNumber = Math.max(oldLines.length, newLines.length);
  3953. for (var i = 0; i < maxLinesNumber; i++) {
  3954. var oldLine = oldLines[i];
  3955. var newLine = newLines[i];
  3956. var diff = oldLine !== undefined && newLine !== undefined
  3957. ? diffHighlight(oldLine.content, newLine.content, isCombined, this.config)
  3958. : undefined;
  3959. var preparedOldLine = oldLine !== undefined && oldLine.oldNumber !== undefined
  3960. ? side_by_side_renderer_assign(side_by_side_renderer_assign({}, (diff !== undefined
  3961. ? {
  3962. prefix: diff.oldLine.prefix,
  3963. content: diff.oldLine.content,
  3964. type: CSSLineClass.DELETE_CHANGES,
  3965. }
  3966. : side_by_side_renderer_assign(side_by_side_renderer_assign({}, deconstructLine(oldLine.content, isCombined)), { type: toCSSClass(oldLine.type) }))), { number: oldLine.oldNumber }) : undefined;
  3967. var preparedNewLine = newLine !== undefined && newLine.newNumber !== undefined
  3968. ? side_by_side_renderer_assign(side_by_side_renderer_assign({}, (diff !== undefined
  3969. ? {
  3970. prefix: diff.newLine.prefix,
  3971. content: diff.newLine.content,
  3972. type: CSSLineClass.INSERT_CHANGES,
  3973. }
  3974. : side_by_side_renderer_assign(side_by_side_renderer_assign({}, deconstructLine(newLine.content, isCombined)), { type: toCSSClass(newLine.type) }))), { number: newLine.newNumber }) : undefined;
  3975. var _a = this.generateLineHtml(preparedOldLine, preparedNewLine), left = _a.left, right = _a.right;
  3976. fileHtml.left += left;
  3977. fileHtml.right += right;
  3978. }
  3979. return fileHtml;
  3980. };
  3981. SideBySideRenderer.prototype.generateLineHtml = function (oldLine, newLine) {
  3982. return {
  3983. left: this.generateSingleHtml(oldLine),
  3984. right: this.generateSingleHtml(newLine),
  3985. };
  3986. };
  3987. SideBySideRenderer.prototype.generateSingleHtml = function (line) {
  3988. var lineClass = 'd2h-code-side-linenumber';
  3989. var contentClass = 'd2h-code-side-line';
  3990. return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'line', {
  3991. type: (line === null || line === void 0 ? void 0 : line.type) || CSSLineClass.CONTEXT + " d2h-emptyplaceholder",
  3992. lineClass: line !== undefined ? lineClass : lineClass + " d2h-code-side-emptyplaceholder",
  3993. contentClass: line !== undefined ? contentClass : contentClass + " d2h-code-side-emptyplaceholder",
  3994. prefix: (line === null || line === void 0 ? void 0 : line.prefix) === ' ' ? '&nbsp;' : line === null || line === void 0 ? void 0 : line.prefix,
  3995. content: line === null || line === void 0 ? void 0 : line.content,
  3996. lineNumber: line === null || line === void 0 ? void 0 : line.number,
  3997. });
  3998. };
  3999. return SideBySideRenderer;
  4000. }());
  4001. /* harmony default export */ const side_by_side_renderer = (SideBySideRenderer);
  4002. //# sourceMappingURL=side-by-side-renderer.js.map
  4003. // EXTERNAL MODULE: ./node_modules/hogan.js/lib/hogan.js
  4004. var hogan = __webpack_require__(485);
  4005. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff2html-templates.js
  4006.  
  4007. var defaultTemplates = {};
  4008. defaultTemplates["file-summary-line"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<li class=\"d2h-file-list-line\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-name-wrapper\">"); t.b("\n" + i); t.b(t.rp("<fileIcon0", c, p, " ")); t.b(" <a href=\"#"); t.b(t.v(t.f("fileHtmlId", c, p, 0))); t.b("\" class=\"d2h-file-name\">"); t.b(t.v(t.f("fileName", c, p, 0))); t.b("</a>"); t.b("\n" + i); t.b(" <span class=\"d2h-file-stats\">"); t.b("\n" + i); t.b(" <span class=\"d2h-lines-added\">"); t.b(t.v(t.f("addedLines", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(" <span class=\"d2h-lines-deleted\">"); t.b(t.v(t.f("deletedLines", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(" </span>"); t.b("\n" + i); t.b(" </span>"); t.b("\n" + i); t.b("</li>"); return t.fl(); }, partials: { "<fileIcon0": { name: "fileIcon", partials: {}, subs: {} } }, subs: {} });
  4009. defaultTemplates["file-summary-wrapper"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-file-list-wrapper\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-list-header\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-list-title\">Files changed ("); t.b(t.v(t.f("filesNumber", c, p, 0))); t.b(")</span>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-hide\">hide</a>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-show\">show</a>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <ol class=\"d2h-file-list\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("files", c, p, 0))); t.b("\n" + i); t.b(" </ol>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
  4010. defaultTemplates["generic-block-header"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<tr>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.f("lineClass", c, p, 0))); t.b(" "); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\"></td>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\""); t.b(t.v(t.f("contentClass", c, p, 0))); t.b("\">"); t.b(t.t(t.f("blockHeader", c, p, 0))); t.b("</div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
  4011. defaultTemplates["generic-empty-diff"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<tr>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\""); t.b(t.v(t.f("contentClass", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" File without changes"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
  4012. defaultTemplates["generic-file-path"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-file-name-wrapper\">"); t.b("\n" + i); t.b(t.rp("<fileIcon0", c, p, " ")); t.b(" <span class=\"d2h-file-name\">"); t.b(t.v(t.f("fileDiffName", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(t.rp("<fileTag1", c, p, " ")); t.b("</span>"); t.b("\n" + i); t.b("<label class=\"d2h-file-collapse\">"); t.b("\n" + i); t.b(" <input class=\"d2h-file-collapse-input\" type=\"checkbox\" name=\"viewed\" value=\"viewed\">"); t.b("\n" + i); t.b(" Viewed"); t.b("\n" + i); t.b("</label>"); return t.fl(); }, partials: { "<fileIcon0": { name: "fileIcon", partials: {}, subs: {} }, "<fileTag1": { name: "fileTag", partials: {}, subs: {} } }, subs: {} });
  4013. defaultTemplates["generic-line"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<tr>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.f("lineClass", c, p, 0))); t.b(" "); t.b(t.v(t.f("type", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("lineNumber", c, p, 0))); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.f("type", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\""); t.b(t.v(t.f("contentClass", c, p, 0))); t.b("\">"); t.b("\n" + i); if (t.s(t.f("prefix", c, p, 1), c, p, 0, 162, 238, "{{ }}")) {
  4014. t.rs(c, p, function (c, p, t) { t.b(" <span class=\"d2h-code-line-prefix\">"); t.b(t.t(t.f("prefix", c, p, 0))); t.b("</span>"); t.b("\n" + i); });
  4015. c.pop();
  4016. } if (!t.s(t.f("prefix", c, p, 1), c, p, 1, 0, 0, "")) {
  4017. t.b(" <span class=\"d2h-code-line-prefix\">&nbsp;</span>");
  4018. t.b("\n" + i);
  4019. } ; if (t.s(t.f("content", c, p, 1), c, p, 0, 371, 445, "{{ }}")) {
  4020. t.rs(c, p, function (c, p, t) { t.b(" <span class=\"d2h-code-line-ctn\">"); t.b(t.t(t.f("content", c, p, 0))); t.b("</span>"); t.b("\n" + i); });
  4021. c.pop();
  4022. } if (!t.s(t.f("content", c, p, 1), c, p, 1, 0, 0, "")) {
  4023. t.b(" <span class=\"d2h-code-line-ctn\"><br></span>");
  4024. t.b("\n" + i);
  4025. } ; t.b(" </div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
  4026. defaultTemplates["generic-wrapper"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-wrapper\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("content", c, p, 0))); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
  4027. defaultTemplates["icon-file-added"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-added\" height=\"16\" title=\"added\" version=\"1.1\" viewBox=\"0 0 14 16\""); t.b("\n" + i); t.b(" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
  4028. defaultTemplates["icon-file-changed"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-changed\" height=\"16\" title=\"modified\" version=\"1.1\""); t.b("\n" + i); t.b(" viewBox=\"0 0 14 16\" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
  4029. defaultTemplates["icon-file-deleted"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-deleted\" height=\"16\" title=\"removed\" version=\"1.1\""); t.b("\n" + i); t.b(" viewBox=\"0 0 14 16\" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM11 9H3V7h8v2z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
  4030. defaultTemplates["icon-file-renamed"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-moved\" height=\"16\" title=\"renamed\" version=\"1.1\""); t.b("\n" + i); t.b(" viewBox=\"0 0 14 16\" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M6 9H3V7h3V4l5 4-5 4V9z m8-7v12c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h12c0.55 0 1 0.45 1 1z m-1 0H1v12h12V2z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
  4031. defaultTemplates["icon-file"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon\" height=\"16\" version=\"1.1\" viewBox=\"0 0 12 16\" width=\"12\">"); t.b("\n" + i); t.b(" <path d=\"M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
  4032. defaultTemplates["line-by-line-file-diff"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div id=\""); t.b(t.v(t.f("fileHtmlId", c, p, 0))); t.b("\" class=\"d2h-file-wrapper\" data-lang=\""); t.b(t.v(t.d("file.language", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-header\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("filePath", c, p, 0))); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <div class=\"d2h-file-diff\">"); t.b("\n" + i); t.b(" <div class=\"d2h-code-wrapper\">"); t.b("\n" + i); t.b(" <table class=\"d2h-diff-table\">"); t.b("\n" + i); t.b(" <tbody class=\"d2h-diff-tbody\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("diffs", c, p, 0))); t.b("\n" + i); t.b(" </tbody>"); t.b("\n" + i); t.b(" </table>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
  4033. defaultTemplates["line-by-line-numbers"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"line-num1\">"); t.b(t.v(t.f("oldNumber", c, p, 0))); t.b("</div>"); t.b("\n" + i); t.b("<div class=\"line-num2\">"); t.b(t.v(t.f("newNumber", c, p, 0))); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
  4034. defaultTemplates["side-by-side-file-diff"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div id=\""); t.b(t.v(t.f("fileHtmlId", c, p, 0))); t.b("\" class=\"d2h-file-wrapper\" data-lang=\""); t.b(t.v(t.d("file.language", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-header\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("filePath", c, p, 0))); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <div class=\"d2h-files-diff\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-side-diff\">"); t.b("\n" + i); t.b(" <div class=\"d2h-code-wrapper\">"); t.b("\n" + i); t.b(" <table class=\"d2h-diff-table\">"); t.b("\n" + i); t.b(" <tbody class=\"d2h-diff-tbody\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.d("diffs.left", c, p, 0))); t.b("\n" + i); t.b(" </tbody>"); t.b("\n" + i); t.b(" </table>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <div class=\"d2h-file-side-diff\">"); t.b("\n" + i); t.b(" <div class=\"d2h-code-wrapper\">"); t.b("\n" + i); t.b(" <table class=\"d2h-diff-table\">"); t.b("\n" + i); t.b(" <tbody class=\"d2h-diff-tbody\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.d("diffs.right", c, p, 0))); t.b("\n" + i); t.b(" </tbody>"); t.b("\n" + i); t.b(" </table>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
  4035. defaultTemplates["tag-file-added"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-tag d2h-added d2h-added-tag\">ADDED</span>"); return t.fl(); }, partials: {}, subs: {} });
  4036. defaultTemplates["tag-file-changed"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-tag d2h-changed d2h-changed-tag\">CHANGED</span>"); return t.fl(); }, partials: {}, subs: {} });
  4037. defaultTemplates["tag-file-deleted"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-tag d2h-deleted d2h-deleted-tag\">DELETED</span>"); return t.fl(); }, partials: {}, subs: {} });
  4038. defaultTemplates["tag-file-renamed"] = new hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-tag d2h-moved d2h-moved-tag\">RENAMED</span>"); return t.fl(); }, partials: {}, subs: {} });
  4039. //# sourceMappingURL=diff2html-templates.js.map
  4040. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/hoganjs-utils.js
  4041. var hoganjs_utils_assign = (undefined && undefined.__assign) || function () {
  4042. hoganjs_utils_assign = Object.assign || function(t) {
  4043. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4044. s = arguments[i];
  4045. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  4046. t[p] = s[p];
  4047. }
  4048. return t;
  4049. };
  4050. return hoganjs_utils_assign.apply(this, arguments);
  4051. };
  4052.  
  4053.  
  4054. var HoganJsUtils = (function () {
  4055. function HoganJsUtils(_a) {
  4056. var _b = _a.compiledTemplates, compiledTemplates = _b === void 0 ? {} : _b, _c = _a.rawTemplates, rawTemplates = _c === void 0 ? {} : _c;
  4057. var compiledRawTemplates = Object.entries(rawTemplates).reduce(function (previousTemplates, _a) {
  4058. var _b;
  4059. var name = _a[0], templateString = _a[1];
  4060. var compiledTemplate = hogan.compile(templateString, { asString: false });
  4061. return hoganjs_utils_assign(hoganjs_utils_assign({}, previousTemplates), (_b = {}, _b[name] = compiledTemplate, _b));
  4062. }, {});
  4063. this.preCompiledTemplates = hoganjs_utils_assign(hoganjs_utils_assign(hoganjs_utils_assign({}, defaultTemplates), compiledTemplates), compiledRawTemplates);
  4064. }
  4065. HoganJsUtils.compile = function (templateString) {
  4066. return hogan.compile(templateString, { asString: false });
  4067. };
  4068. HoganJsUtils.prototype.render = function (namespace, view, params, partials, indent) {
  4069. var templateKey = this.templateKey(namespace, view);
  4070. try {
  4071. var template = this.preCompiledTemplates[templateKey];
  4072. return template.render(params, partials, indent);
  4073. }
  4074. catch (e) {
  4075. throw new Error("Could not find template to render '" + templateKey + "'");
  4076. }
  4077. };
  4078. HoganJsUtils.prototype.template = function (namespace, view) {
  4079. return this.preCompiledTemplates[this.templateKey(namespace, view)];
  4080. };
  4081. HoganJsUtils.prototype.templateKey = function (namespace, view) {
  4082. return namespace + "-" + view;
  4083. };
  4084. return HoganJsUtils;
  4085. }());
  4086. /* harmony default export */ const hoganjs_utils = (HoganJsUtils);
  4087. //# sourceMappingURL=hoganjs-utils.js.map
  4088. ;// CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff2html.js
  4089. var diff2html_assign = (undefined && undefined.__assign) || function () {
  4090. diff2html_assign = Object.assign || function(t) {
  4091. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4092. s = arguments[i];
  4093. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  4094. t[p] = s[p];
  4095. }
  4096. return t;
  4097. };
  4098. return diff2html_assign.apply(this, arguments);
  4099. };
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106. var defaultDiff2HtmlConfig = diff2html_assign(diff2html_assign(diff2html_assign({}, defaultLineByLineRendererConfig), defaultSideBySideRendererConfig), { outputFormat: OutputFormatType.LINE_BY_LINE, drawFileList: true });
  4107. function diff2html_parse(diffInput, configuration) {
  4108. if (configuration === void 0) { configuration = {}; }
  4109. return DiffParser.parse(diffInput, diff2html_assign(diff2html_assign({}, defaultDiff2HtmlConfig), configuration));
  4110. }
  4111. function diff2html_html(diffInput, configuration) {
  4112. if (configuration === void 0) { configuration = {}; }
  4113. var config = diff2html_assign(diff2html_assign({}, defaultDiff2HtmlConfig), configuration);
  4114. var diffJson = typeof diffInput === 'string' ? parse(diffInput, config) : diffInput;
  4115. var hoganUtils = new hoganjs_utils(config);
  4116. var fileList = config.drawFileList ? render(diffJson, hoganUtils) : '';
  4117. var diffOutput = config.outputFormat === 'side-by-side'
  4118. ? new side_by_side_renderer(hoganUtils, config).render(diffJson)
  4119. : new line_by_line_renderer(hoganUtils, config).render(diffJson);
  4120. return fileList + diffOutput;
  4121. }
  4122. //# sourceMappingURL=diff2html.js.map
  4123. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
  4124. var injectStylesIntoStyleTag = __webpack_require__(379);
  4125. var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
  4126. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleDomAPI.js
  4127. var styleDomAPI = __webpack_require__(795);
  4128. var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
  4129. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertBySelector.js
  4130. var insertBySelector = __webpack_require__(569);
  4131. var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
  4132. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
  4133. var setAttributesWithoutAttributes = __webpack_require__(565);
  4134. var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
  4135. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertStyleElement.js
  4136. var insertStyleElement = __webpack_require__(216);
  4137. var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
  4138. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleTagTransform.js
  4139. var styleTagTransform = __webpack_require__(589);
  4140. var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
  4141. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/diff2html/bundles/css/diff2html.min.css
  4142. var diff2html_min = __webpack_require__(650);
  4143. ;// CONCATENATED MODULE: ./node_modules/diff2html/bundles/css/diff2html.min.css
  4144.  
  4145.  
  4146. var options = {};
  4147.  
  4148. options.styleTagTransform = (styleTagTransform_default());
  4149. options.setAttributes = (setAttributesWithoutAttributes_default());
  4150.  
  4151. options.insert = insertBySelector_default().bind(null, "head");
  4152. options.domAPI = (styleDomAPI_default());
  4153. options.insertStyleElement = (insertStyleElement_default());
  4154.  
  4155. var update = injectStylesIntoStyleTag_default()(diff2html_min/* default */.Z, options);
  4156.  
  4157.  
  4158.  
  4159.  
  4160. /* harmony default export */ const css_diff2html_min = (diff2html_min/* default */.Z && diff2html_min/* default.locals */.Z.locals ? diff2html_min/* default.locals */.Z.locals : undefined);
  4161.  
  4162. ;// CONCATENATED MODULE: ./src/main.js
  4163.  
  4164.  
  4165.  
  4166.  
  4167. // モーダル要素作成
  4168. function createDiffModal() {
  4169. const modal = document.createElement('div');
  4170. modal.id = 'diff-result-modal';
  4171. modal.classList.add('modal');
  4172. modal.tabIndex = '-1';
  4173. modal.innerHTML = `
  4174. <div class="modal-dialog" role="document" style="width: 97%;">
  4175. <div class="modal-content">
  4176. <div class="modal-header" style="display: flex;"></div>
  4177. <div class="modal-body"></div>
  4178. <div class="modal-footer">
  4179. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  4180. </div>
  4181. </div>
  4182. </div>`;
  4183. document.body.appendChild(modal);
  4184. }
  4185. createDiffModal();
  4186.  
  4187. // モーダル表示
  4188. function showDiffModal(submissionsCodes) {
  4189. const keys = Object.keys(submissionsCodes).sort();
  4190. const len = keys.map(k => submissionsCodes[k].split('\n').length).sort()[1];
  4191. const diff = createTwoFilesPatch(keys[0], keys[1], submissionsCodes[keys[0]], submissionsCodes[keys[1]], undefined, undefined, { context: len });
  4192. const config = {
  4193. outputFormat: 'side-by-side',
  4194. drawFileList: false,
  4195. };
  4196. const html = diff2html_html(diff, config);
  4197. const dom = new DOMParser().parseFromString(html, 'text/html');
  4198.  
  4199. const modalHeader = document.querySelector('#diff-result-modal .modal-header');
  4200. modalHeader.innerHTML = dom.querySelector('.d2h-file-header').innerHTML;
  4201.  
  4202. const btn = document.createElement('button');
  4203. btn.className = 'close';
  4204. btn.dataset.dismiss = 'modal';
  4205. btn.ariaLabel = 'Close';
  4206. btn.innerHTML = '<span aria-hidden="true">&times;</span>';
  4207. modalHeader.appendChild(btn);
  4208.  
  4209. const modalBody = document.querySelector('#diff-result-modal .modal-body')
  4210. modalBody.innerHTML = dom.querySelector('.d2h-files-diff').innerHTML;
  4211.  
  4212. const syncHorizontalScroll = (elm1,elm2) => {
  4213. elm1.addEventListener('scroll', (e) => elm2.scrollLeft = elm1.scrollLeft);
  4214. };
  4215. const sides = modalBody.querySelectorAll('.d2h-file-side-diff');
  4216. syncHorizontalScroll(sides[0], sides[1]);
  4217. syncHorizontalScroll(sides[1], sides[0]);
  4218. }
  4219.  
  4220. function diffBtnListener(e) {
  4221. const submissionsUrls = [];
  4222. document.querySelectorAll('.diff-checkbox').forEach(cb => {
  4223. if (!cb.checked) return;
  4224. const a = cb.parentNode.parentNode.lastElementChild.firstElementChild;
  4225. submissionsUrls.push(a.href);
  4226. });
  4227.  
  4228. const promises = submissionsUrls.map(url => getSubmissionCode(url));
  4229. Promise.all(promises).then(objs => {
  4230. const obj = {};
  4231. objs.forEach(e => {
  4232. const key = Object.keys(e)[0];
  4233. const m = key.match(/(?<=\/)\d+(?=$)/);
  4234. if (!m) return;
  4235. const submissionId = m.toString();
  4236. obj['#' + submissionId] = e[key];
  4237. });
  4238. showDiffModal(obj);
  4239. });
  4240. }
  4241.  
  4242. // 提出コードの取得
  4243. function getSubmissionHTML(url) {
  4244. return fetch(url)
  4245. .then(response => response.text())
  4246. .then(text => new DOMParser().parseFromString(text, 'text/html'))
  4247. }
  4248.  
  4249. async function getSubmissionCode(url) {
  4250. const dom = await getSubmissionHTML(url);
  4251. const elm = dom.querySelector('#submission-code');
  4252. return { [url]: elm.innerText };
  4253. }
  4254.  
  4255. // チェックボックスの追加
  4256. const checkboxes = [];
  4257. let checkedCnt = 0;
  4258.  
  4259. function checkboxListener(e) {
  4260. checkedCnt += e.target.checked ? 1 : -1;
  4261. const btn = document.getElementById('show-diff-result-btn');
  4262. if (checkedCnt >= 2) {
  4263. btn.disabled = false;
  4264. checkboxes.forEach(cb => {
  4265. cb.disabled = !cb.checked;
  4266. });
  4267. } else {
  4268. btn.disabled = true;
  4269. checkboxes.forEach(cb => {
  4270. cb.disabled = false;
  4271. });
  4272. }
  4273. }
  4274.  
  4275. function checkboxParentListener(e) {
  4276. const elm = e.target.firstElementChild;
  4277. if (elm) elm.click();
  4278. }
  4279.  
  4280. function insertCheckBox() {
  4281. const table = document.querySelector('table');
  4282.  
  4283. const insertCb = (parent, newNode) => {
  4284. parent.insertBefore(newNode, parent.firstElementChild);
  4285. }
  4286.  
  4287. const btn = document.createElement('input');
  4288. btn.type = 'button';
  4289. btn.value = '比較';
  4290. btn.id = 'show-diff-result-btn';
  4291. btn.disabled = true;
  4292. btn.dataset.toggle = 'modal';
  4293. btn.dataset.target = '#diff-result-modal';
  4294. btn.addEventListener('click', diffBtnListener);
  4295. const th = document.createElement('th');
  4296. th.appendChild(btn);
  4297. insertCb(table.querySelector('thead>tr'), th);
  4298.  
  4299. table.querySelectorAll('tbody>tr').forEach(tr => {
  4300. const cb = document.createElement('input');
  4301. cb.type = 'checkbox';
  4302. cb.classList.add('diff-checkbox');
  4303. cb.addEventListener('change', checkboxListener);
  4304. checkboxes.push(cb);
  4305. const td = document.createElement('td');
  4306. td.appendChild(cb);
  4307. td.style.textAlign = 'center';
  4308. td.addEventListener('click', checkboxParentListener); // checkbox の当たりが判定小さいので……。
  4309. insertCb(tr, td);
  4310. });
  4311. }
  4312. insertCheckBox();
  4313.  
  4314. })();
  4315.  
  4316. /******/ })()
  4317. ;