@inpageedit/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -0
  3. package/dist/ActionButton-BhcZX7rl.js +33 -0
  4. package/dist/ActionButton-BhcZX7rl.js.map +1 -0
  5. package/dist/CheckBox-B7zLOm55.js +30 -0
  6. package/dist/CheckBox-B7zLOm55.js.map +1 -0
  7. package/dist/InPageEdit.d.ts +25 -0
  8. package/dist/PluginPreferencesUI-CqQKXQkn.js +33921 -0
  9. package/dist/PluginPreferencesUI-CqQKXQkn.js.map +1 -0
  10. package/dist/Preferences-Bg3J5Ur9.js +9 -0
  11. package/dist/Preferences-Bg3J5Ur9.js.map +1 -0
  12. package/dist/RadioBox-Dl-VRoW0.js +54 -0
  13. package/dist/RadioBox-Dl-VRoW0.js.map +1 -0
  14. package/dist/components/ActionButton.d.ts +9 -0
  15. package/dist/components/CheckBox.d.ts +10 -0
  16. package/dist/components/InputBox.d.ts +11 -0
  17. package/dist/components/MBox/index.d.ts +14 -0
  18. package/dist/components/MwUserLinks.d.ts +4 -0
  19. package/dist/components/ProgressBar/index.d.ts +7 -0
  20. package/dist/components/RadioBox.d.ts +10 -0
  21. package/dist/components/TabView/TabView.d.ts +19 -0
  22. package/dist/components/TwinSwapInput/index.d.ts +18 -0
  23. package/dist/components/utils.d.ts +4 -0
  24. package/dist/constants/endpoints.d.ts +10 -0
  25. package/dist/decorators/Preferences.d.ts +36 -0
  26. package/dist/i18n/languages.json +1527 -0
  27. package/dist/index-BEDkPsz1.js +86 -0
  28. package/dist/index-BEDkPsz1.js.map +1 -0
  29. package/dist/index-Bi1eJIjL.js +83 -0
  30. package/dist/index-Bi1eJIjL.js.map +1 -0
  31. package/dist/index-Bz4cBa1Z.js +1130 -0
  32. package/dist/index-Bz4cBa1Z.js.map +1 -0
  33. package/dist/index-CL0NhE5n.js +155 -0
  34. package/dist/index-CL0NhE5n.js.map +1 -0
  35. package/dist/index-CuEf9G7f.js +5459 -0
  36. package/dist/index-CuEf9G7f.js.map +1 -0
  37. package/dist/index-DA5i7w02.js +141 -0
  38. package/dist/index-DA5i7w02.js.map +1 -0
  39. package/dist/index-Hed2P8uH.js +159 -0
  40. package/dist/index-Hed2P8uH.js.map +1 -0
  41. package/dist/index-LoZLvK3o.js +409 -0
  42. package/dist/index-LoZLvK3o.js.map +1 -0
  43. package/dist/index-sORwn1Vt.js +140 -0
  44. package/dist/index-sORwn1Vt.js.map +1 -0
  45. package/dist/index.d.ts +23 -0
  46. package/dist/index.js +8 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/models/WikiPage/index.d.ts +63 -0
  49. package/dist/models/WikiPage/types/PageInfo.d.ts +56 -0
  50. package/dist/models/WikiPage/types/PageParseData.d.ts +17 -0
  51. package/dist/models/WikiPage/types/WatchlistAction.d.ts +6 -0
  52. package/dist/models/WikiTitle/index.d.ts +12 -0
  53. package/dist/plugins/BasePlugin.d.ts +19 -0
  54. package/dist/plugins/_debug/index.d.ts +8 -0
  55. package/dist/plugins/preferences/PluginPreferencesUI.d.ts +11 -0
  56. package/dist/plugins/preferences/components/hooks.d.ts +5 -0
  57. package/dist/plugins/preferences/index.d.ts +37 -0
  58. package/dist/plugins/quick-diff/JsDiffService.d.ts +23 -0
  59. package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +69 -0
  60. package/dist/plugins/quick-diff/components/DiffTable.d.ts +6 -0
  61. package/dist/plugins/quick-diff/index.d.ts +6 -0
  62. package/dist/plugins/quick-edit/PluginQuickEditInArticleLinks.d.ts +14 -0
  63. package/dist/plugins/quick-edit/index.d.ts +52 -0
  64. package/dist/plugins/quick-move/index.d.ts +27 -0
  65. package/dist/plugins/quick-preview/index.d.ts +32 -0
  66. package/dist/plugins/quick-redirect/index.d.ts +24 -0
  67. package/dist/plugins/toolbox/index.d.ts +38 -0
  68. package/dist/polyfills/Promise.withResolvers.d.ts +5 -0
  69. package/dist/polyfills/index.d.ts +0 -0
  70. package/dist/services/ApiService.d.ts +14 -0
  71. package/dist/services/ResourceLoaderService.d.ts +13 -0
  72. package/dist/services/SiteMetadataService.d.ts +53 -0
  73. package/dist/services/SsiModalService.d.ts +35 -0
  74. package/dist/services/StorageService.d.ts +56 -0
  75. package/dist/services/WikiPageService.d.ts +19 -0
  76. package/dist/sleep-DpyIipK-.js +5 -0
  77. package/dist/sleep-DpyIipK-.js.map +1 -0
  78. package/dist/style.css +1 -0
  79. package/dist/types/SiteMetadata.d.ts +133 -0
  80. package/dist/utils/defineAsyncPlugin.d.ts +2 -0
  81. package/dist/utils/noop.d.ts +1 -0
  82. package/dist/utils/schemaValidator.d.ts +12 -0
  83. package/dist/utils/sleep.d.ts +1 -0
  84. package/dist/utils/string.d.ts +7 -0
  85. package/dist/utils/vueReactivity.d.ts +2 -0
  86. package/package.json +81 -0
