@tiptap/extension-mathematics 2.24.2 → 3.0.0-beta.11
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.
- package/LICENSE.md +21 -0
- package/dist/index.cjs +196 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -6
- package/dist/index.js +159 -156
- package/dist/index.js.map +1 -1
- package/package.json +14 -12
- package/src/MathematicsPlugin.ts +26 -29
- package/src/mathematics.ts +2 -2
- package/src/types.ts +7 -7
- package/dist/MathematicsPlugin.d.ts +0 -13
- package/dist/MathematicsPlugin.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -174
- package/dist/index.umd.js.map +0 -1
- package/dist/mathematics.d.ts +0 -7
- package/dist/mathematics.d.ts.map +0 -1
- package/dist/types.d.ts +0 -13
- package/dist/types.d.ts.map +0 -1
package/dist/index.umd.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/state'), require('@tiptap/pm/view'), require('katex')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/state', '@tiptap/pm/view', 'katex'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-mathematics"] = {}, global.core, global.state, global.view, global.katex));
|
|
5
|
-
})(this, (function (exports, core, state, view, katex) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Get the range of positions that have been affected by a transaction
|
|
9
|
-
*/
|
|
10
|
-
function getAffectedRange(newState, previousPluginState, isEditable, tr, state) {
|
|
11
|
-
const docSize = newState.doc.nodeSize - 2;
|
|
12
|
-
let minFrom = 0;
|
|
13
|
-
let maxTo = docSize;
|
|
14
|
-
if (previousPluginState.isEditable !== isEditable) {
|
|
15
|
-
// When the editable state changes, run on all nodes just to be safe
|
|
16
|
-
minFrom = 0;
|
|
17
|
-
maxTo = docSize;
|
|
18
|
-
}
|
|
19
|
-
else if (tr.docChanged) {
|
|
20
|
-
// When the document changes, only run on the nodes that have changed
|
|
21
|
-
minFrom = docSize;
|
|
22
|
-
maxTo = 0;
|
|
23
|
-
core.getChangedRanges(tr).forEach(range => {
|
|
24
|
-
// Purposefully over scan the range to ensure we catch all decorations
|
|
25
|
-
minFrom = Math.min(minFrom, range.newRange.from - 1, range.oldRange.from - 1);
|
|
26
|
-
maxTo = Math.max(maxTo, range.newRange.to + 1, range.oldRange.to + 1);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else if (tr.selectionSet) {
|
|
30
|
-
const { $from, $to } = state.selection;
|
|
31
|
-
const { $from: $newFrom, $to: $newTo } = newState.selection;
|
|
32
|
-
// When the selection changes, run on all the nodes between the old and new selection
|
|
33
|
-
minFrom = Math.min(
|
|
34
|
-
// Purposefully over scan the range to ensure we catch all decorations
|
|
35
|
-
$from.depth === 0 ? 0 : $from.before(), $newFrom.depth === 0 ? 0 : $newFrom.before());
|
|
36
|
-
maxTo = Math.max($to.depth === 0 ? maxTo : $to.after(), $newTo.depth === 0 ? maxTo : $newTo.after());
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
minFrom: Math.max(minFrom, 0),
|
|
40
|
-
maxTo: Math.min(maxTo, docSize),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const MathematicsPlugin = (options) => {
|
|
44
|
-
const { regex, katexOptions = {}, editor, shouldRender, } = options;
|
|
45
|
-
return new state.Plugin({
|
|
46
|
-
key: new state.PluginKey('mathematics'),
|
|
47
|
-
state: {
|
|
48
|
-
init() {
|
|
49
|
-
return { decorations: undefined, isEditable: undefined };
|
|
50
|
-
},
|
|
51
|
-
apply(tr, previousPluginState, state, newState) {
|
|
52
|
-
if (!tr.docChanged && !tr.selectionSet && previousPluginState.decorations) {
|
|
53
|
-
// Just reuse the existing decorations, since nothing should have changed
|
|
54
|
-
return previousPluginState;
|
|
55
|
-
}
|
|
56
|
-
const nextDecorationSet = (previousPluginState.decorations || view.DecorationSet.empty).map(tr.mapping, tr.doc);
|
|
57
|
-
const { selection } = newState;
|
|
58
|
-
const isEditable = editor.isEditable;
|
|
59
|
-
const decorationsToAdd = [];
|
|
60
|
-
const { minFrom, maxTo } = getAffectedRange(newState, previousPluginState, isEditable, tr, state);
|
|
61
|
-
newState.doc.nodesBetween(minFrom, maxTo, (node, pos) => {
|
|
62
|
-
const enabled = shouldRender(newState, pos, node);
|
|
63
|
-
if (node.isText && node.text && enabled) {
|
|
64
|
-
let match;
|
|
65
|
-
// eslint-disable-next-line no-cond-assign
|
|
66
|
-
while ((match = regex.exec(node.text))) {
|
|
67
|
-
const from = pos + match.index;
|
|
68
|
-
const to = from + match[0].length;
|
|
69
|
-
const content = match.slice(1).find(Boolean);
|
|
70
|
-
if (content) {
|
|
71
|
-
const selectionSize = selection.from - selection.to;
|
|
72
|
-
const anchorIsInside = selection.anchor >= from && selection.anchor <= to;
|
|
73
|
-
const rangeIsInside = selection.from >= from && selection.to <= to;
|
|
74
|
-
const isEditing = (selectionSize === 0 && anchorIsInside) || rangeIsInside;
|
|
75
|
-
if (
|
|
76
|
-
// Are the decorations already present?
|
|
77
|
-
nextDecorationSet.find(from, to, (deco) => isEditing === deco.isEditing
|
|
78
|
-
&& content === deco.content
|
|
79
|
-
&& isEditable === deco.isEditable
|
|
80
|
-
&& katexOptions === deco.katexOptions).length) {
|
|
81
|
-
// Decoration exists in set, no need to add it again
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
// Use an inline decoration to either hide original (preview is showing) or show it (editing "mode")
|
|
85
|
-
decorationsToAdd.push(view.Decoration.inline(from, to, {
|
|
86
|
-
class: isEditing && isEditable
|
|
87
|
-
? 'Tiptap-mathematics-editor'
|
|
88
|
-
: 'Tiptap-mathematics-editor Tiptap-mathematics-editor--hidden',
|
|
89
|
-
style: !isEditing || !isEditable
|
|
90
|
-
? 'display: inline-block; height: 0; opacity: 0; overflow: hidden; position: absolute; width: 0;'
|
|
91
|
-
: undefined,
|
|
92
|
-
}, {
|
|
93
|
-
content,
|
|
94
|
-
isEditable,
|
|
95
|
-
isEditing,
|
|
96
|
-
katexOptions,
|
|
97
|
-
}));
|
|
98
|
-
if (!isEditable || !isEditing) {
|
|
99
|
-
// Create decoration widget and add KaTeX preview if selection is not within the math-editor
|
|
100
|
-
decorationsToAdd.push(view.Decoration.widget(from, () => {
|
|
101
|
-
const element = document.createElement('span');
|
|
102
|
-
// TODO: changeable class names
|
|
103
|
-
element.classList.add('Tiptap-mathematics-render');
|
|
104
|
-
if (isEditable) {
|
|
105
|
-
element.classList.add('Tiptap-mathematics-render--editable');
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
katex.render(content, element, katexOptions);
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
element.innerHTML = content;
|
|
112
|
-
}
|
|
113
|
-
return element;
|
|
114
|
-
}, {
|
|
115
|
-
content,
|
|
116
|
-
isEditable,
|
|
117
|
-
isEditing,
|
|
118
|
-
katexOptions,
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
// Remove any decorations that exist at the same position, they will be replaced by the new decorations
|
|
126
|
-
const decorationsToRemove = decorationsToAdd.flatMap(deco => nextDecorationSet.find(deco.from, deco.to));
|
|
127
|
-
return {
|
|
128
|
-
decorations: nextDecorationSet
|
|
129
|
-
// Remove existing decorations that are going to be replaced
|
|
130
|
-
.remove(decorationsToRemove)
|
|
131
|
-
// Add any new decorations
|
|
132
|
-
.add(tr.doc, decorationsToAdd),
|
|
133
|
-
isEditable,
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
props: {
|
|
138
|
-
decorations(state) {
|
|
139
|
-
var _a, _b;
|
|
140
|
-
return (_b = (_a = this.getState(state)) === null || _a === void 0 ? void 0 : _a.decorations) !== null && _b !== void 0 ? _b : view.DecorationSet.empty;
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const defaultShouldRender = (state, pos) => {
|
|
147
|
-
const $pos = state.doc.resolve(pos);
|
|
148
|
-
const isInCodeBlock = $pos.parent.type.name === 'codeBlock';
|
|
149
|
-
return !isInCodeBlock;
|
|
150
|
-
};
|
|
151
|
-
const Mathematics = core.Extension.create({
|
|
152
|
-
name: 'Mathematics',
|
|
153
|
-
addOptions() {
|
|
154
|
-
return {
|
|
155
|
-
// eslint-disable-next-line no-useless-escape
|
|
156
|
-
regex: /\$([^\$]*)\$/gi,
|
|
157
|
-
katexOptions: undefined,
|
|
158
|
-
shouldRender: defaultShouldRender,
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
addProseMirrorPlugins() {
|
|
162
|
-
return [MathematicsPlugin({ ...this.options, editor: this.editor })];
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
exports.Mathematics = Mathematics;
|
|
167
|
-
exports.MathematicsPlugin = MathematicsPlugin;
|
|
168
|
-
exports.default = Mathematics;
|
|
169
|
-
exports.defaultShouldRender = defaultShouldRender;
|
|
170
|
-
|
|
171
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
172
|
-
|
|
173
|
-
}));
|
|
174
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/MathematicsPlugin.ts","../src/mathematics.ts"],"sourcesContent":["import { getChangedRanges } from '@tiptap/core'\nimport {\n EditorState, Plugin, PluginKey, Transaction,\n} from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\nimport katex from 'katex'\n\nimport { MathematicsOptionsWithEditor } from './types.js'\n\ntype DecoSpec = {\n isEditable: boolean;\n isEditing: boolean;\n katexOptions: MathematicsOptionsWithEditor['katexOptions'];\n content: string;\n};\n\ntype Deco = Omit<Decoration, 'spec'> & { spec: DecoSpec };\n\ntype PluginState =\n| { decorations: DecorationSet; isEditable: boolean }\n| { decorations: undefined; isEditable: undefined }\n\n/**\n * Get the range of positions that have been affected by a transaction\n */\nfunction getAffectedRange(newState: EditorState, previousPluginState: PluginState, isEditable: boolean, tr: Transaction, state: EditorState) {\n const docSize = newState.doc.nodeSize - 2\n let minFrom = 0\n let maxTo = docSize\n\n if (previousPluginState.isEditable !== isEditable) {\n // When the editable state changes, run on all nodes just to be safe\n minFrom = 0\n maxTo = docSize\n } else if (tr.docChanged) {\n // When the document changes, only run on the nodes that have changed\n minFrom = docSize\n maxTo = 0\n\n getChangedRanges(tr).forEach(range => {\n // Purposefully over scan the range to ensure we catch all decorations\n minFrom = Math.min(minFrom, range.newRange.from - 1, range.oldRange.from - 1)\n maxTo = Math.max(maxTo, range.newRange.to + 1, range.oldRange.to + 1)\n })\n } else if (tr.selectionSet) {\n const { $from, $to } = state.selection\n const { $from: $newFrom, $to: $newTo } = newState.selection\n\n // When the selection changes, run on all the nodes between the old and new selection\n minFrom = Math.min(\n // Purposefully over scan the range to ensure we catch all decorations\n $from.depth === 0 ? 0 : $from.before(),\n $newFrom.depth === 0 ? 0 : $newFrom.before(),\n )\n maxTo = Math.max(\n $to.depth === 0 ? maxTo : $to.after(),\n $newTo.depth === 0 ? maxTo : $newTo.after(),\n )\n }\n\n return {\n minFrom: Math.max(minFrom, 0),\n maxTo: Math.min(maxTo, docSize),\n }\n}\n\nexport const MathematicsPlugin = (options: MathematicsOptionsWithEditor) => {\n const {\n regex, katexOptions = {}, editor, shouldRender,\n } = options\n\n return new Plugin<PluginState>({\n key: new PluginKey('mathematics'),\n\n state: {\n init() {\n return { decorations: undefined, isEditable: undefined }\n },\n apply(tr, previousPluginState, state, newState) {\n\n if (!tr.docChanged && !tr.selectionSet && previousPluginState.decorations) {\n // Just reuse the existing decorations, since nothing should have changed\n return previousPluginState\n }\n\n const nextDecorationSet = (previousPluginState.decorations || DecorationSet.empty).map(\n tr.mapping,\n tr.doc,\n )\n const { selection } = newState\n const isEditable = editor.isEditable\n const decorationsToAdd = [] as Deco[]\n const { minFrom, maxTo } = getAffectedRange(newState, previousPluginState, isEditable, tr, state)\n\n newState.doc.nodesBetween(minFrom, maxTo, (node, pos) => {\n const enabled = shouldRender(newState, pos, node)\n\n if (node.isText && node.text && enabled) {\n let match: RegExpExecArray | null\n\n // eslint-disable-next-line no-cond-assign\n while ((match = regex.exec(node.text))) {\n const from = pos + match.index\n const to = from + match[0].length\n const content = match.slice(1).find(Boolean)\n\n if (content) {\n const selectionSize = selection.from - selection.to\n const anchorIsInside = selection.anchor >= from && selection.anchor <= to\n const rangeIsInside = selection.from >= from && selection.to <= to\n const isEditing = (selectionSize === 0 && anchorIsInside) || rangeIsInside\n\n if (\n // Are the decorations already present?\n nextDecorationSet.find(\n from,\n to,\n (deco: DecoSpec) => isEditing === deco.isEditing\n && content === deco.content\n && isEditable === deco.isEditable\n && katexOptions === deco.katexOptions,\n ).length\n ) {\n // Decoration exists in set, no need to add it again\n continue\n }\n // Use an inline decoration to either hide original (preview is showing) or show it (editing \"mode\")\n decorationsToAdd.push(\n Decoration.inline(\n from,\n to,\n {\n class:\n isEditing && isEditable\n ? 'Tiptap-mathematics-editor'\n : 'Tiptap-mathematics-editor Tiptap-mathematics-editor--hidden',\n style:\n !isEditing || !isEditable\n ? 'display: inline-block; height: 0; opacity: 0; overflow: hidden; position: absolute; width: 0;'\n : undefined,\n },\n {\n content,\n isEditable,\n isEditing,\n katexOptions,\n } satisfies DecoSpec,\n ),\n )\n\n if (!isEditable || !isEditing) {\n // Create decoration widget and add KaTeX preview if selection is not within the math-editor\n decorationsToAdd.push(\n Decoration.widget(\n from,\n () => {\n const element = document.createElement('span')\n\n // TODO: changeable class names\n element.classList.add('Tiptap-mathematics-render')\n\n if (isEditable) {\n element.classList.add('Tiptap-mathematics-render--editable')\n }\n\n try {\n katex.render(content!, element, katexOptions)\n } catch {\n element.innerHTML = content!\n }\n\n return element\n },\n {\n content,\n isEditable,\n isEditing,\n katexOptions,\n } satisfies DecoSpec,\n ),\n )\n }\n }\n }\n }\n })\n\n // Remove any decorations that exist at the same position, they will be replaced by the new decorations\n const decorationsToRemove = decorationsToAdd.flatMap(deco => nextDecorationSet.find(deco.from, deco.to))\n\n return {\n decorations: nextDecorationSet\n // Remove existing decorations that are going to be replaced\n .remove(decorationsToRemove)\n // Add any new decorations\n .add(tr.doc, decorationsToAdd),\n isEditable,\n }\n },\n },\n\n props: {\n decorations(state) {\n return this.getState(state)?.decorations ?? DecorationSet.empty\n },\n },\n })\n}\n","import { Extension } from '@tiptap/core'\nimport { EditorState } from '@tiptap/pm/state'\n\nimport { MathematicsPlugin } from './MathematicsPlugin.js'\nimport { MathematicsOptions } from './types.js'\n\nexport const defaultShouldRender = (state: EditorState, pos: number) => {\n const $pos = state.doc.resolve(pos)\n const isInCodeBlock = $pos.parent.type.name === 'codeBlock'\n\n return !isInCodeBlock\n}\n\nexport const Mathematics = Extension.create<MathematicsOptions>({\n name: 'Mathematics',\n\n addOptions() {\n return {\n // eslint-disable-next-line no-useless-escape\n regex: /\\$([^\\$]*)\\$/gi,\n katexOptions: undefined,\n shouldRender: defaultShouldRender,\n }\n },\n\n addProseMirrorPlugins() {\n return [MathematicsPlugin({ ...this.options, editor: this.editor })]\n },\n})\n\nexport default Mathematics\n"],"names":["getChangedRanges","Plugin","PluginKey","DecorationSet","Decoration","Extension"],"mappings":";;;;;;EAsBA;;EAEG;EACH,SAAS,gBAAgB,CAAC,QAAqB,EAAE,mBAAgC,EAAE,UAAmB,EAAE,EAAe,EAAE,KAAkB,EAAA;MACzI,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC;MACzC,IAAI,OAAO,GAAG,CAAC;MACf,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AAA,GAAA,CAAA,EAAA,GAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,WAAW,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAID,kBAAa,CAAC,KAAK;eAChE;EACF,SAAA;EACF,KAAA,CAAC;EACJ;;QCzMa,mBAAmB,GAAG,CAAC,KAAkB,EAAE,GAAW,KAAI;MACrE,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;MACnC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW;MAE3D,OAAO,CAAC,aAAa;EACvB;AAEa,QAAA,WAAW,GAAGE,cAAS,CAAC,MAAM,CAAqB;EAC9D,IAAA,IAAI,EAAE,aAAa;MAEnB,UAAU,GAAA;UACR,OAAO;;EAEL,YAAA,KAAK,EAAE,gBAAgB;EACvB,YAAA,YAAY,EAAE,SAAS;EACvB,YAAA,YAAY,EAAE,mBAAmB;WAClC;OACF;MAED,qBAAqB,GAAA;EACnB,QAAA,OAAO,CAAC,iBAAiB,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;OACrE;EACF,CAAA;;;;;;;;;;;;;"}
|
package/dist/mathematics.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import { EditorState } from '@tiptap/pm/state';
|
|
3
|
-
import { MathematicsOptions } from './types.js';
|
|
4
|
-
export declare const defaultShouldRender: (state: EditorState, pos: number) => boolean;
|
|
5
|
-
export declare const Mathematics: Extension<MathematicsOptions, any>;
|
|
6
|
-
export default Mathematics;
|
|
7
|
-
//# sourceMappingURL=mathematics.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mathematics.d.ts","sourceRoot":"","sources":["../src/mathematics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/C,eAAO,MAAM,mBAAmB,UAAW,WAAW,OAAO,MAAM,YAKlE,CAAA;AAED,eAAO,MAAM,WAAW,oCAetB,CAAA;AAEF,eAAe,WAAW,CAAA"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Editor } from '@tiptap/core';
|
|
2
|
-
import { Node } from '@tiptap/pm/model';
|
|
3
|
-
import { EditorState } from '@tiptap/pm/state';
|
|
4
|
-
import { KatexOptions } from 'katex';
|
|
5
|
-
export type MathematicsOptions = {
|
|
6
|
-
regex: RegExp;
|
|
7
|
-
katexOptions?: KatexOptions;
|
|
8
|
-
shouldRender: (state: EditorState, pos: number, node: Node) => boolean;
|
|
9
|
-
};
|
|
10
|
-
export type MathematicsOptionsWithEditor = MathematicsOptions & {
|
|
11
|
-
editor: Editor;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;CACxE,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA"}
|