@drghaliasri/butex 3.2.2

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,366 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type ArabicNodeJson = {
4
+ node_type: string;
5
+ expr?: string;
6
+ name?: string;
7
+ superscript?: ChainJson | null;
8
+ subscript?: ChainJson | null;
9
+ left_delim_expr?: string;
10
+ right_delim_expr?: string;
11
+ inner_expr?: ChainJson;
12
+ optional_args?: ChainJson[];
13
+ mandatory_args?: ChainJson[];
14
+ opening?: string;
15
+ closing?: string;
16
+ lines?: ChainJson[];
17
+ };
18
+ type ChainJson = {
19
+ node_type: 'ChainClass';
20
+ chain: ArabicNodeJson[];
21
+ };
22
+ declare class State {
23
+ }
24
+ declare class BaseAstNode {
25
+ state: State;
26
+ superscript: ChainNode | null;
27
+ subscript: ChainNode | null;
28
+ nodeType: string;
29
+ constructor(state?: State | null);
30
+ latex(): string;
31
+ arabicLatex(): string;
32
+ toArabicLatex(): string;
33
+ /** Latin-style scripts: `^{...}` and `_{...}` for english_json rendering. */
34
+ latexScripts(): string;
35
+ /**
36
+ * Arabic scripts use \\prescript{sup}{sub}{content} (matches reference Python output).
37
+ * Call with rendered strings for sup/sub chains (may be empty strings).
38
+ */
39
+ arabicLatexScripts(sup: string, sub: string, content: string): string;
40
+ }
41
+ declare class ChainNode {
42
+ chain: BaseAstNode[];
43
+ constructor(chain?: BaseAstNode[]);
44
+ latex(): string;
45
+ toEnglishLatex(): string;
46
+ /** RTL: reverse order relative to Latin chain (see test/ref_tests.txt). */
47
+ arabicLatex(): string;
48
+ toArabicLatex(): string;
49
+ }
50
+
51
+ type MathNode = {
52
+ nodeType: 'MathObject';
53
+ mathMode: string;
54
+ lines: ChainNode[];
55
+ closing: string;
56
+ };
57
+
58
+ type Document2MathOutput = 'svg' | 'chtml';
59
+ type MathObject2Json = {
60
+ node_type: 'MathObject';
61
+ math_mode: string;
62
+ lines: ChainJson[];
63
+ closing: string;
64
+ };
65
+ type Document2Json = {
66
+ node_type: 'DocumentObject';
67
+ blocks: Document2BlockJson[];
68
+ };
69
+ type Document2BlockJson = {
70
+ command: string;
71
+ value?: string;
72
+ math_objects?: MathObject2Json[];
73
+ options?: Record<string, string>;
74
+ closing?: string;
75
+ items?: Document2ListItemJson[];
76
+ rows?: string[][];
77
+ columns?: string;
78
+ };
79
+ type Document2ListItemJson = {
80
+ value: string;
81
+ math_objects?: MathObject2Json[];
82
+ blocks?: Document2BlockJson[];
83
+ };
84
+ type Document2Diagnostic = {
85
+ code: string;
86
+ message: string;
87
+ path: string;
88
+ };
89
+ type TextToken2 = {
90
+ id: string;
91
+ kind: 'text';
92
+ text: string;
93
+ };
94
+ type MathToken2 = {
95
+ id: string;
96
+ kind: 'math';
97
+ display: boolean;
98
+ opening: string;
99
+ closing: string;
100
+ source: string;
101
+ math: MathNode | null;
102
+ editable: boolean;
103
+ reason?: string;
104
+ sourceOwner: 'imported-structured' | 'raw' | 'editor';
105
+ };
106
+ type InlineToken2 = TextToken2 | MathToken2;
107
+ type InlineField2 = {
108
+ id: string;
109
+ tokens: InlineToken2[];
110
+ };
111
+ type TextBlock2 = {
112
+ id: string;
113
+ kind: 'textBlock';
114
+ command: '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph';
115
+ field: InlineField2;
116
+ };
117
+ type ListItem2 = {
118
+ id: string;
119
+ field: InlineField2;
120
+ blocks: Document2Block[];
121
+ };
122
+ type ListBlock2 = {
123
+ id: string;
124
+ kind: 'list';
125
+ command: '\\begin{itemize}' | '\\begin{enumerate}';
126
+ closing: '\\end{itemize}' | '\\end{enumerate}';
127
+ items: ListItem2[];
128
+ };
129
+ type TableBlock2 = {
130
+ id: string;
131
+ kind: 'table';
132
+ command: '\\begin{tabular}';
133
+ closing: '\\end{tabular}';
134
+ columns: string;
135
+ rows: InlineField2[][];
136
+ };
137
+ type ImageBlock2 = {
138
+ id: string;
139
+ kind: 'image';
140
+ command: '\\includegraphics';
141
+ value: string;
142
+ options: Record<string, string>;
143
+ };
144
+ type RawBlock2 = {
145
+ id: string;
146
+ kind: 'raw';
147
+ command: '\\raw';
148
+ value: string;
149
+ };
150
+ type Document2Block = TextBlock2 | ListBlock2 | TableBlock2 | ImageBlock2 | RawBlock2;
151
+ type Document2Node = {
152
+ nodeType: 'DocumentObject';
153
+ blocks: Document2Block[];
154
+ diagnostics: Document2Diagnostic[];
155
+ };
156
+ type PreviewInline2 = {
157
+ kind: 'text';
158
+ text: string;
159
+ } | {
160
+ kind: 'math';
161
+ id: string;
162
+ tex: string;
163
+ display: boolean;
164
+ output: Document2MathOutput;
165
+ editable: boolean;
166
+ };
167
+ type PreviewBlock2 = {
168
+ kind: 'heading';
169
+ id: string;
170
+ level: 1 | 2 | 3;
171
+ inlines: PreviewInline2[];
172
+ } | {
173
+ kind: 'paragraph';
174
+ id: string;
175
+ inlines: PreviewInline2[];
176
+ } | {
177
+ kind: 'list';
178
+ id: string;
179
+ ordered: boolean;
180
+ items: Array<{
181
+ id: string;
182
+ inlines: PreviewInline2[];
183
+ blocks: PreviewBlock2[];
184
+ }>;
185
+ } | {
186
+ kind: 'table';
187
+ id: string;
188
+ rows: PreviewInline2[][][];
189
+ } | {
190
+ kind: 'image';
191
+ id: string;
192
+ src: string;
193
+ options: Record<string, string>;
194
+ }
195
+ /** Preview-only: raw / unknown blocks are omitted from preview until we add proper rendering. */
196
+ | {
197
+ kind: 'omit';
198
+ id: string;
199
+ };
200
+
201
+ type EditorSide = 'english' | 'arabic';
202
+ type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'env' | 'atomicCommand' | 'atomicOperatorCommand';
203
+ type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
204
+ type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
205
+ type EnvColumnAlignment = 'l' | 'c' | 'r';
206
+ type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline';
207
+ type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
208
+ type EditorSyncState = 'synced' | 'diverged';
209
+ type EditorChain = {
210
+ id: string;
211
+ nodes: EditorNode[];
212
+ };
213
+ type EditorNode = {
214
+ id: string;
215
+ kind: EditorNodeKind;
216
+ expr: string;
217
+ characterFont?: CharacterFontId;
218
+ superscript: EditorChain | null;
219
+ subscript: EditorChain | null;
220
+ leftDelimExpr: string;
221
+ rightDelimExpr: string;
222
+ innerExpr: EditorChain | null;
223
+ numerator: EditorChain | null;
224
+ denominator: EditorChain | null;
225
+ radicand: EditorChain | null;
226
+ rootIndex: EditorChain | null;
227
+ envName: GridEnvName | null;
228
+ matrixStyle: MatrixEnvStyle | null;
229
+ matrixRows: EditorChain[][] | null;
230
+ columnAlignments: EnvColumnAlignment[] | null;
231
+ };
232
+ type EditorCaret = {
233
+ chainId: string;
234
+ index: number;
235
+ };
236
+ type EditorSelectionRange = {
237
+ chainId: string;
238
+ anchorIndex: number;
239
+ focusIndex: number;
240
+ };
241
+ type EditorSyncMap = Record<string, {
242
+ expr: EditorSyncState;
243
+ }>;
244
+ type EditorDebugEntry = {
245
+ timestamp: string;
246
+ command: string;
247
+ activeSide: EditorSide;
248
+ englishLatex: string;
249
+ arabicLatex: string;
250
+ renderOk: boolean;
251
+ renderError: string | null;
252
+ note: string;
253
+ };
254
+ type EditorSession = {
255
+ englishTree: EditorChain;
256
+ arabicTree: EditorChain;
257
+ activeSide: EditorSide;
258
+ /** When true, each typed letter/digit inserts a new char/number leaf; when false, merge into adjacent same-kind leaves. */
259
+ splitLeafTyping: boolean;
260
+ /** One-shot: when true, the next insertChar/insertNumber bypasses leaf-merge (used by Space in merge mode). */
261
+ forceSplitNextLeaf: boolean;
262
+ /** When true and active side is Arabic, merged number typing prepends digits (RTL-style); still mirrored on EN/AR. */
263
+ arabicReverseNumberTyping: boolean;
264
+ /** Font applied to newly typed char nodes. */
265
+ currentCharacterFont: CharacterFontId;
266
+ /** Digit glyph form used for editor display and LaTeX preview output. */
267
+ currentDigitForm: DigitFormId;
268
+ caret: EditorCaret;
269
+ /** Whole-node range selection inside a single chain (anchor==focus means no selection). */
270
+ selection: EditorSelectionRange | null;
271
+ selectedNodeId: string | null;
272
+ selectedStructureNodeId: string | null;
273
+ sync: EditorSyncMap;
274
+ debugLog: EditorDebugEntry[];
275
+ };
276
+
277
+ type ButexDocumentEditor2Props = {
278
+ initialDocument?: Document2Json | Document2Node;
279
+ className?: string;
280
+ debug?: boolean;
281
+ mathOutput?: Document2MathOutput;
282
+ onDocumentChange?: (document: Document2Node) => void;
283
+ onLatexChange?: (latex: string) => void;
284
+ };
285
+ type Document2InitialState = {
286
+ document: Document2Node;
287
+ error: string | null;
288
+ };
289
+ declare function resolveInitialDocument2(initialDocument: Document2Json | Document2Node | undefined): Document2InitialState;
290
+ declare function ButexDocumentEditor2({ initialDocument, className, debug, mathOutput, onDocumentChange, onLatexChange, }: ButexDocumentEditor2Props): react_jsx_runtime.JSX.Element;
291
+
292
+ type DocumentInsertToolbarProps = {
293
+ canUndo: boolean;
294
+ canRedo: boolean;
295
+ onUndo: () => void;
296
+ onRedo: () => void;
297
+ onAddSection: () => void;
298
+ onAddSubsection: () => void;
299
+ onAddSubsubsection: () => void;
300
+ onAddParagraph: () => void;
301
+ onAddInlineEquation: () => void;
302
+ onAddDisplayEquation: () => void;
303
+ onAddTable: (rowCount: number, colCount: number) => void;
304
+ onAddList: () => void;
305
+ onAddEnumerate: () => void;
306
+ onAddFigure: () => void;
307
+ };
308
+ declare function DocumentInsertToolbar({ canUndo, canRedo, onUndo, onRedo, onAddSection, onAddSubsection, onAddSubsubsection, onAddParagraph, onAddInlineEquation, onAddDisplayEquation, onAddTable, onAddList, onAddEnumerate, onAddFigure, }: DocumentInsertToolbarProps): react_jsx_runtime.JSX.Element;
309
+
310
+ declare function DocumentPreview({ blocks, output }: {
311
+ blocks: PreviewBlock2[];
312
+ output: Document2MathOutput;
313
+ }): react_jsx_runtime.JSX.Element;
314
+
315
+ type EquationMathMode = 'inline' | 'display';
316
+ type EquationDrawerProps = {
317
+ session: EditorSession;
318
+ reason?: string | null;
319
+ mathMode: EquationMathMode;
320
+ canDelete?: boolean;
321
+ onMathModeChange: (mode: EquationMathMode) => void;
322
+ onClose: () => void;
323
+ onSave: (session: EditorSession) => void;
324
+ onDelete?: () => void;
325
+ };
326
+ declare function EquationDrawer({ session, reason, mathMode, canDelete, onMathModeChange, onClose, onSave, onDelete, }: EquationDrawerProps): react_jsx_runtime.JSX.Element;
327
+
328
+ type InlineFieldProps = {
329
+ field: InlineField2;
330
+ blockId?: string;
331
+ mathOutput?: Document2MathOutput;
332
+ onTextChange: (fieldId: string, tokenId: string, text: string) => void;
333
+ onOpenMath: (token: MathToken2) => void;
334
+ onDeleteMath?: (tokenId: string) => void;
335
+ onFieldFocus?: (blockId: string, fieldId: string, textTokenId: string, caretOffset: number) => void;
336
+ onMathFocus?: (blockId: string, fieldId: string, tokenId: string) => void;
337
+ onFieldBlur?: () => void;
338
+ };
339
+ declare function InlineField({ field, blockId, mathOutput, onTextChange, onOpenMath, onDeleteMath, onFieldFocus, onMathFocus, onFieldBlur, }: InlineFieldProps): react_jsx_runtime.JSX.Element;
340
+
341
+ type MathChipProps = {
342
+ token: MathToken2;
343
+ output?: Document2MathOutput;
344
+ buttonRef?: (element: HTMLButtonElement | null) => void;
345
+ onOpen: (token: MathToken2) => void;
346
+ onDelete?: (tokenId: string) => void;
347
+ onFocus?: (tokenId: string) => void;
348
+ onRequestTextFocus?: (tokenId: string, direction: -1 | 1) => void;
349
+ onTextInputFromFocus?: (tokenId: string, text: string) => void;
350
+ };
351
+ declare function MathChip({ token, output, buttonRef, onOpen, onDelete, onFocus, onRequestTextFocus, onTextInputFromFocus, }: MathChipProps): react_jsx_runtime.JSX.Element;
352
+
353
+ type BuTeXMathOutput = 'chtml' | 'svg';
354
+
355
+ type MathIslandProps = {
356
+ id: string;
357
+ tex: string;
358
+ display: boolean;
359
+ output?: BuTeXMathOutput;
360
+ };
361
+ declare function MathIsland({ id, tex, display, output }: MathIslandProps): react_jsx_runtime.JSX.Element;
362
+
363
+ declare const DOCUMENT2_WIDGET_CSS = "\n.butex-document2-widget {\n --butex-document2-bg: var(--butex-bg, #f8fafc);\n --butex-document2-fg: var(--butex-fg, #0f172a);\n --butex-document2-muted: var(--butex-muted, #64748b);\n --butex-document2-panel: var(--butex-panel, #ffffff);\n --butex-document2-border: var(--butex-border, #e2e8f0);\n --butex-document2-accent: var(--butex-accent, #0d9488);\n --butex-document2-accent-bg: var(--butex-toolbar-hover-bg, rgba(13, 148, 136, 0.08));\n --butex-document2-focus-shadow: var(--butex-focus-shadow, rgba(13, 148, 136, 0.16));\n --butex-document2-danger: var(--butex-danger, #dc2626);\n --butex-document2-error: var(--butex-error, #b91c1c);\n --butex-document2-error-bg: var(--butex-error-bg, #fef2f2);\n --butex-document2-preview-bg: var(--butex-preview-bg, #ffffff);\n --butex-document2-preview-fg: var(--butex-preview-fg, var(--butex-document2-fg));\n --butex-document2-preview-font: \"Amiri\", \"Noto Serif Arabic\", Georgia, \"Times New Roman\", serif;\n --butex-document2-drawer-bg: var(--butex-document2-panel);\n --butex-document2-input-bg: #ffffff;\n --butex-document2-raw-bg: #f8fafc;\n --butex-document2-math-bg: var(--butex-document2-accent-bg);\n --butex-document2-math-border: rgba(13, 148, 136, 0.35);\n --butex-document2-text-token-bg: var(--butex-text-token-bg, color-mix(in srgb, var(--butex-document2-panel) 86%, var(--butex-document2-bg)));\n --butex-document2-text-token-border: var(--butex-text-token-border, color-mix(in srgb, var(--butex-document2-border) 86%, var(--butex-document2-muted)));\n --butex-document2-math-inline-bg: var(--butex-math-inline-bg, color-mix(in srgb, var(--butex-document2-accent) 10%, var(--butex-document2-panel)));\n --butex-document2-math-display-bg: var(--butex-math-display-bg, color-mix(in srgb, var(--butex-document2-accent) 7%, var(--butex-document2-bg)));\n --butex-document2-collapse-bg: var(--butex-collapse-bg, color-mix(in srgb, var(--butex-document2-muted) 8%, var(--butex-document2-panel)));\n --butex-document2-dev-bg: var(--butex-dev-bg, #fffbeb);\n --butex-document2-dev-border: var(--butex-dev-border, #fcd34d);\n --butex-document2-dev-code-bg: var(--butex-dev-inset-bg, #ffffff);\n --butex-document2-dev-code-fg: var(--butex-dev-inset-fg, var(--butex-document2-fg));\n box-sizing: border-box;\n color: var(--butex-document2-fg);\n direction: rtl;\n font-family: ui-sans-serif, system-ui, \"Segoe UI\", Tahoma, Arial, sans-serif;\n line-height: 1.45;\n}\n\n.butex-document2-widget *,\n.butex-document2-widget *::before,\n.butex-document2-widget *::after {\n box-sizing: inherit;\n}\n\n.butex-document2-widget__shell,\n.butex-document2-widget__editor-panel,\n.butex-document2-widget__blocks,\n.butex-document2-widget__dev,\n.butex-document2-widget__field {\n display: grid;\n gap: 10px;\n min-width: 0;\n}\n\n.butex-document2-widget__toolbar,\n.butex-document2-widget__panel,\n.butex-document2-widget__block,\n.butex-document2-widget__dev {\n background: var(--butex-document2-panel);\n border: 1px solid var(--butex-document2-border);\n border-radius: 12px;\n min-width: 0;\n padding: 12px;\n}\n\n.butex-document2-widget__toolbar {\n position: sticky;\n top: 0;\n z-index: 20;\n box-shadow: 0 4px 16px color-mix(in srgb, var(--butex-document2-fg) 6%, transparent);\n gap: 6px;\n}\n\n.butex-document2-widget__toolbar-insert {\n align-items: center;\n display: flex;\n flex: 1 1 auto;\n flex-wrap: wrap;\n gap: 6px;\n min-width: 0;\n}\n\n.butex-document2-widget__toolbar-group {\n align-items: center;\n border-inline-start: 1px solid color-mix(in srgb, var(--butex-document2-border) 75%, transparent);\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n padding-inline-start: 6px;\n}\n\n.butex-document2-widget__toolbar-group:first-child {\n border-inline-start: 0;\n padding-inline-start: 0;\n}\n\n.butex-document2-widget__icon-btn {\n align-items: center;\n background: var(--butex-document2-panel);\n border: 1px solid var(--butex-document2-border);\n border-radius: 8px;\n color: var(--butex-document2-fg);\n cursor: pointer;\n display: inline-flex;\n font-weight: 700;\n justify-content: center;\n line-height: 1;\n min-height: 30px;\n min-width: 30px;\n padding: 0 6px;\n}\n\n.butex-document2-widget__icon-btn:hover:not(:disabled),\n.butex-document2-widget__icon-btn[aria-pressed=\"true\"] {\n background: var(--butex-document2-accent-bg);\n border-color: var(--butex-document2-accent);\n}\n\n.butex-document2-widget__icon-btn:disabled {\n cursor: not-allowed;\n opacity: 0.45;\n}\n\n.butex-document2-widget__icon-btn--h1 {\n font-size: 1.15rem;\n}\n\n.butex-document2-widget__icon-btn--h2 {\n font-size: 1rem;\n}\n\n.butex-document2-widget__icon-btn--h3 {\n font-size: 0.88rem;\n}\n\n.butex-document2-widget__icon-math-inline {\n font-family: ui-monospace, Consolas, monospace;\n font-size: 0.78rem;\n font-weight: 600;\n}\n\n.butex-document2-widget__icon-math-display {\n font-size: 0.82rem;\n font-weight: 700;\n}\n\n.butex-document2-widget__block-actions {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n}\n\n.butex-document2-widget button.butex-document2-widget__block-collapse {\n align-items: center;\n background: var(--butex-document2-collapse-bg);\n border-color: color-mix(in srgb, var(--butex-document2-border) 70%, var(--butex-document2-muted));\n display: inline-flex;\n font-weight: 800;\n justify-content: center;\n min-height: 26px;\n min-width: 26px;\n padding: 0;\n}\n\n.butex-document2-widget__math-chip-wrap {\n align-items: center;\n display: inline-flex;\n gap: 2px;\n}\n\n.butex-document2-widget__math-chip-wrap[data-display=\"true\"] {\n flex: 1 1 100%;\n justify-content: center;\n width: 100%;\n}\n\n.butex-document2-widget__math-chip-delete {\n background: transparent;\n border: 1px solid color-mix(in srgb, var(--butex-document2-danger) 35%, var(--butex-document2-border));\n border-radius: 6px;\n color: var(--butex-document2-danger);\n cursor: pointer;\n font-size: 0.85rem;\n line-height: 1;\n min-height: 24px;\n min-width: 24px;\n padding: 0;\n}\n\n.butex-document2-widget__table-cell {\n flex: 1 1 8rem;\n min-width: 8rem;\n}\n\n.butex-document2-widget__block--table .butex-document2-widget__inline-text {\n min-height: 3.5em;\n min-width: min(12ch, 100%);\n}\n\n.butex-document2-widget__table-popover {\n display: inline-block;\n position: relative;\n}\n\n.butex-document2-widget__table-popover-panel {\n background: var(--butex-document2-panel);\n border: 1px solid var(--butex-document2-border);\n border-radius: 10px;\n box-shadow: 0 8px 24px color-mix(in srgb, var(--butex-document2-fg) 12%, transparent);\n display: grid;\n gap: 8px;\n inset-inline-end: 0;\n padding: 10px;\n position: absolute;\n top: calc(100% + 6px);\n width: min(220px, 70vw);\n z-index: 30;\n}\n\n.butex-document2-widget__table-popover-panel label {\n color: var(--butex-document2-muted);\n display: grid;\n font-size: 0.82rem;\n gap: 4px;\n}\n\n.butex-document2-widget__toolbar-row {\n align-items: center;\n border-block-end: 1px solid color-mix(in srgb, var(--butex-document2-border) 70%, transparent);\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-block-end: 8px;\n padding-block-end: 8px;\n width: 100%;\n}\n\n.butex-document2-widget__toolbar-row:last-child {\n border-block-end: 0;\n margin-block-end: 0;\n padding-block-end: 0;\n}\n\n.butex-document2-widget__toolbar-label {\n color: var(--butex-document2-muted);\n font-size: 0.78rem;\n font-weight: 600;\n margin-inline-end: 4px;\n white-space: nowrap;\n}\n\n.butex-document2-widget__block-header {\n align-items: center;\n border-block-end: 1px solid color-mix(in srgb, var(--butex-document2-border) 80%, transparent);\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n justify-content: space-between;\n margin-block-end: 10px;\n padding-block-end: 8px;\n}\n\n.butex-document2-widget__block-title {\n align-items: center;\n color: var(--butex-document2-fg);\n display: inline-flex;\n gap: 8px;\n font-weight: 700;\n}\n\n.butex-document2-widget__block--section .butex-document2-widget__block-title {\n font-size: 1.12rem;\n}\n\n.butex-document2-widget__block--subsection .butex-document2-widget__block-title {\n font-size: 1.04rem;\n}\n\n.butex-document2-widget__block--subsubsection .butex-document2-widget__block-title {\n font-size: 0.98rem;\n}\n\n.butex-document2-widget__block--paragraph .butex-document2-widget__block-title {\n color: var(--butex-document2-muted);\n font-size: 0.86rem;\n font-weight: 600;\n}\n\n.butex-document2-widget__block--list .butex-document2-widget__block-title,\n.butex-document2-widget__block--table .butex-document2-widget__block-title,\n.butex-document2-widget__block--image .butex-document2-widget__block-title,\n.butex-document2-widget__block--raw .butex-document2-widget__block-title {\n font-size: 0.9rem;\n}\n\n.butex-document2-widget__block--section {\n background: color-mix(in srgb, var(--butex-document2-accent) 9%, var(--butex-document2-panel));\n border-inline-start: 4px solid var(--butex-document2-accent);\n}\n\n.butex-document2-widget__block--subsection {\n background: color-mix(in srgb, var(--butex-document2-accent) 6%, var(--butex-document2-panel));\n border-inline-start: 3px solid color-mix(in srgb, var(--butex-document2-accent) 78%, var(--butex-document2-border));\n}\n\n.butex-document2-widget__block--subsubsection {\n background: color-mix(in srgb, var(--butex-document2-accent) 4%, var(--butex-document2-panel));\n border-inline-start: 3px solid var(--butex-document2-border);\n}\n\n.butex-document2-widget__block--paragraph {\n border-inline-start: 2px solid color-mix(in srgb, var(--butex-document2-muted) 35%, transparent);\n}\n\n.butex-document2-widget__block--list {\n background: color-mix(in srgb, var(--butex-document2-bg) 55%, var(--butex-document2-panel));\n border-inline-start: 3px solid color-mix(in srgb, var(--butex-document2-accent) 55%, var(--butex-document2-border));\n}\n\n.butex-document2-widget__block--table {\n background: color-mix(in srgb, var(--butex-document2-bg) 40%, var(--butex-document2-panel));\n border-inline-start: 3px solid var(--butex-document2-border);\n}\n\n.butex-document2-widget__block--image {\n background: color-mix(in srgb, var(--butex-document2-muted) 6%, var(--butex-document2-panel));\n border-inline-start: 3px dashed color-mix(in srgb, var(--butex-document2-muted) 45%, var(--butex-document2-border));\n}\n\n.butex-document2-widget__block--raw {\n background: color-mix(in srgb, var(--butex-document2-muted) 8%, var(--butex-document2-panel));\n border-inline-start: 3px dashed var(--butex-document2-muted);\n}\n\n.butex-document2-widget__block--collapsed {\n background: var(--butex-document2-collapse-bg);\n}\n\n.butex-document2-widget__block--collapsed .butex-document2-widget__block-header {\n margin-block-end: 8px;\n}\n\n.butex-document2-widget__block-summary {\n background: color-mix(in srgb, var(--butex-document2-panel) 72%, transparent);\n border: 1px dashed color-mix(in srgb, var(--butex-document2-border) 70%, var(--butex-document2-muted));\n border-radius: 8px;\n color: var(--butex-document2-muted);\n font-size: 0.86rem;\n line-height: 1.5;\n min-width: 0;\n overflow-wrap: anywhere;\n padding: 8px 10px;\n}\n\n.butex-document2-widget__list-item-actions {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-block-start: 6px;\n}\n\n.butex-document2-widget__list-footer {\n border-block-start: 1px dashed color-mix(in srgb, var(--butex-document2-border) 85%, transparent);\n margin-block-start: 10px;\n padding-block-start: 10px;\n}\n\n.butex-document2-widget__button--danger:hover {\n border-color: var(--butex-document2-danger);\n color: var(--butex-document2-danger);\n}\n\n.butex-document2-widget__image-src-label {\n color: var(--butex-document2-muted);\n display: block;\n font-size: 0.82rem;\n margin-block-end: 4px;\n}\n\n.butex-document2-widget__toolbar,\n.butex-document2-widget__row {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.butex-document2-widget button {\n background: var(--butex-document2-panel);\n border: 1px solid var(--butex-document2-border);\n border-radius: 8px;\n color: var(--butex-document2-fg);\n cursor: pointer;\n min-height: 32px;\n padding: 0 10px;\n}\n\n.butex-document2-widget button:hover,\n.butex-document2-widget button[aria-pressed=\"true\"] {\n background: var(--butex-document2-accent-bg);\n border-color: var(--butex-document2-accent);\n}\n\n.butex-document2-widget button:focus-visible,\n.butex-document2-widget input:focus-visible,\n.butex-document2-widget textarea:focus-visible {\n border-color: var(--butex-document2-accent);\n box-shadow: 0 0 0 3px var(--butex-document2-focus-shadow);\n outline: none;\n}\n\n.butex-document2-widget input {\n background: var(--butex-document2-input-bg);\n border: 1px solid var(--butex-document2-border);\n border-radius: 8px;\n color: var(--butex-document2-fg);\n font: inherit;\n min-height: 34px;\n padding: 7px 9px;\n}\n\n.butex-document2-widget textarea {\n background: var(--butex-document2-input-bg);\n border: 1px solid var(--butex-document2-border);\n border-radius: 8px;\n color: var(--butex-document2-fg);\n font: inherit;\n line-height: 1.45;\n padding: 7px 9px;\n}\n\n.butex-document2-widget__layout {\n align-items: start;\n display: grid;\n gap: 12px;\n grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);\n transition: grid-template-columns 0.22s ease;\n}\n\n.butex-document2-widget__layout--editor-open.butex-document2-widget__layout--preview-open {\n grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);\n}\n\n.butex-document2-widget__layout--editor-open.butex-document2-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);\n}\n\n.butex-document2-widget__layout--editor-closed.butex-document2-widget__layout--preview-open {\n grid-template-columns: minmax(0, 0fr) minmax(0, 1fr);\n}\n\n.butex-document2-widget__layout--editor-closed.butex-document2-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);\n}\n\n.butex-document2-widget__layout--preview-open {\n grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);\n}\n\n.butex-document2-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);\n}\n\n.butex-document2-widget__editor-panel,\n.butex-document2-widget__preview-panel {\n min-width: 0;\n opacity: 1;\n overflow-x: hidden;\n overflow-y: auto;\n transform: translateX(0);\n transition:\n opacity 0.18s ease,\n transform 0.22s ease,\n padding 0.22s ease,\n border-width 0.22s ease,\n box-shadow 0.22s ease;\n}\n\n.butex-document2-widget__layout--editor-closed .butex-document2-widget__editor-panel {\n border-width: 0;\n box-shadow: none;\n opacity: 0;\n padding-inline: 0;\n pointer-events: none;\n transform: translateX(10px);\n visibility: hidden;\n}\n\n.butex-document2-widget__layout--preview-closed .butex-document2-widget__preview-panel {\n border-width: 0;\n box-shadow: none;\n opacity: 0;\n padding-inline: 0;\n pointer-events: none;\n transform: translateX(-10px);\n visibility: hidden;\n}\n\n.butex-document2-widget__inline-field {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n max-width: 100%;\n min-width: 0;\n width: 100%;\n}\n\n.butex-document2-widget__inline-text {\n background: var(--butex-document2-text-token-bg);\n border-color: var(--butex-document2-text-token-border);\n box-sizing: border-box;\n flex: 0 1 auto;\n max-width: 100%;\n min-height: 2.75em;\n min-width: 3ch;\n overflow-wrap: break-word;\n overflow-y: hidden;\n resize: none;\n white-space: pre-wrap;\n width: auto;\n word-break: break-word;\n}\n\n.butex-document2-widget__inline-text:hover {\n border-color: color-mix(in srgb, var(--butex-document2-text-token-border) 55%, var(--butex-document2-accent));\n}\n\n.butex-document2-widget__inline-field input {\n min-width: 12ch;\n}\n\n.butex-document2-widget__math-chip {\n background: var(--butex-document2-math-inline-bg);\n border-color: color-mix(in srgb, var(--butex-document2-math-border) 70%, var(--butex-document2-accent));\n border-width: 1.5px;\n direction: ltr;\n display: inline-flex;\n font-family: inherit;\n gap: 4px;\n max-width: 100%;\n min-height: 30px;\n overflow: visible;\n padding: 3px 7px;\n unicode-bidi: isolate;\n}\n\n.butex-document2-widget__math-chip:hover,\n.butex-document2-widget__math-chip:focus-visible {\n background: color-mix(in srgb, var(--butex-document2-accent) 12%, var(--butex-document2-panel));\n border-color: var(--butex-document2-accent);\n}\n\n.butex-document2-widget__math-chip[data-editable=\"false\"] {\n border-style: dashed;\n color: var(--butex-document2-muted);\n}\n\n.butex-document2-widget__math-chip[data-display=\"true\"] {\n background: var(--butex-document2-math-display-bg);\n border-color: color-mix(in srgb, var(--butex-document2-accent) 50%, var(--butex-document2-border));\n border-width: 1.5px;\n border-radius: 10px;\n box-shadow: 0 5px 16px color-mix(in srgb, var(--butex-document2-fg) 8%, transparent);\n justify-content: center;\n margin-block: 4px;\n min-height: 54px;\n padding: 10px 12px;\n width: min(100%, 36rem);\n}\n\n.butex-document2-widget__preview {\n background: var(--butex-document2-preview-bg);\n color: var(--butex-document2-preview-fg);\n direction: rtl;\n font-family: var(--butex-document2-preview-font);\n font-size: 1.08rem;\n line-height: 1.9;\n max-width: 100%;\n min-width: 0;\n overflow-wrap: break-word;\n word-break: break-word;\n}\n\n.butex-document2-widget__preview h1,\n.butex-document2-widget__preview h2,\n.butex-document2-widget__preview h3,\n.butex-document2-widget__preview p,\n.butex-document2-widget__preview li {\n max-width: 100%;\n overflow-wrap: break-word;\n white-space: normal;\n word-break: break-word;\n}\n\n.butex-document2-widget__preview table {\n border-collapse: collapse;\n border: 1px solid #000000;\n margin: 12px 0;\n max-width: 100%;\n table-layout: fixed;\n width: 100%;\n}\n\n.butex-document2-widget__preview td {\n border: 1px solid #000000;\n max-width: 100%;\n overflow-wrap: break-word;\n padding: 6px 8px;\n white-space: normal;\n word-break: break-word;\n}\n\n.butex-document2-widget__math-island {\n direction: ltr;\n display: inline-block;\n line-height: normal;\n margin: 0 2px;\n overflow: visible;\n unicode-bidi: isolate;\n vertical-align: middle;\n}\n\n.butex-document2-widget__math-chip .butex-document2-widget__math-island {\n margin: 0;\n}\n\n.butex-document2-widget__math-island[data-render-state=\"loading\"] {\n opacity: 0.72;\n}\n\n.butex-document2-widget__math-island[data-render-state=\"error\"] {\n color: var(--butex-document2-error);\n font-family: ui-monospace, SFMono-Regular, Consolas, monospace;\n font-size: 0.88rem;\n max-width: 100%;\n overflow-wrap: anywhere;\n white-space: normal;\n}\n\n.butex-document2-widget__math-island[data-display=\"true\"] {\n display: block;\n margin: 10px 0;\n text-align: center;\n}\n\n.butex-document2-widget__math-chip .butex-document2-widget__math-island[data-display=\"true\"] {\n margin: 0;\n}\n\n.butex-document2-widget__raw {\n background: var(--butex-document2-raw-bg);\n border-radius: 8px;\n direction: ltr;\n padding: 8px;\n text-align: left;\n white-space: pre-wrap;\n}\n\n.butex-document2-widget__error {\n background: var(--butex-document2-error-bg);\n border: 1px solid var(--butex-document2-error);\n border-radius: 8px;\n color: var(--butex-document2-error);\n padding: 10px;\n}\n\n.butex-document2-widget__equation-modal {\n align-items: center;\n display: flex;\n inset: 0;\n justify-content: center;\n padding: 16px;\n position: fixed;\n z-index: 30;\n}\n\n.butex-document2-widget__equation-modal-backdrop {\n background: color-mix(in srgb, var(--butex-document2-fg) 34%, transparent);\n border: 0;\n cursor: pointer;\n display: block;\n height: 100%;\n inset: 0;\n margin: 0;\n padding: 0;\n position: absolute;\n width: 100%;\n}\n\n.butex-document2-widget__equation-modal-panel {\n background: var(--butex-document2-drawer-bg);\n border: 1px solid var(--butex-document2-border);\n border-radius: 12px;\n box-shadow: 0 18px 48px color-mix(in srgb, var(--butex-document2-fg) 18%, transparent);\n display: grid;\n gap: 12px;\n max-height: min(90vh, 900px);\n max-width: min(720px, 100%);\n overflow: auto;\n padding: 14px;\n position: relative;\n width: min(680px, 100%);\n z-index: 1;\n}\n\n/* Map document v2 tokens onto BuTeX equation editor chrome when embedded in this modal. */\n.butex-document2-widget__equation-modal-panel .butex-widget {\n --butex-bg: var(--butex-document2-bg);\n --butex-fg: var(--butex-document2-fg);\n --butex-muted: var(--butex-document2-muted);\n --butex-accent: var(--butex-document2-accent);\n --butex-accent-hover: color-mix(in srgb, var(--butex-document2-accent) 82%, #000000);\n --butex-toolbar-hover-bg: var(--butex-document2-accent-bg);\n --butex-toolbar-hover-border: var(--butex-document2-accent);\n --butex-danger: var(--butex-document2-danger);\n --butex-danger-bg: color-mix(in srgb, var(--butex-document2-danger) 12%, transparent);\n --butex-danger-border: color-mix(in srgb, var(--butex-document2-danger) 48%, transparent);\n --butex-on-accent: #ffffff;\n --butex-border: var(--butex-document2-border);\n --butex-panel: var(--butex-document2-panel);\n --butex-preview-bg: var(--butex-document2-preview-bg);\n --butex-preview-fg: var(--butex-document2-preview-fg);\n --butex-error: var(--butex-document2-error);\n --butex-error-bg: var(--butex-document2-error-bg);\n --butex-error-border: color-mix(in srgb, var(--butex-document2-error) 32%, var(--butex-document2-panel));\n --butex-shadow-md: 0 4px 14px color-mix(in srgb, var(--butex-document2-fg) 10%, transparent);\n --butex-dev-bg: var(--butex-document2-dev-bg);\n --butex-dev-border: var(--butex-document2-dev-border);\n --butex-dev-badge: var(--butex-dev-badge, #b45309);\n --butex-dev-badge-fg: var(--butex-dev-badge-fg, #ffffff);\n --butex-dev-muted: var(--butex-dev-muted, #92400e);\n --butex-dev-inset-bg: var(--butex-document2-dev-code-bg);\n --butex-dev-inset-border: color-mix(in srgb, var(--butex-document2-dev-border) 45%, transparent);\n --butex-dev-inset-fg: var(--butex-document2-dev-code-fg);\n --butex-surface-bg: linear-gradient(\n 180deg,\n var(--butex-document2-panel) 0%,\n color-mix(in srgb, var(--butex-document2-panel) 88%, var(--butex-document2-bg)) 100%\n );\n --butex-surface-fg: var(--butex-document2-fg);\n --butex-focus-border: color-mix(in srgb, var(--butex-document2-accent) 45%, transparent);\n --butex-focus-shadow: var(--butex-document2-focus-shadow);\n --butex-slot-hover: var(--butex-document2-accent-bg);\n --butex-selection-bg: color-mix(in srgb, var(--butex-document2-accent) 34%, transparent);\n --butex-selection-border: color-mix(in srgb, var(--butex-document2-accent) 90%, #0f172a);\n --butex-caret: var(--butex-document2-fg);\n --butex-node-hover: color-mix(in srgb, var(--butex-document2-muted) 14%, transparent);\n --butex-node-selected-bg: var(--butex-document2-accent-bg);\n --butex-node-selected-border: color-mix(in srgb, var(--butex-document2-accent) 45%, transparent);\n --butex-script-border: var(--butex-document2-border);\n --butex-script-bg: color-mix(in srgb, var(--butex-document2-bg) 35%, var(--butex-document2-panel));\n --butex-script-color: var(--butex-document2-muted);\n --butex-delim-color: var(--butex-document2-muted);\n --butex-frac-bar: currentColor;\n}\n\n.butex-document2-widget__dev {\n background: var(--butex-document2-dev-bg);\n border-color: var(--butex-document2-dev-border);\n}\n\n.butex-document2-widget__dev pre {\n background: var(--butex-document2-dev-code-bg);\n color: var(--butex-document2-dev-code-fg);\n direction: ltr;\n margin: 0;\n max-height: 220px;\n overflow: auto;\n padding: 10px;\n text-align: left;\n white-space: pre-wrap;\n}\n\n.butex-document2-widget__dev-diagnostic {\n background: rgba(251, 191, 36, 0.18);\n border: 1px solid rgba(217, 119, 6, 0.4);\n border-radius: 8px;\n color: #92400e;\n margin: 0;\n padding: 8px 10px;\n}\n\n@media (max-width: 900px) {\n .butex-document2-widget__layout {\n grid-template-columns: 1fr;\n }\n\n .butex-document2-widget__layout--preview-closed .butex-document2-widget__preview-panel {\n display: none;\n }\n\n .butex-document2-widget__layout--editor-closed .butex-document2-widget__editor-panel {\n display: none;\n }\n\n}\n\n@media (prefers-reduced-motion: reduce) {\n .butex-document2-widget__layout,\n .butex-document2-widget__editor-panel,\n .butex-document2-widget__preview-panel {\n transition: none;\n }\n}\n";
364
+ declare function injectBuTeXDocument2Styles(doc?: Document): void;
365
+
366
+ export { ButexDocumentEditor2, type ButexDocumentEditor2Props, DOCUMENT2_WIDGET_CSS, type Document2InitialState, DocumentInsertToolbar, type DocumentInsertToolbarProps, DocumentPreview, EquationDrawer, InlineField, MathChip, MathIsland, injectBuTeXDocument2Styles, resolveInitialDocument2 };