@drghaliasri/butex 6.1.5 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -24,28 +24,8 @@ __export(react_entry_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(react_entry_exports);
26
26
 
27
- // src/react/matrixPickerCss.ts
28
- var MATRIX_PICKER_CSS = `
29
- .butex-widget .matrix-grid-picker,
30
- .butex-widget .matrix-grid-cell {
31
- box-sizing: border-box;
32
- }
33
- `.trim();
34
- var MATRIX_PICKER_STYLE_ID = "butex-matrix-picker-css";
35
- function injectMatrixPickerCss(doc) {
36
- const d = doc ?? (typeof document !== "undefined" ? document : void 0);
37
- if (!d || d.getElementById(MATRIX_PICKER_STYLE_ID)) {
38
- return;
39
- }
40
- const style = d.createElement("style");
41
- style.id = MATRIX_PICKER_STYLE_ID;
42
- style.textContent = MATRIX_PICKER_CSS;
43
- d.head.appendChild(style);
44
- }
45
- injectMatrixPickerCss();
46
-
47
27
  // src/react/ButexEditor.tsx
48
- var import_react = require("react");
28
+ var import_react4 = require("react");
49
29
 
50
30
  // src/editor/factory.ts
51
31
  var nextId = 1;
@@ -2740,7 +2720,22 @@ var EQUATION_EDITOR_MESSAGES = {
2740
2720
  matrixBrackets: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u0645\u0639\u0642\u0648\u0641\u064A\u0646",
2741
2721
  matrixBraces: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062D\u0627\u0635\u0631\u062A\u064A\u0646",
2742
2722
  matrixBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646",
2743
- matrixDoubleBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646 \u0645\u0632\u062F\u0648\u062C\u064A\u0646"
2723
+ matrixDoubleBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646 \u0645\u0632\u062F\u0648\u062C\u064A\u0646",
2724
+ compactToolbar: "\u0634\u0631\u064A\u0637 \u0623\u0648\u0627\u0645\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
2725
+ moreActions: "\u0627\u0644\u0645\u0632\u064A\u062F",
2726
+ commandCategories: "\u0641\u0626\u0627\u062A \u0627\u0644\u0623\u0648\u0627\u0645\u0631",
2727
+ back: "\u0631\u062C\u0648\u0639",
2728
+ closeActions: "\u0625\u063A\u0644\u0627\u0642 \u0627\u0644\u0623\u0648\u0627\u0645\u0631",
2729
+ matrices: "\u0627\u0644\u0645\u0635\u0641\u0648\u0641\u0627\u062A",
2730
+ typography: "\u0627\u0644\u062E\u0637 \u0648\u0627\u0644\u0625\u062F\u062E\u0627\u0644",
2731
+ digitForms: "\u0623\u0634\u0643\u0627\u0644 \u0627\u0644\u0623\u0631\u0642\u0627\u0645",
2732
+ commonMatrixSizes: "\u0623\u062D\u062C\u0627\u0645 \u0634\u0627\u0626\u0639\u0629",
2733
+ decreaseRows: "\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0635\u0641\u0648\u0641",
2734
+ increaseRows: "\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0635\u0641\u0648\u0641",
2735
+ decreaseColumns: "\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0623\u0639\u0645\u062F\u0629",
2736
+ increaseColumns: "\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0623\u0639\u0645\u062F\u0629",
2737
+ showPreview: "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629",
2738
+ hidePreview: "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629"
2744
2739
  },
2745
2740
  en: {
2746
2741
  undoRedo: "Undo and redo",
@@ -2852,7 +2847,22 @@ var EQUATION_EDITOR_MESSAGES = {
2852
2847
  matrixBrackets: "Matrix in brackets",
2853
2848
  matrixBraces: "Matrix in braces",
2854
2849
  matrixBars: "Matrix between bars",
2855
- matrixDoubleBars: "Matrix between double bars"
2850
+ matrixDoubleBars: "Matrix between double bars",
2851
+ compactToolbar: "Equation command toolbar",
2852
+ moreActions: "More",
2853
+ commandCategories: "Command categories",
2854
+ back: "Back",
2855
+ closeActions: "Close actions",
2856
+ matrices: "Matrices",
2857
+ typography: "Typography and input",
2858
+ digitForms: "Digit forms",
2859
+ commonMatrixSizes: "Common sizes",
2860
+ decreaseRows: "Decrease rows",
2861
+ increaseRows: "Increase rows",
2862
+ decreaseColumns: "Decrease columns",
2863
+ increaseColumns: "Increase columns",
2864
+ showPreview: "Show preview",
2865
+ hidePreview: "Hide preview"
2856
2866
  }
2857
2867
  };
2858
2868
  function equationEditorMessages(locale) {
@@ -5163,14 +5173,20 @@ var BUTEX_EDITOR_CSS = `
5163
5173
  ${BUTEX_FONT_FACE_CSS}
5164
5174
 
5165
5175
  .surface {
5176
+ background: var(--butex-surface-bg, linear-gradient(180deg, #ffffff 0%, #fafbfc 100%));
5166
5177
  border: 1px solid var(--butex-border, #e2e8f0);
5167
5178
  border-radius: 12px;
5168
- min-height: 100px;
5169
- padding: 8px 10px;
5170
- background: var(--butex-surface-bg, linear-gradient(180deg, #ffffff 0%, #fafbfc 100%));
5171
5179
  color: var(--butex-surface-fg, #0f172a);
5172
- outline: none;
5173
5180
  cursor: text;
5181
+ max-width: 100%;
5182
+ min-height: 100px;
5183
+ min-width: 0;
5184
+ outline: none;
5185
+ overflow-x: auto;
5186
+ overflow-y: hidden;
5187
+ overscroll-behavior-inline: contain;
5188
+ padding: 8px 10px;
5189
+ touch-action: pan-x pan-y;
5174
5190
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
5175
5191
  }
5176
5192
 
@@ -5235,6 +5251,17 @@ ${CHARACTER_FONT_CSS}
5235
5251
  50% { opacity: 0; }
5236
5252
  }
5237
5253
 
5254
+ @media (prefers-reduced-motion: reduce) {
5255
+ .surface {
5256
+ scroll-behavior: auto;
5257
+ transition: none;
5258
+ }
5259
+
5260
+ .caret {
5261
+ animation: none;
5262
+ }
5263
+ }
5264
+
5238
5265
  .node {
5239
5266
  display: inline-flex;
5240
5267
  align-items: stretch;
@@ -5366,6 +5393,42 @@ function injectBuTeXEditorStyles(doc) {
5366
5393
  }
5367
5394
 
5368
5395
  // src/editor/runtime.ts
5396
+ var CARET_REVEAL_GUTTER_PX = 8;
5397
+ function revealCaretInSurface(surfaceEl, caretEl) {
5398
+ const activeTarget = caretEl ?? surfaceEl.querySelector(".caret") ?? surfaceEl.querySelector(".node.selected");
5399
+ if (!activeTarget) {
5400
+ return;
5401
+ }
5402
+ const surfaceRect = surfaceEl.getBoundingClientRect();
5403
+ const targetRect = activeTarget.getBoundingClientRect();
5404
+ if (surfaceRect.width <= 0) {
5405
+ return;
5406
+ }
5407
+ const gutter = Math.min(CARET_REVEAL_GUTTER_PX, surfaceRect.width / 4);
5408
+ const visibleLeft = surfaceRect.left + gutter;
5409
+ const visibleRight = surfaceRect.right - gutter;
5410
+ const visibleWidth = visibleRight - visibleLeft;
5411
+ let delta = 0;
5412
+ if (targetRect.width > visibleWidth) {
5413
+ if (targetRect.right < visibleLeft) {
5414
+ delta = targetRect.right - visibleLeft;
5415
+ } else if (targetRect.left > visibleRight) {
5416
+ delta = targetRect.left - visibleRight;
5417
+ }
5418
+ } else if (targetRect.left < visibleLeft) {
5419
+ delta = targetRect.left - visibleLeft;
5420
+ } else if (targetRect.right > visibleRight) {
5421
+ delta = targetRect.right - visibleRight;
5422
+ }
5423
+ if (delta === 0) {
5424
+ return;
5425
+ }
5426
+ if (typeof surfaceEl.scrollBy === "function") {
5427
+ surfaceEl.scrollBy({ left: delta, behavior: "auto" });
5428
+ } else {
5429
+ surfaceEl.scrollLeft += delta;
5430
+ }
5431
+ }
5369
5432
  function createEditorRuntime(options) {
5370
5433
  const { surfaceEl, inputEl } = options;
5371
5434
  const buttonElements = options.buttonElements ?? {};
@@ -5383,6 +5446,16 @@ function createEditorRuntime(options) {
5383
5446
  let dragChanged = false;
5384
5447
  let composingInput = false;
5385
5448
  let pendingCompositionText = null;
5449
+ let caretRevealFrame = null;
5450
+ function scheduleCaretReveal() {
5451
+ if (caretRevealFrame !== null) {
5452
+ cancelAnimationFrame(caretRevealFrame);
5453
+ }
5454
+ caretRevealFrame = requestAnimationFrame(() => {
5455
+ caretRevealFrame = null;
5456
+ revealCaretInSurface(surfaceEl);
5457
+ });
5458
+ }
5386
5459
  function resetInputElement() {
5387
5460
  if (!inputEl) {
5388
5461
  return;
@@ -5749,6 +5822,7 @@ function createEditorRuntime(options) {
5749
5822
  surfaceEl.innerHTML = "";
5750
5823
  const activeTree = session[activeTreeKey(session.activeSide)];
5751
5824
  surfaceEl.appendChild(buildChain(activeTree));
5825
+ scheduleCaretReveal();
5752
5826
  if (initialKeyboardFocusPending) {
5753
5827
  requestAnimationFrame(focusInput);
5754
5828
  initialKeyboardFocusPending = false;
@@ -6064,6 +6138,10 @@ function createEditorRuntime(options) {
6064
6138
  const api = {
6065
6139
  render,
6066
6140
  destroy: () => {
6141
+ if (caretRevealFrame !== null) {
6142
+ cancelAnimationFrame(caretRevealFrame);
6143
+ caretRevealFrame = null;
6144
+ }
6067
6145
  surfaceEl.removeEventListener("keydown", onKeyDown);
6068
6146
  inputEl?.removeEventListener("keydown", onKeyDown);
6069
6147
  inputEl?.removeEventListener("beforeinput", onBeforeInput);
@@ -6619,6 +6697,210 @@ async function renderBuTeXMathIsland(tex, options = {}) {
6619
6697
  return node;
6620
6698
  }
6621
6699
 
6700
+ // src/react/matrixPickerCss.ts
6701
+ var MATRIX_PICKER_CSS = `
6702
+ .butex-widget .matrix-grid-picker,
6703
+ .butex-widget .matrix-grid-cell {
6704
+ box-sizing: border-box;
6705
+ }
6706
+
6707
+ .butex-widget .matrix-command-menu {
6708
+ position: relative;
6709
+ display: inline-flex;
6710
+ }
6711
+
6712
+ .butex-widget .matrix-command-btn::after {
6713
+ content: "";
6714
+ width: 0;
6715
+ height: 0;
6716
+ margin-inline-start: 3px;
6717
+ border-inline: 3px solid transparent;
6718
+ border-block-start: 4px solid currentColor;
6719
+ opacity: 0.72;
6720
+ }
6721
+
6722
+ .butex-widget .toolbar-matrix-icon {
6723
+ width: 14px;
6724
+ height: 14px;
6725
+ display: grid;
6726
+ grid-template-columns: repeat(2, 1fr);
6727
+ gap: 2px;
6728
+ }
6729
+
6730
+ .butex-widget .toolbar-matrix-icon span {
6731
+ border: 1px solid currentColor;
6732
+ border-radius: 2px;
6733
+ }
6734
+
6735
+ .butex-widget .matrix-command-popover {
6736
+ position: absolute;
6737
+ z-index: var(--butex-z-popover);
6738
+ top: calc(100% + 5px);
6739
+ right: 0;
6740
+ width: 252px;
6741
+ padding: 8px;
6742
+ border: 1px solid var(--butex-border);
6743
+ border-radius: 9px;
6744
+ background: var(--butex-panel);
6745
+ color: var(--butex-fg);
6746
+ box-shadow: var(--butex-shadow-md);
6747
+ }
6748
+
6749
+ .butex-widget .matrix-command-popover[hidden] {
6750
+ display: none;
6751
+ }
6752
+
6753
+ .butex-widget .matrix-style-options,
6754
+ .butex-widget .matrix-edit-actions,
6755
+ .butex-widget .matrix-custom-size {
6756
+ display: flex;
6757
+ gap: 5px;
6758
+ align-items: center;
6759
+ flex-wrap: wrap;
6760
+ }
6761
+
6762
+ .butex-widget .toolbar .matrix-style-option,
6763
+ .butex-widget .toolbar .matrix-edit-actions button,
6764
+ .butex-widget .toolbar .matrix-insert-custom {
6765
+ height: 26px;
6766
+ min-width: 30px;
6767
+ padding: 0 6px;
6768
+ border-radius: 7px;
6769
+ }
6770
+
6771
+ .butex-widget .toolbar .matrix-style-option[aria-selected="true"] {
6772
+ border-color: var(--butex-toolbar-hover-border);
6773
+ background: var(--butex-toolbar-hover-bg);
6774
+ }
6775
+
6776
+ .butex-widget .matrix-size-readout {
6777
+ margin: 7px 0 5px;
6778
+ font-size: 12px;
6779
+ color: var(--butex-muted);
6780
+ text-align: center;
6781
+ direction: ltr;
6782
+ }
6783
+
6784
+ .butex-widget .matrix-grid-picker {
6785
+ display: grid;
6786
+ grid-template-columns: repeat(8, 16px);
6787
+ grid-auto-rows: 16px;
6788
+ gap: 3px;
6789
+ justify-content: center;
6790
+ margin-bottom: 7px;
6791
+ }
6792
+
6793
+ .butex-widget .toolbar .matrix-grid-cell {
6794
+ width: 16px;
6795
+ height: 16px;
6796
+ min-width: 0;
6797
+ padding: 0;
6798
+ border-radius: 3px;
6799
+ border-color: var(--butex-border);
6800
+ }
6801
+
6802
+ .butex-widget .toolbar .matrix-grid-cell.active {
6803
+ border-color: var(--butex-toolbar-hover-border);
6804
+ background: var(--butex-toolbar-hover-bg);
6805
+ }
6806
+
6807
+ .butex-widget .matrix-custom-size {
6808
+ justify-content: center;
6809
+ margin-bottom: 7px;
6810
+ }
6811
+
6812
+ .butex-widget .matrix-custom-size label {
6813
+ display: inline-flex;
6814
+ align-items: center;
6815
+ gap: 3px;
6816
+ font-size: 11px;
6817
+ color: var(--butex-muted);
6818
+ }
6819
+
6820
+ .butex-widget .matrix-custom-size input {
6821
+ width: 42px;
6822
+ height: 24px;
6823
+ border: 1px solid var(--butex-border);
6824
+ border-radius: 6px;
6825
+ padding: 0 4px;
6826
+ direction: ltr;
6827
+ }
6828
+
6829
+ .butex-widget .matrix-edit-actions {
6830
+ justify-content: center;
6831
+ border-top: 1px solid var(--butex-border);
6832
+ padding-top: 7px;
6833
+ }
6834
+
6835
+ .butex-widget .butex-widget__mobile-matrix-picker {
6836
+ display: grid;
6837
+ gap: 14px;
6838
+ min-width: 0;
6839
+ }
6840
+
6841
+ .butex-widget .butex-widget__matrix-presets {
6842
+ display: grid;
6843
+ gap: 8px;
6844
+ grid-template-columns: repeat(4, minmax(44px, 1fr));
6845
+ }
6846
+
6847
+ .butex-widget .butex-widget__matrix-stepper-row {
6848
+ align-items: center;
6849
+ display: flex;
6850
+ gap: 12px;
6851
+ justify-content: space-between;
6852
+ }
6853
+
6854
+ .butex-widget .butex-widget__matrix-stepper {
6855
+ align-items: center;
6856
+ direction: ltr;
6857
+ display: grid;
6858
+ gap: 8px;
6859
+ grid-template-columns: 44px minmax(42px, auto) 44px;
6860
+ }
6861
+
6862
+ .butex-widget .butex-widget__matrix-stepper output {
6863
+ font-variant-numeric: tabular-nums;
6864
+ font-weight: 700;
6865
+ text-align: center;
6866
+ }
6867
+
6868
+ .butex-widget .butex-widget__matrix-size-summary {
6869
+ color: var(--butex-muted);
6870
+ direction: ltr;
6871
+ margin: 0;
6872
+ text-align: center;
6873
+ }
6874
+
6875
+ .butex-widget .butex-widget__matrix-insert {
6876
+ background: var(--butex-accent-hover);
6877
+ border-color: var(--butex-accent-hover);
6878
+ color: var(--butex-on-accent);
6879
+ width: 100%;
6880
+ }
6881
+
6882
+ .butex-widget .butex-widget__matrix-alignment {
6883
+ align-items: center;
6884
+ display: flex;
6885
+ flex-wrap: wrap;
6886
+ gap: 8px;
6887
+ }
6888
+
6889
+ .butex-widget .butex-widget__matrix-alignment label {
6890
+ align-items: center;
6891
+ display: inline-flex;
6892
+ gap: 6px;
6893
+ }
6894
+
6895
+ .butex-widget .butex-widget__matrix-alignment input {
6896
+ border: 1px solid var(--butex-border);
6897
+ border-radius: 8px;
6898
+ min-height: 44px;
6899
+ padding-inline: 8px;
6900
+ width: 70px;
6901
+ }
6902
+ `.trim();
6903
+
6622
6904
  // src/react/widgetChromeCss.ts
6623
6905
  var WIDGET_CHROME_CSS = `
6624
6906
  .butex-widget {
@@ -6665,9 +6947,22 @@ var WIDGET_CHROME_CSS = `
6665
6947
  --butex-script-color: #475569;
6666
6948
  --butex-delim-color: #475569;
6667
6949
  --butex-frac-bar: currentColor;
6950
+ --butex-z-popover: 10;
6951
+ box-sizing: border-box;
6668
6952
  font-family: ui-sans-serif, system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
6669
6953
  color: var(--butex-fg);
6954
+ container-name: butex-equation;
6955
+ container-type: inline-size;
6670
6956
  line-height: 1.45;
6957
+ max-width: 100%;
6958
+ min-width: 0;
6959
+ width: 100%;
6960
+ }
6961
+
6962
+ .butex-widget *,
6963
+ .butex-widget *::before,
6964
+ .butex-widget *::after {
6965
+ box-sizing: inherit;
6671
6966
  }
6672
6967
 
6673
6968
  .butex-widget .butex-widget-layout {
@@ -6676,12 +6971,16 @@ var WIDGET_CHROME_CSS = `
6676
6971
  gap: 8px;
6677
6972
  max-width: 920px;
6678
6973
  margin: 0 auto;
6974
+ min-width: 0;
6975
+ width: 100%;
6679
6976
  }
6680
6977
 
6681
6978
  .butex-widget .panel {
6682
6979
  background: var(--butex-panel);
6683
6980
  border: 1px solid var(--butex-border);
6684
6981
  border-radius: 14px;
6982
+ max-width: 100%;
6983
+ min-width: 0;
6685
6984
  padding: 12px 14px;
6686
6985
  box-shadow: var(--butex-shadow-md);
6687
6986
  }
@@ -6714,21 +7013,191 @@ var WIDGET_CHROME_CSS = `
6714
7013
  margin-bottom: 8px;
6715
7014
  align-items: center;
6716
7015
  align-content: flex-start;
7016
+ min-width: 0;
7017
+ position: relative;
6717
7018
  }
6718
7019
 
6719
- .butex-widget .toolbar button {
7020
+ .butex-widget .butex-widget__mobile-toolbar,
7021
+ .butex-widget .butex-widget__mobile-preview-toggle,
7022
+ .butex-widget .butex-widget__command-sheet-backdrop {
7023
+ display: none;
7024
+ }
7025
+
7026
+ .butex-widget .butex-widget__mobile-toolbar {
7027
+ background: var(--butex-panel);
7028
+ gap: 4px;
7029
+ grid-template-columns: repeat(8, minmax(44px, 1fr));
7030
+ margin-bottom: 8px;
7031
+ min-width: 0;
7032
+ position: sticky;
7033
+ top: 0;
7034
+ z-index: 1;
7035
+ }
7036
+
7037
+ .butex-widget .butex-widget__mobile-toolbar button,
7038
+ .butex-widget .butex-widget__mobile-preview-toggle,
7039
+ .butex-widget .butex-widget__command-sheet button {
7040
+ align-items: center;
7041
+ background: var(--butex-panel);
6720
7042
  border: 1px solid var(--butex-border);
6721
7043
  border-radius: 9px;
6722
- background: var(--butex-panel);
6723
7044
  color: var(--butex-fg);
6724
- min-width: 30px;
6725
- height: 30px;
6726
- padding: 0 7px;
6727
- font-size: 12px;
6728
- font-weight: 600;
6729
7045
  cursor: pointer;
6730
7046
  display: inline-flex;
6731
- align-items: center;
7047
+ font: inherit;
7048
+ font-size: 13px;
7049
+ font-weight: 600;
7050
+ justify-content: center;
7051
+ min-height: 44px;
7052
+ min-width: 44px;
7053
+ padding: 6px 9px;
7054
+ }
7055
+
7056
+ .butex-widget .butex-widget__mobile-preview-toggle {
7057
+ display: none;
7058
+ }
7059
+
7060
+ .butex-widget .butex-widget__mobile-toolbar button:disabled,
7061
+ .butex-widget .butex-widget__command-sheet button:disabled {
7062
+ cursor: not-allowed;
7063
+ opacity: 0.42;
7064
+ }
7065
+
7066
+ .butex-widget .butex-widget__mobile-toolbar button:focus-visible,
7067
+ .butex-widget .butex-widget__mobile-preview-toggle:focus-visible,
7068
+ .butex-widget .butex-widget__command-sheet button:focus-visible {
7069
+ border-color: var(--butex-accent);
7070
+ box-shadow: 0 0 0 3px var(--butex-focus-shadow);
7071
+ outline: none;
7072
+ }
7073
+
7074
+ .butex-widget .butex-widget__mobile-toolbar button[aria-expanded="true"],
7075
+ .butex-widget .butex-widget__mobile-preview-toggle[aria-expanded="true"],
7076
+ .butex-widget .butex-widget__command-sheet button[aria-pressed="true"],
7077
+ .butex-widget .butex-widget__command-sheet button[aria-selected="true"] {
7078
+ background: var(--butex-toolbar-hover-bg);
7079
+ border-color: var(--butex-toolbar-hover-border);
7080
+ box-shadow: 0 0 0 2px var(--butex-focus-shadow);
7081
+ }
7082
+
7083
+ .butex-widget .butex-widget__mobile-danger {
7084
+ color: var(--butex-danger);
7085
+ }
7086
+
7087
+ .butex-widget .butex-widget__mobile-preview-toggle {
7088
+ align-self: flex-start;
7089
+ margin-top: 8px;
7090
+ }
7091
+
7092
+ .butex-widget .butex-widget__command-sheet-backdrop {
7093
+ align-items: flex-end;
7094
+ background: rgba(15, 23, 42, 0.38);
7095
+ inset: 0;
7096
+ justify-content: center;
7097
+ padding-bottom: var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px));
7098
+ padding-left: max(12px, var(--butex-safe-area-left, env(safe-area-inset-left, 0px)));
7099
+ padding-right: max(12px, var(--butex-safe-area-right, env(safe-area-inset-right, 0px)));
7100
+ padding-top: max(12px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)));
7101
+ position: fixed;
7102
+ z-index: var(--butex-z-popover);
7103
+ }
7104
+
7105
+ .butex-widget .butex-widget__command-sheet {
7106
+ background: var(--butex-panel);
7107
+ border: 1px solid var(--butex-border);
7108
+ border-radius: 16px 16px 0 0;
7109
+ box-shadow: 0 -18px 48px rgba(15, 23, 42, 0.22);
7110
+ display: grid;
7111
+ grid-template-rows: auto minmax(0, 1fr);
7112
+ max-height: min(78vh, 720px);
7113
+ max-height: min(720px, calc(100dvh - max(12px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px))) - var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px))));
7114
+ max-width: 640px;
7115
+ min-width: 0;
7116
+ overflow: hidden;
7117
+ width: 100%;
7118
+ }
7119
+
7120
+ .butex-widget .butex-widget__command-sheet-header {
7121
+ align-items: center;
7122
+ border-bottom: 1px solid var(--butex-border);
7123
+ display: grid;
7124
+ gap: 8px;
7125
+ grid-template-columns: minmax(44px, auto) minmax(0, 1fr) minmax(44px, auto);
7126
+ padding: 10px 12px;
7127
+ text-align: center;
7128
+ }
7129
+
7130
+ .butex-widget .butex-widget__command-sheet-header strong {
7131
+ overflow-wrap: anywhere;
7132
+ }
7133
+
7134
+ .butex-widget .butex-widget__command-sheet-body {
7135
+ display: grid;
7136
+ gap: 14px;
7137
+ min-height: 0;
7138
+ min-width: 0;
7139
+ overflow-y: auto;
7140
+ overscroll-behavior: contain;
7141
+ padding: 12px;
7142
+ }
7143
+
7144
+ .butex-widget .butex-widget__sheet-section {
7145
+ display: grid;
7146
+ gap: 8px;
7147
+ min-width: 0;
7148
+ }
7149
+
7150
+ .butex-widget .butex-widget__sheet-section h4 {
7151
+ font-size: 13px;
7152
+ margin: 0;
7153
+ }
7154
+
7155
+ .butex-widget .butex-widget__sheet-categories,
7156
+ .butex-widget .butex-widget__sheet-command-grid,
7157
+ .butex-widget .butex-widget__sheet-command-list,
7158
+ .butex-widget .butex-widget__sheet-choice-row {
7159
+ display: grid;
7160
+ gap: 8px;
7161
+ min-width: 0;
7162
+ }
7163
+
7164
+ .butex-widget .butex-widget__sheet-categories,
7165
+ .butex-widget .butex-widget__sheet-command-grid {
7166
+ grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
7167
+ }
7168
+
7169
+ .butex-widget .butex-widget__sheet-command-grid--three,
7170
+ .butex-widget .butex-widget__sheet-choice-row {
7171
+ grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
7172
+ }
7173
+
7174
+ .butex-widget .butex-widget__sheet-categories button,
7175
+ .butex-widget .butex-widget__sheet-command-list button {
7176
+ justify-content: flex-start;
7177
+ overflow-wrap: anywhere;
7178
+ text-align: start;
7179
+ }
7180
+
7181
+ .butex-widget .butex-widget__command-sheet .operator-command-svg-label {
7182
+ background-color: currentColor;
7183
+ display: inline-block;
7184
+ height: 22px;
7185
+ width: 22px;
7186
+ }
7187
+
7188
+ .butex-widget .toolbar button {
7189
+ border: 1px solid var(--butex-border);
7190
+ border-radius: 9px;
7191
+ background: var(--butex-panel);
7192
+ color: var(--butex-fg);
7193
+ min-width: 30px;
7194
+ height: 30px;
7195
+ padding: 0 7px;
7196
+ font-size: 12px;
7197
+ font-weight: 600;
7198
+ cursor: pointer;
7199
+ display: inline-flex;
7200
+ align-items: center;
6732
7201
  justify-content: center;
6733
7202
  line-height: 1;
6734
7203
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
@@ -6781,7 +7250,7 @@ var WIDGET_CHROME_CSS = `
6781
7250
 
6782
7251
  .butex-widget .delimiter-command-options {
6783
7252
  position: absolute;
6784
- z-index: 10;
7253
+ z-index: var(--butex-z-popover);
6785
7254
  top: calc(100% + 5px);
6786
7255
  right: 0;
6787
7256
  left: auto;
@@ -6860,133 +7329,7 @@ var WIDGET_CHROME_CSS = `
6860
7329
  opacity: 0.85;
6861
7330
  }
6862
7331
 
6863
- .butex-widget .matrix-command-menu {
6864
- position: relative;
6865
- display: inline-flex;
6866
- }
6867
-
6868
- .butex-widget .matrix-command-btn::after {
6869
- content: "";
6870
- width: 0;
6871
- height: 0;
6872
- margin-inline-start: 3px;
6873
- border-inline: 3px solid transparent;
6874
- border-block-start: 4px solid currentColor;
6875
- opacity: 0.72;
6876
- }
6877
-
6878
- .butex-widget .toolbar-matrix-icon {
6879
- width: 14px;
6880
- height: 14px;
6881
- display: grid;
6882
- grid-template-columns: repeat(2, 1fr);
6883
- gap: 2px;
6884
- }
6885
-
6886
- .butex-widget .toolbar-matrix-icon span {
6887
- border: 1px solid currentColor;
6888
- border-radius: 2px;
6889
- }
6890
-
6891
- .butex-widget .matrix-command-popover {
6892
- position: absolute;
6893
- z-index: 12;
6894
- top: calc(100% + 5px);
6895
- right: 0;
6896
- width: 252px;
6897
- padding: 8px;
6898
- border: 1px solid var(--butex-border);
6899
- border-radius: 9px;
6900
- background: var(--butex-panel);
6901
- color: var(--butex-fg);
6902
- box-shadow: var(--butex-shadow-md);
6903
- }
6904
-
6905
- .butex-widget .matrix-command-popover[hidden] {
6906
- display: none;
6907
- }
6908
-
6909
- .butex-widget .matrix-style-options,
6910
- .butex-widget .matrix-edit-actions,
6911
- .butex-widget .matrix-custom-size {
6912
- display: flex;
6913
- gap: 5px;
6914
- align-items: center;
6915
- flex-wrap: wrap;
6916
- }
6917
-
6918
- .butex-widget .toolbar .matrix-style-option,
6919
- .butex-widget .toolbar .matrix-edit-actions button,
6920
- .butex-widget .toolbar .matrix-insert-custom {
6921
- height: 26px;
6922
- min-width: 30px;
6923
- padding: 0 6px;
6924
- border-radius: 7px;
6925
- }
6926
-
6927
- .butex-widget .toolbar .matrix-style-option[aria-selected="true"] {
6928
- border-color: var(--butex-toolbar-hover-border);
6929
- background: var(--butex-toolbar-hover-bg);
6930
- }
6931
-
6932
- .butex-widget .matrix-size-readout {
6933
- margin: 7px 0 5px;
6934
- font-size: 12px;
6935
- color: var(--butex-muted);
6936
- text-align: center;
6937
- direction: ltr;
6938
- }
6939
-
6940
- .butex-widget .matrix-grid-picker {
6941
- display: grid;
6942
- grid-template-columns: repeat(8, 16px);
6943
- grid-auto-rows: 16px;
6944
- gap: 3px;
6945
- justify-content: center;
6946
- margin-bottom: 7px;
6947
- }
6948
-
6949
- .butex-widget .toolbar .matrix-grid-cell {
6950
- width: 16px;
6951
- height: 16px;
6952
- min-width: 0;
6953
- padding: 0;
6954
- border-radius: 3px;
6955
- border-color: var(--butex-border);
6956
- }
6957
-
6958
- .butex-widget .toolbar .matrix-grid-cell.active {
6959
- border-color: var(--butex-toolbar-hover-border);
6960
- background: var(--butex-toolbar-hover-bg);
6961
- }
6962
-
6963
- .butex-widget .matrix-custom-size {
6964
- justify-content: center;
6965
- margin-bottom: 7px;
6966
- }
6967
-
6968
- .butex-widget .matrix-custom-size label {
6969
- display: inline-flex;
6970
- align-items: center;
6971
- gap: 3px;
6972
- font-size: 11px;
6973
- color: var(--butex-muted);
6974
- }
6975
-
6976
- .butex-widget .matrix-custom-size input {
6977
- width: 42px;
6978
- height: 24px;
6979
- border: 1px solid var(--butex-border);
6980
- border-radius: 6px;
6981
- padding: 0 4px;
6982
- direction: ltr;
6983
- }
6984
-
6985
- .butex-widget .matrix-edit-actions {
6986
- justify-content: center;
6987
- border-top: 1px solid var(--butex-border);
6988
- padding-top: 7px;
6989
- }
7332
+ ${MATRIX_PICKER_CSS}
6990
7333
 
6991
7334
  .butex-widget .script-icon-btn {
6992
7335
  min-width: 32px;
@@ -7022,28 +7365,32 @@ var WIDGET_CHROME_CSS = `
7022
7365
  }
7023
7366
 
7024
7367
  .butex-widget .font-mode-btn--takween,
7025
- .butex-widget .character-font-option--takween {
7368
+ .butex-widget .character-font-option--takween,
7369
+ .butex-widget .butex-widget__command-sheet .character-font-option--takween {
7026
7370
  font-family: ${BUTEX_TAKWEEN_FONT_STACK};
7027
7371
  }
7028
7372
 
7029
7373
  .butex-widget .font-mode-btn--diwani,
7030
- .butex-widget .character-font-option--diwani {
7374
+ .butex-widget .character-font-option--diwani,
7375
+ .butex-widget .butex-widget__command-sheet .character-font-option--diwani {
7031
7376
  font-family: ${BUTEX_DIWANI_FONT_STACK};
7032
7377
  }
7033
7378
 
7034
7379
  .butex-widget .font-mode-btn--diwaniOutline,
7035
- .butex-widget .character-font-option--diwaniOutline {
7380
+ .butex-widget .character-font-option--diwaniOutline,
7381
+ .butex-widget .butex-widget__command-sheet .character-font-option--diwaniOutline {
7036
7382
  font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
7037
7383
  }
7038
7384
 
7039
7385
  .butex-widget .font-mode-btn--maghribi,
7040
- .butex-widget .character-font-option--maghribi {
7386
+ .butex-widget .character-font-option--maghribi,
7387
+ .butex-widget .butex-widget__command-sheet .character-font-option--maghribi {
7041
7388
  font-family: ${BUTEX_MAGHRIBI_FONT_STACK};
7042
7389
  }
7043
7390
 
7044
7391
  .butex-widget .character-font-options {
7045
7392
  position: absolute;
7046
- z-index: 10;
7393
+ z-index: var(--butex-z-popover);
7047
7394
  top: calc(100% + 5px);
7048
7395
  right: 0;
7049
7396
  left: auto;
@@ -7080,8 +7427,9 @@ var WIDGET_CHROME_CSS = `
7080
7427
  }
7081
7428
 
7082
7429
  .butex-widget .toolbar .character-font-option[aria-selected="true"] {
7083
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
7430
+ background: var(--butex-accent-hover);
7084
7431
  color: var(--butex-on-accent);
7432
+ box-shadow: inset 0 0 0 2px currentColor;
7085
7433
  }
7086
7434
 
7087
7435
  .butex-widget .toolbar-script-icon {
@@ -7171,6 +7519,16 @@ var WIDGET_CHROME_CSS = `
7171
7519
  font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
7172
7520
  }
7173
7521
 
7522
+ .butex-widget .butex-widget__command-sheet .function-command-option {
7523
+ direction: rtl;
7524
+ font-family: ${BUTEX_DIWANI_FONT_STACK};
7525
+ font-size: 17px;
7526
+ }
7527
+
7528
+ .butex-widget .butex-widget__command-sheet .function-command-option--outline {
7529
+ font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
7530
+ }
7531
+
7174
7532
  .butex-widget .function-command-btn::after {
7175
7533
  content: "";
7176
7534
  width: 0;
@@ -7189,7 +7547,7 @@ var WIDGET_CHROME_CSS = `
7189
7547
 
7190
7548
  .butex-widget .function-command-options {
7191
7549
  position: absolute;
7192
- z-index: 10;
7550
+ z-index: var(--butex-z-popover);
7193
7551
  top: calc(100% + 5px);
7194
7552
  right: 0;
7195
7553
  left: auto;
@@ -7251,6 +7609,11 @@ var WIDGET_CHROME_CSS = `
7251
7609
  font-family: "Cambria Math", "Times New Roman", serif;
7252
7610
  }
7253
7611
 
7612
+ .butex-widget .butex-widget__command-sheet .operator-command-option {
7613
+ font-family: "Cambria Math", "Times New Roman", serif;
7614
+ font-size: 17px;
7615
+ }
7616
+
7254
7617
  .butex-widget .operator-command-label {
7255
7618
  display: inline-flex;
7256
7619
  align-items: center;
@@ -7286,7 +7649,7 @@ var WIDGET_CHROME_CSS = `
7286
7649
 
7287
7650
  .butex-widget .spacing-command-options {
7288
7651
  position: absolute;
7289
- z-index: 10;
7652
+ z-index: var(--butex-z-popover);
7290
7653
  top: calc(100% + 5px);
7291
7654
  right: 0;
7292
7655
  left: auto;
@@ -7402,7 +7765,7 @@ var WIDGET_CHROME_CSS = `
7402
7765
 
7403
7766
  .butex-widget .digit-form-options {
7404
7767
  position: absolute;
7405
- z-index: 10;
7768
+ z-index: var(--butex-z-popover);
7406
7769
  top: calc(100% + 5px);
7407
7770
  right: 0;
7408
7771
  left: auto;
@@ -7439,8 +7802,9 @@ var WIDGET_CHROME_CSS = `
7439
7802
  }
7440
7803
 
7441
7804
  .butex-widget .toolbar .digit-form-option[aria-selected="true"] {
7442
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
7805
+ background: var(--butex-accent-hover);
7443
7806
  color: var(--butex-on-accent);
7807
+ box-shadow: inset 0 0 0 2px currentColor;
7444
7808
  }
7445
7809
 
7446
7810
  .butex-widget .delete-node-btn,
@@ -7468,6 +7832,8 @@ var WIDGET_CHROME_CSS = `
7468
7832
  border: 1px solid var(--butex-border);
7469
7833
  border-radius: 10px;
7470
7834
  background: rgba(248, 250, 252, 0.72);
7835
+ max-width: 100%;
7836
+ min-width: 0;
7471
7837
  }
7472
7838
 
7473
7839
  .butex-widget .toolbar-functions,
@@ -7476,9 +7842,10 @@ var WIDGET_CHROME_CSS = `
7476
7842
  }
7477
7843
 
7478
7844
  .butex-widget .toolbar .accent {
7479
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
7845
+ background: var(--butex-accent-hover);
7480
7846
  color: var(--butex-on-accent);
7481
7847
  border-color: transparent;
7848
+ box-shadow: inset 0 0 0 2px currentColor;
7482
7849
  }
7483
7850
 
7484
7851
  .butex-widget .preview-box {
@@ -7487,7 +7854,13 @@ var WIDGET_CHROME_CSS = `
7487
7854
  padding: 10px 12px;
7488
7855
  background: var(--butex-preview-bg);
7489
7856
  color: var(--butex-preview-fg);
7857
+ max-width: 100%;
7490
7858
  min-height: 48px;
7859
+ min-width: 0;
7860
+ overflow-x: auto;
7861
+ overflow-y: hidden;
7862
+ overscroll-behavior-inline: contain;
7863
+ touch-action: pan-x pan-y;
7491
7864
  }
7492
7865
 
7493
7866
  .butex-widget .error {
@@ -7605,6 +7978,150 @@ var WIDGET_CHROME_CSS = `
7605
7978
  padding: 8px 10px;
7606
7979
  white-space: pre-wrap;
7607
7980
  }
7981
+
7982
+ .butex-widget .delimiter-command-options,
7983
+ .butex-widget .matrix-command-popover,
7984
+ .butex-widget .character-font-options,
7985
+ .butex-widget .function-command-options,
7986
+ .butex-widget .spacing-command-options,
7987
+ .butex-widget .digit-form-options {
7988
+ max-height: min(70vh, 24rem);
7989
+ max-height: min(70dvh, 24rem);
7990
+ max-width: calc(100vw - 24px);
7991
+ max-width: calc(100cqw - 16px);
7992
+ overflow: auto;
7993
+ overscroll-behavior: contain;
7994
+ }
7995
+
7996
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__desktop-toolbar {
7997
+ display: none;
7998
+ }
7999
+
8000
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__mobile-toolbar {
8001
+ display: grid;
8002
+ }
8003
+
8004
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__mobile-preview-toggle {
8005
+ display: inline-flex;
8006
+ }
8007
+
8008
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__command-sheet-backdrop {
8009
+ display: flex;
8010
+ }
8011
+
8012
+ .butex-widget[data-responsive-mode="compact"] .panel-editor {
8013
+ display: flex;
8014
+ flex-direction: column;
8015
+ min-height: min(60dvh, 520px);
8016
+ }
8017
+
8018
+ .butex-widget[data-responsive-mode="compact"] .surface {
8019
+ flex: 1 1 auto;
8020
+ min-height: clamp(180px, 38dvh, 380px);
8021
+ }
8022
+
8023
+ .butex-widget[data-responsive-mode="compact"][data-compact-preview="closed"] .panel-preview {
8024
+ display: none;
8025
+ }
8026
+
8027
+ @media (max-width: 768px) {
8028
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__desktop-toolbar {
8029
+ display: none;
8030
+ }
8031
+
8032
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-toolbar {
8033
+ display: grid;
8034
+ }
8035
+
8036
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-preview-toggle {
8037
+ display: inline-flex;
8038
+ }
8039
+
8040
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet-backdrop {
8041
+ display: flex;
8042
+ }
8043
+
8044
+ .butex-widget:not([data-responsive-mode="desktop"]) .panel-editor {
8045
+ display: flex;
8046
+ flex-direction: column;
8047
+ min-height: min(60dvh, 520px);
8048
+ }
8049
+
8050
+ .butex-widget:not([data-responsive-mode="desktop"]) .surface {
8051
+ flex: 1 1 auto;
8052
+ min-height: clamp(180px, 38dvh, 380px);
8053
+ }
8054
+
8055
+ .butex-widget:not([data-responsive-mode="desktop"])[data-compact-preview="closed"] .panel-preview {
8056
+ display: none;
8057
+ }
8058
+ }
8059
+
8060
+ @media (max-width: 430px) {
8061
+ .butex-widget-layout {
8062
+ gap: 6px;
8063
+ }
8064
+
8065
+ .butex-widget .panel {
8066
+ border-radius: 10px;
8067
+ padding: 8px;
8068
+ }
8069
+
8070
+ .butex-widget .toolbar {
8071
+ gap: 4px;
8072
+ }
8073
+
8074
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-toolbar {
8075
+ grid-template-columns: repeat(4, minmax(44px, 1fr));
8076
+ }
8077
+
8078
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet-backdrop {
8079
+ padding-bottom: var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px));
8080
+ padding-left: var(--butex-safe-area-left, env(safe-area-inset-left, 0px));
8081
+ padding-right: var(--butex-safe-area-right, env(safe-area-inset-right, 0px));
8082
+ padding-top: max(8px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)));
8083
+ }
8084
+
8085
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet {
8086
+ border-bottom: 0;
8087
+ max-height: calc(100dvh - max(8px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px))) - var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px)));
8088
+ max-width: none;
8089
+ }
8090
+
8091
+ .butex-widget:not([data-responsive-mode="desktop"]) .delimiter-command-menu,
8092
+ .butex-widget:not([data-responsive-mode="desktop"]) .matrix-command-menu,
8093
+ .butex-widget:not([data-responsive-mode="desktop"]) .character-font-menu,
8094
+ .butex-widget:not([data-responsive-mode="desktop"]) .function-command-menu,
8095
+ .butex-widget:not([data-responsive-mode="desktop"]) .spacing-command-menu,
8096
+ .butex-widget:not([data-responsive-mode="desktop"]) .digit-form-menu {
8097
+ position: static;
8098
+ }
8099
+
8100
+ .butex-widget:not([data-responsive-mode="desktop"]) .delimiter-command-options,
8101
+ .butex-widget:not([data-responsive-mode="desktop"]) .matrix-command-popover,
8102
+ .butex-widget:not([data-responsive-mode="desktop"]) .character-font-options,
8103
+ .butex-widget:not([data-responsive-mode="desktop"]) .function-command-options,
8104
+ .butex-widget:not([data-responsive-mode="desktop"]) .spacing-command-options,
8105
+ .butex-widget:not([data-responsive-mode="desktop"]) .digit-form-options {
8106
+ left: 8px;
8107
+ max-width: none;
8108
+ min-width: 0;
8109
+ right: 8px;
8110
+ width: auto;
8111
+ }
8112
+ }
8113
+
8114
+ @media (prefers-reduced-motion: reduce) {
8115
+ .butex-widget .toolbar button,
8116
+ .butex-widget .butex-widget__mobile-toolbar button,
8117
+ .butex-widget .butex-widget__mobile-preview-toggle,
8118
+ .butex-widget .butex-widget__command-sheet,
8119
+ .butex-widget .butex-widget__command-sheet button {
8120
+ animation: none;
8121
+ scroll-behavior: auto;
8122
+ transition: none;
8123
+ }
8124
+ }
7608
8125
  `.trim();
7609
8126
  var CHROME_STYLE_ID = "butex-widget-chrome-css";
7610
8127
  function injectWidgetChromeCss(doc) {
@@ -8587,82 +9104,911 @@ function editorNodeToAstNode(node) {
8587
9104
  } else {
8588
9105
  return { ok: false, reason: `\u0639\u0642\u062F\u0629 \u0631\u064A\u0627\u0636\u064A\u0629 \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645\u0629 \u062D\u0627\u0644\u064A\u0627: ${node.kind}` };
8589
9106
  }
8590
- const scripts = attachAstScripts(node, astNode);
8591
- return scripts ?? { ok: true, node: astNode };
9107
+ const scripts = attachAstScripts(node, astNode);
9108
+ return scripts ?? { ok: true, node: astNode };
9109
+ }
9110
+ function editorChainToAstChain(chain) {
9111
+ const nodes = [];
9112
+ for (const editorNode of chain.nodes) {
9113
+ const converted = editorNodeToAstNode(editorNode);
9114
+ if (!converted.ok) {
9115
+ return converted;
9116
+ }
9117
+ nodes.push(converted.node);
9118
+ }
9119
+ return { ok: true, chain: new ChainNode(nodes) };
9120
+ }
9121
+ function mathNodeFromEditorSession(session, mathMode = "$", closing = "$") {
9122
+ const converted = editorChainToAstChain(session.englishTree);
9123
+ if (!converted.ok) {
9124
+ return converted;
9125
+ }
9126
+ return {
9127
+ ok: true,
9128
+ math: {
9129
+ nodeType: "MathObject",
9130
+ mathMode,
9131
+ lines: [converted.chain],
9132
+ closing
9133
+ }
9134
+ };
9135
+ }
9136
+
9137
+ // src/debugJson.ts
9138
+ function lineColumnForPosition(text, position) {
9139
+ const before = text.slice(0, Math.max(0, position));
9140
+ const lines = before.split("\n");
9141
+ return {
9142
+ line: lines.length,
9143
+ column: (lines[lines.length - 1]?.length ?? 0) + 1
9144
+ };
9145
+ }
9146
+ function parseJsonDebugInput(text) {
9147
+ try {
9148
+ return { ok: true, value: JSON.parse(text) };
9149
+ } catch (error) {
9150
+ const message = error instanceof Error ? error.message : String(error);
9151
+ const positionMatch = message.match(/position\s+(\d+)/i);
9152
+ if (positionMatch) {
9153
+ const position = Number(positionMatch[1]);
9154
+ if (Number.isFinite(position)) {
9155
+ const location = lineColumnForPosition(text, position);
9156
+ return { ok: false, error: `Invalid JSON at line ${String(location.line)}, column ${String(location.column)}: ${message}` };
9157
+ }
9158
+ }
9159
+ return { ok: false, error: `Invalid JSON: ${message}` };
9160
+ }
9161
+ }
9162
+
9163
+ // src/react/EquationMobileToolbar.tsx
9164
+ var import_react2 = require("react");
9165
+
9166
+ // src/react/dialogFocus.ts
9167
+ var import_react = require("react");
9168
+ var FOCUSABLE_SELECTOR = [
9169
+ 'a[href]:not([tabindex="-1"])',
9170
+ 'button:not([disabled]):not([tabindex="-1"])',
9171
+ 'input:not([disabled]):not([tabindex="-1"])',
9172
+ 'select:not([disabled]):not([tabindex="-1"])',
9173
+ 'textarea:not([disabled]):not([tabindex="-1"])',
9174
+ '[tabindex]:not([tabindex="-1"])'
9175
+ ].join(",");
9176
+ var dialogStateByDocument = /* @__PURE__ */ new WeakMap();
9177
+ function focusableElements(dialog) {
9178
+ return Array.from(dialog.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
9179
+ (element) => {
9180
+ if (element.hidden || element.closest('[hidden], [aria-hidden="true"], [inert]') || typeof element.checkVisibility === "function" && !element.checkVisibility()) {
9181
+ return false;
9182
+ }
9183
+ return true;
9184
+ }
9185
+ );
9186
+ }
9187
+ function useDialogFocus({ open, dialogRef, onClose, triggerRef }) {
9188
+ const closeRef = (0, import_react.useRef)(onClose);
9189
+ closeRef.current = onClose;
9190
+ (0, import_react.useEffect)(() => {
9191
+ if (!open) {
9192
+ return;
9193
+ }
9194
+ const doc = dialogRef.current?.ownerDocument ?? document;
9195
+ const view = doc.defaultView ?? window;
9196
+ const registration = /* @__PURE__ */ Symbol("butex-dialog");
9197
+ const previouslyFocused = doc.activeElement instanceof HTMLElement ? doc.activeElement : null;
9198
+ const documentState = dialogStateByDocument.get(doc) ?? { stack: [], origin: null };
9199
+ if (documentState.stack.length === 0 && documentState.origin === null) {
9200
+ documentState.origin = triggerRef?.current ?? previouslyFocused;
9201
+ }
9202
+ documentState.stack.push(registration);
9203
+ dialogStateByDocument.set(doc, documentState);
9204
+ const focusTimer = view.setTimeout(() => {
9205
+ const initialFocus = dialogRef.current?.querySelector("[data-dialog-initial-focus]") ?? (dialogRef.current ? focusableElements(dialogRef.current)[0] : null) ?? dialogRef.current;
9206
+ initialFocus?.focus();
9207
+ }, 0);
9208
+ const onKeyDown = (event) => {
9209
+ if (documentState.stack.at(-1) !== registration) {
9210
+ return;
9211
+ }
9212
+ if (event.key === "Escape") {
9213
+ event.preventDefault();
9214
+ closeRef.current();
9215
+ return;
9216
+ }
9217
+ if (event.key !== "Tab" || !dialogRef.current) {
9218
+ return;
9219
+ }
9220
+ const focusable = focusableElements(dialogRef.current);
9221
+ if (focusable.length === 0) {
9222
+ event.preventDefault();
9223
+ dialogRef.current.focus();
9224
+ return;
9225
+ }
9226
+ const first = focusable[0];
9227
+ const last = focusable[focusable.length - 1];
9228
+ if (event.shiftKey && (doc.activeElement === first || !dialogRef.current.contains(doc.activeElement))) {
9229
+ event.preventDefault();
9230
+ last?.focus();
9231
+ } else if (!event.shiftKey && doc.activeElement === last) {
9232
+ event.preventDefault();
9233
+ first?.focus();
9234
+ }
9235
+ };
9236
+ const onFocusIn = (event) => {
9237
+ if (documentState.stack.at(-1) !== registration || !dialogRef.current || dialogRef.current.contains(event.target)) {
9238
+ return;
9239
+ }
9240
+ (focusableElements(dialogRef.current)[0] ?? dialogRef.current).focus();
9241
+ };
9242
+ doc.addEventListener("keydown", onKeyDown);
9243
+ doc.addEventListener("focusin", onFocusIn);
9244
+ return () => {
9245
+ view.clearTimeout(focusTimer);
9246
+ doc.removeEventListener("keydown", onKeyDown);
9247
+ doc.removeEventListener("focusin", onFocusIn);
9248
+ const index = documentState.stack.lastIndexOf(registration);
9249
+ const hadParentDialog = index > 0;
9250
+ if (index >= 0) {
9251
+ documentState.stack.splice(index, 1);
9252
+ }
9253
+ view.setTimeout(() => {
9254
+ if (documentState.stack.length > 0 && !hadParentDialog) {
9255
+ return;
9256
+ }
9257
+ const restoreTarget = [triggerRef?.current, previouslyFocused, documentState.origin].find(
9258
+ (candidate) => Boolean(candidate?.isConnected)
9259
+ );
9260
+ if (restoreTarget) {
9261
+ restoreTarget.focus();
9262
+ }
9263
+ if (documentState.stack.length === 0) {
9264
+ view.setTimeout(() => {
9265
+ if (documentState.stack.length === 0 && dialogStateByDocument.get(doc) === documentState) {
9266
+ dialogStateByDocument.delete(doc);
9267
+ }
9268
+ }, 0);
9269
+ }
9270
+ }, 0);
9271
+ };
9272
+ }, [dialogRef, open, triggerRef]);
9273
+ }
9274
+
9275
+ // src/react/EquationMobileToolbar.tsx
9276
+ var import_jsx_runtime = require("react/jsx-runtime");
9277
+ var ACCENT_COMMANDS2 = accentCommandsList();
9278
+ var FUNCTION_COMMANDS = atomicCommandsByCategory("function");
9279
+ var LIMITS_SERIES_COMMANDS = atomicCommandsByCategory("limits_series");
9280
+ var FUNCTION2_COMMANDS = atomicCommandsByCategory("function2");
9281
+ var DERIVATIVE_COMMANDS = atomicCommandsByCategory("derivative");
9282
+ var GROUP_COMMANDS = atomicCommandsByCategory("groups");
9283
+ var SPACING_COMMANDS = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
9284
+ var OPERATOR_GROUPS = [
9285
+ atomicOperatorCommandsByCategory("operators1"),
9286
+ atomicOperatorCommandsByCategory("operators2"),
9287
+ atomicOperatorCommandsByCategory("operators3"),
9288
+ atomicOperatorCommandsByCategory("dots"),
9289
+ atomicOperatorCommandsByCategory("integrals")
9290
+ ];
9291
+ var MATRIX_STYLES = [
9292
+ { id: "matrix", label: "\u25A1" },
9293
+ { id: "pmatrix", label: "(\u25A1)" },
9294
+ { id: "bmatrix", label: "[\u25A1]" },
9295
+ { id: "Bmatrix", label: "{\u25A1}" },
9296
+ { id: "vmatrix", label: "|\u25A1|" },
9297
+ { id: "Vmatrix", label: "||\u25A1||" }
9298
+ ];
9299
+ var MATRIX_PRESETS = [
9300
+ { rows: 2, columns: 2 },
9301
+ { rows: 2, columns: 3 },
9302
+ { rows: 3, columns: 2 },
9303
+ { rows: 3, columns: 3 }
9304
+ ];
9305
+ var ARRAY_ALIGNMENTS = ["l", "c", "r"];
9306
+ function clampMatrixSize(value) {
9307
+ return Math.max(1, Math.min(12, Math.trunc(value)));
9308
+ }
9309
+ function matrixSizeLabel(rows, columns, messages) {
9310
+ const rowLabel = rows === 1 ? messages.row : messages.rows;
9311
+ const columnLabel = columns === 1 ? messages.column : messages.columns;
9312
+ return `${String(rows)} ${rowLabel} \xD7 ${String(columns)} ${columnLabel}`;
9313
+ }
9314
+ function matrixStyleTitle(style, messages) {
9315
+ if (style === "pmatrix") return messages.matrixParentheses;
9316
+ if (style === "bmatrix") return messages.matrixBrackets;
9317
+ if (style === "Bmatrix") return messages.matrixBraces;
9318
+ if (style === "vmatrix") return messages.matrixBars;
9319
+ if (style === "Vmatrix") return messages.matrixDoubleBars;
9320
+ return messages.matrixNoDelimiters;
9321
+ }
9322
+ function alignmentLabel(alignment, messages) {
9323
+ if (alignment === "l") return messages.alignLeft;
9324
+ if (alignment === "r") return messages.alignRight;
9325
+ return messages.alignCenter;
9326
+ }
9327
+ function alignmentTitle(alignment, messages) {
9328
+ if (alignment === "l") return messages.alignColumnLeft;
9329
+ if (alignment === "r") return messages.alignColumnRight;
9330
+ return messages.alignColumnCenter;
9331
+ }
9332
+ function characterFontTitle(fontId, messages) {
9333
+ const key = characterFontSpec(fontId).titleKey;
9334
+ return messages[key] ?? messages.defaultFont;
9335
+ }
9336
+ function digitTitle(digitForm, messages) {
9337
+ if (digitForm === "arabicIndic") return messages.arabicIndicDigits;
9338
+ if (digitForm === "persianIndic") return messages.persianIndicDigits;
9339
+ return messages.westernDigits;
9340
+ }
9341
+ function spacingArrow(command, side) {
9342
+ const pointsWithFlow = command.spacing.direction === "positive";
9343
+ if (pointsWithFlow) {
9344
+ return side === "arabic" ? "\u2190" : "\u2192";
9345
+ }
9346
+ return side === "arabic" ? "\u2192" : "\u2190";
8592
9347
  }
8593
- function editorChainToAstChain(chain) {
8594
- const nodes = [];
8595
- for (const editorNode of chain.nodes) {
8596
- const converted = editorNodeToAstNode(editorNode);
8597
- if (!converted.ok) {
8598
- return converted;
9348
+ function functionLabel(command) {
9349
+ if (command.id !== "ln") {
9350
+ return command.arabicLabel;
9351
+ }
9352
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
9353
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
9354
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
9355
+ ] });
9356
+ }
9357
+ function operatorLabel(command) {
9358
+ const label = command.svg_path ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9359
+ "span",
9360
+ {
9361
+ className: "operator-command-svg-label",
9362
+ "aria-hidden": "true",
9363
+ style: {
9364
+ mask: `url("${command.svg_path}") center / contain no-repeat`,
9365
+ WebkitMask: `url("${command.svg_path}") center / contain no-repeat`
9366
+ }
9367
+ }
9368
+ ) : command.Label;
9369
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: label });
9370
+ }
9371
+ function categoryTitle(view, messages) {
9372
+ if (view === "delimiters") return messages.insertDelimiters;
9373
+ if (view === "structures") return messages.structures;
9374
+ if (view === "functions") return messages.functions;
9375
+ if (view === "operators") return messages.operations;
9376
+ if (view === "matrices") return messages.matrices;
9377
+ if (view === "typography") return messages.typography;
9378
+ if (view === "spacing") return messages.spaces;
9379
+ if (view === "digits") return messages.digitForms;
9380
+ return messages.moreActions;
9381
+ }
9382
+ function EquationMobileToolbar({
9383
+ uiLocale,
9384
+ messages,
9385
+ state,
9386
+ showSideSwitcher,
9387
+ inputRef,
9388
+ getRuntime
9389
+ }) {
9390
+ const [sheetView, setSheetView] = (0, import_react2.useState)("closed");
9391
+ const [envMode, setEnvMode] = (0, import_react2.useState)("matrix");
9392
+ const [matrixStyle, setMatrixStyle] = (0, import_react2.useState)("pmatrix");
9393
+ const [matrixRows, setMatrixRows] = (0, import_react2.useState)(2);
9394
+ const [matrixColumns, setMatrixColumns] = (0, import_react2.useState)(2);
9395
+ const [alignmentColumn, setAlignmentColumn] = (0, import_react2.useState)(1);
9396
+ const dialogRef = (0, import_react2.useRef)(null);
9397
+ const moreButtonRef = (0, import_react2.useRef)(null);
9398
+ const delimiterButtonRef = (0, import_react2.useRef)(null);
9399
+ const backButtonRef = (0, import_react2.useRef)(null);
9400
+ const restoreFocusRef = (0, import_react2.useRef)(null);
9401
+ const sheetTitleId = (0, import_react2.useId)();
9402
+ const sheetOpen = sheetView !== "closed";
9403
+ function dismissSheet() {
9404
+ setSheetView("closed");
9405
+ }
9406
+ useDialogFocus({ open: sheetOpen, dialogRef, onClose: dismissSheet, triggerRef: restoreFocusRef });
9407
+ (0, import_react2.useEffect)(() => {
9408
+ if (sheetView !== "closed" && sheetView !== "root" && sheetView !== "delimiters") {
9409
+ const timer = window.setTimeout(() => backButtonRef.current?.focus(), 0);
9410
+ return () => window.clearTimeout(timer);
9411
+ }
9412
+ }, [sheetView]);
9413
+ function focusInputAfterClose() {
9414
+ restoreFocusRef.current = inputRef.current;
9415
+ setSheetView("closed");
9416
+ window.requestAnimationFrame(() => getRuntime()?.focusInput());
9417
+ }
9418
+ function runAndClose(action) {
9419
+ const runtime = getRuntime();
9420
+ if (runtime) {
9421
+ action(runtime);
9422
+ }
9423
+ focusInputAfterClose();
9424
+ }
9425
+ function runAndKeepFocus(button, action) {
9426
+ const runtime = getRuntime();
9427
+ if (runtime) {
9428
+ action(runtime);
9429
+ }
9430
+ window.requestAnimationFrame(() => button.focus());
9431
+ }
9432
+ function openMore() {
9433
+ restoreFocusRef.current = moreButtonRef.current;
9434
+ setSheetView("root");
9435
+ }
9436
+ function openDelimiters() {
9437
+ restoreFocusRef.current = delimiterButtonRef.current;
9438
+ setSheetView("delimiters");
9439
+ }
9440
+ function setMatrixDimension(kind, value) {
9441
+ const next = clampMatrixSize(value);
9442
+ if (kind === "rows") {
9443
+ setMatrixRows(next);
9444
+ } else {
9445
+ setMatrixColumns(envMode === "aligned" ? 2 : next);
8599
9446
  }
8600
- nodes.push(converted.node);
8601
9447
  }
8602
- return { ok: true, chain: new ChainNode(nodes) };
9448
+ function insertEnvironment() {
9449
+ runAndClose((runtime) => {
9450
+ if (envMode === "array") {
9451
+ runtime.insertArrayEnv(matrixRows, matrixColumns);
9452
+ } else if (envMode === "aligned") {
9453
+ runtime.insertAlignedEnv(matrixRows, 2);
9454
+ } else {
9455
+ runtime.insertMatrixEnv(matrixStyle, matrixRows, matrixColumns);
9456
+ }
9457
+ });
9458
+ }
9459
+ const directButtonMouseDown = (event) => event.preventDefault();
9460
+ const undoArrow = state.activeSide === "arabic" ? "\u21B7" : "\u21B6";
9461
+ const redoArrow = state.activeSide === "arabic" ? "\u21B6" : "\u21B7";
9462
+ const renderFunctionGroup = (label, commands, limits = false, outline = false) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9463
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: label }),
9464
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid", children: commands.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9465
+ "button",
9466
+ {
9467
+ className: `function-command-option${outline ? " function-command-option--outline" : ""}`,
9468
+ type: "button",
9469
+ title: atomicCommandTitle(command, uiLocale),
9470
+ "aria-label": atomicCommandTitle(command, uiLocale),
9471
+ onClick: () => runAndClose((runtime) => {
9472
+ if (limits) runtime.insertLimitsSeriesTemplate(command.id);
9473
+ else runtime.insertAtomicCommand(command.id);
9474
+ }),
9475
+ children: functionLabel(command)
9476
+ },
9477
+ command.id
9478
+ )) })
9479
+ ] }, label);
9480
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9481
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__mobile-toolbar", role: "toolbar", "aria-label": messages.compactToolbar, children: [
9482
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: !state.canUndo, title: messages.undo, "aria-label": messages.undo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performUndo(), children: undoArrow }),
9483
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: !state.canRedo, title: messages.redo, "aria-label": messages.redo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performRedo(), children: redoArrow }),
9484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.insertFraction(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
9485
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0623" }),
9486
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0628" })
9487
+ ] }) }),
9488
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSup(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
9489
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
9490
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0633" })
9491
+ ] }) }),
9492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSub(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
9493
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
9494
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0633" })
9495
+ ] }) }),
9496
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: delimiterButtonRef, type: "button", title: messages.insertDelimiters, "aria-label": messages.insertDelimiters, "aria-haspopup": "dialog", "aria-expanded": sheetView === "delimiters", onClick: openDelimiters, children: "()" }),
9497
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "butex-widget__mobile-danger", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.deleteStructure(), children: "\xD7" }),
9498
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: moreButtonRef, type: "button", title: messages.moreActions, "aria-label": messages.moreActions, "aria-haspopup": "dialog", "aria-expanded": sheetOpen && sheetView !== "delimiters", onClick: openMore, children: "\u22EF" })
9499
+ ] }),
9500
+ sheetOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9501
+ "div",
9502
+ {
9503
+ className: "butex-widget__command-sheet-backdrop",
9504
+ role: "presentation",
9505
+ onClick: (event) => {
9506
+ if (event.target === event.currentTarget) dismissSheet();
9507
+ },
9508
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
9509
+ "div",
9510
+ {
9511
+ ref: dialogRef,
9512
+ className: "butex-widget__command-sheet",
9513
+ role: "dialog",
9514
+ "aria-modal": "true",
9515
+ "aria-labelledby": sheetTitleId,
9516
+ tabIndex: -1,
9517
+ children: [
9518
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__command-sheet-header", children: [
9519
+ sheetView !== "root" && sheetView !== "delimiters" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: backButtonRef, type: "button", onClick: () => setSheetView("root"), children: messages.back }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
9520
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { id: sheetTitleId, children: categoryTitle(sheetView, messages) }),
9521
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "data-dialog-initial-focus": true, "aria-label": messages.closeActions, onClick: dismissSheet, children: "\xD7" })
9522
+ ] }),
9523
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__command-sheet-body", children: [
9524
+ sheetView === "root" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9525
+ showSideSwitcher ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9526
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.activeSide }),
9527
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-choice-row", children: [
9528
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9529
+ "button",
9530
+ {
9531
+ type: "button",
9532
+ "aria-pressed": state.activeSide === "arabic",
9533
+ onClick: (event) => {
9534
+ if (state.activeSide !== "arabic") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
9535
+ },
9536
+ children: messages.arabicSide
9537
+ }
9538
+ ),
9539
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9540
+ "button",
9541
+ {
9542
+ type: "button",
9543
+ "aria-pressed": state.activeSide === "english",
9544
+ onClick: (event) => {
9545
+ if (state.activeSide !== "english") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
9546
+ },
9547
+ children: messages.englishSide
9548
+ }
9549
+ )
9550
+ ] })
9551
+ ] }) : null,
9552
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9553
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.clipboard }),
9554
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-choice-row", children: [
9555
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: !state.hasSelection, onClick: () => runAndClose((runtime) => {
9556
+ void runtime.performCopy();
9557
+ }), children: messages.copy }),
9558
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: !state.hasSelection, onClick: () => runAndClose((runtime) => {
9559
+ void runtime.performCut();
9560
+ }), children: messages.cut }),
9561
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => runAndClose((runtime) => {
9562
+ void runtime.performPaste();
9563
+ }), children: messages.paste })
9564
+ ] })
9565
+ ] }),
9566
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { className: "butex-widget__sheet-categories", "aria-label": messages.commandCategories, children: ["structures", "functions", "operators", "matrices", "typography", "spacing", "digits"].map((view) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => setSheetView(view), children: categoryTitle(view, messages) }, view)) })
9567
+ ] }) : null,
9568
+ sheetView === "delimiters" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three", children: [
9569
+ { kind: "paren", label: "()", title: messages.insertParentheses },
9570
+ { kind: "bracket", label: "[]", title: messages.insertBrackets },
9571
+ { kind: "brace", label: "{}", title: messages.insertBraces }
9572
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": option.title, title: option.title, onClick: () => runAndClose((runtime) => runtime.insertDelimiterByKind(option.kind)), children: option.label }, option.kind)) }) : null,
9573
+ sheetView === "structures" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9574
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-command-grid", children: [
9575
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => runAndClose((runtime) => runtime.insertSqrt()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
9576
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => runAndClose((runtime) => runtime.insertOverset()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
9577
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" }),
9578
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" })
9579
+ ] }) }),
9580
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => runAndClose((runtime) => runtime.insertUnderset()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
9581
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" }),
9582
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" })
9583
+ ] }) }),
9584
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => runAndClose((runtime) => runtime.insertAccentPair()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
9585
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" }),
9586
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" }),
9587
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" })
9588
+ ] }) }),
9589
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runAndClose((runtime) => runtime.removeSup()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
9590
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xD7" }),
9591
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" })
9592
+ ] }) }),
9593
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runAndClose((runtime) => runtime.removeSub()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
9594
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xD7" }),
9595
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" })
9596
+ ] }) })
9597
+ ] }),
9598
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9599
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.insertAccents }),
9600
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid", children: ACCENT_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "operator-command-option", type: "button", title: accentCommandTitle(command, uiLocale), "aria-label": accentCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAccent(command.id)), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "operator-command-label", "aria-hidden": "true", children: command.label }) }, command.id)) })
9601
+ ] })
9602
+ ] }) : null,
9603
+ sheetView === "functions" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9604
+ renderFunctionGroup(messages.insertFunction, FUNCTION_COMMANDS),
9605
+ renderFunctionGroup(messages.insertLimitsSeries, LIMITS_SERIES_COMMANDS, true),
9606
+ renderFunctionGroup(messages.insertAdditionalFunctions, FUNCTION2_COMMANDS),
9607
+ renderFunctionGroup(messages.insertDerivative, DERIVATIVE_COMMANDS),
9608
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-command-grid", children: [
9609
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "function-command-option", type: "button", title: messages.insertFirstDerivative, "aria-label": messages.insertFirstDerivative, onClick: () => runAndClose((runtime) => runtime.insertFirstDerivative()), children: "\u0621/\u0633" }),
9610
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "function-command-option", type: "button", title: messages.insertSecondDerivative, "aria-label": messages.insertSecondDerivative, onClick: () => runAndClose((runtime) => runtime.insertSecondDerivative()), children: "\u0621\xB2/\u0633\xB2" })
9611
+ ] }),
9612
+ renderFunctionGroup(messages.insertNumberSets, GROUP_COMMANDS, false, true)
9613
+ ] }) : null,
9614
+ sheetView === "operators" ? OPERATOR_GROUPS.map((commands, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", { className: "butex-widget__sheet-section", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid", children: commands.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "operator-command-option", type: "button", title: atomicOperatorCommandTitle(command, uiLocale), "aria-label": atomicOperatorCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAtomicOperatorCommand(command.id)), children: operatorLabel(command) }, command.id)) }) }, String(index))) : null,
9615
+ sheetView === "matrices" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__mobile-matrix-picker", children: [
9616
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.environmentType, children: [
9617
+ { id: "matrix", label: messages.matrix },
9618
+ { id: "array", label: messages.array },
9619
+ { id: "aligned", label: messages.aligned }
9620
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9621
+ "button",
9622
+ {
9623
+ type: "button",
9624
+ "aria-pressed": envMode === option.id,
9625
+ onClick: () => {
9626
+ setEnvMode(option.id);
9627
+ if (option.id === "aligned") setMatrixColumns(2);
9628
+ },
9629
+ children: option.label
9630
+ },
9631
+ option.id
9632
+ )) }),
9633
+ envMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: matrixStyleTitle(style.id, messages), "aria-label": matrixStyleTitle(style.id, messages), "aria-pressed": matrixStyle === style.id, onClick: () => setMatrixStyle(style.id), children: style.label }, style.id)) }) : null,
9634
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9635
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.commonMatrixSizes }),
9636
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__matrix-presets", children: (envMode === "aligned" ? MATRIX_PRESETS.filter((preset) => preset.columns === 2) : MATRIX_PRESETS).map((preset) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
9637
+ "button",
9638
+ {
9639
+ type: "button",
9640
+ "aria-pressed": matrixRows === preset.rows && matrixColumns === preset.columns,
9641
+ onClick: () => {
9642
+ setMatrixRows(preset.rows);
9643
+ setMatrixColumns(envMode === "aligned" ? 2 : preset.columns);
9644
+ },
9645
+ children: [
9646
+ preset.rows,
9647
+ "\xD7",
9648
+ envMode === "aligned" ? 2 : preset.columns
9649
+ ]
9650
+ },
9651
+ `${String(preset.rows)}-${String(preset.columns)}`
9652
+ )) })
9653
+ ] }),
9654
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-stepper-row", children: [
9655
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: messages.rows }),
9656
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-stepper", children: [
9657
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: matrixRows <= 1, "aria-label": messages.decreaseRows, onClick: () => setMatrixDimension("rows", matrixRows - 1), children: "\u2212" }),
9658
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("output", { "aria-live": "polite", children: matrixRows }),
9659
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: matrixRows >= 12, "aria-label": messages.increaseRows, onClick: () => setMatrixDimension("rows", matrixRows + 1), children: "+" })
9660
+ ] })
9661
+ ] }),
9662
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-stepper-row", children: [
9663
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: messages.columns }),
9664
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-stepper", children: [
9665
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: matrixColumns <= 1 || envMode === "aligned", "aria-label": messages.decreaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns - 1), children: "\u2212" }),
9666
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("output", { "aria-live": "polite", children: envMode === "aligned" ? 2 : matrixColumns }),
9667
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: matrixColumns >= 12 || envMode === "aligned", "aria-label": messages.increaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns + 1), children: "+" })
9668
+ ] })
9669
+ ] }),
9670
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "butex-widget__matrix-size-summary", "aria-live": "polite", children: matrixSizeLabel(matrixRows, envMode === "aligned" ? 2 : matrixColumns, messages) }),
9671
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "butex-widget__matrix-insert", onClick: insertEnvironment, children: messages.insert }),
9672
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9673
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.editSelectedEnvironment }),
9674
+ envMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => getRuntime()?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
9675
+ envMode === "array" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-alignment", children: [
9676
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
9677
+ messages.column,
9678
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "number", min: 1, max: 12, value: alignmentColumn, onChange: (event) => setAlignmentColumn(clampMatrixSize(Number(event.currentTarget.value) || 1)) })
9679
+ ] }),
9680
+ ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: alignmentTitle(alignment, messages), onClick: () => getRuntime()?.setArrayColumnAlignment(alignmentColumn - 1, alignment), children: alignmentLabel(alignment, messages) }, alignment))
9681
+ ] }) : null,
9682
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-command-grid", children: [
9683
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => getRuntime()?.addMatrixRow(), children: [
9684
+ "+",
9685
+ messages.row
9686
+ ] }),
9687
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => getRuntime()?.removeMatrixRow(), children: [
9688
+ "\u2212",
9689
+ messages.row
9690
+ ] }),
9691
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => getRuntime()?.addMatrixColumn(), children: [
9692
+ "+",
9693
+ messages.column
9694
+ ] }),
9695
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => getRuntime()?.removeMatrixColumn(), children: [
9696
+ "\u2212",
9697
+ messages.column
9698
+ ] })
9699
+ ] })
9700
+ ] })
9701
+ ] }) : null,
9702
+ sheetView === "typography" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9703
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9704
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.chooseWritingFont }),
9705
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9706
+ "button",
9707
+ {
9708
+ type: "button",
9709
+ className: `character-font-option--${option.id}`,
9710
+ "aria-pressed": state.characterFont === option.id,
9711
+ title: characterFontTitle(option.id, messages),
9712
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
9713
+ children: option.label
9714
+ },
9715
+ option.id
9716
+ )) })
9717
+ ] }),
9718
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9719
+ "button",
9720
+ {
9721
+ className: "ligature-btn butex-widget__compact-ligature",
9722
+ type: "button",
9723
+ title: !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
9724
+ "aria-label": !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
9725
+ "aria-pressed": !state.splitLeafTyping,
9726
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSplitLeafTyping()),
9727
+ children: !state.splitLeafTyping ? "\u0633\u0635\u0639" : "\u0633 \u0635 \u0639"
9728
+ }
9729
+ )
9730
+ ] }) : null,
9731
+ sheetView === "spacing" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-list", children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: atomicCommandTitle(command, uiLocale), "aria-label": atomicCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAtomicCommand(command.id)), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
9732
+ "span",
9733
+ {
9734
+ className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`,
9735
+ "aria-hidden": "true",
9736
+ children: [
9737
+ command.spacing.direction === "negative" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null,
9738
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__bar" }),
9739
+ command.spacing.direction === "positive" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null
9740
+ ]
9741
+ }
9742
+ ) }, command.id)) }) : null,
9743
+ sheetView === "digits" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", children: [
9744
+ { id: "western", label: "456" },
9745
+ { id: "arabicIndic", label: "\u0664\u0665\u0666" },
9746
+ { id: "persianIndic", label: "\u06F4\u06F5\u06F6" }
9747
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9748
+ "button",
9749
+ {
9750
+ type: "button",
9751
+ "aria-pressed": state.digitForm === option.id,
9752
+ title: digitTitle(option.id, messages),
9753
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentDigitForm(option.id)),
9754
+ children: option.label
9755
+ },
9756
+ option.id
9757
+ )) }) : null
9758
+ ] })
9759
+ ]
9760
+ }
9761
+ )
9762
+ }
9763
+ ) : null
9764
+ ] });
8603
9765
  }
8604
- function mathNodeFromEditorSession(session, mathMode = "$", closing = "$") {
8605
- const converted = editorChainToAstChain(session.englishTree);
8606
- if (!converted.ok) {
8607
- return converted;
9766
+
9767
+ // src/react/visibleViewport.ts
9768
+ function positiveFinite(value, fallback) {
9769
+ return Number.isFinite(value) && value > 0 ? value : fallback;
9770
+ }
9771
+ function finiteOffset(value) {
9772
+ return Number.isFinite(value) ? value : 0;
9773
+ }
9774
+ function visibleViewportSnapshot(view) {
9775
+ const fallbackWidth = positiveFinite(view.innerWidth, 1);
9776
+ const fallbackHeight = positiveFinite(view.innerHeight, 1);
9777
+ const visualViewport = view.visualViewport;
9778
+ if (visualViewport && Number.isFinite(visualViewport.width) && visualViewport.width > 0 && Number.isFinite(visualViewport.height) && visualViewport.height > 0) {
9779
+ return {
9780
+ width: visualViewport.width,
9781
+ height: visualViewport.height,
9782
+ offsetLeft: finiteOffset(visualViewport.offsetLeft),
9783
+ offsetTop: finiteOffset(visualViewport.offsetTop),
9784
+ scale: positiveFinite(visualViewport.scale, 1),
9785
+ source: "visual-viewport"
9786
+ };
8608
9787
  }
8609
9788
  return {
8610
- ok: true,
8611
- math: {
8612
- nodeType: "MathObject",
8613
- mathMode,
8614
- lines: [converted.chain],
8615
- closing
9789
+ width: fallbackWidth,
9790
+ height: fallbackHeight,
9791
+ offsetLeft: 0,
9792
+ offsetTop: 0,
9793
+ scale: 1,
9794
+ source: "layout-viewport"
9795
+ };
9796
+ }
9797
+ function reasonPriority(reason) {
9798
+ if (reason === "orientation") return 3;
9799
+ if (reason === "resize") return 2;
9800
+ if (reason === "scroll") return 1;
9801
+ return 0;
9802
+ }
9803
+ function observeVisibleViewport(view, onChange) {
9804
+ let previous = visibleViewportSnapshot(view);
9805
+ let frame = null;
9806
+ let pendingReason = "scroll";
9807
+ onChange({
9808
+ snapshot: previous,
9809
+ initial: true,
9810
+ sizeChanged: false,
9811
+ offsetChanged: false,
9812
+ reason: "initial"
9813
+ });
9814
+ const emit = () => {
9815
+ frame = null;
9816
+ const next = visibleViewportSnapshot(view);
9817
+ const sizeChanged = next.width !== previous.width || next.height !== previous.height || next.scale !== previous.scale || next.source !== previous.source;
9818
+ const offsetChanged = next.offsetLeft !== previous.offsetLeft || next.offsetTop !== previous.offsetTop;
9819
+ const reason = pendingReason;
9820
+ pendingReason = "scroll";
9821
+ previous = next;
9822
+ onChange({ snapshot: next, initial: false, sizeChanged, offsetChanged, reason });
9823
+ };
9824
+ const schedule = (reason) => {
9825
+ if (reasonPriority(reason) > reasonPriority(pendingReason)) {
9826
+ pendingReason = reason;
9827
+ }
9828
+ if (frame !== null) {
9829
+ return;
9830
+ }
9831
+ frame = view.requestAnimationFrame(emit);
9832
+ };
9833
+ const onResize = () => schedule("resize");
9834
+ const onScroll = () => schedule("scroll");
9835
+ const onOrientation = () => schedule("orientation");
9836
+ const visualViewport = view.visualViewport;
9837
+ visualViewport?.addEventListener("resize", onResize);
9838
+ visualViewport?.addEventListener("scroll", onScroll);
9839
+ view.addEventListener("resize", onResize);
9840
+ view.addEventListener("orientationchange", onOrientation);
9841
+ return () => {
9842
+ visualViewport?.removeEventListener("resize", onResize);
9843
+ visualViewport?.removeEventListener("scroll", onScroll);
9844
+ view.removeEventListener("resize", onResize);
9845
+ view.removeEventListener("orientationchange", onOrientation);
9846
+ if (frame !== null) {
9847
+ view.cancelAnimationFrame(frame);
9848
+ frame = null;
8616
9849
  }
8617
9850
  };
8618
9851
  }
8619
9852
 
8620
- // src/debugJson.ts
8621
- function lineColumnForPosition(text, position) {
8622
- const before = text.slice(0, Math.max(0, position));
8623
- const lines = before.split("\n");
8624
- return {
8625
- line: lines.length,
8626
- column: (lines[lines.length - 1]?.length ?? 0) + 1
8627
- };
9853
+ // src/react/desktopPopover.ts
9854
+ var import_react3 = require("react");
9855
+ var POPOVER_GAP = 5;
9856
+ var VIEWPORT_MARGIN = 8;
9857
+ var MIN_USABLE_HEIGHT = 96;
9858
+ function clearPlacement(popover) {
9859
+ for (const property of ["position", "inset", "left", "top", "right", "bottom", "max-width", "max-height"]) {
9860
+ popover.style.removeProperty(property);
9861
+ }
9862
+ delete popover.dataset.placement;
8628
9863
  }
8629
- function parseJsonDebugInput(text) {
8630
- try {
8631
- return { ok: true, value: JSON.parse(text) };
8632
- } catch (error) {
8633
- const message = error instanceof Error ? error.message : String(error);
8634
- const positionMatch = message.match(/position\s+(\d+)/i);
8635
- if (positionMatch) {
8636
- const position = Number(positionMatch[1]);
8637
- if (Number.isFinite(position)) {
8638
- const location = lineColumnForPosition(text, position);
8639
- return { ok: false, error: `Invalid JSON at line ${String(location.line)}, column ${String(location.column)}: ${message}` };
8640
- }
9864
+ function useDesktopPopoverPlacement(rootRef, active, onClose) {
9865
+ (0, import_react3.useEffect)(() => {
9866
+ if (!active || typeof window === "undefined") {
9867
+ return;
8641
9868
  }
8642
- return { ok: false, error: `Invalid JSON: ${message}` };
8643
- }
9869
+ const root = rootRef.current;
9870
+ const trigger = root?.querySelector('.butex-widget__desktop-toolbar button[aria-expanded="true"]');
9871
+ const popover = trigger?.parentElement?.querySelector(
9872
+ ':scope > [role="menu"], :scope > [role="listbox"], :scope > [role="dialog"]'
9873
+ );
9874
+ if (!root || !trigger || !popover) {
9875
+ return;
9876
+ }
9877
+ let frame = null;
9878
+ const place = () => {
9879
+ frame = null;
9880
+ clearPlacement(popover);
9881
+ popover.style.position = "fixed";
9882
+ popover.style.inset = "auto";
9883
+ const rootRect = root.getBoundingClientRect();
9884
+ const scrollBoundary = root.closest(".butex-document2-widget__equation-modal-body");
9885
+ const scrollBoundaryRect = scrollBoundary?.getBoundingClientRect();
9886
+ const triggerRect = trigger.getBoundingClientRect();
9887
+ const boundaryLeft = Math.max(VIEWPORT_MARGIN, rootRect.left + VIEWPORT_MARGIN);
9888
+ const boundaryRight = Math.max(
9889
+ boundaryLeft + 1,
9890
+ Math.min(window.innerWidth - VIEWPORT_MARGIN, rootRect.right - VIEWPORT_MARGIN)
9891
+ );
9892
+ const boundaryTop = Math.max(VIEWPORT_MARGIN, (scrollBoundaryRect?.top ?? rootRect.top) + VIEWPORT_MARGIN);
9893
+ const boundaryBottom = Math.max(
9894
+ boundaryTop + 1,
9895
+ Math.min(window.innerHeight - VIEWPORT_MARGIN, (scrollBoundaryRect?.bottom ?? rootRect.bottom) - VIEWPORT_MARGIN)
9896
+ );
9897
+ const availableWidth = Math.max(1, boundaryRight - boundaryLeft);
9898
+ popover.style.maxWidth = `${availableWidth}px`;
9899
+ const naturalRect = popover.getBoundingClientRect();
9900
+ const popoverWidth = Math.min(Math.max(naturalRect.width, popover.scrollWidth), availableWidth);
9901
+ const preferredLeft = root.dir === "rtl" ? triggerRect.right - popoverWidth : triggerRect.left;
9902
+ const left = Math.min(Math.max(preferredLeft, boundaryLeft), boundaryRight - popoverWidth);
9903
+ const belowTop = triggerRect.bottom + POPOVER_GAP;
9904
+ const belowSpace = Math.max(0, boundaryBottom - belowTop);
9905
+ const aboveSpace = Math.max(0, triggerRect.top - boundaryTop - POPOVER_GAP);
9906
+ const naturalHeight = Math.max(naturalRect.height, popover.scrollHeight);
9907
+ const placeBelow = belowSpace >= Math.min(naturalHeight, MIN_USABLE_HEIGHT) || belowSpace >= aboveSpace;
9908
+ const availableHeight = placeBelow ? belowSpace : aboveSpace;
9909
+ const maxHeight = Math.max(1, availableHeight);
9910
+ const renderedHeight = Math.min(naturalHeight, maxHeight);
9911
+ const top = placeBelow ? belowTop : Math.max(boundaryTop, triggerRect.top - POPOVER_GAP - renderedHeight);
9912
+ popover.style.left = `${left}px`;
9913
+ popover.style.top = `${top}px`;
9914
+ popover.style.maxHeight = `${maxHeight}px`;
9915
+ popover.dataset.placement = placeBelow ? "below" : "above";
9916
+ };
9917
+ const schedulePlacement = () => {
9918
+ if (frame !== null) {
9919
+ window.cancelAnimationFrame(frame);
9920
+ }
9921
+ frame = window.requestAnimationFrame(place);
9922
+ };
9923
+ const handleKeyDown = (event) => {
9924
+ if (event.key === "Escape") {
9925
+ event.preventDefault();
9926
+ event.stopPropagation();
9927
+ onClose();
9928
+ window.requestAnimationFrame(() => trigger.focus());
9929
+ return;
9930
+ }
9931
+ if (!["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
9932
+ return;
9933
+ }
9934
+ if (popover.getAttribute("role") === "dialog") {
9935
+ return;
9936
+ }
9937
+ const items = Array.from(
9938
+ popover.querySelectorAll('[role="menuitem"]:not([disabled]), [role="option"]:not([disabled])')
9939
+ ).filter((item) => !item.hidden && item.getAttribute("aria-hidden") !== "true");
9940
+ if (items.length === 0 || event.target !== trigger && !popover.contains(event.target)) {
9941
+ return;
9942
+ }
9943
+ const currentIndex = items.indexOf(document.activeElement);
9944
+ let nextIndex;
9945
+ if (event.key === "Home") {
9946
+ nextIndex = 0;
9947
+ } else if (event.key === "End") {
9948
+ nextIndex = items.length - 1;
9949
+ } else if (event.key === "ArrowDown" || event.key === "ArrowRight") {
9950
+ nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % items.length;
9951
+ } else {
9952
+ nextIndex = currentIndex < 0 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
9953
+ }
9954
+ event.preventDefault();
9955
+ items[nextIndex]?.focus();
9956
+ };
9957
+ const closeOnOutsidePointer = (event) => {
9958
+ const target = event.target;
9959
+ if (target instanceof Node && !trigger.contains(target) && !popover.contains(target)) {
9960
+ onClose();
9961
+ }
9962
+ };
9963
+ const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedulePlacement);
9964
+ resizeObserver?.observe(root);
9965
+ const toolbar = root.querySelector(".butex-widget__desktop-toolbar");
9966
+ if (toolbar) {
9967
+ resizeObserver?.observe(toolbar);
9968
+ }
9969
+ window.addEventListener("resize", schedulePlacement);
9970
+ window.addEventListener("scroll", schedulePlacement, true);
9971
+ window.visualViewport?.addEventListener("resize", schedulePlacement);
9972
+ window.visualViewport?.addEventListener("scroll", schedulePlacement);
9973
+ document.addEventListener("keydown", handleKeyDown, true);
9974
+ document.addEventListener("pointerdown", closeOnOutsidePointer, true);
9975
+ schedulePlacement();
9976
+ return () => {
9977
+ if (frame !== null) {
9978
+ window.cancelAnimationFrame(frame);
9979
+ }
9980
+ resizeObserver?.disconnect();
9981
+ window.removeEventListener("resize", schedulePlacement);
9982
+ window.removeEventListener("scroll", schedulePlacement, true);
9983
+ window.visualViewport?.removeEventListener("resize", schedulePlacement);
9984
+ window.visualViewport?.removeEventListener("scroll", schedulePlacement);
9985
+ document.removeEventListener("keydown", handleKeyDown, true);
9986
+ document.removeEventListener("pointerdown", closeOnOutsidePointer, true);
9987
+ clearPlacement(popover);
9988
+ };
9989
+ }, [active, onClose, rootRef]);
8644
9990
  }
8645
9991
 
8646
9992
  // src/react/ButexEditor.tsx
8647
- var import_jsx_runtime = require("react/jsx-runtime");
9993
+ var import_jsx_runtime2 = require("react/jsx-runtime");
8648
9994
  var DIGIT_FORM_OPTIONS = [
8649
9995
  { id: "western", label: "456" },
8650
9996
  { id: "arabicIndic", label: "\u0664\u0665\u0666" },
8651
9997
  { id: "persianIndic", label: "\u06F4\u06F5\u06F6" }
8652
9998
  ];
8653
9999
  var ACCENT_COMMANDS_LIST = accentCommandsList();
8654
- var FUNCTION_COMMANDS = atomicCommandsByCategory("function");
8655
- var LIMITS_SERIES_COMMANDS = atomicCommandsByCategory("limits_series");
8656
- var FUNCTION2_COMMANDS = atomicCommandsByCategory("function2");
8657
- var DERIVATIVE_COMMANDS = atomicCommandsByCategory("derivative");
8658
- var GROUP_COMMANDS = atomicCommandsByCategory("groups");
8659
- var SPACING_COMMANDS = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
10000
+ var FUNCTION_COMMANDS2 = atomicCommandsByCategory("function");
10001
+ var LIMITS_SERIES_COMMANDS2 = atomicCommandsByCategory("limits_series");
10002
+ var FUNCTION2_COMMANDS2 = atomicCommandsByCategory("function2");
10003
+ var DERIVATIVE_COMMANDS2 = atomicCommandsByCategory("derivative");
10004
+ var GROUP_COMMANDS2 = atomicCommandsByCategory("groups");
10005
+ var SPACING_COMMANDS2 = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
8660
10006
  var OPERATOR_COMMANDS = atomicOperatorCommandsByCategory("operators1");
8661
10007
  var OPERATOR2_COMMANDS = atomicOperatorCommandsByCategory("operators2");
8662
10008
  var OPERATOR3_COMMANDS = atomicOperatorCommandsByCategory("operators3");
8663
10009
  var DOT_COMMANDS = atomicOperatorCommandsByCategory("dots");
8664
10010
  var INTEGRAL_COMMANDS = atomicOperatorCommandsByCategory("integrals");
8665
- var MATRIX_STYLES = [
10011
+ var MATRIX_STYLES2 = [
8666
10012
  { id: "matrix", label: "\u25A1" },
8667
10013
  { id: "pmatrix", label: "(\u25A1)" },
8668
10014
  { id: "bmatrix", label: "[\u25A1]" },
@@ -8670,15 +10016,15 @@ var MATRIX_STYLES = [
8670
10016
  { id: "vmatrix", label: "|\u25A1|" },
8671
10017
  { id: "Vmatrix", label: "||\u25A1||" }
8672
10018
  ];
8673
- var ARRAY_ALIGNMENTS = [
10019
+ var ARRAY_ALIGNMENTS2 = [
8674
10020
  { id: "l" },
8675
10021
  { id: "c" },
8676
10022
  { id: "r" }
8677
10023
  ];
8678
- function matrixSizeLabel(rows, columns, messages) {
10024
+ function matrixSizeLabel2(rows, columns, messages) {
8679
10025
  return `${String(rows)} ${messages.row} \xD7 ${String(columns)} ${messages.column}`;
8680
10026
  }
8681
- function clampMatrixSize(value) {
10027
+ function clampMatrixSize2(value) {
8682
10028
  return Math.max(1, Math.min(12, Math.trunc(value)));
8683
10029
  }
8684
10030
  function digitFormLabel(digitForm) {
@@ -8687,7 +10033,7 @@ function digitFormLabel(digitForm) {
8687
10033
  function characterFontOption(fontId) {
8688
10034
  return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
8689
10035
  }
8690
- function characterFontTitle(fontId, messages) {
10036
+ function characterFontTitle2(fontId, messages) {
8691
10037
  const key = characterFontSpec(fontId).titleKey;
8692
10038
  return messages[key] ?? messages.defaultFont;
8693
10039
  }
@@ -8696,7 +10042,7 @@ function digitFormTitle(digitForm, messages) {
8696
10042
  if (digitForm === "persianIndic") return messages.persianIndicDigits;
8697
10043
  return messages.westernDigits;
8698
10044
  }
8699
- function matrixStyleTitle(style, messages) {
10045
+ function matrixStyleTitle2(style, messages) {
8700
10046
  if (style === "pmatrix") return messages.matrixParentheses;
8701
10047
  if (style === "bmatrix") return messages.matrixBrackets;
8702
10048
  if (style === "Bmatrix") return messages.matrixBraces;
@@ -8709,7 +10055,7 @@ function alignmentCopy(alignment, messages) {
8709
10055
  if (alignment === "r") return { label: messages.alignRight, title: messages.alignColumnRight };
8710
10056
  return { label: messages.alignCenter, title: messages.alignColumnCenter };
8711
10057
  }
8712
- function spacingArrow(spec, side) {
10058
+ function spacingArrow2(spec, side) {
8713
10059
  const pointsWithFlow = spec.spacing.direction === "positive";
8714
10060
  if (pointsWithFlow) {
8715
10061
  return side === "arabic" ? "\u2190" : "\u2192";
@@ -8720,16 +10066,16 @@ function renderArabicCommandLabel(command) {
8720
10066
  if (command.id !== "ln") {
8721
10067
  return command.arabicLabel;
8722
10068
  }
8723
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
8724
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
8725
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
10069
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
10070
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
10071
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
8726
10072
  ] });
8727
10073
  }
8728
10074
  function renderOperatorCommandLabel(command) {
8729
10075
  if (!command.svg_path) {
8730
10076
  return command.Label;
8731
10077
  }
8732
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10078
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
8733
10079
  "span",
8734
10080
  {
8735
10081
  className: "operator-command-svg-label",
@@ -8745,7 +10091,7 @@ function renderOperatorMenuButtonLabel(command, fallback) {
8745
10091
  if (!command) {
8746
10092
  return fallback;
8747
10093
  }
8748
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
10094
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
8749
10095
  }
8750
10096
  function passiveTreeText(session, messages) {
8751
10097
  const passive = session.activeSide === "arabic" ? session.englishTree : session.arabicTree;
@@ -8755,67 +10101,104 @@ function passiveTreeText(session, messages) {
8755
10101
 
8756
10102
  ${latex || messages.empty}`;
8757
10103
  }
