@drghaliasri/butex 8.1.3 → 8.2.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.
@@ -11187,6 +11187,11 @@ function remapSelectionAfterRangeMove(selection, direction) {
11187
11187
  function mathTex(token, equationSide, digitForm) {
11188
11188
  return mathTokenSourceForSide(token, equationSide, digitForm, true);
11189
11189
  }
11190
+ function projectedBookTarget(options, ownerId, kind) {
11191
+ if (options.mode !== "book-content") return void 0;
11192
+ const book = options.bookContext;
11193
+ return book?.targets?.find((target) => target.unitId === book.unitId && target.ownerId === ownerId && target.kind === kind);
11194
+ }
11190
11195
  function previewInlines(field, islands, output, equationSide, document2, previewOptions) {
11191
11196
  return field.tokens.map((token) => {
11192
11197
  if (token.kind === "text") {
@@ -11218,7 +11223,8 @@ function previewInlines(field, islands, output, equationSide, document2, preview
11218
11223
  })
11219
11224
  };
11220
11225
  }
11221
- const number = collectDocumentReferenceTargets(document2).find((target) => target.kind === "eq" && target.ownerId === token.id)?.number;
11226
+ const projected = projectedBookTarget(previewOptions, token.id, "eq");
11227
+ const number = projected ? void 0 : collectDocumentReferenceTargets(document2).find((target) => target.kind === "eq" && target.ownerId === token.id)?.number;
11222
11228
  const island = {
11223
11229
  id: token.id,
11224
11230
  tex: mathTex(token, equationSide, previewOptions.digitForm),
@@ -11226,7 +11232,7 @@ function previewInlines(field, islands, output, equationSide, document2, preview
11226
11232
  output,
11227
11233
  editable: token.editable
11228
11234
  };
11229
- const numberLabel = number == null ? void 0 : formatBibliographyNumber(number, {
11235
+ const numberLabel = projected ? projected.ordinal : number == null ? void 0 : formatBibliographyNumber(number, {
11230
11236
  documentDirection: previewOptions.documentDirection,
11231
11237
  digitForm: previewOptions.digitForm
11232
11238
  });
@@ -11255,6 +11261,8 @@ function textBlockPreview(block, islands, output, equationSide, document2, previ
11255
11261
  };
11256
11262
  }
11257
11263
  function floatNumberLabel(document2, ownerId, previewOptions) {
11264
+ const projected = projectedBookTarget(previewOptions, ownerId, "fig") ?? projectedBookTarget(previewOptions, ownerId, "tab");
11265
+ if (projected) return projected.displayLabel;
11258
11266
  const hit = collectDocumentReferenceTargets(document2).find((target) => target.ownerId === ownerId);
11259
11267
  if (!hit || hit.number === null || hit.kind !== "fig" && hit.kind !== "tab") {
11260
11268
  return void 0;
@@ -11959,7 +11967,7 @@ function focusArticleMetaPanel(panel) {
11959
11967
  import { forwardRef as forwardRef3, useCallback as useCallback3, useRef as useRef16 } from "react";
11960
11968
 
11961
11969
  // src/react-document/ButexDocumentEditor.tsx
11962
- import { forwardRef as forwardRef2, useCallback as useCallback2, useEffect as useEffect13, useImperativeHandle as useImperativeHandle2, useMemo as useMemo2, useRef as useRef15, useState as useState14 } from "react";
11970
+ import { forwardRef as forwardRef2, useCallback as useCallback2, useEffect as useEffect13, useImperativeHandle as useImperativeHandle2, useMemo as useMemo2, useRef as useRef15, useState as useState15 } from "react";
11963
11971
 
11964
11972
  // src/debugJson.ts
11965
11973
  function lineColumnForPosition(text, position) {
@@ -14249,285 +14257,955 @@ function DocumentInsertToolbar({
14249
14257
  }
14250
14258
 
14251
14259
  // src/react-document/DocumentMobileToolbar.tsx
14252
- import { useId as useId2, useRef as useRef8, useState as useState7 } from "react";
14253
- import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
14254
- var DIGIT_FORMS2 = ["western", "arabicIndic", "persianIndic"];
14255
- function digitFormLabel2(digitForm) {
14256
- if (digitForm === "arabicIndic") {
14257
- return "\u0664\u0665\u0666";
14258
- }
14259
- if (digitForm === "persianIndic") {
14260
- return "\u06F4\u06F5\u06F6";
14261
- }
14262
- return "456";
14260
+ import { useId as useId2, useRef as useRef8, useState as useState8 } from "react";
14261
+
14262
+ // src/react/mobileCommandUi.tsx
14263
+ import { useLayoutEffect as useLayoutEffect2 } from "react";
14264
+
14265
+ // src/react/mobileCommandPortal.tsx
14266
+ import { useLayoutEffect, useState as useState7 } from "react";
14267
+ import { createPortal } from "react-dom";
14268
+
14269
+ // src/react/visibleViewport.ts
14270
+ function positiveFinite(value, fallback) {
14271
+ return Number.isFinite(value) && value > 0 ? value : fallback;
14263
14272
  }
14264
- function DocumentMobileToolbar({
14265
- mode = "article",
14266
- mobileView,
14267
- canUndo,
14268
- canRedo,
14269
- editableEquations,
14270
- uiLocale,
14271
- digitForm,
14272
- selectionCount,
14273
- canMoveSelectionUp,
14274
- canMoveSelectionDown,
14275
- canFormatText,
14276
- activeTextStyles,
14277
- onMobileViewChange,
14278
- onUndo,
14279
- onRedo,
14280
- onToggleTextStyle,
14281
- onMoveSelectionUp,
14282
- onMoveSelectionDown,
14283
- onDeleteSelection,
14284
- onAddSection,
14285
- onAddSubsection,
14286
- onAddSubsubsection,
14287
- onAddParagraph,
14288
- onAddInlineEquation,
14289
- onAddDisplayEquation,
14290
- onAddTable,
14291
- onAddList,
14292
- onAddEnumerate,
14293
- onAddFigure,
14294
- onInsertCitation,
14295
- onInsertInternalRef,
14296
- onInsertBibliography,
14297
- onManageReferences,
14298
- onManageLabels,
14299
- onOpenArticleMeta,
14300
- onDigitFormChange,
14301
- onCollapseAll,
14302
- onOpenAll
14303
- }) {
14304
- const messages = documentMessages(uiLocale);
14305
- const [sheetOpen, setSheetOpen] = useState7(false);
14306
- const [sheetView, setSheetView] = useState7("commands");
14307
- const [rows, setRows] = useState7("3");
14308
- const [cols, setCols] = useState7("3");
14309
- const triggerRef = useRef8(null);
14310
- const dialogRef = useRef8(null);
14311
- const titleId = useId2();
14312
- function closeSheet() {
14313
- setSheetOpen(false);
14314
- setSheetView("commands");
14273
+ function finiteOffset(value) {
14274
+ return Number.isFinite(value) ? value : 0;
14275
+ }
14276
+ function visibleViewportSnapshot(view) {
14277
+ const fallbackWidth = positiveFinite(view.innerWidth, 1);
14278
+ const fallbackHeight = positiveFinite(view.innerHeight, 1);
14279
+ const visualViewport = view.visualViewport;
14280
+ if (visualViewport && Number.isFinite(visualViewport.width) && visualViewport.width > 0 && Number.isFinite(visualViewport.height) && visualViewport.height > 0) {
14281
+ return {
14282
+ width: visualViewport.width,
14283
+ height: visualViewport.height,
14284
+ offsetLeft: finiteOffset(visualViewport.offsetLeft),
14285
+ offsetTop: finiteOffset(visualViewport.offsetTop),
14286
+ scale: positiveFinite(visualViewport.scale, 1),
14287
+ source: "visual-viewport"
14288
+ };
14315
14289
  }
14316
- useDialogFocus({ open: sheetOpen, dialogRef, triggerRef, onClose: closeSheet });
14317
- function runAction(action, revealEditor = true) {
14318
- closeSheet();
14319
- if (revealEditor) {
14320
- onMobileViewChange("editor");
14290
+ return {
14291
+ width: fallbackWidth,
14292
+ height: fallbackHeight,
14293
+ offsetLeft: 0,
14294
+ offsetTop: 0,
14295
+ scale: 1,
14296
+ source: "layout-viewport"
14297
+ };
14298
+ }
14299
+ function reasonPriority(reason) {
14300
+ if (reason === "orientation") return 3;
14301
+ if (reason === "resize") return 2;
14302
+ if (reason === "scroll") return 1;
14303
+ return 0;
14304
+ }
14305
+ function observeVisibleViewport(view, onChange) {
14306
+ let previous = visibleViewportSnapshot(view);
14307
+ let frame = null;
14308
+ let pendingReason = "scroll";
14309
+ onChange({
14310
+ snapshot: previous,
14311
+ initial: true,
14312
+ sizeChanged: false,
14313
+ offsetChanged: false,
14314
+ reason: "initial"
14315
+ });
14316
+ const emit = () => {
14317
+ frame = null;
14318
+ const next = visibleViewportSnapshot(view);
14319
+ const sizeChanged = next.width !== previous.width || next.height !== previous.height || next.scale !== previous.scale || next.source !== previous.source;
14320
+ const offsetChanged = next.offsetLeft !== previous.offsetLeft || next.offsetTop !== previous.offsetTop;
14321
+ const reason = pendingReason;
14322
+ pendingReason = "scroll";
14323
+ previous = next;
14324
+ onChange({ snapshot: next, initial: false, sizeChanged, offsetChanged, reason });
14325
+ };
14326
+ const schedule = (reason) => {
14327
+ if (reasonPriority(reason) > reasonPriority(pendingReason)) {
14328
+ pendingReason = reason;
14321
14329
  }
14322
- action();
14323
- }
14324
- function insertTable() {
14325
- const rowCount = Math.max(1, Math.min(20, Number.parseInt(rows, 10) || 3));
14326
- const colCount = Math.max(1, Math.min(10, Number.parseInt(cols, 10) || 3));
14327
- runAction(() => onAddTable(rowCount, colCount));
14328
- }
14329
- function digitTitle2(id) {
14330
- if (id === "arabicIndic") {
14331
- return messages.arabicIndicDigits;
14330
+ if (frame !== null) {
14331
+ return;
14332
14332
  }
14333
- if (id === "persianIndic") {
14334
- return messages.persianIndicDigits;
14333
+ frame = view.requestAnimationFrame(emit);
14334
+ };
14335
+ const onResize = () => schedule("resize");
14336
+ const onScroll = () => schedule("scroll");
14337
+ const onOrientation = () => schedule("orientation");
14338
+ const visualViewport = view.visualViewport;
14339
+ visualViewport?.addEventListener("resize", onResize);
14340
+ visualViewport?.addEventListener("scroll", onScroll);
14341
+ view.addEventListener("resize", onResize);
14342
+ view.addEventListener("orientationchange", onOrientation);
14343
+ return () => {
14344
+ visualViewport?.removeEventListener("resize", onResize);
14345
+ visualViewport?.removeEventListener("scroll", onScroll);
14346
+ view.removeEventListener("resize", onResize);
14347
+ view.removeEventListener("orientationchange", onOrientation);
14348
+ if (frame !== null) {
14349
+ view.cancelAnimationFrame(frame);
14350
+ frame = null;
14335
14351
  }
14336
- return messages.westernDigits;
14337
- }
14338
- const showContextRow = selectionCount > 0 || canFormatText;
14339
- return /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__mobile-toolbar", children: [
14340
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__mobile-toolbar-primary", children: [
14341
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__mobile-view", role: "group", "aria-label": messages.mobileViews, children: [
14342
- /* @__PURE__ */ jsx11(
14343
- "button",
14344
- {
14345
- type: "button",
14346
- "aria-pressed": mobileView === "editor",
14347
- onClick: () => onMobileViewChange("editor"),
14348
- children: messages.editor
14349
- }
14350
- ),
14351
- /* @__PURE__ */ jsx11(
14352
- "button",
14353
- {
14354
- type: "button",
14355
- "aria-pressed": mobileView === "preview",
14356
- onClick: () => onMobileViewChange("preview"),
14357
- children: messages.preview
14358
- }
14359
- )
14360
- ] }),
14361
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__mobile-toolbar-actions", role: "group", "aria-label": messages.mobileToolbar, children: [
14362
- /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document-widget__icon-btn", title: messages.undo, "aria-label": messages.undo, disabled: !canUndo, onClick: onUndo, children: "\u21B6" }),
14363
- /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document-widget__icon-btn", title: messages.redo, "aria-label": messages.redo, disabled: !canRedo, onClick: onRedo, children: "\u21B7" }),
14364
- /* @__PURE__ */ jsx11(
14365
- "button",
14366
- {
14367
- ref: triggerRef,
14368
- type: "button",
14369
- className: "butex-document-widget__icon-btn",
14370
- title: messages.moreActions,
14371
- "aria-label": messages.moreActions,
14372
- "aria-haspopup": "dialog",
14373
- "aria-expanded": sheetOpen,
14374
- onClick: () => setSheetOpen(true),
14375
- children: "\u22EF"
14376
- }
14377
- )
14378
- ] })
14379
- ] }),
14380
- showContextRow ? /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__mobile-context", "aria-label": messages.contextActions, children: [
14381
- selectionCount > 0 ? /* @__PURE__ */ jsxs10(Fragment3, { children: [
14382
- /* @__PURE__ */ jsxs10("span", { className: "butex-document-widget__selection-count", children: [
14383
- selectionCount,
14384
- " ",
14385
- messages.selectedBlockCount
14386
- ] }),
14387
- /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document-widget__icon-btn", title: messages.moveUp, "aria-label": messages.moveUp, disabled: !canMoveSelectionUp, onClick: onMoveSelectionUp, children: "\u2191" }),
14388
- /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document-widget__icon-btn", title: messages.moveDown, "aria-label": messages.moveDown, disabled: !canMoveSelectionDown, onClick: onMoveSelectionDown, children: "\u2193" }),
14389
- /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document-widget__button--danger", onClick: onDeleteSelection, children: messages.deleteBlock })
14390
- ] }) : null,
14391
- canFormatText ? /* @__PURE__ */ jsx11(Fragment3, { children: ["bold", "italic", "underline"].map((styleName) => /* @__PURE__ */ jsx11(
14392
- "button",
14393
- {
14394
- type: "button",
14395
- className: `butex-document-widget__icon-btn butex-document-widget__format-btn butex-document-widget__format-btn--${styleName}`,
14396
- "aria-label": messages[styleName],
14397
- "aria-pressed": activeTextStyles[styleName] === true,
14398
- onMouseDown: (event) => event.preventDefault(),
14399
- onClick: () => onToggleTextStyle(styleName),
14400
- children: styleName === "bold" ? "B" : styleName === "italic" ? "I" : "U"
14401
- },
14402
- styleName
14403
- )) }) : null
14404
- ] }) : null,
14405
- sheetOpen ? /* @__PURE__ */ jsx11("div", { className: "butex-document-widget__command-sheet-backdrop", role: "presentation", onClick: closeSheet, children: /* @__PURE__ */ jsxs10(
14406
- "section",
14407
- {
14408
- ref: dialogRef,
14409
- className: "butex-document-widget__command-sheet",
14410
- role: "dialog",
14411
- "aria-modal": "true",
14412
- "aria-labelledby": titleId,
14413
- tabIndex: -1,
14414
- onClick: (event) => event.stopPropagation(),
14415
- children: [
14416
- /* @__PURE__ */ jsxs10("header", { className: "butex-document-widget__command-sheet-header", children: [
14417
- /* @__PURE__ */ jsx11("strong", { id: titleId, children: sheetView === "table" ? messages.tableSize : messages.moreActions }),
14418
- /* @__PURE__ */ jsx11("button", { type: "button", "data-dialog-initial-focus": true, "aria-label": messages.close, onClick: closeSheet, children: "\xD7" })
14419
- ] }),
14420
- sheetView === "table" ? /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-sheet-body butex-document-widget__mobile-table-form", children: [
14421
- /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document-widget__sheet-back", onClick: () => setSheetView("commands"), children: messages.backToActions }),
14422
- /* @__PURE__ */ jsxs10("label", { children: [
14423
- /* @__PURE__ */ jsx11("span", { children: messages.rows }),
14424
- /* @__PURE__ */ jsx11("input", { type: "number", min: 1, max: 20, value: rows, onChange: (event) => setRows(event.currentTarget.value) })
14425
- ] }),
14426
- /* @__PURE__ */ jsxs10("label", { children: [
14427
- /* @__PURE__ */ jsx11("span", { children: messages.columns }),
14428
- /* @__PURE__ */ jsx11("input", { type: "number", min: 1, max: 10, value: cols, onChange: (event) => setCols(event.currentTarget.value) })
14429
- ] }),
14430
- /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document-widget__primary-btn", onClick: insertTable, children: messages.insertTable })
14431
- ] }) : /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-sheet-body", children: [
14432
- /* @__PURE__ */ jsxs10("section", { className: "butex-document-widget__command-group", "aria-labelledby": `${titleId}-format`, children: [
14433
- /* @__PURE__ */ jsx11("h3", { id: `${titleId}-format`, children: messages.textFormatting }),
14434
- /* @__PURE__ */ jsx11("div", { className: "butex-document-widget__command-grid", children: ["bold", "italic", "underline"].map((styleName) => /* @__PURE__ */ jsx11(
14435
- "button",
14436
- {
14437
- type: "button",
14438
- "aria-pressed": activeTextStyles[styleName] === true,
14439
- disabled: !canFormatText,
14440
- onMouseDown: (event) => event.preventDefault(),
14441
- onClick: () => runAction(() => onToggleTextStyle(styleName)),
14442
- children: messages[styleName]
14443
- },
14444
- styleName
14445
- )) })
14446
- ] }),
14447
- /* @__PURE__ */ jsxs10("section", { className: "butex-document-widget__command-group", "aria-labelledby": `${titleId}-structure`, children: [
14448
- /* @__PURE__ */ jsx11("h3", { id: `${titleId}-structure`, children: messages.structure }),
14449
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-grid", children: [
14450
- mode === "article" ? /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onOpenArticleMeta), children: messages.articleMetaTitle }) : null,
14451
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddSection), children: messages.addSection }),
14452
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddSubsection), children: messages.addSubsection }),
14453
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddSubsubsection), children: messages.addSubsubsection }),
14454
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddParagraph), children: messages.addParagraph })
14455
- ] })
14456
- ] }),
14457
- /* @__PURE__ */ jsxs10("section", { className: "butex-document-widget__command-group", "aria-labelledby": `${titleId}-equations`, children: [
14458
- /* @__PURE__ */ jsx11("h3", { id: `${titleId}-equations`, children: messages.equations }),
14459
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-grid", children: [
14460
- /* @__PURE__ */ jsx11("button", { type: "button", disabled: !editableEquations, onClick: () => runAction(onAddInlineEquation), children: messages.inlineEquation }),
14461
- /* @__PURE__ */ jsx11("button", { type: "button", disabled: !editableEquations, onClick: () => runAction(onAddDisplayEquation), children: messages.displayEquation })
14462
- ] }),
14463
- /* @__PURE__ */ jsx11("span", { className: "butex-document-widget__command-subtitle", children: messages.chooseDigitForm }),
14464
- /* @__PURE__ */ jsx11("div", { className: "butex-document-widget__command-grid butex-document-widget__command-grid--digits", role: "listbox", "aria-label": messages.chooseDigitForm, children: DIGIT_FORMS2.map((id) => /* @__PURE__ */ jsx11(
14465
- "button",
14466
- {
14467
- type: "button",
14468
- role: "option",
14469
- "aria-selected": digitForm === id,
14470
- title: digitTitle2(id),
14471
- onClick: () => runAction(() => onDigitFormChange(id), false),
14472
- children: digitFormLabel2(id)
14473
- },
14474
- id
14475
- )) })
14476
- ] }),
14477
- /* @__PURE__ */ jsxs10("section", { className: "butex-document-widget__command-group", "aria-labelledby": `${titleId}-content`, children: [
14478
- /* @__PURE__ */ jsx11("h3", { id: `${titleId}-content`, children: messages.content }),
14479
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-grid", children: [
14480
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddList), children: messages.bulletedList }),
14481
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddEnumerate), children: messages.numberedList }),
14482
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => setSheetView("table"), children: messages.insertTable }),
14483
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddFigure), children: messages.insertImage })
14484
- ] })
14485
- ] }),
14486
- /* @__PURE__ */ jsxs10("section", { className: "butex-document-widget__command-group", "aria-labelledby": `${titleId}-references`, children: [
14487
- /* @__PURE__ */ jsx11("h3", { id: `${titleId}-references`, children: messages.citations }),
14488
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-grid", children: [
14489
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onInsertCitation, false), children: messages.insertCitation }),
14490
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onInsertInternalRef, false), children: messages.insertInternalRef }),
14491
- mode === "article" ? /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onInsertBibliography), children: messages.insertBibliography }) : null,
14492
- mode === "article" ? /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(() => onManageReferences(triggerRef.current), false), children: messages.manageReferences }) : null,
14493
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(() => onManageLabels(triggerRef.current), false), children: messages.manageLabels })
14494
- ] })
14495
- ] }),
14496
- /* @__PURE__ */ jsxs10("section", { className: "butex-document-widget__command-group", "aria-labelledby": `${titleId}-document`, children: [
14497
- /* @__PURE__ */ jsx11("h3", { id: `${titleId}-document`, children: messages.documentActions }),
14498
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-grid", children: [
14499
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onCollapseAll), children: messages.collapseAll }),
14500
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onOpenAll), children: messages.openAll })
14501
- ] })
14502
- ] }),
14503
- selectionCount > 0 ? /* @__PURE__ */ jsxs10("section", { className: "butex-document-widget__command-group", "aria-labelledby": `${titleId}-selection`, children: [
14504
- /* @__PURE__ */ jsx11("h3", { id: `${titleId}-selection`, children: messages.blockSelection }),
14505
- /* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-grid", children: [
14506
- /* @__PURE__ */ jsx11("button", { type: "button", disabled: !canMoveSelectionUp, onClick: () => runAction(onMoveSelectionUp), children: messages.moveUp }),
14507
- /* @__PURE__ */ jsx11("button", { type: "button", disabled: !canMoveSelectionDown, onClick: () => runAction(onMoveSelectionDown), children: messages.moveDown }),
14508
- /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document-widget__button--danger", onClick: () => runAction(onDeleteSelection), children: messages.deleteBlock })
14509
- ] })
14510
- ] }) : null
14511
- ] })
14512
- ]
14513
- }
14514
- ) }) : null
14515
- ] });
14352
+ };
14516
14353
  }
14517
14354
 
