@tectra-ng/code-editor 0.0.1 → 0.2.3

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.
@@ -0,0 +1,3080 @@
1
+ import { Annotation, Compartment, EditorSelection, EditorState, Facet, Prec, RangeSet, RangeSetBuilder, StateEffect, StateField, Transaction, countColumn } from "@codemirror/state";
2
+ import { Decoration, EditorView, GutterMarker, ViewPlugin, WidgetType, drawSelection, gutter, highlightActiveLine, highlightActiveLineGutter, keymap, lineNumbers, placeholder } from "@codemirror/view";
3
+ import { NgTemplateOutlet } from "@angular/common";
4
+ import * as i0 from "@angular/core";
5
+ import { ChangeDetectionStrategy, Component, DestroyRef, Injector, ViewEncapsulation, afterNextRender, afterRenderEffect, booleanAttribute, computed, effect, forwardRef, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
6
+ import { injectPassThrough, injectUnstyled } from "@tectra-ng/core/config";
7
+ import { TxLocaleService, injectTranslations } from "@tectra-ng/core/i18n";
8
+ import { TxStyleLoader } from "@tectra-ng/core/styles";
9
+ import { optionalBoolean, optionalNumber } from "@tectra-ng/core/utils";
10
+ import { TxCodeLineStates, TxCodeSyntaxStyles, codeLines, getCodeMode, guideLevels, highlightCode, lineIndent, resolveCodeLanguage, tokenClass } from "@tectra-ng/code-editor/highlight";
11
+ import { toStyleObject } from "@tectra-ng/themes";
12
+ import { NG_VALUE_ACCESSOR } from "@angular/forms";
13
+ import { injectFieldInvalid } from "@tectra-ng/core/forms";
14
+ import { TxButton } from "@tectra-ng/ui/button";
15
+ import { TxInput } from "@tectra-ng/ui/input";
16
+ const CHAR_DIFF_LIMIT = 6e3;
17
+ const CHAR_COST = 400;
18
+ const SHORT_EQUAL = 3;
19
+ function push(ops, type, aFrom, aTo, bFrom, bTo) {
20
+ if (aFrom === aTo && bFrom === bTo) return;
21
+ const last = ops[ops.length - 1];
22
+ if (last && last.type === type && last.aTo === aFrom && last.bTo === bFrom) {
23
+ last.aTo = aTo;
24
+ last.bTo = bTo;
25
+ } else ops.push({
26
+ type,
27
+ aFrom,
28
+ aTo,
29
+ bFrom,
30
+ bTo
31
+ });
32
+ }
33
+ function middle(a, aStart, aEnd, b, bStart, bEnd, equal, maxCost, ops) {
34
+ const n = aEnd - aStart;
35
+ const m = bEnd - bStart;
36
+ if (!n || !m) {
37
+ push(ops, "delete", aStart, aEnd, bStart, bStart);
38
+ push(ops, "insert", aEnd, aEnd, bStart, bEnd);
39
+ return;
40
+ }
41
+ const max = n + m;
42
+ const offset = max + 1;
43
+ const v = new Int32Array(2 * max + 3);
44
+ const trace = [];
45
+ for (let d = 0; d <= max; d++) {
46
+ if (d > maxCost) {
47
+ push(ops, "delete", aStart, aEnd, bStart, bStart);
48
+ push(ops, "insert", aEnd, aEnd, bStart, bEnd);
49
+ return;
50
+ }
51
+ trace.push(v.slice(offset - d - 1, offset + d + 2));
52
+ for (let k = -d; k <= d; k += 2) {
53
+ let x = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1] ? v[offset + k + 1] : v[offset + k - 1] + 1;
54
+ let y = x - k;
55
+ while (x < n && y < m && equal(a[aStart + x], b[bStart + y])) {
56
+ x++;
57
+ y++;
58
+ }
59
+ v[offset + k] = x;
60
+ if (x >= n && y >= m) {
61
+ backtrack(trace, d, n, m, aStart, bStart, ops);
62
+ return;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ function backtrack(trace, depth, n, m, aStart, bStart, ops) {
68
+ const steps = [];
69
+ let x = n;
70
+ let y = m;
71
+ for (let d = depth; d > 0; d--) {
72
+ const row = trace[d];
73
+ const at = (k) => row[k + d + 1];
74
+ const k = x - y;
75
+ const previousK = k === -d || k !== d && at(k - 1) < at(k + 1) ? k + 1 : k - 1;
76
+ const previousX = at(previousK);
77
+ const previousY = previousX - previousK;
78
+ while (x > previousX && y > previousY) {
79
+ steps.push({
80
+ type: "equal",
81
+ aFrom: aStart + x - 1,
82
+ aTo: aStart + x,
83
+ bFrom: bStart + y - 1,
84
+ bTo: bStart + y
85
+ });
86
+ x--;
87
+ y--;
88
+ }
89
+ if (x === previousX) steps.push({
90
+ type: "insert",
91
+ aFrom: aStart + x,
92
+ aTo: aStart + x,
93
+ bFrom: bStart + y - 1,
94
+ bTo: bStart + y
95
+ });
96
+ else steps.push({
97
+ type: "delete",
98
+ aFrom: aStart + x - 1,
99
+ aTo: aStart + x,
100
+ bFrom: bStart + y,
101
+ bTo: bStart + y
102
+ });
103
+ x = previousX;
104
+ y = previousY;
105
+ }
106
+ while (x > 0 && y > 0) {
107
+ steps.push({
108
+ type: "equal",
109
+ aFrom: aStart + x - 1,
110
+ aTo: aStart + x,
111
+ bFrom: bStart + y - 1,
112
+ bTo: bStart + y
113
+ });
114
+ x--;
115
+ y--;
116
+ }
117
+ for (let index = steps.length - 1; index >= 0; index--) {
118
+ const step = steps[index];
119
+ push(ops, step.type, step.aFrom, step.aTo, step.bFrom, step.bTo);
120
+ }
121
+ }
122
+ function diffSequences(a, b, equal = (x, y) => x === y, maxCost = 2e3) {
123
+ const ops = [];
124
+ let start = 0;
125
+ while (start < a.length && start < b.length && equal(a[start], b[start])) start++;
126
+ let endA = a.length;
127
+ let endB = b.length;
128
+ while (endA > start && endB > start && equal(a[endA - 1], b[endB - 1])) {
129
+ endA--;
130
+ endB--;
131
+ }
132
+ push(ops, "equal", 0, start, 0, start);
133
+ middle(a, start, endA, b, start, endB, equal, maxCost, ops);
134
+ push(ops, "equal", endA, a.length, endB, b.length);
135
+ return ops;
136
+ }
137
+ function cleanShortEquals(ops) {
138
+ return ops.map((op, index) => {
139
+ const previous = ops[index - 1];
140
+ const next = ops[index + 1];
141
+ if (op.type === "equal" && previous && next && previous.type !== "equal" && next.type !== "equal" && op.aTo - op.aFrom < SHORT_EQUAL) return {
142
+ ...op,
143
+ type: "delete",
144
+ bTo: op.bFrom,
145
+ merged: true
146
+ };
147
+ return op;
148
+ });
149
+ }
150
+ function charRanges(original, modified) {
151
+ if (original.length + modified.length > CHAR_DIFF_LIMIT) return {
152
+ original: original ? [{
153
+ from: 0,
154
+ to: original.length
155
+ }] : [],
156
+ modified: modified ? [{
157
+ from: 0,
158
+ to: modified.length
159
+ }] : []
160
+ };
161
+ const ops = cleanShortEquals(diffSequences([...original], [...modified], void 0, CHAR_COST));
162
+ const removed = [];
163
+ const added = [];
164
+ const add = (list, from, to) => {
165
+ if (from >= to) return;
166
+ const last = list[list.length - 1];
167
+ if (last && last.to === from) list[list.length - 1] = {
168
+ from: last.from,
169
+ to
170
+ };
171
+ else list.push({
172
+ from,
173
+ to
174
+ });
175
+ };
176
+ for (const op of ops) if (op.type === "delete") {
177
+ add(removed, op.aFrom, op.aTo);
178
+ if ("merged" in op) add(added, op.bFrom, op.bFrom + (op.aTo - op.aFrom));
179
+ } else if (op.type === "insert") add(added, op.bFrom, op.bTo);
180
+ return {
181
+ original: removed,
182
+ modified: added
183
+ };
184
+ }
185
+ function bigrams(text) {
186
+ const counts = /* @__PURE__ */ new Map();
187
+ const trimmed = text.trim();
188
+ for (let index = 0; index < trimmed.length - 1; index++) {
189
+ const pair = trimmed.slice(index, index + 2);
190
+ counts.set(pair, (counts.get(pair) ?? 0) + 1);
191
+ }
192
+ return counts;
193
+ }
194
+ function similar(a, b) {
195
+ if (a.trim() === b.trim()) return true;
196
+ const left = bigrams(a);
197
+ const right = bigrams(b);
198
+ let total = 0;
199
+ let shared = 0;
200
+ left.forEach((count, pair) => {
201
+ total += count;
202
+ shared += Math.min(count, right.get(pair) ?? 0);
203
+ });
204
+ right.forEach((count) => total += count);
205
+ return total > 0 && 2 * shared / total >= .5;
206
+ }
207
+ function offsets(lines) {
208
+ const starts = [];
209
+ let position = 0;
210
+ for (const line of lines) {
211
+ starts.push(position);
212
+ position += line.length + 1;
213
+ }
214
+ return starts;
215
+ }
216
+ function blockRanges(removed, added) {
217
+ const original = [];
218
+ const modified = [];
219
+ if (!removed.length || !added.length) return {
220
+ original,
221
+ modified
222
+ };
223
+ const removedStarts = offsets(removed);
224
+ const addedStarts = offsets(added);
225
+ for (const op of diffSequences(removed, added, similar, 200)) {
226
+ if (op.type !== "equal") continue;
227
+ for (let index = 0; index < op.aTo - op.aFrom; index++) {
228
+ const left = op.aFrom + index;
229
+ const right = op.bFrom + index;
230
+ const ranges = charRanges(removed[left], added[right]);
231
+ original.push(...ranges.original.map((range) => ({
232
+ from: range.from + removedStarts[left],
233
+ to: range.to + removedStarts[left]
234
+ })));
235
+ modified.push(...ranges.modified.map((range) => ({
236
+ from: range.from + addedStarts[right],
237
+ to: range.to + addedStarts[right]
238
+ })));
239
+ }
240
+ }
241
+ return {
242
+ original,
243
+ modified
244
+ };
245
+ }
246
+ function splitDiffLines(text) {
247
+ return text.split(/\r\n?|\n/);
248
+ }
249
+ function diffCode(original, modified, options = {}) {
250
+ const a = splitDiffLines(original);
251
+ const b = splitDiffLines(modified);
252
+ const ops = diffSequences(a, b, options.ignoreTrimWhitespace ?? true ? (x, y) => x === y || x.trim() === y.trim() : void 0, options.maxCost ?? 2e3);
253
+ const changes = [];
254
+ let index = 0;
255
+ while (index < ops.length) {
256
+ if (ops[index].type === "equal") {
257
+ index++;
258
+ continue;
259
+ }
260
+ const first = ops[index];
261
+ let last = first;
262
+ while (index + 1 < ops.length && ops[index + 1].type !== "equal") last = ops[++index];
263
+ index++;
264
+ const originalFrom = first.aFrom;
265
+ const originalTo = last.aTo;
266
+ const modifiedFrom = first.bFrom;
267
+ const modifiedTo = last.bTo;
268
+ const ranges = blockRanges(a.slice(originalFrom, originalTo), b.slice(modifiedFrom, modifiedTo));
269
+ changes.push({
270
+ originalFrom,
271
+ originalTo,
272
+ modifiedFrom,
273
+ modifiedTo,
274
+ originalRanges: ranges.original,
275
+ modifiedRanges: ranges.modified
276
+ });
277
+ }
278
+ return changes;
279
+ }
280
+ function rangesByLine(lines, ranges) {
281
+ const result = lines.map(() => []);
282
+ let lineStart = 0;
283
+ lines.forEach((line, index) => {
284
+ const lineEnd = lineStart + line.length;
285
+ for (const range of ranges) {
286
+ const from = Math.max(range.from, lineStart);
287
+ const to = Math.min(range.to, lineEnd);
288
+ if (from < to) result[index].push({
289
+ from: from - lineStart,
290
+ to: to - lineStart
291
+ });
292
+ }
293
+ lineStart = lineEnd + 1;
294
+ });
295
+ return result;
296
+ }
297
+ function summarizeDiff(changes) {
298
+ return changes.reduce((summary, change) => ({
299
+ added: summary.added + change.modifiedTo - change.modifiedFrom,
300
+ removed: summary.removed + change.originalTo - change.originalFrom,
301
+ changes: summary.changes + 1
302
+ }), {
303
+ added: 0,
304
+ removed: 0,
305
+ changes: 0
306
+ });
307
+ }
308
+ const MATCH_LIMIT = 1e4;
309
+ const MATCH = Decoration.mark({ class: "tx-code-editor__match" });
310
+ const CURRENT = Decoration.mark({ class: "tx-code-editor__match tx-code-editor__match--current" });
311
+ function escapeRegExp(text) {
312
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
313
+ }
314
+ function searchPattern(query) {
315
+ if (!query.text) return null;
316
+ let source = query.regexp ? query.text : escapeRegExp(query.text);
317
+ if (query.wholeWord) source = `(?<![\\w$])(?:${source})(?![\\w$])`;
318
+ try {
319
+ return new RegExp(source, `g${query.matchCase ? "" : "i"}m`);
320
+ } catch {
321
+ return null;
322
+ }
323
+ }
324
+ function findMatches(text, query) {
325
+ if (!query.text) return {
326
+ matches: [],
327
+ valid: true,
328
+ pattern: null
329
+ };
330
+ const pattern = searchPattern(query);
331
+ if (!pattern) return {
332
+ matches: [],
333
+ valid: false,
334
+ pattern: null
335
+ };
336
+ const matches = [];
337
+ let found;
338
+ while ((found = pattern.exec(text)) && matches.length < MATCH_LIMIT) {
339
+ if (found[0].length === 0) {
340
+ pattern.lastIndex++;
341
+ continue;
342
+ }
343
+ matches.push({
344
+ from: found.index,
345
+ to: found.index + found[0].length
346
+ });
347
+ }
348
+ return {
349
+ matches,
350
+ valid: true,
351
+ pattern
352
+ };
353
+ }
354
+ function replacementFor(state, match, query, replacement) {
355
+ if (!query.regexp) return replacement;
356
+ const pattern = searchPattern(query);
357
+ if (!pattern) return replacement;
358
+ return state.doc.sliceString(match.from, match.to).replace(new RegExp(pattern.source, pattern.flags.replace("g", "")), replacement);
359
+ }
360
+ const setSearchMarks = StateEffect.define();
361
+ const searchMarks = StateField.define({
362
+ create: () => Decoration.none,
363
+ update(value, transaction) {
364
+ let marks = value.map(transaction.changes);
365
+ for (const effect of transaction.effects) if (effect.is(setSearchMarks)) {
366
+ const { matches, current } = effect.value;
367
+ marks = Decoration.set(matches.map((match, index) => (index === current ? CURRENT : MATCH).range(match.from, match.to)), true);
368
+ }
369
+ return marks;
370
+ },
371
+ provide: (field) => EditorView.decorations.from(field)
372
+ });
373
+ const codeLanguage = Facet.define({ combine: (values) => values[0] ?? "plain" });
374
+ const OPENERS = {
375
+ "(": ")",
376
+ "[": "]",
377
+ "{": "}",
378
+ "\"": "\"",
379
+ "'": "'",
380
+ "`": "`"
381
+ };
382
+ const CLOSERS = /* @__PURE__ */ new Set([
383
+ ")",
384
+ "]",
385
+ "}",
386
+ "\"",
387
+ "'",
388
+ "`"
389
+ ]);
390
+ const QUOTES = /* @__PURE__ */ new Set([
391
+ "\"",
392
+ "'",
393
+ "`"
394
+ ]);
395
+ const VOID_TAGS = /* @__PURE__ */ new Set([
396
+ "area",
397
+ "base",
398
+ "br",
399
+ "col",
400
+ "embed",
401
+ "hr",
402
+ "img",
403
+ "input",
404
+ "link",
405
+ "meta",
406
+ "source",
407
+ "track",
408
+ "wbr"
409
+ ]);
410
+ const OPEN_TAG_BEFORE = /<([A-Za-z][\w:.-]*)(?:\s(?:[^<>"']|"[^"]*"|'[^']*')*)?$/;
411
+ const OPEN_TAG_END = /<([A-Za-z][\w:.-]*)(?:\s(?:[^<>"']|"[^"]*"|'[^']*')*)?>$/;
412
+ function indentUnit(state) {
413
+ return " ".repeat(state.tabSize);
414
+ }
415
+ function leadingSpace(text) {
416
+ return /^\s*/.exec(text)?.[0] ?? "";
417
+ }
418
+ function touchedLines(state, range) {
419
+ const lines = [];
420
+ const first = state.doc.lineAt(range.from);
421
+ let last = state.doc.lineAt(range.to);
422
+ if (!range.empty && range.to === last.from && last.number > first.number) last = state.doc.line(last.number - 1);
423
+ for (let number = first.number; number <= last.number; number++) lines.push(state.doc.line(number));
424
+ return lines;
425
+ }
426
+ function uniqueLines(state) {
427
+ const seen = /* @__PURE__ */ new Set();
428
+ const lines = [];
429
+ for (const range of state.selection.ranges) for (const line of touchedLines(state, range)) if (!seen.has(line.number)) {
430
+ seen.add(line.number);
431
+ lines.push(line);
432
+ }
433
+ return lines;
434
+ }
435
+ function guard(command) {
436
+ return (target) => !target.state.readOnly && command(target);
437
+ }
438
+ const indentMore = guard(({ state, dispatch }) => {
439
+ const unit = indentUnit(state);
440
+ const changes = uniqueLines(state).filter((line) => line.length > 0 || state.selection.ranges.length === 1).map((line) => ({
441
+ from: line.from,
442
+ insert: unit
443
+ }));
444
+ dispatch(state.update({
445
+ changes,
446
+ userEvent: "input.indent"
447
+ }));
448
+ return true;
449
+ });
450
+ const indentLess = guard(({ state, dispatch }) => {
451
+ const changes = [];
452
+ for (const line of uniqueLines(state)) {
453
+ const space = leadingSpace(line.text);
454
+ if (!space) continue;
455
+ const remove = space.startsWith(" ") ? 1 : Math.min(space.length, (countColumn(space, state.tabSize) - 1) % state.tabSize + 1);
456
+ changes.push({
457
+ from: line.from,
458
+ to: line.from + remove
459
+ });
460
+ }
461
+ if (changes.length) dispatch(state.update({
462
+ changes,
463
+ userEvent: "delete.dedent"
464
+ }));
465
+ return true;
466
+ });
467
+ const insertTab = guard((target) => {
468
+ const { state, dispatch } = target;
469
+ if (state.selection.ranges.some((range) => !range.empty)) return indentMore(target);
470
+ dispatch(state.update(state.changeByRange((range) => {
471
+ const line = state.doc.lineAt(range.from);
472
+ const column = countColumn(line.text.slice(0, range.from - line.from), state.tabSize);
473
+ const insert = " ".repeat(state.tabSize - column % state.tabSize);
474
+ return {
475
+ changes: {
476
+ from: range.from,
477
+ insert
478
+ },
479
+ range: EditorSelection.cursor(range.from + insert.length)
480
+ };
481
+ }), {
482
+ userEvent: "input.type",
483
+ scrollIntoView: true
484
+ }));
485
+ return true;
486
+ });
487
+ function opensBlock(state, before) {
488
+ const char = before.trimEnd().slice(-1);
489
+ if (char === "{" || char === "[" || char === "(") return true;
490
+ const language = state.facet(codeLanguage);
491
+ if (language === "html" || language === "markdown") {
492
+ const tag = OPEN_TAG_END.exec(before.trimEnd());
493
+ return !!tag && !VOID_TAGS.has(tag[1].toLowerCase()) && !before.trimEnd().endsWith("/>");
494
+ }
495
+ return false;
496
+ }
497
+ function closesBlock(after) {
498
+ const text = after.trimStart();
499
+ return /^[)\]}]/.test(text) || text.startsWith("</");
500
+ }
501
+ const insertNewline = guard(({ state, dispatch }) => {
502
+ const unit = indentUnit(state);
503
+ dispatch(state.update(state.changeByRange((range) => {
504
+ const line = state.doc.lineAt(range.from);
505
+ const before = line.text.slice(0, range.from - line.from);
506
+ const after = state.doc.sliceString(range.to, state.doc.lineAt(range.to).to);
507
+ const indent = leadingSpace(before);
508
+ const trimmedTo = after.length - after.trimStart().length;
509
+ if (opensBlock(state, before)) {
510
+ const inner = `\n${indent}${unit}`;
511
+ if (closesBlock(after)) return {
512
+ changes: {
513
+ from: range.from,
514
+ to: range.to + trimmedTo,
515
+ insert: `${inner}\n${indent}`
516
+ },
517
+ range: EditorSelection.cursor(range.from + inner.length)
518
+ };
519
+ return {
520
+ changes: {
521
+ from: range.from,
522
+ to: range.to,
523
+ insert: inner
524
+ },
525
+ range: EditorSelection.cursor(range.from + inner.length)
526
+ };
527
+ }
528
+ const insert = `\n${indent}`;
529
+ return {
530
+ changes: {
531
+ from: range.from,
532
+ to: range.to,
533
+ insert
534
+ },
535
+ range: EditorSelection.cursor(range.from + insert.length)
536
+ };
537
+ }), {
538
+ userEvent: "input",
539
+ scrollIntoView: true
540
+ }));
541
+ return true;
542
+ });
543
+ const smartBackspace = guard(({ state, dispatch }) => {
544
+ if (state.selection.ranges.some((range) => !range.empty)) return false;
545
+ let handled = false;
546
+ const transaction = state.changeByRange((range) => {
547
+ const line = state.doc.lineAt(range.from);
548
+ const before = line.text.slice(0, range.from - line.from);
549
+ const previous = before.slice(-1);
550
+ const next = state.doc.sliceString(range.from, range.from + 1);
551
+ if (previous && OPENERS[previous] === next) {
552
+ handled = true;
553
+ return {
554
+ changes: {
555
+ from: range.from - 1,
556
+ to: range.from + 1
557
+ },
558
+ range: EditorSelection.cursor(range.from - 1)
559
+ };
560
+ }
561
+ if (before.length > 0 && /^ +$/.test(before)) {
562
+ handled = true;
563
+ const remove = (before.length - 1) % state.tabSize + 1;
564
+ return {
565
+ changes: {
566
+ from: range.from - remove,
567
+ to: range.from
568
+ },
569
+ range: EditorSelection.cursor(range.from - remove)
570
+ };
571
+ }
572
+ return { range };
573
+ });
574
+ if (!handled) return false;
575
+ dispatch(state.update(transaction, {
576
+ userEvent: "delete.backward",
577
+ scrollIntoView: true
578
+ }));
579
+ return true;
580
+ });
581
+ const toggleComment = guard(({ state, dispatch }) => {
582
+ const comments = getCodeMode(state.facet(codeLanguage)).comments;
583
+ if (comments.line) {
584
+ const token = comments.line;
585
+ const lines = uniqueLines(state).filter((line) => line.text.trim());
586
+ if (!lines.length) return false;
587
+ const commented = lines.every((line) => line.text.trimStart().startsWith(token));
588
+ const column = Math.min(...lines.map((line) => leadingSpace(line.text).length));
589
+ const changes = lines.map((line) => {
590
+ if (commented) {
591
+ const at = line.from + leadingSpace(line.text).length;
592
+ const space = line.text.charAt(at - line.from + token.length) === " " ? 1 : 0;
593
+ return {
594
+ from: at,
595
+ to: at + token.length + space
596
+ };
597
+ }
598
+ return {
599
+ from: line.from + column,
600
+ insert: `${token} `
601
+ };
602
+ });
603
+ dispatch(state.update({
604
+ changes,
605
+ userEvent: commented ? "delete.uncomment" : "input.comment"
606
+ }));
607
+ return true;
608
+ }
609
+ if (!comments.block) return false;
610
+ const [open, close] = comments.block;
611
+ const changes = [];
612
+ for (const range of state.selection.ranges) {
613
+ const lines = touchedLines(state, range);
614
+ const first = lines[0];
615
+ const last = lines[lines.length - 1];
616
+ const from = first.from + leadingSpace(first.text).length;
617
+ const to = last.from + last.text.trimEnd().length;
618
+ const text = state.doc.sliceString(from, to);
619
+ if (text.startsWith(open) && text.endsWith(close) && text.length >= open.length + close.length) {
620
+ const openSpace = text.charAt(open.length) === " " ? 1 : 0;
621
+ const closeSpace = text.charAt(text.length - close.length - 1) === " " ? 1 : 0;
622
+ changes.push({
623
+ from,
624
+ to: from + open.length + openSpace
625
+ }, {
626
+ from: to - close.length - closeSpace,
627
+ to
628
+ });
629
+ } else changes.push({
630
+ from,
631
+ insert: `${open} `
632
+ }, {
633
+ from: to,
634
+ insert: ` ${close}`
635
+ });
636
+ }
637
+ dispatch(state.update({
638
+ changes,
639
+ userEvent: "input.comment"
640
+ }));
641
+ return true;
642
+ });
643
+ function moveLines(direction) {
644
+ return guard(({ state, dispatch }) => {
645
+ const lines = uniqueLines(state).sort((a, b) => a.number - b.number);
646
+ const first = lines[0];
647
+ const last = lines[lines.length - 1];
648
+ if (direction < 0 && first.number === 1 || direction > 0 && last.number === state.doc.lines) return true;
649
+ const block = state.doc.sliceString(first.from, last.to);
650
+ if (direction < 0) {
651
+ const above = state.doc.line(first.number - 1);
652
+ dispatch(state.update({
653
+ changes: {
654
+ from: above.from,
655
+ to: last.to,
656
+ insert: `${block}\n${above.text}`
657
+ },
658
+ selection: EditorSelection.create(shifted(state, -(above.length + 1)), state.selection.mainIndex),
659
+ userEvent: "move.line",
660
+ scrollIntoView: true
661
+ }));
662
+ } else {
663
+ const below = state.doc.line(last.number + 1);
664
+ dispatch(state.update({
665
+ changes: {
666
+ from: first.from,
667
+ to: below.to,
668
+ insert: `${below.text}\n${block}`
669
+ },
670
+ selection: EditorSelection.create(shifted(state, below.length + 1), state.selection.mainIndex),
671
+ userEvent: "move.line",
672
+ scrollIntoView: true
673
+ }));
674
+ }
675
+ return true;
676
+ });
677
+ }
678
+ function shifted(state, offset) {
679
+ return state.selection.ranges.map((range) => EditorSelection.range(range.anchor + offset, range.head + offset));
680
+ }
681
+ const moveLineUp = moveLines(-1);
682
+ const moveLineDown = moveLines(1);
683
+ function copyLines(direction) {
684
+ return guard(({ state, dispatch }) => {
685
+ const lines = uniqueLines(state).sort((a, b) => a.number - b.number);
686
+ const first = lines[0];
687
+ const last = lines[lines.length - 1];
688
+ const block = state.doc.sliceString(first.from, last.to);
689
+ const offset = direction > 0 ? block.length + 1 : 0;
690
+ dispatch(state.update({
691
+ changes: {
692
+ from: last.to,
693
+ insert: `\n${block}`
694
+ },
695
+ selection: EditorSelection.create(state.selection.ranges.map((range) => EditorSelection.range(range.anchor + offset, range.head + offset))),
696
+ userEvent: "input.copyline",
697
+ scrollIntoView: true
698
+ }));
699
+ return true;
700
+ });
701
+ }
702
+ const copyLineUp = copyLines(-1);
703
+ const copyLineDown = copyLines(1);
704
+ const deleteLine = guard(({ state, dispatch }) => {
705
+ const changes = uniqueLines(state).sort((a, b) => a.number - b.number).map((line) => {
706
+ if (line.number < state.doc.lines) return {
707
+ from: line.from,
708
+ to: line.to + 1
709
+ };
710
+ return {
711
+ from: Math.max(0, line.from - 1),
712
+ to: line.to
713
+ };
714
+ });
715
+ dispatch(state.update({
716
+ changes,
717
+ userEvent: "delete.line",
718
+ scrollIntoView: true
719
+ }));
720
+ return true;
721
+ });
722
+ const selectAll = ({ state, dispatch }) => {
723
+ dispatch(state.update({
724
+ selection: EditorSelection.single(0, state.doc.length),
725
+ userEvent: "select"
726
+ }));
727
+ return true;
728
+ };
729
+ function closeTagAt(state, from) {
730
+ const language = state.facet(codeLanguage);
731
+ if (language !== "html" && language !== "markdown") return null;
732
+ const line = state.doc.lineAt(from);
733
+ const before = line.text.slice(0, from - line.from);
734
+ const tag = OPEN_TAG_BEFORE.exec(before);
735
+ if (!tag || before.endsWith("/") || VOID_TAGS.has(tag[1].toLowerCase())) return null;
736
+ return `</${tag[1]}>`;
737
+ }
738
+ const autoClose = EditorView.inputHandler.of((view, from, to, text) => {
739
+ const state = view.state;
740
+ if (state.readOnly || view.composing || text.length !== 1 || state.selection.ranges.length > 1) return false;
741
+ const next = state.doc.sliceString(to, to + 1);
742
+ const previous = state.doc.sliceString(from - 1, from);
743
+ if (from !== to && OPENERS[text]) {
744
+ const inner = state.doc.sliceString(from, to);
745
+ view.dispatch({
746
+ changes: {
747
+ from,
748
+ to,
749
+ insert: `${text}${inner}${OPENERS[text]}`
750
+ },
751
+ selection: EditorSelection.range(from + 1, from + 1 + inner.length),
752
+ userEvent: "input.type"
753
+ });
754
+ return true;
755
+ }
756
+ if (from === to && CLOSERS.has(text) && next === text) {
757
+ view.dispatch({
758
+ selection: EditorSelection.cursor(to + 1),
759
+ userEvent: "input.type"
760
+ });
761
+ return true;
762
+ }
763
+ if (from === to && text === ">") {
764
+ const close = closeTagAt(state, from);
765
+ if (close) {
766
+ view.dispatch({
767
+ changes: {
768
+ from,
769
+ insert: `>${close}`
770
+ },
771
+ selection: EditorSelection.cursor(from + 1),
772
+ userEvent: "input.type"
773
+ });
774
+ return true;
775
+ }
776
+ }
777
+ if (from === to && OPENERS[text] && (next === "" || /[\s)\]};,:>]/.test(next))) {
778
+ if (QUOTES.has(text) && (/[\w\\]/.test(previous) || previous === text)) return false;
779
+ view.dispatch({
780
+ changes: {
781
+ from,
782
+ insert: `${text}${OPENERS[text]}`
783
+ },
784
+ selection: EditorSelection.cursor(from + 1),
785
+ userEvent: "input.type"
786
+ });
787
+ return true;
788
+ }
789
+ return false;
790
+ });
791
+ function detectTabSize(text, fallback = 4) {
792
+ const counts = /* @__PURE__ */ new Map();
793
+ let previous = 0;
794
+ let checked = 0;
795
+ for (const line of text.split("\n")) {
796
+ if (!line.trim()) continue;
797
+ if (line.startsWith(" ")) return fallback;
798
+ const indent = leadingSpace(line).length;
799
+ const step = Math.abs(indent - previous);
800
+ if (step >= 2 && step <= 8) counts.set(step, (counts.get(step) ?? 0) + 1);
801
+ previous = indent;
802
+ if (++checked > 2e3) break;
803
+ }
804
+ let best = fallback;
805
+ let bestCount = 0;
806
+ for (const [step, count] of counts) if (count > bestCount) {
807
+ best = step;
808
+ bestCount = count;
809
+ }
810
+ return best;
811
+ }
812
+ const TX_DIFF_INSERTED_TEXT = "tx-code-diff__text--inserted";
813
+ const TX_DIFF_REMOVED_TEXT = "tx-code-diff__text--removed";
814
+ function diffDocument(text, language) {
815
+ const lines = splitDiffLines(text);
816
+ const tabSize = detectTabSize(text);
817
+ return {
818
+ lines,
819
+ tokens: highlightCode(text, language),
820
+ guides: guideLevels(lines.length, (index) => lines[index], tabSize),
821
+ tabSize
822
+ };
823
+ }
824
+ function markedSegments(text, tokens, marks, markClass) {
825
+ const cuts = /* @__PURE__ */ new Set([0, text.length]);
826
+ tokens.forEach((token) => cuts.add(token.from).add(token.to));
827
+ marks.forEach((mark) => cuts.add(mark.from).add(mark.to));
828
+ const points = [...cuts].filter((point) => point >= 0 && point <= text.length).sort((a, b) => a - b);
829
+ const segments = [];
830
+ for (let index = 0; index < points.length - 1; index++) {
831
+ const from = points[index];
832
+ const to = points[index + 1];
833
+ const token = tokens.find((item) => item.from <= from && item.to >= to);
834
+ const marked = marks.some((mark) => mark.from <= from && mark.to >= to);
835
+ const classes = [token ? tokenClass(token.type) : "", marked ? markClass : ""].filter(Boolean).join(" ");
836
+ segments.push({
837
+ text: text.slice(from, to),
838
+ className: classes || null
839
+ });
840
+ }
841
+ return segments;
842
+ }
843
+ function blockRows(document, from, to, ranges, kind, numbered) {
844
+ const lines = document.lines.slice(from, to);
845
+ const marks = rangesByLine(lines, ranges);
846
+ const markClass = kind === "inserted" ? TX_DIFF_INSERTED_TEXT : TX_DIFF_REMOVED_TEXT;
847
+ return lines.map((line, index) => ({
848
+ kind,
849
+ number: numbered ? from + index + 1 : null,
850
+ segments: markedSegments(line, document.tokens[from + index] ?? [], marks[index], markClass),
851
+ indent: lineIndent(line),
852
+ guides: document.guides[from + index] ?? 0
853
+ }));
854
+ }
855
+ function equalRow(document, index) {
856
+ return {
857
+ kind: "equal",
858
+ number: index + 1,
859
+ segments: markedSegments(document.lines[index], document.tokens[index] ?? [], [], ""),
860
+ indent: lineIndent(document.lines[index]),
861
+ guides: document.guides[index] ?? 0
862
+ };
863
+ }
864
+ function filler(count) {
865
+ return Array.from({ length: count }, () => ({
866
+ kind: "filler",
867
+ number: null,
868
+ segments: [],
869
+ indent: null,
870
+ guides: 0
871
+ }));
872
+ }
873
+ function inlineRows(original, modified, changes) {
874
+ const rows = [];
875
+ let line = 0;
876
+ for (const change of changes) {
877
+ while (line < change.modifiedFrom) rows.push(equalRow(modified, line++));
878
+ rows.push(...blockRows(original, change.originalFrom, change.originalTo, change.originalRanges, "removed", false));
879
+ rows.push(...blockRows(modified, change.modifiedFrom, change.modifiedTo, change.modifiedRanges, "inserted", true));
880
+ line = change.modifiedTo;
881
+ }
882
+ while (line < modified.lines.length) rows.push(equalRow(modified, line++));
883
+ return rows;
884
+ }
885
+ function splitRows(original, modified, changes) {
886
+ const left = [];
887
+ const right = [];
888
+ let a = 0;
889
+ let b = 0;
890
+ for (const change of changes) {
891
+ while (a < change.originalFrom && b < change.modifiedFrom) {
892
+ left.push(equalRow(original, a++));
893
+ right.push(equalRow(modified, b++));
894
+ }
895
+ const removed = blockRows(original, change.originalFrom, change.originalTo, change.originalRanges, "removed", true);
896
+ const inserted = blockRows(modified, change.modifiedFrom, change.modifiedTo, change.modifiedRanges, "inserted", true);
897
+ left.push(...removed, ...filler(Math.max(0, inserted.length - removed.length)));
898
+ right.push(...inserted, ...filler(Math.max(0, removed.length - inserted.length)));
899
+ a = change.originalTo;
900
+ b = change.modifiedTo;
901
+ }
902
+ while (a < original.lines.length || b < modified.lines.length) {
903
+ left.push(a < original.lines.length ? equalRow(original, a++) : filler(1)[0]);
904
+ right.push(b < modified.lines.length ? equalRow(modified, b++) : filler(1)[0]);
905
+ }
906
+ return {
907
+ original: left,
908
+ modified: right
909
+ };
910
+ }
911
+ const setDiffDecorations = StateEffect.define();
912
+ function appendSegments(parent, segments) {
913
+ const document = parent.ownerDocument;
914
+ for (const segment of segments) {
915
+ const span = document.createElement("span");
916
+ if (segment.className) span.className = segment.className;
917
+ span.textContent = segment.text;
918
+ parent.appendChild(span);
919
+ }
920
+ if (!segments.length) parent.appendChild(document.createElement("br"));
921
+ }
922
+ var RemovedLinesWidget = class extends WidgetType {
923
+ rows;
924
+ key;
925
+ guides;
926
+ tabSize;
927
+ constructor(rows, key, guides, tabSize) {
928
+ super();
929
+ this.rows = rows;
930
+ this.key = key;
931
+ this.guides = guides;
932
+ this.tabSize = tabSize;
933
+ }
934
+ eq(other) {
935
+ return other.key === this.key && other.guides === this.guides && other.tabSize === this.tabSize;
936
+ }
937
+ get lines() {
938
+ return this.rows.length;
939
+ }
940
+ toDOM(view) {
941
+ const document = view.dom.ownerDocument;
942
+ const block = document.createElement("div");
943
+ block.className = "tx-code-diff__removed";
944
+ block.setAttribute("aria-hidden", "true");
945
+ for (const row of this.rows) {
946
+ const line = document.createElement("div");
947
+ line.className = "tx-code-diff__row tx-code-diff__line--removed";
948
+ if (row.indent) line.style.setProperty("--tx-code-wrap-indent", row.indent);
949
+ if (this.guides && row.guides > 0) {
950
+ line.classList.add("tx-code-guides");
951
+ line.style.setProperty("--tx-code-guides", String(row.guides));
952
+ line.style.setProperty("--tx-code-guide-step", `${this.tabSize}ch`);
953
+ }
954
+ appendSegments(line, row.segments);
955
+ block.appendChild(line);
956
+ }
957
+ return block;
958
+ }
959
+ get estimatedHeight() {
960
+ return -1;
961
+ }
962
+ ignoreEvent() {
963
+ return false;
964
+ }
965
+ };
966
+ var FillerWidget = class extends WidgetType {
967
+ lines;
968
+ constructor(lines) {
969
+ super();
970
+ this.lines = lines;
971
+ }
972
+ eq(other) {
973
+ return other.lines === this.lines;
974
+ }
975
+ toDOM(view) {
976
+ const filler = view.dom.ownerDocument.createElement("div");
977
+ filler.className = "tx-code-diff__filler";
978
+ filler.setAttribute("aria-hidden", "true");
979
+ filler.style.setProperty("--tx-code-diff-filler-lines", String(this.lines));
980
+ return filler;
981
+ }
982
+ };
983
+ var SignMarker = class extends GutterMarker {
984
+ sign;
985
+ rows;
986
+ constructor(sign, rows = 1) {
987
+ super();
988
+ this.sign = sign;
989
+ this.rows = rows;
990
+ }
991
+ eq(other) {
992
+ return other.sign === this.sign && other.rows === this.rows;
993
+ }
994
+ toDOM(view) {
995
+ const document = view.dom.ownerDocument;
996
+ const marker = document.createElement("div");
997
+ marker.className = `tx-code-diff__sign tx-code-diff__sign--${this.sign === "+" ? "inserted" : "removed"}`;
998
+ for (let index = 0; index < this.rows; index++) {
999
+ const row = document.createElement("div");
1000
+ row.textContent = this.sign;
1001
+ marker.appendChild(row);
1002
+ }
1003
+ return marker;
1004
+ }
1005
+ };
1006
+ const INSERTED_LINE = Decoration.line({ class: "tx-code-diff__line--inserted" });
1007
+ const REMOVED_LINE = Decoration.line({ class: "tx-code-diff__line--removed" });
1008
+ const INSERTED_TEXT = Decoration.mark({ class: TX_DIFF_INSERTED_TEXT });
1009
+ const REMOVED_TEXT = Decoration.mark({ class: TX_DIFF_REMOVED_TEXT });
1010
+ const PLUS = new SignMarker("+");
1011
+ const MINUS = new SignMarker("−");
1012
+ function blockPosition(state, lineIndex) {
1013
+ return lineIndex < state.doc.lines ? {
1014
+ position: state.doc.line(lineIndex + 1).from,
1015
+ side: -1
1016
+ } : {
1017
+ position: state.doc.length,
1018
+ side: 1
1019
+ };
1020
+ }
1021
+ function markLines(state, from, to, ranges, line, text, marker, decorations, markers) {
1022
+ const lines = [];
1023
+ for (let index = from; index < to && index < state.doc.lines; index++) lines.push(state.doc.line(index + 1).text);
1024
+ const marks = rangesByLine(lines, ranges);
1025
+ lines.forEach((_, offset) => {
1026
+ const docLine = state.doc.line(from + offset + 1);
1027
+ decorations.push(line.range(docLine.from));
1028
+ markers.push(marker.range(docLine.from));
1029
+ for (const mark of marks[offset]) decorations.push(text.range(docLine.from + mark.from, docLine.from + mark.to));
1030
+ });
1031
+ }
1032
+ function buildDiffDecorations(state, side, original, changes, guides = true) {
1033
+ const decorations = [];
1034
+ const markers = [];
1035
+ for (const change of changes) {
1036
+ const removedCount = change.originalTo - change.originalFrom;
1037
+ const insertedCount = change.modifiedTo - change.modifiedFrom;
1038
+ if (side === "inline") {
1039
+ if (removedCount) {
1040
+ const lines = original.lines.slice(change.originalFrom, change.originalTo);
1041
+ const marks = rangesByLine(lines, change.originalRanges);
1042
+ const rows = lines.map((text, offset) => ({
1043
+ kind: "removed",
1044
+ number: null,
1045
+ segments: markedSegments(text, original.tokens[change.originalFrom + offset] ?? [], marks[offset], TX_DIFF_REMOVED_TEXT),
1046
+ indent: lineIndent(text),
1047
+ guides: original.guides[change.originalFrom + offset] ?? 0
1048
+ }));
1049
+ const key = `${lines.join("\n")}|${change.originalRanges.map((range) => `${range.from}-${range.to}`).join(",")}`;
1050
+ const { position, side: blockSide } = blockPosition(state, change.modifiedFrom);
1051
+ decorations.push(Decoration.widget({
1052
+ widget: new RemovedLinesWidget(rows, key, guides, original.tabSize),
1053
+ block: true,
1054
+ side: blockSide
1055
+ }).range(position));
1056
+ }
1057
+ markLines(state, change.modifiedFrom, change.modifiedTo, change.modifiedRanges, INSERTED_LINE, INSERTED_TEXT, PLUS, decorations, markers);
1058
+ } else {
1059
+ const own = side === "original" ? removedCount : insertedCount;
1060
+ const other = side === "original" ? insertedCount : removedCount;
1061
+ const from = side === "original" ? change.originalFrom : change.modifiedFrom;
1062
+ const to = side === "original" ? change.originalTo : change.modifiedTo;
1063
+ if (side === "original") markLines(state, from, to, change.originalRanges, REMOVED_LINE, REMOVED_TEXT, MINUS, decorations, markers);
1064
+ else markLines(state, from, to, change.modifiedRanges, INSERTED_LINE, INSERTED_TEXT, PLUS, decorations, markers);
1065
+ if (other > own) {
1066
+ const { position, side: blockSide } = blockPosition(state, to);
1067
+ decorations.push(Decoration.widget({
1068
+ widget: new FillerWidget(other - own),
1069
+ block: true,
1070
+ side: blockSide
1071
+ }).range(position));
1072
+ }
1073
+ }
1074
+ }
1075
+ return {
1076
+ decorations: Decoration.set(decorations, true),
1077
+ markers: RangeSet.of(markers, true)
1078
+ };
1079
+ }
1080
+ const EMPTY$1 = {
1081
+ decorations: Decoration.none,
1082
+ markers: RangeSet.empty
1083
+ };
1084
+ const diffField = StateField.define({
1085
+ create: () => EMPTY$1,
1086
+ update(value, transaction) {
1087
+ let next = transaction.docChanged ? {
1088
+ decorations: value.decorations.map(transaction.changes),
1089
+ markers: value.markers.map(transaction.changes)
1090
+ } : value;
1091
+ for (const effect of transaction.effects) if (effect.is(setDiffDecorations)) next = effect.value;
1092
+ return next;
1093
+ },
1094
+ provide: (field) => EditorView.decorations.from(field, (value) => value.decorations)
1095
+ });
1096
+ function diffGutter() {
1097
+ return gutter({
1098
+ class: "tx-code-diff__signs",
1099
+ markers: (view) => view.state.field(diffField).markers,
1100
+ widgetMarker: (_view, widget) => widget instanceof RemovedLinesWidget ? new SignMarker("−", widget.lines) : null,
1101
+ initialSpacer: () => PLUS
1102
+ });
1103
+ }
1104
+ const historyAction = Annotation.define();
1105
+ const GROUP_DELAY = 500;
1106
+ const GROUPED = /^(input\.type|delete\.(backward|forward))/;
1107
+ const EMPTY = {
1108
+ done: [],
1109
+ undone: []
1110
+ };
1111
+ const historyField = StateField.define({
1112
+ create: () => EMPTY,
1113
+ update(value, transaction) {
1114
+ const action = transaction.annotation(historyAction);
1115
+ if (action === "reset") return EMPTY;
1116
+ if (!transaction.docChanged) return value;
1117
+ if (transaction.annotation(Transaction.addToHistory) === false) return EMPTY;
1118
+ const event = {
1119
+ changes: transaction.changes.invert(transaction.startState.doc),
1120
+ selection: transaction.startState.selection,
1121
+ time: Date.now(),
1122
+ type: transaction.annotation(Transaction.userEvent) ?? ""
1123
+ };
1124
+ if (action === "undo") return {
1125
+ done: value.done.slice(0, -1),
1126
+ undone: [...value.undone, event]
1127
+ };
1128
+ if (action === "redo") return {
1129
+ done: [...value.done, event],
1130
+ undone: value.undone.slice(0, -1)
1131
+ };
1132
+ const last = value.done[value.done.length - 1];
1133
+ if (last && event.time - last.time < GROUP_DELAY && GROUPED.test(event.type) && last.type === event.type) {
1134
+ const merged = {
1135
+ ...event,
1136
+ changes: event.changes.compose(last.changes),
1137
+ selection: last.selection
1138
+ };
1139
+ return {
1140
+ done: [...value.done.slice(0, -1), merged],
1141
+ undone: []
1142
+ };
1143
+ }
1144
+ return {
1145
+ done: [...value.done, event].slice(-200),
1146
+ undone: []
1147
+ };
1148
+ }
1149
+ });
1150
+ function travel(action) {
1151
+ return ({ state, dispatch }) => {
1152
+ const history = state.field(historyField, false);
1153
+ const stack = action === "undo" ? history?.done : history?.undone;
1154
+ const event = stack?.[stack.length - 1];
1155
+ if (!event || state.readOnly) return false;
1156
+ dispatch(state.update({
1157
+ changes: event.changes,
1158
+ selection: event.selection,
1159
+ annotations: [historyAction.of(action), Transaction.userEvent.of(action)],
1160
+ scrollIntoView: true
1161
+ }));
1162
+ return true;
1163
+ };
1164
+ }
1165
+ const undo = travel("undo");
1166
+ const redo = travel("redo");
1167
+ const PAIRS = {
1168
+ "(": ")",
1169
+ "[": "]",
1170
+ "{": "}",
1171
+ ")": "(",
1172
+ "]": "[",
1173
+ "}": "{"
1174
+ };
1175
+ const OPENING = /* @__PURE__ */ new Set([
1176
+ "(",
1177
+ "[",
1178
+ "{"
1179
+ ]);
1180
+ const SCAN_LIMIT = 2e4;
1181
+ const MARK = Decoration.mark({ class: "tx-code-editor__bracket" });
1182
+ function matchBracket(state, position) {
1183
+ const doc = state.doc;
1184
+ const char = doc.sliceString(position, position + 1);
1185
+ const pair = PAIRS[char];
1186
+ if (!pair) return null;
1187
+ const forward = OPENING.has(char);
1188
+ const end = forward ? Math.min(doc.length, position + SCAN_LIMIT) : Math.max(0, position - SCAN_LIMIT);
1189
+ const text = forward ? doc.sliceString(position + 1, end) : doc.sliceString(end, position);
1190
+ let depth = 0;
1191
+ if (forward) for (let index = 0; index < text.length; index++) {
1192
+ const current = text[index];
1193
+ if (current === char) depth++;
1194
+ else if (current === pair && depth-- === 0) return [position, position + 1 + index];
1195
+ }
1196
+ else for (let index = text.length - 1; index >= 0; index--) {
1197
+ const current = text[index];
1198
+ if (current === char) depth++;
1199
+ else if (current === pair && depth-- === 0) return [end + index, position];
1200
+ }
1201
+ return null;
1202
+ }
1203
+ function bracketDecorations(state) {
1204
+ const head = state.selection.main.head;
1205
+ const match = matchBracket(state, head - 1) ?? matchBracket(state, head);
1206
+ if (!match || !state.selection.main.empty) return Decoration.none;
1207
+ const [from, to] = match;
1208
+ return Decoration.set([MARK.range(from, from + 1), MARK.range(to, to + 1)]);
1209
+ }
1210
+ const bracketMatching = ViewPlugin.fromClass(class {
1211
+ decorations;
1212
+ constructor(view) {
1213
+ this.decorations = bracketDecorations(view.state);
1214
+ }
1215
+ update(update) {
1216
+ if (update.docChanged || update.selectionSet) this.decorations = bracketDecorations(update.state);
1217
+ }
1218
+ }, { decorations: (plugin) => plugin.decorations });
1219
+ const MARKS = /* @__PURE__ */ new Map();
1220
+ function tokenMark(type) {
1221
+ let mark = MARKS.get(type);
1222
+ if (!mark) {
1223
+ mark = Decoration.mark({ class: tokenClass(type) });
1224
+ MARKS.set(type, mark);
1225
+ }
1226
+ return mark;
1227
+ }
1228
+ function syntaxHighlight(language) {
1229
+ return ViewPlugin.fromClass(class {
1230
+ decorations;
1231
+ states = new TxCodeLineStates(getCodeMode(language));
1232
+ constructor(view) {
1233
+ this.decorations = this.build(view);
1234
+ }
1235
+ update(update) {
1236
+ if (update.docChanged) {
1237
+ let first = update.startState.doc.length;
1238
+ update.changes.iterChangedRanges((fromA) => {
1239
+ first = Math.min(first, fromA);
1240
+ });
1241
+ this.states.invalidateFrom(update.startState.doc.lineAt(first).number - 1);
1242
+ }
1243
+ if (update.docChanged || update.viewportChanged) this.decorations = this.build(update.view);
1244
+ }
1245
+ build(view) {
1246
+ const builder = new RangeSetBuilder();
1247
+ const doc = view.state.doc;
1248
+ const lineText = (index) => doc.line(index + 1).text;
1249
+ let done = 0;
1250
+ for (const { from, to } of view.visibleRanges) for (let number = Math.max(doc.lineAt(from).number, done + 1); number <= doc.lines; number++) {
1251
+ const line = doc.line(number);
1252
+ if (line.from > to) break;
1253
+ for (const token of this.states.tokens(number - 1, lineText)) builder.add(line.from + token.from, line.from + token.to, tokenMark(token.type));
1254
+ done = number;
1255
+ }
1256
+ return builder.finish();
1257
+ }
1258
+ }, { decorations: (plugin) => plugin.decorations });
1259
+ }
1260
+ const CACHE$1 = /* @__PURE__ */ new Map();
1261
+ function guideDecoration(levels, tabSize) {
1262
+ const key = `${levels}:${tabSize}`;
1263
+ let decoration = CACHE$1.get(key);
1264
+ if (!decoration) {
1265
+ decoration = Decoration.line({
1266
+ class: "tx-code-guides",
1267
+ attributes: { style: `--tx-code-guides: ${levels}; --tx-code-guide-step: ${tabSize}ch` }
1268
+ });
1269
+ CACHE$1.set(key, decoration);
1270
+ }
1271
+ return decoration;
1272
+ }
1273
+ function build$1(view) {
1274
+ const builder = new RangeSetBuilder();
1275
+ const doc = view.state.doc;
1276
+ const tabSize = view.state.tabSize;
1277
+ const text = (index) => doc.line(index + 1).text;
1278
+ let last = 0;
1279
+ for (const { from, to } of view.visibleRanges) {
1280
+ const first = Math.max(doc.lineAt(from).number, last + 1);
1281
+ const end = doc.lineAt(to).number;
1282
+ if (first > end) continue;
1283
+ guideLevels(doc.lines, text, tabSize, first - 1, end).forEach((levels, offset) => {
1284
+ if (levels > 0) {
1285
+ const line = doc.line(first + offset);
1286
+ builder.add(line.from, line.from, guideDecoration(levels, tabSize));
1287
+ }
1288
+ });
1289
+ last = end;
1290
+ }
1291
+ return builder.finish();
1292
+ }
1293
+ const indentGuides = ViewPlugin.fromClass(class {
1294
+ decorations;
1295
+ constructor(view) {
1296
+ this.decorations = build$1(view);
1297
+ }
1298
+ update(update) {
1299
+ if (update.docChanged || update.viewportChanged || update.startState.tabSize !== update.state.tabSize) this.decorations = build$1(update.view);
1300
+ }
1301
+ }, { decorations: (plugin) => plugin.decorations });
1302
+ const CACHE = /* @__PURE__ */ new Map();
1303
+ function indentDecoration(indent) {
1304
+ let decoration = CACHE.get(indent);
1305
+ if (!decoration) {
1306
+ decoration = Decoration.line({
1307
+ class: "tx-code-wrap-indent",
1308
+ attributes: { style: `--tx-code-wrap-indent: ${indent}` }
1309
+ });
1310
+ CACHE.set(indent, decoration);
1311
+ }
1312
+ return decoration;
1313
+ }
1314
+ function build(view) {
1315
+ const builder = new RangeSetBuilder();
1316
+ const doc = view.state.doc;
1317
+ let last = 0;
1318
+ for (const { from, to } of view.visibleRanges) for (let number = Math.max(doc.lineAt(from).number, last + 1); number <= doc.lines; number++) {
1319
+ const line = doc.line(number);
1320
+ if (line.from > to) break;
1321
+ const indent = lineIndent(line.text, view.state.tabSize);
1322
+ if (indent) builder.add(line.from, line.from, indentDecoration(indent));
1323
+ last = number;
1324
+ }
1325
+ return builder.finish();
1326
+ }
1327
+ const wrapIndent = ViewPlugin.fromClass(class {
1328
+ decorations;
1329
+ constructor(view) {
1330
+ this.decorations = build(view);
1331
+ }
1332
+ update(update) {
1333
+ if (update.docChanged || update.viewportChanged || update.startState.tabSize !== update.state.tabSize) this.decorations = build(update.view);
1334
+ }
1335
+ }, { decorations: (plugin) => plugin.decorations });
1336
+ var TxCodeEditorCompartments = class {
1337
+ language = new Compartment();
1338
+ readOnly = new Compartment();
1339
+ gutter = new Compartment();
1340
+ wrap = new Compartment();
1341
+ tabSize = new Compartment();
1342
+ placeholder = new Compartment();
1343
+ attributes = new Compartment();
1344
+ guides = new Compartment();
1345
+ languageExtension(language) {
1346
+ return [codeLanguage.of(language), syntaxHighlight(language)];
1347
+ }
1348
+ readOnlyExtension(readOnly, editable) {
1349
+ return [EditorState.readOnly.of(readOnly || !editable), EditorView.editable.of(editable)];
1350
+ }
1351
+ gutterExtension(enabled) {
1352
+ return enabled ? [lineNumbers(), highlightActiveLineGutter()] : [];
1353
+ }
1354
+ wrapExtension(enabled) {
1355
+ return enabled ? [EditorView.lineWrapping, wrapIndent] : [];
1356
+ }
1357
+ tabSizeExtension(size) {
1358
+ return EditorState.tabSize.of(size);
1359
+ }
1360
+ placeholderExtension(text) {
1361
+ return text ? placeholder(text) : [];
1362
+ }
1363
+ guidesExtension(enabled) {
1364
+ return enabled ? indentGuides : [];
1365
+ }
1366
+ attributesExtension(attributes) {
1367
+ return EditorView.contentAttributes.of(attributes);
1368
+ }
1369
+ initial(settings) {
1370
+ return [
1371
+ this.language.of(this.languageExtension(settings.language)),
1372
+ this.readOnly.of(this.readOnlyExtension(settings.readOnly, settings.editable)),
1373
+ this.gutter.of(this.gutterExtension(settings.lineNumbers)),
1374
+ this.wrap.of(this.wrapExtension(settings.wordWrap)),
1375
+ this.tabSize.of(this.tabSizeExtension(settings.tabSize)),
1376
+ this.placeholder.of(this.placeholderExtension(settings.placeholder)),
1377
+ this.attributes.of(this.attributesExtension(settings.attributes)),
1378
+ this.guides.of(this.guidesExtension(settings.indentGuides))
1379
+ ];
1380
+ }
1381
+ };
1382
+ const TX_CODE_EDITING_KEYS = [
1383
+ {
1384
+ key: "Mod-z",
1385
+ run: undo,
1386
+ preventDefault: true
1387
+ },
1388
+ {
1389
+ key: "Mod-Shift-z",
1390
+ run: redo,
1391
+ preventDefault: true
1392
+ },
1393
+ {
1394
+ key: "Mod-y",
1395
+ run: redo,
1396
+ preventDefault: true
1397
+ },
1398
+ {
1399
+ key: "Enter",
1400
+ run: insertNewline
1401
+ },
1402
+ {
1403
+ key: "Backspace",
1404
+ run: smartBackspace
1405
+ },
1406
+ {
1407
+ key: "Mod-/",
1408
+ run: toggleComment,
1409
+ preventDefault: true
1410
+ },
1411
+ {
1412
+ key: "Mod-]",
1413
+ run: indentMore,
1414
+ preventDefault: true
1415
+ },
1416
+ {
1417
+ key: "Mod-[",
1418
+ run: indentLess,
1419
+ preventDefault: true
1420
+ },
1421
+ {
1422
+ key: "Alt-ArrowUp",
1423
+ run: moveLineUp,
1424
+ preventDefault: true
1425
+ },
1426
+ {
1427
+ key: "Alt-ArrowDown",
1428
+ run: moveLineDown,
1429
+ preventDefault: true
1430
+ },
1431
+ {
1432
+ key: "Shift-Alt-ArrowUp",
1433
+ run: copyLineUp,
1434
+ preventDefault: true
1435
+ },
1436
+ {
1437
+ key: "Shift-Alt-ArrowDown",
1438
+ run: copyLineDown,
1439
+ preventDefault: true
1440
+ },
1441
+ {
1442
+ key: "Mod-Shift-k",
1443
+ run: deleteLine,
1444
+ preventDefault: true
1445
+ },
1446
+ {
1447
+ key: "Mod-a",
1448
+ run: selectAll,
1449
+ preventDefault: true
1450
+ }
1451
+ ];
1452
+ function tabKeys(escaped) {
1453
+ return [{
1454
+ key: "Tab",
1455
+ run: (view) => !escaped() && insertTab(view)
1456
+ }, {
1457
+ key: "Shift-Tab",
1458
+ run: (view) => !escaped() && indentLess(view)
1459
+ }];
1460
+ }
1461
+ function codeEditorBase() {
1462
+ return [
1463
+ historyField,
1464
+ searchMarks,
1465
+ drawSelection(),
1466
+ highlightActiveLine(),
1467
+ bracketMatching,
1468
+ autoClose,
1469
+ EditorState.allowMultipleSelections.of(true),
1470
+ Prec.high(keymap.of(TX_CODE_EDITING_KEYS))
1471
+ ];
1472
+ }
1473
+ const RECOMPUTE_DELAY = 150;
1474
+ var TxCodeDiff = class TxCodeDiff {
1475
+ original = input("", ...ngDevMode ? [{ debugName: "original" }] : /* istanbul ignore next */ []);
1476
+ value = model("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
1477
+ language = input("html", ...ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []);
1478
+ view = input("inline", ...ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []);
1479
+ readOnly = input(false, {
1480
+ ...ngDevMode ? { debugName: "readOnly" } : /* istanbul ignore next */ {},
1481
+ transform: booleanAttribute
1482
+ });
1483
+ lineNumbers = input(true, {
1484
+ ...ngDevMode ? { debugName: "lineNumbers" } : /* istanbul ignore next */ {},
1485
+ transform: booleanAttribute
1486
+ });
1487
+ wordWrap = input(true, {
1488
+ ...ngDevMode ? { debugName: "wordWrap" } : /* istanbul ignore next */ {},
1489
+ transform: booleanAttribute
1490
+ });
1491
+ indentGuides = input(true, {
1492
+ ...ngDevMode ? { debugName: "indentGuides" } : /* istanbul ignore next */ {},
1493
+ transform: booleanAttribute
1494
+ });
1495
+ ignoreTrimWhitespace = input(true, {
1496
+ ...ngDevMode ? { debugName: "ignoreTrimWhitespace" } : /* istanbul ignore next */ {},
1497
+ transform: booleanAttribute
1498
+ });
1499
+ scrollToFirstChange = input(true, {
1500
+ ...ngDevMode ? { debugName: "scrollToFirstChange" } : /* istanbul ignore next */ {},
1501
+ transform: booleanAttribute
1502
+ });
1503
+ height = input("600px", ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
1504
+ ariaLabel = input(void 0, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
1505
+ dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
1506
+ pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
1507
+ ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
1508
+ unstyled = input(void 0, {
1509
+ ...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
1510
+ transform: optionalBoolean
1511
+ });
1512
+ changed = output();
1513
+ isUnstyled = injectUnstyled(this.unstyled);
1514
+ passThrough = injectPassThrough("codeDiff", this, this.pt, this.ptOptions);
1515
+ t = injectTranslations();
1516
+ destroyRef = inject(DestroyRef);
1517
+ originalMount = viewChild("originalMount", ...ngDevMode ? [{ debugName: "originalMount" }] : /* istanbul ignore next */ []);
1518
+ modifiedMount = viewChild("modifiedMount", ...ngDevMode ? [{ debugName: "modifiedMount" }] : /* istanbul ignore next */ []);
1519
+ ready = signal(false, ...ngDevMode ? [{ debugName: "ready" }] : /* istanbul ignore next */ []);
1520
+ modifiedText = signal(null, ...ngDevMode ? [{ debugName: "modifiedText" }] : /* istanbul ignore next */ []);
1521
+ resolvedLanguage = computed(() => resolveCodeLanguage(this.language()) ?? "plain", ...ngDevMode ? [{ debugName: "resolvedLanguage" }] : /* istanbul ignore next */ []);
1522
+ originalDocument = computed(() => diffDocument(this.original() ?? "", this.resolvedLanguage()), ...ngDevMode ? [{ debugName: "originalDocument" }] : /* istanbul ignore next */ []);
1523
+ currentText = computed(() => this.modifiedText() ?? this.value() ?? "", ...ngDevMode ? [{ debugName: "currentText" }] : /* istanbul ignore next */ []);
1524
+ guideStep = computed(() => `${detectTabSize(this.currentText())}ch`, ...ngDevMode ? [{ debugName: "guideStep" }] : /* istanbul ignore next */ []);
1525
+ changes = computed(() => diffCode(this.original() ?? "", this.currentText(), { ignoreTrimWhitespace: this.ignoreTrimWhitespace() }), ...ngDevMode ? [{ debugName: "changes" }] : /* istanbul ignore next */ []);
1526
+ summary = computed(() => summarizeDiff(this.changes()), ...ngDevMode ? [{ debugName: "summary" }] : /* istanbul ignore next */ []);
1527
+ staticInline = computed(() => this.ready() || this.view() !== "inline" ? [] : inlineRows(this.originalDocument(), diffDocument(this.currentText(), this.resolvedLanguage()), this.changes()), ...ngDevMode ? [{ debugName: "staticInline" }] : /* istanbul ignore next */ []);
1528
+ staticSplit = computed(() => this.ready() || this.view() !== "split" ? {
1529
+ original: [],
1530
+ modified: []
1531
+ } : splitRows(this.originalDocument(), diffDocument(this.currentText(), this.resolvedLanguage()), this.changes()), ...ngDevMode ? [{ debugName: "staticSplit" }] : /* istanbul ignore next */ []);
1532
+ hostStyle = computed(() => {
1533
+ const { syntax, ...own } = this.dt() ?? {};
1534
+ return {
1535
+ ...toStyleObject(own, "--tx-code-diff"),
1536
+ ...toStyleObject(syntax, "--tx-code-syntax"),
1537
+ ...this.height() ? { height: this.height() } : {},
1538
+ ...this.passThrough().root?.style
1539
+ };
1540
+ }, ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
1541
+ originalView = null;
1542
+ modifiedView = null;
1543
+ builtFor = "";
1544
+ scrolled = false;
1545
+ recomputeTimer;
1546
+ syncing = null;
1547
+ escaped = false;
1548
+ compartments = new TxCodeEditorCompartments();
1549
+ originalCompartments = new TxCodeEditorCompartments();
1550
+ constructor() {
1551
+ inject(TxStyleLoader).load(TxCodeSyntaxStyles);
1552
+ afterRenderEffect(() => {
1553
+ const key = [
1554
+ this.view(),
1555
+ this.resolvedLanguage(),
1556
+ this.readOnly(),
1557
+ this.lineNumbers(),
1558
+ this.wordWrap(),
1559
+ this.indentGuides()
1560
+ ].join("|");
1561
+ const modified = this.modifiedMount();
1562
+ const original = this.originalMount();
1563
+ untracked(() => {
1564
+ if (!modified || key === this.builtFor) return;
1565
+ this.destroyViews();
1566
+ this.builtFor = key;
1567
+ this.createViews(modified.nativeElement, original?.nativeElement ?? null);
1568
+ });
1569
+ });
1570
+ effect(() => {
1571
+ const value = this.value() ?? "";
1572
+ untracked(() => {
1573
+ const view = this.modifiedView;
1574
+ if (view && value !== view.state.doc.toString()) {
1575
+ view.dispatch({
1576
+ changes: {
1577
+ from: 0,
1578
+ to: view.state.doc.length,
1579
+ insert: value
1580
+ },
1581
+ annotations: [historyAction.of("reset"), Transaction.addToHistory.of(false)]
1582
+ });
1583
+ this.modifiedText.set(null);
1584
+ this.scrolled = false;
1585
+ }
1586
+ });
1587
+ });
1588
+ effect(() => {
1589
+ const original = this.original() ?? "";
1590
+ untracked(() => {
1591
+ const view = this.originalView;
1592
+ if (view && original !== view.state.doc.toString()) {
1593
+ view.dispatch({ changes: {
1594
+ from: 0,
1595
+ to: view.state.doc.length,
1596
+ insert: original
1597
+ } });
1598
+ this.scrolled = false;
1599
+ }
1600
+ });
1601
+ });
1602
+ effect(() => {
1603
+ const changes = this.changes();
1604
+ const original = this.originalDocument();
1605
+ this.changed.emit(this.summary());
1606
+ untracked(() => this.applyDecorations(changes, original));
1607
+ });
1608
+ this.destroyRef.onDestroy(() => {
1609
+ clearTimeout(this.recomputeTimer);
1610
+ this.destroyViews();
1611
+ });
1612
+ }
1613
+ nextChange() {
1614
+ return this.goToChange(1);
1615
+ }
1616
+ previousChange() {
1617
+ return this.goToChange(-1);
1618
+ }
1619
+ goToChange(direction) {
1620
+ const view = this.modifiedView;
1621
+ const changes = this.changes();
1622
+ if (!view || !changes.length) return false;
1623
+ const line = view.state.doc.lineAt(view.state.selection.main.head).number - 1;
1624
+ const ordered = direction > 0 ? changes : [...changes].reverse();
1625
+ const target = ordered.find((change) => direction > 0 ? change.modifiedFrom > line : change.modifiedFrom < line) ?? ordered[0];
1626
+ const position = view.state.doc.line(Math.min(target.modifiedFrom + 1, view.state.doc.lines)).from;
1627
+ view.dispatch({
1628
+ selection: EditorSelection.cursor(position),
1629
+ effects: EditorView.scrollIntoView(position, { y: "center" })
1630
+ });
1631
+ return true;
1632
+ }
1633
+ editorExtensions(compartments, side, doc, readOnly) {
1634
+ const label = side === "original" ? this.t().codeDiffOriginal : side === "modified" ? this.t().codeDiffModified : this.ariaLabel() ?? this.t().codeDiffLabel;
1635
+ return [
1636
+ codeEditorBase(),
1637
+ compartments.initial({
1638
+ language: this.resolvedLanguage(),
1639
+ readOnly,
1640
+ editable: true,
1641
+ lineNumbers: this.lineNumbers(),
1642
+ wordWrap: side === "inline" && this.wordWrap(),
1643
+ tabSize: detectTabSize(doc),
1644
+ placeholder: "",
1645
+ indentGuides: this.indentGuides(),
1646
+ attributes: {
1647
+ "aria-label": label,
1648
+ "aria-multiline": "true",
1649
+ tabindex: "0",
1650
+ ...readOnly ? { "aria-readonly": "true" } : {}
1651
+ }
1652
+ }),
1653
+ diffField,
1654
+ diffGutter(),
1655
+ keymap.of([{
1656
+ key: "F7",
1657
+ run: () => this.goToChange(1),
1658
+ shift: () => this.goToChange(-1),
1659
+ preventDefault: true
1660
+ }, ...tabKeys(() => this.escaped)]),
1661
+ EditorView.domEventHandlers({ keydown: (event) => {
1662
+ this.escaped = event.key === "Escape" || this.escaped && (event.key === "Tab" || event.key === "Shift");
1663
+ return false;
1664
+ } })
1665
+ ];
1666
+ }
1667
+ createViews(modifiedParent, originalParent) {
1668
+ const modifiedDoc = this.value() ?? "";
1669
+ const split = this.view() === "split" && !!originalParent;
1670
+ modifiedParent.querySelector(".tx-code-diff__static")?.setAttribute("hidden", "");
1671
+ originalParent?.querySelector(".tx-code-diff__static")?.setAttribute("hidden", "");
1672
+ this.modifiedView = new EditorView({
1673
+ parent: modifiedParent,
1674
+ state: EditorState.create({
1675
+ doc: modifiedDoc,
1676
+ extensions: [this.editorExtensions(this.compartments, split ? "modified" : "inline", modifiedDoc, this.readOnly()), EditorView.updateListener.of((update) => {
1677
+ if (update.docChanged && !update.transactions.some((transaction) => transaction.annotation(historyAction) === "reset")) {
1678
+ const text = update.state.doc.toString();
1679
+ if (this.modifiedText() === null) this.modifiedText.set(update.startState.doc.toString());
1680
+ this.value.set(text);
1681
+ clearTimeout(this.recomputeTimer);
1682
+ this.recomputeTimer = setTimeout(() => this.modifiedText.set(text), RECOMPUTE_DELAY);
1683
+ }
1684
+ })]
1685
+ })
1686
+ });
1687
+ if (split && originalParent) {
1688
+ const originalDoc = this.original() ?? "";
1689
+ this.originalView = new EditorView({
1690
+ parent: originalParent,
1691
+ state: EditorState.create({
1692
+ doc: originalDoc,
1693
+ extensions: this.editorExtensions(this.originalCompartments, "original", originalDoc, true)
1694
+ })
1695
+ });
1696
+ this.syncScroll(this.originalView, this.modifiedView);
1697
+ this.syncScroll(this.modifiedView, this.originalView);
1698
+ }
1699
+ this.ready.set(true);
1700
+ this.applyDecorations(this.changes(), this.originalDocument());
1701
+ }
1702
+ syncScroll(source, target) {
1703
+ source.scrollDOM.addEventListener("scroll", () => {
1704
+ if (this.syncing === source) {
1705
+ this.syncing = null;
1706
+ return;
1707
+ }
1708
+ if (Math.abs(target.scrollDOM.scrollTop - source.scrollDOM.scrollTop) > 1 || target.scrollDOM.scrollLeft !== source.scrollDOM.scrollLeft) {
1709
+ this.syncing = target;
1710
+ target.scrollDOM.scrollTop = source.scrollDOM.scrollTop;
1711
+ target.scrollDOM.scrollLeft = source.scrollDOM.scrollLeft;
1712
+ }
1713
+ });
1714
+ }
1715
+ applyDecorations(changes, original) {
1716
+ const modified = this.modifiedView;
1717
+ if (!modified || this.currentText() !== modified.state.doc.toString()) return;
1718
+ const split = !!this.originalView;
1719
+ modified.dispatch({ effects: setDiffDecorations.of(buildDiffDecorations(modified.state, split ? "modified" : "inline", original, changes, this.indentGuides())) });
1720
+ if (this.originalView) {
1721
+ const left = this.originalView;
1722
+ left.dispatch({ effects: setDiffDecorations.of(buildDiffDecorations(left.state, "original", original, changes, this.indentGuides())) });
1723
+ }
1724
+ if (!this.scrolled && changes.length && this.scrollToFirstChange()) {
1725
+ this.scrolled = true;
1726
+ const first = changes[0];
1727
+ const position = modified.state.doc.line(Math.min(first.modifiedFrom + 1, modified.state.doc.lines)).from;
1728
+ this.centerInside(modified, position);
1729
+ }
1730
+ }
1731
+ centerInside(view, position) {
1732
+ view.requestMeasure({
1733
+ read: () => {
1734
+ const block = view.lineBlockAt(position);
1735
+ return Math.max(0, block.top - (view.scrollDOM.clientHeight - block.height) / 2);
1736
+ },
1737
+ write: (scrollTop) => {
1738
+ view.scrollDOM.scrollTop = scrollTop;
1739
+ }
1740
+ });
1741
+ }
1742
+ destroyViews() {
1743
+ this.modifiedView?.destroy();
1744
+ this.originalView?.destroy();
1745
+ this.modifiedView = null;
1746
+ this.originalView = null;
1747
+ this.builtFor = "";
1748
+ this.scrolled = false;
1749
+ this.ready.set(false);
1750
+ }
1751
+ static ɵfac = i0.ɵɵngDeclareFactory({
1752
+ minVersion: "12.0.0",
1753
+ version: "22.2.5",
1754
+ ngImport: i0,
1755
+ type: TxCodeDiff,
1756
+ deps: [],
1757
+ target: i0.ɵɵFactoryTarget.Component
1758
+ });
1759
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1760
+ minVersion: "17.0.0",
1761
+ version: "22.2.5",
1762
+ type: TxCodeDiff,
1763
+ isStandalone: true,
1764
+ selector: "tx-code-diff",
1765
+ inputs: {
1766
+ original: {
1767
+ classPropertyName: "original",
1768
+ publicName: "original",
1769
+ isSignal: true,
1770
+ isRequired: false,
1771
+ transformFunction: null
1772
+ },
1773
+ value: {
1774
+ classPropertyName: "value",
1775
+ publicName: "value",
1776
+ isSignal: true,
1777
+ isRequired: false,
1778
+ transformFunction: null
1779
+ },
1780
+ language: {
1781
+ classPropertyName: "language",
1782
+ publicName: "language",
1783
+ isSignal: true,
1784
+ isRequired: false,
1785
+ transformFunction: null
1786
+ },
1787
+ view: {
1788
+ classPropertyName: "view",
1789
+ publicName: "view",
1790
+ isSignal: true,
1791
+ isRequired: false,
1792
+ transformFunction: null
1793
+ },
1794
+ readOnly: {
1795
+ classPropertyName: "readOnly",
1796
+ publicName: "readOnly",
1797
+ isSignal: true,
1798
+ isRequired: false,
1799
+ transformFunction: null
1800
+ },
1801
+ lineNumbers: {
1802
+ classPropertyName: "lineNumbers",
1803
+ publicName: "lineNumbers",
1804
+ isSignal: true,
1805
+ isRequired: false,
1806
+ transformFunction: null
1807
+ },
1808
+ wordWrap: {
1809
+ classPropertyName: "wordWrap",
1810
+ publicName: "wordWrap",
1811
+ isSignal: true,
1812
+ isRequired: false,
1813
+ transformFunction: null
1814
+ },
1815
+ indentGuides: {
1816
+ classPropertyName: "indentGuides",
1817
+ publicName: "indentGuides",
1818
+ isSignal: true,
1819
+ isRequired: false,
1820
+ transformFunction: null
1821
+ },
1822
+ ignoreTrimWhitespace: {
1823
+ classPropertyName: "ignoreTrimWhitespace",
1824
+ publicName: "ignoreTrimWhitespace",
1825
+ isSignal: true,
1826
+ isRequired: false,
1827
+ transformFunction: null
1828
+ },
1829
+ scrollToFirstChange: {
1830
+ classPropertyName: "scrollToFirstChange",
1831
+ publicName: "scrollToFirstChange",
1832
+ isSignal: true,
1833
+ isRequired: false,
1834
+ transformFunction: null
1835
+ },
1836
+ height: {
1837
+ classPropertyName: "height",
1838
+ publicName: "height",
1839
+ isSignal: true,
1840
+ isRequired: false,
1841
+ transformFunction: null
1842
+ },
1843
+ ariaLabel: {
1844
+ classPropertyName: "ariaLabel",
1845
+ publicName: "ariaLabel",
1846
+ isSignal: true,
1847
+ isRequired: false,
1848
+ transformFunction: null
1849
+ },
1850
+ dt: {
1851
+ classPropertyName: "dt",
1852
+ publicName: "dt",
1853
+ isSignal: true,
1854
+ isRequired: false,
1855
+ transformFunction: null
1856
+ },
1857
+ pt: {
1858
+ classPropertyName: "pt",
1859
+ publicName: "pt",
1860
+ isSignal: true,
1861
+ isRequired: false,
1862
+ transformFunction: null
1863
+ },
1864
+ ptOptions: {
1865
+ classPropertyName: "ptOptions",
1866
+ publicName: "ptOptions",
1867
+ isSignal: true,
1868
+ isRequired: false,
1869
+ transformFunction: null
1870
+ },
1871
+ unstyled: {
1872
+ classPropertyName: "unstyled",
1873
+ publicName: "unstyled",
1874
+ isSignal: true,
1875
+ isRequired: false,
1876
+ transformFunction: null
1877
+ }
1878
+ },
1879
+ outputs: {
1880
+ value: "valueChange",
1881
+ changed: "changed"
1882
+ },
1883
+ host: {
1884
+ attributes: { "role": "group" },
1885
+ properties: {
1886
+ "class": "passThrough().root?.class",
1887
+ "style": "hostStyle()",
1888
+ "attr.data-styled": "!isUnstyled() || null",
1889
+ "attr.data-view": "view()",
1890
+ "class.tx-code-diff--split": "view() === 'split'",
1891
+ "class.tx-code-diff--numbers": "lineNumbers()",
1892
+ "class.tx-code-diff--wrap": "wordWrap() && view() === 'inline'",
1893
+ "attr.aria-label": "ariaLabel() ?? t().codeDiffLabel"
1894
+ },
1895
+ classAttribute: "tx-code-diff"
1896
+ },
1897
+ viewQueries: [{
1898
+ propertyName: "originalMount",
1899
+ first: true,
1900
+ predicate: ["originalMount"],
1901
+ descendants: true,
1902
+ isSignal: true
1903
+ }, {
1904
+ propertyName: "modifiedMount",
1905
+ first: true,
1906
+ predicate: ["modifiedMount"],
1907
+ descendants: true,
1908
+ isSignal: true
1909
+ }],
1910
+ ngImport: i0,
1911
+ template: "<ng-template #rowsTemplate let-rows>\n <div class=\"tx-code-diff__static\" role=\"presentation\">\n @for (row of rows; track $index) {\n <div\n class=\"tx-code-diff__static-line\"\n [class.tx-code-diff__line--inserted]=\"row.kind === 'inserted'\"\n [class.tx-code-diff__line--removed]=\"row.kind === 'removed'\"\n [class.tx-code-diff__static-line--filler]=\"row.kind === 'filler'\"\n >\n @if (lineNumbers()) {\n <span class=\"tx-code-diff__static-number\" aria-hidden=\"true\">{{ row.number }}</span>\n }\n <span class=\"tx-code-diff__static-sign\" aria-hidden=\"true\">{{ row.kind === 'inserted' ? '+' : row.kind === 'removed' ? '−' : '' }}</span>\n <span\n class=\"tx-code-diff__static-text\"\n [class.tx-code-guides]=\"indentGuides() && row.guides > 0\"\n [style.--tx-code-guides]=\"indentGuides() && row.guides > 0 ? row.guides : null\"\n [style.--tx-code-guide-step]=\"indentGuides() ? guideStep() : null\"\n [style.--tx-code-wrap-indent]=\"wordWrap() && view() === 'inline' ? row.indent : null\"\n >@for (segment of row.segments; track $index) {<span [class]=\"segment.className\">{{ segment.text }}</span>}</span\n >\n </div>\n }\n </div>\n</ng-template>\n\n@if (view() === 'split') {\n <div #originalMount class=\"tx-code-diff__pane tx-code-diff__pane--original\" [class]=\"passThrough().original?.class\" [style]=\"passThrough().original?.style\">\n @if (!ready()) {\n <ng-container *ngTemplateOutlet=\"rowsTemplate; context: { $implicit: staticSplit().original }\" />\n }\n </div>\n <div #modifiedMount class=\"tx-code-diff__pane tx-code-diff__pane--modified\" [class]=\"passThrough().modified?.class\" [style]=\"passThrough().modified?.style\">\n @if (!ready()) {\n <ng-container *ngTemplateOutlet=\"rowsTemplate; context: { $implicit: staticSplit().modified }\" />\n }\n </div>\n} @else {\n <div #modifiedMount class=\"tx-code-diff__pane\" [class]=\"passThrough().modified?.class\" [style]=\"passThrough().modified?.style\">\n @if (!ready()) {\n <ng-container *ngTemplateOutlet=\"rowsTemplate; context: { $implicit: staticInline() }\" />\n }\n </div>\n}\n",
1912
+ styles: [".tx-code-diff{position:relative;display:flex;min-width:0}.tx-code-diff__pane{flex:1 1 0;min-width:0;height:100%}.tx-code-diff[data-styled]{box-sizing:border-box;overflow:hidden;border:var(--tx-code-diff-border-width) solid var(--tx-code-diff-border-color);border-radius:var(--tx-code-diff-border-radius);background:var(--tx-code-diff-background);color:var(--tx-code-diff-color);font-family:var(--tx-code-diff-font-family);font-size:var(--tx-code-diff-font-size);line-height:var(--tx-code-diff-line-height)}.tx-code-diff[data-styled] .cm-editor{height:100%;background:transparent;color:inherit}.tx-code-diff[data-styled] .cm-editor.cm-focused{outline:none}.tx-code-diff[data-styled] .cm-scroller{font-family:inherit;line-height:inherit}.tx-code-diff[data-styled] .cm-content{padding-block:var(--tx-code-diff-padding-block);caret-color:var(--tx-code-editor-cursor-color);tab-size:var(--tx-code-diff-tab-size)}.tx-code-diff[data-styled]{--tx-code-line-start: 0px}.tx-code-diff[data-styled]:not(.tx-code-diff--numbers){--tx-code-line-start: var(--tx-code-diff-padding-inline-end)}.tx-code-diff[data-styled] .cm-scroller .cm-content .cm-line{padding:0 var(--tx-code-diff-padding-inline-end) 0 var(--tx-code-line-start)}.tx-code-diff[data-styled] .cm-editor .cm-gutters{border:none;background:var(--tx-code-diff-gutter-background);color:var(--tx-code-diff-gutter-color)}.tx-code-diff[data-styled] .cm-editor .cm-lineNumbers .cm-gutterElement{box-sizing:content-box;min-width:var(--tx-code-diff-gutter-min-digits);padding:0 var(--tx-code-diff-gutter-gap) 0 var(--tx-code-diff-gutter-padding-start);text-align:right}.tx-code-diff[data-styled] .cm-editor .cm-activeLineGutter{background:transparent;color:var(--tx-code-diff-gutter-active-color)}.tx-code-diff[data-styled] .cm-editor .cm-content .cm-activeLine{background-color:transparent;box-shadow:inset 0 0 0 var(--tx-code-editor-active-line-border-width) var(--tx-code-editor-active-line-border-color)}.tx-code-diff[data-styled] .cm-editor .cm-cursorLayer .cm-cursor{border-left:var(--tx-code-editor-cursor-width) solid var(--tx-code-editor-cursor-color)}.tx-code-diff[data-styled] .cm-editor .cm-scroller .cm-selectionLayer .cm-selectionBackground{background:var(--tx-code-editor-selection-inactive-background)}.tx-code-diff[data-styled] .cm-editor.cm-focused .cm-scroller .cm-selectionLayer .cm-selectionBackground{background:var(--tx-code-editor-selection-background)}.tx-code-diff[data-styled] .cm-editor .cm-placeholder{color:var(--tx-code-editor-placeholder-color)}.tx-code-diff[data-styled] .cm-scroller .cm-content .cm-line.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-diff[data-styled] .cm-scroller .cm-content .cm-line.tx-code-wrap-indent{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-diff[data-styled] .tx-code-editor__bracket{border-radius:1px;background:var(--tx-code-editor-bracket-background);outline:1px solid var(--tx-code-editor-bracket-border-color)}.tx-code-diff[data-styled] .tx-code-diff__static{box-sizing:border-box;min-height:100%;height:100%;padding-block:var(--tx-code-diff-padding-block);overflow:auto;tab-size:var(--tx-code-diff-tab-size)}.tx-code-diff[data-styled] .tx-code-diff__static[hidden]{display:none}.tx-code-diff[data-styled] .tx-code-diff__static-line{display:flex;min-height:var(--tx-code-diff-line-height)}.tx-code-diff[data-styled] .tx-code-diff__static-number{position:sticky;left:0;flex:none;box-sizing:content-box;min-width:var(--tx-code-diff-gutter-min-digits);padding:0 var(--tx-code-diff-gutter-gap) 0 var(--tx-code-diff-gutter-padding-start);background:var(--tx-code-diff-gutter-background);color:var(--tx-code-diff-gutter-color);text-align:right;-webkit-user-select:none;user-select:none}.tx-code-diff[data-styled] .tx-code-diff__static-text{flex:1 1 auto;padding-inline:var(--tx-code-line-start) var(--tx-code-diff-padding-inline-end);white-space:pre}.tx-code-diff[data-styled] .tx-code-diff__static-text.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-diff[data-styled].tx-code-diff--wrap .tx-code-diff__static-text{min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}.tx-code-diff[data-styled].tx-code-diff--wrap .tx-code-diff__static-text[style*=--tx-code-wrap-indent]{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-diff[data-styled].tx-code-diff--split .tx-code-diff__pane--original{border-inline-end:1px solid var(--tx-code-diff-split-border-color)}.tx-code-diff[data-styled] .tx-code-diff__signs .cm-gutterElement,.tx-code-diff[data-styled] .tx-code-diff__static-sign{box-sizing:border-box;flex:none;width:var(--tx-code-diff-gutter-marker-width);text-align:center;-webkit-user-select:none;user-select:none}.tx-code-diff[data-styled] .tx-code-diff__static-number,.tx-code-diff[data-styled] .cm-editor .cm-lineNumbers .cm-gutterElement{padding-inline-end:0}.tx-code-diff[data-styled],.tx-code-diff[data-styled]:not(.tx-code-diff--numbers){--tx-code-line-start: calc(var(--tx-code-diff-gutter-gap) - var(--tx-code-diff-gutter-marker-width))}.tx-code-diff[data-styled] .tx-code-diff__row{padding-inline-start:var(--tx-code-line-start)}.tx-code-diff[data-styled] .tx-code-diff__row.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-diff[data-styled].tx-code-diff--wrap .tx-code-diff__row[style*=--tx-code-wrap-indent]{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-diff[data-styled] .tx-code-diff__sign--inserted{color:var(--tx-code-diff-inserted-marker-color)}.tx-code-diff[data-styled] .tx-code-diff__sign--removed{color:var(--tx-code-diff-removed-marker-color)}.tx-code-diff[data-styled] .tx-code-diff__static-line.tx-code-diff__line--inserted .tx-code-diff__static-sign{color:var(--tx-code-diff-inserted-marker-color)}.tx-code-diff[data-styled] .tx-code-diff__static-line.tx-code-diff__line--removed .tx-code-diff__static-sign{color:var(--tx-code-diff-removed-marker-color)}.tx-code-diff[data-styled] .cm-scroller .cm-content .tx-code-diff__line--inserted,.tx-code-diff[data-styled] .tx-code-diff__static-line.tx-code-diff__line--inserted .tx-code-diff__static-text{background-color:var(--tx-code-diff-inserted-line-background)}.tx-code-diff[data-styled] .cm-scroller .cm-content .tx-code-diff__line--removed,.tx-code-diff[data-styled] .tx-code-diff__row.tx-code-diff__line--removed,.tx-code-diff[data-styled] .tx-code-diff__static-line.tx-code-diff__line--removed .tx-code-diff__static-text{background-color:var(--tx-code-diff-removed-line-background)}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-comment,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-comment{color:color-mix(in srgb,var(--tx-code-syntax-comment) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-quote,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-quote{color:color-mix(in srgb,var(--tx-code-syntax-quote) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-keyword,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-keyword{color:color-mix(in srgb,var(--tx-code-syntax-keyword) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-literal,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-literal{color:color-mix(in srgb,var(--tx-code-syntax-literal) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-string,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-string{color:color-mix(in srgb,var(--tx-code-syntax-string) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-number,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-number{color:color-mix(in srgb,var(--tx-code-syntax-number) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-regexp,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-regexp{color:color-mix(in srgb,var(--tx-code-syntax-regexp) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-type,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-type{color:color-mix(in srgb,var(--tx-code-syntax-type) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-delimiter,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-delimiter{color:color-mix(in srgb,var(--tx-code-syntax-delimiter) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-tag,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-tag{color:color-mix(in srgb,var(--tx-code-syntax-tag) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-tag-delimiter,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-tag-delimiter{color:color-mix(in srgb,var(--tx-code-syntax-tag-delimiter) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-meta,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-meta{color:color-mix(in srgb,var(--tx-code-syntax-meta) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-attribute,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-attribute{color:color-mix(in srgb,var(--tx-code-syntax-attribute) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-attribute-value,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-attribute-value{color:color-mix(in srgb,var(--tx-code-syntax-attribute-value) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-value,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-value{color:color-mix(in srgb,var(--tx-code-syntax-value) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-key,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-key{color:color-mix(in srgb,var(--tx-code-syntax-key) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-heading,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-heading{color:color-mix(in srgb,var(--tx-code-syntax-heading) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-link,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-link{color:color-mix(in srgb,var(--tx-code-syntax-link) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-code,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-code{color:color-mix(in srgb,var(--tx-code-syntax-code) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__text--inserted{background:var(--tx-code-diff-inserted-text-background)}.tx-code-diff[data-styled] .tx-code-diff__text--removed{background:var(--tx-code-diff-removed-text-background)}.tx-code-diff[data-styled] .tx-code-diff__row{min-height:var(--tx-code-diff-line-height);padding-inline-end:var(--tx-code-diff-padding-inline-end);white-space:pre}.tx-code-diff[data-styled].tx-code-diff--wrap .tx-code-diff__row{white-space:pre-wrap;overflow-wrap:anywhere}.tx-code-diff[data-styled] .tx-code-diff__filler,.tx-code-diff[data-styled] .tx-code-diff__static-line--filler .tx-code-diff__static-text{background-color:var(--tx-code-diff-filler-background)}.tx-code-diff[data-styled] .tx-code-diff__filler{height:calc(var(--tx-code-diff-line-height) * var(--tx-code-diff-filler-lines, 1))}.tx-code-diff[data-styled] .cm-editor .cm-content .cm-activeLine.tx-code-diff__line--inserted{background-color:var(--tx-code-diff-inserted-line-background)}\n"],
1913
+ dependencies: [{
1914
+ kind: "directive",
1915
+ type: NgTemplateOutlet,
1916
+ selector: "[ngTemplateOutlet]",
1917
+ inputs: [
1918
+ "ngTemplateOutletContext",
1919
+ "ngTemplateOutlet",
1920
+ "ngTemplateOutletInjector"
1921
+ ]
1922
+ }],
1923
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
1924
+ encapsulation: i0.ViewEncapsulation.None
1925
+ });
1926
+ };
1927
+ i0.ɵɵngDeclareClassMetadata({
1928
+ minVersion: "12.0.0",
1929
+ version: "22.2.5",
1930
+ ngImport: i0,
1931
+ type: TxCodeDiff,
1932
+ decorators: [{
1933
+ type: Component,
1934
+ args: [{
1935
+ selector: "tx-code-diff",
1936
+ imports: [NgTemplateOutlet],
1937
+ encapsulation: ViewEncapsulation.None,
1938
+ changeDetection: ChangeDetectionStrategy.OnPush,
1939
+ host: {
1940
+ class: "tx-code-diff",
1941
+ "[class]": "passThrough().root?.class",
1942
+ "[style]": "hostStyle()",
1943
+ "[attr.data-styled]": "!isUnstyled() || null",
1944
+ "[attr.data-view]": "view()",
1945
+ "[class.tx-code-diff--split]": "view() === 'split'",
1946
+ "[class.tx-code-diff--numbers]": "lineNumbers()",
1947
+ "[class.tx-code-diff--wrap]": "wordWrap() && view() === 'inline'",
1948
+ role: "group",
1949
+ "[attr.aria-label]": "ariaLabel() ?? t().codeDiffLabel"
1950
+ },
1951
+ template: "<ng-template #rowsTemplate let-rows>\n <div class=\"tx-code-diff__static\" role=\"presentation\">\n @for (row of rows; track $index) {\n <div\n class=\"tx-code-diff__static-line\"\n [class.tx-code-diff__line--inserted]=\"row.kind === 'inserted'\"\n [class.tx-code-diff__line--removed]=\"row.kind === 'removed'\"\n [class.tx-code-diff__static-line--filler]=\"row.kind === 'filler'\"\n >\n @if (lineNumbers()) {\n <span class=\"tx-code-diff__static-number\" aria-hidden=\"true\">{{ row.number }}</span>\n }\n <span class=\"tx-code-diff__static-sign\" aria-hidden=\"true\">{{ row.kind === 'inserted' ? '+' : row.kind === 'removed' ? '−' : '' }}</span>\n <span\n class=\"tx-code-diff__static-text\"\n [class.tx-code-guides]=\"indentGuides() && row.guides > 0\"\n [style.--tx-code-guides]=\"indentGuides() && row.guides > 0 ? row.guides : null\"\n [style.--tx-code-guide-step]=\"indentGuides() ? guideStep() : null\"\n [style.--tx-code-wrap-indent]=\"wordWrap() && view() === 'inline' ? row.indent : null\"\n >@for (segment of row.segments; track $index) {<span [class]=\"segment.className\">{{ segment.text }}</span>}</span\n >\n </div>\n }\n </div>\n</ng-template>\n\n@if (view() === 'split') {\n <div #originalMount class=\"tx-code-diff__pane tx-code-diff__pane--original\" [class]=\"passThrough().original?.class\" [style]=\"passThrough().original?.style\">\n @if (!ready()) {\n <ng-container *ngTemplateOutlet=\"rowsTemplate; context: { $implicit: staticSplit().original }\" />\n }\n </div>\n <div #modifiedMount class=\"tx-code-diff__pane tx-code-diff__pane--modified\" [class]=\"passThrough().modified?.class\" [style]=\"passThrough().modified?.style\">\n @if (!ready()) {\n <ng-container *ngTemplateOutlet=\"rowsTemplate; context: { $implicit: staticSplit().modified }\" />\n }\n </div>\n} @else {\n <div #modifiedMount class=\"tx-code-diff__pane\" [class]=\"passThrough().modified?.class\" [style]=\"passThrough().modified?.style\">\n @if (!ready()) {\n <ng-container *ngTemplateOutlet=\"rowsTemplate; context: { $implicit: staticInline() }\" />\n }\n </div>\n}\n",
1952
+ styles: [".tx-code-diff{position:relative;display:flex;min-width:0}.tx-code-diff__pane{flex:1 1 0;min-width:0;height:100%}.tx-code-diff[data-styled]{box-sizing:border-box;overflow:hidden;border:var(--tx-code-diff-border-width) solid var(--tx-code-diff-border-color);border-radius:var(--tx-code-diff-border-radius);background:var(--tx-code-diff-background);color:var(--tx-code-diff-color);font-family:var(--tx-code-diff-font-family);font-size:var(--tx-code-diff-font-size);line-height:var(--tx-code-diff-line-height)}.tx-code-diff[data-styled] .cm-editor{height:100%;background:transparent;color:inherit}.tx-code-diff[data-styled] .cm-editor.cm-focused{outline:none}.tx-code-diff[data-styled] .cm-scroller{font-family:inherit;line-height:inherit}.tx-code-diff[data-styled] .cm-content{padding-block:var(--tx-code-diff-padding-block);caret-color:var(--tx-code-editor-cursor-color);tab-size:var(--tx-code-diff-tab-size)}.tx-code-diff[data-styled]{--tx-code-line-start: 0px}.tx-code-diff[data-styled]:not(.tx-code-diff--numbers){--tx-code-line-start: var(--tx-code-diff-padding-inline-end)}.tx-code-diff[data-styled] .cm-scroller .cm-content .cm-line{padding:0 var(--tx-code-diff-padding-inline-end) 0 var(--tx-code-line-start)}.tx-code-diff[data-styled] .cm-editor .cm-gutters{border:none;background:var(--tx-code-diff-gutter-background);color:var(--tx-code-diff-gutter-color)}.tx-code-diff[data-styled] .cm-editor .cm-lineNumbers .cm-gutterElement{box-sizing:content-box;min-width:var(--tx-code-diff-gutter-min-digits);padding:0 var(--tx-code-diff-gutter-gap) 0 var(--tx-code-diff-gutter-padding-start);text-align:right}.tx-code-diff[data-styled] .cm-editor .cm-activeLineGutter{background:transparent;color:var(--tx-code-diff-gutter-active-color)}.tx-code-diff[data-styled] .cm-editor .cm-content .cm-activeLine{background-color:transparent;box-shadow:inset 0 0 0 var(--tx-code-editor-active-line-border-width) var(--tx-code-editor-active-line-border-color)}.tx-code-diff[data-styled] .cm-editor .cm-cursorLayer .cm-cursor{border-left:var(--tx-code-editor-cursor-width) solid var(--tx-code-editor-cursor-color)}.tx-code-diff[data-styled] .cm-editor .cm-scroller .cm-selectionLayer .cm-selectionBackground{background:var(--tx-code-editor-selection-inactive-background)}.tx-code-diff[data-styled] .cm-editor.cm-focused .cm-scroller .cm-selectionLayer .cm-selectionBackground{background:var(--tx-code-editor-selection-background)}.tx-code-diff[data-styled] .cm-editor .cm-placeholder{color:var(--tx-code-editor-placeholder-color)}.tx-code-diff[data-styled] .cm-scroller .cm-content .cm-line.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-diff[data-styled] .cm-scroller .cm-content .cm-line.tx-code-wrap-indent{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-diff[data-styled] .tx-code-editor__bracket{border-radius:1px;background:var(--tx-code-editor-bracket-background);outline:1px solid var(--tx-code-editor-bracket-border-color)}.tx-code-diff[data-styled] .tx-code-diff__static{box-sizing:border-box;min-height:100%;height:100%;padding-block:var(--tx-code-diff-padding-block);overflow:auto;tab-size:var(--tx-code-diff-tab-size)}.tx-code-diff[data-styled] .tx-code-diff__static[hidden]{display:none}.tx-code-diff[data-styled] .tx-code-diff__static-line{display:flex;min-height:var(--tx-code-diff-line-height)}.tx-code-diff[data-styled] .tx-code-diff__static-number{position:sticky;left:0;flex:none;box-sizing:content-box;min-width:var(--tx-code-diff-gutter-min-digits);padding:0 var(--tx-code-diff-gutter-gap) 0 var(--tx-code-diff-gutter-padding-start);background:var(--tx-code-diff-gutter-background);color:var(--tx-code-diff-gutter-color);text-align:right;-webkit-user-select:none;user-select:none}.tx-code-diff[data-styled] .tx-code-diff__static-text{flex:1 1 auto;padding-inline:var(--tx-code-line-start) var(--tx-code-diff-padding-inline-end);white-space:pre}.tx-code-diff[data-styled] .tx-code-diff__static-text.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-diff[data-styled].tx-code-diff--wrap .tx-code-diff__static-text{min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}.tx-code-diff[data-styled].tx-code-diff--wrap .tx-code-diff__static-text[style*=--tx-code-wrap-indent]{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-diff[data-styled].tx-code-diff--split .tx-code-diff__pane--original{border-inline-end:1px solid var(--tx-code-diff-split-border-color)}.tx-code-diff[data-styled] .tx-code-diff__signs .cm-gutterElement,.tx-code-diff[data-styled] .tx-code-diff__static-sign{box-sizing:border-box;flex:none;width:var(--tx-code-diff-gutter-marker-width);text-align:center;-webkit-user-select:none;user-select:none}.tx-code-diff[data-styled] .tx-code-diff__static-number,.tx-code-diff[data-styled] .cm-editor .cm-lineNumbers .cm-gutterElement{padding-inline-end:0}.tx-code-diff[data-styled],.tx-code-diff[data-styled]:not(.tx-code-diff--numbers){--tx-code-line-start: calc(var(--tx-code-diff-gutter-gap) - var(--tx-code-diff-gutter-marker-width))}.tx-code-diff[data-styled] .tx-code-diff__row{padding-inline-start:var(--tx-code-line-start)}.tx-code-diff[data-styled] .tx-code-diff__row.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-diff[data-styled].tx-code-diff--wrap .tx-code-diff__row[style*=--tx-code-wrap-indent]{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-diff[data-styled] .tx-code-diff__sign--inserted{color:var(--tx-code-diff-inserted-marker-color)}.tx-code-diff[data-styled] .tx-code-diff__sign--removed{color:var(--tx-code-diff-removed-marker-color)}.tx-code-diff[data-styled] .tx-code-diff__static-line.tx-code-diff__line--inserted .tx-code-diff__static-sign{color:var(--tx-code-diff-inserted-marker-color)}.tx-code-diff[data-styled] .tx-code-diff__static-line.tx-code-diff__line--removed .tx-code-diff__static-sign{color:var(--tx-code-diff-removed-marker-color)}.tx-code-diff[data-styled] .cm-scroller .cm-content .tx-code-diff__line--inserted,.tx-code-diff[data-styled] .tx-code-diff__static-line.tx-code-diff__line--inserted .tx-code-diff__static-text{background-color:var(--tx-code-diff-inserted-line-background)}.tx-code-diff[data-styled] .cm-scroller .cm-content .tx-code-diff__line--removed,.tx-code-diff[data-styled] .tx-code-diff__row.tx-code-diff__line--removed,.tx-code-diff[data-styled] .tx-code-diff__static-line.tx-code-diff__line--removed .tx-code-diff__static-text{background-color:var(--tx-code-diff-removed-line-background)}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-comment,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-comment{color:color-mix(in srgb,var(--tx-code-syntax-comment) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-quote,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-quote{color:color-mix(in srgb,var(--tx-code-syntax-quote) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-keyword,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-keyword{color:color-mix(in srgb,var(--tx-code-syntax-keyword) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-literal,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-literal{color:color-mix(in srgb,var(--tx-code-syntax-literal) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-string,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-string{color:color-mix(in srgb,var(--tx-code-syntax-string) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-number,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-number{color:color-mix(in srgb,var(--tx-code-syntax-number) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-regexp,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-regexp{color:color-mix(in srgb,var(--tx-code-syntax-regexp) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-type,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-type{color:color-mix(in srgb,var(--tx-code-syntax-type) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-delimiter,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-delimiter{color:color-mix(in srgb,var(--tx-code-syntax-delimiter) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-tag,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-tag{color:color-mix(in srgb,var(--tx-code-syntax-tag) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-tag-delimiter,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-tag-delimiter{color:color-mix(in srgb,var(--tx-code-syntax-tag-delimiter) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-meta,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-meta{color:color-mix(in srgb,var(--tx-code-syntax-meta) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-attribute,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-attribute{color:color-mix(in srgb,var(--tx-code-syntax-attribute) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-attribute-value,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-attribute-value{color:color-mix(in srgb,var(--tx-code-syntax-attribute-value) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-value,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-value{color:color-mix(in srgb,var(--tx-code-syntax-value) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-key,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-key{color:color-mix(in srgb,var(--tx-code-syntax-key) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-heading,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-heading{color:color-mix(in srgb,var(--tx-code-syntax-heading) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-link,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-link{color:color-mix(in srgb,var(--tx-code-syntax-link) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__line--inserted .tx-code-tok-code,.tx-code-diff[data-styled] .tx-code-diff__line--removed .tx-code-tok-code{color:color-mix(in srgb,var(--tx-code-syntax-code) var(--tx-code-diff-syntax-mix),var(--tx-code-diff-syntax-shade))}.tx-code-diff[data-styled] .tx-code-diff__text--inserted{background:var(--tx-code-diff-inserted-text-background)}.tx-code-diff[data-styled] .tx-code-diff__text--removed{background:var(--tx-code-diff-removed-text-background)}.tx-code-diff[data-styled] .tx-code-diff__row{min-height:var(--tx-code-diff-line-height);padding-inline-end:var(--tx-code-diff-padding-inline-end);white-space:pre}.tx-code-diff[data-styled].tx-code-diff--wrap .tx-code-diff__row{white-space:pre-wrap;overflow-wrap:anywhere}.tx-code-diff[data-styled] .tx-code-diff__filler,.tx-code-diff[data-styled] .tx-code-diff__static-line--filler .tx-code-diff__static-text{background-color:var(--tx-code-diff-filler-background)}.tx-code-diff[data-styled] .tx-code-diff__filler{height:calc(var(--tx-code-diff-line-height) * var(--tx-code-diff-filler-lines, 1))}.tx-code-diff[data-styled] .cm-editor .cm-content .cm-activeLine.tx-code-diff__line--inserted{background-color:var(--tx-code-diff-inserted-line-background)}\n"]
1953
+ }]
1954
+ }],
1955
+ ctorParameters: () => [],
1956
+ propDecorators: {
1957
+ original: [{
1958
+ type: i0.Input,
1959
+ args: [{
1960
+ isSignal: true,
1961
+ alias: "original",
1962
+ required: false
1963
+ }]
1964
+ }],
1965
+ value: [{
1966
+ type: i0.Input,
1967
+ args: [{
1968
+ isSignal: true,
1969
+ alias: "value",
1970
+ required: false
1971
+ }]
1972
+ }, {
1973
+ type: i0.Output,
1974
+ args: ["valueChange"]
1975
+ }],
1976
+ language: [{
1977
+ type: i0.Input,
1978
+ args: [{
1979
+ isSignal: true,
1980
+ alias: "language",
1981
+ required: false
1982
+ }]
1983
+ }],
1984
+ view: [{
1985
+ type: i0.Input,
1986
+ args: [{
1987
+ isSignal: true,
1988
+ alias: "view",
1989
+ required: false
1990
+ }]
1991
+ }],
1992
+ readOnly: [{
1993
+ type: i0.Input,
1994
+ args: [{
1995
+ isSignal: true,
1996
+ alias: "readOnly",
1997
+ required: false
1998
+ }]
1999
+ }],
2000
+ lineNumbers: [{
2001
+ type: i0.Input,
2002
+ args: [{
2003
+ isSignal: true,
2004
+ alias: "lineNumbers",
2005
+ required: false
2006
+ }]
2007
+ }],
2008
+ wordWrap: [{
2009
+ type: i0.Input,
2010
+ args: [{
2011
+ isSignal: true,
2012
+ alias: "wordWrap",
2013
+ required: false
2014
+ }]
2015
+ }],
2016
+ indentGuides: [{
2017
+ type: i0.Input,
2018
+ args: [{
2019
+ isSignal: true,
2020
+ alias: "indentGuides",
2021
+ required: false
2022
+ }]
2023
+ }],
2024
+ ignoreTrimWhitespace: [{
2025
+ type: i0.Input,
2026
+ args: [{
2027
+ isSignal: true,
2028
+ alias: "ignoreTrimWhitespace",
2029
+ required: false
2030
+ }]
2031
+ }],
2032
+ scrollToFirstChange: [{
2033
+ type: i0.Input,
2034
+ args: [{
2035
+ isSignal: true,
2036
+ alias: "scrollToFirstChange",
2037
+ required: false
2038
+ }]
2039
+ }],
2040
+ height: [{
2041
+ type: i0.Input,
2042
+ args: [{
2043
+ isSignal: true,
2044
+ alias: "height",
2045
+ required: false
2046
+ }]
2047
+ }],
2048
+ ariaLabel: [{
2049
+ type: i0.Input,
2050
+ args: [{
2051
+ isSignal: true,
2052
+ alias: "ariaLabel",
2053
+ required: false
2054
+ }]
2055
+ }],
2056
+ dt: [{
2057
+ type: i0.Input,
2058
+ args: [{
2059
+ isSignal: true,
2060
+ alias: "dt",
2061
+ required: false
2062
+ }]
2063
+ }],
2064
+ pt: [{
2065
+ type: i0.Input,
2066
+ args: [{
2067
+ isSignal: true,
2068
+ alias: "pt",
2069
+ required: false
2070
+ }]
2071
+ }],
2072
+ ptOptions: [{
2073
+ type: i0.Input,
2074
+ args: [{
2075
+ isSignal: true,
2076
+ alias: "ptOptions",
2077
+ required: false
2078
+ }]
2079
+ }],
2080
+ unstyled: [{
2081
+ type: i0.Input,
2082
+ args: [{
2083
+ isSignal: true,
2084
+ alias: "unstyled",
2085
+ required: false
2086
+ }]
2087
+ }],
2088
+ changed: [{
2089
+ type: i0.Output,
2090
+ args: ["changed"]
2091
+ }],
2092
+ originalMount: [{
2093
+ type: i0.ViewChild,
2094
+ args: ["originalMount", { isSignal: true }]
2095
+ }],
2096
+ modifiedMount: [{
2097
+ type: i0.ViewChild,
2098
+ args: ["modifiedMount", { isSignal: true }]
2099
+ }]
2100
+ }
2101
+ });
2102
+ const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
2103
+ var TxCodeEditor = class TxCodeEditor {
2104
+ value = model("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
2105
+ language = input("html", ...ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []);
2106
+ height = input("600px", ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
2107
+ readOnly = input(false, {
2108
+ ...ngDevMode ? { debugName: "readOnly" } : /* istanbul ignore next */ {},
2109
+ transform: booleanAttribute
2110
+ });
2111
+ lineNumbers = input(true, {
2112
+ ...ngDevMode ? { debugName: "lineNumbers" } : /* istanbul ignore next */ {},
2113
+ transform: booleanAttribute
2114
+ });
2115
+ wordWrap = input(true, {
2116
+ ...ngDevMode ? { debugName: "wordWrap" } : /* istanbul ignore next */ {},
2117
+ transform: booleanAttribute
2118
+ });
2119
+ indentGuides = input(true, {
2120
+ ...ngDevMode ? { debugName: "indentGuides" } : /* istanbul ignore next */ {},
2121
+ transform: booleanAttribute
2122
+ });
2123
+ tabSize = input(void 0, {
2124
+ ...ngDevMode ? { debugName: "tabSize" } : /* istanbul ignore next */ {},
2125
+ transform: optionalNumber
2126
+ });
2127
+ placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
2128
+ search = input(true, {
2129
+ ...ngDevMode ? { debugName: "search" } : /* istanbul ignore next */ {},
2130
+ transform: booleanAttribute
2131
+ });
2132
+ disabled = input(void 0, {
2133
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
2134
+ transform: optionalBoolean
2135
+ });
2136
+ invalid = input(void 0, {
2137
+ ...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
2138
+ transform: optionalBoolean
2139
+ });
2140
+ ariaLabel = input(void 0, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
2141
+ ariaLabelledBy = input(void 0, ...ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []);
2142
+ diffMode = input(false, {
2143
+ ...ngDevMode ? { debugName: "diffMode" } : /* istanbul ignore next */ {},
2144
+ transform: booleanAttribute
2145
+ });
2146
+ originalValue = input("", ...ngDevMode ? [{ debugName: "originalValue" }] : /* istanbul ignore next */ []);
2147
+ diffView = input("inline", ...ngDevMode ? [{ debugName: "diffView" }] : /* istanbul ignore next */ []);
2148
+ dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
2149
+ pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
2150
+ ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
2151
+ unstyled = input(void 0, {
2152
+ ...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
2153
+ transform: optionalBoolean
2154
+ });
2155
+ codeChanged = output();
2156
+ focused = output();
2157
+ blurred = output();
2158
+ diffChanged = output();
2159
+ isUnstyled = injectUnstyled(this.unstyled);
2160
+ passThrough = injectPassThrough("codeEditor", this, this.pt, this.ptOptions);
2161
+ isInvalid = injectFieldInvalid(this.invalid);
2162
+ t = injectTranslations();
2163
+ locale = inject(TxLocaleService);
2164
+ destroyRef = inject(DestroyRef);
2165
+ injector = inject(Injector);
2166
+ mount = viewChild("mount", ...ngDevMode ? [{ debugName: "mount" }] : /* istanbul ignore next */ []);
2167
+ findInput = viewChild("findInput", ...ngDevMode ? [{ debugName: "findInput" }] : /* istanbul ignore next */ []);
2168
+ replaceInput = viewChild("replaceInput", ...ngDevMode ? [{ debugName: "replaceInput" }] : /* istanbul ignore next */ []);
2169
+ formDisabled = signal(false, ...ngDevMode ? [{ debugName: "formDisabled" }] : /* istanbul ignore next */ []);
2170
+ docVersion = signal(0, ...ngDevMode ? [{ debugName: "docVersion" }] : /* istanbul ignore next */ []);
2171
+ ready = signal(false, ...ngDevMode ? [{ debugName: "ready" }] : /* istanbul ignore next */ []);
2172
+ focusedState = signal(false, ...ngDevMode ? [{ debugName: "focusedState" }] : /* istanbul ignore next */ []);
2173
+ searchOpen = signal(false, ...ngDevMode ? [{ debugName: "searchOpen" }] : /* istanbul ignore next */ []);
2174
+ replaceOpen = signal(false, ...ngDevMode ? [{ debugName: "replaceOpen" }] : /* istanbul ignore next */ []);
2175
+ query = signal("", ...ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []);
2176
+ replacement = signal("", ...ngDevMode ? [{ debugName: "replacement" }] : /* istanbul ignore next */ []);
2177
+ matchCase = signal(false, ...ngDevMode ? [{ debugName: "matchCase" }] : /* istanbul ignore next */ []);
2178
+ wholeWord = signal(false, ...ngDevMode ? [{ debugName: "wholeWord" }] : /* istanbul ignore next */ []);
2179
+ regexp = signal(false, ...ngDevMode ? [{ debugName: "regexp" }] : /* istanbul ignore next */ []);
2180
+ currentMatch = signal(-1, ...ngDevMode ? [{ debugName: "currentMatch" }] : /* istanbul ignore next */ []);
2181
+ view = null;
2182
+ text = "";
2183
+ applyingExternal = false;
2184
+ escaped = false;
2185
+ detectedTabSize = 4;
2186
+ compartments = new TxCodeEditorCompartments();
2187
+ onChange = () => void 0;
2188
+ onTouched = () => void 0;
2189
+ resolvedLanguage = computed(() => resolveCodeLanguage(this.language()) ?? "plain", ...ngDevMode ? [{ debugName: "resolvedLanguage" }] : /* istanbul ignore next */ []);
2190
+ isDisabled = computed(() => this.disabled() ?? this.formDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
2191
+ label = computed(() => this.ariaLabel() ?? (this.ariaLabelledBy() ? void 0 : this.t().codeEditorLabel), ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
2192
+ staticLines = computed(() => {
2193
+ if (this.ready()) return [];
2194
+ return codeLines(this.value() ?? "", this.resolvedLanguage(), 1, this.staticTabSize());
2195
+ }, ...ngDevMode ? [{ debugName: "staticLines" }] : /* istanbul ignore next */ []);
2196
+ staticTabSize = computed(() => this.tabSize() ?? detectTabSize(this.value() ?? ""), ...ngDevMode ? [{ debugName: "staticTabSize" }] : /* istanbul ignore next */ []);
2197
+ staticEmpty = computed(() => !(this.value() ?? ""), ...ngDevMode ? [{ debugName: "staticEmpty" }] : /* istanbul ignore next */ []);
2198
+ hostStyle = computed(() => {
2199
+ const { syntax, ...own } = this.dt() ?? {};
2200
+ return {
2201
+ ...toStyleObject(own, "--tx-code-editor"),
2202
+ ...toStyleObject(syntax, "--tx-code-syntax"),
2203
+ ...this.height() ? { height: this.height() } : {},
2204
+ ...this.passThrough().root?.style
2205
+ };
2206
+ }, ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
2207
+ searchQuery = computed(() => ({
2208
+ text: this.query(),
2209
+ matchCase: this.matchCase(),
2210
+ wholeWord: this.wholeWord(),
2211
+ regexp: this.regexp()
2212
+ }), ...ngDevMode ? [{ debugName: "searchQuery" }] : /* istanbul ignore next */ []);
2213
+ searchResult = computed(() => {
2214
+ this.docVersion();
2215
+ return this.searchOpen() ? findMatches(this.text, this.searchQuery()) : {
2216
+ matches: [],
2217
+ valid: true,
2218
+ pattern: null
2219
+ };
2220
+ }, ...ngDevMode ? [{ debugName: "searchResult" }] : /* istanbul ignore next */ []);
2221
+ current = computed(() => {
2222
+ const total = this.searchResult().matches.length;
2223
+ const index = this.currentMatch();
2224
+ return total ? Math.min(Math.max(index, 0), total - 1) : -1;
2225
+ }, ...ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []);
2226
+ countText = computed(() => {
2227
+ const total = this.searchResult().matches.length;
2228
+ if (!this.query()) return "";
2229
+ if (!total) return this.t().codeSearchNoResults;
2230
+ return this.locale.format(this.t().codeSearchCount, {
2231
+ current: this.current() + 1,
2232
+ total
2233
+ });
2234
+ }, ...ngDevMode ? [{ debugName: "countText" }] : /* istanbul ignore next */ []);
2235
+ constructor() {
2236
+ inject(TxStyleLoader).load(TxCodeSyntaxStyles);
2237
+ afterRenderEffect(() => {
2238
+ const mount = this.mount();
2239
+ if (mount && !this.view) this.createView(mount.nativeElement);
2240
+ else if (!mount && this.view) this.destroyView();
2241
+ });
2242
+ effect(() => {
2243
+ const value = this.value() ?? "";
2244
+ untracked(() => {
2245
+ if (this.view && value !== this.text) this.replaceDocument(value);
2246
+ });
2247
+ });
2248
+ effect(() => this.reconfigure("language", this.compartments.languageExtension(this.resolvedLanguage())));
2249
+ effect(() => this.reconfigure("readOnly", this.compartments.readOnlyExtension(this.readOnly(), !this.isDisabled())));
2250
+ effect(() => this.reconfigure("gutter", this.compartments.gutterExtension(this.lineNumbers())));
2251
+ effect(() => this.reconfigure("wrap", this.compartments.wrapExtension(this.wordWrap())));
2252
+ effect(() => this.reconfigure("tabSize", this.compartments.tabSizeExtension(this.tabSize() ?? this.detectedTabSize)));
2253
+ effect(() => this.reconfigure("placeholder", this.compartments.placeholderExtension(this.placeholder())));
2254
+ effect(() => this.reconfigure("guides", this.compartments.guidesExtension(this.indentGuides())));
2255
+ effect(() => this.reconfigure("attributes", this.compartments.attributesExtension(this.contentAttributes())));
2256
+ effect(() => {
2257
+ const open = this.searchOpen();
2258
+ const matches = this.searchResult().matches;
2259
+ const current = this.current();
2260
+ untracked(() => this.view?.dispatch({ effects: setSearchMarks.of({
2261
+ matches: open ? matches : [],
2262
+ current
2263
+ }) }));
2264
+ });
2265
+ this.destroyRef.onDestroy(() => this.destroyView());
2266
+ }
2267
+ writeValue(value) {
2268
+ this.value.set(value ?? "");
2269
+ }
2270
+ registerOnChange(fn) {
2271
+ this.onChange = fn;
2272
+ }
2273
+ registerOnTouched(fn) {
2274
+ this.onTouched = fn;
2275
+ }
2276
+ setDisabledState(isDisabled) {
2277
+ this.formDisabled.set(isDisabled);
2278
+ }
2279
+ focus() {
2280
+ this.view?.focus();
2281
+ }
2282
+ undo() {
2283
+ return this.view ? undo(this.view) : false;
2284
+ }
2285
+ redo() {
2286
+ return this.view ? redo(this.view) : false;
2287
+ }
2288
+ openSearch(replace = false) {
2289
+ if (!this.search() || this.diffMode()) return;
2290
+ const view = this.view;
2291
+ if (view) {
2292
+ const { from, to } = view.state.selection.main;
2293
+ const selected = view.state.sliceDoc(from, to);
2294
+ if (selected && !selected.includes("\n")) this.query.set(selected);
2295
+ }
2296
+ this.searchOpen.set(true);
2297
+ this.replaceOpen.set(replace || this.replaceOpen() && this.searchOpen());
2298
+ this.revealFrom(view?.state.selection.main.from ?? 0, false);
2299
+ afterNextRender(() => {
2300
+ const input = (replace ? this.replaceInput() : this.findInput())?.nativeElement;
2301
+ input?.focus();
2302
+ input?.select();
2303
+ }, { injector: this.injector });
2304
+ }
2305
+ closeSearch() {
2306
+ if (!this.searchOpen()) return;
2307
+ this.searchOpen.set(false);
2308
+ this.view?.focus();
2309
+ }
2310
+ findNext() {
2311
+ this.step(1);
2312
+ }
2313
+ findPrevious() {
2314
+ this.step(-1);
2315
+ }
2316
+ replaceCurrent() {
2317
+ const view = this.view;
2318
+ const matches = this.searchResult().matches;
2319
+ const index = this.current();
2320
+ if (!view || index < 0 || view.state.readOnly) return;
2321
+ const match = matches[index];
2322
+ const insert = replacementFor(view.state, match, this.searchQuery(), this.replacement());
2323
+ view.dispatch({
2324
+ changes: {
2325
+ from: match.from,
2326
+ to: match.to,
2327
+ insert
2328
+ },
2329
+ userEvent: "input.replace"
2330
+ });
2331
+ this.revealFrom(match.from + insert.length, true);
2332
+ }
2333
+ replaceAll() {
2334
+ const view = this.view;
2335
+ const matches = this.searchResult().matches;
2336
+ if (!view || !matches.length || view.state.readOnly) return;
2337
+ const query = this.searchQuery();
2338
+ const replacement = this.replacement();
2339
+ view.dispatch({
2340
+ changes: matches.map((match) => ({
2341
+ from: match.from,
2342
+ to: match.to,
2343
+ insert: replacementFor(view.state, match, query, replacement)
2344
+ })),
2345
+ userEvent: "input.replace.all"
2346
+ });
2347
+ }
2348
+ toggleReplace() {
2349
+ this.replaceOpen.update((open) => !open);
2350
+ }
2351
+ onQuery(value) {
2352
+ this.query.set(value);
2353
+ this.revealFrom(this.view?.state.selection.main.from ?? 0, true);
2354
+ }
2355
+ toggleOption(option) {
2356
+ this[option].update((on) => !on);
2357
+ this.revealFrom(this.view?.state.selection.main.from ?? 0, true);
2358
+ }
2359
+ onSearchKeydown(event, field) {
2360
+ const mod = isMac ? event.metaKey : event.ctrlKey;
2361
+ const key = event.key.toLowerCase();
2362
+ const replaceKey = isMac ? mod && event.altKey && event.code === "KeyF" : mod && key === "h";
2363
+ if (replaceKey || mod && !event.altKey && key === "f") {
2364
+ event.preventDefault();
2365
+ if (replaceKey) this.replaceOpen.set(true);
2366
+ afterNextRender(() => (replaceKey ? this.replaceInput() : this.findInput())?.nativeElement.focus(), { injector: this.injector });
2367
+ return;
2368
+ }
2369
+ if (event.key === "Escape") {
2370
+ event.preventDefault();
2371
+ this.closeSearch();
2372
+ } else if (event.key === "Enter" && field === "find") {
2373
+ event.preventDefault();
2374
+ this.step(event.shiftKey ? -1 : 1);
2375
+ } else if (event.key === "Enter" && field === "replace") {
2376
+ event.preventDefault();
2377
+ if (event.metaKey || event.ctrlKey) this.replaceAll();
2378
+ else this.replaceCurrent();
2379
+ } else if (event.key === "F3") {
2380
+ event.preventDefault();
2381
+ this.step(event.shiftKey ? -1 : 1);
2382
+ }
2383
+ }
2384
+ onDiffValue(next) {
2385
+ const value = next ?? "";
2386
+ this.text = value;
2387
+ this.value.set(value);
2388
+ this.codeChanged.emit(value);
2389
+ this.onChange(value);
2390
+ }
2391
+ step(direction) {
2392
+ const total = this.searchResult().matches.length;
2393
+ if (!total) return;
2394
+ const next = (this.current() + direction + total) % total;
2395
+ this.select(next);
2396
+ }
2397
+ revealFrom(position, select) {
2398
+ const matches = this.searchResult().matches;
2399
+ if (!matches.length) {
2400
+ this.currentMatch.set(-1);
2401
+ return;
2402
+ }
2403
+ const index = matches.findIndex((match) => match.from >= position);
2404
+ const target = index < 0 ? 0 : index;
2405
+ if (select) this.select(target);
2406
+ else this.currentMatch.set(target);
2407
+ }
2408
+ select(index) {
2409
+ const match = this.searchResult().matches[index];
2410
+ this.currentMatch.set(index);
2411
+ if (match && this.view) this.view.dispatch({
2412
+ selection: EditorSelection.single(match.from, match.to),
2413
+ effects: EditorView.scrollIntoView(match.from, { y: "center" }),
2414
+ userEvent: "select.search"
2415
+ });
2416
+ }
2417
+ contentAttributes() {
2418
+ const attributes = { "aria-multiline": "true" };
2419
+ if (!this.isDisabled()) attributes["tabindex"] = "0";
2420
+ const label = this.label();
2421
+ if (label) attributes["aria-label"] = label;
2422
+ if (this.ariaLabelledBy()) attributes["aria-labelledby"] = this.ariaLabelledBy();
2423
+ if (this.isInvalid()) attributes["aria-invalid"] = "true";
2424
+ if (this.readOnly()) attributes["aria-readonly"] = "true";
2425
+ if (this.isDisabled()) attributes["aria-disabled"] = "true";
2426
+ return attributes;
2427
+ }
2428
+ searchKeys() {
2429
+ if (!this.search()) return [];
2430
+ return [
2431
+ {
2432
+ key: "Mod-f",
2433
+ run: () => (this.openSearch(false), true),
2434
+ preventDefault: true
2435
+ },
2436
+ {
2437
+ key: isMac ? "Mod-Alt-f" : "Mod-h",
2438
+ run: () => (this.openSearch(true), true),
2439
+ preventDefault: true
2440
+ },
2441
+ {
2442
+ key: "F3",
2443
+ run: () => this.searchOpen() ? (this.findNext(), true) : false,
2444
+ shift: () => this.searchOpen() ? (this.findPrevious(), true) : false
2445
+ },
2446
+ {
2447
+ key: "Mod-g",
2448
+ run: () => this.searchOpen() ? (this.findNext(), true) : false,
2449
+ shift: () => this.searchOpen() ? (this.findPrevious(), true) : false
2450
+ },
2451
+ {
2452
+ key: "Escape",
2453
+ run: () => this.searchOpen() ? (this.closeSearch(), true) : false
2454
+ }
2455
+ ];
2456
+ }
2457
+ createView(parent) {
2458
+ const doc = this.value() ?? "";
2459
+ this.text = doc;
2460
+ this.detectedTabSize = detectTabSize(doc);
2461
+ parent.querySelector(".tx-code-editor__static")?.setAttribute("hidden", "");
2462
+ const extensions = [
2463
+ codeEditorBase(),
2464
+ this.compartments.initial({
2465
+ language: this.resolvedLanguage(),
2466
+ readOnly: this.readOnly(),
2467
+ editable: !this.isDisabled(),
2468
+ lineNumbers: this.lineNumbers(),
2469
+ wordWrap: this.wordWrap(),
2470
+ tabSize: this.tabSize() ?? this.detectedTabSize,
2471
+ placeholder: this.placeholder(),
2472
+ attributes: this.contentAttributes(),
2473
+ indentGuides: this.indentGuides()
2474
+ }),
2475
+ Prec.highest(keymap.of(this.searchKeys())),
2476
+ keymap.of(tabKeys(() => this.escaped)),
2477
+ EditorView.domEventHandlers({
2478
+ keydown: (event) => {
2479
+ if (event.key === "Escape") this.escaped = true;
2480
+ else if (event.key !== "Tab" && event.key !== "Shift") this.escaped = false;
2481
+ return false;
2482
+ },
2483
+ focus: (event) => {
2484
+ this.focused.emit(event);
2485
+ return false;
2486
+ },
2487
+ blur: (event) => {
2488
+ this.escaped = false;
2489
+ this.onTouched();
2490
+ this.blurred.emit(event);
2491
+ return false;
2492
+ }
2493
+ }),
2494
+ EditorView.updateListener.of((update) => this.onUpdate(update))
2495
+ ];
2496
+ this.view = new EditorView({
2497
+ parent,
2498
+ state: EditorState.create({
2499
+ doc,
2500
+ extensions
2501
+ })
2502
+ });
2503
+ this.ready.set(true);
2504
+ }
2505
+ destroyView() {
2506
+ this.view?.destroy();
2507
+ this.view = null;
2508
+ this.ready.set(false);
2509
+ }
2510
+ onUpdate(update) {
2511
+ if (update.focusChanged) this.focusedState.set(update.view.hasFocus);
2512
+ if (!update.docChanged) return;
2513
+ this.text = update.state.doc.toString();
2514
+ this.docVersion.update((version) => version + 1);
2515
+ if (this.applyingExternal) return;
2516
+ this.value.set(this.text);
2517
+ this.codeChanged.emit(this.text);
2518
+ this.onChange(this.text);
2519
+ }
2520
+ replaceDocument(value) {
2521
+ const view = this.view;
2522
+ if (!view) return;
2523
+ this.applyingExternal = true;
2524
+ const head = Math.min(view.state.selection.main.head, value.length);
2525
+ view.dispatch({
2526
+ changes: {
2527
+ from: 0,
2528
+ to: view.state.doc.length,
2529
+ insert: value
2530
+ },
2531
+ selection: EditorSelection.cursor(head),
2532
+ annotations: [historyAction.of("reset"), Transaction.addToHistory.of(false)]
2533
+ });
2534
+ this.applyingExternal = false;
2535
+ if (this.tabSize() === void 0) {
2536
+ this.detectedTabSize = detectTabSize(value);
2537
+ this.reconfigure("tabSize", this.compartments.tabSizeExtension(this.detectedTabSize));
2538
+ }
2539
+ }
2540
+ reconfigure(name, extension) {
2541
+ this.view?.dispatch({ effects: this.compartments[name].reconfigure(extension) });
2542
+ }
2543
+ static ɵfac = i0.ɵɵngDeclareFactory({
2544
+ minVersion: "12.0.0",
2545
+ version: "22.2.5",
2546
+ ngImport: i0,
2547
+ type: TxCodeEditor,
2548
+ deps: [],
2549
+ target: i0.ɵɵFactoryTarget.Component
2550
+ });
2551
+ static ɵcmp = i0.ɵɵngDeclareComponent({
2552
+ minVersion: "17.0.0",
2553
+ version: "22.2.5",
2554
+ type: TxCodeEditor,
2555
+ isStandalone: true,
2556
+ selector: "tx-code-editor",
2557
+ inputs: {
2558
+ value: {
2559
+ classPropertyName: "value",
2560
+ publicName: "value",
2561
+ isSignal: true,
2562
+ isRequired: false,
2563
+ transformFunction: null
2564
+ },
2565
+ language: {
2566
+ classPropertyName: "language",
2567
+ publicName: "language",
2568
+ isSignal: true,
2569
+ isRequired: false,
2570
+ transformFunction: null
2571
+ },
2572
+ height: {
2573
+ classPropertyName: "height",
2574
+ publicName: "height",
2575
+ isSignal: true,
2576
+ isRequired: false,
2577
+ transformFunction: null
2578
+ },
2579
+ readOnly: {
2580
+ classPropertyName: "readOnly",
2581
+ publicName: "readOnly",
2582
+ isSignal: true,
2583
+ isRequired: false,
2584
+ transformFunction: null
2585
+ },
2586
+ lineNumbers: {
2587
+ classPropertyName: "lineNumbers",
2588
+ publicName: "lineNumbers",
2589
+ isSignal: true,
2590
+ isRequired: false,
2591
+ transformFunction: null
2592
+ },
2593
+ wordWrap: {
2594
+ classPropertyName: "wordWrap",
2595
+ publicName: "wordWrap",
2596
+ isSignal: true,
2597
+ isRequired: false,
2598
+ transformFunction: null
2599
+ },
2600
+ indentGuides: {
2601
+ classPropertyName: "indentGuides",
2602
+ publicName: "indentGuides",
2603
+ isSignal: true,
2604
+ isRequired: false,
2605
+ transformFunction: null
2606
+ },
2607
+ tabSize: {
2608
+ classPropertyName: "tabSize",
2609
+ publicName: "tabSize",
2610
+ isSignal: true,
2611
+ isRequired: false,
2612
+ transformFunction: null
2613
+ },
2614
+ placeholder: {
2615
+ classPropertyName: "placeholder",
2616
+ publicName: "placeholder",
2617
+ isSignal: true,
2618
+ isRequired: false,
2619
+ transformFunction: null
2620
+ },
2621
+ search: {
2622
+ classPropertyName: "search",
2623
+ publicName: "search",
2624
+ isSignal: true,
2625
+ isRequired: false,
2626
+ transformFunction: null
2627
+ },
2628
+ disabled: {
2629
+ classPropertyName: "disabled",
2630
+ publicName: "disabled",
2631
+ isSignal: true,
2632
+ isRequired: false,
2633
+ transformFunction: null
2634
+ },
2635
+ invalid: {
2636
+ classPropertyName: "invalid",
2637
+ publicName: "invalid",
2638
+ isSignal: true,
2639
+ isRequired: false,
2640
+ transformFunction: null
2641
+ },
2642
+ ariaLabel: {
2643
+ classPropertyName: "ariaLabel",
2644
+ publicName: "ariaLabel",
2645
+ isSignal: true,
2646
+ isRequired: false,
2647
+ transformFunction: null
2648
+ },
2649
+ ariaLabelledBy: {
2650
+ classPropertyName: "ariaLabelledBy",
2651
+ publicName: "ariaLabelledBy",
2652
+ isSignal: true,
2653
+ isRequired: false,
2654
+ transformFunction: null
2655
+ },
2656
+ diffMode: {
2657
+ classPropertyName: "diffMode",
2658
+ publicName: "diffMode",
2659
+ isSignal: true,
2660
+ isRequired: false,
2661
+ transformFunction: null
2662
+ },
2663
+ originalValue: {
2664
+ classPropertyName: "originalValue",
2665
+ publicName: "originalValue",
2666
+ isSignal: true,
2667
+ isRequired: false,
2668
+ transformFunction: null
2669
+ },
2670
+ diffView: {
2671
+ classPropertyName: "diffView",
2672
+ publicName: "diffView",
2673
+ isSignal: true,
2674
+ isRequired: false,
2675
+ transformFunction: null
2676
+ },
2677
+ dt: {
2678
+ classPropertyName: "dt",
2679
+ publicName: "dt",
2680
+ isSignal: true,
2681
+ isRequired: false,
2682
+ transformFunction: null
2683
+ },
2684
+ pt: {
2685
+ classPropertyName: "pt",
2686
+ publicName: "pt",
2687
+ isSignal: true,
2688
+ isRequired: false,
2689
+ transformFunction: null
2690
+ },
2691
+ ptOptions: {
2692
+ classPropertyName: "ptOptions",
2693
+ publicName: "ptOptions",
2694
+ isSignal: true,
2695
+ isRequired: false,
2696
+ transformFunction: null
2697
+ },
2698
+ unstyled: {
2699
+ classPropertyName: "unstyled",
2700
+ publicName: "unstyled",
2701
+ isSignal: true,
2702
+ isRequired: false,
2703
+ transformFunction: null
2704
+ }
2705
+ },
2706
+ outputs: {
2707
+ value: "valueChange",
2708
+ codeChanged: "codeChanged",
2709
+ focused: "focused",
2710
+ blurred: "blurred",
2711
+ diffChanged: "diffChanged"
2712
+ },
2713
+ host: {
2714
+ properties: {
2715
+ "class": "passThrough().root?.class",
2716
+ "style": "hostStyle()",
2717
+ "attr.data-styled": "!isUnstyled() || null",
2718
+ "attr.data-language": "resolvedLanguage()",
2719
+ "class.tx-code-editor--focused": "focusedState()",
2720
+ "class.tx-code-editor--invalid": "isInvalid()",
2721
+ "class.tx-code-editor--disabled": "isDisabled()",
2722
+ "class.tx-code-editor--readonly": "readOnly()",
2723
+ "class.tx-code-editor--wrap": "wordWrap()",
2724
+ "class.tx-code-editor--numbers": "lineNumbers()",
2725
+ "class.tx-code-editor--diff": "diffMode()"
2726
+ },
2727
+ classAttribute: "tx-code-editor"
2728
+ },
2729
+ providers: [{
2730
+ provide: NG_VALUE_ACCESSOR,
2731
+ useExisting: forwardRef(() => TxCodeEditor),
2732
+ multi: true
2733
+ }],
2734
+ viewQueries: [
2735
+ {
2736
+ propertyName: "mount",
2737
+ first: true,
2738
+ predicate: ["mount"],
2739
+ descendants: true,
2740
+ isSignal: true
2741
+ },
2742
+ {
2743
+ propertyName: "findInput",
2744
+ first: true,
2745
+ predicate: ["findInput"],
2746
+ descendants: true,
2747
+ isSignal: true
2748
+ },
2749
+ {
2750
+ propertyName: "replaceInput",
2751
+ first: true,
2752
+ predicate: ["replaceInput"],
2753
+ descendants: true,
2754
+ isSignal: true
2755
+ }
2756
+ ],
2757
+ ngImport: i0,
2758
+ template: "@if (diffMode()) {\n <tx-code-diff\n class=\"tx-code-editor__diff\"\n [original]=\"originalValue()\"\n [value]=\"value()\"\n [language]=\"language()\"\n [view]=\"diffView()\"\n [readOnly]=\"readOnly() || isDisabled()\"\n [lineNumbers]=\"lineNumbers()\"\n [wordWrap]=\"wordWrap()\"\n [indentGuides]=\"indentGuides()\"\n [ariaLabel]=\"ariaLabel()\"\n [unstyled]=\"isUnstyled()\"\n height=\"100%\"\n (valueChange)=\"onDiffValue($event)\"\n (changed)=\"diffChanged.emit($event)\"\n />\n} @else {\n <div #mount class=\"tx-code-editor__mount\" [class]=\"passThrough().editor?.class\" [style]=\"passThrough().editor?.style\">\n @if (!ready()) {\n <div\n class=\"tx-code-editor__static\"\n role=\"textbox\"\n aria-multiline=\"true\"\n aria-readonly=\"true\"\n [attr.aria-label]=\"ariaLabel() ?? (ariaLabelledBy() ? null : t().codeEditorLabel)\"\n [attr.aria-labelledby]=\"ariaLabelledBy() ?? null\"\n >\n @for (line of staticLines(); track $index) {\n <div class=\"tx-code-editor__static-line\">\n @if (lineNumbers()) {\n <span class=\"tx-code-editor__static-number\" aria-hidden=\"true\">{{ line.number }}</span>\n }\n <span\n class=\"tx-code-editor__static-text\"\n [class.tx-code-guides]=\"indentGuides() && line.guides > 0\"\n [style.--tx-code-guides]=\"indentGuides() && line.guides > 0 ? line.guides : null\"\n [style.--tx-code-guide-step]=\"indentGuides() ? staticTabSize() + 'ch' : null\"\n [style.--tx-code-wrap-indent]=\"wordWrap() ? line.indent : null\"\n >@for (segment of line.segments; track $index) {<span [class]=\"segment.className\">{{ segment.text }}</span>}@if (\n staticEmpty() && placeholder()\n ) {<span class=\"tx-code-editor__static-placeholder\">{{ placeholder() }}</span>}</span\n >\n </div>\n }\n </div>\n }\n </div>\n @if (searchOpen()) {\n <div class=\"tx-code-editor__search\" role=\"search\" [class]=\"passThrough().search?.class\" [style]=\"passThrough().search?.style\">\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n class=\"tx-code-editor__search-expand\"\n [icon]=\"replaceOpen() ? 'chevron-down' : 'chevron-right'\"\n [attr.aria-label]=\"t().codeSearchToggleReplace\"\n [attr.aria-expanded]=\"replaceOpen()\"\n (click)=\"toggleReplace()\"\n ></button>\n <div class=\"tx-code-editor__search-rows\">\n <div class=\"tx-code-editor__search-row\">\n <div class=\"tx-code-editor__search-field\">\n <input\n #findInput\n txInput\n size=\"small\"\n class=\"tx-code-editor__search-input\"\n [class]=\"passThrough().searchInput?.class\"\n [invalid]=\"!searchResult().valid\"\n [value]=\"query()\"\n [placeholder]=\"t().codeSearchFind\"\n [attr.aria-label]=\"t().codeSearchFind\"\n (input)=\"onQuery($any($event.target).value)\"\n (keydown)=\"onSearchKeydown($event, 'find')\"\n />\n <div class=\"tx-code-editor__search-options\">\n <button\n type=\"button\"\n class=\"tx-code-editor__search-option\"\n [attr.aria-pressed]=\"matchCase()\"\n [attr.aria-label]=\"t().codeSearchMatchCase\"\n [attr.title]=\"t().codeSearchMatchCase\"\n (click)=\"toggleOption('matchCase')\"\n >\n Aa\n </button>\n <button\n type=\"button\"\n class=\"tx-code-editor__search-option tx-code-editor__search-option--word\"\n [attr.aria-pressed]=\"wholeWord()\"\n [attr.aria-label]=\"t().codeSearchWholeWord\"\n [attr.title]=\"t().codeSearchWholeWord\"\n (click)=\"toggleOption('wholeWord')\"\n >\n ab\n </button>\n <button\n type=\"button\"\n class=\"tx-code-editor__search-option\"\n [attr.aria-pressed]=\"regexp()\"\n [attr.aria-label]=\"t().codeSearchRegexp\"\n [attr.title]=\"t().codeSearchRegexp\"\n (click)=\"toggleOption('regexp')\"\n >\n .*\n </button>\n </div>\n </div>\n <span class=\"tx-code-editor__search-count\" aria-live=\"polite\">{{ countText() }}</span>\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n icon=\"arrow-up\"\n [disabled]=\"!searchResult().matches.length\"\n [attr.aria-label]=\"t().codeSearchPrevious\"\n (click)=\"findPrevious()\"\n ></button>\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n icon=\"arrow-down\"\n [disabled]=\"!searchResult().matches.length\"\n [attr.aria-label]=\"t().codeSearchNext\"\n (click)=\"findNext()\"\n ></button>\n <button txButton type=\"button\" text plain size=\"small\" icon=\"times\" [attr.aria-label]=\"t().codeSearchClose\" (click)=\"closeSearch()\"></button>\n </div>\n @if (replaceOpen()) {\n <div class=\"tx-code-editor__search-row\">\n <div class=\"tx-code-editor__search-field\">\n <input\n #replaceInput\n txInput\n size=\"small\"\n class=\"tx-code-editor__search-input\"\n [value]=\"replacement()\"\n [placeholder]=\"t().codeSearchReplace\"\n [attr.aria-label]=\"t().codeSearchReplace\"\n [readOnly]=\"readOnly() || isDisabled()\"\n (input)=\"replacement.set($any($event.target).value)\"\n (keydown)=\"onSearchKeydown($event, 'replace')\"\n />\n </div>\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n icon=\"pen-line\"\n [disabled]=\"!searchResult().matches.length || readOnly() || isDisabled()\"\n [attr.aria-label]=\"t().codeSearchReplace\"\n (click)=\"replaceCurrent()\"\n ></button>\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n icon=\"list-check\"\n [disabled]=\"!searchResult().matches.length || readOnly() || isDisabled()\"\n [attr.aria-label]=\"t().codeSearchReplaceAll\"\n (click)=\"replaceAll()\"\n ></button>\n </div>\n }\n </div>\n </div>\n }\n}\n",
2759
+ styles: [".tx-code-editor{position:relative;display:block;min-width:0}.tx-code-editor__mount,.tx-code-editor__diff{height:100%}.tx-code-editor[data-styled]{box-sizing:border-box;overflow:hidden;border:var(--tx-code-editor-border-width) solid var(--tx-code-editor-border-color);border-radius:var(--tx-code-editor-border-radius);background:var(--tx-code-editor-background);color:var(--tx-code-editor-color);font-family:var(--tx-code-editor-font-family);font-size:var(--tx-code-editor-font-size);line-height:var(--tx-code-editor-line-height);transition:border-color var(--tx-motion-duration)}.tx-code-editor[data-styled].tx-code-editor--focused{border-color:var(--tx-code-editor-focus-border-color)}.tx-code-editor[data-styled].tx-code-editor--invalid{border-color:var(--tx-code-editor-invalid-border-color)}.tx-code-editor[data-styled].tx-code-editor--disabled{opacity:var(--tx-code-editor-disabled-opacity)}.tx-code-editor[data-styled].tx-code-editor--diff{border:none;border-radius:0;background:none}.tx-code-editor[data-styled] .cm-editor{height:100%;background:transparent;color:inherit}.tx-code-editor[data-styled] .cm-editor.cm-focused{outline:none}.tx-code-editor[data-styled] .cm-scroller{font-family:inherit;line-height:inherit}.tx-code-editor[data-styled] .cm-content{padding-block:var(--tx-code-editor-padding-block);caret-color:var(--tx-code-editor-cursor-color);tab-size:var(--tx-code-editor-tab-size)}.tx-code-editor[data-styled]{--tx-code-line-start: 0px}.tx-code-editor[data-styled]:not(.tx-code-editor--numbers){--tx-code-line-start: var(--tx-code-editor-padding-inline-end)}.tx-code-editor[data-styled] .cm-scroller .cm-content .cm-line{padding:0 var(--tx-code-editor-padding-inline-end) 0 var(--tx-code-line-start)}.tx-code-editor[data-styled] .cm-editor .cm-gutters{border:none;background:var(--tx-code-editor-gutter-background);color:var(--tx-code-editor-gutter-color)}.tx-code-editor[data-styled] .cm-editor .cm-lineNumbers .cm-gutterElement{box-sizing:content-box;min-width:var(--tx-code-editor-gutter-min-digits);padding:0 var(--tx-code-editor-gutter-gap) 0 var(--tx-code-editor-gutter-padding-start);text-align:right}.tx-code-editor[data-styled] .cm-editor .cm-activeLineGutter{background:transparent;color:var(--tx-code-editor-gutter-active-color)}.tx-code-editor[data-styled] .cm-editor .cm-content .cm-activeLine{background-color:transparent;box-shadow:inset 0 0 0 var(--tx-code-editor-active-line-border-width) var(--tx-code-editor-active-line-border-color)}.tx-code-editor[data-styled] .cm-editor .cm-cursorLayer .cm-cursor{border-left:var(--tx-code-editor-cursor-width) solid var(--tx-code-editor-cursor-color)}.tx-code-editor[data-styled] .cm-editor .cm-scroller .cm-selectionLayer .cm-selectionBackground{background:var(--tx-code-editor-selection-inactive-background)}.tx-code-editor[data-styled] .cm-editor.cm-focused .cm-scroller .cm-selectionLayer .cm-selectionBackground{background:var(--tx-code-editor-selection-background)}.tx-code-editor[data-styled] .cm-editor .cm-placeholder{color:var(--tx-code-editor-placeholder-color)}.tx-code-editor[data-styled] .cm-scroller .cm-content .cm-line.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-editor[data-styled] .cm-scroller .cm-content .cm-line.tx-code-wrap-indent{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-editor[data-styled] .tx-code-editor__bracket{border-radius:1px;background:var(--tx-code-editor-bracket-background);outline:1px solid var(--tx-code-editor-bracket-border-color)}.tx-code-editor[data-styled] .tx-code-editor__match{background:var(--tx-code-editor-search-match-background)}.tx-code-editor[data-styled] .tx-code-editor__match--current{background:var(--tx-code-editor-search-current-background)}.tx-code-editor[data-styled] .tx-code-editor__static{box-sizing:border-box;min-height:100%;height:100%;padding-block:var(--tx-code-editor-padding-block);overflow:auto;tab-size:var(--tx-code-editor-tab-size)}.tx-code-editor[data-styled] .tx-code-editor__static[hidden]{display:none}.tx-code-editor[data-styled] .tx-code-editor__static-line{display:flex;min-height:var(--tx-code-editor-line-height)}.tx-code-editor[data-styled] .tx-code-editor__static-number{position:sticky;left:0;flex:none;box-sizing:content-box;min-width:var(--tx-code-editor-gutter-min-digits);padding:0 var(--tx-code-editor-gutter-gap) 0 var(--tx-code-editor-gutter-padding-start);background:var(--tx-code-editor-gutter-background);color:var(--tx-code-editor-gutter-color);text-align:right;-webkit-user-select:none;user-select:none}.tx-code-editor[data-styled] .tx-code-editor__static-text{flex:1 1 auto;padding-inline:var(--tx-code-line-start) var(--tx-code-editor-padding-inline-end);white-space:pre}.tx-code-editor[data-styled] .tx-code-editor__static-text.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-editor[data-styled].tx-code-editor--wrap .tx-code-editor__static-text{min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}.tx-code-editor[data-styled].tx-code-editor--wrap .tx-code-editor__static-text[style*=--tx-code-wrap-indent]{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-editor[data-styled] .tx-code-editor__static-line:first-child .tx-code-editor__static-number{color:var(--tx-code-editor-gutter-active-color)}.tx-code-editor[data-styled] .tx-code-editor__static-line:first-child .tx-code-editor__static-text{box-shadow:inset 0 0 0 var(--tx-code-editor-active-line-border-width) var(--tx-code-editor-active-line-border-color)}.tx-code-editor[data-styled] .tx-code-editor__static-placeholder{color:var(--tx-code-editor-placeholder-color)}.tx-code-editor[data-styled] .tx-code-editor__search{position:absolute;z-index:3;top:var(--tx-code-editor-search-widget-top);right:var(--tx-code-editor-search-widget-end);display:flex;align-items:flex-start;gap:var(--tx-code-editor-search-widget-gap);box-sizing:border-box;width:min(var(--tx-code-editor-search-widget-width),100% - 2 * var(--tx-code-editor-search-widget-end));padding:var(--tx-code-editor-search-widget-padding);border-radius:0 0 var(--tx-code-editor-search-widget-border-radius) var(--tx-code-editor-search-widget-border-radius);background:var(--tx-code-editor-search-widget-background);box-shadow:var(--tx-code-editor-search-widget-shadow);color:var(--tx-code-editor-search-widget-color);font-family:var(--tx-font-family);animation:tx-code-editor-search-in var(--tx-motion-duration) ease-out}.tx-code-editor[data-styled] .tx-code-editor__search-rows{display:flex;flex:1 1 auto;flex-direction:column;gap:var(--tx-code-editor-search-widget-gap);min-width:0}.tx-code-editor[data-styled] .tx-code-editor__search-row{display:flex;align-items:center;gap:var(--tx-code-editor-search-widget-gap)}.tx-code-editor[data-styled] .tx-code-editor__search-field{position:relative;flex:1 1 auto;min-width:0}.tx-code-editor[data-styled] .tx-code-editor__search-input{width:100%}.tx-code-editor[data-styled] .tx-code-editor__search-row:first-child .tx-code-editor__search-input{padding-inline-end:72px}.tx-code-editor[data-styled] .tx-code-editor__search-options{position:absolute;top:50%;right:3px;display:flex;gap:1px;transform:translateY(-50%)}.tx-code-editor[data-styled] .tx-code-editor__search-option{display:inline-grid;place-items:center;width:22px;height:22px;padding:0;border:1px solid transparent;border-radius:var(--tx-radius-sm);background:transparent;color:var(--tx-text-muted);font:var(--tx-font-weight-semibold) 11px/1 var(--tx-font-family);cursor:pointer;transition:background-color var(--tx-motion-duration),color var(--tx-motion-duration),border-color var(--tx-motion-duration)}.tx-code-editor[data-styled] .tx-code-editor__search-option:hover{background:color-mix(in srgb,var(--tx-text-primary) 8%,transparent);color:var(--tx-text-primary)}.tx-code-editor[data-styled] .tx-code-editor__search-option:focus-visible{outline:2px solid var(--tx-focus-ring-color);outline-offset:-1px}.tx-code-editor[data-styled] .tx-code-editor__search-option[aria-pressed=true]{border-color:var(--tx-primary-base);background:color-mix(in srgb,var(--tx-primary-base) 14%,transparent);color:var(--tx-primary-base)}.tx-code-editor[data-styled] .tx-code-editor__search-option--word{text-decoration:underline;text-underline-offset:2px}.tx-code-editor[data-styled] .tx-code-editor__search-count{flex:none;min-width:76px;color:var(--tx-code-editor-search-count-color);font-size:var(--tx-code-editor-search-count-font-size);white-space:nowrap}@keyframes tx-code-editor-search-in{0%{transform:translateY(-100%)}}@media(prefers-reduced-motion:reduce){.tx-code-editor[data-styled]{transition:none}.tx-code-editor[data-styled] .tx-code-editor__search{animation:none}}\n"],
2760
+ dependencies: [
2761
+ {
2762
+ kind: "component",
2763
+ type: TxButton,
2764
+ selector: "button[txButton], a[txButton]",
2765
+ inputs: [
2766
+ "label",
2767
+ "severity",
2768
+ "size",
2769
+ "variant",
2770
+ "outlined",
2771
+ "text",
2772
+ "link",
2773
+ "rounded",
2774
+ "raised",
2775
+ "plain",
2776
+ "fluid",
2777
+ "disabled",
2778
+ "tabindex",
2779
+ "icon",
2780
+ "iconPos",
2781
+ "iconOnly",
2782
+ "loading",
2783
+ "loadingIcon",
2784
+ "badge",
2785
+ "badgeSeverity",
2786
+ "dt",
2787
+ "pt",
2788
+ "ptOptions",
2789
+ "unstyled"
2790
+ ]
2791
+ },
2792
+ {
2793
+ kind: "directive",
2794
+ type: TxInput,
2795
+ selector: "input[txInput], textarea[txInput]",
2796
+ inputs: [
2797
+ "invalid",
2798
+ "size",
2799
+ "variant",
2800
+ "fluid",
2801
+ "dt",
2802
+ "pt",
2803
+ "ptOptions",
2804
+ "unstyled"
2805
+ ]
2806
+ },
2807
+ {
2808
+ kind: "component",
2809
+ type: TxCodeDiff,
2810
+ selector: "tx-code-diff",
2811
+ inputs: [
2812
+ "original",
2813
+ "value",
2814
+ "language",
2815
+ "view",
2816
+ "readOnly",
2817
+ "lineNumbers",
2818
+ "wordWrap",
2819
+ "indentGuides",
2820
+ "ignoreTrimWhitespace",
2821
+ "scrollToFirstChange",
2822
+ "height",
2823
+ "ariaLabel",
2824
+ "dt",
2825
+ "pt",
2826
+ "ptOptions",
2827
+ "unstyled"
2828
+ ],
2829
+ outputs: ["valueChange", "changed"]
2830
+ }
2831
+ ],
2832
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
2833
+ encapsulation: i0.ViewEncapsulation.None
2834
+ });
2835
+ };
2836
+ i0.ɵɵngDeclareClassMetadata({
2837
+ minVersion: "12.0.0",
2838
+ version: "22.2.5",
2839
+ ngImport: i0,
2840
+ type: TxCodeEditor,
2841
+ decorators: [{
2842
+ type: Component,
2843
+ args: [{
2844
+ selector: "tx-code-editor",
2845
+ imports: [
2846
+ TxButton,
2847
+ TxInput,
2848
+ TxCodeDiff
2849
+ ],
2850
+ encapsulation: ViewEncapsulation.None,
2851
+ changeDetection: ChangeDetectionStrategy.OnPush,
2852
+ providers: [{
2853
+ provide: NG_VALUE_ACCESSOR,
2854
+ useExisting: forwardRef(() => TxCodeEditor),
2855
+ multi: true
2856
+ }],
2857
+ host: {
2858
+ class: "tx-code-editor",
2859
+ "[class]": "passThrough().root?.class",
2860
+ "[style]": "hostStyle()",
2861
+ "[attr.data-styled]": "!isUnstyled() || null",
2862
+ "[attr.data-language]": "resolvedLanguage()",
2863
+ "[class.tx-code-editor--focused]": "focusedState()",
2864
+ "[class.tx-code-editor--invalid]": "isInvalid()",
2865
+ "[class.tx-code-editor--disabled]": "isDisabled()",
2866
+ "[class.tx-code-editor--readonly]": "readOnly()",
2867
+ "[class.tx-code-editor--wrap]": "wordWrap()",
2868
+ "[class.tx-code-editor--numbers]": "lineNumbers()",
2869
+ "[class.tx-code-editor--diff]": "diffMode()"
2870
+ },
2871
+ template: "@if (diffMode()) {\n <tx-code-diff\n class=\"tx-code-editor__diff\"\n [original]=\"originalValue()\"\n [value]=\"value()\"\n [language]=\"language()\"\n [view]=\"diffView()\"\n [readOnly]=\"readOnly() || isDisabled()\"\n [lineNumbers]=\"lineNumbers()\"\n [wordWrap]=\"wordWrap()\"\n [indentGuides]=\"indentGuides()\"\n [ariaLabel]=\"ariaLabel()\"\n [unstyled]=\"isUnstyled()\"\n height=\"100%\"\n (valueChange)=\"onDiffValue($event)\"\n (changed)=\"diffChanged.emit($event)\"\n />\n} @else {\n <div #mount class=\"tx-code-editor__mount\" [class]=\"passThrough().editor?.class\" [style]=\"passThrough().editor?.style\">\n @if (!ready()) {\n <div\n class=\"tx-code-editor__static\"\n role=\"textbox\"\n aria-multiline=\"true\"\n aria-readonly=\"true\"\n [attr.aria-label]=\"ariaLabel() ?? (ariaLabelledBy() ? null : t().codeEditorLabel)\"\n [attr.aria-labelledby]=\"ariaLabelledBy() ?? null\"\n >\n @for (line of staticLines(); track $index) {\n <div class=\"tx-code-editor__static-line\">\n @if (lineNumbers()) {\n <span class=\"tx-code-editor__static-number\" aria-hidden=\"true\">{{ line.number }}</span>\n }\n <span\n class=\"tx-code-editor__static-text\"\n [class.tx-code-guides]=\"indentGuides() && line.guides > 0\"\n [style.--tx-code-guides]=\"indentGuides() && line.guides > 0 ? line.guides : null\"\n [style.--tx-code-guide-step]=\"indentGuides() ? staticTabSize() + 'ch' : null\"\n [style.--tx-code-wrap-indent]=\"wordWrap() ? line.indent : null\"\n >@for (segment of line.segments; track $index) {<span [class]=\"segment.className\">{{ segment.text }}</span>}@if (\n staticEmpty() && placeholder()\n ) {<span class=\"tx-code-editor__static-placeholder\">{{ placeholder() }}</span>}</span\n >\n </div>\n }\n </div>\n }\n </div>\n @if (searchOpen()) {\n <div class=\"tx-code-editor__search\" role=\"search\" [class]=\"passThrough().search?.class\" [style]=\"passThrough().search?.style\">\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n class=\"tx-code-editor__search-expand\"\n [icon]=\"replaceOpen() ? 'chevron-down' : 'chevron-right'\"\n [attr.aria-label]=\"t().codeSearchToggleReplace\"\n [attr.aria-expanded]=\"replaceOpen()\"\n (click)=\"toggleReplace()\"\n ></button>\n <div class=\"tx-code-editor__search-rows\">\n <div class=\"tx-code-editor__search-row\">\n <div class=\"tx-code-editor__search-field\">\n <input\n #findInput\n txInput\n size=\"small\"\n class=\"tx-code-editor__search-input\"\n [class]=\"passThrough().searchInput?.class\"\n [invalid]=\"!searchResult().valid\"\n [value]=\"query()\"\n [placeholder]=\"t().codeSearchFind\"\n [attr.aria-label]=\"t().codeSearchFind\"\n (input)=\"onQuery($any($event.target).value)\"\n (keydown)=\"onSearchKeydown($event, 'find')\"\n />\n <div class=\"tx-code-editor__search-options\">\n <button\n type=\"button\"\n class=\"tx-code-editor__search-option\"\n [attr.aria-pressed]=\"matchCase()\"\n [attr.aria-label]=\"t().codeSearchMatchCase\"\n [attr.title]=\"t().codeSearchMatchCase\"\n (click)=\"toggleOption('matchCase')\"\n >\n Aa\n </button>\n <button\n type=\"button\"\n class=\"tx-code-editor__search-option tx-code-editor__search-option--word\"\n [attr.aria-pressed]=\"wholeWord()\"\n [attr.aria-label]=\"t().codeSearchWholeWord\"\n [attr.title]=\"t().codeSearchWholeWord\"\n (click)=\"toggleOption('wholeWord')\"\n >\n ab\n </button>\n <button\n type=\"button\"\n class=\"tx-code-editor__search-option\"\n [attr.aria-pressed]=\"regexp()\"\n [attr.aria-label]=\"t().codeSearchRegexp\"\n [attr.title]=\"t().codeSearchRegexp\"\n (click)=\"toggleOption('regexp')\"\n >\n .*\n </button>\n </div>\n </div>\n <span class=\"tx-code-editor__search-count\" aria-live=\"polite\">{{ countText() }}</span>\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n icon=\"arrow-up\"\n [disabled]=\"!searchResult().matches.length\"\n [attr.aria-label]=\"t().codeSearchPrevious\"\n (click)=\"findPrevious()\"\n ></button>\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n icon=\"arrow-down\"\n [disabled]=\"!searchResult().matches.length\"\n [attr.aria-label]=\"t().codeSearchNext\"\n (click)=\"findNext()\"\n ></button>\n <button txButton type=\"button\" text plain size=\"small\" icon=\"times\" [attr.aria-label]=\"t().codeSearchClose\" (click)=\"closeSearch()\"></button>\n </div>\n @if (replaceOpen()) {\n <div class=\"tx-code-editor__search-row\">\n <div class=\"tx-code-editor__search-field\">\n <input\n #replaceInput\n txInput\n size=\"small\"\n class=\"tx-code-editor__search-input\"\n [value]=\"replacement()\"\n [placeholder]=\"t().codeSearchReplace\"\n [attr.aria-label]=\"t().codeSearchReplace\"\n [readOnly]=\"readOnly() || isDisabled()\"\n (input)=\"replacement.set($any($event.target).value)\"\n (keydown)=\"onSearchKeydown($event, 'replace')\"\n />\n </div>\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n icon=\"pen-line\"\n [disabled]=\"!searchResult().matches.length || readOnly() || isDisabled()\"\n [attr.aria-label]=\"t().codeSearchReplace\"\n (click)=\"replaceCurrent()\"\n ></button>\n <button\n txButton\n type=\"button\"\n text\n plain\n size=\"small\"\n icon=\"list-check\"\n [disabled]=\"!searchResult().matches.length || readOnly() || isDisabled()\"\n [attr.aria-label]=\"t().codeSearchReplaceAll\"\n (click)=\"replaceAll()\"\n ></button>\n </div>\n }\n </div>\n </div>\n }\n}\n",
2872
+ styles: [".tx-code-editor{position:relative;display:block;min-width:0}.tx-code-editor__mount,.tx-code-editor__diff{height:100%}.tx-code-editor[data-styled]{box-sizing:border-box;overflow:hidden;border:var(--tx-code-editor-border-width) solid var(--tx-code-editor-border-color);border-radius:var(--tx-code-editor-border-radius);background:var(--tx-code-editor-background);color:var(--tx-code-editor-color);font-family:var(--tx-code-editor-font-family);font-size:var(--tx-code-editor-font-size);line-height:var(--tx-code-editor-line-height);transition:border-color var(--tx-motion-duration)}.tx-code-editor[data-styled].tx-code-editor--focused{border-color:var(--tx-code-editor-focus-border-color)}.tx-code-editor[data-styled].tx-code-editor--invalid{border-color:var(--tx-code-editor-invalid-border-color)}.tx-code-editor[data-styled].tx-code-editor--disabled{opacity:var(--tx-code-editor-disabled-opacity)}.tx-code-editor[data-styled].tx-code-editor--diff{border:none;border-radius:0;background:none}.tx-code-editor[data-styled] .cm-editor{height:100%;background:transparent;color:inherit}.tx-code-editor[data-styled] .cm-editor.cm-focused{outline:none}.tx-code-editor[data-styled] .cm-scroller{font-family:inherit;line-height:inherit}.tx-code-editor[data-styled] .cm-content{padding-block:var(--tx-code-editor-padding-block);caret-color:var(--tx-code-editor-cursor-color);tab-size:var(--tx-code-editor-tab-size)}.tx-code-editor[data-styled]{--tx-code-line-start: 0px}.tx-code-editor[data-styled]:not(.tx-code-editor--numbers){--tx-code-line-start: var(--tx-code-editor-padding-inline-end)}.tx-code-editor[data-styled] .cm-scroller .cm-content .cm-line{padding:0 var(--tx-code-editor-padding-inline-end) 0 var(--tx-code-line-start)}.tx-code-editor[data-styled] .cm-editor .cm-gutters{border:none;background:var(--tx-code-editor-gutter-background);color:var(--tx-code-editor-gutter-color)}.tx-code-editor[data-styled] .cm-editor .cm-lineNumbers .cm-gutterElement{box-sizing:content-box;min-width:var(--tx-code-editor-gutter-min-digits);padding:0 var(--tx-code-editor-gutter-gap) 0 var(--tx-code-editor-gutter-padding-start);text-align:right}.tx-code-editor[data-styled] .cm-editor .cm-activeLineGutter{background:transparent;color:var(--tx-code-editor-gutter-active-color)}.tx-code-editor[data-styled] .cm-editor .cm-content .cm-activeLine{background-color:transparent;box-shadow:inset 0 0 0 var(--tx-code-editor-active-line-border-width) var(--tx-code-editor-active-line-border-color)}.tx-code-editor[data-styled] .cm-editor .cm-cursorLayer .cm-cursor{border-left:var(--tx-code-editor-cursor-width) solid var(--tx-code-editor-cursor-color)}.tx-code-editor[data-styled] .cm-editor .cm-scroller .cm-selectionLayer .cm-selectionBackground{background:var(--tx-code-editor-selection-inactive-background)}.tx-code-editor[data-styled] .cm-editor.cm-focused .cm-scroller .cm-selectionLayer .cm-selectionBackground{background:var(--tx-code-editor-selection-background)}.tx-code-editor[data-styled] .cm-editor .cm-placeholder{color:var(--tx-code-editor-placeholder-color)}.tx-code-editor[data-styled] .cm-scroller .cm-content .cm-line.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-editor[data-styled] .cm-scroller .cm-content .cm-line.tx-code-wrap-indent{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-editor[data-styled] .tx-code-editor__bracket{border-radius:1px;background:var(--tx-code-editor-bracket-background);outline:1px solid var(--tx-code-editor-bracket-border-color)}.tx-code-editor[data-styled] .tx-code-editor__match{background:var(--tx-code-editor-search-match-background)}.tx-code-editor[data-styled] .tx-code-editor__match--current{background:var(--tx-code-editor-search-current-background)}.tx-code-editor[data-styled] .tx-code-editor__static{box-sizing:border-box;min-height:100%;height:100%;padding-block:var(--tx-code-editor-padding-block);overflow:auto;tab-size:var(--tx-code-editor-tab-size)}.tx-code-editor[data-styled] .tx-code-editor__static[hidden]{display:none}.tx-code-editor[data-styled] .tx-code-editor__static-line{display:flex;min-height:var(--tx-code-editor-line-height)}.tx-code-editor[data-styled] .tx-code-editor__static-number{position:sticky;left:0;flex:none;box-sizing:content-box;min-width:var(--tx-code-editor-gutter-min-digits);padding:0 var(--tx-code-editor-gutter-gap) 0 var(--tx-code-editor-gutter-padding-start);background:var(--tx-code-editor-gutter-background);color:var(--tx-code-editor-gutter-color);text-align:right;-webkit-user-select:none;user-select:none}.tx-code-editor[data-styled] .tx-code-editor__static-text{flex:1 1 auto;padding-inline:var(--tx-code-line-start) var(--tx-code-editor-padding-inline-end);white-space:pre}.tx-code-editor[data-styled] .tx-code-editor__static-text.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}.tx-code-editor[data-styled].tx-code-editor--wrap .tx-code-editor__static-text{min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}.tx-code-editor[data-styled].tx-code-editor--wrap .tx-code-editor__static-text[style*=--tx-code-wrap-indent]{padding-inline-start:calc(var(--tx-code-line-start) + var(--tx-code-wrap-indent));text-indent:calc(-1 * var(--tx-code-wrap-indent))}.tx-code-editor[data-styled] .tx-code-editor__static-line:first-child .tx-code-editor__static-number{color:var(--tx-code-editor-gutter-active-color)}.tx-code-editor[data-styled] .tx-code-editor__static-line:first-child .tx-code-editor__static-text{box-shadow:inset 0 0 0 var(--tx-code-editor-active-line-border-width) var(--tx-code-editor-active-line-border-color)}.tx-code-editor[data-styled] .tx-code-editor__static-placeholder{color:var(--tx-code-editor-placeholder-color)}.tx-code-editor[data-styled] .tx-code-editor__search{position:absolute;z-index:3;top:var(--tx-code-editor-search-widget-top);right:var(--tx-code-editor-search-widget-end);display:flex;align-items:flex-start;gap:var(--tx-code-editor-search-widget-gap);box-sizing:border-box;width:min(var(--tx-code-editor-search-widget-width),100% - 2 * var(--tx-code-editor-search-widget-end));padding:var(--tx-code-editor-search-widget-padding);border-radius:0 0 var(--tx-code-editor-search-widget-border-radius) var(--tx-code-editor-search-widget-border-radius);background:var(--tx-code-editor-search-widget-background);box-shadow:var(--tx-code-editor-search-widget-shadow);color:var(--tx-code-editor-search-widget-color);font-family:var(--tx-font-family);animation:tx-code-editor-search-in var(--tx-motion-duration) ease-out}.tx-code-editor[data-styled] .tx-code-editor__search-rows{display:flex;flex:1 1 auto;flex-direction:column;gap:var(--tx-code-editor-search-widget-gap);min-width:0}.tx-code-editor[data-styled] .tx-code-editor__search-row{display:flex;align-items:center;gap:var(--tx-code-editor-search-widget-gap)}.tx-code-editor[data-styled] .tx-code-editor__search-field{position:relative;flex:1 1 auto;min-width:0}.tx-code-editor[data-styled] .tx-code-editor__search-input{width:100%}.tx-code-editor[data-styled] .tx-code-editor__search-row:first-child .tx-code-editor__search-input{padding-inline-end:72px}.tx-code-editor[data-styled] .tx-code-editor__search-options{position:absolute;top:50%;right:3px;display:flex;gap:1px;transform:translateY(-50%)}.tx-code-editor[data-styled] .tx-code-editor__search-option{display:inline-grid;place-items:center;width:22px;height:22px;padding:0;border:1px solid transparent;border-radius:var(--tx-radius-sm);background:transparent;color:var(--tx-text-muted);font:var(--tx-font-weight-semibold) 11px/1 var(--tx-font-family);cursor:pointer;transition:background-color var(--tx-motion-duration),color var(--tx-motion-duration),border-color var(--tx-motion-duration)}.tx-code-editor[data-styled] .tx-code-editor__search-option:hover{background:color-mix(in srgb,var(--tx-text-primary) 8%,transparent);color:var(--tx-text-primary)}.tx-code-editor[data-styled] .tx-code-editor__search-option:focus-visible{outline:2px solid var(--tx-focus-ring-color);outline-offset:-1px}.tx-code-editor[data-styled] .tx-code-editor__search-option[aria-pressed=true]{border-color:var(--tx-primary-base);background:color-mix(in srgb,var(--tx-primary-base) 14%,transparent);color:var(--tx-primary-base)}.tx-code-editor[data-styled] .tx-code-editor__search-option--word{text-decoration:underline;text-underline-offset:2px}.tx-code-editor[data-styled] .tx-code-editor__search-count{flex:none;min-width:76px;color:var(--tx-code-editor-search-count-color);font-size:var(--tx-code-editor-search-count-font-size);white-space:nowrap}@keyframes tx-code-editor-search-in{0%{transform:translateY(-100%)}}@media(prefers-reduced-motion:reduce){.tx-code-editor[data-styled]{transition:none}.tx-code-editor[data-styled] .tx-code-editor__search{animation:none}}\n"]
2873
+ }]
2874
+ }],
2875
+ ctorParameters: () => [],
2876
+ propDecorators: {
2877
+ value: [{
2878
+ type: i0.Input,
2879
+ args: [{
2880
+ isSignal: true,
2881
+ alias: "value",
2882
+ required: false
2883
+ }]
2884
+ }, {
2885
+ type: i0.Output,
2886
+ args: ["valueChange"]
2887
+ }],
2888
+ language: [{
2889
+ type: i0.Input,
2890
+ args: [{
2891
+ isSignal: true,
2892
+ alias: "language",
2893
+ required: false
2894
+ }]
2895
+ }],
2896
+ height: [{
2897
+ type: i0.Input,
2898
+ args: [{
2899
+ isSignal: true,
2900
+ alias: "height",
2901
+ required: false
2902
+ }]
2903
+ }],
2904
+ readOnly: [{
2905
+ type: i0.Input,
2906
+ args: [{
2907
+ isSignal: true,
2908
+ alias: "readOnly",
2909
+ required: false
2910
+ }]
2911
+ }],
2912
+ lineNumbers: [{
2913
+ type: i0.Input,
2914
+ args: [{
2915
+ isSignal: true,
2916
+ alias: "lineNumbers",
2917
+ required: false
2918
+ }]
2919
+ }],
2920
+ wordWrap: [{
2921
+ type: i0.Input,
2922
+ args: [{
2923
+ isSignal: true,
2924
+ alias: "wordWrap",
2925
+ required: false
2926
+ }]
2927
+ }],
2928
+ indentGuides: [{
2929
+ type: i0.Input,
2930
+ args: [{
2931
+ isSignal: true,
2932
+ alias: "indentGuides",
2933
+ required: false
2934
+ }]
2935
+ }],
2936
+ tabSize: [{
2937
+ type: i0.Input,
2938
+ args: [{
2939
+ isSignal: true,
2940
+ alias: "tabSize",
2941
+ required: false
2942
+ }]
2943
+ }],
2944
+ placeholder: [{
2945
+ type: i0.Input,
2946
+ args: [{
2947
+ isSignal: true,
2948
+ alias: "placeholder",
2949
+ required: false
2950
+ }]
2951
+ }],
2952
+ search: [{
2953
+ type: i0.Input,
2954
+ args: [{
2955
+ isSignal: true,
2956
+ alias: "search",
2957
+ required: false
2958
+ }]
2959
+ }],
2960
+ disabled: [{
2961
+ type: i0.Input,
2962
+ args: [{
2963
+ isSignal: true,
2964
+ alias: "disabled",
2965
+ required: false
2966
+ }]
2967
+ }],
2968
+ invalid: [{
2969
+ type: i0.Input,
2970
+ args: [{
2971
+ isSignal: true,
2972
+ alias: "invalid",
2973
+ required: false
2974
+ }]
2975
+ }],
2976
+ ariaLabel: [{
2977
+ type: i0.Input,
2978
+ args: [{
2979
+ isSignal: true,
2980
+ alias: "ariaLabel",
2981
+ required: false
2982
+ }]
2983
+ }],
2984
+ ariaLabelledBy: [{
2985
+ type: i0.Input,
2986
+ args: [{
2987
+ isSignal: true,
2988
+ alias: "ariaLabelledBy",
2989
+ required: false
2990
+ }]
2991
+ }],
2992
+ diffMode: [{
2993
+ type: i0.Input,
2994
+ args: [{
2995
+ isSignal: true,
2996
+ alias: "diffMode",
2997
+ required: false
2998
+ }]
2999
+ }],
3000
+ originalValue: [{
3001
+ type: i0.Input,
3002
+ args: [{
3003
+ isSignal: true,
3004
+ alias: "originalValue",
3005
+ required: false
3006
+ }]
3007
+ }],
3008
+ diffView: [{
3009
+ type: i0.Input,
3010
+ args: [{
3011
+ isSignal: true,
3012
+ alias: "diffView",
3013
+ required: false
3014
+ }]
3015
+ }],
3016
+ dt: [{
3017
+ type: i0.Input,
3018
+ args: [{
3019
+ isSignal: true,
3020
+ alias: "dt",
3021
+ required: false
3022
+ }]
3023
+ }],
3024
+ pt: [{
3025
+ type: i0.Input,
3026
+ args: [{
3027
+ isSignal: true,
3028
+ alias: "pt",
3029
+ required: false
3030
+ }]
3031
+ }],
3032
+ ptOptions: [{
3033
+ type: i0.Input,
3034
+ args: [{
3035
+ isSignal: true,
3036
+ alias: "ptOptions",
3037
+ required: false
3038
+ }]
3039
+ }],
3040
+ unstyled: [{
3041
+ type: i0.Input,
3042
+ args: [{
3043
+ isSignal: true,
3044
+ alias: "unstyled",
3045
+ required: false
3046
+ }]
3047
+ }],
3048
+ codeChanged: [{
3049
+ type: i0.Output,
3050
+ args: ["codeChanged"]
3051
+ }],
3052
+ focused: [{
3053
+ type: i0.Output,
3054
+ args: ["focused"]
3055
+ }],
3056
+ blurred: [{
3057
+ type: i0.Output,
3058
+ args: ["blurred"]
3059
+ }],
3060
+ diffChanged: [{
3061
+ type: i0.Output,
3062
+ args: ["diffChanged"]
3063
+ }],
3064
+ mount: [{
3065
+ type: i0.ViewChild,
3066
+ args: ["mount", { isSignal: true }]
3067
+ }],
3068
+ findInput: [{
3069
+ type: i0.ViewChild,
3070
+ args: ["findInput", { isSignal: true }]
3071
+ }],
3072
+ replaceInput: [{
3073
+ type: i0.ViewChild,
3074
+ args: ["replaceInput", { isSignal: true }]
3075
+ }]
3076
+ }
3077
+ });
3078
+ export { TxCodeDiff, TxCodeEditor, diffCode, diffSequences, findMatches, rangesByLine, replacementFor, searchMarks, searchPattern, setSearchMarks, splitDiffLines, summarizeDiff };
3079
+
3080
+ //# sourceMappingURL=tectra-ng-code-editor.mjs.map