8758
- var ButexEditor = (0, import_react.forwardRef)(
8759
- function ButexEditor2({ className, debug = false, defaultSide, uiLocale = "ar", initialSession, onSessionChange }, ref) {
10104
+ var ButexEditor = (0, import_react4.forwardRef)(
10105
+ function ButexEditor2({ className, debug = false, defaultSide, uiLocale = "ar", initialSession, onSessionChange, responsiveMode = "auto", showSideSwitcher = true }, ref) {
8760
10106
  const messages = equationEditorMessages(uiLocale);
10107
+ const previewPanelId = (0, import_react4.useId)();
8761
10108
  const debugEnabled = debug || typeof window !== "undefined" && new URLSearchParams(window.location.search).get("debug") === "1";
8762
- const wrapperRef = (0, import_react.useRef)(null);
8763
- const surfaceRef = (0, import_react.useRef)(null);
8764
- const inputRef = (0, import_react.useRef)(null);
8765
- const mathOutputRef = (0, import_react.useRef)(null);
8766
- const renderErrorRef = (0, import_react.useRef)(null);
8767
- const latexLinesRef = (0, import_react.useRef)(null);
8768
- const passivePreviewRef = (0, import_react.useRef)(null);
8769
- const debugLogRef = (0, import_react.useRef)(null);
8770
- const undoBtnRef = (0, import_react.useRef)(null);
8771
- const redoBtnRef = (0, import_react.useRef)(null);
8772
- const copyBtnRef = (0, import_react.useRef)(null);
8773
- const cutBtnRef = (0, import_react.useRef)(null);
8774
- const splitTypingBtnRef = (0, import_react.useRef)(null);
8775
- const characterFontBtnRef = (0, import_react.useRef)(null);
8776
- const digitFormBtnRef = (0, import_react.useRef)(null);
8777
- const runtimeRef = (0, import_react.useRef)(null);
8778
- const debugRef = (0, import_react.useRef)(debug);
10109
+ const wrapperRef = (0, import_react4.useRef)(null);
10110
+ const surfaceRef = (0, import_react4.useRef)(null);
10111
+ const inputRef = (0, import_react4.useRef)(null);
10112
+ const mathOutputRef = (0, import_react4.useRef)(null);
10113
+ const renderErrorRef = (0, import_react4.useRef)(null);
10114
+ const latexLinesRef = (0, import_react4.useRef)(null);
10115
+ const passivePreviewRef = (0, import_react4.useRef)(null);
10116
+ const debugLogRef = (0, import_react4.useRef)(null);
10117
+ const undoBtnRef = (0, import_react4.useRef)(null);
10118
+ const redoBtnRef = (0, import_react4.useRef)(null);
10119
+ const copyBtnRef = (0, import_react4.useRef)(null);
10120
+ const cutBtnRef = (0, import_react4.useRef)(null);
10121
+ const splitTypingBtnRef = (0, import_react4.useRef)(null);
10122
+ const characterFontBtnRef = (0, import_react4.useRef)(null);
10123
+ const digitFormBtnRef = (0, import_react4.useRef)(null);
10124
+ const runtimeRef = (0, import_react4.useRef)(null);
10125
+ const debugRef = (0, import_react4.useRef)(debug);
8779
10126
  debugRef.current = debugEnabled;
8780
- const uiLocaleRef = (0, import_react.useRef)(uiLocale);
10127
+ const uiLocaleRef = (0, import_react4.useRef)(uiLocale);
8781
10128
  uiLocaleRef.current = uiLocale;
8782
- const onSessionChangeRef = (0, import_react.useRef)(onSessionChange);
10129
+ const onSessionChangeRef = (0, import_react4.useRef)(onSessionChange);
8783
10130
  onSessionChangeRef.current = onSessionChange;
8784
- const debugBodyHiddenRef = (0, import_react.useRef)(false);
8785
- const [debugBodyHidden, setDebugBodyHidden] = (0, import_react.useState)(false);
10131
+ const debugBodyHiddenRef = (0, import_react4.useRef)(false);
10132
+ const [debugBodyHidden, setDebugBodyHidden] = (0, import_react4.useState)(false);
8786
10133
  debugBodyHiddenRef.current = debugBodyHidden;
8787
- const [debugImportOpen, setDebugImportOpen] = (0, import_react.useState)(false);
8788
- const [debugImportText, setDebugImportText] = (0, import_react.useState)("");
8789
- const [debugImportError, setDebugImportError] = (0, import_react.useState)("");
8790
- const [digitMenuOpen, setDigitMenuOpen] = (0, import_react.useState)(false);
8791
- const [characterFontMenuOpen, setCharacterFontMenuOpen] = (0, import_react.useState)(false);
8792
- const [delimiterMenuOpen, setDelimiterMenuOpen] = (0, import_react.useState)(false);
8793
- const [matrixMenuOpen, setMatrixMenuOpen] = (0, import_react.useState)(false);
8794
- const [spacingMenuOpen, setSpacingMenuOpen] = (0, import_react.useState)(false);
8795
- const [functionMenuOpen, setFunctionMenuOpen] = (0, import_react.useState)(false);
8796
- const [limitsSeriesMenuOpen, setLimitsSeriesMenuOpen] = (0, import_react.useState)(false);
8797
- const [function2MenuOpen, setFunction2MenuOpen] = (0, import_react.useState)(false);
8798
- const [derivativeMenuOpen, setDerivativeMenuOpen] = (0, import_react.useState)(false);
8799
- const [groupMenuOpen, setGroupMenuOpen] = (0, import_react.useState)(false);
8800
- const [operatorMenuOpen, setOperatorMenuOpen] = (0, import_react.useState)(false);
8801
- const [operator2MenuOpen, setOperator2MenuOpen] = (0, import_react.useState)(false);
8802
- const [operator3MenuOpen, setOperator3MenuOpen] = (0, import_react.useState)(false);
8803
- const [dotMenuOpen, setDotMenuOpen] = (0, import_react.useState)(false);
8804
- const [accentMenuOpen, setAccentMenuOpen] = (0, import_react.useState)(false);
8805
- const [integralMenuOpen, setIntegralMenuOpen] = (0, import_react.useState)(false);
8806
- const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react.useState)("western");
8807
- const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react.useState)("default");
8808
- const [activeEditorSide, setActiveEditorSide] = (0, import_react.useState)("arabic");
8809
- const [envPaletteMode, setEnvPaletteMode] = (0, import_react.useState)("matrix");
8810
- const [matrixStyle, setMatrixStyle] = (0, import_react.useState)("pmatrix");
8811
- const [matrixRows, setMatrixRows] = (0, import_react.useState)(2);
8812
- const [matrixColumns, setMatrixColumns] = (0, import_react.useState)(2);
8813
- const [matrixHover, setMatrixHover] = (0, import_react.useState)(null);
8814
- const [arrayAlignmentColumn, setArrayAlignmentColumn] = (0, import_react.useState)(1);
8815
- (0, import_react.useImperativeHandle)(ref, () => ({
10134
+ const [debugImportOpen, setDebugImportOpen] = (0, import_react4.useState)(false);
10135
+ const [debugImportText, setDebugImportText] = (0, import_react4.useState)("");
10136
+ const [debugImportError, setDebugImportError] = (0, import_react4.useState)("");
10137
+ const [openDesktopMenu, setOpenDesktopMenu] = (0, import_react4.useState)(null);
10138
+ const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react4.useState)("western");
10139
+ const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react4.useState)("default");
10140
+ const [activeEditorSide, setActiveEditorSide] = (0, import_react4.useState)("arabic");
10141
+ const [compactPreviewOpen, setCompactPreviewOpen] = (0, import_react4.useState)(false);
10142
+ const [compactControlState, setCompactControlState] = (0, import_react4.useState)({
10143
+ canUndo: false,
10144
+ canRedo: false,
10145
+ hasSelection: false,
10146
+ splitLeafTyping: initialSession?.splitLeafTyping ?? true
10147
+ });
10148
+ const [envPaletteMode, setEnvPaletteMode] = (0, import_react4.useState)("matrix");
10149
+ const [matrixStyle, setMatrixStyle] = (0, import_react4.useState)("pmatrix");
10150
+ const [matrixRows, setMatrixRows] = (0, import_react4.useState)(2);
10151
+ const [matrixColumns, setMatrixColumns] = (0, import_react4.useState)(2);
10152
+ const [matrixHover, setMatrixHover] = (0, import_react4.useState)(null);
10153
+ const [arrayAlignmentColumn, setArrayAlignmentColumn] = (0, import_react4.useState)(1);
10154
+ const closeDesktopMenu = (0, import_react4.useCallback)(() => setOpenDesktopMenu(null), []);
10155
+ useDesktopPopoverPlacement(wrapperRef, openDesktopMenu !== null, closeDesktopMenu);
10156
+ function desktopMenuOpen(menu) {
10157
+ return openDesktopMenu === menu;
10158
+ }
10159
+ function setDesktopMenuOpen(menu, value) {
10160
+ setOpenDesktopMenu((current) => {
10161
+ const isOpen = current === menu;
10162
+ const shouldOpen = typeof value === "function" ? value(isOpen) : value;
10163
+ return shouldOpen ? menu : isOpen ? null : current;
10164
+ });
10165
+ }
10166
+ const delimiterMenuOpen = desktopMenuOpen("delimiters");
10167
+ const matrixMenuOpen = desktopMenuOpen("matrix");
10168
+ const spacingMenuOpen = desktopMenuOpen("spacing");
10169
+ const functionMenuOpen = desktopMenuOpen("functions");
10170
+ const limitsSeriesMenuOpen = desktopMenuOpen("limitsSeries");
10171
+ const function2MenuOpen = desktopMenuOpen("functions2");
10172
+ const derivativeMenuOpen = desktopMenuOpen("derivatives");
10173
+ const groupMenuOpen = desktopMenuOpen("groups");
10174
+ const operatorMenuOpen = desktopMenuOpen("operators1");
10175
+ const operator2MenuOpen = desktopMenuOpen("operators2");
10176
+ const operator3MenuOpen = desktopMenuOpen("operators3");
10177
+ const dotMenuOpen = desktopMenuOpen("dots");
10178
+ const accentMenuOpen = desktopMenuOpen("accents");
10179
+ const integralMenuOpen = desktopMenuOpen("integrals");
10180
+ const characterFontMenuOpen = desktopMenuOpen("font");
10181
+ const digitMenuOpen = desktopMenuOpen("digits");
10182
+ const setDelimiterMenuOpen = (value) => setDesktopMenuOpen("delimiters", value);
10183
+ const setMatrixMenuOpen = (value) => setDesktopMenuOpen("matrix", value);
10184
+ const setSpacingMenuOpen = (value) => setDesktopMenuOpen("spacing", value);
10185
+ const setFunctionMenuOpen = (value) => setDesktopMenuOpen("functions", value);
10186
+ const setLimitsSeriesMenuOpen = (value) => setDesktopMenuOpen("limitsSeries", value);
10187
+ const setFunction2MenuOpen = (value) => setDesktopMenuOpen("functions2", value);
10188
+ const setDerivativeMenuOpen = (value) => setDesktopMenuOpen("derivatives", value);
10189
+ const setGroupMenuOpen = (value) => setDesktopMenuOpen("groups", value);
10190
+ const setOperatorMenuOpen = (value) => setDesktopMenuOpen("operators1", value);
10191
+ const setOperator2MenuOpen = (value) => setDesktopMenuOpen("operators2", value);
10192
+ const setOperator3MenuOpen = (value) => setDesktopMenuOpen("operators3", value);
10193
+ const setDotMenuOpen = (value) => setDesktopMenuOpen("dots", value);
10194
+ const setAccentMenuOpen = (value) => setDesktopMenuOpen("accents", value);
10195
+ const setIntegralMenuOpen = (value) => setDesktopMenuOpen("integrals", value);
10196
+ const setCharacterFontMenuOpen = (value) => setDesktopMenuOpen("font", value);
10197
+ const setDigitMenuOpen = (value) => setDesktopMenuOpen("digits", value);
10198
+ (0, import_react4.useImperativeHandle)(ref, () => ({
8816
10199
  getRuntime: () => runtimeRef.current
8817
10200
  }));
8818
- const updatePreview = (0, import_react.useCallback)(async (session) => {
10201
+ const updatePreview = (0, import_react4.useCallback)(async (session) => {
8819
10202
  const mathOutputEl = mathOutputRef.current;
8820
10203
  const renderErrorEl = renderErrorRef.current;
8821
10204
  const latexLinesEl = latexLinesRef.current;
@@ -8865,7 +10248,7 @@ ${arabic || currentMessages.empty}`;
8865
10248
  }
8866
10249
  }
8867
10250
  }, []);
8868
- const updatePreviewRef = (0, import_react.useRef)(updatePreview);
10251
+ const updatePreviewRef = (0, import_react4.useRef)(updatePreview);
8869
10252
  updatePreviewRef.current = updatePreview;
8870
10253
  async function copyDebugText(text) {
8871
10254
  try {
@@ -8915,7 +10298,7 @@ ${arabic || currentMessages.empty}`;
8915
10298
  setDebugImportError(importError instanceof Error ? importError.message : String(importError));
8916
10299
  }
8917
10300
  }
8918
- (0, import_react.useEffect)(() => {
10301
+ (0, import_react4.useEffect)(() => {
8919
10302
  injectWidgetChromeCss();
8920
10303
  injectBuTeXEditorStyles(typeof document !== "undefined" ? document : void 0);
8921
10304
  const surfaceEl = surfaceRef.current;
@@ -8936,11 +10319,28 @@ ${arabic || currentMessages.empty}`;
8936
10319
  splitTypingBtn: splitTypingBtnRef.current,
8937
10320
  digitFormBtn: digitFormBtnRef.current
8938
10321
  },
8939
- outsidePointerIgnoreSelectors: [".butex-widget .toolbar", "#btn-copy", "#btn-cut", "#btn-paste"],
10322
+ outsidePointerIgnoreSelectors: [
10323
+ ".butex-widget .toolbar",
10324
+ ".butex-widget__mobile-toolbar",
10325
+ ".butex-widget__command-sheet-backdrop",
10326
+ "#btn-copy",
10327
+ "#btn-cut",
10328
+ "#btn-paste"
10329
+ ],
8940
10330
  onSessionChange: (session) => {
8941
10331
  setSelectedDigitForm(session.currentDigitForm ?? "western");
8942
10332
  setSelectedCharacterFont(session.currentCharacterFont ?? "default");
8943
10333
  setActiveEditorSide(session.activeSide);
10334
+ const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
10335
+ const nextCompactState = {
10336
+ canUndo: undoBtnRef.current?.disabled === false,
10337
+ canRedo: redoBtnRef.current?.disabled === false,
10338
+ hasSelection,
10339
+ splitLeafTyping: session.splitLeafTyping
10340
+ };
10341
+ setCompactControlState(
10342
+ (current) => current.canUndo === nextCompactState.canUndo && current.canRedo === nextCompactState.canRedo && current.hasSelection === nextCompactState.hasSelection && current.splitLeafTyping === nextCompactState.splitLeafTyping ? current : nextCompactState
10343
+ );
8944
10344
  onSessionChangeRef.current?.(session);
8945
10345
  void updatePreviewRef.current(session).catch((err) => {
8946
10346
  const message = err instanceof Error ? err.message : String(err);
@@ -8953,6 +10353,19 @@ ${arabic || currentMessages.empty}`;
8953
10353
  }
8954
10354
  });
8955
10355
  runtimeRef.current = runtime;
10356
+ let viewportRevealFrame = null;
10357
+ const stopViewportObserver = observeVisibleViewport(window, (change) => {
10358
+ if (change.initial || !change.sizeChanged && change.reason !== "orientation") {
10359
+ return;
10360
+ }
10361
+ if (viewportRevealFrame !== null) {
10362
+ window.cancelAnimationFrame(viewportRevealFrame);
10363
+ }
10364
+ viewportRevealFrame = window.requestAnimationFrame(() => {
10365
+ viewportRevealFrame = null;
10366
+ revealCaretInSurface(surfaceEl);
10367
+ });
10368
+ });
8956
10369
  if (typeof window !== "undefined" && window.MathJax?.startup?.promise) {
8957
10370
  window.MathJax.startup.promise.then(() => {
8958
10371
  runtime.render();
@@ -8968,11 +10381,15 @@ ${arabic || currentMessages.empty}`;
8968
10381
  }
8969
10382
  runtime.focusInput();
8970
10383
  return () => {
10384
+ stopViewportObserver();
10385
+ if (viewportRevealFrame !== null) {
10386
+ window.cancelAnimationFrame(viewportRevealFrame);
10387
+ }
8971
10388
  runtime.destroy();
8972
10389
  runtimeRef.current = null;
8973
10390
  };
8974
10391
  }, []);
8975
- (0, import_react.useEffect)(() => {
10392
+ (0, import_react4.useEffect)(() => {
8976
10393
  runtimeRef.current?.setUiLocale(uiLocale);
8977
10394
  const session = runtimeRef.current?.getSession();
8978
10395
  if (session) {
@@ -8991,24 +10408,43 @@ ${arabic || currentMessages.empty}`;
8991
10408
  runtimeRef.current?.insertMatrixEnv(matrixStyle, rows, columns);
8992
10409
  }
8993
10410
  }
8994
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10411
+ const compactToolbarState = {
10412
+ ...compactControlState,
10413
+ activeSide: activeEditorSide,
10414
+ characterFont: selectedCharacterFont,
10415
+ digitForm: selectedDigitForm2
10416
+ };
10417
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
8995
10418
  "div",
8996
10419
  {
8997
10420
  ref: wrapperRef,
8998
10421
  className: `butex-widget ${className ?? ""}`.trim(),
10422
+ "data-compact-preview": compactPreviewOpen ? "open" : "closed",
10423
+ "data-responsive-mode": responsiveMode,
8999
10424
  dir: uiLocaleDirection(uiLocale),
9000
10425
  lang: uiLocale,
9001
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget-layout", children: [
9002
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "panel", children: [
9003
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar", children: [
9004
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
9005
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
9006
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
10426
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-widget-layout", children: [
10427
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "panel panel-editor", children: [
10428
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10429
+ EquationMobileToolbar,
10430
+ {
10431
+ uiLocale,
10432
+ messages,
10433
+ state: compactToolbarState,
10434
+ showSideSwitcher,
10435
+ inputRef,
10436
+ getRuntime: () => runtimeRef.current
10437
+ }
10438
+ ),
10439
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar butex-widget__desktop-toolbar", children: [
10440
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
10441
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
10442
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
9007
10443
  ] }),
9008
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
9009
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
9010
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
9011
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10444
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
10445
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
10446
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
10447
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9012
10448
  "button",
9013
10449
  {
9014
10450
  id: "btn-paste",
@@ -9025,9 +10461,9 @@ ${arabic || currentMessages.empty}`;
9025
10461
  }
9026
10462
  )
9027
10463
  ] }),
9028
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }),
9029
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
9030
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10464
+ showSideSwitcher ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }) : null,
10465
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
10466
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9031
10467
  "div",
9032
10468
  {
9033
10469
  className: "delimiter-command-menu",
@@ -9038,27 +10474,27 @@ ${arabic || currentMessages.empty}`;
9038
10474
  }
9039
10475
  },
9040
10476
  children: [
9041
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10477
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9042
10478
  "button",
9043
10479
  {
9044
10480
  className: "icon-btn delimiter-command-btn",
9045
10481
  type: "button",
9046
10482
  title: messages.insertDelimiters,
9047
10483
  "aria-label": messages.insertDelimiters,
9048
- "aria-haspopup": "listbox",
10484
+ "aria-haspopup": "menu",
9049
10485
  "aria-expanded": delimiterMenuOpen,
9050
10486
  onClick: () => setDelimiterMenuOpen((open) => !open),
9051
10487
  children: "()"
9052
10488
  }
9053
10489
  ),
9054
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "delimiter-command-options", role: "listbox", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
9055
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10490
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "delimiter-command-options", role: "menu", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
10491
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9056
10492
  "button",
9057
10493
  {
9058
10494
  className: "delimiter-command-option",
9059
10495
  "data-delim": "paren",
9060
10496
  type: "button",
9061
- role: "option",
10497
+ role: "menuitem",
9062
10498
  title: messages.insertParentheses,
9063
10499
  "aria-label": messages.insertParentheses,
9064
10500
  onMouseDown: (event) => event.preventDefault(),
@@ -9070,13 +10506,13 @@ ${arabic || currentMessages.empty}`;
9070
10506
  children: "()"
9071
10507
  }
9072
10508
  ),
9073
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10509
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9074
10510
  "button",
9075
10511
  {
9076
10512
  className: "delimiter-command-option",
9077
10513
  "data-delim": "bracket",
9078
10514
  type: "button",
9079
- role: "option",
10515
+ role: "menuitem",
9080
10516
  title: messages.insertBrackets,
9081
10517
  "aria-label": messages.insertBrackets,
9082
10518
  onMouseDown: (event) => event.preventDefault(),
@@ -9088,13 +10524,13 @@ ${arabic || currentMessages.empty}`;
9088
10524
  children: "[]"
9089
10525
  }
9090
10526
  ),
9091
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10527
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9092
10528
  "button",
9093
10529
  {
9094
10530
  className: "delimiter-command-option",
9095
10531
  "data-delim": "brace",
9096
10532
  type: "button",
9097
- role: "option",
10533
+ role: "menuitem",
9098
10534
  title: messages.insertBraces,
9099
10535
  "aria-label": messages.insertBraces,
9100
10536
  onMouseDown: (event) => event.preventDefault(),
@@ -9110,40 +10546,40 @@ ${arabic || currentMessages.empty}`;
9110
10546
  ]
9111
10547
  }
9112
10548
  ),
9113
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
10549
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
9114
10550
  runtimeRef.current?.insertFraction();
9115
10551
  focusSurface();
9116
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
9117
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0623" }),
9118
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0628" })
10552
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
10553
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0623" }),
10554
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0628" })
9119
10555
  ] }) }),
9120
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
10556
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
9121
10557
  runtimeRef.current?.insertSqrt();
9122
10558
  focusSurface();
9123
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
9124
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-overset", className: "icon-btn", type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => {
10559
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
10560
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-overset", className: "icon-btn", type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => {
9125
10561
  runtimeRef.current?.insertOverset();
9126
10562
  focusSurface();
9127
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
9128
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" }),
9129
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" })
10563
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
10564
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u2217" }),
10565
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u25A1" })
9130
10566
  ] }) }),
9131
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-underset", className: "icon-btn", type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => {
10567
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-underset", className: "icon-btn", type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => {
9132
10568
  runtimeRef.current?.insertUnderset();
9133
10569
  focusSurface();
9134
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
9135
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" }),
9136
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" })
10570
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
10571
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u25A1" }),
10572
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u2217" })
9137
10573
  ] }) }),
9138
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-accent-pair", className: "icon-btn", type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => {
10574
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-accent-pair", className: "icon-btn", type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => {
9139
10575
  runtimeRef.current?.insertAccentPair();
9140
10576
  focusSurface();
9141
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
9142
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" }),
9143
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" }),
9144
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" })
10577
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
10578
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u2217" }),
10579
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u25A1" }),
10580
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u2217" })
9145
10581
  ] }) }),
9146
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10582
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9147
10583
  "div",
9148
10584
  {
9149
10585
  className: "function-command-menu operator-command-menu",
@@ -9154,7 +10590,7 @@ ${arabic || currentMessages.empty}`;
9154
10590
  }
9155
10591
  },
9156
10592
  children: [
9157
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10593
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9158
10594
  "button",
9159
10595
  {
9160
10596
  id: "insert-accents",
@@ -9162,21 +10598,21 @@ ${arabic || currentMessages.empty}`;
9162
10598
  type: "button",
9163
10599
  title: messages.insertAccents,
9164
10600
  "aria-label": messages.insertAccents,
9165
- "aria-haspopup": "listbox",
10601
+ "aria-haspopup": "menu",
9166
10602
  "aria-expanded": accentMenuOpen,
9167
10603
  onClick: () => setAccentMenuOpen((open) => !open),
9168
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
9169
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u02C6" }),
9170
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" })
10604
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
10605
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u02C6" }),
10606
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u25A1" })
9171
10607
  ] })
9172
10608
  }
9173
10609
  ),
9174
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertAccents, hidden: !accentMenuOpen, children: ACCENT_COMMANDS_LIST.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10610
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertAccents, hidden: !accentMenuOpen, children: ACCENT_COMMANDS_LIST.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9175
10611
  "button",
9176
10612
  {
9177
10613
  className: "function-command-option operator-command-option",
9178
10614
  type: "button",
9179
- role: "option",
10615
+ role: "menuitem",
9180
10616
  title: accentCommandTitle(command, uiLocale),
9181
10617
  "aria-label": accentCommandTitle(command, uiLocale),
9182
10618
  onMouseDown: (event) => event.preventDefault(),
@@ -9185,7 +10621,7 @@ ${arabic || currentMessages.empty}`;
9185
10621
  setAccentMenuOpen(false);
9186
10622
  focusSurface();
9187
10623
  },
9188
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "operator-command-label", children: command.label })
10624
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "operator-command-label", children: command.label })
9189
10625
  },