@@ -0,0 +1,1130 @@
1
+ import { j as m, F as Ne, B as ee, P as Pe, a as Ee, S as E } from "./index-CuEf9G7f.js";
2
+ import { R as We } from "./Preferences-Bg3J5Ur9.js";
3
+ import { R as _e, M as Oe } from "./RadioBox-Dl-VRoW0.js";
4
+ class D {
5
+ diff(e, n, i = {}) {
6
+ let s;
7
+ typeof i == "function" ? (s = i, i = {}) : "callback" in i && (s = i.callback);
8
+ const r = this.castInput(e, i), l = this.castInput(n, i), o = this.removeEmpty(this.tokenize(r, i)), f = this.removeEmpty(this.tokenize(l, i));
9
+ return this.diffWithOptionsObj(o, f, i, s);
10
+ }
11
+ diffWithOptionsObj(e, n, i, s) {
12
+ var r;
13
+ const l = (u) => {
14
+ if (u = this.postProcess(u, i), s) {
15
+ setTimeout(function() {
16
+ s(u);
17
+ }, 0);
18
+ return;
19
+ } else
20
+ return u;
21
+ }, o = n.length, f = e.length;
22
+ let g = 1, a = o + f;
23
+ i.maxEditLength != null && (a = Math.min(a, i.maxEditLength));
24
+ const h = (r = i.timeout) !== null && r !== void 0 ? r : 1 / 0, y = Date.now() + h, v = [{ oldPos: -1, lastComponent: void 0 }];
25
+ let d = this.extractCommon(v[0], n, e, 0, i);
26
+ if (v[0].oldPos + 1 >= f && d + 1 >= o)
27
+ return l(this.buildValues(v[0].lastComponent, n, e));
28
+ let p = -1 / 0, x = 1 / 0;
29
+ const C = () => {
30
+ for (let u = Math.max(p, -g); u <= Math.min(x, g); u += 2) {
31
+ let c;
32
+ const w = v[u - 1], k = v[u + 1];
33
+ w && (v[u - 1] = void 0);
34
+ let b = !1;
35
+ if (k) {
36
+ const N = k.oldPos - u;
37
+ b = k && 0 <= N && N < o;
38
+ }
39
+ const S = w && w.oldPos + 1 < f;
40
+ if (!b && !S) {
41
+ v[u] = void 0;
42
+ continue;
43
+ }
44
+ if (!S || b && w.oldPos < k.oldPos ? c = this.addToPath(k, !0, !1, 0, i) : c = this.addToPath(w, !1, !0, 1, i), d = this.extractCommon(c, n, e, u, i), c.oldPos + 1 >= f && d + 1 >= o)
45
+ return l(this.buildValues(c.lastComponent, n, e)) || !0;
46
+ v[u] = c, c.oldPos + 1 >= f && (x = Math.min(x, u - 1)), d + 1 >= o && (p = Math.max(p, u + 1));
47
+ }
48
+ g++;
49
+ };
50
+ if (s)
51
+ (function u() {
52
+ setTimeout(function() {
53
+ if (g > a || Date.now() > y)
54
+ return s(void 0);
55
+ C() || u();
56
+ }, 0);
57
+ })();
58
+ else
59
+ for (; g <= a && Date.now() <= y; ) {
60
+ const u = C();
61
+ if (u)
62
+ return u;
63
+ }
64
+ }
65
+ addToPath(e, n, i, s, r) {
66
+ const l = e.lastComponent;
67
+ return l && !r.oneChangePerToken && l.added === n && l.removed === i ? {
68
+ oldPos: e.oldPos + s,
69
+ lastComponent: { count: l.count + 1, added: n, removed: i, previousComponent: l.previousComponent }
70
+ } : {
71
+ oldPos: e.oldPos + s,
72
+ lastComponent: { count: 1, added: n, removed: i, previousComponent: l }
73
+ };
74
+ }
75
+ extractCommon(e, n, i, s, r) {
76
+ const l = n.length, o = i.length;
77
+ let f = e.oldPos, g = f - s, a = 0;
78
+ for (; g + 1 < l && f + 1 < o && this.equals(i[f + 1], n[g + 1], r); )
79
+ g++, f++, a++, r.oneChangePerToken && (e.lastComponent = { count: 1, previousComponent: e.lastComponent, added: !1, removed: !1 });
80
+ return a && !r.oneChangePerToken && (e.lastComponent = { count: a, previousComponent: e.lastComponent, added: !1, removed: !1 }), e.oldPos = f, g;
81
+ }
82
+ equals(e, n, i) {
83
+ return i.comparator ? i.comparator(e, n) : e === n || !!i.ignoreCase && e.toLowerCase() === n.toLowerCase();
84
+ }
85
+ removeEmpty(e) {
86
+ const n = [];
87
+ for (let i = 0; i < e.length; i++)
88
+ e[i] && n.push(e[i]);
89
+ return n;
90
+ }
91
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
92
+ castInput(e, n) {
93
+ return e;
94
+ }
95
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
96
+ tokenize(e, n) {
97
+ return Array.from(e);
98
+ }
99
+ join(e) {
100
+ return e.join("");
101
+ }
102
+ postProcess(e, n) {
103
+ return e;
104
+ }
105
+ get useLongestToken() {
106
+ return !1;
107
+ }
108
+ buildValues(e, n, i) {
109
+ const s = [];
110
+ let r;
111
+ for (; e; )
112
+ s.push(e), r = e.previousComponent, delete e.previousComponent, e = r;
113
+ s.reverse();
114
+ const l = s.length;
115
+ let o = 0, f = 0, g = 0;
116
+ for (; o < l; o++) {
117
+ const a = s[o];
118
+ if (a.removed)
119
+ a.value = this.join(i.slice(g, g + a.count)), g += a.count;
120
+ else {
121
+ if (!a.added && this.useLongestToken) {
122
+ let h = n.slice(f, f + a.count);
123
+ h = h.map(function(y, v) {
124
+ const d = i[g + v];
125
+ return d.length > y.length ? d : y;
126
+ }), a.value = this.join(h);
127
+ } else
128
+ a.value = this.join(n.slice(f, f + a.count));
129
+ f += a.count, a.added || (g += a.count);
130
+ }
131
+ }
132
+ return s;
133
+ }
134
+ }
135
+ class Te extends D {
136
+ }
137
+ const te = new Te();
138
+ function ne(t, e, n) {
139
+ return te.diff(t, e, n);
140
+ }
141
+ function V(t, e) {
142
+ let n;
143
+ for (n = 0; n < t.length && n < e.length; n++)
144
+ if (t[n] != e[n])
145
+ return t.slice(0, n);
146
+ return t.slice(0, n);
147
+ }
148
+ function Y(t, e) {
149
+ let n;
150
+ if (!t || !e || t[t.length - 1] != e[e.length - 1])
151
+ return "";
152
+ for (n = 0; n < t.length && n < e.length; n++)
153
+ if (t[t.length - (n + 1)] != e[e.length - (n + 1)])
154
+ return t.slice(-n);
155
+ return t.slice(-n);
156
+ }
157
+ function I(t, e, n) {
158
+ if (t.slice(0, e.length) != e)
159
+ throw Error(`string ${JSON.stringify(t)} doesn't start with prefix ${JSON.stringify(e)}; this is a bug`);
160
+ return n + t.slice(e.length);
161
+ }
162
+ function H(t, e, n) {
163
+ if (!e)
164
+ return t + n;
165
+ if (t.slice(-e.length) != e)
166
+ throw Error(`string ${JSON.stringify(t)} doesn't end with suffix ${JSON.stringify(e)}; this is a bug`);
167
+ return t.slice(0, -e.length) + n;
168
+ }
169
+ function W(t, e) {
170
+ return I(t, e, "");
171
+ }
172
+ function O(t, e) {
173
+ return H(t, e, "");
174
+ }
175
+ function X(t, e) {
176
+ return e.slice(0, Fe(t, e));
177
+ }
178
+ function Fe(t, e) {
179
+ let n = 0;
180
+ t.length > e.length && (n = t.length - e.length);
181
+ let i = e.length;
182
+ t.length < e.length && (i = t.length);
183
+ const s = Array(i);
184
+ let r = 0;
185
+ s[0] = 0;
186
+ for (let l = 1; l < i; l++) {
187
+ for (e[l] == e[r] ? s[l] = s[r] : s[l] = r; r > 0 && e[l] != e[r]; )
188
+ r = s[r];
189
+ e[l] == e[r] && r++;
190
+ }
191
+ r = 0;
192
+ for (let l = n; l < t.length; l++) {
193
+ for (; r > 0 && t[l] != e[r]; )
194
+ r = s[r];
195
+ t[l] == e[r] && r++;
196
+ }
197
+ return r;
198
+ }
199
+ function Ae(t) {
200
+ return t.includes(`\r
201
+ `) && !t.startsWith(`
202
+ `) && !t.match(/[^\r]\n/);
203
+ }
204
+ function Le(t) {
205
+ return !t.includes(`\r
206
+ `) && t.includes(`
207
+ `);
208
+ }
209
+ function _(t) {
210
+ let e;
211
+ for (e = t.length - 1; e >= 0 && t[e].match(/\s/); e--)
212
+ ;
213
+ return t.substring(e + 1);
214
+ }
215
+ function P(t) {
216
+ const e = t.match(/^\s*/);
217
+ return e ? e[0] : "";
218
+ }
219
+ const T = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}", je = new RegExp(`[${T}]+|\\s+|[^${T}]`, "ug");
220
+ class ze extends D {
221
+ equals(e, n, i) {
222
+ return i.ignoreCase && (e = e.toLowerCase(), n = n.toLowerCase()), e.trim() === n.trim();
223
+ }
224
+ tokenize(e, n = {}) {
225
+ let i;
226
+ if (n.intlSegmenter) {
227
+ const l = n.intlSegmenter;
228
+ if (l.resolvedOptions().granularity != "word")
229
+ throw new Error('The segmenter passed must have a granularity of "word"');
230
+ i = Array.from(l.segment(e), (o) => o.segment);
231
+ } else
232
+ i = e.match(je) || [];
233
+ const s = [];
234
+ let r = null;
235
+ return i.forEach((l) => {
236
+ /\s/.test(l) ? r == null ? s.push(l) : s.push(s.pop() + l) : r != null && /\s/.test(r) ? s[s.length - 1] == r ? s.push(s.pop() + l) : s.push(r + l) : s.push(l), r = l;
237
+ }), s;
238
+ }
239
+ join(e) {
240
+ return e.map((n, i) => i == 0 ? n : n.replace(/^\s+/, "")).join("");
241
+ }
242
+ postProcess(e, n) {
243
+ if (!e || n.oneChangePerToken)
244
+ return e;
245
+ let i = null, s = null, r = null;
246
+ return e.forEach((l) => {
247
+ l.added ? s = l : l.removed ? r = l : ((s || r) && Z(i, r, s, l), i = l, s = null, r = null);
248
+ }), (s || r) && Z(i, r, s, null), e;
249
+ }
250
+ }
251
+ const ie = new ze();
252
+ function re(t, e, n) {
253
+ return n?.ignoreWhitespace != null && !n.ignoreWhitespace ? q(t, e, n) : ie.diff(t, e, n);
254
+ }
255
+ function Z(t, e, n, i) {
256
+ if (e && n) {
257
+ const s = P(e.value), r = _(e.value), l = P(n.value), o = _(n.value);
258
+ if (t) {
259
+ const f = V(s, l);
260
+ t.value = H(t.value, l, f), e.value = W(e.value, f), n.value = W(n.value, f);
261
+ }
262
+ if (i) {
263
+ const f = Y(r, o);
264
+ i.value = I(i.value, o, f), e.value = O(e.value, f), n.value = O(n.value, f);
265
+ }
266
+ } else if (n) {
267
+ if (t) {
268
+ const s = P(n.value);
269
+ n.value = n.value.substring(s.length);
270
+ }
271
+ if (i) {
272
+ const s = P(i.value);
273
+ i.value = i.value.substring(s.length);
274
+ }
275
+ } else if (t && i) {
276
+ const s = P(i.value), r = P(e.value), l = _(e.value), o = V(s, r);
277
+ e.value = W(e.value, o);
278
+ const f = Y(W(s, o), l);
279
+ e.value = O(e.value, f), i.value = I(i.value, s, f), t.value = H(t.value, s, s.slice(0, s.length - f.length));
280
+ } else if (i) {
281
+ const s = P(i.value), r = _(e.value), l = X(r, s);
282
+ e.value = O(e.value, l);
283
+ } else if (t) {
284
+ const s = _(t.value), r = P(e.value), l = X(s, r);
285
+ e.value = W(e.value, l);
286
+ }
287
+ }
288
+ class Ie extends D {
289
+ tokenize(e) {
290
+ const n = new RegExp(`(\\r?\\n)|[${T}]+|[^\\S\\n\\r]+|[^${T}]`, "ug");
291
+ return e.match(n) || [];
292
+ }
293
+ }
294
+ const se = new Ie();
295
+ function q(t, e, n) {
296
+ return se.diff(t, e, n);
297
+ }
298
+ function He(t, e) {
299
+ if (typeof t == "function")
300
+ e.callback = t;
301
+ else if (t)
302
+ for (const n in t)
303
+ Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
304
+ return e;
305
+ }
306
+ class $e extends D {
307
+ constructor() {
308
+ super(...arguments), this.tokenize = oe;
309
+ }
310
+ equals(e, n, i) {
311
+ return i.ignoreWhitespace ? ((!i.newlineIsToken || !e.includes(`
312
+ `)) && (e = e.trim()), (!i.newlineIsToken || !n.includes(`
313
+ `)) && (n = n.trim())) : i.ignoreNewlineAtEof && !i.newlineIsToken && (e.endsWith(`
314
+ `) && (e = e.slice(0, -1)), n.endsWith(`
315
+ `) && (n = n.slice(0, -1))), super.equals(e, n, i);
316
+ }
317
+ }
318
+ const M = new $e();
319
+ function F(t, e, n) {
320
+ return M.diff(t, e, n);
321
+ }
322
+ function le(t, e, n) {
323
+ return n = He(n, { ignoreWhitespace: !0 }), M.diff(t, e, n);
324
+ }
325
+ function oe(t, e) {
326
+ e.stripTrailingCr && (t = t.replace(/\r\n/g, `
327
+ `));
328
+ const n = [], i = t.split(/(\n|\r\n)/);
329
+ i[i.length - 1] || i.pop();
330
+ for (let s = 0; s < i.length; s++) {
331
+ const r = i[s];
332
+ s % 2 && !e.newlineIsToken ? n[n.length - 1] += r : n.push(r);
333
+ }
334
+ return n;
335
+ }
336
+ function qe(t) {
337
+ return t == "." || t == "!" || t == "?";
338
+ }
339
+ class Me extends D {
340
+ tokenize(e) {
341
+ var n;
342
+ const i = [];
343
+ let s = 0;
344
+ for (let r = 0; r < e.length; r++) {
345
+ if (r == e.length - 1) {
346
+ i.push(e.slice(s));
347
+ break;
348
+ }
349
+ if (qe(e[r]) && e[r + 1].match(/\s/)) {
350
+ for (i.push(e.slice(s, r + 1)), r = s = r + 1; !((n = e[r + 1]) === null || n === void 0) && n.match(/\s/); )
351
+ r++;
352
+ i.push(e.slice(s, r + 1)), s = r + 1;
353
+ }
354
+ }
355
+ return i;
356
+ }
357
+ }
358
+ const fe = new Me();
359
+ function ae(t, e, n) {
360
+ return fe.diff(t, e, n);
361
+ }
362
+ class Re extends D {
363
+ tokenize(e) {
364
+ return e.split(/([{}:;,]|\s+)/);
365
+ }
366
+ }
367
+ const ce = new Re();
368
+ function ue(t, e, n) {
369
+ return ce.diff(t, e, n);
370
+ }
371
+ class Je extends D {
372
+ constructor() {
373
+ super(...arguments), this.tokenize = oe;
374
+ }
375
+ get useLongestToken() {
376
+ return !0;
377
+ }
378
+ castInput(e, n) {
379
+ const { undefinedReplacement: i, stringifyReplacer: s = (r, l) => typeof l > "u" ? i : l } = n;
380
+ return typeof e == "string" ? e : JSON.stringify(A(e, null, null, s), null, " ");
381
+ }
382
+ equals(e, n, i) {
383
+ return super.equals(e.replace(/,([\r\n])/g, "$1"), n.replace(/,([\r\n])/g, "$1"), i);
384
+ }
385
+ }
386
+ const de = new Je();
387
+ function me(t, e, n) {
388
+ return de.diff(t, e, n);
389
+ }
390
+ function A(t, e, n, i, s) {
391
+ e = e || [], n = n || [], i && (t = i(s === void 0 ? "" : s, t));
392
+ let r;
393
+ for (r = 0; r < e.length; r += 1)
394
+ if (e[r] === t)
395
+ return n[r];
396
+ let l;
397
+ if (Object.prototype.toString.call(t) === "[object Array]") {
398
+ for (e.push(t), l = new Array(t.length), n.push(l), r = 0; r < t.length; r += 1)
399
+ l[r] = A(t[r], e, n, i, String(r));
400
+ return e.pop(), n.pop(), l;
401
+ }
402
+ if (t && t.toJSON && (t = t.toJSON()), typeof t == "object" && t !== null) {
403
+ e.push(t), l = {}, n.push(l);
404
+ const o = [];
405
+ let f;
406
+ for (f in t)
407
+ Object.prototype.hasOwnProperty.call(t, f) && o.push(f);
408
+ for (o.sort(), r = 0; r < o.length; r += 1)
409
+ f = o[r], l[f] = A(t[f], e, n, i, f);
410
+ e.pop(), n.pop();
411
+ } else
412
+ l = t;
413
+ return l;
414
+ }
415
+ class Be extends D {
416
+ tokenize(e) {
417
+ return e.slice();
418
+ }
419
+ join(e) {
420
+ return e;
421
+ }
422
+ removeEmpty(e) {
423
+ return e;
424
+ }
425
+ }
426
+ const he = new Be();
427
+ function ge(t, e, n) {
428
+ return he.diff(t, e, n);
429
+ }
430
+ function pe(t) {
431
+ return Array.isArray(t) ? t.map((e) => pe(e)) : Object.assign(Object.assign({}, t), { hunks: t.hunks.map((e) => Object.assign(Object.assign({}, e), { lines: e.lines.map((n, i) => {
432
+ var s;
433
+ return n.startsWith("\\") || n.endsWith("\r") || !((s = e.lines[i + 1]) === null || s === void 0) && s.startsWith("\\") ? n : n + "\r";
434
+ }) })) });
435
+ }
436
+ function we(t) {
437
+ return Array.isArray(t) ? t.map((e) => we(e)) : Object.assign(Object.assign({}, t), { hunks: t.hunks.map((e) => Object.assign(Object.assign({}, e), { lines: e.lines.map((n) => n.endsWith("\r") ? n.substring(0, n.length - 1) : n) })) });
438
+ }
439
+ function Ue(t) {
440
+ return Array.isArray(t) || (t = [t]), !t.some((e) => e.hunks.some((n) => n.lines.some((i) => !i.startsWith("\\") && i.endsWith("\r"))));
441
+ }
442
+ function Qe(t) {
443
+ return Array.isArray(t) || (t = [t]), t.some((e) => e.hunks.some((n) => n.lines.some((i) => i.endsWith("\r")))) && t.every((e) => e.hunks.every((n) => n.lines.every((i, s) => {
444
+ var r;
445
+ return i.startsWith("\\") || i.endsWith("\r") || ((r = n.lines[s + 1]) === null || r === void 0 ? void 0 : r.startsWith("\\"));
446
+ })));
447
+ }
448
+ function R(t) {
449
+ const e = t.split(/\n/), n = [];
450
+ let i = 0;
451
+ function s() {
452
+ const o = {};
453
+ for (n.push(o); i < e.length; ) {
454
+ const f = e[i];
455
+ if (/^(---|\+\+\+|@@)\s/.test(f))
456
+ break;
457
+ const g = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(f);
458
+ g && (o.index = g[1]), i++;
459
+ }
460
+ for (r(o), r(o), o.hunks = []; i < e.length; ) {
461
+ const f = e[i];
462
+ if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(f))
463
+ break;
464
+ if (/^@@/.test(f))
465
+ o.hunks.push(l());
466
+ else {
467
+ if (f)
468
+ throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(f));
469
+ i++;
470
+ }
471
+ }
472
+ }
473
+ function r(o) {
474
+ const f = /^(---|\+\+\+)\s+(.*)\r?$/.exec(e[i]);
475
+ if (f) {
476
+ const g = f[2].split(" ", 2), a = (g[1] || "").trim();
477
+ let h = g[0].replace(/\\\\/g, "\\");
478
+ /^".*"$/.test(h) && (h = h.substr(1, h.length - 2)), f[1] === "---" ? (o.oldFileName = h, o.oldHeader = a) : (o.newFileName = h, o.newHeader = a), i++;
479
+ }
480
+ }
481
+ function l() {
482
+ var o;
483
+ const f = i, g = e[i++], a = g.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/), h = {
484
+ oldStart: +a[1],
485
+ oldLines: typeof a[2] > "u" ? 1 : +a[2],
486
+ newStart: +a[3],
487
+ newLines: typeof a[4] > "u" ? 1 : +a[4],
488
+ lines: []
489
+ };
490
+ h.oldLines === 0 && (h.oldStart += 1), h.newLines === 0 && (h.newStart += 1);
491
+ let y = 0, v = 0;
492
+ for (; i < e.length && (v < h.oldLines || y < h.newLines || !((o = e[i]) === null || o === void 0) && o.startsWith("\\")); i++) {
493
+ const d = e[i].length == 0 && i != e.length - 1 ? " " : e[i][0];
494
+ if (d === "+" || d === "-" || d === " " || d === "\\")
495
+ h.lines.push(e[i]), d === "+" ? y++ : d === "-" ? v++ : d === " " && (y++, v++);
496
+ else
497
+ throw new Error(`Hunk at line ${f + 1} contained invalid line ${e[i]}`);
498
+ }
499
+ if (!y && h.newLines === 1 && (h.newLines = 0), !v && h.oldLines === 1 && (h.oldLines = 0), y !== h.newLines)
500
+ throw new Error("Added line count did not match for hunk at line " + (f + 1));
501
+ if (v !== h.oldLines)
502
+ throw new Error("Removed line count did not match for hunk at line " + (f + 1));
503
+ return h;
504
+ }
505
+ for (; i < e.length; )
506
+ s();
507
+ return n;
508
+ }
509
+ function Ve(t, e, n) {
510
+ let i = !0, s = !1, r = !1, l = 1;
511
+ return function o() {
512
+ if (i && !r) {
513
+ if (s ? l++ : i = !1, t + l <= n)
514
+ return t + l;
515
+ r = !0;
516
+ }
517
+ if (!s)
518
+ return r || (i = !0), e <= t - l ? t - l++ : (s = !0, o());
519
+ };
520
+ }
521
+ function ve(t, e, n = {}) {
522
+ let i;
523
+ if (typeof e == "string" ? i = R(e) : Array.isArray(e) ? i = e : i = [e], i.length > 1)
524
+ throw new Error("applyPatch only works with a single input.");
525
+ return Ye(t, i[0], n);
526
+ }
527
+ function Ye(t, e, n = {}) {
528
+ (n.autoConvertLineEndings || n.autoConvertLineEndings == null) && (Ae(t) && Ue(e) ? e = pe(e) : Le(t) && Qe(e) && (e = we(e)));
529
+ const i = t.split(`
530
+ `), s = e.hunks, r = n.compareLine || ((d, p, x, C) => p === C), l = n.fuzzFactor || 0;
531
+ let o = 0;
532
+ if (l < 0 || !Number.isInteger(l))
533
+ throw new Error("fuzzFactor must be a non-negative integer");
534
+ if (!s.length)
535
+ return t;
536
+ let f = "", g = !1, a = !1;
537
+ for (let d = 0; d < s[s.length - 1].lines.length; d++) {
538
+ const p = s[s.length - 1].lines[d];
539
+ p[0] == "\\" && (f[0] == "+" ? g = !0 : f[0] == "-" && (a = !0)), f = p;
540
+ }
541
+ if (g) {
542
+ if (a) {
543
+ if (!l && i[i.length - 1] == "")
544
+ return !1;
545
+ } else if (i[i.length - 1] == "")
546
+ i.pop();
547
+ else if (!l)
548
+ return !1;
549
+ } else if (a) {
550
+ if (i[i.length - 1] != "")
551
+ i.push("");
552
+ else if (!l)
553
+ return !1;
554
+ }
555
+ function h(d, p, x, C = 0, u = !0, c = [], w = 0) {
556
+ let k = 0, b = !1;
557
+ for (; C < d.length; C++) {
558
+ const S = d[C], N = S.length > 0 ? S[0] : " ", z = S.length > 0 ? S.substr(1) : S;
559
+ if (N === "-")
560
+ if (r(p + 1, i[p], N, z))
561
+ p++, k = 0;
562
+ else
563
+ return !x || i[p] == null ? null : (c[w] = i[p], h(d, p + 1, x - 1, C, !1, c, w + 1));
564
+ if (N === "+") {
565
+ if (!u)
566
+ return null;
567
+ c[w] = z, w++, k = 0, b = !0;
568
+ }
569
+ if (N === " ")
570
+ if (k++, c[w] = i[p], r(p + 1, i[p], N, z))
571
+ w++, u = !0, b = !1, p++;
572
+ else
573
+ return b || !x ? null : i[p] && (h(d, p + 1, x - 1, C + 1, !1, c, w + 1) || h(d, p + 1, x - 1, C, !1, c, w + 1)) || h(d, p, x - 1, C + 1, !1, c, w);
574
+ }
575
+ return w -= k, p -= k, c.length = w, {
576
+ patchedLines: c,
577
+ oldLineLastI: p - 1
578
+ };
579
+ }
580
+ const y = [];
581
+ let v = 0;
582
+ for (let d = 0; d < s.length; d++) {
583
+ const p = s[d];
584
+ let x;
585
+ const C = i.length - p.oldLines + l;
586
+ let u;
587
+ for (let c = 0; c <= l; c++) {
588
+ u = p.oldStart + v - 1;
589
+ const w = Ve(u, o, C);
590
+ for (; u !== void 0 && (x = h(p.lines, u, c), !x); u = w())
591
+ ;
592
+ if (x)
593
+ break;
594
+ }
595
+ if (!x)
596
+ return !1;
597
+ for (let c = o; c < u; c++)
598
+ y.push(i[c]);
599
+ for (let c = 0; c < x.patchedLines.length; c++) {
600
+ const w = x.patchedLines[c];
601
+ y.push(w);
602
+ }
603
+ o = x.oldLineLastI + 1, v = u + 1 - p.oldStart;
604
+ }
605
+ for (let d = o; d < i.length; d++)
606
+ y.push(i[d]);
607
+ return y.join(`
608
+ `);
609
+ }
610
+ function Xe(t, e) {
611
+ const n = typeof t == "string" ? R(t) : t;
612
+ let i = 0;
613
+ function s() {
614
+ const r = n[i++];
615
+ if (!r)
616
+ return e.complete();
617
+ e.loadFile(r, function(l, o) {
618
+ if (l)
619
+ return e.complete(l);
620
+ const f = ve(o, r, e);
621
+ e.patched(r, f, function(g) {
622
+ if (g)
623
+ return e.complete(g);
624
+ s();
625
+ });
626
+ });
627
+ }
628
+ s();
629
+ }
630
+ function ye(t) {
631
+ return Array.isArray(t) ? t.map((e) => ye(e)).reverse() : Object.assign(Object.assign({}, t), { oldFileName: t.newFileName, oldHeader: t.newHeader, newFileName: t.oldFileName, newHeader: t.oldHeader, hunks: t.hunks.map((e) => ({
632
+ oldLines: e.newLines,
633
+ oldStart: e.newStart,
634
+ newLines: e.oldLines,
635
+ newStart: e.oldStart,
636
+ lines: e.lines.map((n) => n.startsWith("-") ? `+${n.slice(1)}` : n.startsWith("+") ? `-${n.slice(1)}` : n)
637
+ })) });
638
+ }
639
+ function $(t, e, n, i, s, r, l) {
640
+ let o;
641
+ l ? typeof l == "function" ? o = { callback: l } : o = l : o = {}, typeof o.context > "u" && (o.context = 4);
642
+ const f = o.context;
643
+ if (o.newlineIsToken)
644
+ throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
645
+ if (o.callback) {
646
+ const { callback: a } = o;
647
+ F(n, i, Object.assign(Object.assign({}, o), { callback: (h) => {
648
+ const y = g(h);
649
+ a(y);
650
+ } }));
651
+ } else
652
+ return g(F(n, i, o));
653
+ function g(a) {
654
+ if (!a)
655
+ return;
656
+ a.push({ value: "", lines: [] });
657
+ function h(u) {
658
+ return u.map(function(c) {
659
+ return " " + c;
660
+ });
661
+ }
662
+ const y = [];
663
+ let v = 0, d = 0, p = [], x = 1, C = 1;
664
+ for (let u = 0; u < a.length; u++) {
665
+ const c = a[u], w = c.lines || Ge(c.value);
666
+ if (c.lines = w, c.added || c.removed) {
667
+ if (!v) {
668
+ const k = a[u - 1];
669
+ v = x, d = C, k && (p = f > 0 ? h(k.lines.slice(-f)) : [], v -= p.length, d -= p.length);
670
+ }
671
+ for (const k of w)
672
+ p.push((c.added ? "+" : "-") + k);
673
+ c.added ? C += w.length : x += w.length;
674
+ } else {
675
+ if (v)
676
+ if (w.length <= f * 2 && u < a.length - 2)
677
+ for (const k of h(w))
678
+ p.push(k);
679
+ else {
680
+ const k = Math.min(w.length, f);
681
+ for (const S of h(w.slice(0, k)))
682
+ p.push(S);
683
+ const b = {
684
+ oldStart: v,
685
+ oldLines: x - v + k,
686
+ newStart: d,
687
+ newLines: C - d + k,
688
+ lines: p
689
+ };
690
+ y.push(b), v = 0, d = 0, p = [];
691
+ }
692
+ x += w.length, C += w.length;
693
+ }
694
+ }
695
+ for (const u of y)
696
+ for (let c = 0; c < u.lines.length; c++)
697
+ u.lines[c].endsWith(`
698
+ `) ? u.lines[c] = u.lines[c].slice(0, -1) : (u.lines.splice(c + 1, 0, "\"), c++);
699
+ return {
700
+ oldFileName: t,
701
+ newFileName: e,
702
+ oldHeader: s,
703
+ newHeader: r,
704
+ hunks: y
705
+ };
706
+ }
707
+ }
708
+ function L(t) {
709
+ if (Array.isArray(t))
710
+ return t.map(L).join(`
711
+ `);
712
+ const e = [];
713
+ t.oldFileName == t.newFileName && e.push("Index: " + t.oldFileName), e.push("==================================================================="), e.push("--- " + t.oldFileName + (typeof t.oldHeader > "u" ? "" : " " + t.oldHeader)), e.push("+++ " + t.newFileName + (typeof t.newHeader > "u" ? "" : " " + t.newHeader));
714
+ for (let n = 0; n < t.hunks.length; n++) {
715
+ const i = t.hunks[n];
716
+ i.oldLines === 0 && (i.oldStart -= 1), i.newLines === 0 && (i.newStart -= 1), e.push("@@ -" + i.oldStart + "," + i.oldLines + " +" + i.newStart + "," + i.newLines + " @@");
717
+ for (const s of i.lines)
718
+ e.push(s);
719
+ }
720
+ return e.join(`
721
+ `) + `
722
+ `;
723
+ }
724
+ function J(t, e, n, i, s, r, l) {
725
+ if (typeof l == "function" && (l = { callback: l }), l?.callback) {
726
+ const { callback: o } = l;
727
+ $(t, e, n, i, s, r, Object.assign(Object.assign({}, l), { callback: (f) => {
728
+ o(f ? L(f) : void 0);
729
+ } }));
730
+ } else {
731
+ const o = $(t, e, n, i, s, r, l);
732
+ return o ? L(o) : void 0;
733
+ }
734
+ }
735
+ function Ze(t, e, n, i, s, r) {
736
+ return J(t, t, e, n, i, s, r);
737
+ }
738
+ function Ge(t) {
739
+ const e = t.endsWith(`
740
+ `), n = t.split(`
741
+ `).map((i) => i + `
742
+ `);
743
+ return e ? n.pop() : n.push(n.pop().slice(0, -1)), n;
744
+ }
745
+ function Ke(t) {
746
+ const e = [];
747
+ let n, i;
748
+ for (let s = 0; s < t.length; s++)
749
+ n = t[s], n.added ? i = 1 : n.removed ? i = -1 : i = 0, e.push([i, n.value]);
750
+ return e;
751
+ }
752
+ function et(t) {
753
+ const e = [];
754
+ for (let n = 0; n < t.length; n++) {
755
+ const i = t[n];
756
+ i.added ? e.push("<ins>") : i.removed && e.push("<del>"), e.push(tt(i.value)), i.added ? e.push("</ins>") : i.removed && e.push("</del>");
757
+ }
758
+ return e.join("");
759
+ }
760
+ function tt(t) {
761
+ let e = t;
762
+ return e = e.replace(/&/g, "&amp;"), e = e.replace(/</g, "&lt;"), e = e.replace(/>/g, "&gt;"), e = e.replace(/"/g, "&quot;"), e;
763
+ }
764
+ const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
765
+ __proto__: null,
766
+ Diff: D,
767
+ applyPatch: ve,
768
+ applyPatches: Xe,
769
+ arrayDiff: he,
770
+ canonicalize: A,
771
+ characterDiff: te,
772
+ convertChangesToDMP: Ke,
773
+ convertChangesToXML: et,
774
+ createPatch: Ze,
775
+ createTwoFilesPatch: J,
776
+ cssDiff: ce,
777
+ diffArrays: ge,
778
+ diffChars: ne,
779
+ diffCss: ue,
780
+ diffJson: me,
781
+ diffLines: F,
782
+ diffSentences: ae,
783
+ diffTrimmedLines: le,
784
+ diffWords: re,
785
+ diffWordsWithSpace: q,
786
+ formatPatch: L,
787
+ jsonDiff: de,
788
+ lineDiff: M,
789
+ parsePatch: R,
790
+ reversePatch: ye,
791
+ sentenceDiff: fe,
792
+ structuredPatch: $,
793
+ wordDiff: ie,
794
+ wordsWithSpaceDiff: se
795
+ }, Symbol.toStringTag, { value: "Module" }));
796
+ class it {
797
+ constructor(e) {
798
+ this.ctx = e, this.JsDiff = nt, this.diffChars = ne, this.diffWords = re, this.diffWordsWithSpace = q, this.diffLines = F, this.diffTrimmedLines = le, this.diffSentences = ae, this.diffCss = ue, this.diffJson = me, this.diffArrays = ge, this.createTwoFilesPatch = J, this.ctx.set("jsdiff", this);
799
+ }
800
+ }
801
+ const rt = {
802
+ "diff-container": "_diff-container_lq0si_2"
803
+ }, st = (t) => {
804
+ let { user: e, target: n } = t;
805
+ const i = window.mw?.config?.get("wgArticlePath") || "/$1", s = (r) => i.replace("$1", r);
806
+ return /* @__PURE__ */ m("span", { className: "mw-userlinks", children: [
807
+ /* @__PURE__ */ m("a", { href: s(`User:${e}`), className: "mw-userlink", target: n, children: e }),
808
+ " ",
809
+ /* @__PURE__ */ m("span", { className: "mw-usertoollinks", children: [
810
+ "(",
811
+ /* @__PURE__ */ m("a", { href: s(`User_talk:${e}`), className: "mw-usertoollinks-talk", target: n, children: "talk" }),
812
+ " | ",
813
+ /* @__PURE__ */ m(
814
+ "a",
815
+ {
816
+ href: s(`Special:Contributions/${e}`),
817
+ className: "mw-usertoollinks-contribs",
818
+ target: n,
819
+ children: "contribs"
820
+ }
821
+ ),
822
+ " | ",
823
+ /* @__PURE__ */ m(
824
+ "a",
825
+ {
826
+ href: s(`Special:Block/${e}`),
827
+ className: "mw-usertoollinks-block",
828
+ target: n,
829
+ children: "block"
830
+ }
831
+ ),
832
+ ")"
833
+ ] })
834
+ ] });
835
+ }, lt = new Intl.DateTimeFormat(void 0, {
836
+ dateStyle: "medium",
837
+ timeStyle: "medium"
838
+ }).format, G = (t) => {
839
+ let e = ["diff-title"];
840
+ return t.type === "from" ? e.push("diff-otitle") : t.type === "to" && e.push("diff-ntitle"), !t.pageid || !t.userid ? /* @__PURE__ */ m("td", { colSpan: 2, className: e, children: /* @__PURE__ */ m("div", { className: "mw-diff-title--title", children: t.type === "from" ? "Original content" : t.type === "to" ? "Your content" : "" }) }) : /* @__PURE__ */ m("td", { colSpan: 2, className: e, children: [
841
+ /* @__PURE__ */ m("div", { className: "mw-diff-title--title", children: t.pagetitle || t.timestamp }),
842
+ /* @__PURE__ */ m("div", { className: "mw-diff-title--user", children: t.username && /* @__PURE__ */ m(st, { user: t.username, target: "_blank" }) }),
843
+ /* @__PURE__ */ m("div", { className: "mw-diff-title--timestamp", children: t.timestamp && lt(new Date(t.timestamp)) }),
844
+ /* @__PURE__ */ m("div", { className: "mw-diff-title--comment", children: t.parsedcomment && /* @__PURE__ */ m(Ne, { children: [
845
+ "(",
846
+ /* @__PURE__ */ m("i", { innerHTML: t.parsedcomment }),
847
+ ")"
848
+ ] }) }),
849
+ /* @__PURE__ */ m("div", { className: "mw-diff-title--navigation" })
850
+ ] });
851
+ }, ot = (t) => {
852
+ const { data: e, ...n } = t, i = /* @__PURE__ */ m("table", { className: "theme-ipe diff diff-type-table", "data-mw": "interface", ...n, children: [
853
+ /* @__PURE__ */ m("colgroup", { children: [
854
+ /* @__PURE__ */ m("col", { className: "diff-marker" }),
855
+ /* @__PURE__ */ m("col", { className: "diff-content" }),
856
+ /* @__PURE__ */ m("col", { className: "diff-marker" }),
857
+ /* @__PURE__ */ m("col", { className: "diff-content" })
858
+ ] }),
859
+ /* @__PURE__ */ m("tbody", { children: [
860
+ /* @__PURE__ */ m("tr", { children: [
861
+ /* @__PURE__ */ m(
862
+ G,
863
+ {
864
+ type: "from",
865
+ pageid: e.fromid,
866
+ pagetitle: e.fromtitle,
867
+ revid: e.fromrevid,
868
+ size: e.fromsize,
869
+ timestamp: e.fromtimestamp,
870
+ username: e.fromuser,
871
+ userid: e.fromuserid,
872
+ comment: e.fromcomment,
873
+ parsedcomment: e.fromparsedcomment
874
+ }
875
+ ),
876
+ /* @__PURE__ */ m(
877
+ G,
878
+ {
879
+ type: "to",
880
+ pageid: e.toid,
881
+ pagetitle: e.totitle,
882
+ revid: e.torevid,
883
+ size: e.tosize,
884
+ timestamp: e.totimestamp,
885
+ username: e.touser,
886
+ userid: e.touserid,
887
+ comment: e.tocomment,
888
+ parsedcomment: e.toparsedcomment
889
+ }
890
+ )
891
+ ] }),
892
+ /* @__PURE__ */ m("div", { id: "diffbody" }),
893
+ /* @__PURE__ */ m("tr", { className: "diff-size", style: { textAlign: "center" }, children: [
894
+ /* @__PURE__ */ m("td", { colSpan: 2, className: "diff-size-old", children: e.fromsize !== void 0 && `${e.fromsize} bytes` }),
895
+ /* @__PURE__ */ m("td", { colSpan: 2, className: "diff-size-new", children: e.tosize !== void 0 && `${e.tosize} bytes` })
896
+ ] })
897
+ ] })
898
+ ] });
899
+ return i.querySelector("#diffbody").outerHTML = e.body || (/* @__PURE__ */ m("tr", { children: /* @__PURE__ */ m("td", { colSpan: 4, children: /* @__PURE__ */ m(
900
+ "div",
901
+ {
902
+ style: {
903
+ display: "flex",
904
+ justifyContent: "center",
905
+ alignItems: "center",
906
+ height: "5rem"
907
+ },
908
+ children: /* @__PURE__ */ m("i", { children: "No changes" })
909
+ }
910
+ ) }) })).outerHTML, i;
911
+ }, ft = (t, e = document) => e.querySelector(t), at = (t, e = document) => e.querySelectorAll(t);
912
+ var ct = Object.create, B = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, xe = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), ke = (t) => {
913
+ throw TypeError(t);
914
+ }, dt = (t, e, n) => e in t ? B(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, mt = (t, e) => B(t, "name", { value: e, configurable: !0 }), ht = (t) => [, , , ct(t?.[xe("metadata")] ?? null)], gt = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Ce = (t) => t !== void 0 && typeof t != "function" ? ke("Function expected") : t, pt = (t, e, n, i, s) => ({ kind: gt[t], name: e, metadata: i, addInitializer: (r) => n._ ? ke("Already initialized") : s.push(Ce(r || null)) }), wt = (t, e) => dt(e, xe("metadata"), t[3]), vt = (t, e, n, i) => {
915
+ for (var s = 0, r = t[e >> 1], l = r && r.length; s < l; s++) r[s].call(n);
916
+ return i;
917
+ }, yt = (t, e, n, i, s, r) => {
918
+ var l, o, f, g = e & 7, a = !1, h = 0, y = t[h] || (t[h] = []), v = g && (s = s.prototype, g < 5 && (g > 3 || !a) && ut(s, n));
919
+ mt(s, n);
920
+ for (var d = i.length - 1; d >= 0; d--)
921
+ f = pt(g, n, o = {}, t[3], y), l = (0, i[d])(s, f), o._ = 1, Ce(l) && (s = l);
922
+ return wt(t, s), v && B(s, n, v), a ? g ^ 4 ? r : v : s;
923
+ }, Se, U, be;
924
+ const De = [
925
+ "diffChars",
926
+ "diffWords",
927
+ "diffSentences",
928
+ "diffLines",
929
+ "createTwoFilesPatch"
930
+ ];
931
+ Se = [Ee(["jsdiff"]), We(
932
+ E.object({
933
+ "quickDiff.preferredCompareMode": E.union([E.const("jsDiff"), E.const("mwApi")]).description("The preferred comparison mode for quick diff").default("mwApi"),
934
+ "quickDiff.jsDiff.defaultType": E.union(De.map((t) => E.const(t))).description("The default diff type for JsDiff").default("diffSentences")
935
+ }).description("Quick Diff Preferences"),
936
+ {
937
+ "quickDiff.preferredCompareMode": "mwApi",
938
+ "quickDiff.jsDiff.defaultType": "diffSentences"
939
+ }
940
+ )];
941
+ class j extends (be = ee) {
942
+ constructor(e) {
943
+ super(e, {}, "quick-diff"), this.ctx = e, this.VALID_DIFF_TYPES = De, this.COMPARE_API_DEFAULT_OPTIONS = {
944
+ prop: [
945
+ "comment",
946
+ "diff",
947
+ "diffsize",
948
+ "ids",
949
+ "parsedcomment",
950
+ "size",
951
+ "timestamp",
952
+ "title",
953
+ "user"
954
+ ].join("|"),
955
+ difftype: "table"
956
+ };
957
+ }
958
+ start() {
959
+ this.ctx.set("quickDiff", this), this.ctx.on("quickEdit/wikiPage", this.injectQuickEdit.bind(this)), window.RLQ.push(this.injectHistoryPage.bind(this));
960
+ }
961
+ stop() {
962
+ this.ctx.off("quickEdit/wikiPage", this.injectQuickEdit.bind(this));
963
+ }
964
+ injectHistoryPage() {
965
+ const e = ft("#mw-history-compare");
966
+ if (!e)
967
+ return;
968
+ at(".mw-history-compareselectedversions-button", e).forEach((i) => {
969
+ i.after(
970
+ /* @__PURE__ */ m(
971
+ "button",
972
+ {
973
+ className: "cdx-button",
974
+ onClick: (s) => {
975
+ s.preventDefault();
976
+ const r = new FormData(e), l = Number(r.get("oldid")) || 0, o = Number(r.get("diff")) || 0;
977
+ if (!r.get("title") || !l || !o)
978
+ return this.logger.warn("Missing title or revision IDs");
979
+ this.comparePages({
980
+ fromrev: l,
981
+ torev: o
982
+ });
983
+ },
984
+ children: "Quick Diff"
985
+ }
986
+ )
987
+ );
988
+ });
989
+ }
990
+ injectQuickEdit({ modal: e, wikiPage: n }) {
991
+ e.setButtons([
992
+ {
993
+ label: "Diff",
994
+ side: "left",
995
+ className: "btn btn-secondary",
996
+ method: () => {
997
+ const i = n.title, s = n.revisions?.[0]?.content || "", r = e.get$content().find('textarea[name="text"]').prop("value") || "";
998
+ return this.comparePages({
999
+ fromtitle: i,
1000
+ fromtext: s,
1001
+ totitle: i,
1002
+ totext: r
1003
+ });
1004
+ }
1005
+ }
1006
+ ]);
1007
+ }
1008
+ simpleTextDiff(e, n) {
1009
+ const i = this.ctx.modal.show({
1010
+ title: "Quick Diff",
1011
+ className: "in-page-edit ipe-quickDiff"
1012
+ });
1013
+ i.show();
1014
+ const s = /* @__PURE__ */ m("pre", { className: rt["diff-container"] }), r = /* @__PURE__ */ m(
1015
+ "div",
1016
+ {
1017
+ style: {
1018
+ display: "flex",
1019
+ gap: "1em"
1020
+ },
1021
+ children: this.VALID_DIFF_TYPES.map((l, o) => /* @__PURE__ */ m(
1022
+ _e,
1023
+ {
1024
+ name: "diffType",
1025
+ value: l,
1026
+ label: l,
1027
+ inputProps: {
1028
+ checked: o === 0
1029
+ }
1030
+ }
1031
+ ))
1032
+ }
1033
+ );
1034
+ i.setContent(
1035
+ /* @__PURE__ */ m("section", { children: [
1036
+ r,
1037
+ s
1038
+ ] })
1039
+ ), r.querySelectorAll('input[name="diffType"]').forEach((l) => {
1040
+ l.addEventListener("change", () => {
1041
+ const o = this.renderJsDiff(e, n, l.value);
1042
+ s.textContent = "", s.appendChild(o);
1043
+ });
1044
+ }), r.querySelector('input[name="diffType"]').dispatchEvent(new Event("change"));
1045
+ }
1046
+ /**
1047
+ * TODO: 类型体操
1048
+ */
1049
+ renderJsDiff(e, n, i = "diffSentences") {
1050
+ const s = document.createDocumentFragment();
1051
+ let r;
1052
+ if (i === "createTwoFilesPatch") {
1053
+ let l = !1;
1054
+ r = this.ctx.jsdiff.createTwoFilesPatch("original.txt", "modified.txt", e, n).split(`
1055
+ `).map(function(o) {
1056
+ const f = {
1057
+ value: o + `
1058
+ `
1059
+ };
1060
+ return o.startsWith("@@") ? (f.chunkHeader = !0, l = !0) : l && (o.startsWith("-") ? f.removed = !0 : o.startsWith("+") && (f.added = !0)), f;
1061
+ });
1062
+ } else {
1063
+ const l = this.ctx.jsdiff[i];
1064
+ if (!l)
1065
+ throw new Error(`Missing DiffEngine for ${i}`);
1066
+ r = l(e, n);
1067
+ }
1068
+ if (!Array.isArray(r))
1069
+ throw new Error("Missing diff result");
1070
+ for (let l = 0; l < r.length; l++) {
1071
+ if (r[l].added && r[l + 1] && r[l + 1].removed) {
1072
+ const f = r[l];
1073
+ r[l] = r[l + 1], r[l + 1] = f;
1074
+ }
1075
+ let o;
1076
+ r[l].removed ? (o = document.createElement("del"), o.appendChild(document.createTextNode(r[l].value))) : r[l].added ? (o = document.createElement("ins"), o.appendChild(document.createTextNode(r[l].value))) : r[l].chunkHeader ? (o = document.createElement("span"), o.setAttribute("class", "chunk-header"), o.appendChild(document.createTextNode(r[l].value))) : o = document.createTextNode(r[l].value), s.appendChild(o);
1077
+ }
1078
+ return s;
1079
+ }
1080
+ comparePages(e) {
1081
+ const n = this.ctx.modal.createObject({
1082
+ title: "Loading diff...",
1083
+ content: /* @__PURE__ */ m(Pe, {}),
1084
+ className: "quick-diff"
1085
+ }).init();
1086
+ return window.mw && mw.loader.getState("mediawiki.diff.styles") !== "ready" && mw.loader.load(["mediawiki.diff.styles"]), this.ctx.api.post({
1087
+ ...this.COMPARE_API_DEFAULT_OPTIONS,
1088
+ ...e,
1089
+ action: "compare",
1090
+ format: "json",
1091
+ formatversion: 2
1092
+ }).then((i) => {
1093
+ if (i.data?.error || i.data?.errors) {
1094
+ const r = [i.data?.error, ...i.data?.errors || []].filter(
1095
+ Boolean
1096
+ );
1097
+ throw new Error(r.map((l) => l.info).join(`
1098
+ `), { cause: i });
1099
+ }
1100
+ if (!i.data.compare)
1101
+ throw new Error("No compare data received", { cause: i });
1102
+ const {
1103
+ data: { compare: s }
1104
+ } = i;
1105
+ n.setTitle(
1106
+ s.fromtitle && s.totitle ? `${s.fromtitle} ⇔ ${s.totitle}` : "Differences"
1107
+ ), n.setContent(
1108
+ /* @__PURE__ */ m("section", { children: /* @__PURE__ */ m(ot, { data: s }) })
1109
+ );
1110
+ }).catch((i) => {
1111
+ n.setContent(
1112
+ /* @__PURE__ */ m(Oe, { title: "Failed to load diff", type: "error", children: /* @__PURE__ */ m("pre", { children: i instanceof Error ? i.message : String(i) }) })
1113
+ );
1114
+ }), n.show();
1115
+ }
1116
+ }
1117
+ U = ht(be);
1118
+ j = yt(U, 0, "PluginQuickDiffCore", Se, j);
1119
+ vt(U, 1, j);
1120
+ const Q = class Q extends ee {
1121
+ constructor(e) {
1122
+ super(e, {}, "quick-diff-loader"), this.ctx = e, e.plugin(it), e.plugin(j);
1123
+ }
1124
+ };
1125
+ Q.inject = ["api", "wikiPage", "modal"];
1126
+ let K = Q;
1127
+ export {
1128
+ K as PluginQuickDiff
1129
+ };
1130
+ //# sourceMappingURL=index-Bz4cBa1Z.js.map