14518
- // src/react-document/DocumentPreview.tsx
14519
- import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
14520
- var REF_KIND_NAMES = [
14521
- { names: ["\u0627\u0644\u0634\u0643\u0644", "\u0634\u0643\u0644", "Figure", "figure"], prefixes: ["\u0627\u0644\u0634\u0643\u0644 ", "Figure "] },
14522
- { names: ["\u0627\u0644\u062C\u062F\u0648\u0644", "\u062C\u062F\u0648\u0644", "Table", "table"], prefixes: ["\u0627\u0644\u062C\u062F\u0648\u0644 ", "Table "] },
14523
- { names: ["\u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629", "\u0645\u0639\u0627\u062F\u0644\u0629", "Equation", "equation"], prefixes: ["\u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 ", "Equation "] }
14524
- ];
14525
- function contextualRefLabel(inlines, index, label) {
14526
- const previous = inlines[index - 1];
14527
- if (previous?.kind !== "text") {
14528
- return label;
14355
+ // src/react/mobileCommandPortal.tsx
14356
+ var scrollLocks = /* @__PURE__ */ new WeakMap();
14357
+ function lockBackground(doc) {
14358
+ let lock = scrollLocks.get(doc);
14359
+ if (!lock) {
14360
+ lock = {
14361
+ count: 0,
14362
+ overflow: doc.body.style.overflow,
14363
+ overscroll: doc.documentElement.style.overscrollBehavior
14364
+ };
14365
+ scrollLocks.set(doc, lock);
14366
+ doc.body.style.overflow = "hidden";
14367
+ doc.documentElement.style.overscrollBehavior = "none";
14529
14368
  }
14530
- const previousText = previous.text.trimEnd();
14369
+ lock.count += 1;
14370
+ return () => {
14371
+ if (!lock) return;
14372
+ lock.count -= 1;
14373
+ if (lock.count === 0) {
14374
+ doc.body.style.overflow = lock.overflow;
14375
+ doc.documentElement.style.overscrollBehavior = lock.overscroll;
14376
+ scrollLocks.delete(doc);
14377
+ }
14378
+ };
14379
+ }
14380
+ function ViewportModalPortal({ sourceRef, scopeClassName, children }) {
14381
+ const [host, setHost] = useState7(null);
14382
+ useLayoutEffect(() => {
14383
+ const doc = sourceRef?.current?.ownerDocument ?? document;
14384
+ const source = sourceRef?.current?.closest(`.${scopeClassName}`) ?? doc.documentElement;
14385
+ const view = doc.defaultView;
14386
+ if (!view) return;
14387
+ const computed = view.getComputedStyle(source);
14388
+ const layer = doc.createElement("div");
14389
+ layer.className = `${scopeClassName} butex-mobile-command-portal`;
14390
+ layer.dataset.responsiveMode = source.dataset.responsiveMode ?? "auto";
14391
+ layer.dir = source.dir || computed.direction;
14392
+ layer.lang = source.lang || doc.documentElement.lang;
14393
+ for (let i = 0; i < computed.length; i += 1) {
14394
+ const name = computed.item(i);
14395
+ if (name.startsWith("--")) layer.style.setProperty(name, computed.getPropertyValue(name));
14396
+ }
14397
+ layer.style.fontFamily = computed.fontFamily;
14398
+ layer.style.fontSize = computed.fontSize;
14399
+ layer.style.lineHeight = computed.lineHeight;
14400
+ layer.style.color = computed.color;
14401
+ layer.style.direction = computed.direction;
14402
+ layer.style.position = "fixed";
14403
+ layer.style.inset = "auto";
14404
+ layer.style.maxWidth = "none";
14405
+ layer.style.minWidth = "0";
14406
+ layer.style.containerType = "normal";
14407
+ layer.style.contain = "none";
14408
+ layer.style.isolation = "isolate";
14409
+ layer.style.zIndex = "2147483000";
14410
+ const stopObserving = observeVisibleViewport(view, ({ snapshot }) => {
14411
+ layer.style.left = `${String(snapshot.offsetLeft)}px`;
14412
+ layer.style.top = `${String(snapshot.offsetTop)}px`;
14413
+ layer.style.width = `${String(snapshot.width)}px`;
14414
+ layer.style.height = `${String(snapshot.height)}px`;
14415
+ });
14416
+ doc.body.appendChild(layer);
14417
+ const unlock = lockBackground(doc);
14418
+ setHost(layer);
14419
+ return () => {
14420
+ stopObserving();
14421
+ unlock();
14422
+ layer.remove();
14423
+ };
14424
+ }, [sourceRef, scopeClassName]);
14425
+ return host ? createPortal(children, host) : null;
14426
+ }
14427
+ var mobileCommandBackdropStyle = { position: "absolute" };
14428
+ var mobileCommandSheetStyle = { maxHeight: "min(720px, 100%)" };
14429
+ var MobileCommandPortal = ViewportModalPortal;
14430
+
14431
+ // src/react/mobileCommandCss.ts
14432
+ var MOBILE_COMMAND_CSS = String.raw`
14433
+ /* A single visual language for document and equation command portals (mobile only). */
14434
+ .butex-document-widget.butex-mobile-command-portal {
14435
+ --butex-mobile-panel: var(--butex-document-panel);
14436
+ --butex-mobile-fg: var(--butex-document-fg);
14437
+ --butex-mobile-muted: var(--butex-document-muted);
14438
+ --butex-mobile-border: var(--butex-document-border);
14439
+ --butex-mobile-accent: var(--butex-document-accent);
14440
+ --butex-mobile-soft: var(--butex-document-accent-bg);
14441
+ --butex-mobile-danger: var(--butex-document-danger);
14442
+ }
14443
+ .butex-widget.butex-mobile-command-portal {
14444
+ --butex-mobile-panel: var(--butex-panel);
14445
+ --butex-mobile-fg: var(--butex-fg);
14446
+ --butex-mobile-muted: var(--butex-muted);
14447
+ --butex-mobile-border: var(--butex-border);
14448
+ --butex-mobile-accent: var(--butex-accent);
14449
+ --butex-mobile-soft: var(--butex-toolbar-hover-bg);
14450
+ --butex-mobile-danger: var(--butex-danger);
14451
+ }
14452
+ .butex-mobile-command-portal .butex-mobile-sheet__backdrop {
14453
+ display: flex;
14454
+ align-items: flex-end;
14455
+ justify-content: center;
14456
+ inset: 0;
14457
+ padding: max(10px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)))
14458
+ max(8px, var(--butex-safe-area-right, env(safe-area-inset-right, 0px)))
14459
+ var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px))
14460
+ max(8px, var(--butex-safe-area-left, env(safe-area-inset-left, 0px)));
14461
+ background: color-mix(in srgb, #0f172a 40%, transparent);
14462
+ z-index: 1;
14463
+ }
14464
+ .butex-mobile-command-portal .butex-mobile-sheet__panel {
14465
+ display: grid;
14466
+ grid-template-rows: auto minmax(0, 1fr);
14467
+ width: 100%;
14468
+ max-width: 620px;
14469
+ min-height: 0;
14470
+ min-width: 0;
14471
+ overflow: hidden;
14472
+ border: 1px solid var(--butex-mobile-border);
14473
+ border-block-end: 0;
14474
+ border-radius: 20px 20px 0 0;
14475
+ background: var(--butex-mobile-panel);
14476
+ color: var(--butex-mobile-fg);
14477
+ box-shadow: 0 -20px 60px color-mix(in srgb, #0f172a 24%, transparent);
14478
+ }
14479
+ .butex-mobile-command-portal .butex-mobile-sheet__header {
14480
+ display: grid;
14481
+ grid-template-columns: minmax(64px, 1fr) minmax(0, 2fr) minmax(44px, 1fr);
14482
+ gap: 8px;
14483
+ align-items: center;
14484
+ min-height: 66px;
14485
+ padding: 11px 16px 9px;
14486
+ text-align: center;
14487
+ background: var(--butex-mobile-panel);
14488
+ border-block-end: 1px solid var(--butex-mobile-border);
14489
+ }
14490
+ .butex-mobile-command-portal .butex-mobile-sheet__header strong {
14491
+ display: block;
14492
+ font-size: 1.18rem;
14493
+ font-weight: 750;
14494
+ line-height: 1.45;
14495
+ overflow-wrap: anywhere;
14496
+ }
14497
+ .butex-mobile-command-portal .butex-mobile-sheet__header-spacer { display: block; }
14498
+ .butex-mobile-command-portal .butex-mobile-sheet__back,
14499
+ .butex-mobile-command-portal .butex-mobile-sheet__close {
14500
+ display: inline-flex;
14501
+ align-items: center;
14502
+ justify-content: center;
14503
+ gap: 5px;
14504
+ min-height: 44px;
14505
+ min-width: 44px;
14506
+ padding: 6px;
14507
+ border-radius: 11px;
14508
+ border: 1px solid transparent;
14509
+ background: transparent;
14510
+ color: var(--butex-mobile-fg);
14511
+ cursor: pointer;
14512
+ font: inherit;
14513
+ font-size: .88rem;
14514
+ }
14515
+ .butex-mobile-command-portal .butex-mobile-sheet__back { justify-self: start; }
14516
+ .butex-mobile-command-portal .butex-mobile-sheet__close {
14517
+ justify-self: end;
14518
+ background: var(--butex-mobile-soft);
14519
+ }
14520
+ .butex-mobile-command-portal .butex-mobile-sheet__body {
14521
+ display: grid;
14522
+ align-content: start;
14523
+ gap: 16px;
14524
+ min-height: 0;
14525
+ min-width: 0;
14526
+ overflow-y: auto;
14527
+ overscroll-behavior: contain;
14528
+ scrollbar-width: thin;
14529
+ padding: 16px clamp(12px, 3vw, 20px) max(20px, var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px)));
14530
+ }
14531
+ .butex-mobile-command-portal .butex-mobile-command__section {
14532
+ display: grid;
14533
+ min-width: 0;
14534
+ gap: 10px;
14535
+ padding-block-end: 15px;
14536
+ border-block-end: 1px solid color-mix(in srgb, var(--butex-mobile-border) 74%, transparent);
14537
+ }
14538
+ .butex-mobile-command-portal .butex-mobile-command__section:last-child { border-block-end: 0; padding-block-end: 0; }
14539
+ .butex-mobile-command-portal .butex-mobile-command__section-title {
14540
+ margin: 0;
14541
+ display: flex;
14542
+ align-items: center;
14543
+ gap: 9px;
14544
+ color: var(--butex-mobile-fg);
14545
+ font-size: 1.08rem;
14546
+ font-weight: 750;
14547
+ line-height: 1.55;
14548
+ }
14549
+ .butex-mobile-command-portal .butex-mobile-command__section-title > svg {
14550
+ color: var(--butex-mobile-accent);
14551
+ flex: none;
14552
+ }
14553
+ .butex-mobile-command-portal .butex-mobile-command__grid {
14554
+ display: grid;
14555
+ grid-template-columns: repeat(2, minmax(0, 1fr));
14556
+ gap: 8px;
14557
+ min-width: 0;
14558
+ }
14559
+ .butex-mobile-command-portal .butex-mobile-command__grid--dense {
14560
+ grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
14561
+ }
14562
+ .butex-mobile-command-portal .butex-mobile-command__choice-row {
14563
+ display: grid;
14564
+ grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
14565
+ gap: 8px;
14566
+ min-width: 0;
14567
+ }
14568
+ .butex-mobile-command-portal .butex-mobile-command__choice {
14569
+ min-height: 44px;
14570
+ min-width: 0;
14571
+ padding: 7px 10px;
14572
+ border: 1px solid var(--butex-mobile-border);
14573
+ border-radius: 10px;
14574
+ background: var(--butex-mobile-panel);
14575
+ color: var(--butex-mobile-fg);
14576
+ text-align: center;
14577
+ font: inherit;
14578
+ font-size: .91rem;
14579
+ cursor: pointer;
14580
+ }
14581
+ .butex-mobile-command-portal .butex-mobile-command__choice[aria-pressed="true"] {
14582
+ background: var(--butex-mobile-soft);
14583
+ border-color: var(--butex-mobile-accent);
14584
+ }
14585
+ .butex-mobile-command-portal .butex-mobile-sheet__panel .butex-mobile-command__action,
14586
+ .butex-mobile-command-portal .butex-mobile-sheet__panel .butex-mobile-command__category {
14587
+ display: flex;
14588
+ align-items: center;
14589
+ justify-content: flex-start;
14590
+ gap: 10px;
14591
+ min-height: 48px;
14592
+ min-width: 0;
14593
+ width: 100%;
14594
+ text-align: start;
14595
+ padding: 9px 11px;
14596
+ border: 1px solid var(--butex-mobile-border);
14597
+ border-radius: 12px;
14598
+ background: var(--butex-mobile-panel);
14599
+ color: var(--butex-mobile-fg);
14600
+ cursor: pointer;
14601
+ font: inherit;
14602
+ font-size: 1rem;
14603
+ font-weight: 560;
14604
+ line-height: 1.5;
14605
+ white-space: normal;
14606
+ overflow-wrap: anywhere;
14607
+ }
14608
+ .butex-mobile-command-portal .butex-mobile-command__action .butex-mobile-command__icon {
14609
+ flex: 0 0 20px;
14610
+ color: var(--butex-mobile-accent);
14611
+ }
14612
+ .butex-mobile-command-portal .butex-mobile-command__action-label {
14613
+ flex: 1 1 0;
14614
+ min-width: 0;
14615
+ }
14616
+ .butex-mobile-command-portal .butex-mobile-command__action--danger { color: var(--butex-mobile-danger); }
14617
+ .butex-mobile-command-portal .butex-mobile-command__action--danger svg { color: currentColor; }
14618
+ .butex-mobile-command-portal .butex-mobile-command__category {
14619
+ min-height: 64px;
14620
+ padding: 10px 12px;
14621
+ font-weight: 680;
14622
+ background: color-mix(in srgb, var(--butex-mobile-panel) 94%, var(--butex-mobile-accent));
14623
+ }
14624
+ .butex-mobile-command-portal .butex-mobile-command__category-icon {
14625
+ display: inline-flex;
14626
+ align-items: center;
14627
+ justify-content: center;
14628
+ width: 36px;
14629
+ height: 36px;
14630
+ flex: 0 0 36px;
14631
+ border-radius: 10px;
14632
+ background: var(--butex-mobile-soft);
14633
+ color: var(--butex-mobile-accent);
14634
+ }
14635
+ .butex-mobile-command-portal .butex-mobile-command__category-label { flex: 1; min-width: 0; }
14636
+ .butex-mobile-command-portal .butex-mobile-command__category > svg { color: var(--butex-mobile-muted); flex: 0 0 auto; }
14637
+ .butex-mobile-command-portal[dir="rtl"] .butex-mobile-command__category > svg,
14638
+ .butex-mobile-command-portal[dir="rtl"] .butex-mobile-sheet__back > svg { transform: scaleX(-1); }
14639
+ .butex-mobile-command-portal .butex-mobile-command__action[aria-pressed="true"],
14640
+ .butex-mobile-command-portal .butex-mobile-command__action[aria-selected="true"],
14641
+ .butex-mobile-command-portal .butex-mobile-command__category[aria-pressed="true"] {
14642
+ border-color: var(--butex-mobile-accent);
14643
+ background: var(--butex-mobile-soft);
14644
+ }
14645
+ .butex-mobile-command-portal .butex-mobile-command__action:disabled,
14646
+ .butex-mobile-command-portal .butex-mobile-command__category:disabled { opacity: .45; cursor: not-allowed; }
14647
+ .butex-mobile-command-portal .butex-mobile-command__action:focus-visible,
14648
+ .butex-mobile-command-portal .butex-mobile-command__category:focus-visible,
14649
+ .butex-mobile-command-portal .butex-mobile-sheet__back:focus-visible,
14650
+ .butex-mobile-command-portal .butex-mobile-sheet__close:focus-visible,
14651
+ .butex-mobile-command-portal .butex-mobile-sheet__body button:focus-visible {
14652
+ outline: 2px solid var(--butex-mobile-accent);
14653
+ outline-offset: 2px;
14654
+ }
14655
+ .butex-mobile-command-portal .butex-mobile-command__digits {
14656
+ display: grid; gap: 8px; padding-block-start: 4px;
14657
+ }
14658
+ .butex-mobile-command-portal .butex-widget__sheet-section {
14659
+ display: grid;
14660
+ gap: 10px;
14661
+ min-width: 0;
14662
+ padding-block: 3px 14px;
14663
+ border-block-end: 1px solid var(--butex-mobile-border);
14664
+ }
14665
+ .butex-mobile-command-portal .butex-widget__sheet-section h4 {
14666
+ margin: 0;
14667
+ font-size: 1rem;
14668
+ font-weight: 740;
14669
+ line-height: 1.5;
14670
+ color: var(--butex-mobile-fg);
14671
+ }
14672
+ .butex-mobile-command-portal .butex-widget__sheet-command-grid,
14673
+ .butex-mobile-command-portal .butex-widget__sheet-choice-row,
14674
+ .butex-mobile-command-portal .butex-widget__sheet-command-list {
14675
+ display: grid;
14676
+ gap: 8px;
14677
+ grid-template-columns: repeat(2, minmax(0, 1fr));
14678
+ min-width: 0;
14679
+ }
14680
+ .butex-mobile-command-portal .butex-widget__sheet-choice-row {
14681
+ grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
14682
+ }
14683
+ .butex-mobile-command-portal .butex-mobile-command__math-glyphs {
14684
+ display: grid;
14685
+ grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
14686
+ gap: 8px;
14687
+ }
14688
+ .butex-mobile-command-portal .butex-mobile-command__math-glyphs button {
14689
+ min-width: 0;
14690
+ min-height: 46px;
14691
+ justify-content: center;
14692
+ overflow-wrap: anywhere;
14693
+ }
14694
+ .butex-mobile-command-portal .butex-mobile-sheet__body > nav > .butex-mobile-command__grid {
14695
+ margin-top: 2px;
14696
+ }
14697
+ .butex-mobile-command-portal .butex-mobile-command__grid--dense > button {
14698
+ min-height: 48px; min-width: 0;
14699
+ text-align: center; overflow-wrap: anywhere;
14700
+ }
14701
+ .butex-mobile-command-portal .butex-widget__sheet-command-grid.butex-mobile-command__grid--dense {
14702
+ grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
14703
+ }
14704
+ .butex-mobile-command-portal .butex-mobile-command__section > .butex-widget__sheet-command-grid {
14705
+ margin-block-start: 0;
14706
+ }
14707
+ .butex-mobile-command-portal .butex-mobile-sheet__body button:not(.butex-mobile-command__action):not(.butex-mobile-command__category) {
14708
+ min-height: 44px;
14709
+ }
14710
+ .butex-mobile-command-portal .butex-mobile-sheet__body .butex-widget__sheet-command-grid,
14711
+ .butex-mobile-command-portal .butex-mobile-sheet__body .butex-widget__sheet-choice-row,
14712
+ .butex-mobile-command-portal .butex-mobile-sheet__body .butex-widget__sheet-command-list {
14713
+ min-width: 0;
14714
+ }
14715
+ @media (max-width: 430px) {
14716
+ .butex-mobile-command-portal .butex-mobile-sheet__panel { border-radius: 18px 18px 0 0; }
14717
+ .butex-mobile-command-portal .butex-mobile-sheet__header { padding-inline: 10px; }
14718
+ .butex-mobile-command-portal .butex-mobile-sheet__body { padding-inline: 12px; }
14719
+ }
14720
+ @media (hover: hover) {
14721
+ .butex-mobile-command-portal .butex-mobile-command__action:hover:not(:disabled),
14722
+ .butex-mobile-command-portal .butex-mobile-command__category:hover:not(:disabled),
14723
+ .butex-mobile-command-portal .butex-mobile-command__choice:hover:not(:disabled) {
14724
+ border-color: var(--butex-mobile-accent);
14725
+ background: color-mix(in srgb, var(--butex-mobile-panel) 94%, var(--butex-mobile-accent));
14726
+ }
14727
+ }
14728
+ @media (forced-colors: active) {
14729
+ .butex-mobile-command-portal .butex-mobile-command__action[aria-pressed="true"],
14730
+ .butex-mobile-command-portal .butex-mobile-command__category[aria-pressed="true"] { outline: 2px solid Highlight; }
14731
+ }
14732
+ @media (prefers-reduced-motion: reduce) {
14733
+ .butex-mobile-command-portal .butex-mobile-sheet__panel,
14734
+ .butex-mobile-command-portal .butex-mobile-sheet__body,
14735
+ .butex-mobile-command-portal .butex-mobile-sheet__body button { animation: none; transition: none; scroll-behavior: auto; }
14736
+ }
14737
+ `.trim();
14738
+ var STYLE_ID = "butex-mobile-command-ui-css";
14739
+ function injectMobileCommandCss(doc) {
14740
+ if (doc.getElementById(STYLE_ID)) return;
14741
+ const style = doc.createElement("style");
14742
+ style.id = STYLE_ID;
14743
+ style.textContent = MOBILE_COMMAND_CSS;
14744
+ doc.head.appendChild(style);
14745
+ }
14746
+
14747
+ // src/react/mobileCommandUi.tsx
14748
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
14749
+ var MOBILE_DIGIT_CHOICES = [
14750
+ { id: "western", label: "456" },
14751
+ { id: "arabicIndic", label: "\u0664\u0665\u0666" },
14752
+ { id: "persianIndic", label: "\u06F4\u06F5\u06F6" }
14753
+ ];
14754
+ var iconPaths = {
14755
+ bold: "M7 4h6a4 4 0 0 1 0 8H7zm0 8h7a4 4 0 0 1 0 8H7z",
14756
+ italic: "M14 4h6M4 20h6M15 4 9 20",
14757
+ underline: "M6 4v7a6 6 0 0 0 12 0V4M4 21h16",
14758
+ heading: "M4 5v14M14 5v14M4 12h10M18 7h3v12",
14759
+ paragraph: "M19 4H9a5 5 0 0 0 0 10h3v6M16 4v16",
14760
+ math: "M18 5H6l6 7-6 7h12",
14761
+ table: "M4 5h16v14H4zM4 10h16M4 15h16M10 5v14",
14762
+ image: "M4 5h16v14H4zM7 15l4-4 3 3 2-2 4 4M9 9h.01",
14763
+ list: "M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01",
14764
+ "ordered-list": "M9 6h11M9 12h11M9 18h11M3 4h2v5M3 15h2l-2 3h2",
14765
+ citation: "M9 5H4v7h5v5H4M20 5h-5v7h5v5h-5",
14766
+ reference: "M5 4h14v16l-7-4-7 4z",
14767
+ book: "M5 4h7v16H5a2 2 0 0 0-2 2V6a2 2 0 0 1 2-2zm7 0h7a2 2 0 0 1 2 2v16a2 2 0 0 0-2-2h-7",
14768
+ collapse: "M5 9l7-6 7 6M5 15l7-6 7 6M4 21h16",
14769
+ expand: "M5 6l7 6 7-6M5 12l7 6 7-6",
14770
+ up: "M12 20V4M5 11l7-7 7 7",
14771
+ down: "M12 4v16M5 13l7 7 7-7",
14772
+ trash: "M4 7h16M9 7V4h6v3M7 7l1 13h8l1-13M10 11v6M14 11v6",
14773
+ structure: "M12 3v6M5 9h14M5 9v5M19 9v5M2 14h6v6H2zM16 14h6v6h-6z",
14774
+ functions: "M4 20c5-4 3-12 8-16M6 10h11M17 9l5 9M22 9l-5 9",
14775
+ operators: "M4 8h8M8 4v8M16 8h6M16 16h6M16 20h6",
14776
+ matrices: "M7 4H4v16h3M17 4h3v16h-3M10 7h.01M14 7h.01M10 12h.01M14 12h.01M10 17h.01M14 17h.01",
14777
+ typography: "M3 6V4h18v2M12 4v16M8 20h8",
14778
+ spacing: "M4 7v10M20 7v10M7 12h10M10 9l-3 3 3 3M14 9l3 3-3 3",
14779
+ digits: "M4 7h4v10M13 7h7v5h-7v5h7",
14780
+ copy: "M8 8h12v13H8zM5 17H4V4h12v1",
14781
+ cut: "M4 6l16 12M20 6 4 18M7 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0M7 18a2 2 0 1 1-4 0 2 2 0 0 1 4 0",
14782
+ paste: "M9 4h6l1 3H8zM7 6H5v15h14V6h-2M9 13h6M9 17h5",
14783
+ chevron: "M9 5l6 7-6 7",
14784
+ back: "M19 12H5M12 5l-7 7 7 7",
14785
+ close: "M5 5l14 14M19 5 5 19",
14786
+ fraction: "M5 12h14M8 4h8M8 20h8",
14787
+ delimiters: "M9 3c-5 4-5 14 0 18M15 3c5 4 5 14 0 18"
14788
+ };
14789
+ function MobileIcon({ name, size = 20 }) {
14790
+ return /* @__PURE__ */ jsx11(
14791
+ "svg",
14792
+ {
14793
+ "aria-hidden": "true",
14794
+ focusable: "false",
14795
+ className: "butex-mobile-command__icon",
14796
+ width: size,
14797
+ height: size,
14798
+ viewBox: "0 0 24 24",
14799
+ fill: "none",
14800
+ stroke: "currentColor",
14801
+ strokeWidth: "1.8",
14802
+ strokeLinecap: "round",
14803
+ strokeLinejoin: "round",
14804
+ children: /* @__PURE__ */ jsx11("path", { d: iconPaths[name] })
14805
+ }
14806
+ );
14807
+ }
14808
+ function MobileAction({ command }) {
14809
+ return /* @__PURE__ */ jsxs10(
14810
+ "button",
14811
+ {
14812
+ type: "button",
14813
+ className: "butex-mobile-command__action" + (command.danger ? " butex-mobile-command__action--danger" : ""),
14814
+ disabled: command.disabled,
14815
+ "aria-label": command.label,
14816
+ "aria-pressed": command.pressed,
14817
+ title: command.hint ?? command.label,
14818
+ onMouseDown: command.preserveSelection ? (event) => event.preventDefault() : void 0,
14819
+ onClick: command.onSelect,
14820
+ children: [
14821
+ /* @__PURE__ */ jsx11(MobileIcon, { name: command.icon }),
14822
+ /* @__PURE__ */ jsx11("span", { className: "butex-mobile-command__action-label", children: command.label })
14823
+ ]
14824
+ }
14825
+ );
14826
+ }
14827
+ function MobileSection({ title, icon, children, id }) {
14828
+ return /* @__PURE__ */ jsxs10("section", { className: "butex-mobile-command__section", "aria-label": id ? void 0 : title, "aria-labelledby": id, children: [
14829
+ /* @__PURE__ */ jsxs10("h3", { className: "butex-mobile-command__section-title", id, children: [
14830
+ icon ? /* @__PURE__ */ jsx11(MobileIcon, { name: icon, size: 18 }) : null,
14831
+ /* @__PURE__ */ jsx11("span", { children: title })
14832
+ ] }),
14833
+ children
14834
+ ] });
14835
+ }
14836
+ function MobileGrid({ children, dense = false, className = "" }) {
14837
+ return /* @__PURE__ */ jsx11("div", { className: "butex-mobile-command__grid" + (dense ? " butex-mobile-command__grid--dense" : "") + (className ? " " + className : ""), children });
14838
+ }
14839
+ function MobileChoice({ label, title, pressed, onClick, disabled, className = "" }) {
14840
+ return /* @__PURE__ */ jsx11(
14841
+ "button",
14842
+ {
14843
+ type: "button",
14844
+ className: "butex-mobile-command__choice " + className,
14845
+ title,
14846
+ "aria-pressed": pressed,
14847
+ disabled,
14848
+ onClick,
14849
+ children: label
14850
+ }
14851
+ );
14852
+ }
14853
+ function MobileCategory({ label, icon, onClick }) {
14854
+ return /* @__PURE__ */ jsxs10("button", { type: "button", className: "butex-mobile-command__category", onClick, children: [
14855
+ /* @__PURE__ */ jsx11("span", { className: "butex-mobile-command__category-icon", children: /* @__PURE__ */ jsx11(MobileIcon, { name: icon }) }),
14856
+ /* @__PURE__ */ jsx11("span", { className: "butex-mobile-command__category-label", children: label }),
14857
+ /* @__PURE__ */ jsx11(MobileIcon, { name: "chevron", size: 16 })
14858
+ ] });
14859
+ }
14860
+ function MobileCommandSheet({
14861
+ scope,
14862
+ sourceRef,
14863
+ dialogRef,
14864
+ titleId,
14865
+ title,
14866
+ closeLabel,
14867
+ onClose,
14868
+ backLabel,
14869
+ onBack,
14870
+ backRef,
14871
+ bodyClassName,
14872
+ children
14873
+ }) {
14874
+ useLayoutEffect2(() => {
14875
+ const doc = sourceRef.current?.ownerDocument ?? document;
14876
+ injectMobileCommandCss(doc);
14877
+ }, [sourceRef]);
14878
+ const stopBackdropClick = (event) => {
14879
+ if (event.currentTarget === event.target) onClose();
14880
+ };
14881
+ return /* @__PURE__ */ jsx11(MobileCommandPortal, { sourceRef, scopeClassName: scope, children: /* @__PURE__ */ jsx11(
14882
+ "div",
14883
+ {
14884
+ className: scope + "__command-sheet-backdrop butex-mobile-sheet__backdrop",
14885
+ style: mobileCommandBackdropStyle,
14886
+ role: "presentation",
14887
+ onClick: stopBackdropClick,
14888
+ children: /* @__PURE__ */ jsxs10(
14889
+ "section",
14890
+ {
14891
+ ref: dialogRef,
14892
+ className: scope + "__command-sheet butex-mobile-sheet__panel",
14893
+ style: mobileCommandSheetStyle,
14894
+ role: "dialog",
14895
+ "aria-modal": "true",
14896
+ "aria-labelledby": titleId,
14897
+ tabIndex: -1,
14898
+ children: [
14899
+ /* @__PURE__ */ jsxs10("header", { className: scope + "__command-sheet-header butex-mobile-sheet__header", children: [
14900
+ onBack ? /* @__PURE__ */ jsxs10("button", { type: "button", className: "butex-mobile-sheet__back", ref: backRef, onClick: onBack, children: [
14901
+ /* @__PURE__ */ jsx11(MobileIcon, { name: "back", size: 18 }),
14902
+ /* @__PURE__ */ jsx11("span", { children: backLabel })
14903
+ ] }) : /* @__PURE__ */ jsx11("span", { "aria-hidden": "true", className: "butex-mobile-sheet__header-spacer" }),
14904
+ /* @__PURE__ */ jsx11("strong", { id: titleId, children: title }),
14905
+ /* @__PURE__ */ jsx11(
14906
+ "button",
14907
+ {
14908
+ type: "button",
14909
+ className: "butex-mobile-sheet__close",
14910
+ "data-dialog-initial-focus": true,
14911
+ "aria-label": closeLabel,
14912
+ title: closeLabel,
14913
+ onClick: onClose,
14914
+ children: /* @__PURE__ */ jsx11(MobileIcon, { name: "close", size: 19 })
14915
+ }
14916
+ )
14917
+ ] }),
14918
+ /* @__PURE__ */ jsx11("div", { className: scope + "__command-sheet-body butex-mobile-sheet__body" + (bodyClassName ? " " + bodyClassName : ""), children })
14919
+ ]
14920
+ }
14921
+ )
14922
+ }
14923
+ ) });
14924
+ }
14925
+
14926
+ // src/react-document/DocumentMobileToolbar.tsx
14927
+ import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
14928
+ function DocumentMobileToolbar({
14929
+ mode = "article",
14930
+ mobileView,
14931
+ canUndo,
14932
+ canRedo,
14933
+ editableEquations,
14934
+ uiLocale,
14935
+ digitForm,
14936
+ selectionCount,
14937
+ canMoveSelectionUp,
14938
+ canMoveSelectionDown,
14939
+ canFormatText,
14940
+ activeTextStyles,
14941
+ onMobileViewChange,
14942
+ onUndo,
14943
+ onRedo,
14944
+ onToggleTextStyle,
14945
+ onMoveSelectionUp,
14946
+ onMoveSelectionDown,
14947
+ onDeleteSelection,
14948
+ onAddSection,
14949
+ onAddSubsection,
14950
+ onAddSubsubsection,
14951
+ onAddParagraph,
14952
+ onAddInlineEquation,
14953
+ onAddDisplayEquation,
14954
+ onAddTable,
14955
+ onAddList,
14956
+ onAddEnumerate,
14957
+ onAddFigure,
14958
+ onInsertCitation,
14959
+ onInsertInternalRef,
14960
+ onInsertBibliography,
14961
+ onManageReferences,
14962
+ onManageLabels,
14963
+ onOpenArticleMeta,
14964
+ onDigitFormChange,
14965
+ onCollapseAll,
14966
+ onOpenAll
14967
+ }) {
14968
+ const messages = documentMessages(uiLocale);
14969
+ const [sheetOpen, setSheetOpen] = useState8(false);
14970
+ const [sheetView, setSheetView] = useState8("commands");
14971
+ const [rows, setRows] = useState8("3");
14972
+ const [cols, setCols] = useState8("3");
14973
+ const triggerRef = useRef8(null);
14974
+ const dialogRef = useRef8(null);
14975
+ const titleId = useId2();
14976
+ function closeSheet() {
14977
+ setSheetOpen(false);
14978
+ setSheetView("commands");
14979
+ }
14980
+ useDialogFocus({ open: sheetOpen, dialogRef, triggerRef, onClose: closeSheet });
14981
+ function runAction(action, revealEditor = true) {
14982
+ closeSheet();
14983
+ if (revealEditor) {
14984
+ onMobileViewChange("editor");
14985
+ }
14986
+ action();
14987
+ }
14988
+ function insertTable() {
14989
+ const rowCount = Math.max(1, Math.min(20, Number.parseInt(rows, 10) || 3));
14990
+ const colCount = Math.max(1, Math.min(10, Number.parseInt(cols, 10) || 3));
14991
+ runAction(() => onAddTable(rowCount, colCount));
14992
+ }
14993
+ function digitTitle2(id) {
14994
+ if (id === "arabicIndic") {
14995
+ return messages.arabicIndicDigits;
14996
+ }
14997
+ if (id === "persianIndic") {
14998
+ return messages.persianIndicDigits;
14999
+ }
15000
+ return messages.westernDigits;
15001
+ }
15002
+ const showContextRow = selectionCount > 0 || canFormatText;
15003
+ const formatStyles = ["bold", "italic", "underline"];
15004
+ const formatIcons = { bold: "bold", italic: "italic", underline: "underline" };
15005
+ const groups = [
15006
+ {
15007
+ id: "format",
15008
+ label: messages.textFormatting,
15009
+ icon: "bold",
15010
+ commands: formatStyles.map((style) => ({
15011
+ id: style,
15012
+ label: messages[style],
15013
+ icon: formatIcons[style],
15014
+ pressed: activeTextStyles[style] === true,
15015
+ disabled: !canFormatText,
15016
+ preserveSelection: true,
15017
+ onSelect: () => runAction(() => onToggleTextStyle(style))
15018
+ }))
15019
+ },
15020
+ {
15021
+ id: "structure",
15022
+ label: messages.structure,
15023
+ icon: "heading",
15024
+ commands: [
15025
+ ...mode === "article" ? [{ id: "meta", label: messages.articleMetaTitle, icon: "book", onSelect: () => runAction(onOpenArticleMeta) }] : [],
15026
+ { id: "section", label: messages.addSection, icon: "heading", onSelect: () => runAction(onAddSection) },
15027
+ { id: "subsection", label: messages.addSubsection, icon: "heading", onSelect: () => runAction(onAddSubsection) },
15028
+ { id: "subsubsection", label: messages.addSubsubsection, icon: "heading", onSelect: () => runAction(onAddSubsubsection) },
15029
+ { id: "paragraph", label: messages.addParagraph, icon: "paragraph", onSelect: () => runAction(onAddParagraph) }
15030
+ ]
15031
+ },
15032
+ {
15033
+ id: "equations",
15034
+ label: messages.equations,
15035
+ icon: "math",
15036
+ commands: [
15037
+ { id: "inline", label: messages.inlineEquation, icon: "math", disabled: !editableEquations, onSelect: () => runAction(onAddInlineEquation) },
15038
+ { id: "display", label: messages.displayEquation, icon: "fraction", disabled: !editableEquations, onSelect: () => runAction(onAddDisplayEquation) }
15039
+ ]
15040
+ },
15041
+ {
15042
+ id: "content",
15043
+ label: messages.content,
15044
+ icon: "image",
15045
+ commands: [
15046
+ { id: "bullets", label: messages.bulletedList, icon: "list", onSelect: () => runAction(onAddList) },
15047
+ { id: "numbers", label: messages.numberedList, icon: "ordered-list", onSelect: () => runAction(onAddEnumerate) },
15048
+ { id: "table", label: messages.insertTable, icon: "table", onSelect: () => setSheetView("table") },
15049
+ { id: "figure", label: messages.insertImage, icon: "image", onSelect: () => runAction(onAddFigure) }
15050
+ ]
15051
+ },
15052
+ {
15053
+ id: "references",
15054
+ label: messages.citations,
15055
+ icon: "citation",
15056
+ commands: [
15057
+ { id: "cite", label: messages.insertCitation, icon: "citation", onSelect: () => runAction(onInsertCitation, false) },
15058
+ { id: "ref", label: messages.insertInternalRef, icon: "reference", onSelect: () => runAction(onInsertInternalRef, false) },
15059
+ ...mode === "article" ? [
15060
+ { id: "bibliography", label: messages.insertBibliography, icon: "book", onSelect: () => runAction(onInsertBibliography) },
15061
+ { id: "manage-refs", label: messages.manageReferences, icon: "citation", onSelect: () => runAction(() => onManageReferences(triggerRef.current), false) }
15062
+ ] : [],
15063
+ { id: "labels", label: messages.manageLabels, icon: "reference", onSelect: () => runAction(() => onManageLabels(triggerRef.current), false) }
15064
+ ]
15065
+ },
15066
+ {
15067
+ id: "document",
15068
+ label: messages.documentActions,
15069
+ icon: "collapse",
15070
+ commands: [
15071
+ { id: "collapse", label: messages.collapseAll, icon: "collapse", onSelect: () => runAction(onCollapseAll) },
15072
+ { id: "expand", label: messages.openAll, icon: "expand", onSelect: () => runAction(onOpenAll) }
15073
+ ]
15074
+ },
15075
+ ...selectionCount > 0 ? [{
15076
+ id: "selection",
15077
+ label: messages.blockSelection,
15078
+ icon: "structure",
15079
+ commands: [
15080
+ { id: "up", label: messages.moveUp, icon: "up", disabled: !canMoveSelectionUp, onSelect: () => runAction(onMoveSelectionUp) },
15081
+ { id: "down", label: messages.moveDown, icon: "down", disabled: !canMoveSelectionDown, onSelect: () => runAction(onMoveSelectionDown) },
15082
+ { id: "delete", label: messages.deleteBlock, icon: "trash", danger: true, onSelect: () => runAction(onDeleteSelection) }
15083
+ ]
15084
+ }] : []
15085
+ ];
15086
+ return /* @__PURE__ */ jsxs11("div", { className: "butex-document-widget__mobile-toolbar", children: [
15087
+ /* @__PURE__ */ jsxs11("div", { className: "butex-document-widget__mobile-toolbar-primary", children: [
15088
+ /* @__PURE__ */ jsxs11("div", { className: "butex-document-widget__mobile-view", role: "group", "aria-label": messages.mobileViews, children: [
15089
+ /* @__PURE__ */ jsx12(
15090
+ "button",
15091
+ {
15092
+ type: "button",
15093
+ "aria-pressed": mobileView === "editor",
15094
+ onClick: () => onMobileViewChange("editor"),
15095
+ children: messages.editor
15096
+ }
15097
+ ),
15098
+ /* @__PURE__ */ jsx12(
15099
+ "button",
15100
+ {
15101
+ type: "button",
15102
+ "aria-pressed": mobileView === "preview",
15103
+ onClick: () => onMobileViewChange("preview"),
15104
+ children: messages.preview
15105
+ }
15106
+ )
15107
+ ] }),
15108
+ /* @__PURE__ */ jsxs11("div", { className: "butex-document-widget__mobile-toolbar-actions", role: "group", "aria-label": messages.mobileToolbar, children: [
15109
+ /* @__PURE__ */ jsx12("button", { type: "button", className: "butex-document-widget__icon-btn", title: messages.undo, "aria-label": messages.undo, disabled: !canUndo, onClick: onUndo, children: "\u21B6" }),
15110
+ /* @__PURE__ */ jsx12("button", { type: "button", className: "butex-document-widget__icon-btn", title: messages.redo, "aria-label": messages.redo, disabled: !canRedo, onClick: onRedo, children: "\u21B7" }),
15111
+ /* @__PURE__ */ jsx12(
15112
+ "button",
15113
+ {
15114
+ ref: triggerRef,
15115
+ type: "button",
15116
+ className: "butex-document-widget__icon-btn",
15117
+ title: messages.moreActions,
15118
+ "aria-label": messages.moreActions,
15119
+ "aria-haspopup": "dialog",
15120
+ "aria-expanded": sheetOpen,
15121
+ onClick: () => setSheetOpen(true),
15122
+ children: "\u22EF"
15123
+ }
15124
+ )
15125
+ ] })
15126
+ ] }),
15127
+ showContextRow ? /* @__PURE__ */ jsxs11("div", { className: "butex-document-widget__mobile-context", "aria-label": messages.contextActions, children: [
15128
+ selectionCount > 0 ? /* @__PURE__ */ jsxs11(Fragment3, { children: [
15129
+ /* @__PURE__ */ jsxs11("span", { className: "butex-document-widget__selection-count", children: [
15130
+ selectionCount,
15131
+ " ",
15132
+ messages.selectedBlockCount
15133
+ ] }),
15134
+ /* @__PURE__ */ jsx12("button", { type: "button", className: "butex-document-widget__icon-btn", title: messages.moveUp, "aria-label": messages.moveUp, disabled: !canMoveSelectionUp, onClick: onMoveSelectionUp, children: "\u2191" }),
15135
+ /* @__PURE__ */ jsx12("button", { type: "button", className: "butex-document-widget__icon-btn", title: messages.moveDown, "aria-label": messages.moveDown, disabled: !canMoveSelectionDown, onClick: onMoveSelectionDown, children: "\u2193" }),
15136
+ /* @__PURE__ */ jsx12("button", { type: "button", className: "butex-document-widget__button--danger", onClick: onDeleteSelection, children: messages.deleteBlock })
15137
+ ] }) : null,
15138
+ canFormatText ? /* @__PURE__ */ jsx12(Fragment3, { children: ["bold", "italic", "underline"].map((styleName) => /* @__PURE__ */ jsx12(
15139
+ "button",
15140
+ {
15141
+ type: "button",
15142
+ className: `butex-document-widget__icon-btn butex-document-widget__format-btn butex-document-widget__format-btn--${styleName}`,
15143
+ "aria-label": messages[styleName],
15144
+ "aria-pressed": activeTextStyles[styleName] === true,
15145
+ onMouseDown: (event) => event.preventDefault(),
15146
+ onClick: () => onToggleTextStyle(styleName),
15147
+ children: styleName === "bold" ? "B" : styleName === "italic" ? "I" : "U"
15148
+ },
15149
+ styleName
15150
+ )) }) : null
15151
+ ] }) : null,
15152
+ sheetOpen ? /* @__PURE__ */ jsx12(
15153
+ MobileCommandSheet,
15154
+ {
15155
+ scope: "butex-document-widget",
15156
+ sourceRef: triggerRef,
15157
+ dialogRef,
15158
+ titleId,
15159
+ title: sheetView === "table" ? messages.tableSize : messages.moreActions,
15160
+ closeLabel: messages.close,
15161
+ onClose: closeSheet,
15162
+ backLabel: sheetView === "table" ? messages.backToActions : void 0,
15163
+ onBack: sheetView === "table" ? () => setSheetView("commands") : void 0,
15164
+ bodyClassName: sheetView === "table" ? "butex-document-widget__mobile-table-form" : void 0,
15165
+ children: sheetView === "table" ? /* @__PURE__ */ jsxs11(Fragment3, { children: [
15166
+ /* @__PURE__ */ jsxs11("label", { children: [
15167
+ /* @__PURE__ */ jsx12("span", { children: messages.rows }),
15168
+ /* @__PURE__ */ jsx12("input", { type: "number", min: 1, max: 20, value: rows, onChange: (event) => setRows(event.currentTarget.value) })
15169
+ ] }),
15170
+ /* @__PURE__ */ jsxs11("label", { children: [
15171
+ /* @__PURE__ */ jsx12("span", { children: messages.columns }),
15172
+ /* @__PURE__ */ jsx12("input", { type: "number", min: 1, max: 10, value: cols, onChange: (event) => setCols(event.currentTarget.value) })
15173
+ ] }),
15174
+ /* @__PURE__ */ jsx12("button", { type: "button", className: "butex-document-widget__primary-btn", onClick: insertTable, children: messages.insertTable })
15175
+ ] }) : /* @__PURE__ */ jsx12(Fragment3, { children: groups.map((group) => /* @__PURE__ */ jsxs11(MobileSection, { id: titleId + "-" + group.id, title: group.label, icon: group.icon, children: [
15176
+ /* @__PURE__ */ jsx12(MobileGrid, { children: group.commands.map((command) => /* @__PURE__ */ jsx12(MobileAction, { command }, command.id)) }),
15177
+ group.id === "equations" ? /* @__PURE__ */ jsxs11("div", { className: "butex-mobile-command__digits", children: [
15178
+ /* @__PURE__ */ jsx12("span", { className: "butex-document-widget__command-subtitle", children: messages.chooseDigitForm }),
15179
+ /* @__PURE__ */ jsx12("div", { className: "butex-mobile-command__choice-row", role: "group", "aria-label": messages.chooseDigitForm, children: MOBILE_DIGIT_CHOICES.map((option) => /* @__PURE__ */ jsx12(
15180
+ MobileChoice,
15181
+ {
15182
+ label: option.label,
15183
+ title: digitTitle2(option.id),
15184
+ pressed: digitForm === option.id,
15185
+ onClick: () => runAction(() => onDigitFormChange(option.id), false)
15186
+ },
15187
+ option.id
15188
+ )) })
15189
+ ] }) : null
15190
+ ] }, group.id)) })
15191
+ }
15192
+ ) : null
15193
+ ] });
15194
+ }
15195
+
15196
+ // src/react-document/DocumentPreview.tsx
15197
+ import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
15198
+ var REF_KIND_NAMES = [
15199
+ { names: ["\u0627\u0644\u0634\u0643\u0644", "\u0634\u0643\u0644", "Figure", "figure"], prefixes: ["\u0627\u0644\u0634\u0643\u0644 ", "Figure "] },
15200
+ { names: ["\u0627\u0644\u062C\u062F\u0648\u0644", "\u062C\u062F\u0648\u0644", "Table", "table"], prefixes: ["\u0627\u0644\u062C\u062F\u0648\u0644 ", "Table "] },
15201
+ { names: ["\u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629", "\u0645\u0639\u0627\u062F\u0644\u0629", "Equation", "equation"], prefixes: ["\u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 ", "Equation "] }
15202
+ ];
15203
+ function contextualRefLabel(inlines, index, label) {
15204
+ const previous = inlines[index - 1];
15205
+ if (previous?.kind !== "text") {
15206
+ return label;
15207
+ }
15208
+ const previousText = previous.text.trimEnd();
14531
15209
  for (const group of REF_KIND_NAMES) {
14532
15210
  if (!group.names.some((name) => previousText.endsWith(name))) {
14533
15211
  continue;
@@ -14540,29 +15218,29 @@ function contextualRefLabel(inlines, index, label) {
14540
15218
  return label;
14541
15219
  }
14542
15220
  function PreviewInlines({ inlines, output }) {
14543
- return /* @__PURE__ */ jsx12(Fragment4, { children: inlines.map((inline, index) => {
15221
+ return /* @__PURE__ */ jsx13(Fragment4, { children: inlines.map((inline, index) => {
14544
15222
  if (inline.kind === "text") {
14545
- let content = /* @__PURE__ */ jsx12("span", { children: inline.text });
15223
+ let content = /* @__PURE__ */ jsx13("span", { children: inline.text });
14546
15224
  if (inline.style?.bold) {
14547
- content = /* @__PURE__ */ jsx12("strong", { children: content });
15225
+ content = /* @__PURE__ */ jsx13("strong", { children: content });
14548
15226
  }
14549
15227
  if (inline.style?.italic) {
14550
- content = /* @__PURE__ */ jsx12("em", { children: content });
15228
+ content = /* @__PURE__ */ jsx13("em", { children: content });
14551
15229
  }
14552
15230
  if (inline.style?.underline) {
14553
- content = /* @__PURE__ */ jsx12("span", { className: "butex-document-widget__preview-underline", children: content });
15231
+ content = /* @__PURE__ */ jsx13("span", { className: "butex-document-widget__preview-underline", children: content });
14554
15232
  }
14555
- return /* @__PURE__ */ jsx12("span", { children: content }, index);
15233
+ return /* @__PURE__ */ jsx13("span", { children: content }, index);
14556
15234
  }
14557
15235
  if (inline.kind === "cite") {
14558
- return /* @__PURE__ */ jsx12("span", { className: "butex-document-widget__preview-cite", children: inline.label }, inline.id);
15236
+ return /* @__PURE__ */ jsx13("span", { className: "butex-document-widget__preview-cite", children: inline.label }, inline.id);
14559
15237
  }
14560
15238
  if (inline.kind === "ref") {
14561
- return /* @__PURE__ */ jsx12("span", { className: "butex-document-widget__preview-cite butex-document-widget__preview-ref", children: contextualRefLabel(inlines, index, inline.label) }, inline.id);
15239
+ return /* @__PURE__ */ jsx13("span", { className: "butex-document-widget__preview-cite butex-document-widget__preview-ref", children: contextualRefLabel(inlines, index, inline.label) }, inline.id);
14562
15240
  }
14563
- return /* @__PURE__ */ jsxs11("span", { className: "butex-document-widget__preview-math-numbered", children: [
14564
- /* @__PURE__ */ jsx12(MathIsland, { id: inline.id, tex: inline.tex, display: inline.display, output }),
14565
- inline.numberLabel ? /* @__PURE__ */ jsxs11("span", { className: "butex-document-widget__preview-equation-number", children: [
15241
+ return /* @__PURE__ */ jsxs12("span", { className: "butex-document-widget__preview-math-numbered", children: [
15242
+ /* @__PURE__ */ jsx13(MathIsland, { id: inline.id, tex: inline.tex, display: inline.display, output }),
15243
+ inline.numberLabel ? /* @__PURE__ */ jsxs12("span", { className: "butex-document-widget__preview-equation-number", children: [
14566
15244
  "(",
14567
15245
  inline.numberLabel,
14568
15246
  ")"
@@ -14593,51 +15271,51 @@ function PreviewBlock({
14593
15271
  if (!numberLabel && !hasCaption) {
14594
15272
  return null;
14595
15273
  }
14596
- return /* @__PURE__ */ jsxs11("figcaption", { dir: documentDirection, children: [
14597
- numberLabel ? /* @__PURE__ */ jsxs11("span", { className: "butex-document-widget__preview-float-number", children: [
15274
+ return /* @__PURE__ */ jsxs12("figcaption", { dir: documentDirection, children: [
15275
+ numberLabel ? /* @__PURE__ */ jsxs12("span", { className: "butex-document-widget__preview-float-number", children: [
14598
15276
  numberLabel,
14599
15277
  hasCaption ? floatCaptionSeparator : ""
14600
15278
  ] }) : null,
14601
- captionInlines ? /* @__PURE__ */ jsx12(PreviewInlines, { inlines: captionInlines, output }) : caption ?? ""
15279
+ captionInlines ? /* @__PURE__ */ jsx13(PreviewInlines, { inlines: captionInlines, output }) : caption ?? ""
14602
15280
  ] });
14603
15281
  }
14604
15282
  if (block.kind === "basmala" || block.kind === "closing") {
14605
- return /* @__PURE__ */ jsx12(
15283
+ return /* @__PURE__ */ jsx13(
14606
15284
  "p",
14607
15285
  {
14608
15286
  className: block.kind === "basmala" ? "butex-document-widget__preview-basmala" : "butex-document-widget__preview-closing",
14609
- children: /* @__PURE__ */ jsx12(MathIsland, { id: block.id, tex: block.tex, display: true, output })
15287
+ children: /* @__PURE__ */ jsx13(MathIsland, { id: block.id, tex: block.tex, display: true, output })
14610
15288
  }
14611
15289
  );
14612
15290
  }
14613
15291
  if (block.kind === "titleBlock") {
14614
- return /* @__PURE__ */ jsxs11("header", { className: "butex-document-widget__preview-title-block", children: [
14615
- block.title ? /* @__PURE__ */ jsx12("h1", { className: "butex-document-widget__preview-article-title", children: block.title }) : null,
14616
- block.authors ? /* @__PURE__ */ jsx12("p", { className: "butex-document-widget__preview-article-authors", children: block.authors.split("\n").map((line, index) => /* @__PURE__ */ jsxs11("span", { children: [
14617
- index > 0 ? /* @__PURE__ */ jsx12("br", {}) : null,
15292
+ return /* @__PURE__ */ jsxs12("header", { className: "butex-document-widget__preview-title-block", children: [
15293
+ block.title ? /* @__PURE__ */ jsx13("h1", { className: "butex-document-widget__preview-article-title", children: block.title }) : null,
15294
+ block.authors ? /* @__PURE__ */ jsx13("p", { className: "butex-document-widget__preview-article-authors", children: block.authors.split("\n").map((line, index) => /* @__PURE__ */ jsxs12("span", { children: [
15295
+ index > 0 ? /* @__PURE__ */ jsx13("br", {}) : null,
14618
15296
  line
14619
15297
  ] }, index)) }) : null,
14620
- block.date ? /* @__PURE__ */ jsx12("p", { className: "butex-document-widget__preview-article-date", children: block.date }) : null
15298
+ block.date ? /* @__PURE__ */ jsx13("p", { className: "butex-document-widget__preview-article-date", children: block.date }) : null
14621
15299
  ] });
14622
15300
  }
14623
15301
  if (block.kind === "abstract") {
14624
- return /* @__PURE__ */ jsxs11("section", { className: "butex-document-widget__preview-abstract", "aria-label": messages.articleAbstract, children: [
14625
- /* @__PURE__ */ jsx12("h2", { className: "butex-document-widget__preview-abstract-label", children: messages.articleAbstract }),
14626
- /* @__PURE__ */ jsx12("p", { children: block.text })
15302
+ return /* @__PURE__ */ jsxs12("section", { className: "butex-document-widget__preview-abstract", "aria-label": messages.articleAbstract, children: [
15303
+ /* @__PURE__ */ jsx13("h2", { className: "butex-document-widget__preview-abstract-label", children: messages.articleAbstract }),
15304
+ /* @__PURE__ */ jsx13("p", { children: block.text })
14627
15305
  ] });
14628
15306
  }
14629
15307
  if (block.kind === "heading") {
14630
15308
  const Tag = block.level === 1 ? "h1" : block.level === 2 ? "h2" : "h3";
14631
- return /* @__PURE__ */ jsx12(Tag, { "data-butex-block-source": source, children: /* @__PURE__ */ jsx12(PreviewInlines, { inlines: block.inlines, output }) });
15309
+ return /* @__PURE__ */ jsx13(Tag, { "data-butex-block-source": source, children: /* @__PURE__ */ jsx13(PreviewInlines, { inlines: block.inlines, output }) });
14632
15310
  }
14633
15311
  if (block.kind === "paragraph") {
14634
- return /* @__PURE__ */ jsx12("p", { "data-butex-block-source": source, className: block.centered ? "butex-document-widget__preview-paragraph--centered" : void 0, children: /* @__PURE__ */ jsx12(PreviewInlines, { inlines: block.inlines, output }) });
15312
+ return /* @__PURE__ */ jsx13("p", { "data-butex-block-source": source, className: block.centered ? "butex-document-widget__preview-paragraph--centered" : void 0, children: /* @__PURE__ */ jsx13(PreviewInlines, { inlines: block.inlines, output }) });
14635
15313
  }
14636
15314
  if (block.kind === "list") {
14637
15315
  const Tag = block.ordered ? "ol" : "ul";
14638
- return /* @__PURE__ */ jsx12(Tag, { "data-butex-block-source": source, children: block.items.map((item) => /* @__PURE__ */ jsxs11("li", { children: [
14639
- /* @__PURE__ */ jsx12(PreviewInlines, { inlines: item.inlines, output }),
14640
- item.blocks.map((child) => /* @__PURE__ */ jsx12(
15316
+ return /* @__PURE__ */ jsx13(Tag, { "data-butex-block-source": source, children: block.items.map((item) => /* @__PURE__ */ jsxs12("li", { children: [
15317
+ /* @__PURE__ */ jsx13(PreviewInlines, { inlines: item.inlines, output }),
15318
+ item.blocks.map((child) => /* @__PURE__ */ jsx13(
14641
15319
  PreviewBlock,
14642
15320
  {
14643
15321
  block: child,
@@ -14655,39 +15333,39 @@ function PreviewBlock({
14655
15333
  return null;
14656
15334
  }
14657
15335
  if (block.kind === "table") {
14658
- return /* @__PURE__ */ jsxs11("figure", { className: "butex-document-widget__preview-float", "data-butex-block-source": source, children: [
14659
- /* @__PURE__ */ jsx12("div", { className: "butex-document-widget__preview-table-scroll", children: /* @__PURE__ */ jsx12("table", { children: /* @__PURE__ */ jsx12("tbody", { children: block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx12("tr", { children: row.map((cell, columnIndex) => /* @__PURE__ */ jsx12("td", { children: /* @__PURE__ */ jsx12(PreviewInlines, { inlines: cell, output }) }, columnIndex)) }, rowIndex)) }) }) }),
14660
- /* @__PURE__ */ jsx12(FloatCaption, { numberLabel: block.numberLabel, caption: block.caption, captionInlines: block.captionInlines })
15336
+ return /* @__PURE__ */ jsxs12("figure", { className: "butex-document-widget__preview-float", "data-butex-block-source": source, children: [
15337
+ /* @__PURE__ */ jsx13("div", { className: "butex-document-widget__preview-table-scroll", children: /* @__PURE__ */ jsx13("table", { children: /* @__PURE__ */ jsx13("tbody", { children: block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx13("tr", { children: row.map((cell, columnIndex) => /* @__PURE__ */ jsx13("td", { children: /* @__PURE__ */ jsx13(PreviewInlines, { inlines: cell, output }) }, columnIndex)) }, rowIndex)) }) }) }),
15338
+ /* @__PURE__ */ jsx13(FloatCaption, { numberLabel: block.numberLabel, caption: block.caption, captionInlines: block.captionInlines })
14661
15339
  ] });
14662
15340
  }
14663
15341
  if (block.kind === "image") {
14664
15342
  const resolvedSrc = resolveImageUrl ? resolveImageUrl({ assetId: block.assetId, value: block.src }) : block.src;
14665
15343
  const src = resolvedSrc?.trim() ?? "";
14666
- return /* @__PURE__ */ jsxs11(
15344
+ return /* @__PURE__ */ jsxs12(
14667
15345
  "figure",
14668
15346
  {
14669
15347
  className: `butex-document-widget__preview-float${block.centered === false ? " butex-document-widget__preview-float--start" : ""}`,
14670
15348
  "data-butex-block-source": source,
14671
15349
  "data-butex-image-pending": src.length === 0 ? "true" : void 0,
14672
15350
  children: [
14673
- src.length > 0 ? /* @__PURE__ */ jsx12("img", { src, alt: block.caption ?? "" }) : null,
14674
- /* @__PURE__ */ jsx12(FloatCaption, { numberLabel: block.numberLabel, caption: block.caption, captionInlines: block.captionInlines })
15351
+ src.length > 0 ? /* @__PURE__ */ jsx13("img", { src, alt: block.caption ?? "" }) : null,
15352
+ /* @__PURE__ */ jsx13(FloatCaption, { numberLabel: block.numberLabel, caption: block.caption, captionInlines: block.captionInlines })
14675
15353
  ]
14676
15354
  }
14677
15355
  );
14678
15356
  }
14679
15357
  if (block.kind === "bibliography") {
14680
- return /* @__PURE__ */ jsx12("ol", { className: "butex-document-widget__preview-bibliography", "data-butex-block-source": source, children: block.items.map((item) => /* @__PURE__ */ jsxs11("li", { children: [
14681
- /* @__PURE__ */ jsxs11("span", { className: "butex-document-widget__preview-bib-number", children: [
15358
+ return /* @__PURE__ */ jsx13("ol", { className: "butex-document-widget__preview-bibliography", "data-butex-block-source": source, children: block.items.map((item) => /* @__PURE__ */ jsxs12("li", { children: [
15359
+ /* @__PURE__ */ jsxs12("span", { className: "butex-document-widget__preview-bib-number", children: [
14682
15360
  item.numberLabel,
14683
15361
  "."
14684
15362
  ] }),
14685
15363
  " ",
14686
- /* @__PURE__ */ jsxs11("span", { children: [
15364
+ /* @__PURE__ */ jsxs12("span", { children: [
14687
15365
  bibliographyEntryBody(item, item.fieldSeparator, { digitForm }),
14688
- item.url ? /* @__PURE__ */ jsxs11(Fragment4, { children: [
15366
+ item.url ? /* @__PURE__ */ jsxs12(Fragment4, { children: [
14689
15367
  " ",
14690
- /* @__PURE__ */ jsx12("a", { href: absoluteHttpHref(item.url), target: "_blank", rel: "noreferrer", children: item.url })
15368
+ /* @__PURE__ */ jsx13("a", { href: absoluteHttpHref(item.url), target: "_blank", rel: "noreferrer", children: item.url })
14691
15369
  ] }) : null
14692
15370
  ] })
14693
15371
  ] }, item.id)) });
@@ -14705,8 +15383,8 @@ function DocumentPreview({
14705
15383
  const messages = documentMessages(uiLocale);
14706
15384
  const resolvedDigitForm = digitForm ?? (documentDirection === "rtl" ? "arabicIndic" : "western");
14707
15385
  const hasBody = blocks.some(isBodyPreviewBlock);
14708
- return /* @__PURE__ */ jsxs11("div", { className: "butex-document-widget__preview", dir: documentDirection, children: [
14709
- blocks.map((block) => /* @__PURE__ */ jsx12(
15386
+ return /* @__PURE__ */ jsxs12("div", { className: "butex-document-widget__preview", dir: documentDirection, children: [
15387
+ blocks.map((block) => /* @__PURE__ */ jsx13(
14710
15388
  PreviewBlock,
14711
15389
  {
14712
15390
  block,
@@ -14718,12 +15396,12 @@ function DocumentPreview({
14718
15396
  },
14719
15397
  block.id
14720
15398
  )),
14721
- !hasBody ? /* @__PURE__ */ jsx12("p", { className: "butex-document-widget__preview-empty-body", children: messages.emptyDocument }) : null
15399
+ !hasBody ? /* @__PURE__ */ jsx13("p", { className: "butex-document-widget__preview-empty-body", children: messages.emptyDocument }) : null
14722
15400
  ] });
14723
15401
  }
14724
15402
 
14725
15403
  // src/react-document/EquationDrawer.tsx
14726
- import { useEffect as useEffect11, useId as useId5, useRef as useRef11, useState as useState10 } from "react";
15404
+ import { useEffect as useEffect11, useId as useId5, useRef as useRef11, useState as useState11 } from "react";
14727
15405
 
14728
15406
  // src/react/ButexEditor.tsx
14729
15407
  import {
@@ -14733,7 +15411,7 @@ import {
14733
15411
  useId as useId4,
14734
15412
  useImperativeHandle,
14735
15413
  useRef as useRef10,
14736
- useState as useState9
15414
+ useState as useState10
14737
15415
  } from "react";
14738
15416
 
14739
15417
  // src/react/matrixPickerCss.ts
@@ -15128,95 +15806,6 @@ var WIDGET_CHROME_CSS = `
15128
15806
  margin-top: 8px;
15129
15807
  }
15130
15808
 
15131
- .butex-widget .butex-widget__command-sheet-backdrop {
15132
- align-items: flex-end;
15133
- background: rgba(15, 23, 42, 0.38);
15134
- inset: 0;
15135
- justify-content: center;
15136
- padding-bottom: var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px));
15137
- padding-left: max(12px, var(--butex-safe-area-left, env(safe-area-inset-left, 0px)));
15138
- padding-right: max(12px, var(--butex-safe-area-right, env(safe-area-inset-right, 0px)));
15139
- padding-top: max(12px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)));
15140
- position: fixed;
15141
- z-index: var(--butex-z-popover);
15142
- }
15143
-
15144
- .butex-widget .butex-widget__command-sheet {
15145
- background: var(--butex-panel);
15146
- border: 1px solid var(--butex-border);
15147
- border-radius: 16px 16px 0 0;
15148
- box-shadow: 0 -18px 48px rgba(15, 23, 42, 0.22);
15149
- display: grid;
15150
- grid-template-rows: auto minmax(0, 1fr);
15151
- max-height: min(78vh, 720px);
15152
- 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))));
15153
- max-width: 640px;
15154
- min-width: 0;
15155
- overflow: hidden;
15156
- width: 100%;
15157
- }
15158
-
15159
- .butex-widget .butex-widget__command-sheet-header {
15160
- align-items: center;
15161
- border-bottom: 1px solid var(--butex-border);
15162
- display: grid;
15163
- gap: 8px;
15164
- grid-template-columns: minmax(44px, auto) minmax(0, 1fr) minmax(44px, auto);
15165
- padding: 10px 12px;
15166
- text-align: center;
15167
- }
15168
-
15169
- .butex-widget .butex-widget__command-sheet-header strong {
15170
- overflow-wrap: anywhere;
15171
- }
15172
-
15173
- .butex-widget .butex-widget__command-sheet-body {
15174
- display: grid;
15175
- gap: 14px;
15176
- min-height: 0;
15177
- min-width: 0;
15178
- overflow-y: auto;
15179
- overscroll-behavior: contain;
15180
- padding: 12px;
15181
- }
15182
-
15183
- .butex-widget .butex-widget__sheet-section {
15184
- display: grid;
15185
- gap: 8px;
15186
- min-width: 0;
15187
- }
15188
-
15189
- .butex-widget .butex-widget__sheet-section h4 {
15190
- font-size: 13px;
15191
- margin: 0;
15192
- }
15193
-
15194
- .butex-widget .butex-widget__sheet-categories,
15195
- .butex-widget .butex-widget__sheet-command-grid,
15196
- .butex-widget .butex-widget__sheet-command-list,
15197
- .butex-widget .butex-widget__sheet-choice-row {
15198
- display: grid;
15199
- gap: 8px;
15200
- min-width: 0;
15201
- }
15202
-
15203
- .butex-widget .butex-widget__sheet-categories,
15204
- .butex-widget .butex-widget__sheet-command-grid {
15205
- grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
15206
- }
15207
-
15208
- .butex-widget .butex-widget__sheet-command-grid--three,
15209
- .butex-widget .butex-widget__sheet-choice-row {
15210
- grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
15211
- }
15212
-
15213
- .butex-widget .butex-widget__sheet-categories button,
15214
- .butex-widget .butex-widget__sheet-command-list button {
15215
- justify-content: flex-start;
15216
- overflow-wrap: anywhere;
15217
- text-align: start;
15218
- }
15219
-
15220
15809
  .butex-widget .butex-widget__command-sheet .operator-command-svg-label {
15221
15810
  background-color: currentColor;
15222
15811
  display: inline-block;
@@ -16121,19 +16710,6 @@ ${MATRIX_PICKER_CSS}
16121
16710
  grid-template-columns: repeat(4, minmax(44px, 1fr));
16122
16711
  }
16123
16712
 
16124
- .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet-backdrop {
16125
- padding-bottom: var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px));
16126
- padding-left: var(--butex-safe-area-left, env(safe-area-inset-left, 0px));
16127
- padding-right: var(--butex-safe-area-right, env(safe-area-inset-right, 0px));
16128
- padding-top: max(8px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)));
16129
- }
16130
-
16131
- .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet {
16132
- border-bottom: 0;
16133
- 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)));
16134
- max-width: none;
16135
- }
16136
-
16137
16713
  .butex-widget:not([data-responsive-mode="desktop"]) .delimiter-command-menu,
16138
16714
  .butex-widget:not([data-responsive-mode="desktop"]) .matrix-command-menu,
16139
16715
  .butex-widget:not([data-responsive-mode="desktop"]) .character-font-menu,
@@ -16182,8 +16758,8 @@ function injectWidgetChromeCss(doc) {
16182
16758
  }
16183
16759
 
16184
16760
  // src/react/EquationMobileToolbar.tsx
16185
- import { useEffect as useEffect8, useId as useId3, useRef as useRef9, useState as useState8 } from "react";
16186
- import { Fragment as Fragment5, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
16761
+ import { useEffect as useEffect8, useId as useId3, useRef as useRef9, useState as useState9 } from "react";
16762
+ import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
16187
16763
  var ACCENT_COMMANDS2 = accentCommandsList();
16188
16764
  var FUNCTION_COMMANDS = atomicCommandsByCategory("function");
16189
16765
  var LIMITS_SERIES_COMMANDS = atomicCommandsByCategory("limits_series");
@@ -16262,13 +16838,13 @@ function functionLabel(command) {
16262
16838
  if (command.id !== "ln") {
16263
16839
  return command.arabicLabel;
16264
16840
  }
16265
- return /* @__PURE__ */ jsxs12("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
16266
- /* @__PURE__ */ jsx13("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
16267
- /* @__PURE__ */ jsx13("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
16841
+ return /* @__PURE__ */ jsxs13("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
16842
+ /* @__PURE__ */ jsx14("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
16843
+ /* @__PURE__ */ jsx14("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
16268
16844
  ] });
16269
16845
  }
16270
16846
  function operatorLabel(command) {
16271
- const label = command.svg_path ? /* @__PURE__ */ jsx13(
16847
+ const label = command.svg_path ? /* @__PURE__ */ jsx14(
16272
16848
  "span",
16273
16849
  {
16274
16850
  className: "operator-command-svg-label",
@@ -16279,7 +16855,7 @@ function operatorLabel(command) {
16279
16855
  }
16280
16856
  }
16281
16857
  ) : command.Label;
16282
- return /* @__PURE__ */ jsx13("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: label });
16858
+ return /* @__PURE__ */ jsx14("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: label });
16283
16859
  }
16284
16860
  function categoryTitle(view, messages) {
16285
16861
  if (view === "delimiters") return messages.insertDelimiters;
@@ -16300,12 +16876,12 @@ function EquationMobileToolbar({
16300
16876
  inputRef,
16301
16877
  getRuntime
16302
16878
  }) {
16303
- const [sheetView, setSheetView] = useState8("closed");
16304
- const [envMode, setEnvMode] = useState8("matrix");
16305
- const [matrixStyle, setMatrixStyle] = useState8("pmatrix");
16306
- const [matrixRows, setMatrixRows] = useState8(2);
16307
- const [matrixColumns, setMatrixColumns] = useState8(2);
16308
- const [alignmentColumn, setAlignmentColumn] = useState8(1);
16879
+ const [sheetView, setSheetView] = useState9("closed");
16880
+ const [envMode, setEnvMode] = useState9("matrix");
16881
+ const [matrixStyle, setMatrixStyle] = useState9("pmatrix");
16882
+ const [matrixRows, setMatrixRows] = useState9(2);
16883
+ const [matrixColumns, setMatrixColumns] = useState9(2);
16884
+ const [alignmentColumn, setAlignmentColumn] = useState9(1);
16309
16885
  const dialogRef = useRef9(null);
16310
16886
  const moreButtonRef = useRef9(null);
16311
16887
  const delimiterButtonRef = useRef9(null);
@@ -16374,413 +16950,321 @@ function EquationMobileToolbar({
16374
16950
  const directButtonMouseDown = (event) => event.preventDefault();
16375
16951
  const undoArrow = state.activeSide === "arabic" ? "\u21B7" : "\u21B6";
16376
16952
  const redoArrow = state.activeSide === "arabic" ? "\u21B6" : "\u21B7";
16377
- const renderFunctionGroup = (label, commands, limits = false, outline = false) => /* @__PURE__ */ jsxs12("section", { className: "butex-widget__sheet-section", children: [
16378
- /* @__PURE__ */ jsx13("h4", { children: label }),
16379
- /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-command-grid", children: commands.map((command) => /* @__PURE__ */ jsx13(
16380
- "button",
16381
- {
16382
- className: `function-command-option${outline ? " function-command-option--outline" : ""}`,
16383
- type: "button",
16384
- title: atomicCommandTitle(command, uiLocale),
16385
- "aria-label": atomicCommandTitle(command, uiLocale),
16386
- onClick: () => runAndClose((runtime) => {
16387
- if (limits) runtime.insertLimitsSeriesTemplate(command.id);
16388
- else runtime.insertAtomicCommand(command.id);
16389
- }),
16390
- children: functionLabel(command)
16391
- },
16392
- command.id
16393
- )) })
16394
- ] }, label);
16395
- return /* @__PURE__ */ jsxs12(Fragment5, { children: [
16396
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__mobile-toolbar", role: "toolbar", "aria-label": messages.compactToolbar, children: [
16397
- /* @__PURE__ */ jsx13("button", { type: "button", disabled: !state.canUndo, title: messages.undo, "aria-label": messages.undo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performUndo(), children: undoArrow }),
16398
- /* @__PURE__ */ jsx13("button", { type: "button", disabled: !state.canRedo, title: messages.redo, "aria-label": messages.redo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performRedo(), children: redoArrow }),
16399
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.insertFraction(), children: /* @__PURE__ */ jsxs12("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
16400
- /* @__PURE__ */ jsx13("span", { children: "\u0623" }),
16401
- /* @__PURE__ */ jsx13("span", { children: "\u0628" })
16953
+ const categoryIcons = {
16954
+ structures: "structure",
16955
+ functions: "functions",
16956
+ operators: "operators",
16957
+ matrices: "matrices",
16958
+ typography: "typography",
16959
+ spacing: "spacing",
16960
+ digits: "digits"
16961
+ };
16962
+ const renderFunctionGroup = (label, commands, limits = false, outline = false) => /* @__PURE__ */ jsx14(MobileSection, { title: label, icon: "functions", children: /* @__PURE__ */ jsx14(MobileGrid, { dense: true, className: "butex-widget__sheet-command-grid butex-mobile-command__math-glyphs", children: commands.map((command) => /* @__PURE__ */ jsx14(
16963
+ "button",
16964
+ {
16965
+ className: `function-command-option${outline ? " function-command-option--outline" : ""}`,
16966
+ type: "button",
16967
+ title: atomicCommandTitle(command, uiLocale),
16968
+ "aria-label": atomicCommandTitle(command, uiLocale),
16969
+ onClick: () => runAndClose((runtime) => {
16970
+ if (limits) runtime.insertLimitsSeriesTemplate(command.id);
16971
+ else runtime.insertAtomicCommand(command.id);
16972
+ }),
16973
+ children: functionLabel(command)
16974
+ },
16975
+ command.id
16976
+ )) }) });
16977
+ return /* @__PURE__ */ jsxs13(Fragment5, { children: [
16978
+ /* @__PURE__ */ jsxs13("div", { className: "butex-widget__mobile-toolbar", role: "toolbar", "aria-label": messages.compactToolbar, children: [
16979
+ /* @__PURE__ */ jsx14("button", { type: "button", disabled: !state.canUndo, title: messages.undo, "aria-label": messages.undo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performUndo(), children: undoArrow }),
16980
+ /* @__PURE__ */ jsx14("button", { type: "button", disabled: !state.canRedo, title: messages.redo, "aria-label": messages.redo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performRedo(), children: redoArrow }),
16981
+ /* @__PURE__ */ jsx14("button", { type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.insertFraction(), children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
16982
+ /* @__PURE__ */ jsx14("span", { children: "\u0623" }),
16983
+ /* @__PURE__ */ jsx14("span", { children: "\u0628" })
16402
16984
  ] }) }),
16403
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSup(), children: /* @__PURE__ */ jsxs12("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
16404
- /* @__PURE__ */ jsx13("span", { children: "\u0646" }),
16405
- /* @__PURE__ */ jsx13("span", { children: "\u0633" })
16985
+ /* @__PURE__ */ jsx14("button", { type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSup(), children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
16986
+ /* @__PURE__ */ jsx14("span", { children: "\u0646" }),
16987
+ /* @__PURE__ */ jsx14("span", { children: "\u0633" })
16406
16988
  ] }) }),
16407
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSub(), children: /* @__PURE__ */ jsxs12("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
16408
- /* @__PURE__ */ jsx13("span", { children: "\u0646" }),
16409
- /* @__PURE__ */ jsx13("span", { children: "\u0633" })
16989
+ /* @__PURE__ */ jsx14("button", { type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSub(), children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
16990
+ /* @__PURE__ */ jsx14("span", { children: "\u0646" }),
16991
+ /* @__PURE__ */ jsx14("span", { children: "\u0633" })
16410
16992
  ] }) }),
16411
- /* @__PURE__ */ jsx13("button", { ref: delimiterButtonRef, type: "button", title: messages.insertDelimiters, "aria-label": messages.insertDelimiters, "aria-haspopup": "dialog", "aria-expanded": sheetView === "delimiters", onClick: openDelimiters, children: "()" }),
16412
- /* @__PURE__ */ jsx13("button", { className: "butex-widget__mobile-danger", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.deleteStructure(), children: "\xD7" }),
16413
- /* @__PURE__ */ jsx13("button", { ref: moreButtonRef, type: "button", title: messages.moreActions, "aria-label": messages.moreActions, "aria-haspopup": "dialog", "aria-expanded": sheetOpen && sheetView !== "delimiters", onClick: openMore, children: "\u22EF" })
16993
+ /* @__PURE__ */ jsx14("button", { ref: delimiterButtonRef, type: "button", title: messages.insertDelimiters, "aria-label": messages.insertDelimiters, "aria-haspopup": "dialog", "aria-expanded": sheetView === "delimiters", onClick: openDelimiters, children: "()" }),
16994
+ /* @__PURE__ */ jsx14("button", { className: "butex-widget__mobile-danger", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.deleteStructure(), children: "\xD7" }),
16995
+ /* @__PURE__ */ jsx14("button", { ref: moreButtonRef, type: "button", title: messages.moreActions, "aria-label": messages.moreActions, "aria-haspopup": "dialog", "aria-expanded": sheetOpen && sheetView !== "delimiters", onClick: openMore, children: "\u22EF" })
16414
16996
  ] }),
16415
- sheetOpen ? /* @__PURE__ */ jsx13(
16416
- "div",
16997
+ sheetOpen ? /* @__PURE__ */ jsxs13(
16998
+ MobileCommandSheet,
16417
16999
  {
16418
- className: "butex-widget__command-sheet-backdrop",
16419
- role: "presentation",
16420
- onClick: (event) => {
16421
- if (event.target === event.currentTarget) dismissSheet();
16422
- },
16423
- children: /* @__PURE__ */ jsxs12(
16424
- "div",
16425
- {
16426
- ref: dialogRef,
16427
- className: "butex-widget__command-sheet",
16428
- role: "dialog",
16429
- "aria-modal": "true",
16430
- "aria-labelledby": sheetTitleId,
16431
- tabIndex: -1,
16432
- children: [
16433
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__command-sheet-header", children: [
16434
- sheetView !== "root" && sheetView !== "delimiters" ? /* @__PURE__ */ jsx13("button", { ref: backButtonRef, type: "button", onClick: () => setSheetView("root"), children: messages.back }) : /* @__PURE__ */ jsx13("span", {}),
16435
- /* @__PURE__ */ jsx13("strong", { id: sheetTitleId, children: categoryTitle(sheetView, messages) }),
16436
- /* @__PURE__ */ jsx13("button", { type: "button", "data-dialog-initial-focus": true, "aria-label": messages.closeActions, onClick: dismissSheet, children: "\xD7" })
16437
- ] }),
16438
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__command-sheet-body", children: [
16439
- sheetView === "root" ? /* @__PURE__ */ jsxs12(Fragment5, { children: [
16440
- showSideSwitcher ? /* @__PURE__ */ jsxs12("section", { className: "butex-widget__sheet-section", children: [
16441
- /* @__PURE__ */ jsx13("h4", { children: messages.activeSide }),
16442
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__sheet-choice-row", children: [
16443
- /* @__PURE__ */ jsx13(
16444
- "button",
16445
- {
16446
- type: "button",
16447
- "aria-pressed": state.activeSide === "arabic",
16448
- onClick: (event) => {
16449
- if (state.activeSide !== "arabic") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
16450
- },
16451
- children: messages.arabicSide
16452
- }
16453
- ),
16454
- /* @__PURE__ */ jsx13(
16455
- "button",
16456
- {
16457
- type: "button",
16458
- "aria-pressed": state.activeSide === "english",
16459
- onClick: (event) => {
16460
- if (state.activeSide !== "english") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
16461
- },
16462
- children: messages.englishSide
16463
- }
16464
- )
16465
- ] })
16466
- ] }) : null,
16467
- /* @__PURE__ */ jsxs12("section", { className: "butex-widget__sheet-section", children: [
16468
- /* @__PURE__ */ jsx13("h4", { children: messages.clipboard }),
16469
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__sheet-choice-row", children: [
16470
- /* @__PURE__ */ jsx13("button", { type: "button", disabled: !state.hasSelection, onClick: () => runAndClose((runtime) => {
16471
- void runtime.performCopy();
16472
- }), children: messages.copy }),
16473
- /* @__PURE__ */ jsx13("button", { type: "button", disabled: !state.hasSelection, onClick: () => runAndClose((runtime) => {
16474
- void runtime.performCut();
16475
- }), children: messages.cut }),
16476
- /* @__PURE__ */ jsx13("button", { type: "button", onClick: () => runAndClose((runtime) => {
16477
- void runtime.performPaste();
16478
- }), children: messages.paste })
16479
- ] })
16480
- ] }),
16481
- /* @__PURE__ */ jsx13("nav", { className: "butex-widget__sheet-categories", "aria-label": messages.commandCategories, children: ["structures", "functions", "operators", "matrices", "typography", "spacing", "digits"].map((view) => /* @__PURE__ */ jsx13("button", { type: "button", onClick: () => setSheetView(view), children: categoryTitle(view, messages) }, view)) })
16482
- ] }) : null,
16483
- sheetView === "delimiters" ? /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three", children: [
16484
- { kind: "paren", label: "()", title: messages.insertParentheses },
16485
- { kind: "bracket", label: "[]", title: messages.insertBrackets },
16486
- { kind: "brace", label: "{}", title: messages.insertBraces },
16487
- { kind: "vert", label: "| |", title: "| |" },
16488
- { kind: "Vert", label: "\u2016 \u2016", title: "\u2016 \u2016" }
16489
- ].map((option) => /* @__PURE__ */ jsx13("button", { type: "button", "aria-label": option.title, title: option.title, onClick: () => runAndClose((runtime) => runtime.insertDelimiterByKind(option.kind)), children: option.label }, option.kind)) }) : null,
16490
- sheetView === "structures" ? /* @__PURE__ */ jsxs12(Fragment5, { children: [
16491
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__sheet-command-grid", children: [
16492
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => runAndClose((runtime) => runtime.insertSqrt()), children: /* @__PURE__ */ jsx13("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
16493
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => runAndClose((runtime) => runtime.insertOverset()), children: /* @__PURE__ */ jsxs12("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
16494
- /* @__PURE__ */ jsx13("span", { children: "\u2217" }),
16495
- /* @__PURE__ */ jsx13("span", { children: "\u25A1" })
16496
- ] }) }),
16497
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => runAndClose((runtime) => runtime.insertUnderset()), children: /* @__PURE__ */ jsxs12("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
16498
- /* @__PURE__ */ jsx13("span", { children: "\u25A1" }),
16499
- /* @__PURE__ */ jsx13("span", { children: "\u2217" })
16500
- ] }) }),
16501
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => runAndClose((runtime) => runtime.insertAccentPair()), children: /* @__PURE__ */ jsxs12("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
16502
- /* @__PURE__ */ jsx13("span", { children: "\u2217" }),
16503
- /* @__PURE__ */ jsx13("span", { children: "\u25A1" }),
16504
- /* @__PURE__ */ jsx13("span", { children: "\u2217" })
16505
- ] }) }),
16506
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runAndClose((runtime) => runtime.removeSup()), children: /* @__PURE__ */ jsxs12("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
16507
- /* @__PURE__ */ jsx13("span", { children: "\xD7" }),
16508
- /* @__PURE__ */ jsx13("span", { children: "\u0646" })
16509
- ] }) }),
16510
- /* @__PURE__ */ jsx13("button", { type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runAndClose((runtime) => runtime.removeSub()), children: /* @__PURE__ */ jsxs12("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
16511
- /* @__PURE__ */ jsx13("span", { children: "\xD7" }),
16512
- /* @__PURE__ */ jsx13("span", { children: "\u0646" })
16513
- ] }) })
16514
- ] }),
16515
- /* @__PURE__ */ jsxs12("section", { className: "butex-widget__sheet-section", children: [
16516
- /* @__PURE__ */ jsx13("h4", { children: messages.insertAccents }),
16517
- /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-command-grid", children: ACCENT_COMMANDS2.map((command) => /* @__PURE__ */ jsx13("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__ */ jsx13("span", { className: "operator-command-label", "aria-hidden": "true", children: command.label }) }, command.id)) })
16518
- ] })
16519
- ] }) : null,
16520
- sheetView === "functions" ? /* @__PURE__ */ jsxs12(Fragment5, { children: [
16521
- renderFunctionGroup(messages.insertFunction, FUNCTION_COMMANDS),
16522
- renderFunctionGroup(messages.insertLimitsSeries, LIMITS_SERIES_COMMANDS, true),
16523
- renderFunctionGroup(messages.insertAdditionalFunctions, FUNCTION2_COMMANDS),
16524
- renderFunctionGroup(messages.insertDerivative, DERIVATIVE_COMMANDS),
16525
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__sheet-command-grid", children: [
16526
- /* @__PURE__ */ jsx13("button", { className: "function-command-option", type: "button", title: messages.insertFirstDerivative, "aria-label": messages.insertFirstDerivative, onClick: () => runAndClose((runtime) => runtime.insertFirstDerivative()), children: "\u0621/\u0633" }),
16527
- /* @__PURE__ */ jsx13("button", { className: "function-command-option", type: "button", title: messages.insertSecondDerivative, "aria-label": messages.insertSecondDerivative, onClick: () => runAndClose((runtime) => runtime.insertSecondDerivative()), children: "\u0621\xB2/\u0633\xB2" })
16528
- ] }),
16529
- renderFunctionGroup(messages.insertNumberSets, GROUP_COMMANDS, false, true)
16530
- ] }) : null,
16531
- sheetView === "operators" ? OPERATOR_GROUPS.map((commands, index) => /* @__PURE__ */ jsx13("section", { className: "butex-widget__sheet-section", children: /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-command-grid", children: commands.map((command) => /* @__PURE__ */ jsx13("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,
16532
- sheetView === "matrices" ? /* @__PURE__ */ jsxs12("div", { className: "butex-widget__mobile-matrix-picker", children: [
16533
- /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.environmentType, children: [
16534
- { id: "matrix", label: messages.matrix },
16535
- { id: "array", label: messages.array },
16536
- { id: "aligned", label: messages.aligned },
16537
- { id: "cases", label: messages.piecewise }
16538
- ].map((option) => /* @__PURE__ */ jsx13(
16539
- "button",
16540
- {
16541
- type: "button",
16542
- "aria-pressed": envMode === option.id,
16543
- onClick: () => {
16544
- setEnvMode(option.id);
16545
- if (option.id === "aligned" || option.id === "cases") setMatrixColumns(2);
16546
- },
16547
- children: option.label
16548
- },
16549
- option.id
16550
- )) }),
16551
- envMode === "matrix" ? /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ jsx13("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,
16552
- /* @__PURE__ */ jsxs12("section", { className: "butex-widget__sheet-section", children: [
16553
- /* @__PURE__ */ jsx13("h4", { children: messages.commonMatrixSizes }),
16554
- /* @__PURE__ */ jsx13("div", { className: "butex-widget__matrix-presets", children: (envMode === "aligned" || envMode === "cases" ? MATRIX_PRESETS.filter((preset) => preset.columns === 2) : MATRIX_PRESETS).map((preset) => /* @__PURE__ */ jsxs12(
16555
- "button",
16556
- {
16557
- type: "button",
16558
- "aria-pressed": matrixRows === preset.rows && matrixColumns === preset.columns,
16559
- onClick: () => {
16560
- setMatrixRows(preset.rows);
16561
- setMatrixColumns(envMode === "aligned" || envMode === "cases" ? 2 : preset.columns);
16562
- },
16563
- children: [
16564
- preset.rows,
16565
- "\xD7",
16566
- envMode === "aligned" || envMode === "cases" ? 2 : preset.columns
16567
- ]
16568
- },
16569
- `${String(preset.rows)}-${String(preset.columns)}`
16570
- )) })
16571
- ] }),
16572
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__matrix-stepper-row", children: [
16573
- /* @__PURE__ */ jsx13("span", { children: messages.rows }),
16574
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__matrix-stepper", children: [
16575
- /* @__PURE__ */ jsx13("button", { type: "button", disabled: matrixRows <= 1, "aria-label": messages.decreaseRows, onClick: () => setMatrixDimension("rows", matrixRows - 1), children: "\u2212" }),
16576
- /* @__PURE__ */ jsx13("output", { "aria-live": "polite", children: matrixRows }),
16577
- /* @__PURE__ */ jsx13("button", { type: "button", disabled: matrixRows >= 12, "aria-label": messages.increaseRows, onClick: () => setMatrixDimension("rows", matrixRows + 1), children: "+" })
16578
- ] })
16579
- ] }),
16580
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__matrix-stepper-row", children: [
16581
- /* @__PURE__ */ jsx13("span", { children: messages.columns }),
16582
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__matrix-stepper", children: [
16583
- /* @__PURE__ */ jsx13("button", { type: "button", disabled: matrixColumns <= 1 || envMode === "aligned" || envMode === "cases", "aria-label": messages.decreaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns - 1), children: "\u2212" }),
16584
- /* @__PURE__ */ jsx13("output", { "aria-live": "polite", children: envMode === "aligned" || envMode === "cases" ? 2 : matrixColumns }),
16585
- /* @__PURE__ */ jsx13("button", { type: "button", disabled: matrixColumns >= 12 || envMode === "aligned" || envMode === "cases", "aria-label": messages.increaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns + 1), children: "+" })
16586
- ] })
16587
- ] }),
16588
- /* @__PURE__ */ jsx13("p", { className: "butex-widget__matrix-size-summary", "aria-live": "polite", children: matrixSizeLabel(matrixRows, envMode === "aligned" || envMode === "cases" ? 2 : matrixColumns, messages) }),
16589
- /* @__PURE__ */ jsx13("button", { type: "button", className: "butex-widget__matrix-insert", onClick: insertEnvironment, children: messages.insert }),
16590
- /* @__PURE__ */ jsxs12("section", { className: "butex-widget__sheet-section", children: [
16591
- /* @__PURE__ */ jsx13("h4", { children: messages.editSelectedEnvironment }),
16592
- envMode === "matrix" ? /* @__PURE__ */ jsx13("button", { type: "button", onClick: () => getRuntime()?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
16593
- envMode === "array" ? /* @__PURE__ */ jsxs12("div", { className: "butex-widget__matrix-alignment", children: [
16594
- /* @__PURE__ */ jsxs12("label", { children: [
16595
- messages.column,
16596
- /* @__PURE__ */ jsx13("input", { type: "number", min: 1, max: 12, value: alignmentColumn, onChange: (event) => setAlignmentColumn(clampMatrixSize(Number(event.currentTarget.value) || 1)) })
16597
- ] }),
16598
- ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ jsx13("button", { type: "button", title: alignmentTitle(alignment, messages), onClick: () => getRuntime()?.setArrayColumnAlignment(alignmentColumn - 1, alignment), children: alignmentLabel(alignment, messages) }, alignment))
16599
- ] }) : null,
16600
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__sheet-command-grid", children: [
16601
- /* @__PURE__ */ jsxs12("button", { type: "button", onClick: () => getRuntime()?.addMatrixRow(), children: [
16602
- "+",
16603
- messages.row
16604
- ] }),
16605
- /* @__PURE__ */ jsxs12("button", { type: "button", onClick: () => getRuntime()?.removeMatrixRow(), children: [
16606
- "\u2212",
16607
- messages.row
16608
- ] }),
16609
- /* @__PURE__ */ jsxs12("button", { type: "button", disabled: envMode === "cases", onClick: () => getRuntime()?.addMatrixColumn(), children: [
16610
- "+",
16611
- messages.column
16612
- ] }),
16613
- /* @__PURE__ */ jsxs12("button", { type: "button", disabled: envMode === "cases", onClick: () => getRuntime()?.removeMatrixColumn(), children: [
16614
- "\u2212",
16615
- messages.column
16616
- ] })
16617
- ] })
16618
- ] })
16619
- ] }) : null,
16620
- sheetView === "typography" ? /* @__PURE__ */ jsxs12(Fragment5, { children: [
16621
- /* @__PURE__ */ jsxs12("section", { className: "butex-widget__sheet-section", children: [
16622
- /* @__PURE__ */ jsx13("h4", { children: messages.chooseWritingFont }),
16623
- /* @__PURE__ */ jsxs12("div", { className: "butex-widget__sheet-choice-row", children: [
16624
- /* @__PURE__ */ jsx13(
16625
- "button",
16626
- {
16627
- type: "button",
16628
- className: "character-font-option--bold",
16629
- "aria-pressed": state.boldCharacterStyle,
16630
- title: boldCharacterStyleLabel(uiLocale),
16631
- onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentBoldCharacterStyle()),
16632
- children: boldCharacterStyleLabel(uiLocale)
16633
- }
16634
- ),
16635
- CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx13(
16636
- "button",
16637
- {
16638
- type: "button",
16639
- className: `character-font-option--${option.id}`,
16640
- "aria-pressed": !state.boldCharacterStyle && state.characterFont === option.id,
16641
- title: characterFontTitle(option.id, messages),
16642
- onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
16643
- children: option.label
16644
- },
16645
- option.id
16646
- ))
16647
- ] })
16648
- ] }),
16649
- /* @__PURE__ */ jsx13(
16650
- "button",
16651
- {
16652
- className: "ligature-btn butex-widget__compact-ligature",
16653
- type: "button",
16654
- title: !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
16655
- "aria-label": !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
16656
- "aria-pressed": !state.splitLeafTyping,
16657
- onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSplitLeafTyping()),
16658
- children: !state.splitLeafTyping ? "\u0633\u0635\u0639" : "\u0633 \u0635 \u0639"
16659
- }
16660
- )
16661
- ] }) : null,
16662
- sheetView === "spacing" ? /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-command-list", children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ jsx13("button", { type: "button", title: atomicCommandTitle(command, uiLocale), "aria-label": atomicCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAtomicCommand(command.id)), children: /* @__PURE__ */ jsxs12(
16663
- "span",
17000
+ scope: "butex-widget",
17001
+ sourceRef: moreButtonRef,
17002
+ dialogRef,
17003
+ titleId: sheetTitleId,
17004
+ title: categoryTitle(sheetView, messages),
17005
+ closeLabel: messages.closeActions,
17006
+ onClose: dismissSheet,
17007
+ backRef: backButtonRef,
17008
+ backLabel: messages.back,
17009
+ onBack: sheetView !== "root" && sheetView !== "delimiters" ? () => setSheetView("root") : void 0,
17010
+ children: [
17011
+ sheetView === "root" ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
17012
+ showSideSwitcher ? /* @__PURE__ */ jsx14(MobileSection, { title: messages.activeSide, icon: "typography", children: /* @__PURE__ */ jsxs13("div", { className: "butex-mobile-command__choice-row", children: [
17013
+ /* @__PURE__ */ jsx14(
17014
+ "button",
17015
+ {
17016
+ type: "button",
17017
+ className: "butex-mobile-command__choice",
17018
+ "aria-pressed": state.activeSide === "arabic",
17019
+ onClick: (event) => {
17020
+ if (state.activeSide !== "arabic") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
17021
+ },
17022
+ children: messages.arabicSide
17023
+ }
17024
+ ),
17025
+ /* @__PURE__ */ jsx14(
17026
+ "button",
17027
+ {
17028
+ type: "button",
17029
+ className: "butex-mobile-command__choice",
17030
+ "aria-pressed": state.activeSide === "english",
17031
+ onClick: (event) => {
17032
+ if (state.activeSide !== "english") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
17033
+ },
17034
+ children: messages.englishSide
17035
+ }
17036
+ )
17037
+ ] }) }) : null,
17038
+ /* @__PURE__ */ jsx14(MobileSection, { title: messages.clipboard, icon: "copy", children: /* @__PURE__ */ jsxs13(MobileGrid, { children: [
17039
+ /* @__PURE__ */ jsx14(MobileAction, { command: {
17040
+ id: "copy",
17041
+ label: messages.copy,
17042
+ icon: "copy",
17043
+ disabled: !state.hasSelection,
17044
+ onSelect: () => runAndClose((runtime) => {
17045
+ void runtime.performCopy();
17046
+ })
17047
+ } }),
17048
+ /* @__PURE__ */ jsx14(MobileAction, { command: {
17049
+ id: "cut",
17050
+ label: messages.cut,
17051
+ icon: "cut",
17052
+ disabled: !state.hasSelection,
17053
+ onSelect: () => runAndClose((runtime) => {
17054
+ void runtime.performCut();
17055
+ })
17056
+ } }),
17057
+ /* @__PURE__ */ jsx14(MobileAction, { command: {
17058
+ id: "paste",
17059
+ label: messages.paste,
17060
+ icon: "paste",
17061
+ onSelect: () => runAndClose((runtime) => {
17062
+ void runtime.performPaste();
17063
+ })
17064
+ } })
17065
+ ] }) }),
17066
+ /* @__PURE__ */ jsx14("nav", { "aria-label": messages.commandCategories, children: /* @__PURE__ */ jsx14(MobileGrid, { children: ["structures", "functions", "operators", "matrices", "typography", "spacing", "digits"].map((view) => /* @__PURE__ */ jsx14(
17067
+ MobileCategory,
17068
+ {
17069
+ label: categoryTitle(view, messages),
17070
+ icon: categoryIcons[view],
17071
+ onClick: () => setSheetView(view)
17072
+ },
17073
+ view
17074
+ )) }) })
17075
+ ] }) : null,
17076
+ sheetView === "delimiters" ? /* @__PURE__ */ jsx14("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three butex-mobile-command__math-glyphs", children: [
17077
+ { kind: "paren", label: "()", title: messages.insertParentheses },
17078
+ { kind: "bracket", label: "[]", title: messages.insertBrackets },
17079
+ { kind: "brace", label: "{}", title: messages.insertBraces },
17080
+ { kind: "vert", label: "| |", title: "| |" },
17081
+ { kind: "Vert", label: "\u2016 \u2016", title: "\u2016 \u2016" }
17082
+ ].map((option) => /* @__PURE__ */ jsx14("button", { type: "button", "aria-label": option.title, title: option.title, onClick: () => runAndClose((runtime) => runtime.insertDelimiterByKind(option.kind)), children: option.label }, option.kind)) }) : null,
17083
+ sheetView === "structures" ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
17084
+ /* @__PURE__ */ jsxs13(MobileGrid, { children: [
17085
+ /* @__PURE__ */ jsx14(MobileAction, { command: { id: "sqrt", label: messages.insertRoot, icon: "math", onSelect: () => runAndClose((runtime) => runtime.insertSqrt()) } }),
17086
+ /* @__PURE__ */ jsx14(MobileAction, { command: { id: "over", label: messages.insertOverset, icon: "structure", onSelect: () => runAndClose((runtime) => runtime.insertOverset()) } }),
17087
+ /* @__PURE__ */ jsx14(MobileAction, { command: { id: "under", label: messages.insertUnderset, icon: "structure", onSelect: () => runAndClose((runtime) => runtime.insertUnderset()) } }),
17088
+ /* @__PURE__ */ jsx14(MobileAction, { command: { id: "pair", label: messages.insertAccentPair, icon: "structure", onSelect: () => runAndClose((runtime) => runtime.insertAccentPair()) } }),
17089
+ /* @__PURE__ */ jsx14(MobileAction, { command: { id: "removeSup", label: messages.removeSuperscript, icon: "trash", onSelect: () => runAndClose((runtime) => runtime.removeSup()) } }),
17090
+ /* @__PURE__ */ jsx14(MobileAction, { command: { id: "removeSub", label: messages.removeSubscript, icon: "trash", onSelect: () => runAndClose((runtime) => runtime.removeSub()) } })
17091
+ ] }),
17092
+ /* @__PURE__ */ jsxs13("section", { className: "butex-widget__sheet-section", children: [
17093
+ /* @__PURE__ */ jsx14("h4", { children: messages.insertAccents }),
17094
+ /* @__PURE__ */ jsx14("div", { className: "butex-widget__sheet-command-grid butex-mobile-command__math-glyphs", children: ACCENT_COMMANDS2.map((command) => /* @__PURE__ */ jsx14("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__ */ jsx14("span", { className: "operator-command-label", "aria-hidden": "true", children: command.label }) }, command.id)) })
17095
+ ] })
17096
+ ] }) : null,
17097
+ sheetView === "functions" ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
17098
+ renderFunctionGroup(messages.insertFunction, FUNCTION_COMMANDS),
17099
+ renderFunctionGroup(messages.insertLimitsSeries, LIMITS_SERIES_COMMANDS, true),
17100
+ renderFunctionGroup(messages.insertAdditionalFunctions, FUNCTION2_COMMANDS),
17101
+ renderFunctionGroup(messages.insertDerivative, DERIVATIVE_COMMANDS),
17102
+ /* @__PURE__ */ jsxs13("div", { className: "butex-widget__sheet-command-grid butex-mobile-command__math-glyphs", children: [
17103
+ /* @__PURE__ */ jsx14("button", { className: "function-command-option", type: "button", title: messages.insertFirstDerivative, "aria-label": messages.insertFirstDerivative, onClick: () => runAndClose((runtime) => runtime.insertFirstDerivative()), children: "\u0621/\u0633" }),
17104
+ /* @__PURE__ */ jsx14("button", { className: "function-command-option", type: "button", title: messages.insertSecondDerivative, "aria-label": messages.insertSecondDerivative, onClick: () => runAndClose((runtime) => runtime.insertSecondDerivative()), children: "\u0621\xB2/\u0633\xB2" })
17105
+ ] }),
17106
+ renderFunctionGroup(messages.insertNumberSets, GROUP_COMMANDS, false, true)
17107
+ ] }) : null,
17108
+ sheetView === "operators" ? OPERATOR_GROUPS.map((commands, index) => /* @__PURE__ */ jsx14("section", { className: "butex-widget__sheet-section", children: /* @__PURE__ */ jsx14("div", { className: "butex-widget__sheet-command-grid butex-mobile-command__math-glyphs", children: commands.map((command) => /* @__PURE__ */ jsx14("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,
17109
+ sheetView === "matrices" ? /* @__PURE__ */ jsxs13("div", { className: "butex-widget__mobile-matrix-picker", children: [
17110
+ /* @__PURE__ */ jsx14("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.environmentType, children: [
17111
+ { id: "matrix", label: messages.matrix },
17112
+ { id: "array", label: messages.array },
17113
+ { id: "aligned", label: messages.aligned },
17114
+ { id: "cases", label: messages.piecewise }
17115
+ ].map((option) => /* @__PURE__ */ jsx14(
17116
+ "button",
17117
+ {
17118
+ type: "button",
17119
+ "aria-pressed": envMode === option.id,
17120
+ onClick: () => {
17121
+ setEnvMode(option.id);
17122
+ if (option.id === "aligned" || option.id === "cases") setMatrixColumns(2);
17123
+ },
17124
+ children: option.label
17125
+ },
17126
+ option.id
17127
+ )) }),
17128
+ envMode === "matrix" ? /* @__PURE__ */ jsx14("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ jsx14("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,
17129
+ /* @__PURE__ */ jsxs13("section", { className: "butex-widget__sheet-section", children: [
17130
+ /* @__PURE__ */ jsx14("h4", { children: messages.commonMatrixSizes }),
17131
+ /* @__PURE__ */ jsx14("div", { className: "butex-widget__matrix-presets", children: (envMode === "aligned" || envMode === "cases" ? MATRIX_PRESETS.filter((preset) => preset.columns === 2) : MATRIX_PRESETS).map((preset) => /* @__PURE__ */ jsxs13(
17132
+ "button",
17133
+ {
17134
+ type: "button",
17135
+ "aria-pressed": matrixRows === preset.rows && matrixColumns === preset.columns,
17136
+ onClick: () => {
17137
+ setMatrixRows(preset.rows);
17138
+ setMatrixColumns(envMode === "aligned" || envMode === "cases" ? 2 : preset.columns);
17139
+ },
17140
+ children: [
17141
+ preset.rows,
17142
+ "\xD7",
17143
+ envMode === "aligned" || envMode === "cases" ? 2 : preset.columns
17144
+ ]
17145
+ },
17146
+ `${String(preset.rows)}-${String(preset.columns)}`
17147
+ )) })
17148
+ ] }),
17149
+ /* @__PURE__ */ jsxs13("div", { className: "butex-widget__matrix-stepper-row", children: [
17150
+ /* @__PURE__ */ jsx14("span", { children: messages.rows }),
17151
+ /* @__PURE__ */ jsxs13("div", { className: "butex-widget__matrix-stepper", children: [
17152
+ /* @__PURE__ */ jsx14("button", { type: "button", disabled: matrixRows <= 1, "aria-label": messages.decreaseRows, onClick: () => setMatrixDimension("rows", matrixRows - 1), children: "\u2212" }),
17153
+ /* @__PURE__ */ jsx14("output", { "aria-live": "polite", children: matrixRows }),
17154
+ /* @__PURE__ */ jsx14("button", { type: "button", disabled: matrixRows >= 12, "aria-label": messages.increaseRows, onClick: () => setMatrixDimension("rows", matrixRows + 1), children: "+" })
17155
+ ] })
17156
+ ] }),
17157
+ /* @__PURE__ */ jsxs13("div", { className: "butex-widget__matrix-stepper-row", children: [
17158
+ /* @__PURE__ */ jsx14("span", { children: messages.columns }),
17159
+ /* @__PURE__ */ jsxs13("div", { className: "butex-widget__matrix-stepper", children: [
17160
+ /* @__PURE__ */ jsx14("button", { type: "button", disabled: matrixColumns <= 1 || envMode === "aligned" || envMode === "cases", "aria-label": messages.decreaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns - 1), children: "\u2212" }),
17161
+ /* @__PURE__ */ jsx14("output", { "aria-live": "polite", children: envMode === "aligned" || envMode === "cases" ? 2 : matrixColumns }),
17162
+ /* @__PURE__ */ jsx14("button", { type: "button", disabled: matrixColumns >= 12 || envMode === "aligned" || envMode === "cases", "aria-label": messages.increaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns + 1), children: "+" })
17163
+ ] })
17164
+ ] }),
17165
+ /* @__PURE__ */ jsx14("p", { className: "butex-widget__matrix-size-summary", "aria-live": "polite", children: matrixSizeLabel(matrixRows, envMode === "aligned" || envMode === "cases" ? 2 : matrixColumns, messages) }),
17166
+ /* @__PURE__ */ jsx14("button", { type: "button", className: "butex-widget__matrix-insert", onClick: insertEnvironment, children: messages.insert }),
17167
+ /* @__PURE__ */ jsxs13("section", { className: "butex-widget__sheet-section", children: [
17168
+ /* @__PURE__ */ jsx14("h4", { children: messages.editSelectedEnvironment }),
17169
+ envMode === "matrix" ? /* @__PURE__ */ jsx14("button", { type: "button", onClick: () => getRuntime()?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
17170
+ envMode === "array" ? /* @__PURE__ */ jsxs13("div", { className: "butex-widget__matrix-alignment", children: [
17171
+ /* @__PURE__ */ jsxs13("label", { children: [
17172
+ messages.column,
17173
+ /* @__PURE__ */ jsx14("input", { type: "number", min: 1, max: 12, value: alignmentColumn, onChange: (event) => setAlignmentColumn(clampMatrixSize(Number(event.currentTarget.value) || 1)) })
17174
+ ] }),
17175
+ ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ jsx14("button", { type: "button", title: alignmentTitle(alignment, messages), onClick: () => getRuntime()?.setArrayColumnAlignment(alignmentColumn - 1, alignment), children: alignmentLabel(alignment, messages) }, alignment))
17176
+ ] }) : null,
17177
+ /* @__PURE__ */ jsxs13("div", { className: "butex-widget__sheet-command-grid butex-mobile-command__math-glyphs", children: [
17178
+ /* @__PURE__ */ jsxs13("button", { type: "button", onClick: () => getRuntime()?.addMatrixRow(), children: [
17179
+ "+",
17180
+ messages.row
17181
+ ] }),
17182
+ /* @__PURE__ */ jsxs13("button", { type: "button", onClick: () => getRuntime()?.removeMatrixRow(), children: [
17183
+ "\u2212",
17184
+ messages.row
17185
+ ] }),
17186
+ /* @__PURE__ */ jsxs13("button", { type: "button", disabled: envMode === "cases", onClick: () => getRuntime()?.addMatrixColumn(), children: [
17187
+ "+",
17188
+ messages.column
17189
+ ] }),
17190
+ /* @__PURE__ */ jsxs13("button", { type: "button", disabled: envMode === "cases", onClick: () => getRuntime()?.removeMatrixColumn(), children: [
17191
+ "\u2212",
17192
+ messages.column
17193
+ ] })
17194
+ ] })
17195
+ ] })
17196
+ ] }) : null,
17197
+ sheetView === "typography" ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
17198
+ /* @__PURE__ */ jsxs13("section", { className: "butex-widget__sheet-section", children: [
17199
+ /* @__PURE__ */ jsx14("h4", { children: messages.chooseWritingFont }),
17200
+ /* @__PURE__ */ jsxs13("div", { className: "butex-widget__sheet-choice-row", children: [
17201
+ /* @__PURE__ */ jsx14(
17202
+ "button",
16664
17203
  {
16665
- className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`,
16666
- "aria-hidden": "true",
16667
- children: [
16668
- command.spacing.direction === "negative" ? /* @__PURE__ */ jsx13("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null,
16669
- /* @__PURE__ */ jsx13("span", { className: "spacing-command-glyph__bar" }),
16670
- command.spacing.direction === "positive" ? /* @__PURE__ */ jsx13("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null
16671
- ]
17204
+ type: "button",
17205
+ className: "character-font-option--bold",
17206
+ "aria-pressed": state.boldCharacterStyle,
17207
+ title: boldCharacterStyleLabel(uiLocale),
17208
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentBoldCharacterStyle()),
17209
+ children: boldCharacterStyleLabel(uiLocale)
16672
17210
  }
16673
- ) }, command.id)) }) : null,
16674
- sheetView === "digits" ? /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-choice-row", children: [
16675
- { id: "western", label: "456" },
16676
- { id: "arabicIndic", label: "\u0664\u0665\u0666" },
16677
- { id: "persianIndic", label: "\u06F4\u06F5\u06F6" }
16678
- ].map((option) => /* @__PURE__ */ jsx13(
17211
+ ),
17212
+ CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx14(
16679
17213
  "button",
16680
17214
  {
16681
17215
  type: "button",
16682
- "aria-pressed": state.digitForm === option.id,
16683
- title: digitTitle(option.id, messages),
16684
- onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentDigitForm(option.id)),
17216
+ className: `character-font-option--${option.id}`,
17217
+ "aria-pressed": !state.boldCharacterStyle && state.characterFont === option.id,
17218
+ title: characterFontTitle(option.id, messages),
17219
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
16685
17220
  children: option.label
16686
17221
  },
16687
17222
  option.id
16688
- )) }) : null
17223
+ ))
16689
17224
  ] })
16690
- ]
16691
- }
16692
- )
17225
+ ] }),
17226
+ /* @__PURE__ */ jsx14(
17227
+ "button",
17228
+ {
17229
+ className: "ligature-btn butex-widget__compact-ligature",
17230
+ type: "button",
17231
+ title: !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
17232
+ "aria-label": !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
17233
+ "aria-pressed": !state.splitLeafTyping,
17234
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSplitLeafTyping()),
17235
+ children: !state.splitLeafTyping ? "\u0633\u0635\u0639" : "\u0633 \u0635 \u0639"
17236
+ }
17237
+ )
17238
+ ] }) : null,
17239
+ sheetView === "spacing" ? /* @__PURE__ */ jsx14("div", { className: "butex-widget__sheet-command-list", children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ jsx14("button", { type: "button", title: atomicCommandTitle(command, uiLocale), "aria-label": atomicCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAtomicCommand(command.id)), children: /* @__PURE__ */ jsxs13(
17240
+ "span",
17241
+ {
17242
+ className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`,
17243
+ "aria-hidden": "true",
17244
+ children: [
17245
+ command.spacing.direction === "negative" ? /* @__PURE__ */ jsx14("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null,
17246
+ /* @__PURE__ */ jsx14("span", { className: "spacing-command-glyph__bar" }),
17247
+ command.spacing.direction === "positive" ? /* @__PURE__ */ jsx14("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null
17248
+ ]
17249
+ }
17250
+ ) }, command.id)) }) : null,
17251
+ sheetView === "digits" ? /* @__PURE__ */ jsx14("div", { className: "butex-widget__sheet-choice-row", children: MOBILE_DIGIT_CHOICES.map((option) => /* @__PURE__ */ jsx14(
17252
+ "button",
17253
+ {
17254
+ type: "button",
17255
+ "aria-pressed": state.digitForm === option.id,
17256
+ title: digitTitle(option.id, messages),
17257
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentDigitForm(option.id)),
17258
+ children: option.label
17259
+ },
17260
+ option.id
17261
+ )) }) : null
17262
+ ]
16693
17263
  }
16694
17264
  ) : null
16695
17265
  ] });
16696
17266
  }
16697
17267
 
16698
- // src/react/visibleViewport.ts
16699
- function positiveFinite(value, fallback) {
16700
- return Number.isFinite(value) && value > 0 ? value : fallback;
16701
- }
16702
- function finiteOffset(value) {
16703
- return Number.isFinite(value) ? value : 0;
16704
- }
16705
- function visibleViewportSnapshot(view) {
16706
- const fallbackWidth = positiveFinite(view.innerWidth, 1);
16707
- const fallbackHeight = positiveFinite(view.innerHeight, 1);
16708
- const visualViewport = view.visualViewport;
16709
- if (visualViewport && Number.isFinite(visualViewport.width) && visualViewport.width > 0 && Number.isFinite(visualViewport.height) && visualViewport.height > 0) {
16710
- return {
16711
- width: visualViewport.width,
16712
- height: visualViewport.height,
16713
- offsetLeft: finiteOffset(visualViewport.offsetLeft),
16714
- offsetTop: finiteOffset(visualViewport.offsetTop),
16715
- scale: positiveFinite(visualViewport.scale, 1),
16716
- source: "visual-viewport"
16717
- };
16718
- }
16719
- return {
16720
- width: fallbackWidth,
16721
- height: fallbackHeight,
16722
- offsetLeft: 0,
16723
- offsetTop: 0,
16724
- scale: 1,
16725
- source: "layout-viewport"
16726
- };
16727
- }
16728
- function reasonPriority(reason) {
16729
- if (reason === "orientation") return 3;
16730
- if (reason === "resize") return 2;
16731
- if (reason === "scroll") return 1;
16732
- return 0;
16733
- }
16734
- function observeVisibleViewport(view, onChange) {
16735
- let previous = visibleViewportSnapshot(view);
16736
- let frame = null;
16737
- let pendingReason = "scroll";
16738
- onChange({
16739
- snapshot: previous,
16740
- initial: true,
16741
- sizeChanged: false,
16742
- offsetChanged: false,
16743
- reason: "initial"
16744
- });
16745
- const emit = () => {
16746
- frame = null;
16747
- const next = visibleViewportSnapshot(view);
16748
- const sizeChanged = next.width !== previous.width || next.height !== previous.height || next.scale !== previous.scale || next.source !== previous.source;
16749
- const offsetChanged = next.offsetLeft !== previous.offsetLeft || next.offsetTop !== previous.offsetTop;
16750
- const reason = pendingReason;
16751
- pendingReason = "scroll";
16752
- previous = next;
16753
- onChange({ snapshot: next, initial: false, sizeChanged, offsetChanged, reason });
16754
- };
16755
- const schedule = (reason) => {
16756
- if (reasonPriority(reason) > reasonPriority(pendingReason)) {
16757
- pendingReason = reason;
16758
- }
16759
- if (frame !== null) {
16760
- return;
16761
- }
16762
- frame = view.requestAnimationFrame(emit);
16763
- };
16764
- const onResize = () => schedule("resize");
16765
- const onScroll = () => schedule("scroll");
16766
- const onOrientation = () => schedule("orientation");
16767
- const visualViewport = view.visualViewport;
16768
- visualViewport?.addEventListener("resize", onResize);
16769
- visualViewport?.addEventListener("scroll", onScroll);
16770
- view.addEventListener("resize", onResize);
16771
- view.addEventListener("orientationchange", onOrientation);
16772
- return () => {
16773
- visualViewport?.removeEventListener("resize", onResize);
16774
- visualViewport?.removeEventListener("scroll", onScroll);
16775
- view.removeEventListener("resize", onResize);
16776
- view.removeEventListener("orientationchange", onOrientation);
16777
- if (frame !== null) {
16778
- view.cancelAnimationFrame(frame);
16779
- frame = null;
16780
- }
16781
- };
16782
- }
16783
-
16784
17268
  // src/react/desktopPopover.ts
16785
17269
  import { useEffect as useEffect9 } from "react";
16786
17270
  var POPOVER_GAP = 5;
@@ -16921,7 +17405,7 @@ function useDesktopPopoverPlacement(rootRef, active, onClose) {
16921
17405
  }
16922
17406
 
16923
17407
  // src/react/ButexEditor.tsx
16924
- import { Fragment as Fragment6, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
17408
+ import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
16925
17409
  var DIGIT_FORM_OPTIONS = [
16926
17410
  { id: "western", label: "456" },
16927
17411
  { id: "arabicIndic", label: "\u0664\u0665\u0666" },
@@ -16958,7 +17442,7 @@ function matrixSizeLabel2(rows, columns, messages) {
16958
17442
  function clampMatrixSize2(value) {
16959
17443
  return Math.max(1, Math.min(12, Math.trunc(value)));
16960
17444
  }
16961
- function digitFormLabel3(digitForm) {
17445
+ function digitFormLabel2(digitForm) {
16962
17446
  return DIGIT_FORM_OPTIONS.find((option) => option.id === digitForm)?.label ?? "456";
16963
17447
  }
16964
17448
  function characterFontOption(fontId) {
@@ -17000,16 +17484,16 @@ function renderArabicCommandLabel(command) {
17000
17484
  if (command.id !== "ln") {
17001
17485
  return command.arabicLabel;
17002
17486
  }
17003
- return /* @__PURE__ */ jsxs13("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
17004
- /* @__PURE__ */ jsx14("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
17005
- /* @__PURE__ */ jsx14("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
17487
+ return /* @__PURE__ */ jsxs14("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
17488
+ /* @__PURE__ */ jsx15("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
17489
+ /* @__PURE__ */ jsx15("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
17006
17490
  ] });
17007
17491
  }
17008
17492
  function renderOperatorCommandLabel(command) {
17009
17493
  if (!command.svg_path) {
17010
17494
  return command.Label;
17011
17495
  }
17012
- return /* @__PURE__ */ jsx14(
17496
+ return /* @__PURE__ */ jsx15(
17013
17497
  "span",
17014
17498
  {
17015
17499
  className: "operator-command-svg-label",
@@ -17025,7 +17509,7 @@ function renderOperatorMenuButtonLabel(command, fallback) {
17025
17509
  if (!command) {
17026
17510
  return fallback;
17027
17511
  }
17028
- return /* @__PURE__ */ jsx14("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
17512
+ return /* @__PURE__ */ jsx15("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
17029
17513
  }
17030
17514
  function passiveTreeText(session, messages) {
17031
17515
  const passive = session.activeSide === "arabic" ? session.englishTree : session.arabicTree;
@@ -17063,29 +17547,29 @@ var ButexEditor = forwardRef(
17063
17547
  const onSessionChangeRef = useRef10(onSessionChange);
17064
17548
  onSessionChangeRef.current = onSessionChange;
17065
17549
  const debugBodyHiddenRef = useRef10(false);
17066
- const [debugBodyHidden, setDebugBodyHidden] = useState9(false);
17550
+ const [debugBodyHidden, setDebugBodyHidden] = useState10(false);
17067
17551
  debugBodyHiddenRef.current = debugBodyHidden;
17068
- const [debugImportOpen, setDebugImportOpen] = useState9(false);
17069
- const [debugImportText, setDebugImportText] = useState9("");
17070
- const [debugImportError, setDebugImportError] = useState9("");
17071
- const [openDesktopMenu, setOpenDesktopMenu] = useState9(null);
17072
- const [selectedDigitForm2, setSelectedDigitForm] = useState9("western");
17073
- const [selectedCharacterFont, setSelectedCharacterFont] = useState9("default");
17074
- const [boldCharacterStyle, setBoldCharacterStyle] = useState9(initialSession?.currentCharacterWrapper === "\\boldarabic");
17075
- const [activeEditorSide, setActiveEditorSide] = useState9("arabic");
17076
- const [compactPreviewOpen, setCompactPreviewOpen] = useState9(false);
17077
- const [compactControlState, setCompactControlState] = useState9({
17552
+ const [debugImportOpen, setDebugImportOpen] = useState10(false);
17553
+ const [debugImportText, setDebugImportText] = useState10("");
17554
+ const [debugImportError, setDebugImportError] = useState10("");
17555
+ const [openDesktopMenu, setOpenDesktopMenu] = useState10(null);
17556
+ const [selectedDigitForm2, setSelectedDigitForm] = useState10("western");
17557
+ const [selectedCharacterFont, setSelectedCharacterFont] = useState10("default");
17558
+ const [boldCharacterStyle, setBoldCharacterStyle] = useState10(initialSession?.currentCharacterWrapper === "\\boldarabic");
17559
+ const [activeEditorSide, setActiveEditorSide] = useState10("arabic");
17560
+ const [compactPreviewOpen, setCompactPreviewOpen] = useState10(false);
17561
+ const [compactControlState, setCompactControlState] = useState10({
17078
17562
  canUndo: false,
17079
17563
  canRedo: false,
17080
17564
  hasSelection: false,
17081
17565
  splitLeafTyping: initialSession?.splitLeafTyping ?? true
17082
17566
  });
17083
- const [envPaletteMode, setEnvPaletteMode] = useState9("matrix");
17084
- const [matrixStyle, setMatrixStyle] = useState9("pmatrix");
17085
- const [matrixRows, setMatrixRows] = useState9(2);
17086
- const [matrixColumns, setMatrixColumns] = useState9(2);
17087
- const [matrixHover, setMatrixHover] = useState9(null);
17088
- const [arrayAlignmentColumn, setArrayAlignmentColumn] = useState9(1);
17567
+ const [envPaletteMode, setEnvPaletteMode] = useState10("matrix");
17568
+ const [matrixStyle, setMatrixStyle] = useState10("pmatrix");
17569
+ const [matrixRows, setMatrixRows] = useState10(2);
17570
+ const [matrixColumns, setMatrixColumns] = useState10(2);
17571
+ const [matrixHover, setMatrixHover] = useState10(null);
17572
+ const [arrayAlignmentColumn, setArrayAlignmentColumn] = useState10(1);
17089
17573
  const closeDesktopMenu = useCallback(() => setOpenDesktopMenu(null), []);
17090
17574
  useDesktopPopoverPlacement(wrapperRef, openDesktopMenu !== null, closeDesktopMenu);
17091
17575
  function desktopMenuOpen(menu) {
@@ -17354,7 +17838,7 @@ ${arabic || currentMessages.empty}`;
17354
17838
  boldCharacterStyle,
17355
17839
  digitForm: selectedDigitForm2
17356
17840
  };
17357
- return /* @__PURE__ */ jsx14(
17841
+ return /* @__PURE__ */ jsx15(
17358
17842
  "div",
17359
17843
  {
17360
17844
  ref: wrapperRef,
@@ -17363,9 +17847,9 @@ ${arabic || currentMessages.empty}`;
17363
17847
  "data-responsive-mode": responsiveMode,
17364
17848
  dir: uiLocaleDirection(uiLocale),
17365
17849
  lang: uiLocale,
17366
- children: /* @__PURE__ */ jsxs13("div", { className: "butex-widget-layout", children: [
17367
- /* @__PURE__ */ jsxs13("section", { className: "panel panel-editor", children: [
17368
- /* @__PURE__ */ jsx14(
17850
+ children: /* @__PURE__ */ jsxs14("div", { className: "butex-widget-layout", children: [
17851
+ /* @__PURE__ */ jsxs14("section", { className: "panel panel-editor", children: [
17852
+ /* @__PURE__ */ jsx15(
17369
17853
  EquationMobileToolbar,
17370
17854
  {
17371
17855
  uiLocale,
@@ -17376,15 +17860,15 @@ ${arabic || currentMessages.empty}`;
17376
17860
  getRuntime: () => runtimeRef.current
17377
17861
  }
17378
17862
  ),
17379
- /* @__PURE__ */ jsxs13("div", { className: "toolbar butex-widget__desktop-toolbar", children: [
17380
- /* @__PURE__ */ jsxs13("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
17381
- /* @__PURE__ */ jsx14("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
17382
- /* @__PURE__ */ jsx14("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
17863
+ /* @__PURE__ */ jsxs14("div", { className: "toolbar butex-widget__desktop-toolbar", children: [
17864
+ /* @__PURE__ */ jsxs14("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
17865
+ /* @__PURE__ */ jsx15("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
17866
+ /* @__PURE__ */ jsx15("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
17383
17867
  ] }),
17384
- /* @__PURE__ */ jsxs13("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
17385
- /* @__PURE__ */ jsx14("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
17386
- /* @__PURE__ */ jsx14("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
17387
- /* @__PURE__ */ jsx14(
17868
+ /* @__PURE__ */ jsxs14("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
17869
+ /* @__PURE__ */ jsx15("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
17870
+ /* @__PURE__ */ jsx15("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
17871
+ /* @__PURE__ */ jsx15(
17388
17872
  "button",
17389
17873
  {
17390
17874
  id: "btn-paste",
@@ -17401,9 +17885,9 @@ ${arabic || currentMessages.empty}`;
17401
17885
  }
17402
17886
  )
17403
17887
  ] }),
17404
- showSideSwitcher ? /* @__PURE__ */ jsx14("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ jsx14("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }) : null,
17405
- /* @__PURE__ */ jsxs13("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
17406
- /* @__PURE__ */ jsxs13(
17888
+ showSideSwitcher ? /* @__PURE__ */ jsx15("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ jsx15("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }) : null,
17889
+ /* @__PURE__ */ jsxs14("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
17890
+ /* @__PURE__ */ jsxs14(
17407
17891
  "div",
17408
17892
  {
17409
17893
  className: "delimiter-command-menu",
@@ -17414,7 +17898,7 @@ ${arabic || currentMessages.empty}`;
17414
17898
  }
17415
17899
  },
17416
17900
  children: [
17417
- /* @__PURE__ */ jsx14(
17901
+ /* @__PURE__ */ jsx15(
17418
17902
  "button",
17419
17903
  {
17420
17904
  className: "icon-btn delimiter-command-btn",
@@ -17427,8 +17911,8 @@ ${arabic || currentMessages.empty}`;
17427
17911
  children: "()"
17428
17912
  }
17429
17913
  ),
17430
- /* @__PURE__ */ jsxs13("div", { className: "delimiter-command-options", role: "menu", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
17431
- /* @__PURE__ */ jsx14(
17914
+ /* @__PURE__ */ jsxs14("div", { className: "delimiter-command-options", role: "menu", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
17915
+ /* @__PURE__ */ jsx15(
17432
17916
  "button",
17433
17917
  {
17434
17918
  className: "delimiter-command-option",
@@ -17446,7 +17930,7 @@ ${arabic || currentMessages.empty}`;
17446
17930
  children: "()"
17447
17931
  }
17448
17932
  ),
17449
- /* @__PURE__ */ jsx14(
17933
+ /* @__PURE__ */ jsx15(
17450
17934
  "button",
17451
17935
  {
17452
17936
  className: "delimiter-command-option",
@@ -17464,7 +17948,7 @@ ${arabic || currentMessages.empty}`;
17464
17948
  children: "[]"
17465
17949
  }
17466
17950
  ),
17467
- /* @__PURE__ */ jsx14(
17951
+ /* @__PURE__ */ jsx15(
17468
17952
  "button",
17469
17953
  {
17470
17954
  className: "delimiter-command-option",
@@ -17482,7 +17966,7 @@ ${arabic || currentMessages.empty}`;
17482
17966
  children: "{}"
17483
17967
  }
17484
17968
  ),
17485
- /* @__PURE__ */ jsx14(
17969
+ /* @__PURE__ */ jsx15(
17486
17970
  "button",
17487
17971
  {
17488
17972
  className: "delimiter-command-option",
@@ -17500,7 +17984,7 @@ ${arabic || currentMessages.empty}`;
17500
17984
  children: "| |"
17501
17985
  }
17502
17986
  ),
17503
- /* @__PURE__ */ jsx14(
17987
+ /* @__PURE__ */ jsx15(
17504
17988
  "button",
17505
17989
  {
17506
17990
  className: "delimiter-command-option",
@@ -17522,40 +18006,40 @@ ${arabic || currentMessages.empty}`;
17522
18006
  ]
17523
18007
  }
17524
18008
  ),
17525
- /* @__PURE__ */ jsx14("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
18009
+ /* @__PURE__ */ jsx15("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
17526
18010
  runtimeRef.current?.insertFraction();
17527
18011
  focusSurface();
17528
- }, children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
17529
- /* @__PURE__ */ jsx14("span", { children: "\u0623" }),
17530
- /* @__PURE__ */ jsx14("span", { children: "\u0628" })
18012
+ }, children: /* @__PURE__ */ jsxs14("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
18013
+ /* @__PURE__ */ jsx15("span", { children: "\u0623" }),
18014
+ /* @__PURE__ */ jsx15("span", { children: "\u0628" })
17531
18015
  ] }) }),
17532
- /* @__PURE__ */ jsx14("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
18016
+ /* @__PURE__ */ jsx15("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
17533
18017
  runtimeRef.current?.insertSqrt();
17534
18018
  focusSurface();
17535
- }, children: /* @__PURE__ */ jsx14("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
17536
- /* @__PURE__ */ jsx14("button", { id: "insert-overset", className: "icon-btn", type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => {
18019
+ }, children: /* @__PURE__ */ jsx15("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
18020
+ /* @__PURE__ */ jsx15("button", { id: "insert-overset", className: "icon-btn", type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => {
17537
18021
  runtimeRef.current?.insertOverset();
17538
18022
  focusSurface();
17539
- }, children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
17540
- /* @__PURE__ */ jsx14("span", { children: "\u2217" }),
17541
- /* @__PURE__ */ jsx14("span", { children: "\u25A1" })
18023
+ }, children: /* @__PURE__ */ jsxs14("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
18024
+ /* @__PURE__ */ jsx15("span", { children: "\u2217" }),
18025
+ /* @__PURE__ */ jsx15("span", { children: "\u25A1" })
17542
18026
  ] }) }),
17543
- /* @__PURE__ */ jsx14("button", { id: "insert-underset", className: "icon-btn", type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => {
18027
+ /* @__PURE__ */ jsx15("button", { id: "insert-underset", className: "icon-btn", type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => {
17544
18028
  runtimeRef.current?.insertUnderset();
17545
18029
  focusSurface();
17546
- }, children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
17547
- /* @__PURE__ */ jsx14("span", { children: "\u25A1" }),
17548
- /* @__PURE__ */ jsx14("span", { children: "\u2217" })
18030
+ }, children: /* @__PURE__ */ jsxs14("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
18031
+ /* @__PURE__ */ jsx15("span", { children: "\u25A1" }),
18032
+ /* @__PURE__ */ jsx15("span", { children: "\u2217" })
17549
18033
  ] }) }),
17550
- /* @__PURE__ */ jsx14("button", { id: "insert-accent-pair", className: "icon-btn", type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => {
18034
+ /* @__PURE__ */ jsx15("button", { id: "insert-accent-pair", className: "icon-btn", type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => {
17551
18035
  runtimeRef.current?.insertAccentPair();
17552
18036
  focusSurface();
17553
- }, children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
17554
- /* @__PURE__ */ jsx14("span", { children: "\u2217" }),
17555
- /* @__PURE__ */ jsx14("span", { children: "\u25A1" }),
17556
- /* @__PURE__ */ jsx14("span", { children: "\u2217" })
18037
+ }, children: /* @__PURE__ */ jsxs14("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
18038
+ /* @__PURE__ */ jsx15("span", { children: "\u2217" }),
18039
+ /* @__PURE__ */ jsx15("span", { children: "\u25A1" }),
18040
+ /* @__PURE__ */ jsx15("span", { children: "\u2217" })
17557
18041
  ] }) }),
17558
- /* @__PURE__ */ jsxs13(
18042
+ /* @__PURE__ */ jsxs14(
17559
18043
  "div",
17560
18044
  {
17561
18045
  className: "function-command-menu operator-command-menu",
@@ -17566,7 +18050,7 @@ ${arabic || currentMessages.empty}`;
17566
18050
  }
17567
18051
  },
17568
18052
  children: [
17569
- /* @__PURE__ */ jsx14(
18053
+ /* @__PURE__ */ jsx15(
17570
18054
  "button",
17571
18055
  {
17572
18056
  id: "insert-accents",
@@ -17577,13 +18061,13 @@ ${arabic || currentMessages.empty}`;
17577
18061
  "aria-haspopup": "menu",
17578
18062
  "aria-expanded": accentMenuOpen,
17579
18063
  onClick: () => setAccentMenuOpen((open) => !open),
17580
- children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
17581
- /* @__PURE__ */ jsx14("span", { children: "\u02C6" }),
17582
- /* @__PURE__ */ jsx14("span", { children: "\u25A1" })
18064
+ children: /* @__PURE__ */ jsxs14("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
18065
+ /* @__PURE__ */ jsx15("span", { children: "\u02C6" }),
18066
+ /* @__PURE__ */ jsx15("span", { children: "\u25A1" })
17583
18067
  ] })
17584
18068
  }
17585
18069
  ),
17586
- /* @__PURE__ */ jsx14("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertAccents, hidden: !accentMenuOpen, children: ACCENT_COMMANDS_LIST.map((command) => /* @__PURE__ */ jsx14(
18070
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertAccents, hidden: !accentMenuOpen, children: ACCENT_COMMANDS_LIST.map((command) => /* @__PURE__ */ jsx15(
17587
18071
  "button",
17588
18072
  {
17589
18073
  className: "function-command-option operator-command-option",
@@ -17597,7 +18081,7 @@ ${arabic || currentMessages.empty}`;
17597
18081
  setAccentMenuOpen(false);
17598
18082
  focusSurface();
17599
18083
  },
17600
- children: /* @__PURE__ */ jsx14("span", { className: "operator-command-label", children: command.label })
18084
+ children: /* @__PURE__ */ jsx15("span", { className: "operator-command-label", children: command.label })
17601
18085
  },
17602
18086
  command.id
17603
18087
  )) })
@@ -17605,7 +18089,7 @@ ${arabic || currentMessages.empty}`;
17605
18089
  }
17606
18090
  )
17607
18091
  ] }),
17608
- /* @__PURE__ */ jsx14("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ jsxs13(
18092
+ /* @__PURE__ */ jsx15("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ jsxs14(
17609
18093
  "div",
17610
18094
  {
17611
18095
  className: "matrix-command-menu",
@@ -17616,7 +18100,7 @@ ${arabic || currentMessages.empty}`;
17616
18100
  }
17617
18101
  },
17618
18102
  children: [
17619
- /* @__PURE__ */ jsx14(
18103
+ /* @__PURE__ */ jsx15(
17620
18104
  "button",
17621
18105
  {
17622
18106
  className: "icon-btn matrix-command-btn",
@@ -17626,21 +18110,21 @@ ${arabic || currentMessages.empty}`;
17626
18110
  "aria-haspopup": "dialog",
17627
18111
  "aria-expanded": matrixMenuOpen,
17628
18112
  onClick: () => setMatrixMenuOpen((open) => !open),
17629
- children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
17630
- /* @__PURE__ */ jsx14("span", {}),
17631
- /* @__PURE__ */ jsx14("span", {}),
17632
- /* @__PURE__ */ jsx14("span", {}),
17633
- /* @__PURE__ */ jsx14("span", {})
18113
+ children: /* @__PURE__ */ jsxs14("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
18114
+ /* @__PURE__ */ jsx15("span", {}),
18115
+ /* @__PURE__ */ jsx15("span", {}),
18116
+ /* @__PURE__ */ jsx15("span", {}),
18117
+ /* @__PURE__ */ jsx15("span", {})
17634
18118
  ] })
17635
18119
  }
17636
18120
  ),
17637
- /* @__PURE__ */ jsxs13("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
17638
- /* @__PURE__ */ jsx14("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
18121
+ /* @__PURE__ */ jsxs14("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
18122
+ /* @__PURE__ */ jsx15("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
17639
18123
  { id: "matrix", label: messages.matrix },
17640
18124
  { id: "array", label: messages.array },
17641
18125
  { id: "aligned", label: messages.aligned },
17642
18126
  { id: "cases", label: messages.piecewise }
17643
- ].map((option) => /* @__PURE__ */ jsx14(
18127
+ ].map((option) => /* @__PURE__ */ jsx15(
17644
18128
  "button",
17645
18129
  {
17646
18130
  type: "button",
@@ -17658,7 +18142,7 @@ ${arabic || currentMessages.empty}`;
17658
18142
  },
17659
18143
  option.id
17660
18144
  )) }),
17661
- envPaletteMode === "matrix" ? /* @__PURE__ */ jsx14("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES2.map((style) => /* @__PURE__ */ jsx14(
18145
+ envPaletteMode === "matrix" ? /* @__PURE__ */ jsx15("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES2.map((style) => /* @__PURE__ */ jsx15(
17662
18146
  "button",
17663
18147
  {
17664
18148
  type: "button",
@@ -17674,15 +18158,15 @@ ${arabic || currentMessages.empty}`;
17674
18158
  },
17675
18159
  style.id
17676
18160
  )) }) : null,
17677
- /* @__PURE__ */ jsx14("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel2(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel2(matrixRows, matrixColumns, messages) }),
17678
- envPaletteMode !== "cases" ? /* @__PURE__ */ jsx14("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
18161
+ /* @__PURE__ */ jsx15("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel2(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel2(matrixRows, matrixColumns, messages) }),
18162
+ envPaletteMode !== "cases" ? /* @__PURE__ */ jsx15("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
17679
18163
  { length: 8 },
17680
18164
  (_, rowIndex) => Array.from({ length: 8 }, (_2, columnIndex) => {
17681
18165
  const rows = rowIndex + 1;
17682
18166
  const columns = columnIndex + 1;
17683
18167
  const activeRows = matrixHover?.rows ?? matrixRows;
17684
18168
  const activeColumns = matrixHover?.columns ?? matrixColumns;
17685
- return /* @__PURE__ */ jsx14(
18169
+ return /* @__PURE__ */ jsx15(
17686
18170
  "button",
17687
18171
  {
17688
18172
  type: "button",
@@ -17704,10 +18188,10 @@ ${arabic || currentMessages.empty}`;
17704
18188
  );
17705
18189
  })
17706
18190
  ) }) : null,
17707
- /* @__PURE__ */ jsxs13("div", { className: "matrix-custom-size", children: [
17708
- /* @__PURE__ */ jsxs13("label", { children: [
18191
+ /* @__PURE__ */ jsxs14("div", { className: "matrix-custom-size", children: [
18192
+ /* @__PURE__ */ jsxs14("label", { children: [
17709
18193
  messages.row,
17710
- /* @__PURE__ */ jsx14(
18194
+ /* @__PURE__ */ jsx15(
17711
18195
  "input",
17712
18196
  {
17713
18197
  type: "number",
@@ -17718,9 +18202,9 @@ ${arabic || currentMessages.empty}`;
17718
18202
  }
17719
18203
  )
17720
18204
  ] }),
17721
- /* @__PURE__ */ jsxs13("label", { children: [
18205
+ /* @__PURE__ */ jsxs14("label", { children: [
17722
18206
  messages.column,
17723
- /* @__PURE__ */ jsx14(
18207
+ /* @__PURE__ */ jsx15(
17724
18208
  "input",
17725
18209
  {
17726
18210
  type: "number",
@@ -17732,7 +18216,7 @@ ${arabic || currentMessages.empty}`;
17732
18216
  }
17733
18217
  )
17734
18218
  ] }),
17735
- /* @__PURE__ */ jsx14(
18219
+ /* @__PURE__ */ jsx15(
17736
18220
  "button",
17737
18221
  {
17738
18222
  type: "button",
@@ -17750,12 +18234,12 @@ ${arabic || currentMessages.empty}`;
17750
18234
  }
17751
18235
  )
17752
18236
  ] }),
17753
- /* @__PURE__ */ jsxs13("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
17754
- envPaletteMode === "matrix" ? /* @__PURE__ */ jsx14("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
17755
- envPaletteMode === "array" ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
17756
- /* @__PURE__ */ jsxs13("label", { children: [
18237
+ /* @__PURE__ */ jsxs14("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
18238
+ envPaletteMode === "matrix" ? /* @__PURE__ */ jsx15("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
18239
+ envPaletteMode === "array" ? /* @__PURE__ */ jsxs14(Fragment6, { children: [
18240
+ /* @__PURE__ */ jsxs14("label", { children: [
17757
18241
  messages.column,
17758
- /* @__PURE__ */ jsx14(
18242
+ /* @__PURE__ */ jsx15(
17759
18243
  "input",
17760
18244
  {
17761
18245
  type: "number",
@@ -17766,7 +18250,7 @@ ${arabic || currentMessages.empty}`;
17766
18250
  }
17767
18251
  )
17768
18252
  ] }),
17769
- ARRAY_ALIGNMENTS2.map((alignment) => /* @__PURE__ */ jsx14(
18253
+ ARRAY_ALIGNMENTS2.map((alignment) => /* @__PURE__ */ jsx15(
17770
18254
  "button",
17771
18255
  {
17772
18256
  type: "button",
@@ -17778,19 +18262,19 @@ ${arabic || currentMessages.empty}`;
17778
18262
  alignment.id
17779
18263
  ))
17780
18264
  ] }) : null,
17781
- /* @__PURE__ */ jsxs13("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
18265
+ /* @__PURE__ */ jsxs14("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
17782
18266
  "+",
17783
18267
  messages.row
17784
18268
  ] }),
17785
- /* @__PURE__ */ jsxs13("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
18269
+ /* @__PURE__ */ jsxs14("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
17786
18270
  "-",
17787
18271
  messages.row
17788
18272
  ] }),
17789
- /* @__PURE__ */ jsxs13("button", { type: "button", title: messages.addColumn, disabled: envPaletteMode === "cases", onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
18273
+ /* @__PURE__ */ jsxs14("button", { type: "button", title: messages.addColumn, disabled: envPaletteMode === "cases", onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
17790
18274
  "+",
17791
18275
  messages.column
17792
18276
  ] }),
17793
- /* @__PURE__ */ jsxs13("button", { type: "button", title: messages.removeColumn, disabled: envPaletteMode === "cases", onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
18277
+ /* @__PURE__ */ jsxs14("button", { type: "button", title: messages.removeColumn, disabled: envPaletteMode === "cases", onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
17794
18278
  "-",
17795
18279
  messages.column
17796
18280
  ] })
@@ -17799,7 +18283,7 @@ ${arabic || currentMessages.empty}`;
17799
18283
  ]
17800
18284
  }
17801
18285
  ) }),
17802
- /* @__PURE__ */ jsx14("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ jsxs13(
18286
+ /* @__PURE__ */ jsx15("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ jsxs14(
17803
18287
  "div",
17804
18288
  {
17805
18289
  className: `spacing-command-menu spacing-command-menu--${activeEditorSide}`,
@@ -17810,7 +18294,7 @@ ${arabic || currentMessages.empty}`;
17810
18294
  }
17811
18295
  },
17812
18296
  children: [
17813
- /* @__PURE__ */ jsx14(
18297
+ /* @__PURE__ */ jsx15(
17814
18298
  "button",
17815
18299
  {
17816
18300
  className: "icon-btn spacing-command-btn",
@@ -17820,13 +18304,13 @@ ${arabic || currentMessages.empty}`;
17820
18304
  "aria-haspopup": "menu",
17821
18305
  "aria-expanded": spacingMenuOpen,
17822
18306
  onClick: () => setSpacingMenuOpen((open) => !open),
17823
- children: /* @__PURE__ */ jsxs13("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
17824
- /* @__PURE__ */ jsx14("span", { className: "spacing-command-glyph__bar" }),
17825
- /* @__PURE__ */ jsx14("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
18307
+ children: /* @__PURE__ */ jsxs14("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
18308
+ /* @__PURE__ */ jsx15("span", { className: "spacing-command-glyph__bar" }),
18309
+ /* @__PURE__ */ jsx15("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
17826
18310
  ] })
17827
18311
  }
17828
18312
  ),
17829
- /* @__PURE__ */ jsx14("div", { className: "spacing-command-options", role: "menu", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS2.map((command) => /* @__PURE__ */ jsxs13(
18313
+ /* @__PURE__ */ jsx15("div", { className: "spacing-command-options", role: "menu", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS2.map((command) => /* @__PURE__ */ jsxs14(
17830
18314
  "button",
17831
18315
  {
17832
18316
  type: "button",
@@ -17840,12 +18324,12 @@ ${arabic || currentMessages.empty}`;
17840
18324
  focusSurface();
17841
18325
  },
17842
18326
  children: [
17843
- /* @__PURE__ */ jsxs13("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
17844
- command.spacing.direction === "negative" ? /* @__PURE__ */ jsx14("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null,
17845
- /* @__PURE__ */ jsx14("span", { className: "spacing-command-glyph__bar" }),
17846
- command.spacing.direction === "positive" ? /* @__PURE__ */ jsx14("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null
18327
+ /* @__PURE__ */ jsxs14("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
18328
+ command.spacing.direction === "negative" ? /* @__PURE__ */ jsx15("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null,
18329
+ /* @__PURE__ */ jsx15("span", { className: "spacing-command-glyph__bar" }),
18330
+ command.spacing.direction === "positive" ? /* @__PURE__ */ jsx15("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null
17847
18331
  ] }),
17848
- /* @__PURE__ */ jsx14("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
18332
+ /* @__PURE__ */ jsx15("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
17849
18333
  ]
17850
18334
  },
17851
18335
  command.id
@@ -17853,8 +18337,8 @@ ${arabic || currentMessages.empty}`;
17853
18337
  ]
17854
18338
  }
17855
18339
  ) }),
17856
- /* @__PURE__ */ jsxs13("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
17857
- /* @__PURE__ */ jsxs13(
18340
+ /* @__PURE__ */ jsxs14("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
18341
+ /* @__PURE__ */ jsxs14(
17858
18342
  "div",
17859
18343
  {
17860
18344
  className: "function-command-menu",
@@ -17865,7 +18349,7 @@ ${arabic || currentMessages.empty}`;
17865
18349
  }
17866
18350
  },
17867
18351
  children: [
17868
- /* @__PURE__ */ jsx14(
18352
+ /* @__PURE__ */ jsx15(
17869
18353
  "button",
17870
18354
  {
17871
18355
  className: "icon-btn function-command-btn",
@@ -17878,7 +18362,7 @@ ${arabic || currentMessages.empty}`;
17878
18362
  children: FUNCTION_COMMANDS2[0]?.arabicLabel ?? "\u062F"
17879
18363
  }
17880
18364
  ),
17881
- /* @__PURE__ */ jsx14("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS2.map((command) => /* @__PURE__ */ jsx14(
18365
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS2.map((command) => /* @__PURE__ */ jsx15(
17882
18366
  "button",
17883
18367
  {
17884
18368
  className: "function-command-option",
@@ -17899,7 +18383,7 @@ ${arabic || currentMessages.empty}`;
17899
18383
  ]
17900
18384
  }
17901
18385
  ),
17902
- /* @__PURE__ */ jsxs13(
18386
+ /* @__PURE__ */ jsxs14(
17903
18387
  "div",
17904
18388
  {
17905
18389
  className: "function-command-menu function-command-menu--limits-series",
@@ -17910,7 +18394,7 @@ ${arabic || currentMessages.empty}`;
17910
18394
  }
17911
18395
  },
17912
18396
  children: [
17913
- /* @__PURE__ */ jsx14(
18397
+ /* @__PURE__ */ jsx15(
17914
18398
  "button",
17915
18399
  {
17916
18400
  className: "icon-btn function-command-btn",
@@ -17923,7 +18407,7 @@ ${arabic || currentMessages.empty}`;
17923
18407
  children: LIMITS_SERIES_COMMANDS2[0]?.arabicLabel ?? "\u062D\u062F"
17924
18408
  }
17925
18409
  ),
17926
- /* @__PURE__ */ jsx14("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS2.map((command) => /* @__PURE__ */ jsx14(
18410
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS2.map((command) => /* @__PURE__ */ jsx15(
17927
18411
  "button",
17928
18412
  {
17929
18413
  className: "function-command-option",
@@ -17944,7 +18428,7 @@ ${arabic || currentMessages.empty}`;
17944
18428
  ]
17945
18429
  }
17946
18430
  ),
17947
- /* @__PURE__ */ jsxs13(
18431
+ /* @__PURE__ */ jsxs14(
17948
18432
  "div",
17949
18433
  {
17950
18434
  className: "function-command-menu function-command-menu--function2",
@@ -17955,7 +18439,7 @@ ${arabic || currentMessages.empty}`;
17955
18439
  }
17956
18440
  },
17957
18441
  children: [
17958
- /* @__PURE__ */ jsx14(
18442
+ /* @__PURE__ */ jsx15(
17959
18443
  "button",
17960
18444
  {
17961
18445
  className: "icon-btn function-command-btn",
@@ -17968,7 +18452,7 @@ ${arabic || currentMessages.empty}`;
17968
18452
  children: FUNCTION2_COMMANDS2[0]?.arabicLabel ?? "\u062F"
17969
18453
  }
17970
18454
  ),
17971
- /* @__PURE__ */ jsx14("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS2.map((command) => /* @__PURE__ */ jsx14(
18455
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS2.map((command) => /* @__PURE__ */ jsx15(
17972
18456
  "button",
17973
18457
  {
17974
18458
  className: "function-command-option",
@@ -17989,7 +18473,7 @@ ${arabic || currentMessages.empty}`;
17989
18473
  ]
17990
18474
  }
17991
18475
  ),
17992
- /* @__PURE__ */ jsxs13(
18476
+ /* @__PURE__ */ jsxs14(
17993
18477
  "div",
17994
18478
  {
17995
18479
  className: "function-command-menu function-command-menu--derivative",
@@ -18000,7 +18484,7 @@ ${arabic || currentMessages.empty}`;
18000
18484
  }
18001
18485
  },
18002
18486
  children: [
18003
- /* @__PURE__ */ jsx14(
18487
+ /* @__PURE__ */ jsx15(
18004
18488
  "button",
18005
18489
  {
18006
18490
  className: "icon-btn function-command-btn",
@@ -18013,8 +18497,8 @@ ${arabic || currentMessages.empty}`;
18013
18497
  children: DERIVATIVE_COMMANDS2[0]?.arabicLabel ?? "\u0621"
18014
18498
  }
18015
18499
  ),
18016
- /* @__PURE__ */ jsxs13("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
18017
- DERIVATIVE_COMMANDS2.map((command) => /* @__PURE__ */ jsx14(
18500
+ /* @__PURE__ */ jsxs14("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
18501
+ DERIVATIVE_COMMANDS2.map((command) => /* @__PURE__ */ jsx15(
18018
18502
  "button",
18019
18503
  {
18020
18504
  className: "function-command-option",
@@ -18032,7 +18516,7 @@ ${arabic || currentMessages.empty}`;
18032
18516
  },
18033
18517
  command.id
18034
18518
  )),
18035
- /* @__PURE__ */ jsx14(
18519
+ /* @__PURE__ */ jsx15(
18036
18520
  "button",
18037
18521
  {
18038
18522
  className: "function-command-option",
@@ -18049,7 +18533,7 @@ ${arabic || currentMessages.empty}`;
18049
18533
  children: "\u0621/\u0633"
18050
18534
  }
18051
18535
  ),
18052
- /* @__PURE__ */ jsx14(
18536
+ /* @__PURE__ */ jsx15(
18053
18537
  "button",
18054
18538
  {
18055
18539
  className: "function-command-option",
@@ -18070,7 +18554,7 @@ ${arabic || currentMessages.empty}`;
18070
18554
  ]
18071
18555
  }
18072
18556
  ),
18073
- /* @__PURE__ */ jsxs13(
18557
+ /* @__PURE__ */ jsxs14(
18074
18558
  "div",
18075
18559
  {
18076
18560
  className: "function-command-menu function-command-menu--groups",
@@ -18081,7 +18565,7 @@ ${arabic || currentMessages.empty}`;
18081
18565
  }
18082
18566
  },
18083
18567
  children: [
18084
- /* @__PURE__ */ jsx14(
18568
+ /* @__PURE__ */ jsx15(
18085
18569
  "button",
18086
18570
  {
18087
18571
  className: "icon-btn function-command-btn",
@@ -18094,7 +18578,7 @@ ${arabic || currentMessages.empty}`;
18094
18578
  children: GROUP_COMMANDS2[0]?.arabicLabel ?? "\u0645"
18095
18579
  }
18096
18580
  ),
18097
- /* @__PURE__ */ jsx14("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS2.map((command) => /* @__PURE__ */ jsx14(
18581
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS2.map((command) => /* @__PURE__ */ jsx15(
18098
18582
  "button",
18099
18583
  {
18100
18584
  className: "function-command-option",
@@ -18116,8 +18600,8 @@ ${arabic || currentMessages.empty}`;
18116
18600
  }
18117
18601
  )
18118
18602
  ] }),
18119
- /* @__PURE__ */ jsxs13("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
18120
- /* @__PURE__ */ jsxs13(
18603
+ /* @__PURE__ */ jsxs14("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
18604
+ /* @__PURE__ */ jsxs14(
18121
18605
  "div",
18122
18606
  {
18123
18607
  className: "function-command-menu operator-command-menu",
@@ -18128,7 +18612,7 @@ ${arabic || currentMessages.empty}`;
18128
18612
  }
18129
18613
  },
18130
18614
  children: [
18131
- /* @__PURE__ */ jsx14(
18615
+ /* @__PURE__ */ jsx15(
18132
18616
  "button",
18133
18617
  {
18134
18618
  className: "icon-btn function-command-btn operator-command-btn",
@@ -18141,7 +18625,7 @@ ${arabic || currentMessages.empty}`;
18141
18625
  children: renderOperatorMenuButtonLabel(OPERATOR_COMMANDS[0], "\u2217")
18142
18626
  }
18143
18627
  ),
18144
- /* @__PURE__ */ jsx14("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ jsx14(
18628
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ jsx15(
18145
18629
  "button",
18146
18630
  {
18147
18631
  className: "function-command-option operator-command-option",
@@ -18155,14 +18639,14 @@ ${arabic || currentMessages.empty}`;
18155
18639
  setOperatorMenuOpen(false);
18156
18640
  focusSurface();
18157
18641
  },
18158
- children: /* @__PURE__ */ jsx14("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18642
+ children: /* @__PURE__ */ jsx15("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18159
18643
  },
18160
18644
  command.id
18161
18645
  )) })
18162
18646
  ]
18163
18647
  }
18164
18648
  ),
18165
- /* @__PURE__ */ jsxs13(
18649
+ /* @__PURE__ */ jsxs14(
18166
18650
  "div",
18167
18651
  {
18168
18652
  className: "function-command-menu operator-command-menu",
@@ -18173,7 +18657,7 @@ ${arabic || currentMessages.empty}`;
18173
18657
  }
18174
18658
  },
18175
18659
  children: [
18176
- /* @__PURE__ */ jsx14(
18660
+ /* @__PURE__ */ jsx15(
18177
18661
  "button",
18178
18662
  {
18179
18663
  className: "icon-btn function-command-btn operator-command-btn",
@@ -18186,7 +18670,7 @@ ${arabic || currentMessages.empty}`;
18186
18670
  children: "\u2229"
18187
18671
  }
18188
18672
  ),
18189
- /* @__PURE__ */ jsx14("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ jsx14(
18673
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ jsx15(
18190
18674
  "button",
18191
18675
  {
18192
18676
  className: "function-command-option operator-command-option",
@@ -18200,14 +18684,14 @@ ${arabic || currentMessages.empty}`;
18200
18684
  setOperator2MenuOpen(false);
18201
18685
  focusSurface();
18202
18686
  },
18203
- children: /* @__PURE__ */ jsx14("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18687
+ children: /* @__PURE__ */ jsx15("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18204
18688
  },
18205
18689
  command.id
18206
18690
  )) })
18207
18691
  ]
18208
18692
  }
18209
18693
  ),
18210
- /* @__PURE__ */ jsxs13(
18694
+ /* @__PURE__ */ jsxs14(
18211
18695
  "div",
18212
18696
  {
18213
18697
  className: "function-command-menu operator-command-menu",
@@ -18218,7 +18702,7 @@ ${arabic || currentMessages.empty}`;
18218
18702
  }
18219
18703
  },
18220
18704
  children: [
18221
- /* @__PURE__ */ jsx14(
18705
+ /* @__PURE__ */ jsx15(
18222
18706
  "button",
18223
18707
  {
18224
18708
  className: "icon-btn function-command-btn operator-command-btn",
@@ -18231,7 +18715,7 @@ ${arabic || currentMessages.empty}`;
18231
18715
  children: renderOperatorMenuButtonLabel(OPERATOR3_COMMANDS[0], "\u21D2")
18232
18716
  }
18233
18717
  ),
18234
- /* @__PURE__ */ jsx14("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ jsx14(
18718
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ jsx15(
18235
18719
  "button",
18236
18720
  {
18237
18721
  className: "function-command-option operator-command-option",
@@ -18245,14 +18729,14 @@ ${arabic || currentMessages.empty}`;
18245
18729
  setOperator3MenuOpen(false);
18246
18730
  focusSurface();
18247
18731
  },
18248
- children: /* @__PURE__ */ jsx14("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18732
+ children: /* @__PURE__ */ jsx15("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18249
18733
  },
18250
18734
  command.id
18251
18735
  )) })
18252
18736
  ]
18253
18737
  }
18254
18738
  ),
18255
- /* @__PURE__ */ jsxs13(
18739
+ /* @__PURE__ */ jsxs14(
18256
18740
  "div",
18257
18741
  {
18258
18742
  className: "function-command-menu operator-command-menu",
@@ -18263,7 +18747,7 @@ ${arabic || currentMessages.empty}`;
18263
18747
  }
18264
18748
  },
18265
18749
  children: [
18266
- /* @__PURE__ */ jsx14(
18750
+ /* @__PURE__ */ jsx15(
18267
18751
  "button",
18268
18752
  {
18269
18753
  className: "icon-btn function-command-btn operator-command-btn",
@@ -18276,7 +18760,7 @@ ${arabic || currentMessages.empty}`;
18276
18760
  children: renderOperatorMenuButtonLabel(DOT_COMMANDS[0], "\u2026")
18277
18761
  }
18278
18762
  ),
18279
- /* @__PURE__ */ jsx14("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ jsx14(
18763
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ jsx15(
18280
18764
  "button",
18281
18765
  {
18282
18766
  className: "function-command-option operator-command-option",
@@ -18290,14 +18774,14 @@ ${arabic || currentMessages.empty}`;
18290
18774
  setDotMenuOpen(false);
18291
18775
  focusSurface();
18292
18776
  },
18293
- children: /* @__PURE__ */ jsx14("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18777
+ children: /* @__PURE__ */ jsx15("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18294
18778
  },
18295
18779
  command.id
18296
18780
  )) })
18297
18781
  ]
18298
18782
  }
18299
18783
  ),
18300
- /* @__PURE__ */ jsxs13(
18784
+ /* @__PURE__ */ jsxs14(
18301
18785
  "div",
18302
18786
  {
18303
18787
  className: "function-command-menu operator-command-menu",
@@ -18308,7 +18792,7 @@ ${arabic || currentMessages.empty}`;
18308
18792
  }
18309
18793
  },
18310
18794
  children: [
18311
- /* @__PURE__ */ jsx14(
18795
+ /* @__PURE__ */ jsx15(
18312
18796
  "button",
18313
18797
  {
18314
18798
  className: "icon-btn function-command-btn operator-command-btn",
@@ -18321,7 +18805,7 @@ ${arabic || currentMessages.empty}`;
18321
18805
  children: renderOperatorMenuButtonLabel(INTEGRAL_COMMANDS[0], "\u222B")
18322
18806
  }
18323
18807
  ),
18324
- /* @__PURE__ */ jsx14("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ jsx14(
18808
+ /* @__PURE__ */ jsx15("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ jsx15(
18325
18809
  "button",
18326
18810
  {
18327
18811
  className: "function-command-option operator-command-option",
@@ -18335,7 +18819,7 @@ ${arabic || currentMessages.empty}`;
18335
18819
  setIntegralMenuOpen(false);
18336
18820
  focusSurface();
18337
18821
  },
18338
- children: /* @__PURE__ */ jsx14("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18822
+ children: /* @__PURE__ */ jsx15("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
18339
18823
  },
18340
18824
  command.id
18341
18825
  )) })
@@ -18343,28 +18827,28 @@ ${arabic || currentMessages.empty}`;
18343
18827
  }
18344
18828
  )
18345
18829
  ] }),
18346
- /* @__PURE__ */ jsxs13("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
18347
- /* @__PURE__ */ jsx14("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
18348
- /* @__PURE__ */ jsx14("span", { children: "\u0646" }),
18349
- /* @__PURE__ */ jsx14("span", { children: "\u0633" })
18830
+ /* @__PURE__ */ jsxs14("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
18831
+ /* @__PURE__ */ jsx15("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ jsxs14("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
18832
+ /* @__PURE__ */ jsx15("span", { children: "\u0646" }),
18833
+ /* @__PURE__ */ jsx15("span", { children: "\u0633" })
18350
18834
  ] }) }),
18351
- /* @__PURE__ */ jsx14("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ jsxs13("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
18352
- /* @__PURE__ */ jsx14("span", { children: "\u0646" }),
18353
- /* @__PURE__ */ jsx14("span", { children: "\u0633" })
18835
+ /* @__PURE__ */ jsx15("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ jsxs14("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
18836
+ /* @__PURE__ */ jsx15("span", { children: "\u0646" }),
18837
+ /* @__PURE__ */ jsx15("span", { children: "\u0633" })
18354
18838
  ] }) }),
18355
- /* @__PURE__ */ jsx14("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__ */ jsxs13("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
18356
- /* @__PURE__ */ jsx14("span", { children: "\u0646" }),
18357
- /* @__PURE__ */ jsx14("span", { children: "\xD7" })
18839
+ /* @__PURE__ */ jsx15("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__ */ jsxs14("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
18840
+ /* @__PURE__ */ jsx15("span", { children: "\u0646" }),
18841
+ /* @__PURE__ */ jsx15("span", { children: "\xD7" })
18358
18842
  ] }) }),
18359
- /* @__PURE__ */ jsx14("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__ */ jsxs13("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
18360
- /* @__PURE__ */ jsx14("span", { children: "\u0646" }),
18361
- /* @__PURE__ */ jsx14("span", { children: "\xD7" })
18843
+ /* @__PURE__ */ jsx15("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__ */ jsxs14("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
18844
+ /* @__PURE__ */ jsx15("span", { children: "\u0646" }),
18845
+ /* @__PURE__ */ jsx15("span", { children: "\xD7" })
18362
18846
  ] }) })
18363
18847
  ] }),
18364
- /* @__PURE__ */ jsxs13("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
18365
- /* @__PURE__ */ jsx14("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
18366
- /* @__PURE__ */ jsx14("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" }),
18367
- /* @__PURE__ */ jsxs13(
18848
+ /* @__PURE__ */ jsxs14("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
18849
+ /* @__PURE__ */ jsx15("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
18850
+ /* @__PURE__ */ jsx15("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" }),
18851
+ /* @__PURE__ */ jsxs14(
18368
18852
  "div",
18369
18853
  {
18370
18854
  className: "character-font-menu",
@@ -18375,7 +18859,7 @@ ${arabic || currentMessages.empty}`;
18375
18859
  }
18376
18860
  },
18377
18861
  children: [
18378
- /* @__PURE__ */ jsx14(
18862
+ /* @__PURE__ */ jsx15(
18379
18863
  "button",
18380
18864
  {
18381
18865
  ref: characterFontBtnRef,
@@ -18390,8 +18874,8 @@ ${arabic || currentMessages.empty}`;
18390
18874
  children: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontOption(selectedCharacterFont).label
18391
18875
  }
18392
18876
  ),
18393
- /* @__PURE__ */ jsxs13("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: [
18394
- /* @__PURE__ */ jsx14(
18877
+ /* @__PURE__ */ jsxs14("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: [
18878
+ /* @__PURE__ */ jsx15(
18395
18879
  "button",
18396
18880
  {
18397
18881
  type: "button",
@@ -18408,7 +18892,7 @@ ${arabic || currentMessages.empty}`;
18408
18892
  children: boldCharacterStyleLabel2(uiLocale)
18409
18893
  }
18410
18894
  ),
18411
- CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx14(
18895
+ CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx15(
18412
18896
  "button",
18413
18897
  {
18414
18898
  type: "button",
@@ -18431,7 +18915,7 @@ ${arabic || currentMessages.empty}`;
18431
18915
  ]
18432
18916
  }
18433
18917
  ),
18434
- /* @__PURE__ */ jsxs13(
18918
+ /* @__PURE__ */ jsxs14(
18435
18919
  "div",
18436
18920
  {
18437
18921
  className: "digit-form-menu",
@@ -18442,7 +18926,7 @@ ${arabic || currentMessages.empty}`;
18442
18926
  }
18443
18927
  },
18444
18928
  children: [
18445
- /* @__PURE__ */ jsx14(
18929
+ /* @__PURE__ */ jsx15(
18446
18930
  "button",
18447
18931
  {
18448
18932
  ref: digitFormBtnRef,
@@ -18454,10 +18938,10 @@ ${arabic || currentMessages.empty}`;
18454
18938
  "aria-haspopup": "listbox",
18455
18939
  "aria-expanded": digitMenuOpen,
18456
18940
  onClick: () => setDigitMenuOpen((open) => !open),
18457
- children: digitFormLabel3(selectedDigitForm2)
18941
+ children: digitFormLabel2(selectedDigitForm2)
18458
18942
  }
18459
18943
  ),
18460
- /* @__PURE__ */ jsx14("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ jsx14(
18944
+ /* @__PURE__ */ jsx15("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ jsx15(
18461
18945
  "button",
18462
18946
  {
18463
18947
  type: "button",
@@ -18481,7 +18965,7 @@ ${arabic || currentMessages.empty}`;
18481
18965
  )
18482
18966
  ] })
18483
18967
  ] }),
18484
- /* @__PURE__ */ jsx14(
18968
+ /* @__PURE__ */ jsx15(
18485
18969
  "div",
18486
18970
  {
18487
18971
  ref: surfaceRef,
@@ -18491,7 +18975,7 @@ ${arabic || currentMessages.empty}`;
18491
18975
  "aria-label": messages.equationEditor
18492
18976
  }
18493
18977
  ),
18494
- /* @__PURE__ */ jsx14(
18978
+ /* @__PURE__ */ jsx15(
18495
18979
  "textarea",
18496
18980
  {
18497
18981
  ref: inputRef,
@@ -18505,8 +18989,8 @@ ${arabic || currentMessages.empty}`;
18505
18989
  tabIndex: -1
18506
18990
  }
18507
18991
  ),
18508
- /* @__PURE__ */ jsx14("div", { ref: renderErrorRef, className: "error", hidden: true }),
18509
- /* @__PURE__ */ jsx14(
18992
+ /* @__PURE__ */ jsx15("div", { ref: renderErrorRef, className: "error", hidden: true }),
18993
+ /* @__PURE__ */ jsx15(
18510
18994
  "button",
18511
18995
  {
18512
18996
  type: "button",
@@ -18518,18 +19002,18 @@ ${arabic || currentMessages.empty}`;
18518
19002
  }
18519
19003
  )
18520
19004
  ] }),
18521
- /* @__PURE__ */ jsx14("section", { id: previewPanelId, className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ jsx14("div", { ref: mathOutputRef, className: "preview-box" }) }),
18522
- debugEnabled ? /* @__PURE__ */ jsxs13("section", { className: "panel", children: [
18523
- /* @__PURE__ */ jsxs13("div", { className: "dev-strip", children: [
18524
- /* @__PURE__ */ jsx14("span", { className: "dev-badge", children: messages.development }),
18525
- /* @__PURE__ */ jsx14("div", { ref: latexLinesRef, className: "ascii" }),
18526
- /* @__PURE__ */ jsx14("div", { ref: passivePreviewRef, className: "passive-preview-text" })
19005
+ /* @__PURE__ */ jsx15("section", { id: previewPanelId, className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ jsx15("div", { ref: mathOutputRef, className: "preview-box" }) }),
19006
+ debugEnabled ? /* @__PURE__ */ jsxs14("section", { className: "panel", children: [
19007
+ /* @__PURE__ */ jsxs14("div", { className: "dev-strip", children: [
19008
+ /* @__PURE__ */ jsx15("span", { className: "dev-badge", children: messages.development }),
19009
+ /* @__PURE__ */ jsx15("div", { ref: latexLinesRef, className: "ascii" }),
19010
+ /* @__PURE__ */ jsx15("div", { ref: passivePreviewRef, className: "passive-preview-text" })
18527
19011
  ] }),
18528
- /* @__PURE__ */ jsxs13("div", { style: { marginTop: 12 }, children: [
18529
- /* @__PURE__ */ jsxs13("div", { className: "debug-head", children: [
18530
- /* @__PURE__ */ jsx14("button", { type: "button", onClick: () => void copyDebugText(currentMathObjectJsonText()), children: "Copy MathObject JSON" }),
18531
- /* @__PURE__ */ jsx14("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugMathObjectImport, children: "Import MathObject JSON" }),
18532
- /* @__PURE__ */ jsx14(
19012
+ /* @__PURE__ */ jsxs14("div", { style: { marginTop: 12 }, children: [
19013
+ /* @__PURE__ */ jsxs14("div", { className: "debug-head", children: [
19014
+ /* @__PURE__ */ jsx15("button", { type: "button", onClick: () => void copyDebugText(currentMathObjectJsonText()), children: "Copy MathObject JSON" }),
19015
+ /* @__PURE__ */ jsx15("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugMathObjectImport, children: "Import MathObject JSON" }),
19016
+ /* @__PURE__ */ jsx15(
18533
19017
  "button",
18534
19018
  {
18535
19019
  type: "button",
@@ -18549,7 +19033,7 @@ ${arabic || currentMessages.empty}`;
18549
19033
  children: debugBodyHidden ? messages.showDebugLog : messages.hideDebugLog
18550
19034
  }
18551
19035
  ),
18552
- /* @__PURE__ */ jsx14(
19036
+ /* @__PURE__ */ jsx15(
18553
19037
  "button",
18554
19038
  {
18555
19039
  type: "button",
@@ -18564,8 +19048,8 @@ ${arabic || currentMessages.empty}`;
18564
19048
  }
18565
19049
  )
18566
19050
  ] }),
18567
- debugImportOpen ? /* @__PURE__ */ jsxs13("div", { className: "debug-json-import", children: [
18568
- /* @__PURE__ */ jsx14(
19051
+ debugImportOpen ? /* @__PURE__ */ jsxs14("div", { className: "debug-json-import", children: [
19052
+ /* @__PURE__ */ jsx15(
18569
19053
  "textarea",
18570
19054
  {
18571
19055
  value: debugImportText,
@@ -18577,9 +19061,9 @@ ${arabic || currentMessages.empty}`;
18577
19061
  }
18578
19062
  }
18579
19063
  ),
18580
- /* @__PURE__ */ jsxs13("div", { className: "debug-head", children: [
18581
- /* @__PURE__ */ jsx14("button", { type: "button", onClick: applyDebugMathObjectImport, children: "Apply" }),
18582
- /* @__PURE__ */ jsx14(
19064
+ /* @__PURE__ */ jsxs14("div", { className: "debug-head", children: [
19065
+ /* @__PURE__ */ jsx15("button", { type: "button", onClick: applyDebugMathObjectImport, children: "Apply" }),
19066
+ /* @__PURE__ */ jsx15(
18583
19067
  "button",
18584
19068
  {
18585
19069
  type: "button",
@@ -18591,9 +19075,9 @@ ${arabic || currentMessages.empty}`;
18591
19075
  }
18592
19076
  )
18593
19077
  ] }),
18594
- debugImportError ? /* @__PURE__ */ jsx14("p", { className: "debug-json-error", children: debugImportError }) : null
19078
+ debugImportError ? /* @__PURE__ */ jsx15("p", { className: "debug-json-error", children: debugImportError }) : null
18595
19079
  ] }) : null,
18596
- /* @__PURE__ */ jsx14("div", { ref: debugLogRef, className: "debug-log" })
19080
+ /* @__PURE__ */ jsx15("div", { ref: debugLogRef, className: "debug-log" })
18597
19081
  ] })
18598
19082
  ] }) : null
18599
19083
  ] })
@@ -18604,7 +19088,7 @@ ${arabic || currentMessages.empty}`;
18604
19088
  ButexEditor.displayName = "ButexEditor";
18605
19089
 
18606
19090
  // src/react-document/EquationDrawer.tsx
18607
- import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
19091
+ import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
18608
19092
  function keyErrorMessage2(error, messages) {
18609
19093
  if (error === "empty") {
18610
19094
  return messages.keyEmpty;
@@ -18621,6 +19105,7 @@ function standardCommandWarning(uiLocale) {
18621
19105
  return uiLocale === "en" ? "This equation contains standard non-Arabic math commands. Review them and replace them with the Arabic-oriented equivalent where appropriate." : "\u062A\u062D\u062A\u0648\u064A \u0647\u0630\u0647 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u0639\u0644\u0649 \u0631\u0645\u0648\u0632 \u0623\u0648 \u0623\u0648\u0627\u0645\u0631 \u0631\u064A\u0627\u0636\u064A\u0629 \u0642\u064A\u0627\u0633\u064A\u0629 \u063A\u064A\u0631 \u0645\u0639\u0631\u0651\u0628\u0629. \u064A\u064F\u0631\u062C\u0649 \u0645\u0631\u0627\u062C\u0639\u062A\u0647\u0627 \u0648\u0627\u0633\u062A\u0628\u062F\u0627\u0644\u0647\u0627 \u0628\u0627\u0644\u0645\u0642\u0627\u0628\u0644 \u0627\u0644\u0639\u0631\u0628\u064A \u0639\u0646\u062F \u0627\u0644\u062D\u0627\u062C\u0629.";
18622
19106
  }
18623
19107
  function EquationDrawer({
19108
+ sourceRef,
18624
19109
  debug = false,
18625
19110
  session,
18626
19111
  reason,
@@ -18645,11 +19130,10 @@ function EquationDrawer({
18645
19130
  }) {
18646
19131
  const messages = documentMessages(uiLocale);
18647
19132
  const latestSession = useRef11(session);
18648
- const modalRef = useRef11(null);
18649
19133
  const dialogRef = useRef11(null);
18650
19134
  const titleId = useId5();
18651
- const [labelOverride, setLabelOverride] = useState10(null);
18652
- const [hasStandardCommandWarning, setHasStandardCommandWarning] = useState10(
19135
+ const [labelOverride, setLabelOverride] = useState11(null);
19136
+ const [hasStandardCommandWarning, setHasStandardCommandWarning] = useState11(
18653
19137
  () => sessionHasStandardCommands(session)
18654
19138
  );
18655
19139
  const displayedLabel = labelOverride ?? label;
@@ -18666,26 +19150,8 @@ function EquationDrawer({
18666
19150
  setHasStandardCommandWarning(sessionHasStandardCommands(session));
18667
19151
  }, [session]);
18668
19152
  useDialogFocus({ open: true, dialogRef, onClose });
18669
- useEffect11(() => observeVisibleViewport(window, ({ snapshot }) => {
18670
- const modal = modalRef.current;
18671
- if (!modal) {
18672
- return;
18673
- }
18674
- if (snapshot.source !== "visual-viewport") {
18675
- delete modal.dataset.visibleViewport;
18676
- for (const name of ["top", "left", "width", "height"]) {
18677
- modal.style.removeProperty(`--butex-document-visible-viewport-${name}`);
18678
- }
18679
- return;
18680
- }
18681
- modal.dataset.visibleViewport = "true";
18682
- modal.style.setProperty("--butex-document-visible-viewport-top", `${String(snapshot.offsetTop)}px`);
18683
- modal.style.setProperty("--butex-document-visible-viewport-left", `${String(snapshot.offsetLeft)}px`);
18684
- modal.style.setProperty("--butex-document-visible-viewport-width", `${String(snapshot.width)}px`);
18685
- modal.style.setProperty("--butex-document-visible-viewport-height", `${String(snapshot.height)}px`);
18686
- }), []);
18687
- return /* @__PURE__ */ jsxs14("div", { ref: modalRef, className: "butex-document-widget__equation-modal", role: "presentation", children: [
18688
- /* @__PURE__ */ jsx15(
19153
+ return /* @__PURE__ */ jsx16(ViewportModalPortal, { sourceRef, scopeClassName: "butex-document-widget", children: /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__equation-modal", style: { position: "absolute" }, role: "presentation", children: [
19154
+ /* @__PURE__ */ jsx16(
18689
19155
  "button",
18690
19156
  {
18691
19157
  type: "button",
@@ -18694,7 +19160,7 @@ function EquationDrawer({
18694
19160
  onClick: onClose
18695
19161
  }
18696
19162
  ),
18697
- /* @__PURE__ */ jsxs14(
19163
+ /* @__PURE__ */ jsxs15(
18698
19164
  "div",
18699
19165
  {
18700
19166
  ref: dialogRef,
@@ -18706,28 +19172,28 @@ function EquationDrawer({
18706
19172
  lang: uiLocale,
18707
19173
  tabIndex: -1,
18708
19174
  children: [
18709
- /* @__PURE__ */ jsxs14("div", { className: "butex-document-widget__row butex-document-widget__equation-modal-header", children: [
18710
- /* @__PURE__ */ jsx15("strong", { id: titleId, children: messages.equationEditorTitle }),
18711
- /* @__PURE__ */ jsx15("button", { type: "button", "data-dialog-initial-focus": true, onClick: onClose, children: messages.close })
19175
+ /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__row butex-document-widget__equation-modal-header", children: [
19176
+ /* @__PURE__ */ jsx16("strong", { id: titleId, children: messages.equationEditorTitle }),
19177
+ /* @__PURE__ */ jsx16("button", { type: "button", "data-dialog-initial-focus": true, onClick: onClose, children: messages.close })
18712
19178
  ] }),
18713
- /* @__PURE__ */ jsxs14("div", { className: "butex-document-widget__equation-modal-body", children: [
18714
- /* @__PURE__ */ jsxs14("div", { className: "butex-document-widget__row", role: "group", "aria-label": messages.equationType, children: [
18715
- /* @__PURE__ */ jsxs14("button", { type: "button", "aria-pressed": mathMode === "inline", onClick: () => onMathModeChange("inline"), children: [
19179
+ /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__equation-modal-body", children: [
19180
+ /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__row", role: "group", "aria-label": messages.equationType, children: [
19181
+ /* @__PURE__ */ jsxs15("button", { type: "button", "aria-pressed": mathMode === "inline", onClick: () => onMathModeChange("inline"), children: [
18716
19182
  messages.inline,
18717
19183
  " ($)"
18718
19184
  ] }),
18719
- /* @__PURE__ */ jsxs14("button", { type: "button", "aria-pressed": mathMode === "display", onClick: () => onMathModeChange("display"), children: [
19185
+ /* @__PURE__ */ jsxs15("button", { type: "button", "aria-pressed": mathMode === "display", onClick: () => onMathModeChange("display"), children: [
18720
19186
  messages.displayed,
18721
19187
  " (\\\\[)"
18722
19188
  ] })
18723
19189
  ] }),
18724
- mathMode === "display" ? /* @__PURE__ */ jsxs14("div", { className: "butex-document-widget__float-meta", children: [
18725
- /* @__PURE__ */ jsxs14("label", { className: "butex-document-widget__float-meta-toggle", children: [
18726
- /* @__PURE__ */ jsx15("input", { type: "checkbox", checked: numbered, onChange: (event) => onNumberedChange?.(event.currentTarget.checked) }),
18727
- /* @__PURE__ */ jsx15("span", { children: uiLocale === "ar" ? "\u062A\u0631\u0642\u064A\u0645 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" : "Number equation" })
19190
+ mathMode === "display" ? /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__float-meta", children: [
19191
+ /* @__PURE__ */ jsxs15("label", { className: "butex-document-widget__float-meta-toggle", children: [
19192
+ /* @__PURE__ */ jsx16("input", { type: "checkbox", checked: numbered, onChange: (event) => onNumberedChange?.(event.currentTarget.checked) }),
19193
+ /* @__PURE__ */ jsx16("span", { children: uiLocale === "ar" ? "\u062A\u0631\u0642\u064A\u0645 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" : "Number equation" })
18728
19194
  ] }),
18729
- /* @__PURE__ */ jsxs14("label", { className: "butex-document-widget__float-meta-toggle", children: [
18730
- /* @__PURE__ */ jsx15(
19195
+ /* @__PURE__ */ jsxs15("label", { className: "butex-document-widget__float-meta-toggle", children: [
19196
+ /* @__PURE__ */ jsx16(
18731
19197
  "input",
18732
19198
  {
18733
19199
  type: "checkbox",
@@ -18735,11 +19201,11 @@ function EquationDrawer({
18735
19201
  onChange: (event) => onLabelEnabledChange?.(event.currentTarget.checked)
18736
19202
  }
18737
19203
  ),
18738
- /* @__PURE__ */ jsx15("span", { children: messages.labelToggle })
19204
+ /* @__PURE__ */ jsx16("span", { children: messages.labelToggle })
18739
19205
  ] }),
18740
- labelEnabled ? /* @__PURE__ */ jsxs14("label", { className: "butex-document-widget__refs-field", children: [
18741
- /* @__PURE__ */ jsx15("span", { children: messages.floatLabel }),
18742
- /* @__PURE__ */ jsx15(
19206
+ labelEnabled ? /* @__PURE__ */ jsxs15("label", { className: "butex-document-widget__refs-field", children: [
19207
+ /* @__PURE__ */ jsx16("span", { children: messages.floatLabel }),
19208
+ /* @__PURE__ */ jsx16(
18743
19209
  "input",
18744
19210
  {
18745
19211
  value: displayedLabel,
@@ -18762,12 +19228,12 @@ function EquationDrawer({
18762
19228
  }
18763
19229
  }
18764
19230
  ),
18765
- labelError !== null ? /* @__PURE__ */ jsx15("p", { className: "butex-document-widget__field-error", children: labelError === "invalid" ? messages.keyRulesHint : keyErrorMessage2(labelError, messages) }) : null
19231
+ labelError !== null ? /* @__PURE__ */ jsx16("p", { className: "butex-document-widget__field-error", children: labelError === "invalid" ? messages.keyRulesHint : keyErrorMessage2(labelError, messages) }) : null
18766
19232
  ] }) : null
18767
19233
  ] }) : null,
18768
- reason ? /* @__PURE__ */ jsx15("p", { className: "butex-document-widget__error", children: uiLocale === "en" ? messages.equationUnavailable : reason }) : null,
18769
- hasStandardCommandWarning && !reason ? /* @__PURE__ */ jsx15("p", { className: "butex-document-widget__standard-command-warning", role: "status", children: standardCommandWarning(uiLocale) }) : null,
18770
- /* @__PURE__ */ jsx15(
19234
+ reason ? /* @__PURE__ */ jsx16("p", { className: "butex-document-widget__error", children: uiLocale === "en" ? messages.equationUnavailable : reason }) : null,
19235
+ hasStandardCommandWarning && !reason ? /* @__PURE__ */ jsx16("p", { className: "butex-document-widget__standard-command-warning", role: "status", children: standardCommandWarning(uiLocale) }) : null,
19236
+ /* @__PURE__ */ jsx16(
18771
19237
  ButexEditor,
18772
19238
  {
18773
19239
  debug,
@@ -18783,9 +19249,9 @@ function EquationDrawer({
18783
19249
  }
18784
19250
  )
18785
19251
  ] }),
18786
- /* @__PURE__ */ jsxs14("div", { className: "butex-document-widget__row butex-document-widget__equation-modal-actions", children: [
18787
- canDelete && onDelete ? /* @__PURE__ */ jsx15("button", { type: "button", className: "butex-document-widget__button--danger", onClick: onDelete, children: messages.deleteEquation }) : null,
18788
- /* @__PURE__ */ jsx15(
19252
+ /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__row butex-document-widget__equation-modal-actions", children: [
19253
+ canDelete && onDelete ? /* @__PURE__ */ jsx16("button", { type: "button", className: "butex-document-widget__button--danger", onClick: onDelete, children: messages.deleteEquation }) : null,
19254
+ /* @__PURE__ */ jsx16(
18789
19255
  "button",
18790
19256
  {
18791
19257
  type: "button",
@@ -18798,12 +19264,12 @@ function EquationDrawer({
18798
19264
  ]
18799
19265
  }
18800
19266
  )
18801
- ] });
19267
+ ] }) });
18802
19268
  }
18803
19269
 
18804
19270
  // src/react-document/LabelsPanel.tsx
18805
- import { useRef as useRef12, useState as useState11 } from "react";
18806
- import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
19271
+ import { useRef as useRef12, useState as useState12 } from "react";
19272
+ import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
18807
19273
  function keyErrorMessage3(error, messages) {
18808
19274
  if (error === "empty") {
18809
19275
  return messages.keyEmpty;
@@ -18829,13 +19295,13 @@ function LabelsPanel({
18829
19295
  }) {
18830
19296
  const messages = documentMessages(uiLocale);
18831
19297
  const documentDirection = uiLocale === "ar" ? "rtl" : "ltr";
18832
- const [keyOverrides, setKeyOverrides] = useState11({});
19298
+ const [keyOverrides, setKeyOverrides] = useState12({});
18833
19299
  const dialogRef = useRef12(null);
18834
19300
  useDialogFocus({ open, dialogRef, triggerRef: returnFocusRef, onClose });
18835
19301
  if (!open) {
18836
19302
  return null;
18837
19303
  }
18838
- return /* @__PURE__ */ jsx16("div", { className: "butex-document-widget__refs-backdrop", role: "presentation", onClick: onClose, children: /* @__PURE__ */ jsxs15(
19304
+ return /* @__PURE__ */ jsx17("div", { className: "butex-document-widget__refs-backdrop", role: "presentation", onClick: onClose, children: /* @__PURE__ */ jsxs16(
18839
19305
  "div",
18840
19306
  {
18841
19307
  ref: dialogRef,
@@ -18846,13 +19312,13 @@ function LabelsPanel({
18846
19312
  tabIndex: -1,
18847
19313
  onClick: (event) => event.stopPropagation(),
18848
19314
  children: [
18849
- /* @__PURE__ */ jsxs15("header", { className: "butex-document-widget__refs-header", children: [
18850
- /* @__PURE__ */ jsx16("strong", { children: messages.labelsTitle }),
18851
- /* @__PURE__ */ jsx16("button", { type: "button", "data-dialog-initial-focus": true, className: "butex-document-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
19315
+ /* @__PURE__ */ jsxs16("header", { className: "butex-document-widget__refs-header", children: [
19316
+ /* @__PURE__ */ jsx17("strong", { children: messages.labelsTitle }),
19317
+ /* @__PURE__ */ jsx17("button", { type: "button", "data-dialog-initial-focus": true, className: "butex-document-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
18852
19318
  ] }),
18853
- /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__dialog-body", children: [
18854
- /* @__PURE__ */ jsx16("p", { className: "butex-document-widget__labels-help", children: messages.labelsHelp }),
18855
- labels.length === 0 ? /* @__PURE__ */ jsx16("p", { className: "butex-document-widget__cite-picker-empty", children: messages.noLabelsYet }) : /* @__PURE__ */ jsx16("ul", { className: "butex-document-widget__refs-list", children: labels.map((entry) => {
19319
+ /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__dialog-body", children: [
19320
+ /* @__PURE__ */ jsx17("p", { className: "butex-document-widget__labels-help", children: messages.labelsHelp }),
19321
+ labels.length === 0 ? /* @__PURE__ */ jsx17("p", { className: "butex-document-widget__cite-picker-empty", children: messages.noLabelsYet }) : /* @__PURE__ */ jsx17("ul", { className: "butex-document-widget__refs-list", children: labels.map((entry) => {
18856
19322
  const title = formatFloatCaptionTitle(entry.kind, entry.number, {
18857
19323
  uiLocale,
18858
19324
  digitForm,
@@ -18866,12 +19332,12 @@ function LabelsPanel({
18866
19332
  labels,
18867
19333
  excludeOwnerId: entry.ownerId
18868
19334
  });
18869
- return /* @__PURE__ */ jsxs15("li", { className: "butex-document-widget__refs-item", children: [
18870
- /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__refs-item-head", children: [
18871
- /* @__PURE__ */ jsx16("strong", { children: title }),
18872
- /* @__PURE__ */ jsx16("span", { className: "butex-document-widget__refs-item-key", children: entry.key })
19335
+ return /* @__PURE__ */ jsxs16("li", { className: "butex-document-widget__refs-item", children: [
19336
+ /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-item-head", children: [
19337
+ /* @__PURE__ */ jsx17("strong", { children: title }),
19338
+ /* @__PURE__ */ jsx17("span", { className: "butex-document-widget__refs-item-key", children: entry.key })
18873
19339
  ] }),
18874
- /* @__PURE__ */ jsx16(
19340
+ /* @__PURE__ */ jsx17(
18875
19341
  "div",
18876
19342
  {
18877
19343
  className: "butex-document-widget__modal-preview",
@@ -18880,10 +19346,10 @@ function LabelsPanel({
18880
19346
  children: captionPreview2
18881
19347
  }
18882
19348
  ),
18883
- /* @__PURE__ */ jsxs15("div", { className: "butex-document-widget__refs-grid", children: [
18884
- /* @__PURE__ */ jsxs15("label", { className: "butex-document-widget__refs-field", children: [
18885
- /* @__PURE__ */ jsx16("span", { children: messages.floatLabel }),
18886
- /* @__PURE__ */ jsx16(
19349
+ /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-grid", children: [
19350
+ /* @__PURE__ */ jsxs16("label", { className: "butex-document-widget__refs-field", children: [
19351
+ /* @__PURE__ */ jsx17("span", { children: messages.floatLabel }),
19352
+ /* @__PURE__ */ jsx17(
18887
19353
  "input",
18888
19354
  {
18889
19355
  value: displayedKey,
@@ -18913,11 +19379,11 @@ function LabelsPanel({
18913
19379
  }
18914
19380
  }
18915
19381
  ),
18916
- entryKeyError !== null ? /* @__PURE__ */ jsx16("p", { className: "butex-document-widget__field-error", children: entryKeyError === "invalid" ? messages.keyRulesHint : keyErrorMessage3(entryKeyError, messages) }) : null
19382
+ entryKeyError !== null ? /* @__PURE__ */ jsx17("p", { className: "butex-document-widget__field-error", children: entryKeyError === "invalid" ? messages.keyRulesHint : keyErrorMessage3(entryKeyError, messages) }) : null
18917
19383
  ] }),
18918
- entry.kind === "fig" || entry.kind === "tab" ? /* @__PURE__ */ jsxs15("label", { className: "butex-document-widget__refs-field", children: [
18919
- /* @__PURE__ */ jsx16("span", { children: messages.floatCaption }),
18920
- /* @__PURE__ */ jsx16(
19384
+ entry.kind === "fig" || entry.kind === "tab" ? /* @__PURE__ */ jsxs16("label", { className: "butex-document-widget__refs-field", children: [
19385
+ /* @__PURE__ */ jsx17("span", { children: messages.floatCaption }),
19386
+ /* @__PURE__ */ jsx17(
18921
19387
  "input",
18922
19388
  {
18923
19389
  value: entry.caption,
@@ -18941,8 +19407,8 @@ function LabelsPanel({
18941
19407
  }
18942
19408
 
18943
19409
  // src/react-document/ReferencesPanel.tsx
18944
- import { useMemo, useRef as useRef13, useState as useState12 } from "react";
18945
- import { Fragment as Fragment7, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
19410
+ import { useMemo, useRef as useRef13, useState as useState13 } from "react";
19411
+ import { Fragment as Fragment7, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
18946
19412
  var EMPTY_DRAFT = {
18947
19413
  key: "",
18948
19414
  authors: "",
@@ -18977,10 +19443,10 @@ function FieldSeparatorToggle({
18977
19443
  messages,
18978
19444
  onChange
18979
19445
  }) {
18980
- return /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-field butex-document-widget__refs-separator", children: [
18981
- /* @__PURE__ */ jsx17("span", { children: messages.referenceFieldSeparator }),
18982
- /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-separator-toggle", role: "group", "aria-label": messages.referenceFieldSeparator, children: [
18983
- /* @__PURE__ */ jsx17(
19446
+ return /* @__PURE__ */ jsxs17("div", { className: "butex-document-widget__refs-field butex-document-widget__refs-separator", children: [
19447
+ /* @__PURE__ */ jsx18("span", { children: messages.referenceFieldSeparator }),
19448
+ /* @__PURE__ */ jsxs17("div", { className: "butex-document-widget__refs-separator-toggle", role: "group", "aria-label": messages.referenceFieldSeparator, children: [
19449
+ /* @__PURE__ */ jsx18(
18984
19450
  "button",
18985
19451
  {
18986
19452
  type: "button",
@@ -18992,7 +19458,7 @@ function FieldSeparatorToggle({
18992
19458
  children: "\u060C"
18993
19459
  }
18994
19460
  ),
18995
- /* @__PURE__ */ jsx17(
19461
+ /* @__PURE__ */ jsx18(
18996
19462
  "button",
18997
19463
  {
18998
19464
  type: "button",
@@ -19020,22 +19486,22 @@ function ReferencePreview({
19020
19486
  digitForm
19021
19487
  }) {
19022
19488
  const body = bibliographyEntryBody({ authors, title, venue, year, fieldSeparator }, fieldSeparator, { digitForm });
19023
- return /* @__PURE__ */ jsxs16(
19489
+ return /* @__PURE__ */ jsxs17(
19024
19490
  "div",
19025
19491
  {
19026
19492
  className: "butex-document-widget__modal-preview",
19027
19493
  dir: uiLocaleDirection(uiLocale),
19028
19494
  "aria-label": messages.referencePreview,
19029
19495
  children: [
19030
- numberLabel ? /* @__PURE__ */ jsxs16("span", { className: "butex-document-widget__modal-preview-number", children: [
19496
+ numberLabel ? /* @__PURE__ */ jsxs17("span", { className: "butex-document-widget__modal-preview-number", children: [
19031
19497
  "[",
19032
19498
  numberLabel,
19033
19499
  "] "
19034
19500
  ] }) : null,
19035
- body.length > 0 ? body : /* @__PURE__ */ jsx17("span", { className: "butex-document-widget__cite-picker-empty", children: "\u2026" }),
19036
- url.trim().length > 0 ? /* @__PURE__ */ jsxs16(Fragment7, { children: [
19501
+ body.length > 0 ? body : /* @__PURE__ */ jsx18("span", { className: "butex-document-widget__cite-picker-empty", children: "\u2026" }),
19502
+ url.trim().length > 0 ? /* @__PURE__ */ jsxs17(Fragment7, { children: [
19037
19503
  " ",
19038
- /* @__PURE__ */ jsx17("span", { className: "butex-document-widget__modal-preview-url", children: url.trim() })
19504
+ /* @__PURE__ */ jsx18("span", { className: "butex-document-widget__modal-preview-url", children: url.trim() })
19039
19505
  ] }) : null
19040
19506
  ]
19041
19507
  }
@@ -19055,9 +19521,9 @@ function ReferencesPanel({
19055
19521
  onMove
19056
19522
  }) {
19057
19523
  const messages = documentMessages(uiLocale);
19058
- const [draft, setDraft] = useState12(EMPTY_DRAFT);
19059
- const [draftKeyTouched, setDraftKeyTouched] = useState12(false);
19060
- const [keyOverrides, setKeyOverrides] = useState12({});
19524
+ const [draft, setDraft] = useState13(EMPTY_DRAFT);
19525
+ const [draftKeyTouched, setDraftKeyTouched] = useState13(false);
19526
+ const [keyOverrides, setKeyOverrides] = useState13({});
19061
19527
  const dialogRef = useRef13(null);
19062
19528
  const draftSeparator = draft.field_separator === "," ? "," : DEFAULT_REFERENCE_FIELD_SEPARATOR;
19063
19529
  const documentDirection = uiLocale === "ar" ? "rtl" : "ltr";
@@ -19072,7 +19538,7 @@ function ReferencesPanel({
19072
19538
  if (!open) {
19073
19539
  return null;
19074
19540
  }
19075
- return /* @__PURE__ */ jsx17("div", { className: "butex-document-widget__refs-backdrop", role: "presentation", onClick: onClose, children: /* @__PURE__ */ jsxs16(
19541
+ return /* @__PURE__ */ jsx18("div", { className: "butex-document-widget__refs-backdrop", role: "presentation", onClick: onClose, children: /* @__PURE__ */ jsxs17(
19076
19542
  "div",
19077
19543
  {
19078
19544
  ref: dialogRef,
@@ -19083,17 +19549,17 @@ function ReferencesPanel({
19083
19549
  tabIndex: -1,
19084
19550
  onClick: (event) => event.stopPropagation(),
19085
19551
  children: [
19086
- /* @__PURE__ */ jsxs16("header", { className: "butex-document-widget__refs-header", children: [
19087
- /* @__PURE__ */ jsx17("strong", { children: messages.referencesTitle }),
19088
- /* @__PURE__ */ jsx17("button", { type: "button", "data-dialog-initial-focus": true, className: "butex-document-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
19552
+ /* @__PURE__ */ jsxs17("header", { className: "butex-document-widget__refs-header", children: [
19553
+ /* @__PURE__ */ jsx18("strong", { children: messages.referencesTitle }),
19554
+ /* @__PURE__ */ jsx18("button", { type: "button", "data-dialog-initial-focus": true, className: "butex-document-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
19089
19555
  ] }),
19090
- /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__dialog-body", children: [
19091
- /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-add", children: [
19092
- /* @__PURE__ */ jsx17("h3", { children: messages.addReference }),
19093
- /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-grid", children: [
19094
- REFERENCE_FIELDS.map(([field, messageKey]) => /* @__PURE__ */ jsxs16("label", { className: "butex-document-widget__refs-field", children: [
19095
- /* @__PURE__ */ jsx17("span", { children: messages[messageKey] }),
19096
- /* @__PURE__ */ jsx17(
19556
+ /* @__PURE__ */ jsxs17("div", { className: "butex-document-widget__dialog-body", children: [
19557
+ /* @__PURE__ */ jsxs17("div", { className: "butex-document-widget__refs-add", children: [
19558
+ /* @__PURE__ */ jsx18("h3", { children: messages.addReference }),
19559
+ /* @__PURE__ */ jsxs17("div", { className: "butex-document-widget__refs-grid", children: [
19560
+ REFERENCE_FIELDS.map(([field, messageKey]) => /* @__PURE__ */ jsxs17("label", { className: "butex-document-widget__refs-field", children: [
19561
+ /* @__PURE__ */ jsx18("span", { children: messages[messageKey] }),
19562
+ /* @__PURE__ */ jsx18(
19097
19563
  "input",
19098
19564
  {
19099
19565
  value: draft[field] ?? "",
@@ -19107,9 +19573,9 @@ function ReferencesPanel({
19107
19573
  }
19108
19574
  }
19109
19575
  ),
19110
- field === "key" && draftKeyTouched && draftKeyError !== null ? /* @__PURE__ */ jsx17("p", { className: "butex-document-widget__field-error", children: draftKeyError === "invalid" ? messages.keyRulesHint : keyErrorMessage4(draftKeyError, messages) }) : null
19576
+ field === "key" && draftKeyTouched && draftKeyError !== null ? /* @__PURE__ */ jsx18("p", { className: "butex-document-widget__field-error", children: draftKeyError === "invalid" ? messages.keyRulesHint : keyErrorMessage4(draftKeyError, messages) }) : null
19111
19577
  ] }, field)),
19112
- /* @__PURE__ */ jsx17(
19578
+ /* @__PURE__ */ jsx18(
19113
19579
  FieldSeparatorToggle,
19114
19580
  {
19115
19581
  value: draftSeparator,
@@ -19118,7 +19584,7 @@ function ReferencesPanel({
19118
19584
  }
19119
19585
  )
19120
19586
  ] }),
19121
- /* @__PURE__ */ jsx17(
19587
+ /* @__PURE__ */ jsx18(
19122
19588
  ReferencePreview,
19123
19589
  {
19124
19590
  authors: draft.authors ?? "",
@@ -19132,7 +19598,7 @@ function ReferencesPanel({
19132
19598
  digitForm
19133
19599
  }
19134
19600
  ),
19135
- /* @__PURE__ */ jsx17(
19601
+ /* @__PURE__ */ jsx18(
19136
19602
  "button",
19137
19603
  {
19138
19604
  type: "button",
@@ -19147,7 +19613,7 @@ function ReferencesPanel({
19147
19613
  }
19148
19614
  )
19149
19615
  ] }),
19150
- /* @__PURE__ */ jsx17("ul", { className: "butex-document-widget__refs-list", children: references.map((reference, index) => {
19616
+ /* @__PURE__ */ jsx18("ul", { className: "butex-document-widget__refs-list", children: references.map((reference, index) => {
19151
19617
  const displayedKey = keyOverrides[reference.id] ?? reference.key;
19152
19618
  const entryKeyError = documentKeyError(displayedKey, {
19153
19619
  references,
@@ -19155,17 +19621,17 @@ function ReferencesPanel({
19155
19621
  excludeReferenceId: reference.id
19156
19622
  });
19157
19623
  const numberLabel = formatBibliographyNumber(index + 1, { documentDirection, digitForm });
19158
- return /* @__PURE__ */ jsxs16("li", { className: "butex-document-widget__refs-item", children: [
19159
- /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-item-head", children: [
19160
- /* @__PURE__ */ jsxs16("strong", { children: [
19624
+ return /* @__PURE__ */ jsxs17("li", { className: "butex-document-widget__refs-item", children: [
19625
+ /* @__PURE__ */ jsxs17("div", { className: "butex-document-widget__refs-item-head", children: [
19626
+ /* @__PURE__ */ jsxs17("strong", { children: [
19161
19627
  "[",
19162
19628
  numberLabel,
19163
19629
  "] ",
19164
19630
  reference.key
19165
19631
  ] }),
19166
- /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-item-actions", children: [
19167
- /* @__PURE__ */ jsx17("button", { type: "button", title: messages.moveUp, "aria-label": messages.moveUp, disabled: index === 0, onClick: () => onMove(reference.id, -1), children: "\u2191" }),
19168
- /* @__PURE__ */ jsx17(
19632
+ /* @__PURE__ */ jsxs17("div", { className: "butex-document-widget__refs-item-actions", children: [
19633
+ /* @__PURE__ */ jsx18("button", { type: "button", title: messages.moveUp, "aria-label": messages.moveUp, disabled: index === 0, onClick: () => onMove(reference.id, -1), children: "\u2191" }),
19634
+ /* @__PURE__ */ jsx18(
19169
19635
  "button",
19170
19636
  {
19171
19637
  type: "button",
@@ -19176,10 +19642,10 @@ function ReferencesPanel({
19176
19642
  children: "\u2193"
19177
19643
  }
19178
19644
  ),
19179
- /* @__PURE__ */ jsx17("button", { type: "button", title: messages.deleteReference, "aria-label": messages.deleteReference, onClick: () => onRemove(reference.id), children: "\xD7" })
19645
+ /* @__PURE__ */ jsx18("button", { type: "button", title: messages.deleteReference, "aria-label": messages.deleteReference, onClick: () => onRemove(reference.id), children: "\xD7" })
19180
19646
  ] })
19181
19647
  ] }),
19182
- /* @__PURE__ */ jsx17(
19648
+ /* @__PURE__ */ jsx18(
19183
19649
  ReferencePreview,
19184
19650
  {
19185
19651
  authors: reference.authors,
@@ -19194,10 +19660,10 @@ function ReferencesPanel({
19194
19660
  digitForm
19195
19661
  }
19196
19662
  ),
19197
- /* @__PURE__ */ jsxs16("div", { className: "butex-document-widget__refs-grid", children: [
19198
- REFERENCE_FIELDS.map(([field, messageKey]) => /* @__PURE__ */ jsxs16("label", { className: "butex-document-widget__refs-field", children: [
19199
- /* @__PURE__ */ jsx17("span", { children: messages[messageKey] }),
19200
- /* @__PURE__ */ jsx17(
19663
+ /* @__PURE__ */ jsxs17("div", { className: "butex-document-widget__refs-grid", children: [
19664
+ REFERENCE_FIELDS.map(([field, messageKey]) => /* @__PURE__ */ jsxs17("label", { className: "butex-document-widget__refs-field", children: [
19665
+ /* @__PURE__ */ jsx18("span", { children: messages[messageKey] }),
19666
+ /* @__PURE__ */ jsx18(
19201
19667
  "input",
19202
19668
  {
19203
19669
  value: field === "key" ? displayedKey : reference[field],
@@ -19225,9 +19691,9 @@ function ReferencesPanel({
19225
19691
  }
19226
19692
  }
19227
19693
  ),
19228
- field === "key" && entryKeyError !== null ? /* @__PURE__ */ jsx17("p", { className: "butex-document-widget__field-error", children: entryKeyError === "invalid" ? messages.keyRulesHint : keyErrorMessage4(entryKeyError, messages) }) : null
19694
+ field === "key" && entryKeyError !== null ? /* @__PURE__ */ jsx18("p", { className: "butex-document-widget__field-error", children: entryKeyError === "invalid" ? messages.keyRulesHint : keyErrorMessage4(entryKeyError, messages) }) : null
19229
19695
  ] }, field)),
19230
- /* @__PURE__ */ jsx17(
19696
+ /* @__PURE__ */ jsx18(
19231
19697
  FieldSeparatorToggle,
19232
19698
  {
19233
19699
  value: reference.fieldSeparator,
@@ -19245,8 +19711,8 @@ function ReferencesPanel({
19245
19711
  }
19246
19712
 
19247
19713
  // src/react-document/RefPickerPopover.tsx
19248
- import { useEffect as useEffect12, useRef as useRef14, useState as useState13 } from "react";
19249
- import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
19714
+ import { useEffect as useEffect12, useRef as useRef14, useState as useState14 } from "react";
19715
+ import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
19250
19716
  function RefPickerPopover({
19251
19717
  open,
19252
19718
  targets,
@@ -19261,8 +19727,8 @@ function RefPickerPopover({
19261
19727
  }) {
19262
19728
  const messages = documentMessages(uiLocale);
19263
19729
  const documentDirection = uiLocale === "ar" ? "rtl" : "ltr";
19264
- const [selected, setSelected] = useState13(initialKeys);
19265
- const [refCommand, setRefCommand] = useState13(initialRefCommand);
19730
+ const [selected, setSelected] = useState14(initialKeys);
19731
+ const [refCommand, setRefCommand] = useState14(initialRefCommand);
19266
19732
  const dialogRef = useRef14(null);
19267
19733
  useDialogFocus({ open, dialogRef, onClose });
19268
19734
  useEffect12(() => {
@@ -19278,7 +19744,7 @@ function RefPickerPopover({
19278
19744
  setSelected([key]);
19279
19745
  setRefCommand(kind === "eq" ? "eqref" : "ref");
19280
19746
  }
19281
- return /* @__PURE__ */ jsx18("div", { className: "butex-document-widget__cite-picker-backdrop", role: "presentation", onClick: onClose, children: /* @__PURE__ */ jsxs17(
19747
+ return /* @__PURE__ */ jsx19("div", { className: "butex-document-widget__cite-picker-backdrop", role: "presentation", onClick: onClose, children: /* @__PURE__ */ jsxs18(
19282
19748
  "div",
19283
19749
  {
19284
19750
  ref: dialogRef,
@@ -19289,30 +19755,30 @@ function RefPickerPopover({
19289
19755
  tabIndex: -1,
19290
19756
  onClick: (event) => event.stopPropagation(),
19291
19757
  children: [
19292
- /* @__PURE__ */ jsxs17("header", { className: "butex-document-widget__cite-picker-header", children: [
19293
- /* @__PURE__ */ jsx18("strong", { children: messages.refPickerTitle }),
19294
- /* @__PURE__ */ jsx18("button", { type: "button", "data-dialog-initial-focus": true, className: "butex-document-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
19758
+ /* @__PURE__ */ jsxs18("header", { className: "butex-document-widget__cite-picker-header", children: [
19759
+ /* @__PURE__ */ jsx19("strong", { children: messages.refPickerTitle }),
19760
+ /* @__PURE__ */ jsx19("button", { type: "button", "data-dialog-initial-focus": true, className: "butex-document-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
19295
19761
  ] }),
19296
- /* @__PURE__ */ jsx18("div", { className: "butex-document-widget__dialog-body", children: targets.length === 0 ? /* @__PURE__ */ jsx18("p", { className: "butex-document-widget__cite-picker-empty", children: messages.noLabelsYet }) : /* @__PURE__ */ jsx18("ul", { className: "butex-document-widget__cite-picker-list", children: targets.filter((entry) => entry.number !== null || Boolean(entry.displayLabel) || entry.kind === "eq").map((entry) => {
19762
+ /* @__PURE__ */ jsx19("div", { className: "butex-document-widget__dialog-body", children: targets.length === 0 ? /* @__PURE__ */ jsx19("p", { className: "butex-document-widget__cite-picker-empty", children: messages.noLabelsYet }) : /* @__PURE__ */ jsx19("ul", { className: "butex-document-widget__cite-picker-list", children: targets.filter((entry) => entry.number !== null || Boolean(entry.displayLabel) || entry.kind === "eq").map((entry) => {
19297
19763
  const checked = selected.includes(entry.key) || Boolean(entry.manualKey && selected.includes(entry.manualKey));
19298
19764
  const title = entry.displayLabel ?? (entry.number === null ? uiLocale === "ar" ? "\u0645\u0639\u0627\u062F\u0644\u0629 \u063A\u064A\u0631 \u0645\u0631\u0642\u0645\u0629" : "Unnumbered equation" : formatFloatCaptionTitle(entry.kind, entry.number, {
19299
19765
  uiLocale,
19300
19766
  digitForm,
19301
19767
  documentDirection
19302
19768
  }));
19303
- return /* @__PURE__ */ jsx18("li", { children: /* @__PURE__ */ jsxs17("label", { className: "butex-document-widget__cite-picker-item", children: [
19304
- /* @__PURE__ */ jsx18("input", { type: "radio", name: "butex-ref-key", checked, disabled: entry.number === null && !entry.displayLabel, onChange: () => selectKey(entry.key, entry.kind) }),
19305
- /* @__PURE__ */ jsxs17("span", { children: [
19306
- /* @__PURE__ */ jsx18("strong", { children: entry.kind === "eq" && entry.number !== null ? title.replace(/(\d+|[٠-٩]+)$/, "($1)") : title }),
19307
- entry.caption ? /* @__PURE__ */ jsx18("span", { className: "butex-document-widget__cite-picker-meta", children: entry.caption }) : null,
19308
- entry.kind === "eq" && entry.number === null && onNumberEquation ? /* @__PURE__ */ jsx18("button", { type: "button", onClick: () => onNumberEquation(entry.ownerId), children: uiLocale === "ar" ? "\u0631\u0642\u0651\u0645 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u0623\u0648\u0644\u0627\u064B" : "Number equation first" }) : null
19769
+ return /* @__PURE__ */ jsx19("li", { children: /* @__PURE__ */ jsxs18("label", { className: "butex-document-widget__cite-picker-item", children: [
19770
+ /* @__PURE__ */ jsx19("input", { type: "radio", name: "butex-ref-key", checked, disabled: entry.number === null && !entry.displayLabel, onChange: () => selectKey(entry.key, entry.kind) }),
19771
+ /* @__PURE__ */ jsxs18("span", { children: [
19772
+ /* @__PURE__ */ jsx19("strong", { children: entry.kind === "eq" && entry.number !== null ? title.replace(/(\d+|[٠-٩]+)$/, "($1)") : title }),
19773
+ entry.caption ? /* @__PURE__ */ jsx19("span", { className: "butex-document-widget__cite-picker-meta", children: entry.caption }) : null,
19774
+ entry.kind === "eq" && entry.number === null && onNumberEquation ? /* @__PURE__ */ jsx19("button", { type: "button", onClick: () => onNumberEquation(entry.ownerId), children: uiLocale === "ar" ? "\u0631\u0642\u0651\u0645 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u0623\u0648\u0644\u0627\u064B" : "Number equation first" }) : null
19309
19775
  ] })
19310
19776
  ] }) }, `${entry.kind}:${entry.ownerId}`);
19311
19777
  }) }) }),
19312
- /* @__PURE__ */ jsxs17("footer", { className: "butex-document-widget__cite-picker-footer", children: [
19313
- onManageLabels ? /* @__PURE__ */ jsx18("button", { type: "button", onClick: onManageLabels, children: messages.manageLabels }) : null,
19314
- /* @__PURE__ */ jsx18("button", { type: "button", onClick: onClose, children: messages.close }),
19315
- /* @__PURE__ */ jsx18(
19778
+ /* @__PURE__ */ jsxs18("footer", { className: "butex-document-widget__cite-picker-footer", children: [
19779
+ onManageLabels ? /* @__PURE__ */ jsx19("button", { type: "button", onClick: onManageLabels, children: messages.manageLabels }) : null,
19780
+ /* @__PURE__ */ jsx19("button", { type: "button", onClick: onClose, children: messages.close }),
19781
+ /* @__PURE__ */ jsx19(
19316
19782
  "button",
19317
19783
  {
19318
19784
  type: "button",
@@ -19569,91 +20035,6 @@ var DOCUMENT_WIDGET_CSS = `
19569
20035
  scrollbar-width: thin;
19570
20036
  }
19571
20037
 
19572
- .butex-document-widget__command-sheet-backdrop {
19573
- align-items: flex-end;
19574
- background: color-mix(in srgb, #000 35%, transparent);
19575
- display: flex;
19576
- inset: 0;
19577
- justify-content: center;
19578
- padding-bottom: var(--butex-safe-area-bottom);
19579
- padding-left: max(12px, var(--butex-safe-area-left));
19580
- padding-right: max(12px, var(--butex-safe-area-right));
19581
- padding-top: max(12px, var(--butex-safe-area-top));
19582
- position: fixed;
19583
- z-index: var(--butex-document-z-popover);
19584
- }
19585
-
19586
- .butex-document-widget__command-sheet {
19587
- background: var(--butex-document-panel);
19588
- border: 1px solid var(--butex-document-border);
19589
- border-radius: 16px 16px 0 0;
19590
- box-shadow: 0 -16px 40px color-mix(in srgb, #000 22%, transparent);
19591
- display: grid;
19592
- grid-template-rows: auto minmax(0, 1fr);
19593
- max-height: min(78vh, 720px);
19594
- max-height: min(720px, calc(100dvh - max(12px, var(--butex-safe-area-top)) - var(--butex-safe-area-bottom)));
19595
- max-width: 640px;
19596
- min-width: 0;
19597
- overflow: hidden;
19598
- width: 100%;
19599
- }
19600
-
19601
- .butex-document-widget__command-sheet-header {
19602
- align-items: center;
19603
- border-block-end: 1px solid var(--butex-document-border);
19604
- display: flex;
19605
- gap: 8px;
19606
- justify-content: space-between;
19607
- min-width: 0;
19608
- padding: 10px 12px;
19609
- }
19610
-
19611
- .butex-document-widget__command-sheet-body {
19612
- display: grid;
19613
- gap: 12px;
19614
- min-height: 0;
19615
- min-width: 0;
19616
- overflow-y: auto;
19617
- overscroll-behavior: contain;
19618
- padding: 12px;
19619
- }
19620
-
19621
- .butex-document-widget__command-group {
19622
- border: 1px solid var(--butex-document-border);
19623
- border-radius: 10px;
19624
- display: grid;
19625
- gap: 8px;
19626
- min-width: 0;
19627
- padding: 10px;
19628
- }
19629
-
19630
- .butex-document-widget__command-group h3 {
19631
- font-size: 0.88rem;
19632
- margin: 0;
19633
- }
19634
-
19635
- .butex-document-widget__command-grid {
19636
- display: grid;
19637
- gap: 6px;
19638
- grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
19639
- min-width: 0;
19640
- }
19641
-
19642
- .butex-document-widget__command-grid button {
19643
- min-height: 44px;
19644
- overflow-wrap: anywhere;
19645
- text-align: start;
19646
- }
19647
-
19648
- .butex-document-widget__command-grid--digits button {
19649
- text-align: center;
19650
- }
19651
-
19652
- .butex-document-widget__command-grid [aria-selected="true"] {
19653
- background: var(--butex-document-accent-bg);
19654
- border-color: var(--butex-document-accent);
19655
- }
19656
-
19657
20038
  .butex-document-widget__command-subtitle {
19658
20039
  color: var(--butex-document-muted);
19659
20040
  font-size: 0.82rem;
@@ -20544,15 +20925,6 @@ var DOCUMENT_WIDGET_CSS = `
20544
20925
  z-index: var(--butex-document-z-equation);
20545
20926
  }
20546
20927
 
20547
- .butex-document-widget__equation-modal[data-visible-viewport="true"] {
20548
- bottom: auto;
20549
- height: var(--butex-document-visible-viewport-height);
20550
- left: var(--butex-document-visible-viewport-left);
20551
- right: auto;
20552
- top: var(--butex-document-visible-viewport-top);
20553
- width: var(--butex-document-visible-viewport-width);
20554
- }
20555
-
20556
20928
  .butex-document-widget__equation-modal-backdrop {
20557
20929
  background: color-mix(in srgb, var(--butex-document-fg) 34%, transparent);
20558
20930
  border: 0;
@@ -21495,7 +21867,7 @@ var DOCUMENT_WIDGET_CSS = `
21495
21867
  width: 100%;
21496
21868
  }
21497
21869
 
21498
- .butex-document-widget__equation-modal[data-visible-viewport="true"] .butex-document-widget__equation-modal-panel {
21870
+ .butex-mobile-command-portal .butex-document-widget__equation-modal-panel {
21499
21871
  height: 100%;
21500
21872
  max-height: 100%;
21501
21873
  }
@@ -21533,21 +21905,6 @@ var DOCUMENT_WIDGET_CSS = `
21533
21905
  min-height: 44px;
21534
21906
  }
21535
21907
 
21536
- .butex-document-widget__command-sheet-backdrop {
21537
- padding-bottom: var(--butex-safe-area-bottom);
21538
- padding-left: var(--butex-safe-area-left);
21539
- padding-right: var(--butex-safe-area-right);
21540
- padding-top: max(8px, var(--butex-safe-area-top));
21541
- }
21542
-
21543
- .butex-document-widget__command-sheet {
21544
- border-block-end: 0;
21545
- border-radius: 16px 16px 0 0;
21546
- max-height: calc(100vh - 8px);
21547
- max-height: calc(100dvh - max(8px, var(--butex-safe-area-top)) - var(--butex-safe-area-bottom));
21548
- max-width: none;
21549
- }
21550
-
21551
21908
  .butex-document-widget__article-meta-date,
21552
21909
  .butex-document-widget__refs-grid {
21553
21910
  grid-template-columns: minmax(0, 1fr);
@@ -21631,6 +21988,11 @@ var DOCUMENT_WIDGET_CSS = `
21631
21988
  padding-top: max(8px, var(--butex-safe-area-top));
21632
21989
  }
21633
21990
 
21991
+ .butex-mobile-command-portal .butex-document-widget__equation-modal-panel {
21992
+ height: 100%;
21993
+ max-height: 100%;
21994
+ }
21995
+
21634
21996
  .butex-document-widget__cite-picker,
21635
21997
  .butex-document-widget__refs-panel {
21636
21998
  border-block-end: 0;
@@ -21671,7 +22033,7 @@ function injectBuTeXDocumentStyles(doc) {
21671
22033
  }
21672
22034
 
21673
22035
  // src/react-document/ButexDocumentEditor.tsx
21674
- import { Fragment as Fragment8, jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
22036
+ import { Fragment as Fragment8, jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
21675
22037
  function mathDelimiters(mode) {
21676
22038
  return mode === "inline" ? { opening: "$", closing: "$" } : { opening: "\\[", closing: "\\]" };
21677
22039
  }
@@ -21976,25 +22338,25 @@ var ButexDocumentEditor = forwardRef2(
21976
22338
  () => resolveInitialDocument(initialDocument, uiLocale, documentMeta),
21977
22339
  [initialDocument, documentMeta, uiLocale]
21978
22340
  );
21979
- const [documentNode, setDocumentNode] = useState14(initialState.document);
21980
- const [error, setError] = useState14(initialState.error);
21981
- const [editorOpen, setEditorOpen] = useState14(true);
21982
- const [previewOpen, setPreviewOpen] = useState14(true);
21983
- const [mobileView, setMobileView] = useState14("editor");
21984
- const [mobileViewAnnouncement, setMobileViewAnnouncement] = useState14("");
21985
- const [selectedMath, setSelectedMath] = useState14(null);
21986
- const [citePicker, setCitePicker] = useState14(null);
21987
- const [referencesOpen, setReferencesOpen] = useState14(false);
21988
- const [labelsOpen, setLabelsOpen] = useState14(false);
21989
- const [refPicker, setRefPicker] = useState14(null);
21990
- const [digitFormState, setDigitFormState] = useState14(null);
21991
- const [debugImportOpen, setDebugImportOpen] = useState14(false);
21992
- const [debugImportText, setDebugImportText] = useState14("");
21993
- const [debugImportError, setDebugImportError] = useState14("");
21994
- const [editorFocus, setEditorFocus] = useState14(createEmptyDocumentEditorFocus());
21995
- const [collapsedBlockIds, setCollapsedBlockIds] = useState14(() => /* @__PURE__ */ new Set());
21996
- const [blockSelectionState, setBlockSelectionState] = useState14(emptyBlockSelection);
21997
- const [historyTick, setHistoryTick] = useState14(0);
22341
+ const [documentNode, setDocumentNode] = useState15(initialState.document);
22342
+ const [error, setError] = useState15(initialState.error);
22343
+ const [editorOpen, setEditorOpen] = useState15(true);
22344
+ const [previewOpen, setPreviewOpen] = useState15(true);
22345
+ const [mobileView, setMobileView] = useState15("editor");
22346
+ const [mobileViewAnnouncement, setMobileViewAnnouncement] = useState15("");
22347
+ const [selectedMath, setSelectedMath] = useState15(null);
22348
+ const [citePicker, setCitePicker] = useState15(null);
22349
+ const [referencesOpen, setReferencesOpen] = useState15(false);
22350
+ const [labelsOpen, setLabelsOpen] = useState15(false);
22351
+ const [refPicker, setRefPicker] = useState15(null);
22352
+ const [digitFormState, setDigitFormState] = useState15(null);
22353
+ const [debugImportOpen, setDebugImportOpen] = useState15(false);
22354
+ const [debugImportText, setDebugImportText] = useState15("");
22355
+ const [debugImportError, setDebugImportError] = useState15("");
22356
+ const [editorFocus, setEditorFocus] = useState15(createEmptyDocumentEditorFocus());
22357
+ const [collapsedBlockIds, setCollapsedBlockIds] = useState15(() => /* @__PURE__ */ new Set());
22358
+ const [blockSelectionState, setBlockSelectionState] = useState15(emptyBlockSelection);
22359
+ const [historyTick, setHistoryTick] = useState15(0);
21998
22360
  const digitForm = digitFormProp ?? digitFormState ?? (documentDirection === "rtl" ? "arabicIndic" : "western");
21999
22361
  function equationSessionWithDocumentDigits(session) {
22000
22362
  return setCurrentDigitForm(session, digitForm);
@@ -22743,7 +23105,7 @@ var ButexDocumentEditor = forwardRef2(
22743
23105
  }
22744
23106
  const showEditorPanel = !previewOnly && editorOpen;
22745
23107
  const showPreviewPanel = previewOnly || previewOpen;
22746
- return /* @__PURE__ */ jsx19(
23108
+ return /* @__PURE__ */ jsx20(
22747
23109
  "div",
22748
23110
  {
22749
23111
  ref: widgetRef,
@@ -22752,9 +23114,9 @@ var ButexDocumentEditor = forwardRef2(
22752
23114
  "data-responsive-mode": responsiveMode,
22753
23115
  dir: uiLocaleDirection(uiLocale),
22754
23116
  lang: uiLocale,
22755
- children: /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__shell", children: [
22756
- !previewOnly ? /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__toolbar", children: [
22757
- /* @__PURE__ */ jsx19(
23117
+ children: /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__shell", children: [
23118
+ !previewOnly ? /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__toolbar", children: [
23119
+ /* @__PURE__ */ jsx20(
22758
23120
  DocumentInsertToolbar,
22759
23121
  {
22760
23122
  mode,
@@ -22793,7 +23155,7 @@ var ButexDocumentEditor = forwardRef2(
22793
23155
  onDigitFormChange: changeDigitForm
22794
23156
  }
22795
23157
  ),
22796
- /* @__PURE__ */ jsx19(
23158
+ /* @__PURE__ */ jsx20(
22797
23159
  DocumentMobileToolbar,
22798
23160
  {
22799
23161
  mode,
@@ -22836,7 +23198,7 @@ var ButexDocumentEditor = forwardRef2(
22836
23198
  onOpenAll: openAllBlocks
22837
23199
  }
22838
23200
  ),
22839
- /* @__PURE__ */ jsx19(
23201
+ /* @__PURE__ */ jsx20(
22840
23202
  "span",
22841
23203
  {
22842
23204
  className: "butex-document-widget__sr-only",
@@ -22846,29 +23208,29 @@ var ButexDocumentEditor = forwardRef2(
22846
23208
  children: mobileViewAnnouncement
22847
23209
  }
22848
23210
  ),
22849
- /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__toolbar-group butex-document-widget__desktop-toolbar-control", role: "group", "aria-label": messages.panels, children: [
22850
- /* @__PURE__ */ jsx19("button", { type: "button", "aria-pressed": editorOpen, onClick: toggleEditorPanel, children: editorOpen ? messages.hideEditor : messages.editor }),
22851
- /* @__PURE__ */ jsx19("button", { type: "button", "aria-pressed": previewOpen, onClick: togglePreviewPanel, children: previewOpen ? messages.hidePreview : messages.preview })
23211
+ /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__toolbar-group butex-document-widget__desktop-toolbar-control", role: "group", "aria-label": messages.panels, children: [
23212
+ /* @__PURE__ */ jsx20("button", { type: "button", "aria-pressed": editorOpen, onClick: toggleEditorPanel, children: editorOpen ? messages.hideEditor : messages.editor }),
23213
+ /* @__PURE__ */ jsx20("button", { type: "button", "aria-pressed": previewOpen, onClick: togglePreviewPanel, children: previewOpen ? messages.hidePreview : messages.preview })
22852
23214
  ] }),
22853
- /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__toolbar-group butex-document-widget__desktop-toolbar-control", role: "group", "aria-label": messages.collapseBlocks, children: [
22854
- /* @__PURE__ */ jsx19("button", { type: "button", onClick: collapseAllBlocks, children: messages.collapseAll }),
22855
- /* @__PURE__ */ jsx19("button", { type: "button", onClick: openAllBlocks, children: messages.openAll })
23215
+ /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__toolbar-group butex-document-widget__desktop-toolbar-control", role: "group", "aria-label": messages.collapseBlocks, children: [
23216
+ /* @__PURE__ */ jsx20("button", { type: "button", onClick: collapseAllBlocks, children: messages.collapseAll }),
23217
+ /* @__PURE__ */ jsx20("button", { type: "button", onClick: openAllBlocks, children: messages.openAll })
22856
23218
  ] })
22857
23219
  ] }) : null,
22858
- error ? /* @__PURE__ */ jsx19("p", { className: "butex-document-widget__error", children: error }) : null,
22859
- /* @__PURE__ */ jsxs18(
23220
+ error ? /* @__PURE__ */ jsx20("p", { className: "butex-document-widget__error", children: error }) : null,
23221
+ /* @__PURE__ */ jsxs19(
22860
23222
  "div",
22861
23223
  {
22862
23224
  className: `butex-document-widget__layout butex-document-widget__layout--editor-${showEditorPanel ? "open" : "closed"} butex-document-widget__layout--preview-${showPreviewPanel ? "open" : "closed"}`,
22863
23225
  children: [
22864
- !previewOnly ? /* @__PURE__ */ jsx19(
23226
+ !previewOnly ? /* @__PURE__ */ jsx20(
22865
23227
  "section",
22866
23228
  {
22867
23229
  className: "butex-document-widget__panel butex-document-widget__editor-panel",
22868
23230
  "aria-label": messages.documentEditor,
22869
23231
  "aria-hidden": !showEditorPanel,
22870
- children: /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__blocks", children: [
22871
- mode === "article" ? /* @__PURE__ */ jsx19(
23232
+ children: /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__blocks", children: [
23233
+ mode === "article" ? /* @__PURE__ */ jsx20(
22872
23234
  ArticleMetaPanel,
22873
23235
  {
22874
23236
  meta: documentNode.meta ?? emptyDocumentMeta(),
@@ -22881,8 +23243,8 @@ var ButexDocumentEditor = forwardRef2(
22881
23243
  }
22882
23244
  }
22883
23245
  ) : null,
22884
- mode === "book-content" && documentNode.blocks.some((block) => block.kind === "bibliography") ? /* @__PURE__ */ jsx19("p", { role: "alert", className: "butex-document-widget__error", children: uiLocale === "ar" ? "\u062A\u0633\u062A\u062E\u062F\u0645 \u0641\u0635\u0648\u0644 \u0627\u0644\u0643\u062A\u0627\u0628 \u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0627\u062C\u0639 \u0645\u0634\u062A\u0631\u0643\u0629\u061B \u0623\u0632\u0644 \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0645\u0631\u0627\u062C\u0639 \u0627\u0644\u0645\u062D\u0644\u064A\u0629 \u0645\u0646 \u0627\u0644\u0641\u0635\u0644." : "Book chapters use the shared bibliography. Remove the local bibliography block." }) : null,
22885
- documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ jsx19(
23246
+ mode === "book-content" && documentNode.blocks.some((block) => block.kind === "bibliography") ? /* @__PURE__ */ jsx20("p", { role: "alert", className: "butex-document-widget__error", children: uiLocale === "ar" ? "\u062A\u0633\u062A\u062E\u062F\u0645 \u0641\u0635\u0648\u0644 \u0627\u0644\u0643\u062A\u0627\u0628 \u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0627\u062C\u0639 \u0645\u0634\u062A\u0631\u0643\u0629\u061B \u0623\u0632\u0644 \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0645\u0631\u0627\u062C\u0639 \u0627\u0644\u0645\u062D\u0644\u064A\u0629 \u0645\u0646 \u0627\u0644\u0641\u0635\u0644." : "Book chapters use the shared bibliography. Remove the local bibliography block." }) : null,
23247
+ documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ jsx20(
22886
23248
  BlockEditor,
22887
23249
  {
22888
23250
  block,
@@ -22957,13 +23319,13 @@ var ButexDocumentEditor = forwardRef2(
22957
23319
  ] })
22958
23320
  }
22959
23321
  ) : null,
22960
- /* @__PURE__ */ jsx19(
23322
+ /* @__PURE__ */ jsx20(
22961
23323
  "section",
22962
23324
  {
22963
23325
  className: "butex-document-widget__panel butex-document-widget__preview-panel",
22964
23326
  "aria-label": messages.documentPreview,
22965
23327
  "aria-hidden": !showPreviewPanel,
22966
- children: /* @__PURE__ */ jsx19(
23328
+ children: /* @__PURE__ */ jsx20(
22967
23329
  DocumentPreview,
22968
23330
  {
22969
23331
  blocks: preview.blocks,
@@ -22979,18 +23341,18 @@ var ButexDocumentEditor = forwardRef2(
22979
23341
  ]
22980
23342
  }
22981
23343
  ),
22982
- debugEnabled ? /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__dev", children: [
22983
- debugEnabled && documentNode.diagnostics.length > 0 ? /* @__PURE__ */ jsxs18(Fragment8, { children: [
22984
- /* @__PURE__ */ jsx19("strong", { children: messages.importWarnings }),
22985
- documentNode.diagnostics.map((diagnostic) => /* @__PURE__ */ jsx19("p", { className: "butex-document-widget__dev-diagnostic", children: formatDocumentDiagnostic(diagnostic, messages) }, `${diagnostic.path}-${diagnostic.message}`))
23344
+ debugEnabled ? /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__dev", children: [
23345
+ debugEnabled && documentNode.diagnostics.length > 0 ? /* @__PURE__ */ jsxs19(Fragment8, { children: [
23346
+ /* @__PURE__ */ jsx20("strong", { children: messages.importWarnings }),
23347
+ documentNode.diagnostics.map((diagnostic) => /* @__PURE__ */ jsx20("p", { className: "butex-document-widget__dev-diagnostic", children: formatDocumentDiagnostic(diagnostic, messages) }, `${diagnostic.path}-${diagnostic.message}`))
22986
23348
  ] }) : null,
22987
- /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__dev-actions", children: [
22988
- /* @__PURE__ */ jsx19("button", { type: "button", onClick: () => void copyDebugText(JSON.stringify(documentJson, null, 2)), children: "Copy JSON" }),
22989
- /* @__PURE__ */ jsx19("button", { type: "button", onClick: () => void copyDebugText(latex), children: "Copy TeX" }),
22990
- /* @__PURE__ */ jsx19("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugJsonImport, children: "Import JSON" })
23349
+ /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__dev-actions", children: [
23350
+ /* @__PURE__ */ jsx20("button", { type: "button", onClick: () => void copyDebugText(JSON.stringify(documentJson, null, 2)), children: "Copy JSON" }),
23351
+ /* @__PURE__ */ jsx20("button", { type: "button", onClick: () => void copyDebugText(latex), children: "Copy TeX" }),
23352
+ /* @__PURE__ */ jsx20("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugJsonImport, children: "Import JSON" })
22991
23353
  ] }),
22992
- debugImportOpen ? /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__dev-import", children: [
22993
- /* @__PURE__ */ jsx19(
23354
+ debugImportOpen ? /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__dev-import", children: [
23355
+ /* @__PURE__ */ jsx20(
22994
23356
  "textarea",
22995
23357
  {
22996
23358
  value: debugImportText,
@@ -23002,9 +23364,9 @@ var ButexDocumentEditor = forwardRef2(
23002
23364
  }
23003
23365
  }
23004
23366
  ),
23005
- /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__dev-actions", children: [
23006
- /* @__PURE__ */ jsx19("button", { type: "button", onClick: applyDebugJsonImport, children: "Apply" }),
23007
- /* @__PURE__ */ jsx19(
23367
+ /* @__PURE__ */ jsxs19("div", { className: "butex-document-widget__dev-actions", children: [
23368
+ /* @__PURE__ */ jsx20("button", { type: "button", onClick: applyDebugJsonImport, children: "Apply" }),
23369
+ /* @__PURE__ */ jsx20(
23008
23370
  "button",
23009
23371
  {
23010
23372
  type: "button",
@@ -23016,18 +23378,19 @@ var ButexDocumentEditor = forwardRef2(
23016
23378
  }
23017
23379
  )
23018
23380
  ] }),
23019
- debugImportError ? /* @__PURE__ */ jsx19("p", { className: "butex-document-widget__dev-error", children: debugImportError }) : null
23381
+ debugImportError ? /* @__PURE__ */ jsx20("p", { className: "butex-document-widget__dev-error", children: debugImportError }) : null
23020
23382
  ] }) : null,
23021
- /* @__PURE__ */ jsx19("strong", { children: "LaTeX" }),
23022
- /* @__PURE__ */ jsx19("pre", { children: latex }),
23023
- /* @__PURE__ */ jsx19("strong", { children: "JSON" }),
23024
- /* @__PURE__ */ jsx19("pre", { children: JSON.stringify(documentJson, null, 2) }),
23025
- /* @__PURE__ */ jsx19("strong", { children: "AST" }),
23026
- /* @__PURE__ */ jsx19("pre", { children: JSON.stringify(documentNode, null, 2) })
23383
+ /* @__PURE__ */ jsx20("strong", { children: "LaTeX" }),
23384
+ /* @__PURE__ */ jsx20("pre", { children: latex }),
23385
+ /* @__PURE__ */ jsx20("strong", { children: "JSON" }),
23386
+ /* @__PURE__ */ jsx20("pre", { children: JSON.stringify(documentJson, null, 2) }),
23387
+ /* @__PURE__ */ jsx20("strong", { children: "AST" }),
23388
+ /* @__PURE__ */ jsx20("pre", { children: JSON.stringify(documentNode, null, 2) })
23027
23389
  ] }) : null,
23028
- !previewOnly && selectedMath ? /* @__PURE__ */ jsx19(
23390
+ !previewOnly && selectedMath ? /* @__PURE__ */ jsx20(
23029
23391
  EquationDrawer,
23030
23392
  {
23393
+ sourceRef: widgetRef,
23031
23394
  debug: debugEnabled,
23032
23395
  session: selectedMath.session,
23033
23396
  reason: selectedMath.reason,
@@ -23051,7 +23414,7 @@ var ButexDocumentEditor = forwardRef2(
23051
23414
  onDelete: deleteSelectedEquation
23052
23415
  }
23053
23416
  ) : null,
23054
- !previewOnly ? /* @__PURE__ */ jsx19(
23417
+ !previewOnly ? /* @__PURE__ */ jsx20(
23055
23418
  CitePickerPopover,
23056
23419
  {
23057
23420
  open: citePicker !== null,
@@ -23067,7 +23430,7 @@ var ButexDocumentEditor = forwardRef2(
23067
23430
  } : void 0
23068
23431
  }
23069
23432
  ) : null,
23070
- !previewOnly ? /* @__PURE__ */ jsx19(
23433
+ !previewOnly ? /* @__PURE__ */ jsx20(
23071
23434
  RefPickerPopover,
23072
23435
  {
23073
23436
  open: refPicker !== null,
@@ -23087,7 +23450,7 @@ var ButexDocumentEditor = forwardRef2(
23087
23450
  }
23088
23451
  }
23089
23452
  ) : null,
23090
- !previewOnly && mode === "article" ? /* @__PURE__ */ jsx19(
23453
+ !previewOnly && mode === "article" ? /* @__PURE__ */ jsx20(
23091
23454
  ReferencesPanel,
23092
23455
  {
23093
23456
  open: referencesOpen,
@@ -23103,7 +23466,7 @@ var ButexDocumentEditor = forwardRef2(
23103
23466
  onMove: (referenceId, direction) => applyDocument(moveDocumentReference(documentRef.current, referenceId, direction), "immediate")
23104
23467
  }
23105
23468
  ) : null,
23106
- !previewOnly ? /* @__PURE__ */ jsx19(
23469
+ !previewOnly ? /* @__PURE__ */ jsx20(
23107
23470
  LabelsPanel,
23108
23471
  {
23109
23472
  open: labelsOpen,
@@ -23128,7 +23491,7 @@ var ButexDocumentEditor = forwardRef2(
23128
23491
  ButexDocumentEditor.displayName = "ButexDocumentEditor";
23129
23492
 
23130
23493
  // src/react-document/ValidatedButexDocumentEditor.tsx
23131
- import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
23494
+ import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
23132
23495
  function imageValidationMessage(uiLocale) {
23133
23496
  return uiLocale === "ar" ? "\u0644\u0645 \u062A\u064F\u062D\u062F\u0651\u062F \u0635\u0648\u0631\u0629 \u0644\u0647\u0630\u0647 \u0627\u0644\u0643\u062A\u0644\u0629." : "No image has been selected for this block.";
23134
23497
  }
@@ -23187,7 +23550,7 @@ var ButexDocumentEditor3 = forwardRef3(
23187
23550
  return rendered;
23188
23551
  }
23189
23552
  const errorId = `butex-document-image-validation-${ctx.blockId}`;
23190
- return /* @__PURE__ */ jsxs19(
23553
+ return /* @__PURE__ */ jsxs20(
23191
23554
  "div",
23192
23555
  {
23193
23556
  role: "group",
@@ -23201,14 +23564,14 @@ var ButexDocumentEditor3 = forwardRef3(
23201
23564
  },
23202
23565
  children: [
23203
23566
  rendered,
23204
- /* @__PURE__ */ jsx20("p", { id: errorId, className: "butex-document-widget__field-error", children: imageValidationMessage(ctx.uiLocale) })
23567
+ /* @__PURE__ */ jsx21("p", { id: errorId, className: "butex-document-widget__field-error", children: imageValidationMessage(ctx.uiLocale) })
23205
23568
  ]
23206
23569
  }
23207
23570
  );
23208
23571
  },
23209
23572
  [renderImageBlockEditor]
23210
23573
  );
23211
- return /* @__PURE__ */ jsx20(
23574
+ return /* @__PURE__ */ jsx21(
23212
23575
  ButexDocumentEditor,
23213
23576
  {
23214
23577
  ref,
@@ -23227,7 +23590,7 @@ ButexDocumentEditor3.displayName = "ButexDocumentEditor";
23227
23590
 
23228
23591
  // src/react-document/ButexDocumentPreview.tsx
23229
23592
  import { useEffect as useEffect14, useMemo as useMemo3 } from "react";
23230
- import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
23593
+ import { jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
23231
23594
  function isRecord2(value) {
23232
23595
  return typeof value === "object" && value !== null;
23233
23596
  }
@@ -23302,20 +23665,20 @@ function ButexDocumentPreview({
23302
23665
  useEffect14(() => {
23303
23666
  injectBuTeXDocumentStyles();
23304
23667
  }, []);
23305
- return /* @__PURE__ */ jsx21(
23668
+ return /* @__PURE__ */ jsx22(
23306
23669
  "div",
23307
23670
  {
23308
23671
  className: ["butex-document-widget", "butex-document-preview", className].filter(Boolean).join(" "),
23309
23672
  dir: uiLocaleDirection(uiLocale),
23310
23673
  lang: uiLocale,
23311
- children: /* @__PURE__ */ jsxs20("div", { className: "butex-document-widget__shell", children: [
23312
- previewState.error ? /* @__PURE__ */ jsx21("p", { className: "butex-document-widget__error", children: previewState.error }) : null,
23313
- /* @__PURE__ */ jsx21("div", { className: "butex-document-widget__layout butex-document-widget__layout--editor-closed butex-document-widget__layout--preview-open", children: /* @__PURE__ */ jsx21(
23674
+ children: /* @__PURE__ */ jsxs21("div", { className: "butex-document-widget__shell", children: [
23675
+ previewState.error ? /* @__PURE__ */ jsx22("p", { className: "butex-document-widget__error", children: previewState.error }) : null,
23676
+ /* @__PURE__ */ jsx22("div", { className: "butex-document-widget__layout butex-document-widget__layout--editor-closed butex-document-widget__layout--preview-open", children: /* @__PURE__ */ jsx22(
23314
23677
  "section",
23315
23678
  {
23316
23679
  className: "butex-document-widget__panel butex-document-widget__preview-panel",
23317
23680
  "aria-label": messages.documentPreview,
23318
- children: /* @__PURE__ */ jsx21(
23681
+ children: /* @__PURE__ */ jsx22(
23319
23682
  DocumentPreview,
23320
23683
  {
23321
23684
  blocks: previewState.preview.blocks,