9190
10626
  command.id
9191
10627
  )) })
@@ -9193,7 +10629,7 @@ ${arabic || currentMessages.empty}`;
9193
10629
  }
9194
10630
  )
9195
10631
  ] }),
9196
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10632
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9197
10633
  "div",
9198
10634
  {
9199
10635
  className: "matrix-command-menu",
@@ -9204,7 +10640,7 @@ ${arabic || currentMessages.empty}`;
9204
10640
  }
9205
10641
  },
9206
10642
  children: [
9207
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10643
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9208
10644
  "button",
9209
10645
  {
9210
10646
  className: "icon-btn matrix-command-btn",
@@ -9214,20 +10650,20 @@ ${arabic || currentMessages.empty}`;
9214
10650
  "aria-haspopup": "dialog",
9215
10651
  "aria-expanded": matrixMenuOpen,
9216
10652
  onClick: () => setMatrixMenuOpen((open) => !open),
9217
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
9218
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
9219
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
9220
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
9221
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {})
10653
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
10654
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {}),
10655
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {}),
10656
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {}),
10657
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {})
9222
10658
  ] })
9223
10659
  }
9224
10660
  ),
9225
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
9226
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
10661
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
10662
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
9227
10663
  { id: "matrix", label: messages.matrix },
9228
10664
  { id: "array", label: messages.array },
9229
10665
  { id: "aligned", label: messages.aligned }
9230
- ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10666
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9231
10667
  "button",
9232
10668
  {
9233
10669
  type: "button",
@@ -9245,14 +10681,14 @@ ${arabic || currentMessages.empty}`;
9245
10681
  },
9246
10682
  option.id
9247
10683
  )) }),
9248
- envPaletteMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10684
+ envPaletteMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES2.map((style) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9249
10685
  "button",
9250
10686
  {
9251
10687
  type: "button",
9252
10688
  role: "option",
9253
10689
  "aria-selected": matrixStyle === style.id,
9254
10690
  className: "matrix-style-option",
9255
- title: matrixStyleTitle(style.id, messages),
10691
+ title: matrixStyleTitle2(style.id, messages),
9256
10692
  onMouseDown: (event) => event.preventDefault(),
9257
10693
  onClick: () => {
9258
10694
  setMatrixStyle(style.id);
@@ -9261,21 +10697,21 @@ ${arabic || currentMessages.empty}`;
9261
10697
  },
9262
10698
  style.id
9263
10699
  )) }) : null,
9264
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel(matrixRows, matrixColumns, messages) }),
9265
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
10700
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel2(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel2(matrixRows, matrixColumns, messages) }),
10701
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
9266
10702
  { length: 8 },
9267
10703
  (_, rowIndex) => Array.from({ length: 8 }, (_2, columnIndex) => {
9268
10704
  const rows = rowIndex + 1;
9269
10705
  const columns = columnIndex + 1;
9270
10706
  const activeRows = matrixHover?.rows ?? matrixRows;
9271
10707
  const activeColumns = matrixHover?.columns ?? matrixColumns;
9272
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10708
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9273
10709
  "button",
9274
10710
  {
9275
10711
  type: "button",
9276
10712
  className: rows <= activeRows && columns <= activeColumns ? "matrix-grid-cell active" : "matrix-grid-cell",
9277
- title: matrixSizeLabel(rows, columns, messages),
9278
- "aria-label": matrixSizeLabel(rows, columns, messages),
10713
+ title: matrixSizeLabel2(rows, columns, messages),
10714
+ "aria-label": matrixSizeLabel2(rows, columns, messages),
9279
10715
  onMouseEnter: () => setMatrixHover({ rows, columns }),
9280
10716
  onMouseDown: (event) => event.preventDefault(),
9281
10717
  onClick: () => {
@@ -9291,42 +10727,42 @@ ${arabic || currentMessages.empty}`;
9291
10727
  );
9292
10728
  })
9293
10729
  ) }),
9294
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "matrix-custom-size", children: [
9295
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
10730
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "matrix-custom-size", children: [
10731
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
9296
10732
  messages.row,
9297
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10733
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9298
10734
  "input",
9299
10735
  {
9300
10736
  type: "number",
9301
10737
  min: 1,
9302
10738
  max: 12,
9303
10739
  value: matrixRows,
9304
- onChange: (event) => setMatrixRows(clampMatrixSize(Number(event.currentTarget.value) || 1))
10740
+ onChange: (event) => setMatrixRows(clampMatrixSize2(Number(event.currentTarget.value) || 1))
9305
10741
  }
9306
10742
  )
9307
10743
  ] }),
9308
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
10744
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
9309
10745
  messages.column,
9310
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10746
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9311
10747
  "input",
9312
10748
  {
9313
10749
  type: "number",
9314
10750
  min: 1,
9315
10751
  max: 12,
9316
10752
  value: matrixColumns,
9317
- onChange: (event) => setMatrixColumns(clampMatrixSize(Number(event.currentTarget.value) || 1))
10753
+ onChange: (event) => setMatrixColumns(clampMatrixSize2(Number(event.currentTarget.value) || 1))
9318
10754
  }
9319
10755
  )
9320
10756
  ] }),
9321
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10757
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9322
10758
  "button",
9323
10759
  {
9324
10760
  type: "button",
9325
10761
  className: "matrix-insert-custom",
9326
10762
  onMouseDown: (event) => event.preventDefault(),
9327
10763
  onClick: () => {
9328
- const rows = clampMatrixSize(matrixRows);
9329
- const columns = clampMatrixSize(matrixColumns);
10764
+ const rows = clampMatrixSize2(matrixRows);
10765
+ const columns = clampMatrixSize2(matrixColumns);
9330
10766
  insertSelectedEnvironment(rows, columns);
9331
10767
  setMatrixMenuOpen(false);
9332
10768
  setMatrixHover(null);
@@ -9336,23 +10772,23 @@ ${arabic || currentMessages.empty}`;
9336
10772
  }
9337
10773
  )
9338
10774
  ] }),
9339
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
9340
- envPaletteMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
9341
- envPaletteMode === "array" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9342
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
10775
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
10776
+ envPaletteMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
10777
+ envPaletteMode === "array" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
10778
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
9343
10779
  messages.column,
9344
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10780
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9345
10781
  "input",
9346
10782
  {
9347
10783
  type: "number",
9348
10784
  min: 1,
9349
10785
  max: 12,
9350
10786
  value: arrayAlignmentColumn,
9351
- onChange: (event) => setArrayAlignmentColumn(clampMatrixSize(Number(event.currentTarget.value) || 1))
10787
+ onChange: (event) => setArrayAlignmentColumn(clampMatrixSize2(Number(event.currentTarget.value) || 1))
9352
10788
  }
9353
10789
  )
9354
10790
  ] }),
9355
- ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10791
+ ARRAY_ALIGNMENTS2.map((alignment) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9356
10792
  "button",
9357
10793
  {
9358
10794
  type: "button",
@@ -9364,19 +10800,19 @@ ${arabic || currentMessages.empty}`;
9364
10800
  alignment.id
9365
10801
  ))
9366
10802
  ] }) : null,
9367
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
10803
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
9368
10804
  "+",
9369
10805
  messages.row
9370
10806
  ] }),
9371
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
10807
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
9372
10808
  "-",
9373
10809
  messages.row
9374
10810
  ] }),
9375
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", title: messages.addColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
10811
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", title: messages.addColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
9376
10812
  "+",
9377
10813
  messages.column
9378
10814
  ] }),
9379
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", title: messages.removeColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
10815
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", title: messages.removeColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
9380
10816
  "-",
9381
10817
  messages.column
9382
10818
  ] })
@@ -9385,7 +10821,7 @@ ${arabic || currentMessages.empty}`;
9385
10821
  ]
9386
10822
  }
9387
10823
  ) }),
9388
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10824
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9389
10825
  "div",
9390
10826
  {
9391
10827
  className: `spacing-command-menu spacing-command-menu--${activeEditorSide}`,
@@ -9396,27 +10832,27 @@ ${arabic || currentMessages.empty}`;
9396
10832
  }
9397
10833
  },
9398
10834
  children: [
9399
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10835
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9400
10836
  "button",
9401
10837
  {
9402
10838
  className: "icon-btn spacing-command-btn",
9403
10839
  type: "button",
9404
10840
  title: messages.insertSpace,
9405
10841
  "aria-label": messages.insertSpace,
9406
- "aria-haspopup": "listbox",
10842
+ "aria-haspopup": "menu",
9407
10843
  "aria-expanded": spacingMenuOpen,
9408
10844
  onClick: () => setSpacingMenuOpen((open) => !open),
9409
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
9410
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__bar" }),
9411
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
10845
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
10846
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__bar" }),
10847
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
9412
10848
  ] })
9413
10849
  }
9414
10850
  ),
9415
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "spacing-command-options", role: "listbox", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10851
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "spacing-command-options", role: "menu", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9416
10852
  "button",
9417
10853
  {
9418
10854
  type: "button",
9419
- role: "option",
10855
+ role: "menuitem",
9420
10856
  className: `spacing-command-option spacing-command-option--${command.spacing.direction}`,
9421
10857
  title: atomicCommandTitle(command, uiLocale),
9422
10858
  onMouseDown: (event) => event.preventDefault(),
@@ -9426,12 +10862,12 @@ ${arabic || currentMessages.empty}`;
9426
10862
  focusSurface();
9427
10863
  },
9428
10864
  children: [
9429
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
9430
- command.spacing.direction === "negative" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, activeEditorSide) }) : null,
9431
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__bar" }),
9432
- command.spacing.direction === "positive" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, activeEditorSide) }) : null
10865
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
10866
+ command.spacing.direction === "negative" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null,
10867
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__bar" }),
10868
+ command.spacing.direction === "positive" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null
9433
10869
  ] }),
9434
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
10870
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
9435
10871
  ]
9436
10872
  },
9437
10873
  command.id
@@ -9439,8 +10875,8 @@ ${arabic || currentMessages.empty}`;
9439
10875
  ]
9440
10876
  }
9441
10877
  ) }),
9442
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
9443
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10878
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
10879
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9444
10880
  "div",
9445
10881
  {
9446
10882
  className: "function-command-menu",
@@ -9451,25 +10887,25 @@ ${arabic || currentMessages.empty}`;
9451
10887
  }
9452
10888
  },
9453
10889
  children: [
9454
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10890
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9455
10891
  "button",
9456
10892
  {
9457
10893
  className: "icon-btn function-command-btn",
9458
10894
  type: "button",
9459
10895
  title: messages.insertFunction,
9460
10896
  "aria-label": messages.insertFunction,
9461
- "aria-haspopup": "listbox",
10897
+ "aria-haspopup": "menu",
9462
10898
  "aria-expanded": functionMenuOpen,
9463
10899
  onClick: () => setFunctionMenuOpen((open) => !open),
9464
- children: FUNCTION_COMMANDS[0]?.arabicLabel ?? "\u062F"
10900
+ children: FUNCTION_COMMANDS2[0]?.arabicLabel ?? "\u062F"
9465
10901
  }
9466
10902
  ),
9467
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10903
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9468
10904
  "button",
9469
10905
  {
9470
10906
  className: "function-command-option",
9471
10907
  type: "button",
9472
- role: "option",
10908
+ role: "menuitem",
9473
10909
  title: atomicCommandTitle(command, uiLocale),
9474
10910
  "aria-label": atomicCommandTitle(command, uiLocale),
9475
10911
  onMouseDown: (event) => event.preventDefault(),
@@ -9485,7 +10921,7 @@ ${arabic || currentMessages.empty}`;
9485
10921
  ]
9486
10922
  }
9487
10923
  ),
9488
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10924
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9489
10925
  "div",
9490
10926
  {
9491
10927
  className: "function-command-menu function-command-menu--limits-series",
@@ -9496,25 +10932,25 @@ ${arabic || currentMessages.empty}`;
9496
10932
  }
9497
10933
  },
9498
10934
  children: [
9499
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10935
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9500
10936
  "button",
9501
10937
  {
9502
10938
  className: "icon-btn function-command-btn",
9503
10939
  type: "button",
9504
10940
  title: messages.insertLimitsSeries,
9505
10941
  "aria-label": messages.insertLimitsSeries,
9506
- "aria-haspopup": "listbox",
10942
+ "aria-haspopup": "menu",
9507
10943
  "aria-expanded": limitsSeriesMenuOpen,
9508
10944
  onClick: () => setLimitsSeriesMenuOpen((open) => !open),
9509
- children: LIMITS_SERIES_COMMANDS[0]?.arabicLabel ?? "\u062D\u062F"
10945
+ children: LIMITS_SERIES_COMMANDS2[0]?.arabicLabel ?? "\u062D\u062F"
9510
10946
  }
9511
10947
  ),
9512
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10948
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9513
10949
  "button",
9514
10950
  {
9515
10951
  className: "function-command-option",
9516
10952
  type: "button",
9517
- role: "option",
10953
+ role: "menuitem",
9518
10954
  title: atomicCommandTitle(command, uiLocale),
9519
10955
  "aria-label": atomicCommandTitle(command, uiLocale),
9520
10956
  onMouseDown: (event) => event.preventDefault(),
@@ -9530,7 +10966,7 @@ ${arabic || currentMessages.empty}`;
9530
10966
  ]
9531
10967
  }
9532
10968
  ),
9533
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10969
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9534
10970
  "div",
9535
10971
  {
9536
10972
  className: "function-command-menu function-command-menu--function2",
@@ -9541,25 +10977,25 @@ ${arabic || currentMessages.empty}`;
9541
10977
  }
9542
10978
  },
9543
10979
  children: [
9544
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10980
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9545
10981
  "button",
9546
10982
  {
9547
10983
  className: "icon-btn function-command-btn",
9548
10984
  type: "button",
9549
10985
  title: messages.insertAdditionalFunctions,
9550
10986
  "aria-label": messages.insertAdditionalFunctions,
9551
- "aria-haspopup": "listbox",
10987
+ "aria-haspopup": "menu",
9552
10988
  "aria-expanded": function2MenuOpen,
9553
10989
  onClick: () => setFunction2MenuOpen((open) => !open),
9554
- children: FUNCTION2_COMMANDS[0]?.arabicLabel ?? "\u062F"
10990
+ children: FUNCTION2_COMMANDS2[0]?.arabicLabel ?? "\u062F"
9555
10991
  }
9556
10992
  ),
9557
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10993
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9558
10994
  "button",
9559
10995
  {
9560
10996
  className: "function-command-option",
9561
10997
  type: "button",
9562
- role: "option",
10998
+ role: "menuitem",
9563
10999
  title: atomicCommandTitle(command, uiLocale),
9564
11000
  "aria-label": atomicCommandTitle(command, uiLocale),
9565
11001
  onMouseDown: (event) => event.preventDefault(),
@@ -9575,7 +11011,7 @@ ${arabic || currentMessages.empty}`;
9575
11011
  ]
9576
11012
  }
9577
11013
  ),
9578
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11014
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9579
11015
  "div",
9580
11016
  {
9581
11017
  className: "function-command-menu function-command-menu--derivative",
@@ -9586,26 +11022,26 @@ ${arabic || currentMessages.empty}`;
9586
11022
  }
9587
11023
  },
9588
11024
  children: [
9589
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11025
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9590
11026
  "button",
9591
11027
  {
9592
11028
  className: "icon-btn function-command-btn",
9593
11029
  type: "button",
9594
11030
  title: messages.insertDerivative,
9595
11031
  "aria-label": messages.insertDerivative,
9596
- "aria-haspopup": "listbox",
11032
+ "aria-haspopup": "menu",
9597
11033
  "aria-expanded": derivativeMenuOpen,
9598
11034
  onClick: () => setDerivativeMenuOpen((open) => !open),
9599
- children: DERIVATIVE_COMMANDS[0]?.arabicLabel ?? "\u0621"
11035
+ children: DERIVATIVE_COMMANDS2[0]?.arabicLabel ?? "\u0621"
9600
11036
  }
9601
11037
  ),
9602
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
9603
- DERIVATIVE_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11038
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
11039
+ DERIVATIVE_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9604
11040
  "button",
9605
11041
  {
9606
11042
  className: "function-command-option",
9607
11043
  type: "button",
9608
- role: "option",
11044
+ role: "menuitem",
9609
11045
  title: atomicCommandTitle(command, uiLocale),
9610
11046
  "aria-label": atomicCommandTitle(command, uiLocale),
9611
11047
  onMouseDown: (event) => event.preventDefault(),
@@ -9618,12 +11054,12 @@ ${arabic || currentMessages.empty}`;
9618
11054
  },
9619
11055
  command.id
9620
11056
  )),
9621
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11057
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9622
11058
  "button",
9623
11059
  {
9624
11060
  className: "function-command-option",
9625
11061
  type: "button",
9626
- role: "option",
11062
+ role: "menuitem",
9627
11063
  title: messages.insertFirstDerivative,
9628
11064
  "aria-label": messages.insertFirstDerivative,
9629
11065
  onMouseDown: (event) => event.preventDefault(),
@@ -9635,12 +11071,12 @@ ${arabic || currentMessages.empty}`;
9635
11071
  children: "\u0621/\u0633"
9636
11072
  }
9637
11073
  ),
9638
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11074
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9639
11075
  "button",
9640
11076
  {
9641
11077
  className: "function-command-option",
9642
11078
  type: "button",
9643
- role: "option",
11079
+ role: "menuitem",
9644
11080
  title: messages.insertSecondDerivative,
9645
11081
  "aria-label": messages.insertSecondDerivative,
9646
11082
  onMouseDown: (event) => event.preventDefault(),
@@ -9656,7 +11092,7 @@ ${arabic || currentMessages.empty}`;
9656
11092
  ]
9657
11093
  }
9658
11094
  ),
9659
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11095
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9660
11096
  "div",
9661
11097
  {
9662
11098
  className: "function-command-menu function-command-menu--groups",
@@ -9667,25 +11103,25 @@ ${arabic || currentMessages.empty}`;
9667
11103
  }
9668
11104
  },
9669
11105
  children: [
9670
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11106
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9671
11107
  "button",
9672
11108
  {
9673
11109
  className: "icon-btn function-command-btn",
9674
11110
  type: "button",
9675
11111
  title: messages.insertNumberSets,
9676
11112
  "aria-label": messages.insertNumberSets,
9677
- "aria-haspopup": "listbox",
11113
+ "aria-haspopup": "menu",
9678
11114
  "aria-expanded": groupMenuOpen,
9679
11115
  onClick: () => setGroupMenuOpen((open) => !open),
9680
- children: GROUP_COMMANDS[0]?.arabicLabel ?? "\u0645"
11116
+ children: GROUP_COMMANDS2[0]?.arabicLabel ?? "\u0645"
9681
11117
  }
9682
11118
  ),
9683
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11119
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9684
11120
  "button",
9685
11121
  {
9686
11122
  className: "function-command-option",
9687
11123
  type: "button",
9688
- role: "option",
11124
+ role: "menuitem",
9689
11125
  title: atomicCommandTitle(command, uiLocale),
9690
11126
  "aria-label": atomicCommandTitle(command, uiLocale),
9691
11127
  onMouseDown: (event) => event.preventDefault(),
@@ -9702,8 +11138,8 @@ ${arabic || currentMessages.empty}`;
9702
11138
  }
9703
11139
  )
9704
11140
  ] }),
9705
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
9706
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11141
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
11142
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9707
11143
  "div",
9708
11144
  {
9709
11145
  className: "function-command-menu operator-command-menu",
@@ -9714,25 +11150,25 @@ ${arabic || currentMessages.empty}`;
9714
11150
  }
9715
11151
  },
9716
11152
  children: [
9717
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11153
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9718
11154
  "button",
9719
11155
  {
9720
11156
  className: "icon-btn function-command-btn operator-command-btn",
9721
11157
  type: "button",
9722
11158
  title: messages.insertOperation,
9723
11159
  "aria-label": messages.insertOperation,
9724
- "aria-haspopup": "listbox",
11160
+ "aria-haspopup": "menu",
9725
11161
  "aria-expanded": operatorMenuOpen,
9726
11162
  onClick: () => setOperatorMenuOpen((open) => !open),
9727
11163
  children: renderOperatorMenuButtonLabel(OPERATOR_COMMANDS[0], "\u2217")
9728
11164
  }
9729
11165
  ),
9730
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11166
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9731
11167
  "button",
9732
11168
  {
9733
11169
  className: "function-command-option operator-command-option",
9734
11170
  type: "button",
9735
- role: "option",
11171
+ role: "menuitem",
9736
11172
  title: atomicOperatorCommandTitle(command, uiLocale),
9737
11173
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
9738
11174
  onMouseDown: (event) => event.preventDefault(),
@@ -9741,14 +11177,14 @@ ${arabic || currentMessages.empty}`;
9741
11177
  setOperatorMenuOpen(false);
9742
11178
  focusSurface();
9743
11179
  },
9744
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
11180
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
9745
11181
  },
9746
11182
  command.id
9747
11183
  )) })
9748
11184
  ]
9749
11185
  }
9750
11186
  ),
9751
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11187
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9752
11188
  "div",
9753
11189
  {
9754
11190
  className: "function-command-menu operator-command-menu",
@@ -9759,25 +11195,25 @@ ${arabic || currentMessages.empty}`;
9759
11195
  }
9760
11196
  },
9761
11197
  children: [
9762
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11198
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9763
11199
  "button",
9764
11200
  {
9765
11201
  className: "icon-btn function-command-btn operator-command-btn",
9766
11202
  type: "button",
9767
11203
  title: messages.insertRelationsSets,
9768
11204
  "aria-label": messages.insertRelationsSets,
9769
- "aria-haspopup": "listbox",
11205
+ "aria-haspopup": "menu",
9770
11206
  "aria-expanded": operator2MenuOpen,
9771
11207
  onClick: () => setOperator2MenuOpen((open) => !open),
9772
11208
  children: "\u2229"
9773
11209
  }
9774
11210
  ),
9775
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11211
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9776
11212
  "button",
9777
11213
  {
9778
11214
  className: "function-command-option operator-command-option",
9779
11215
  type: "button",
9780
- role: "option",
11216
+ role: "menuitem",
9781
11217
  title: atomicOperatorCommandTitle(command, uiLocale),
9782
11218
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
9783
11219
  onMouseDown: (event) => event.preventDefault(),
@@ -9786,14 +11222,14 @@ ${arabic || currentMessages.empty}`;
9786
11222
  setOperator2MenuOpen(false);
9787
11223
  focusSurface();
9788
11224
  },
9789
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
11225
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
9790
11226
  },
9791
11227
  command.id
9792
11228
  )) })
9793
11229
  ]
9794
11230
  }
9795
11231
  ),
9796
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11232
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9797
11233
  "div",
9798
11234
  {
9799
11235
  className: "function-command-menu operator-command-menu",
@@ -9804,25 +11240,25 @@ ${arabic || currentMessages.empty}`;
9804
11240
  }
9805
11241
  },
9806
11242
  children: [
9807
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11243
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9808
11244
  "button",
9809
11245
  {
9810
11246
  className: "icon-btn function-command-btn operator-command-btn",
9811
11247
  type: "button",
9812
11248
  title: messages.insertArrows,
9813
11249
  "aria-label": messages.insertArrows,
9814
- "aria-haspopup": "listbox",
11250
+ "aria-haspopup": "menu",
9815
11251
  "aria-expanded": operator3MenuOpen,
9816
11252
  onClick: () => setOperator3MenuOpen((open) => !open),
9817
11253
  children: renderOperatorMenuButtonLabel(OPERATOR3_COMMANDS[0], "\u21D2")
9818
11254
  }
9819
11255
  ),
9820
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11256
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9821
11257
  "button",
9822
11258
  {
9823
11259
  className: "function-command-option operator-command-option",
9824
11260
  type: "button",
9825
- role: "option",
11261
+ role: "menuitem",
9826
11262
  title: atomicOperatorCommandTitle(command, uiLocale),
9827
11263
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
9828
11264
  onMouseDown: (event) => event.preventDefault(),
@@ -9831,14 +11267,14 @@ ${arabic || currentMessages.empty}`;
9831
11267
  setOperator3MenuOpen(false);
9832
11268
  focusSurface();
9833
11269
  },
9834
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
11270
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
9835
11271
  },
9836
11272
  command.id
9837
11273
  )) })
9838
11274
  ]
9839
11275
  }
9840
11276
  ),
9841
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11277
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9842
11278
  "div",
9843
11279
  {
9844
11280
  className: "function-command-menu operator-command-menu",
@@ -9849,25 +11285,25 @@ ${arabic || currentMessages.empty}`;
9849
11285
  }
9850
11286
  },
9851
11287
  children: [
9852
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11288
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9853
11289
  "button",
9854
11290
  {
9855
11291
  className: "icon-btn function-command-btn operator-command-btn",
9856
11292
  type: "button",
9857
11293
  title: messages.insertDots,
9858
11294
  "aria-label": messages.insertDots,
9859
- "aria-haspopup": "listbox",
11295
+ "aria-haspopup": "menu",
9860
11296
  "aria-expanded": dotMenuOpen,
9861
11297
  onClick: () => setDotMenuOpen((open) => !open),
9862
11298
  children: renderOperatorMenuButtonLabel(DOT_COMMANDS[0], "\u2026")
9863
11299
  }
9864
11300
  ),
9865
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11301
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9866
11302
  "button",
9867
11303
  {
9868
11304
  className: "function-command-option operator-command-option",
9869
11305
  type: "button",
9870
- role: "option",
11306
+ role: "menuitem",
9871
11307
  title: atomicOperatorCommandTitle(command, uiLocale),
9872
11308
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
9873
11309
  onMouseDown: (event) => event.preventDefault(),
@@ -9876,14 +11312,14 @@ ${arabic || currentMessages.empty}`;
9876
11312
  setDotMenuOpen(false);
9877
11313
  focusSurface();
9878
11314
  },
9879
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
11315
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
9880
11316
  },
9881
11317
  command.id
9882
11318
  )) })
9883
11319
  ]
9884
11320
  }
9885
11321
  ),
9886
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11322
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9887
11323
  "div",
9888
11324
  {
9889
11325
  className: "function-command-menu operator-command-menu",
@@ -9894,25 +11330,25 @@ ${arabic || currentMessages.empty}`;
9894
11330
  }
9895
11331
  },
9896
11332
  children: [
9897
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11333
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9898
11334
  "button",
9899
11335
  {
9900
11336
  className: "icon-btn function-command-btn operator-command-btn",
9901
11337
  type: "button",
9902
11338
  title: messages.insertIntegrals,
9903
11339
  "aria-label": messages.insertIntegrals,
9904
- "aria-haspopup": "listbox",
11340
+ "aria-haspopup": "menu",
9905
11341
  "aria-expanded": integralMenuOpen,
9906
11342
  onClick: () => setIntegralMenuOpen((open) => !open),
9907
11343
  children: renderOperatorMenuButtonLabel(INTEGRAL_COMMANDS[0], "\u222B")
9908
11344
  }
9909
11345
  ),
9910
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11346
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9911
11347
  "button",
9912
11348
  {
9913
11349
  className: "function-command-option operator-command-option",
9914
11350
  type: "button",
9915
- role: "option",
11351
+ role: "menuitem",
9916
11352
  title: atomicOperatorCommandTitle(command, uiLocale),
9917
11353
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
9918
11354
  onMouseDown: (event) => event.preventDefault(),
@@ -9921,7 +11357,7 @@ ${arabic || currentMessages.empty}`;
9921
11357
  setIntegralMenuOpen(false);
9922
11358
  focusSurface();
9923
11359
  },
9924
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
11360
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
9925
11361
  },
9926
11362
  command.id
9927
11363
  )) })
@@ -9929,28 +11365,28 @@ ${arabic || currentMessages.empty}`;
9929
11365
  }
9930
11366
  )
9931
11367
  ] }),
9932
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
9933
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
9934
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
9935
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0633" })
11368
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
11369
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
11370
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0646" }),
11371
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0633" })
9936
11372
  ] }) }),
9937
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
9938
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
9939
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0633" })
11373
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
11374
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0646" }),
11375
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0633" })
9940
11376
  ] }) }),
9941
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runtimeRef.current?.removeSup(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
9942
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
9943
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xD7" })
11377
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runtimeRef.current?.removeSup(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
11378
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0646" }),
11379
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\xD7" })
9944
11380
  ] }) }),
9945
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runtimeRef.current?.removeSub(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
9946
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
9947
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xD7" })
11381
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runtimeRef.current?.removeSub(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
11382
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0646" }),
11383
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\xD7" })
9948
11384
  ] }) })
9949
11385
  ] }),
9950
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
9951
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
9952
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: splitTypingBtnRef, id: "toggle-split-leaf-typing", className: "icon-btn ligature-btn", type: "button", title: messages.toggleLetterMerging, "aria-label": messages.toggleLetterMerging, onClick: () => runtimeRef.current?.toggleSplitLeafTyping(), children: "\u0633\u0635\u0639" }),
9953
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11386
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
11387
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
11388
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: splitTypingBtnRef, id: "toggle-split-leaf-typing", className: "icon-btn ligature-btn", type: "button", title: messages.toggleLetterMerging, "aria-label": messages.toggleLetterMerging, onClick: () => runtimeRef.current?.toggleSplitLeafTyping(), children: "\u0633\u0635\u0639" }),
11389
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9954
11390
  "div",
9955
11391
  {
9956
11392
  className: "character-font-menu",
@@ -9961,14 +11397,14 @@ ${arabic || currentMessages.empty}`;
9961
11397
  }
9962
11398
  },
9963
11399
  children: [
9964
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11400
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9965
11401
  "button",
9966
11402
  {
9967
11403
  ref: characterFontBtnRef,
9968
11404
  id: "select-character-font",
9969
11405
  className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
9970
11406
  type: "button",
9971
- title: characterFontTitle(selectedCharacterFont, messages),
11407
+ title: characterFontTitle2(selectedCharacterFont, messages),
9972
11408
  "aria-label": messages.chooseWritingFont,
9973
11409
  "aria-haspopup": "listbox",
9974
11410
  "aria-expanded": characterFontMenuOpen,
@@ -9976,14 +11412,14 @@ ${arabic || currentMessages.empty}`;
9976
11412
  children: characterFontOption(selectedCharacterFont).label
9977
11413
  }
9978
11414
  ),
9979
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11415
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9980
11416
  "button",
9981
11417
  {
9982
11418
  type: "button",
9983
11419
  role: "option",
9984
11420
  "aria-selected": selectedCharacterFont === option.id,
9985
11421
  className: `character-font-option character-font-option--${option.id}`,
9986
- title: characterFontTitle(option.id, messages),
11422
+ title: characterFontTitle2(option.id, messages),
9987
11423
  onMouseDown: (event) => event.preventDefault(),
9988
11424
  onClick: () => {
9989
11425
  runtimeRef.current?.setCurrentCharacterFont(option.id);
@@ -9998,7 +11434,7 @@ ${arabic || currentMessages.empty}`;
9998
11434
  ]
9999
11435
  }
10000
11436
  ),
10001
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11437
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10002
11438
  "div",
10003
11439
  {
10004
11440
  className: "digit-form-menu",
@@ -10009,7 +11445,7 @@ ${arabic || currentMessages.empty}`;
10009
11445
  }
10010
11446
  },
10011
11447
  children: [
10012
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11448
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10013
11449
  "button",
10014
11450
  {
10015
11451
  ref: digitFormBtnRef,
@@ -10024,7 +11460,7 @@ ${arabic || currentMessages.empty}`;
10024
11460
  children: digitFormLabel(selectedDigitForm2)
10025
11461
  }
10026
11462
  ),
10027
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11463
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10028
11464
  "button",
10029
11465
  {
10030
11466
  type: "button",
@@ -10048,7 +11484,7 @@ ${arabic || currentMessages.empty}`;
10048
11484
  )
10049
11485
  ] })
10050
11486
  ] }),
10051
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11487
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10052
11488
  "div",
10053
11489
  {
10054
11490
  ref: surfaceRef,
@@ -10058,7 +11494,7 @@ ${arabic || currentMessages.empty}`;
10058
11494
  "aria-label": messages.equationEditor
10059
11495
  }
10060
11496
  ),
10061
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11497
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10062
11498
  "textarea",
10063
11499
  {
10064
11500
  ref: inputRef,
@@ -10072,20 +11508,31 @@ ${arabic || currentMessages.empty}`;
10072
11508
  tabIndex: -1
10073
11509
  }
10074
11510
  ),
10075
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: renderErrorRef, className: "error", hidden: true })
11511
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: renderErrorRef, className: "error", hidden: true }),
11512
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
11513
+ "button",
11514
+ {
11515
+ type: "button",
11516
+ className: "butex-widget__mobile-preview-toggle",
11517
+ "aria-controls": previewPanelId,
11518
+ "aria-expanded": compactPreviewOpen,
11519
+ onClick: () => setCompactPreviewOpen((open) => !open),
11520
+ children: compactPreviewOpen ? messages.hidePreview : messages.showPreview
11521
+ }
11522
+ )
10076
11523
  ] }),
10077
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", { className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: mathOutputRef, className: "preview-box" }) }),
10078
- debugEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "panel", children: [
10079
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dev-strip", children: [
10080
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dev-badge", children: messages.development }),
10081
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: latexLinesRef, className: "ascii" }),
10082
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: passivePreviewRef, className: "passive-preview-text" })
11524
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("section", { id: previewPanelId, className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: mathOutputRef, className: "preview-box" }) }),
11525
+ debugEnabled ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "panel", children: [
11526
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dev-strip", children: [
11527
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dev-badge", children: messages.development }),
11528
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: latexLinesRef, className: "ascii" }),
11529
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: passivePreviewRef, className: "passive-preview-text" })
10083
11530
  ] }),
10084
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 12 }, children: [
10085
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "debug-head", children: [
10086
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => void copyDebugText(currentMathObjectJsonText()), children: "Copy MathObject JSON" }),
10087
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugMathObjectImport, children: "Import MathObject JSON" }),
10088
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11531
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginTop: 12 }, children: [
11532
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "debug-head", children: [
11533
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => void copyDebugText(currentMathObjectJsonText()), children: "Copy MathObject JSON" }),
11534
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugMathObjectImport, children: "Import MathObject JSON" }),
11535
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10089
11536
  "button",
10090
11537
  {
10091
11538
  type: "button",
@@ -10105,7 +11552,7 @@ ${arabic || currentMessages.empty}`;
10105
11552
  children: debugBodyHidden ? messages.showDebugLog : messages.hideDebugLog
10106
11553
  }
10107
11554
  ),
10108
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11555
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10109
11556
  "button",
10110
11557
  {
10111
11558
  type: "button",
@@ -10120,8 +11567,8 @@ ${arabic || currentMessages.empty}`;
10120
11567
  }
10121
11568
  )
10122
11569
  ] }),
10123
- debugImportOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "debug-json-import", children: [
10124
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11570
+ debugImportOpen ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "debug-json-import", children: [
11571
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10125
11572
  "textarea",
10126
11573
  {
10127
11574
  value: debugImportText,
@@ -10133,9 +11580,9 @@ ${arabic || currentMessages.empty}`;
10133
11580
  }
10134
11581
  }
10135
11582
  ),
10136
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "debug-head", children: [
10137
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: applyDebugMathObjectImport, children: "Apply" }),
10138
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11583
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "debug-head", children: [
11584
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: applyDebugMathObjectImport, children: "Apply" }),
11585
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10139
11586
  "button",
10140
11587
  {
10141
11588
  type: "button",
@@ -10147,9 +11594,9 @@ ${arabic || currentMessages.empty}`;
10147
11594
  }
10148
11595
  )
10149
11596
  ] }),
10150
- debugImportError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "debug-json-error", children: debugImportError }) : null
11597
+ debugImportError ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "debug-json-error", children: debugImportError }) : null
10151
11598
  ] }) : null,
10152
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: debugLogRef, className: "debug-log" })
11599
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: debugLogRef, className: "debug-log" })
10153
11600
  ] })
10154
11601
  ] }) : null
10155
11602
  ] })