@pretextbook/web-editor 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -98463,37 +98463,53 @@ function f8(e) {
98463
98463
  }
98464
98464
  //#endregion
98465
98465
  //#region src/assetTransforms.ts
98466
- function p8(e, t, n) {
98466
+ var p8 = {
98467
+ "image/png": "png",
98468
+ "image/jpeg": "jpg",
98469
+ "image/gif": "gif",
98470
+ "image/svg+xml": "svg",
98471
+ "image/webp": "webp",
98472
+ "image/bmp": "bmp",
98473
+ "image/tiff": "tiff"
98474
+ };
98475
+ function m8(e) {
98476
+ let t = e.split(/[?#]/)[0];
98477
+ return /\.([a-zA-Z0-9]+)$/.exec(t)?.[1];
98478
+ }
98479
+ function h8(e) {
98480
+ return e.fileRef && m8(e.fileRef) || e.url && m8(e.url) || e.contentType && p8[e.contentType];
98481
+ }
98482
+ function g8(e, t, n) {
98467
98483
  if (e.isFile && !e.fileRef && !e.url) return `<!-- image asset "${t}" is marked as file-based but has no fileRef or url -->`;
98468
- let r = e.isFile ? ` source="${f8(e.fileRef ?? e.url)}"` : "", i = n ? ` width="${f8(n)}"` : "", a = e.source?.trim();
98469
- return a ? `<image${r}${i}>\n${a}\n</image>` : `<image${r}${i}/>`;
98484
+ let r = e.isFile ? h8(e) : void 0, i = e.isFile ? ` source="${f8(r ? `${t}.${r}` : t)}"` : "", a = n ? ` width="${f8(n)}"` : "", o = e.source?.trim();
98485
+ return o ? `<image${i}${a}>\n${o}\n</image>` : `<image${i}${a}/>`;
98470
98486
  }
98471
- function m8(e, t) {
98487
+ function _8(e, t) {
98472
98488
  let n = e.source?.trim();
98473
98489
  return n ? `<interactive xml:id="${f8(t)}">\n${n}\n</interactive>` : `<interactive xml:id="${f8(t)}"></interactive>`;
98474
98490
  }
98475
- var h8 = {
98476
- image: p8,
98477
- doenet: m8
98478
- }, g8 = new Set(Object.keys(h8));
98479
- function _8(e, t, n, r) {
98491
+ var v8 = {
98492
+ image: g8,
98493
+ doenet: _8
98494
+ }, y8 = new Set(Object.keys(v8));
98495
+ function b8(e, t, n, r) {
98480
98496
  let i = n.find((n) => n.kind === e && n.ref === t);
98481
- return i ? h8[e](i, t, r) : `<!-- missing asset: ${e} ${t} -->`;
98497
+ return i ? v8[e](i, t, r) : `<!-- missing asset: ${e} ${t} -->`;
98482
98498
  }
98483
98499
  //#endregion
98484
98500
  //#region src/sectionUtils.ts
98485
- var v8 = {
98501
+ var x8 = {
98486
98502
  closeEmptyElements: !0,
98487
98503
  tightClose: !0
98488
98504
  };
98489
- function y8() {
98505
+ function S8() {
98490
98506
  return `sec-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
98491
98507
  }
98492
- function b8(e) {
98508
+ function C8(e) {
98493
98509
  let t = e.children.find((e) => e.type === "element" && e.name === "title");
98494
98510
  return t ? t.children.filter((e) => e.type === "text").map((e) => e.value).join("").trim() : "";
98495
98511
  }
98496
- var x8 = new Set([
98512
+ var w8 = new Set([
98497
98513
  "book",
98498
98514
  "article",
98499
98515
  "slideshow",
@@ -98512,7 +98528,7 @@ var x8 = new Set([
98512
98528
  "conclusion"
98513
98529
  ])
98514
98530
  ]);
98515
- function S8(e) {
98531
+ function T8(e) {
98516
98532
  let t = 0, n = e.length;
98517
98533
  for (; t < n;) {
98518
98534
  let n = e[t];
@@ -98526,31 +98542,31 @@ function S8(e) {
98526
98542
  }
98527
98543
  return e.slice(t, n);
98528
98544
  }
98529
- function C8(e) {
98545
+ function E8(e) {
98530
98546
  return e.replace(/^(?:[ \t]*\r?\n)+/, "").replace(/(?:\r?\n[ \t]*)+$/, "");
98531
98547
  }
98532
- function w8(e) {
98548
+ function D8(e) {
98533
98549
  try {
98534
98550
  return t8(e);
98535
98551
  } catch {
98536
98552
  return null;
98537
98553
  }
98538
98554
  }
98539
- function T8(e) {
98540
- let t = w8(`<__title__>${e}</__title__>`)?.children.find((e) => e.type === "element");
98555
+ function O8(e) {
98556
+ let t = D8(`<__title__>${e}</__title__>`)?.children.find((e) => e.type === "element");
98541
98557
  return t ? t.children : [{
98542
98558
  type: "text",
98543
98559
  value: e
98544
98560
  }];
98545
98561
  }
98546
- function E8(e) {
98562
+ function k8(e) {
98547
98563
  let t = e.match(/^\s*<([A-Za-z_][\w.:-]*)\b[^>]*?>/);
98548
98564
  if (!t || t.index === void 0) return e;
98549
- let n = e.slice(t.index + t[0].length), r = RegExp(`\\s*</${a5(t[1])}\\s*>\\s*$`);
98550
- return C8(n.replace(r, ""));
98565
+ let n = e.slice(t.index + t[0].length), r = RegExp(`\\s*</${c5(t[1])}\\s*>\\s*$`);
98566
+ return E8(n.replace(r, ""));
98551
98567
  }
98552
- function D8(e, t) {
98553
- let n = w8(e);
98568
+ function A8(e, t) {
98569
+ let n = D8(e);
98554
98570
  if (!n) return e;
98555
98571
  let r = n.children.find((e) => e.type === "element");
98556
98572
  if (!r) return e;
@@ -98558,12 +98574,12 @@ function D8(e, t) {
98558
98574
  type: "element",
98559
98575
  name: "title",
98560
98576
  attributes: {},
98561
- children: T8(t)
98577
+ children: O8(t)
98562
98578
  };
98563
- return i === -1 ? r.children.unshift(a) : r.children.splice(i, 1, a), gX(n, v8);
98579
+ return i === -1 ? r.children.unshift(a) : r.children.splice(i, 1, a), gX(n, x8);
98564
98580
  }
98565
- function O8(e = "New Section") {
98566
- let t = y8();
98581
+ function j8(e = "New Section") {
98582
+ let t = S8();
98567
98583
  return {
98568
98584
  id: t,
98569
98585
  xmlId: t,
@@ -98573,8 +98589,8 @@ function O8(e = "New Section") {
98573
98589
  sourceFormat: "pretext"
98574
98590
  };
98575
98591
  }
98576
- function k8() {
98577
- let e = y8();
98592
+ function M8() {
98593
+ let e = S8();
98578
98594
  return {
98579
98595
  id: e,
98580
98596
  xmlId: e,
@@ -98584,8 +98600,8 @@ function k8() {
98584
98600
  sourceFormat: "pretext"
98585
98601
  };
98586
98602
  }
98587
- function A8() {
98588
- let e = y8();
98603
+ function N8() {
98604
+ let e = S8();
98589
98605
  return {
98590
98606
  id: e,
98591
98607
  xmlId: e,
@@ -98595,40 +98611,40 @@ function A8() {
98595
98611
  sourceFormat: "pretext"
98596
98612
  };
98597
98613
  }
98598
- function j8(e) {
98599
- let t = w8(e);
98600
- if (!t) return E8(e);
98614
+ function P8(e) {
98615
+ let t = D8(e);
98616
+ if (!t) return k8(e);
98601
98617
  let n = t.children.find((e) => e.type === "element");
98602
98618
  return n ? gX({
98603
98619
  type: "root",
98604
- children: S8(n.children)
98605
- }, v8) : e;
98620
+ children: T8(n.children)
98621
+ }, x8) : e;
98606
98622
  }
98607
- function M8(e, t) {
98608
- return `<${t}>\n${C8(e)}\n</${t}>`;
98623
+ function F8(e, t) {
98624
+ return `<${t}>\n${E8(e)}\n</${t}>`;
98609
98625
  }
98610
- function N8(e, t) {
98611
- return e.trimStart().startsWith(`<${t}`) ? e : M8(e, t);
98626
+ function I8(e, t) {
98627
+ return e.trimStart().startsWith(`<${t}`) ? e : F8(e, t);
98612
98628
  }
98613
- function P8(e, t) {
98629
+ function L8(e, t) {
98614
98630
  if (t === "introduction" || t === "conclusion") return e;
98615
98631
  let n = e.trimStart();
98616
98632
  return n.startsWith("\\begin{section}") ? n.replace(/^\\begin\{section\}\s*\n?/, "").replace(/\n?\\end\{section\}\s*$/, "") : e.replace(/^\\section\*?\{[^}]*\}\s*\n?/, "");
98617
98633
  }
98618
- function F8(e, t, n, r) {
98634
+ function R8(e, t, n, r) {
98619
98635
  return t === "introduction" || t === "conclusion" ? e : r?.trimStart().startsWith("\\begin{section}") ? `\\begin{section}\n\n${e}\n\n\\end{section}` : `\\section{${n}}\n\n${e}`;
98620
98636
  }
98621
- function I8(e, t, n, r) {
98637
+ function z8(e, t, n, r) {
98622
98638
  if (t === "introduction" || t === "conclusion") return e;
98623
98639
  let i = e.trimStart();
98624
- return i.startsWith("\\section") || i.startsWith("\\begin{section}") ? e : F8(e, t, n, r);
98640
+ return i.startsWith("\\section") || i.startsWith("\\begin{section}") ? e : R8(e, t, n, r);
98625
98641
  }
98626
- var L8 = /^(\s*)\\(?!begin\b|end\b)[A-Za-z][A-Za-z-]*(\*?\{)/;
98627
- function R8(e, t) {
98642
+ var B8 = /^(\s*)\\(?!begin\b|end\b)[A-Za-z][A-Za-z-]*(\*?\{)/;
98643
+ function V8(e, t) {
98628
98644
  let n = /^(\s*\\(?!begin\b|end\b)[A-Za-z][A-Za-z-]*\*?\{)[^}]*/;
98629
98645
  return n.test(e) ? e.replace(n, (e, n) => `${n}${t}`) : e.includes("\\begin{section}") ? /\\title\{/.test(e) ? e.replace(/\\title\{[^}]*\}/, `\\title{${t}}`) : e.replace("\\begin{section}", `\\begin{section}\n\n\\title{${t}}\n\n`) : e;
98630
98646
  }
98631
- function z8(e) {
98647
+ function H8(e) {
98632
98648
  let t = /^\s*\\(?!begin\b|end\b)[A-Za-z][A-Za-z-]*\*?\{([^}]*)\}/.exec(e);
98633
98649
  if (t) return t[1].trim();
98634
98650
  if (e.includes("\\begin{section}")) {
@@ -98637,12 +98653,12 @@ function z8(e) {
98637
98653
  }
98638
98654
  return null;
98639
98655
  }
98640
- function B8(e) {
98656
+ function U8(e) {
98641
98657
  return /^\s*\\(?!begin\b|end\b)[A-Za-z][A-Za-z-]*\*?\{[^}]*\}\s*\\label\{([^}]*)\}/.exec(e)?.[1]?.trim() ?? "";
98642
98658
  }
98643
- function V8(e, t) {
98659
+ function W8(e, t) {
98644
98660
  let n = e.content;
98645
- return t.type !== void 0 && (n = n.replace(L8, `$1\\${t.type}$2`)), t.title !== void 0 && (n = R8(n, t.title)), t.xmlId !== void 0 && (n = n.replace(/^(\s*\\(?!begin\b|end\b)[A-Za-z][A-Za-z-]*\*?\{[^}]*\})(\s*\\label\{[^}]*\})?/, (e, n) => t.xmlId == null || t.xmlId === "" ? n : `${n}\\label{${t.xmlId}}`)), {
98661
+ return t.type !== void 0 && (n = n.replace(B8, `$1\\${t.type}$2`)), t.title !== void 0 && (n = V8(n, t.title)), t.xmlId !== void 0 && (n = n.replace(/^(\s*\\(?!begin\b|end\b)[A-Za-z][A-Za-z-]*\*?\{[^}]*\})(\s*\\label\{[^}]*\})?/, (e, n) => t.xmlId == null || t.xmlId === "" ? n : `${n}\\label{${t.xmlId}}`)), {
98646
98662
  ...e,
98647
98663
  content: n,
98648
98664
  title: t.title ?? e.title,
@@ -98650,12 +98666,12 @@ function V8(e, t) {
98650
98666
  xmlId: t.xmlId || e.xmlId
98651
98667
  };
98652
98668
  }
98653
- function H8(e) {
98669
+ function G8(e) {
98654
98670
  let { pretextSource: t, pretextError: n } = S6(e.content, "latex");
98655
- return n || t === void 0 ? null : j5.has(e.type) ? `<${e.type} xml:id="${e.xmlId}">\n<title>${e.title}</title>\n\n${t}\n</${e.type}>` : t;
98671
+ return n || t === void 0 ? null : L5.has(e.type) ? `<${e.type} xml:id="${e.xmlId}">\n<title>${e.title}</title>\n\n${t}\n</${e.type}>` : t;
98656
98672
  }
98657
- function U8(e = "New Section") {
98658
- let t = y8();
98673
+ function K8(e = "New Section") {
98674
+ let t = S8();
98659
98675
  return {
98660
98676
  id: t,
98661
98677
  xmlId: t,
@@ -98665,8 +98681,8 @@ function U8(e = "New Section") {
98665
98681
  sourceFormat: "latex"
98666
98682
  };
98667
98683
  }
98668
- function W8() {
98669
- let e = y8();
98684
+ function q8() {
98685
+ let e = S8();
98670
98686
  return {
98671
98687
  id: e,
98672
98688
  xmlId: e,
@@ -98676,8 +98692,8 @@ function W8() {
98676
98692
  sourceFormat: "latex"
98677
98693
  };
98678
98694
  }
98679
- function G8() {
98680
- let e = y8();
98695
+ function J8() {
98696
+ let e = S8();
98681
98697
  return {
98682
98698
  id: e,
98683
98699
  xmlId: e,
@@ -98687,15 +98703,15 @@ function G8() {
98687
98703
  sourceFormat: "latex"
98688
98704
  };
98689
98705
  }
98690
- function K8(e, t, n) {
98706
+ function Y8(e, t, n) {
98691
98707
  if (n) {
98692
- let n = P8(t.content, t.type);
98708
+ let n = L8(t.content, t.type);
98693
98709
  return {
98694
98710
  ...e,
98695
98711
  content: e.content.trimEnd() + "\n\n" + n.trimStart()
98696
98712
  };
98697
98713
  }
98698
- let r = w8(e.content), i = w8(t.content), a = r?.children.find((e) => e.type === "element"), o = i?.children.find((e) => e.type === "element");
98714
+ let r = D8(e.content), i = D8(t.content), a = r?.children.find((e) => e.type === "element"), o = i?.children.find((e) => e.type === "element");
98699
98715
  if (!a || !o) return {
98700
98716
  ...e,
98701
98717
  content: e.content + "\n\n" + t.content
@@ -98709,10 +98725,10 @@ function K8(e, t, n) {
98709
98725
  content: gX({
98710
98726
  type: "root",
98711
98727
  children: [c]
98712
- }, v8)
98728
+ }, x8)
98713
98729
  };
98714
98730
  }
98715
- function q8(e) {
98731
+ function X8(e) {
98716
98732
  try {
98717
98733
  let t = t8(e).children.find((e) => e.type === "element");
98718
98734
  return t ? {
@@ -98729,24 +98745,24 @@ function q8(e) {
98729
98745
  };
98730
98746
  }
98731
98747
  }
98732
- function J8(e) {
98748
+ function Z8(e) {
98733
98749
  return e.trim().replace(/[^A-Za-z0-9_-]/g, "-").replace(/^[^A-Za-z_]+/, "");
98734
98750
  }
98735
- function Y8(e) {
98736
- return J8(e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, ""));
98751
+ function Q8(e) {
98752
+ return Z8(e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, ""));
98737
98753
  }
98738
- function X8(e) {
98739
- let t = w8(e);
98754
+ function $8(e) {
98755
+ let t = D8(e);
98740
98756
  if (!t) return null;
98741
98757
  let n = t.children.find((e) => e.type === "element");
98742
- return !n || !x8.has(n.name) ? null : {
98743
- title: b8(n),
98758
+ return !n || !w8.has(n.name) ? null : {
98759
+ title: C8(n),
98744
98760
  type: n.name,
98745
98761
  xmlId: n.attributes?.["xml:id"] ?? "",
98746
98762
  label: n.attributes?.label ?? ""
98747
98763
  };
98748
98764
  }
98749
- function Z8(e, t) {
98765
+ function e5(e, t) {
98750
98766
  let n = t.type ?? e.type, r = t.title ?? e.title;
98751
98767
  try {
98752
98768
  let i = t8(e.content).children.find((e) => e.type === "element");
@@ -98765,7 +98781,7 @@ function Z8(e, t) {
98765
98781
  type: "element",
98766
98782
  name: "title",
98767
98783
  attributes: {},
98768
- children: T8(r)
98784
+ children: O8(r)
98769
98785
  };
98770
98786
  o === -1 ? a.children = [s, ...a.children] : a.children = [
98771
98787
  ...a.children.slice(0, o),
@@ -98775,7 +98791,7 @@ function Z8(e, t) {
98775
98791
  let c = gX({
98776
98792
  type: "root",
98777
98793
  children: [a]
98778
- }, v8), l = t.xmlId !== void 0 && t.xmlId !== null && t.xmlId !== "" ? t.xmlId : e.xmlId;
98794
+ }, x8), l = t.xmlId !== void 0 && t.xmlId !== null && t.xmlId !== "" ? t.xmlId : e.xmlId;
98779
98795
  return {
98780
98796
  ...e,
98781
98797
  title: r,
@@ -98791,9 +98807,9 @@ function Z8(e, t) {
98791
98807
  };
98792
98808
  }
98793
98809
  }
98794
- var Q8 = /^\uFEFF?[ \t]*---[ \t]*\r?\n([\s\S]*?)\r?\n[ \t]*---[ \t]*(?:\r?\n|$)/;
98795
- function $8(e) {
98796
- let t = Q8.exec(e);
98810
+ var t5 = /^\uFEFF?[ \t]*---[ \t]*\r?\n([\s\S]*?)\r?\n[ \t]*---[ \t]*(?:\r?\n|$)/;
98811
+ function n5(e) {
98812
+ let t = t5.exec(e);
98797
98813
  if (!t) return null;
98798
98814
  let n = e.slice(t[0].length), r = "section", i = "", a = "";
98799
98815
  for (let e of t[1].split(/\r?\n/)) {
@@ -98809,29 +98825,29 @@ function $8(e) {
98809
98825
  body: n
98810
98826
  };
98811
98827
  }
98812
- function e5(e) {
98828
+ function r5(e) {
98813
98829
  let t = [`division: ${e.type}`, `xmlid: ${e.xmlId}`];
98814
98830
  return e.label && t.push(`label: ${e.label}`), `---\n${t.join("\n")}\n---`;
98815
98831
  }
98816
- function t5(e) {
98832
+ function i5(e) {
98817
98833
  let t = /^[ \t]*#[ \t]+(.*)$/m.exec(e);
98818
98834
  return t ? t[1].trim() : null;
98819
98835
  }
98820
- function n5(e, t) {
98836
+ function a5(e, t) {
98821
98837
  let n = /^[ \t]*#[ \t]+.*$/m.exec(e);
98822
98838
  return n ? e.slice(0, n.index) + `# ${t}` + e.slice(n.index + n[0].length) : `# ${t}\n\n${e.replace(/^\s+/, "")}`;
98823
98839
  }
98824
- function r5(e) {
98825
- let t = $8(e);
98840
+ function o5(e) {
98841
+ let t = n5(e);
98826
98842
  return t ? {
98827
- title: t5(t.body) ?? "",
98843
+ title: i5(t.body) ?? "",
98828
98844
  type: t.type,
98829
98845
  xmlId: t.xmlId,
98830
98846
  label: t.label
98831
98847
  } : null;
98832
98848
  }
98833
- function i5(e, t) {
98834
- let n = $8(e.content), r = n ? n.body : e.content, i = n?.type ?? e.type, a = n?.xmlId ?? e.xmlId, o = n?.label ?? "", s = t.type ?? i, c = (t.xmlId === void 0 ? a : t.xmlId ?? "") || e.xmlId, l = t.label === void 0 ? o : t.label ?? "", u = t.title === void 0 ? r : n5(r, t.title), d = `${e5({
98849
+ function s5(e, t) {
98850
+ let n = n5(e.content), r = n ? n.body : e.content, i = n?.type ?? e.type, a = n?.xmlId ?? e.xmlId, o = n?.label ?? "", s = t.type ?? i, c = (t.xmlId === void 0 ? a : t.xmlId ?? "") || e.xmlId, l = t.label === void 0 ? o : t.label ?? "", u = t.title === void 0 ? r : a5(r, t.title), d = `${r5({
98835
98851
  type: s,
98836
98852
  xmlId: c,
98837
98853
  label: l
@@ -98844,70 +98860,104 @@ function i5(e, t) {
98844
98860
  content: d
98845
98861
  };
98846
98862
  }
98847
- function a5(e) {
98863
+ function c5(e) {
98848
98864
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
98849
98865
  }
98850
- function o5(e) {
98866
+ function l5(e) {
98851
98867
  return e === "pretext" || e === "markdown" || e === "latex";
98852
98868
  }
98853
- var s5 = new Set([
98869
+ var u5 = new Set([
98854
98870
  "division",
98855
- ...x8,
98871
+ ...w8,
98856
98872
  "subsection",
98857
98873
  "subsubsection",
98858
98874
  "paragraphs"
98859
- ]), c5 = Array.from(s5).join("|");
98860
- function l5(e) {
98861
- let t = e === null ? "ref=\"([^\"]+)\"" : `ref="${a5(e)}"`, n = `(?:${c5})`;
98875
+ ]), d5 = Array.from(u5).join("|");
98876
+ function f5(e) {
98877
+ let t = e === null ? "ref=\"([^\"]+)\"" : `ref="${c5(e)}"`, n = `(?:${d5})`;
98862
98878
  return `<plus:${n}\\s[^>]*${t}[^>]*?(?:/>|>\\s*</plus:${n}>)`;
98863
98879
  }
98864
- function u5(e) {
98865
- let t = e === null ? "ref=\"([^\"]+)\"" : `ref="${a5(e)}"`;
98866
- return `::${`(?:${c5})`}(?:\\[[^\\]]*\\])?\\{[^}]*${t}[^}]*\\}`;
98880
+ function p5(e) {
98881
+ let t = e === null ? "ref=\"([^\"]+)\"" : `ref="${c5(e)}"`;
98882
+ return `::${`(?:${d5})`}(?:\\[[^\\]]*\\])?\\{[^}]*${t}[^}]*\\}`;
98867
98883
  }
98868
- function d5(e) {
98869
- let t = e === null ? "([^}]+)" : a5(e);
98870
- return `\\\\plus\\{${`(?:${c5})`}\\}\\{${t}\\}`;
98884
+ function m5(e) {
98885
+ let t = e === null ? "([^}]+)" : c5(e);
98886
+ return `\\\\plus\\{${`(?:${d5})`}\\}\\{${t}\\}`;
98871
98887
  }
98872
- function f5(e) {
98873
- return `(?:${l5(e)}|${u5(e)}|${d5(e)})`;
98888
+ function h5(e) {
98889
+ return `(?:${f5(e)}|${p5(e)}|${m5(e)})`;
98874
98890
  }
98875
- function p5(e) {
98876
- let t = [], n = new RegExp(f5(null), "g"), r;
98877
- for (; (r = n.exec(e)) !== null;) t.push(r[1] ?? r[2] ?? r[3]);
98878
- return t;
98891
+ function g5(e, t) {
98892
+ switch (e) {
98893
+ case "pretext": return f5(t);
98894
+ case "markdown": return p5(t);
98895
+ case "latex": return m5(t);
98896
+ }
98879
98897
  }
98880
- function m5(e) {
98881
- let t = [], n = `(?:${c5})`, r = RegExp(`<plus:(${c5})\\s[^>]*ref="([^"]+)"[^>]*?(?:/>|>\\s*</plus:${n}>)|::(${c5})(?:\\[[^\\]]*\\])?\\{[^}]*ref="([^"]+)"[^}]*\\}|\\\\plus\\{(${c5})\\}\\{([^}]+)\\}`, "g"), i;
98882
- for (; (i = r.exec(e)) !== null;) {
98883
- let e = i[1] ?? i[3] ?? i[5], n = i[2] ?? i[4] ?? i[6], r = e === "division" ? "section" : e;
98884
- t.push({
98898
+ var _5 = {
98899
+ pretext: [],
98900
+ markdown: [
98901
+ "```[\\s\\S]*?```",
98902
+ "~~~[\\s\\S]*?~~~",
98903
+ "`[^`\\n]*`"
98904
+ ],
98905
+ latex: [
98906
+ "\\\\begin\\{verbatim\\}[\\s\\S]*?\\\\end\\{verbatim\\}",
98907
+ "\\\\begin\\{lstlisting\\}[\\s\\S]*?\\\\end\\{lstlisting\\}",
98908
+ "\\\\verb\\*?\\|[^|\\n]*\\|"
98909
+ ]
98910
+ };
98911
+ function v5(e, t) {
98912
+ let n = _5[t];
98913
+ if (n.length === 0) return e;
98914
+ let r = new RegExp(n.join("|"), "g");
98915
+ return e.replace(r, (e) => e.replace(/[^\n]/g, " "));
98916
+ }
98917
+ function y5(e, t) {
98918
+ let n = [], r = new RegExp(g5(t, null), "g"), i = v5(e, t), a;
98919
+ for (; (a = r.exec(i)) !== null;) n.push(a[1]);
98920
+ return n;
98921
+ }
98922
+ function b5(e, t) {
98923
+ let n = [], r = d5, i = {
98924
+ pretext: `<plus:(${r})\\s[^>]*ref="([^"]+)"[^>]*?(?:/>|>\\s*</plus:${`(?:${r})`}>)`,
98925
+ markdown: `::(${r})(?:\\[[^\\]]*\\])?\\{[^}]*ref="([^"]+)"[^}]*\\}`,
98926
+ latex: `\\\\plus\\{(${r})\\}\\{([^}]+)\\}`
98927
+ }, a = new RegExp(i[t], "g"), o = v5(e, t), s;
98928
+ for (; (s = a.exec(o)) !== null;) {
98929
+ let e = s[1], t = s[2], r = e === "division" ? "section" : e;
98930
+ n.push({
98885
98931
  type: r,
98886
- xmlId: n
98932
+ xmlId: t
98887
98933
  });
98888
98934
  }
98889
- return t;
98935
+ return n;
98890
98936
  }
98891
- function h5(e) {
98892
- let t = [], n = /<plus:(image|doenet)\b[^>]*\bref="([^"]+)"|::(image|doenet)(?:\[[^\]]*\])?\{[^}]*\bref="([^"]+)"[^}]*\}|\\plus\{(image|doenet)\}\{([^}]+)\}/g, r;
98893
- for (; (r = n.exec(e)) !== null;) t.push({
98894
- kind: r[1] ?? r[3] ?? r[5],
98895
- ref: r[2] ?? r[4] ?? r[6]
98937
+ function x5(e, t) {
98938
+ let n = [], r = new RegExp({
98939
+ pretext: "<plus:(image|doenet)\\b[^>]*\\bref=\"([^\"]+)\"",
98940
+ markdown: "::(image|doenet)(?:\\[[^\\]]*\\])?\\{[^}]*\\bref=\"([^\"]+)\"[^}]*\\}",
98941
+ latex: "\\\\plus\\{(image|doenet)\\}\\{([^}]+)\\}"
98942
+ }[t], "g"), i = v5(e, t), a;
98943
+ for (; (a = r.exec(i)) !== null;) n.push({
98944
+ kind: a[1],
98945
+ ref: a[2]
98896
98946
  });
98897
- return t;
98947
+ return n;
98898
98948
  }
98899
- function g5(e, t, n, r) {
98900
- let i = a5(t), a = a5(n), o = RegExp(`(<plus:${i}\\b[^>]*?\\bref=")${a}(")`, "g"), s = RegExp(`(::${i}(?:\\[[^\\]]*\\])?\\{[^}]*?\\bref=")${a}(")`, "g"), c = RegExp(`(\\\\plus\\{${i}\\}\\{)${a}(\\})`, "g");
98949
+ function S5(e, t, n, r) {
98950
+ let i = c5(t), a = c5(n), o = RegExp(`(<plus:${i}\\b[^>]*?\\bref=")${a}(")`, "g"), s = RegExp(`(::${i}(?:\\[[^\\]]*\\])?\\{[^}]*?\\bref=")${a}(")`, "g"), c = RegExp(`(\\\\plus\\{${i}\\}\\{)${a}(\\})`, "g");
98901
98951
  return e.replace(o, `$1${r}$2`).replace(s, `$1${r}$2`).replace(c, `$1${r}$2`);
98902
98952
  }
98903
- function _5(e, t, n) {
98904
- let r = a5(t), i = a5(n), a = RegExp(`<plus:${r}\\b[^>]*?\\bref="${i}"[^>]*/?>`, "g"), o = RegExp(`::${r}(?:\\[[^\\]]*\\])?\\{[^}]*?\\bref="${i}"[^}]*\\}`, "g"), s = RegExp(`\\\\plus\\{${r}\\}\\{${i}\\}`, "g");
98953
+ function C5(e, t, n) {
98954
+ let r = c5(t), i = c5(n), a = RegExp(`<plus:${r}\\b[^>]*?\\bref="${i}"[^>]*/?>`, "g"), o = RegExp(`::${r}(?:\\[[^\\]]*\\])?\\{[^}]*?\\bref="${i}"[^}]*\\}`, "g"), s = RegExp(`\\\\plus\\{${r}\\}\\{${i}\\}`, "g");
98905
98955
  return e.replace(a, "").replace(o, "").replace(s, "");
98906
98956
  }
98907
- function v5(e, t, n = "pretext") {
98957
+ function w5(e, t, n = "pretext") {
98908
98958
  return n === "markdown" ? `::${e}{ref="${t}"}` : n === "latex" ? `\\plus{${e}}{${t}}` : `<plus:${e} ref="${t}"/>`;
98909
98959
  }
98910
- function y5(e, t, n = "pretext") {
98960
+ function T5(e, t, n = "pretext") {
98911
98961
  let r = `New ${t.charAt(0).toUpperCase() + t.slice(1)}`;
98912
98962
  return {
98913
98963
  id: e,
@@ -98915,20 +98965,20 @@ function y5(e, t, n = "pretext") {
98915
98965
  title: r,
98916
98966
  type: t,
98917
98967
  sourceFormat: n,
98918
- content: b5(t, n, r, e)
98968
+ content: E5(t, n, r, e)
98919
98969
  };
98920
98970
  }
98921
- function b5(e, t, n, r) {
98922
- return t === "latex" ? e === "introduction" || e === "conclusion" ? `% ${n}\n\n` : `\\${e}{${n}}\\label{${r}}\n\n` : t === "markdown" ? `${e5({
98971
+ function E5(e, t, n, r) {
98972
+ return t === "latex" ? e === "introduction" || e === "conclusion" ? `% ${n}\n\n` : `\\${e}{${n}}\\label{${r}}\n\n` : t === "markdown" ? `${r5({
98923
98973
  type: e,
98924
98974
  xmlId: r,
98925
98975
  label: ""
98926
98976
  })}\n# ${n}\n\n` : e === "introduction" || e === "conclusion" ? `<${e} xml:id="${r}">\n\n\t<p>\n\n\t</p>\n\n</${e}>` : `<${e} xml:id="${r}">\n\t<title>${n}</title>\n\n\t<p>\n\n\t</p>\n\n</${e}>`;
98927
98977
  }
98928
- function x5(e, t, n, r, i = "pretext") {
98978
+ function D5(e, t, n, r, i = "pretext") {
98929
98979
  let a = i === "markdown" ? `::${n}{ref="${t}"}` : i === "latex" ? `\\plus{${n}}{${t}}` : `<plus:${n} ref="${t}"/>`;
98930
98980
  if (r !== null) {
98931
- let t = new RegExp(f5(r)).exec(e);
98981
+ let t = new RegExp(h5(r)).exec(e);
98932
98982
  if (t) {
98933
98983
  let n = t.index + t[0].length;
98934
98984
  return e.slice(0, n) + "\n" + a + e.slice(n);
@@ -98937,14 +98987,14 @@ function x5(e, t, n, r, i = "pretext") {
98937
98987
  let o = e.lastIndexOf("</");
98938
98988
  return o === -1 ? e + "\n" + a : e.slice(0, o) + a + "\n" + e.slice(o);
98939
98989
  }
98940
- function S5(e, t) {
98941
- let n = RegExp(`[ \t]*${f5(t)}[ \t]*\n?`, "g");
98990
+ function O5(e, t) {
98991
+ let n = RegExp(`[ \t]*${h5(t)}[ \t]*\n?`, "g");
98942
98992
  return e.replace(n, "");
98943
98993
  }
98944
- function C5(e, t, n) {
98945
- let r = new RegExp(f5(t)).exec(e), i = r ? r[0] : `<plus:division ref="${t}"/>`, a = S5(e, t);
98994
+ function k5(e, t, n) {
98995
+ let r = new RegExp(h5(t)).exec(e), i = r ? r[0] : `<plus:division ref="${t}"/>`, a = O5(e, t);
98946
98996
  if (n !== null) {
98947
- let e = new RegExp(f5(n)).exec(a);
98997
+ let e = new RegExp(h5(n)).exec(a);
98948
98998
  if (e) {
98949
98999
  let t = e.index + e[0].length;
98950
99000
  return a.slice(0, t) + "\n" + i + a.slice(t);
@@ -98953,41 +99003,41 @@ function C5(e, t, n) {
98953
99003
  let o = a.lastIndexOf("</");
98954
99004
  return o === -1 ? a + "\n" + i : a.slice(0, o) + i + "\n" + a.slice(o);
98955
99005
  }
98956
- function w5(e, t, n, r) {
98957
- let i = new RegExp(f5(t));
99006
+ function A5(e, t, n, r) {
99007
+ let i = new RegExp(h5(t));
98958
99008
  return e.replace(i, (e) => {
98959
99009
  let t = e.trimStart();
98960
99010
  return t.startsWith("::") ? `::${r}{ref="${n}"}` : t.startsWith("\\plus") ? `\\plus{${r}}{${n}}` : `<plus:${r} ref="${n}"/>`;
98961
99011
  });
98962
99012
  }
98963
- function T5(e, t) {
98964
- let n = new RegExp(f5(t));
99013
+ function j5(e, t) {
99014
+ let n = new RegExp(h5(t));
98965
99015
  return e.find((e) => n.test(e.content)) ?? null;
98966
99016
  }
98967
- function E5(e, t) {
99017
+ function M5(e, t) {
98968
99018
  let n = e, r = null;
98969
- for (let e of t) n = C5(n, e, r), r = e;
99019
+ for (let e of t) n = k5(n, e, r), r = e;
98970
99020
  return n;
98971
99021
  }
98972
- function D5(e, t) {
99022
+ function N5(e, t) {
98973
99023
  let n = /* @__PURE__ */ new Set(), r = [t];
98974
99024
  for (; r.length > 0;) {
98975
99025
  let t = r.pop();
98976
99026
  if (n.has(t)) continue;
98977
99027
  n.add(t);
98978
99028
  let i = e.find((e) => e.xmlId === t);
98979
- if (i) for (let e of p5(i.content)) r.push(e);
99029
+ if (i) for (let e of y5(i.content, i.sourceFormat)) r.push(e);
98980
99030
  }
98981
99031
  return n;
98982
99032
  }
98983
- function O5(e, t) {
98984
- let n = D5(e, t);
99033
+ function P5(e, t) {
99034
+ let n = N5(e, t);
98985
99035
  return e.filter((e) => !n.has(e.xmlId));
98986
99036
  }
98987
- function k5(e, t) {
99037
+ function F5(e, t) {
98988
99038
  let n = [], r = new Set([t]), i = (t, a) => {
98989
99039
  let o = e.find((e) => e.xmlId === t);
98990
- if (o) for (let s of p5(o.content)) {
99040
+ if (o) for (let s of y5(o.content, o.sourceFormat)) {
98991
99041
  if (r.has(s)) continue;
98992
99042
  let o = e.find((e) => e.xmlId === s);
98993
99043
  o && (r.add(s), n.push({
@@ -98999,38 +99049,38 @@ function k5(e, t) {
98999
99049
  };
99000
99050
  return i(t, 0), n;
99001
99051
  }
99002
- function A5(e, t) {
99003
- let n = O5(e, t), r = new Set(n.map((e) => e.xmlId)), i = /* @__PURE__ */ new Set();
99004
- for (let e of n) for (let t of p5(e.content)) r.has(t) && i.add(t);
99052
+ function I5(e, t) {
99053
+ let n = P5(e, t), r = new Set(n.map((e) => e.xmlId)), i = /* @__PURE__ */ new Set();
99054
+ for (let e of n) for (let t of y5(e.content, e.sourceFormat)) r.has(t) && i.add(t);
99005
99055
  return n.filter((e) => !i.has(e.xmlId));
99006
99056
  }
99007
- var j5 = new Set([
99057
+ var L5 = new Set([
99008
99058
  "book",
99009
99059
  "article",
99010
99060
  "slideshow"
99011
99061
  ]);
99012
- function M5(e) {
99062
+ function R5(e) {
99013
99063
  try {
99014
- let t = t8(e), n = t.children.find((e) => e.type === "element"), r = n?.name === "pretext" ? n.children.find((e) => e.type === "element" && j5.has(e.name)) : n && j5.has(n.name) ? n : void 0;
99064
+ let t = t8(e), n = t.children.find((e) => e.type === "element"), r = n?.name === "pretext" ? n.children.find((e) => e.type === "element" && L5.has(e.name)) : n && L5.has(n.name) ? n : void 0;
99015
99065
  if (!r) return e;
99016
99066
  if (!r.attributes.label) {
99017
- let e = P5(t, "pretext-plus-preview");
99018
- return r.attributes.label = e, gX(t, v8);
99067
+ let e = B5(t, "pretext-plus-preview");
99068
+ return r.attributes.label = e, gX(t, x8);
99019
99069
  }
99020
99070
  return e;
99021
99071
  } catch (t) {
99022
99072
  return console.error("Error ensuring label:", t), e;
99023
99073
  }
99024
99074
  }
99025
- function N5(e, t) {
99026
- return e.type === "element" && e.attributes?.label === t ? !0 : "children" in e && e.children ? e.children.some((e) => e.type === "element" ? N5(e, t) : !1) : !1;
99075
+ function z5(e, t) {
99076
+ return e.type === "element" && e.attributes?.label === t ? !0 : "children" in e && e.children ? e.children.some((e) => e.type === "element" ? z5(e, t) : !1) : !1;
99027
99077
  }
99028
- function P5(e, t) {
99078
+ function B5(e, t) {
99029
99079
  let n = t, r = 1;
99030
- for (; N5(e, n);) n = `${t}-${r}`, r++;
99080
+ for (; z5(e, n);) n = `${t}-${r}`, r++;
99031
99081
  return n;
99032
99082
  }
99033
- function F5(e, t, n, r) {
99083
+ function V5(e, t, n, r) {
99034
99084
  let i = t.find((t) => t.xmlId === e);
99035
99085
  if (!i) return `<!-- missing division: ${e} -->`;
99036
99086
  if (n.has(e)) return `<!-- circular reference: ${e} -->`;
@@ -99039,29 +99089,29 @@ function F5(e, t, n, r) {
99039
99089
  else if (i.sourceFormat === "markdown") {
99040
99090
  let { pretextSource: e, pretextError: t } = S6(i.content, "markdown");
99041
99091
  a = e ?? `<!-- conversion error: ${t} -->`;
99042
- } else a = H8(i) ?? `<!-- conversion error: ${i.xmlId} -->`;
99092
+ } else a = G8(i) ?? `<!-- conversion error: ${i.xmlId} -->`;
99043
99093
  let o = new Set(n).add(e);
99044
99094
  return a.replace(/<plus:([a-z-]+)\s([^>]*ref="[^"]+"[^>]*?)(?:\/>|>\s*<\/plus:\1>)/g, (e, n, i) => {
99045
99095
  let a = /ref="([^"]+)"/.exec(i)?.[1] ?? "";
99046
- if (!g8.has(n)) return F5(a, t, o, r);
99096
+ if (!y8.has(n)) return V5(a, t, o, r);
99047
99097
  let s = /width="([^"]+)"/.exec(i)?.[1];
99048
- return _8(n, a, r, s);
99098
+ return b8(n, a, r, s);
99049
99099
  });
99050
99100
  }
99051
- function I5(e, t, n = []) {
99052
- return M5(F5(t, e, /* @__PURE__ */ new Set(), n));
99101
+ function H5(e, t, n = []) {
99102
+ return R5(V5(t, e, /* @__PURE__ */ new Set(), n));
99053
99103
  }
99054
- function L5(e, t) {
99055
- return M5(`<pretext>\n${t.trim() ? `${t.trim()}\n` : ""}${e}\n</pretext>`);
99104
+ function U5(e, t) {
99105
+ return R5(`<pretext>\n${t.trim() ? `${t.trim()}\n` : ""}${e}\n</pretext>`);
99056
99106
  }
99057
- function R5(e, t, n, r = []) {
99058
- return L5(F5(t, e, /* @__PURE__ */ new Set(), r), n);
99107
+ function W5(e, t, n, r = []) {
99108
+ return U5(V5(t, e, /* @__PURE__ */ new Set(), r), n);
99059
99109
  }
99060
- var z5 = new Set(["part", "chapter"]);
99061
- function B5(e, t, n, r) {
99062
- return L5(j5.has(e) ? t : z5.has(e) ? `<book>\n<title>${r}</title>\n${t}\n</book>` : `<article>\n<title>${r}</title>\n${t}\n</article>`, n);
99110
+ var G5 = new Set(["part", "chapter"]);
99111
+ function K5(e, t, n, r) {
99112
+ return U5(L5.has(e) ? t : G5.has(e) ? `<book>\n<title>${r}</title>\n${t}\n</book>` : `<article>\n<title>${r}</title>\n${t}\n</article>`, n);
99063
99113
  }
99064
- function V5(e) {
99114
+ function q5(e) {
99065
99115
  let t = e.trim(), n = t.match(/^<title\b[^>]*>([\s\S]*?)<\/title>\s*/);
99066
99116
  return n ? {
99067
99117
  title: n[1].trim(),
@@ -99071,12 +99121,12 @@ function V5(e) {
99071
99121
  body: t
99072
99122
  };
99073
99123
  }
99074
- function H5(e, t, n, r) {
99124
+ function J5(e, t, n, r) {
99075
99125
  let i = n === "book" ? "book" : "article";
99076
99126
  return e.map((e) => {
99077
99127
  if (e.sourceFormat === "markdown") {
99078
99128
  if (!e.title) {
99079
- let t = r5(e.content)?.title;
99129
+ let t = o5(e.content)?.title;
99080
99130
  if (t) return {
99081
99131
  ...e,
99082
99132
  title: t
@@ -99086,7 +99136,7 @@ function H5(e, t, n, r) {
99086
99136
  }
99087
99137
  if (e.sourceFormat === "latex") {
99088
99138
  if (!e.title) {
99089
- let t = z8(e.content);
99139
+ let t = H8(e.content);
99090
99140
  if (t) return {
99091
99141
  ...e,
99092
99142
  title: t
@@ -99095,9 +99145,9 @@ function H5(e, t, n, r) {
99095
99145
  return e;
99096
99146
  }
99097
99147
  if (e.sourceFormat !== "pretext") return e;
99098
- let n = X8(e.content);
99099
- if (e.xmlId === t && !(n && j5.has(n.type))) {
99100
- let { title: t, body: n } = V5(e.content), a = e.title || t || r || "Untitled";
99148
+ let n = $8(e.content);
99149
+ if (e.xmlId === t && !(n && L5.has(n.type))) {
99150
+ let { title: t, body: n } = q5(e.content), a = e.title || t || r || "Untitled";
99101
99151
  return {
99102
99152
  ...e,
99103
99153
  type: i,
@@ -99113,9 +99163,9 @@ function H5(e, t, n, r) {
99113
99163
  }
99114
99164
  //#endregion
99115
99165
  //#region src/assetView.ts
99116
- function U5(e, t) {
99166
+ function Y5(e, t) {
99117
99167
  let n = t ?? [], r = (e, t) => n.find((n) => n.kind === e && n.ref === t), i = [], a = /* @__PURE__ */ new Set();
99118
- for (let t of e ?? []) for (let { kind: e, ref: n } of h5(t.content)) {
99168
+ for (let t of e ?? []) for (let { kind: e, ref: n } of x5(t.content, t.sourceFormat)) {
99119
99169
  let t = `${e}:${n}`;
99120
99170
  if (a.has(t)) continue;
99121
99171
  a.add(t);
@@ -99141,7 +99191,7 @@ function U5(e, t) {
99141
99191
  }
99142
99192
  return i;
99143
99193
  }
99144
- function W5(e, t) {
99194
+ function X5(e, t) {
99145
99195
  let n = `${e}-copy`;
99146
99196
  if (!t.has(n)) return n;
99147
99197
  for (let e = 2;; e++) {
@@ -99149,17 +99199,17 @@ function W5(e, t) {
99149
99199
  if (!t.has(r)) return r;
99150
99200
  }
99151
99201
  }
99152
- var G5 = {
99202
+ var Z5 = {
99153
99203
  image: "Images",
99154
99204
  doenet: "Doenet"
99155
- }, K5 = ["image", "doenet"].filter((e) => e !== "doenet" || !1);
99205
+ }, Q5 = ["image", "doenet"].filter((e) => e !== "doenet" || !1);
99156
99206
  //#endregion
99157
99207
  //#region src/components/AssetManagerModal.tsx
99158
- function q5(e) {
99208
+ function $5(e) {
99159
99209
  return `${e}-${Date.now()}`;
99160
99210
  }
99161
- var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAssets: s, onLoadLibraryAssets: c, onAddFromLibrary: l, onUpload: u, onFetchUrl: f, onCreateDoenet: p, onRemoveAsset: h, onDuplicateAsset: g, onAssetAdded: _, onResolveRef: v, onReplaceAsset: x }) => {
99162
- let S = A6((e) => e.divisions), C = A6((e) => e.activeDivisionId), w = S?.find((e) => e.xmlId === C)?.sourceFormat ?? "pretext", T = (e, t) => v5(e, t, w), E = A6((e) => e.projectAssets) ?? [], D = A6((e) => e.setProjectAssets), O = A6((e) => e.libraryAssets), k = A6((e) => e.openAssetEditor), A = A6((e) => e.openAssetResolver), j = A6((e) => e.removeAssetRefFromDocument), ee = !!(s || c), [te, ne] = b(null), [M, N] = b(!1), [re, ie] = b(null), ae = E, P = te ?? O ?? ae, oe = new Set(ae.map((e) => e.id)), [F, se] = b("in-document"), [ce, le] = b(null), [ue, I] = b("library"), [de, fe] = b("library"), [pe, me] = b(null), [he, L] = b(!1), [ge, _e] = b(!1), [ve, ye] = b(null), be = y(null), [xe, Se] = b(""), [R, Ce] = b(""), [we, Te] = b(!1), [z, Ee] = b(null), [De, Oe] = b(""), [B, ke] = b(""), [Ae, je] = b(!1), [Me, Ne] = b(null), [Pe, Fe] = b(null), [Ie, Le] = b(null), [Re, ze] = b(null), Be = d(() => {
99211
+ var e7 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAssets: s, onLoadLibraryAssets: c, onAddFromLibrary: l, onUpload: u, onFetchUrl: f, onCreateDoenet: p, onRemoveAsset: h, onDuplicateAsset: g, onAssetAdded: _, onResolveRef: v, onReplaceAsset: x }) => {
99212
+ let S = A6((e) => e.divisions), C = A6((e) => e.activeDivisionId), w = S?.find((e) => e.xmlId === C)?.sourceFormat ?? "pretext", T = (e, t) => w5(e, t, w), E = A6((e) => e.projectAssets) ?? [], D = A6((e) => e.setProjectAssets), O = A6((e) => e.libraryAssets), k = A6((e) => e.openAssetEditor), A = A6((e) => e.openAssetResolver), j = A6((e) => e.removeAssetRefFromDocument), ee = !!(s || c), [te, ne] = b(null), [M, N] = b(!1), [re, ie] = b(null), ae = E, P = te ?? O ?? ae, oe = new Set(ae.map((e) => e.id)), [F, se] = b("in-document"), [ce, le] = b(null), [ue, I] = b("library"), [de, fe] = b("library"), [pe, me] = b(null), [he, L] = b(!1), [ge, _e] = b(!1), [ve, ye] = b(null), be = y(null), [xe, Se] = b(""), [R, Ce] = b(""), [we, Te] = b(!1), [z, Ee] = b(null), [De, Oe] = b(""), [B, ke] = b(""), [Ae, je] = b(!1), [Me, Ne] = b(null), [Pe, Fe] = b(null), [Ie, Le] = b(null), [Re, ze] = b(null), Be = d(() => {
99163
99213
  !s && !c || (N(!0), ie(null), Promise.all([s?.() ?? Promise.resolve(null), c?.() ?? Promise.resolve(null)]).then(([e, t]) => {
99164
99214
  e !== null && D(e), t !== null && ne(t);
99165
99215
  }).catch((e) => {
@@ -99181,7 +99231,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
99181
99231
  };
99182
99232
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
99183
99233
  }, [r, i]), !r) return null;
99184
- let He = U5(S, ae), V = (e, t) => {
99234
+ let He = Y5(S, ae), V = (e, t) => {
99185
99235
  if (o) {
99186
99236
  x(o, e, !!t?.fromLibrary), i();
99187
99237
  return;
@@ -99230,7 +99280,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
99230
99280
  Te(!1);
99231
99281
  }
99232
99282
  } else V({
99233
- id: q5("url"),
99283
+ id: $5("url"),
99234
99284
  name: t || e,
99235
99285
  ref: e.split("/").pop() ?? "image",
99236
99286
  kind: "image",
@@ -99248,7 +99298,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
99248
99298
  je(!1);
99249
99299
  }
99250
99300
  } else V({
99251
- id: q5("doenet"),
99301
+ id: $5("doenet"),
99252
99302
  name: e,
99253
99303
  ref: t,
99254
99304
  kind: "doenet"
@@ -99276,7 +99326,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
99276
99326
  className: "pretext-plus-editor__am-empty-text",
99277
99327
  children: [
99278
99328
  "No ",
99279
- G5[e].toLowerCase(),
99329
+ Z5[e].toLowerCase(),
99280
99330
  " assets in your library."
99281
99331
  ]
99282
99332
  }) : /* @__PURE__ */ t("ul", {
@@ -99318,7 +99368,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
99318
99368
  children: "Add an asset"
99319
99369
  })]
99320
99370
  });
99321
- let e = K5.map((e) => ({
99371
+ let e = Q5.map((e) => ({
99322
99372
  kind: e,
99323
99373
  rows: He.filter((t) => t.kind === e)
99324
99374
  })).filter((e) => e.rows.length > 0), r = (e) => {
@@ -99407,7 +99457,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
99407
99457
  "aria-hidden": "true",
99408
99458
  children: "📁"
99409
99459
  }),
99410
- /* @__PURE__ */ t("span", { children: G5[e] }),
99460
+ /* @__PURE__ */ t("span", { children: Z5[e] }),
99411
99461
  /* @__PURE__ */ t("span", {
99412
99462
  className: "pretext-plus-editor__am-kind-count",
99413
99463
  children: i.length
@@ -99842,7 +99892,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
99842
99892
  ] })
99843
99893
  })
99844
99894
  });
99845
- }, Y5 = {
99895
+ }, t7 = {
99846
99896
  automaticLayout: !0,
99847
99897
  minimap: { enabled: !1 },
99848
99898
  wordWrap: "on",
@@ -99853,18 +99903,18 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
99853
99903
  bottom: 10
99854
99904
  },
99855
99905
  scrollBeyondLastLine: !1
99856
- }, X5 = 160, Z5 = {
99906
+ }, n7 = 160, r7 = {
99857
99907
  image: "image",
99858
99908
  doenet: "interactive"
99859
- }, Q5 = ({ asset: e, projectAssets: r, onClose: i, onSave: a, onReplace: o, onDuplicate: s }) => {
99860
- let c = A6((e) => e.divisions), l = A6((e) => e.activeDivisionId), u = c?.find((e) => e.xmlId === l)?.sourceFormat ?? "pretext", d = e.ref ?? "", [f, p] = b(e.name), [h, g] = b(d), [_, v] = b(e.source ?? ""), [x, S] = b(!1), [C, w] = b(!1), [T, E] = b(null), [D, O] = b(!1), [k, A] = b(X5), j = y(null);
99909
+ }, i7 = ({ asset: e, projectAssets: r, onClose: i, onSave: a, onReplace: o, onDuplicate: s }) => {
99910
+ let c = A6((e) => e.divisions), l = A6((e) => e.activeDivisionId), u = c?.find((e) => e.xmlId === l)?.sourceFormat ?? "pretext", d = e.ref ?? "", [f, p] = b(e.name), [h, g] = b(d), [_, v] = b(e.source ?? ""), [x, S] = b(!1), [C, w] = b(!1), [T, E] = b(null), [D, O] = b(!1), [k, A] = b(n7), j = y(null);
99861
99911
  m(() => {
99862
99912
  j.current?.scrollTo({ top: 0 });
99863
99913
  }, []);
99864
99914
  let ee = (e) => {
99865
- let t = () => A(Math.max(X5, e.getContentHeight()));
99915
+ let t = () => A(Math.max(n7, e.getContentHeight()));
99866
99916
  e.onDidContentSizeChange(t), t();
99867
- }, te = v5(e.kind, h.trim() || d, u), ne = () => {
99917
+ }, te = w5(e.kind, h.trim() || d, u), ne = () => {
99868
99918
  navigator.clipboard.writeText(te).catch(() => {}), O(!0), setTimeout(() => O(!1), 2e3);
99869
99919
  }, M = async () => {
99870
99920
  let t = h.trim();
@@ -100004,7 +100054,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
100004
100054
  className: "pretext-plus-editor__dialog-helper-copy",
100005
100055
  children: [
100006
100056
  "Inserted verbatim inside the generated ",
100007
- /* @__PURE__ */ t("code", { children: `<${Z5[e.kind]}>` }),
100057
+ /* @__PURE__ */ t("code", { children: `<${r7[e.kind]}>` }),
100008
100058
  " element — e.g. ",
100009
100059
  /* @__PURE__ */ t("code", { children: "<shortdescription>...</shortdescription>" }),
100010
100060
  "."
@@ -100015,7 +100065,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
100015
100065
  style: { height: k },
100016
100066
  children: /* @__PURE__ */ t(_r, {
100017
100067
  options: {
100018
- ...Y5,
100068
+ ...t7,
100019
100069
  readOnly: re
100020
100070
  },
100021
100071
  height: "100%",
@@ -100062,7 +100112,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
100062
100112
  ]
100063
100113
  })
100064
100114
  });
100065
- }, $5 = (e) => {
100115
+ }, a7 = (e) => {
100066
100116
  let r = A6((e) => e.showFullPreview), i = A6((e) => e.setShowFullPreview), a = A6((e) => e.title), o = A6((e) => e.updateTitle), s;
100067
100117
  return s = e.showPreviewModeToggle === !1 ? null : /* @__PURE__ */ n("label", {
100068
100118
  className: "pretext-plus-editor__preview-toggle",
@@ -100139,11 +100189,11 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
100139
100189
  ]
100140
100190
  })]
100141
100191
  });
100142
- }, e7 = {
100192
+ }, o7 = {
100143
100193
  pretext: "PreTeXt",
100144
100194
  latex: "LaTeX",
100145
100195
  markdown: "Markdown"
100146
- }, t7 = {
100196
+ }, s7 = {
100147
100197
  book: "bk",
100148
100198
  article: "art",
100149
100199
  slideshow: "slides",
@@ -100162,7 +100212,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
100162
100212
  solutions: "sol",
100163
100213
  "reading-questions": "rq",
100164
100214
  paragraphs: "para"
100165
- }, n7 = {
100215
+ }, c7 = {
100166
100216
  book: "Book",
100167
100217
  article: "Article",
100168
100218
  slideshow: "Slideshow",
@@ -100181,7 +100231,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
100181
100231
  subsection: "Subsection",
100182
100232
  subsubsection: "Subsubsection",
100183
100233
  paragraphs: "Paragraphs"
100184
- }, r7 = [
100234
+ }, l7 = [
100185
100235
  "part",
100186
100236
  "chapter",
100187
100237
  "section",
@@ -100195,7 +100245,7 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
100195
100245
  "solutions",
100196
100246
  "reading-questions",
100197
100247
  "paragraphs"
100198
- ], i7 = [
100248
+ ], u7 = [
100199
100249
  "worksheet",
100200
100250
  "handout",
100201
100251
  "exercises",
@@ -100204,29 +100254,29 @@ var J5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAsset
100204
100254
  "solutions",
100205
100255
  "reading-questions",
100206
100256
  "paragraphs"
100207
- ], a7 = {
100257
+ ], d7 = {
100208
100258
  book: ["part", "chapter"],
100209
- article: ["section", ...i7],
100259
+ article: ["section", ...u7],
100210
100260
  slideshow: ["section"],
100211
100261
  part: ["chapter"],
100212
- chapter: ["section", ...i7],
100213
- section: ["subsection", ...i7],
100214
- subsection: ["subsubsection", ...i7],
100215
- subsubsection: [...i7],
100262
+ chapter: ["section", ...u7],
100263
+ section: ["subsection", ...u7],
100264
+ subsection: ["subsubsection", ...u7],
100265
+ subsubsection: [...u7],
100216
100266
  worksheet: ["paragraphs"],
100217
100267
  handout: ["paragraphs"]
100218
100268
  };
100219
- function o7(e) {
100220
- return e ? a7[e] ?? r7 : r7;
100269
+ function f7(e) {
100270
+ return e ? d7[e] ?? l7 : l7;
100221
100271
  }
100222
100272
  //#endregion
100223
100273
  //#region src/components/toc/SectionEditForm.tsx
100224
- function s7(e, t) {
100225
- let n = t7[e] ?? "sec", r = Y8(t);
100274
+ function p7(e, t) {
100275
+ let n = s7[e] ?? "sec", r = Q8(t);
100226
100276
  return r ? `${n}-${r}` : n;
100227
100277
  }
100228
- var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDraftChange: o, onCommit: s, onCancel: c }) => {
100229
- let l = o7(a), u = y(r);
100278
+ var m7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDraftChange: o, onCommit: s, onCancel: c }) => {
100279
+ let l = f7(a), u = y(r);
100230
100280
  return m(() => {
100231
100281
  i || l.length > 0 && !l.includes(e.type) && o({
100232
100282
  ...e,
@@ -100250,7 +100300,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100250
100300
  o(u.current ? {
100251
100301
  ...e,
100252
100302
  title: n,
100253
- xmlId: s7(e.type, n)
100303
+ xmlId: p7(e.type, n)
100254
100304
  } : {
100255
100305
  ...e,
100256
100306
  title: n
@@ -100270,9 +100320,9 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100270
100320
  ...e,
100271
100321
  sourceFormat: t.target.value
100272
100322
  }),
100273
- children: Object.keys(e7).map((e) => /* @__PURE__ */ t("option", {
100323
+ children: Object.keys(o7).map((e) => /* @__PURE__ */ t("option", {
100274
100324
  value: e,
100275
- children: e7[e]
100325
+ children: o7[e]
100276
100326
  }, e))
100277
100327
  })]
100278
100328
  }) : void 0,
@@ -100285,7 +100335,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100285
100335
  o(u.current ? {
100286
100336
  ...e,
100287
100337
  type: n,
100288
- xmlId: s7(n, e.title)
100338
+ xmlId: p7(n, e.title)
100289
100339
  } : {
100290
100340
  ...e,
100291
100341
  type: n
@@ -100293,7 +100343,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100293
100343
  },
100294
100344
  children: l.map((e) => /* @__PURE__ */ t("option", {
100295
100345
  value: e,
100296
- children: n7[e]
100346
+ children: c7[e]
100297
100347
  }, e))
100298
100348
  })]
100299
100349
  }),
@@ -100327,7 +100377,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100327
100377
  })
100328
100378
  ]
100329
100379
  });
100330
- }, l7 = ({ items: e }) => {
100380
+ }, h7 = ({ items: e }) => {
100331
100381
  let [r, i] = b(!1), [a, o] = b(null), s = y(null), c = y(null);
100332
100382
  m(() => {
100333
100383
  if (!r) return;
@@ -100383,8 +100433,8 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100383
100433
  }, e.label))
100384
100434
  }), document.body)]
100385
100435
  });
100386
- }, u7 = ({ division: e, depth: r, isActive: i, hasChildren: a, isExpanded: o, onToggleExpand: s, editDraft: c, onSelect: l, onDraftChange: u, onEditCommit: d, onEditCancel: f, menuItems: p, isNew: m = !1, isRoot: h = !1, parentType: g = null }) => {
100387
- let _ = c !== null, v = e.type === "introduction" || e.type === "conclusion" ? n7[e.type] : null;
100436
+ }, g7 = ({ division: e, depth: r, isActive: i, hasChildren: a, isExpanded: o, onToggleExpand: s, editDraft: c, onSelect: l, onDraftChange: u, onEditCommit: d, onEditCancel: f, menuItems: p, isNew: m = !1, isRoot: h = !1, parentType: g = null }) => {
100437
+ let _ = c !== null, v = e.type === "introduction" || e.type === "conclusion" ? c7[e.type] : null;
100388
100438
  return /* @__PURE__ */ n("li", {
100389
100439
  className: [
100390
100440
  "pretext-plus-editor__toc-item",
@@ -100410,7 +100460,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100410
100460
  className: "pretext-plus-editor__toc-select",
100411
100461
  onClick: l,
100412
100462
  "aria-current": i ? "true" : void 0,
100413
- title: n7[e.type] ?? e.type,
100463
+ title: c7[e.type] ?? e.type,
100414
100464
  children: [/* @__PURE__ */ t("span", {
100415
100465
  className: "pretext-plus-editor__toc-title",
100416
100466
  children: e.title || v || /* @__PURE__ */ t("em", { children: "Untitled" })
@@ -100421,10 +100471,10 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100421
100471
  }),
100422
100472
  /* @__PURE__ */ t("div", {
100423
100473
  className: "pretext-plus-editor__toc-actions",
100424
- children: /* @__PURE__ */ t(l7, { items: p })
100474
+ children: /* @__PURE__ */ t(h7, { items: p })
100425
100475
  })
100426
100476
  ]
100427
- }), _ && c && /* @__PURE__ */ t(c7, {
100477
+ }), _ && c && /* @__PURE__ */ t(m7, {
100428
100478
  draft: c,
100429
100479
  isNew: m,
100430
100480
  isRoot: h,
@@ -100434,8 +100484,8 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100434
100484
  onCancel: f
100435
100485
  })]
100436
100486
  });
100437
- }, d7 = ({ onOpenAssetPicker: r }) => {
100438
- let i = A6((e) => e.divisions), o = A6((e) => e.rootDivisionId), s = A6((e) => e.activeDivisionId), c = A6((e) => e.projectAssets) ?? [], l = A6((e) => e.selectSection), u = A6((e) => e.addSection), d = A6((e) => e.removeSection), f = A6((e) => e.divisionContentChange), p = A6((e) => e.insertAtCursor), m = A6((e) => e.openAssetEditor), h = A6((e) => e.openAssetResolver), g = A6((e) => e.removeAsset), _ = A6((e) => e.removeAssetRefFromDocument), v = A6((e) => e.duplicateAsset), y = A6((e) => e.hasAssetDuplicate), x = A6((e) => e.startSectionEdit), S = A6((e) => e.setEditDraft), C = A6((e) => e.commitSectionEdit), w = A6((e) => e.cancelSectionEdit), T = A6((e) => e.editingId), E = A6((e) => e.editDraft), D = A6((e) => e.editingIsNew), O = i ? i.find((e) => e.xmlId === o) ?? i.find((e) => e.type === "book" || e.type === "article" || e.type === "slideshow") ?? i[0] ?? null : null, k = O && i ? k5(i, O.xmlId) : [], A = O && i ? A5(i, O.xmlId) : [], j = U5(i, c), ee = K5.map((e) => ({
100487
+ }, _7 = ({ onOpenAssetPicker: r }) => {
100488
+ let i = A6((e) => e.divisions), o = A6((e) => e.rootDivisionId), s = A6((e) => e.activeDivisionId), c = A6((e) => e.projectAssets) ?? [], l = A6((e) => e.selectSection), u = A6((e) => e.addSection), d = A6((e) => e.removeSection), f = A6((e) => e.divisionContentChange), p = A6((e) => e.insertAtCursor), m = A6((e) => e.openAssetEditor), h = A6((e) => e.openAssetResolver), g = A6((e) => e.removeAsset), _ = A6((e) => e.removeAssetRefFromDocument), v = A6((e) => e.duplicateAsset), y = A6((e) => e.hasAssetDuplicate), x = A6((e) => e.startSectionEdit), S = A6((e) => e.setEditDraft), C = A6((e) => e.commitSectionEdit), w = A6((e) => e.cancelSectionEdit), T = A6((e) => e.editingId), E = A6((e) => e.editDraft), D = A6((e) => e.editingIsNew), O = i ? i.find((e) => e.xmlId === o) ?? i.find((e) => e.type === "book" || e.type === "article" || e.type === "slideshow") ?? i[0] ?? null : null, k = O && i ? F5(i, O.xmlId) : [], A = O && i ? I5(i, O.xmlId) : [], j = Y5(i, c), ee = Q5.map((e) => ({
100439
100489
  kind: e,
100440
100490
  rows: j.filter((t) => t.kind === e)
100441
100491
  })).filter((e) => e.rows.length > 0), [te, ne] = b(!1), [M, N] = b(null), re = async (e) => {
@@ -100477,21 +100527,21 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100477
100527
  let ue = (e, t) => {
100478
100528
  if (!i) return;
100479
100529
  let n = i.find((e) => e.xmlId === t);
100480
- n && f(n.xmlId, S5(n.content, e));
100530
+ n && f(n.xmlId, O5(n.content, e));
100481
100531
  }, I = (e, t) => {
100482
100532
  if (window.confirm(`Delete "${e.title || "Untitled"}"? This permanently removes the division.`)) {
100483
100533
  if (t && i) {
100484
100534
  let n = i.find((e) => e.xmlId === t);
100485
- n && f(n.xmlId, S5(n.content, e.xmlId));
100535
+ n && f(n.xmlId, O5(n.content, e.xmlId));
100486
100536
  }
100487
100537
  d(e.xmlId);
100488
100538
  }
100489
100539
  }, de = i?.find((e) => e.xmlId === s)?.sourceFormat ?? "pretext", fe = (e) => {
100490
100540
  p(de === "markdown" ? `::${e.type}{ref="${e.xmlId}"}` : de === "latex" ? `\\plus{${e.type}}{${e.xmlId}}` : `<plus:${e.type} ref="${e.xmlId}"/>`);
100491
100541
  }, pe = (e) => {
100492
- O && f(O.xmlId, x5(O.content, e.xmlId, e.type, null, O.sourceFormat));
100542
+ O && f(O.xmlId, D5(O.content, e.xmlId, e.type, null, O.sourceFormat));
100493
100543
  }, me = (e) => e && i?.find((t) => t.xmlId === e)?.type || null, he = (e) => e.status === "unlinked" ? h(e.kind, e.ref) : m(e.kind, e.ref), L = (e, t) => {
100494
- navigator.clipboard.writeText(v5(e, t, de)).catch(() => {});
100544
+ navigator.clipboard.writeText(w5(e, t, de)).catch(() => {});
100495
100545
  }, ge = (e) => {
100496
100546
  let t = [{
100497
100547
  label: e.status === "unlinked" ? "Link / create asset" : "Edit asset",
@@ -100520,7 +100570,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100520
100570
  className: "pretext-plus-editor__toc-list",
100521
100571
  role: "list",
100522
100572
  children: [
100523
- O && /* @__PURE__ */ t(u7, {
100573
+ O && /* @__PURE__ */ t(g7, {
100524
100574
  division: O,
100525
100575
  depth: 0,
100526
100576
  isActive: s === O.xmlId,
@@ -100535,7 +100585,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100535
100585
  menuItems: [{
100536
100586
  label: "Edit properties",
100537
100587
  onClick: () => x(O)
100538
- }, ...o5(O.sourceFormat) ? [{
100588
+ }, ...l5(O.sourceFormat) ? [{
100539
100589
  label: "Add new division",
100540
100590
  onClick: () => u(O.xmlId)
100541
100591
  }] : []],
@@ -100546,7 +100596,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100546
100596
  className: "pretext-plus-editor__toc-no-sections",
100547
100597
  children: /* @__PURE__ */ t("span", { children: "No placed divisions" })
100548
100598
  }),
100549
- le.map((e) => /* @__PURE__ */ t(u7, {
100599
+ le.map((e) => /* @__PURE__ */ t(g7, {
100550
100600
  division: e.division,
100551
100601
  depth: e.depth + 1,
100552
100602
  isActive: s === e.division.xmlId,
@@ -100563,7 +100613,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100563
100613
  label: "Edit properties",
100564
100614
  onClick: () => x(e.division)
100565
100615
  },
100566
- ...o5(e.division.sourceFormat) ? [{
100616
+ ...l5(e.division.sourceFormat) ? [{
100567
100617
  label: "Add new division",
100568
100618
  onClick: () => u(e.division.xmlId)
100569
100619
  }] : [],
@@ -100590,8 +100640,8 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100590
100640
  }), /* @__PURE__ */ t("ul", {
100591
100641
  className: "pretext-plus-editor__toc-list",
100592
100642
  children: A.map((e) => {
100593
- let r = i ? k5(i, e.xmlId) : [], o = new Set(r.map((e) => e.parentXmlId).filter(Boolean));
100594
- return /* @__PURE__ */ n(a, { children: [/* @__PURE__ */ t(u7, {
100643
+ let r = i ? F5(i, e.xmlId) : [], o = new Set(r.map((e) => e.parentXmlId).filter(Boolean));
100644
+ return /* @__PURE__ */ n(a, { children: [/* @__PURE__ */ t(g7, {
100595
100645
  division: e,
100596
100646
  depth: 0,
100597
100647
  isActive: s === e.xmlId,
@@ -100623,7 +100673,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100623
100673
  }
100624
100674
  ],
100625
100675
  parentType: null
100626
- }), P(e.xmlId) && r.map((e) => /* @__PURE__ */ t(u7, {
100676
+ }), P(e.xmlId) && r.map((e) => /* @__PURE__ */ t(g7, {
100627
100677
  division: e.division,
100628
100678
  depth: e.depth + 1,
100629
100679
  isActive: s === e.division.xmlId,
@@ -100694,7 +100744,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100694
100744
  className: "pretext-plus-editor__toc-assets-groups",
100695
100745
  children: ee.map(({ kind: e, rows: r }) => /* @__PURE__ */ n("div", { children: [/* @__PURE__ */ t("div", {
100696
100746
  className: "pretext-plus-editor__toc-assets-group-header",
100697
- children: G5[e]
100747
+ children: Z5[e]
100698
100748
  }), /* @__PURE__ */ t("ul", {
100699
100749
  className: "pretext-plus-editor__toc-assets-list",
100700
100750
  children: r.map((e) => /* @__PURE__ */ n("li", {
@@ -100736,7 +100786,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100736
100786
  role: "status",
100737
100787
  "aria-label": "Duplicating asset",
100738
100788
  title: "Duplicating…"
100739
- }) : /* @__PURE__ */ t(l7, { items: ge(e) })
100789
+ }) : /* @__PURE__ */ t(h7, { items: ge(e) })
100740
100790
  })
100741
100791
  ]
100742
100792
  }, e.ref))
@@ -100751,7 +100801,7 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100751
100801
  children: "Manage Assets"
100752
100802
  })
100753
100803
  ] });
100754
- }, f7 = ({ isCollapsed: e, onToggleCollapse: r, onOpenAssetPicker: i }) => e ? /* @__PURE__ */ t("div", {
100804
+ }, v7 = ({ isCollapsed: e, onToggleCollapse: r, onOpenAssetPicker: i }) => e ? /* @__PURE__ */ t("div", {
100755
100805
  className: "pretext-plus-editor__toc pretext-plus-editor__toc--collapsed",
100756
100806
  children: /* @__PURE__ */ t("button", {
100757
100807
  type: "button",
@@ -100779,8 +100829,8 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100779
100829
  children: "✕"
100780
100830
  })
100781
100831
  })]
100782
- }), /* @__PURE__ */ t(d7, { onOpenAssetPicker: i })]
100783
- }), p7 = class extends i {
100832
+ }), /* @__PURE__ */ t(_7, { onOpenAssetPicker: i })]
100833
+ }), y7 = class extends i {
100784
100834
  state = { error: null };
100785
100835
  static getDerivedStateFromError(e) {
100786
100836
  return { error: e };
@@ -100816,8 +100866,8 @@ var c7 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
100816
100866
  ]
100817
100867
  });
100818
100868
  }
100819
- }, m7 = (e, t) => e.kind === t.kind && e.ref === t.ref;
100820
- function h7(e) {
100869
+ }, b7 = (e, t) => e.kind === t.kind && e.ref === t.ref;
100870
+ function x7(e) {
100821
100871
  let t = () => {}, n = { cbs: {
100822
100872
  selectDivision: t,
100823
100873
  addDivision: t,
@@ -100903,13 +100953,13 @@ function h7(e) {
100903
100953
  updateSection: (e, t) => n.cbs.updateDivision(e, t),
100904
100954
  divisionContentChange: (e, t) => n.cbs.divisionContentChange?.(e, t),
100905
100955
  startSectionEdit: (e, n) => {
100906
- let { xmlId: r, label: i } = e.sourceFormat === "markdown" ? r5(e.content) ?? {
100956
+ let { xmlId: r, label: i } = e.sourceFormat === "markdown" ? o5(e.content) ?? {
100907
100957
  xmlId: e.xmlId,
100908
100958
  label: ""
100909
100959
  } : e.sourceFormat === "latex" ? {
100910
- xmlId: B8(e.content) || e.xmlId,
100960
+ xmlId: U8(e.content) || e.xmlId,
100911
100961
  label: ""
100912
- } : q8(e.content);
100962
+ } : X8(e.content);
100913
100963
  t({
100914
100964
  editingId: e.xmlId,
100915
100965
  editDraft: {
@@ -100928,7 +100978,7 @@ function h7(e) {
100928
100978
  if (e && i) {
100929
100979
  let t = (a ?? []).find((t) => t.xmlId === e), r = null;
100930
100980
  if (t) {
100931
- let t = J8(i.xmlId);
100981
+ let t = Z8(i.xmlId);
100932
100982
  if (!t) {
100933
100983
  window.alert("xml:id can't be empty — it identifies the division and is used by references to it.");
100934
100984
  return;
@@ -100978,14 +101028,14 @@ function h7(e) {
100978
101028
  setProjectAssets: (e) => t({ projectAssets: e }),
100979
101029
  addAssetToPool: (e) => t((t) => {
100980
101030
  let n = t.projectAssets ?? [];
100981
- return n.some((t) => m7(t, e)) ? {} : { projectAssets: [...n, e] };
101031
+ return n.some((t) => b7(t, e)) ? {} : { projectAssets: [...n, e] };
100982
101032
  }),
100983
101033
  updateAssetInPool: (e) => t((t) => {
100984
101034
  let n = t.projectAssets ?? [];
100985
- return n.some((t) => m7(t, e)) ? { projectAssets: n.map((t) => m7(t, e) ? e : t) } : { projectAssets: [...n, e] };
101035
+ return n.some((t) => b7(t, e)) ? { projectAssets: n.map((t) => b7(t, e) ? e : t) } : { projectAssets: [...n, e] };
100986
101036
  }),
100987
- renameAssetInPool: (e, n, r) => t((t) => ({ projectAssets: [...(t.projectAssets ?? []).filter((t) => !(t.kind === e && t.ref === n) && !m7(t, r)), r] })),
100988
- removeAssetFromPool: (e) => t((t) => ({ projectAssets: (t.projectAssets ?? []).filter((t) => !m7(t, e)) })),
101037
+ renameAssetInPool: (e, n, r) => t((t) => ({ projectAssets: [...(t.projectAssets ?? []).filter((t) => !(t.kind === e && t.ref === n) && !b7(t, r)), r] })),
101038
+ removeAssetFromPool: (e) => t((t) => ({ projectAssets: (t.projectAssets ?? []).filter((t) => !b7(t, e)) })),
100989
101039
  updateTitle: (e) => n.cbs.updateTitle(e),
100990
101040
  feedbackSubmit: (e) => n.cbs.feedbackSubmit?.(e)
100991
101041
  })),
@@ -100996,7 +101046,7 @@ function h7(e) {
100996
101046
  }
100997
101047
  //#endregion
100998
101048
  //#region src/store/EditorStoreProvider.tsx
100999
- function g7({ store: e, children: n }) {
101049
+ function S7({ store: e, children: n }) {
101000
101050
  return /* @__PURE__ */ t(k6.Provider, {
101001
101051
  value: e,
101002
101052
  children: n
@@ -101004,10 +101054,10 @@ function g7({ store: e, children: n }) {
101004
101054
  }
101005
101055
  //#endregion
101006
101056
  //#region src/components/Editors.tsx
101007
- var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type === "article" || e.type === "slideshow") ?? e[0] ?? null, v7 = (e) => {
101057
+ var C7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type === "article" || e.type === "slideshow") ?? e[0] ?? null, w7 = (e) => {
101008
101058
  let [n] = b(() => {
101009
- let t = _7(e.divisions, e.rootDivisionId), n = H5(e.divisions, t?.xmlId, e.projectType, e.title), r = n.find((e) => e.xmlId === t?.xmlId) ?? t, i = e.activeDivisionId ?? r?.xmlId ?? null, a = n.find((e) => e.xmlId === i) ?? r;
101010
- return h7({
101059
+ let t = C7(e.divisions, e.rootDivisionId), n = J5(e.divisions, t?.xmlId, e.projectType, e.title), r = n.find((e) => e.xmlId === t?.xmlId) ?? t, i = e.activeDivisionId ?? r?.xmlId ?? null, a = n.find((e) => e.xmlId === i) ?? r;
101060
+ return x7({
101011
101061
  source: a?.content ?? "",
101012
101062
  sourceFormat: a?.sourceFormat ?? "pretext",
101013
101063
  title: e.title || r?.title || "Document Title",
@@ -101020,19 +101070,19 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101020
101070
  projectAssets: e.projectAssets
101021
101071
  });
101022
101072
  });
101023
- return /* @__PURE__ */ t(g7, {
101073
+ return /* @__PURE__ */ t(S7, {
101024
101074
  store: n.store,
101025
- children: /* @__PURE__ */ t(y7, {
101075
+ children: /* @__PURE__ */ t(T7, {
101026
101076
  ...e,
101027
101077
  bindCallbacks: n.bindCallbacks
101028
101078
  })
101029
101079
  });
101030
- }, y7 = (e) => {
101080
+ }, T7 = (e) => {
101031
101081
  let { bindCallbacks: r } = e, i = A6((e) => e.showFullPreview), a = A6((e) => e.isNarrowScreen), o = A6((e) => e.setIsNarrowScreen), s = A6((e) => e.activeTab), c = A6((e) => e.setActiveTab), l = A6((e) => e.isTocCollapsed), u = A6((e) => e.setIsTocCollapsed), d = A6((e) => e.isLatexDialogOpen), f = A6((e) => e.isConvertDialogOpen), p = A6((e) => e.isDocinfoEditorOpen), h = A6((e) => e.isAssetPickerOpen), g = A6((e) => e.isFullSourceOpen), x = A6((e) => e.editingAssetRef), S = A6((e) => e.openAssetEditor), C = A6((e) => e.closeAssetEditor), w = A6((e) => e.assetResolveTarget), T = A6((e) => e.closeAssetResolver), [E, D] = b(null), O = A6((e) => e.openModal), k = A6((e) => e.closeModal), A = A6((e) => e.syncState), j = A6((e) => e.projectAssets), ee = A6((e) => e.addAssetToPool), te = A6((e) => e.updateAssetInPool), ne = A6((e) => e.renameAssetInPool), M = A6((e) => e.removeAssetFromPool), N = x ? j?.find((e) => e.kind === x.kind && e.ref === x.ref) : void 0, re = A6((e) => e.divisions), ie = v(() => re ?? [], [re]), ae = A6((e) => e.activeDivisionId), P = A6((e) => e.title), oe = A6((e) => e.docinfo), F = A6((e) => e.commonDocinfo), se = A6((e) => e.useCommonDocinfo), ce = A6((e) => e.applyExternalUpdate), le = A6((e) => e.setDivisionContent), ue = A6((e) => e.patchDivision), I = A6((e) => e.addDivisionToPool), de = A6((e) => e.removeDivisionFromPool), fe = A6((e) => e.setActiveDivisionId), pe = A6((e) => e.startSectionEdit), me = A6((e) => e.setTitle), he = A6((e) => e.setDocinfo), L = A6((e) => e.editingId), ge = A6((e) => e.editingIsNew), _e = y(null), ve = y(null), ye = y(!1);
101032
101082
  m(() => {
101033
101083
  L && ge ? ye.current = !0 : ye.current && (ye.current = !1, ve.current?.focus());
101034
101084
  }, [L, ge]);
101035
- let be = _7(ie, e.rootDivisionId), xe = ie.find((e) => e.xmlId === ae) ?? ie[0] ?? null, Se = xe?.sourceFormat ?? "pretext", R = xe?.content ?? "", Ce = (t, n, r, i) => {
101085
+ let be = C7(ie, e.rootDivisionId), xe = ie.find((e) => e.xmlId === ae) ?? ie[0] ?? null, Se = xe?.sourceFormat ?? "pretext", R = xe?.content ?? "", Ce = (t, n, r, i) => {
101036
101086
  le(t, n), e.onContentChange({
101037
101087
  xmlId: t,
101038
101088
  sourceContent: n,
@@ -101057,17 +101107,17 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101057
101107
  type: e,
101058
101108
  title: i,
101059
101109
  xmlId: a,
101060
- content: b5(e, t.sourceFormat, i, a)
101110
+ content: E5(e, t.sourceFormat, i, a)
101061
101111
  };
101062
- } else r = n.sourceFormat === "markdown" ? i5(n, t) : n.sourceFormat === "latex" ? V8(n, t) : Z8(n, t);
101112
+ } else r = n.sourceFormat === "markdown" ? s5(n, t) : n.sourceFormat === "latex" ? W8(n, t) : e5(n, t);
101063
101113
  let i = r.xmlId;
101064
101114
  if (r.content !== n.content && Ce(n.xmlId, r.content, r.sourceFormat), we(e, {
101065
101115
  ...t,
101066
101116
  xmlId: i
101067
101117
  }), i !== n.xmlId || r.type !== n.type) {
101068
- let e = T5(ie, n.xmlId);
101118
+ let e = j5(ie, n.xmlId);
101069
101119
  if (e) {
101070
- let t = w5(e.content, n.xmlId, i, r.type);
101120
+ let t = A5(e.content, n.xmlId, i, r.type);
101071
101121
  t !== e.content && Ce(e.xmlId, t, e.sourceFormat);
101072
101122
  }
101073
101123
  }
@@ -101080,7 +101130,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101080
101130
  fe(t), e.onDivisionSelect?.(t);
101081
101131
  }, Oe = v(() => {
101082
101132
  if (!xe || Se === "pretext") return;
101083
- if (Se === "latex") return H8(xe) ?? void 0;
101133
+ if (Se === "latex") return G8(xe) ?? void 0;
101084
101134
  let e = S6(R, Se);
101085
101135
  return e.pretextError ? void 0 : e.pretextSource;
101086
101136
  }, [
@@ -101091,8 +101141,8 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101091
101141
  if (!xe) return;
101092
101142
  let t = e || "";
101093
101143
  if (Se === "pretext") {
101094
- let e = X8(t);
101095
- e && e.xmlId !== xe.xmlId && (t = Z8({
101144
+ let e = $8(t);
101145
+ e && e.xmlId !== xe.xmlId && (t = e5({
101096
101146
  ...xe,
101097
101147
  content: t,
101098
101148
  title: e.title,
@@ -101102,54 +101152,54 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101102
101152
  label: e.label || null
101103
101153
  }).content);
101104
101154
  } else if (Se === "markdown") {
101105
- let e = r5(t);
101106
- e && e.xmlId !== xe.xmlId && (t = i5({
101155
+ let e = o5(t);
101156
+ e && e.xmlId !== xe.xmlId && (t = s5({
101107
101157
  ...xe,
101108
101158
  content: t
101109
101159
  }, { xmlId: xe.xmlId }).content);
101110
101160
  }
101111
101161
  if (t === xe.content) return;
101112
101162
  if (Ce(xe.xmlId, t, Se), Se === "pretext") {
101113
- let e = X8(t);
101163
+ let e = $8(t);
101114
101164
  if (e && (we(xe.xmlId, {
101115
101165
  title: e.title,
101116
101166
  type: e.type,
101117
101167
  label: e.label || null
101118
101168
  }), e.type !== xe.type)) {
101119
- let t = T5(ie, xe.xmlId);
101169
+ let t = j5(ie, xe.xmlId);
101120
101170
  if (t) {
101121
- let n = w5(t.content, xe.xmlId, xe.xmlId, e.type);
101171
+ let n = A5(t.content, xe.xmlId, xe.xmlId, e.type);
101122
101172
  n !== t.content && Ce(t.xmlId, n, t.sourceFormat);
101123
101173
  }
101124
101174
  }
101125
101175
  } else if (Se === "markdown") {
101126
- let e = r5(t);
101176
+ let e = o5(t);
101127
101177
  if (e && (we(xe.xmlId, {
101128
101178
  title: e.title,
101129
101179
  type: e.type,
101130
101180
  label: e.label || null
101131
101181
  }), e.type !== xe.type)) {
101132
- let t = T5(ie, xe.xmlId);
101182
+ let t = j5(ie, xe.xmlId);
101133
101183
  if (t) {
101134
- let n = w5(t.content, xe.xmlId, xe.xmlId, e.type);
101184
+ let n = A5(t.content, xe.xmlId, xe.xmlId, e.type);
101135
101185
  n !== t.content && Ce(t.xmlId, n, t.sourceFormat);
101136
101186
  }
101137
101187
  }
101138
101188
  } else if (Se === "latex") {
101139
- let e = z8(t);
101189
+ let e = H8(t);
101140
101190
  e !== null && we(xe.xmlId, { title: e });
101141
101191
  }
101142
101192
  let n = new Set(ie.map((e) => e.xmlId));
101143
- for (let { xmlId: e, type: r } of m5(t)) n.has(e) || (z(y5(e, r, Se)), n.add(e));
101193
+ for (let { xmlId: e, type: r } of b5(t, Se)) n.has(e) || (z(T5(e, r, Se)), n.add(e));
101144
101194
  }, ke = (e) => {
101145
101195
  De(e);
101146
101196
  }, Ae = () => {
101147
101197
  xe && (u(!1), pe(xe));
101148
101198
  }, je = (e) => {
101149
- let t = O8();
101199
+ let t = j8();
101150
101200
  if (z(t), e) {
101151
101201
  let n = ie.find((t) => t.xmlId === e);
101152
- n && Ce(n.xmlId, x5(n.content, t.xmlId, t.type, null, n.sourceFormat), n.sourceFormat);
101202
+ n && Ce(n.xmlId, D5(n.content, t.xmlId, t.type, null, n.sourceFormat), n.sourceFormat);
101153
101203
  }
101154
101204
  fe(t.xmlId), pe(t, { isNew: !0 });
101155
101205
  }, Me = (e) => {
@@ -101158,7 +101208,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101158
101208
  M(t), e.onAssetRemove?.(t);
101159
101209
  }, Pe = !!(e.onAssetUpload && e.onAssetFetchUrl && e.onAssetUpdate), Fe = !!(e.onAssetRemove && (e.onAssetUpload || e.onAssetAddFromLibrary)), Ie = async (t) => {
101160
101210
  if (!e.onAssetUpload || !e.onAssetFetchUrl || !t.ref || !t.url) return;
101161
- let n = new Set(U5(ie, j).map((e) => e.ref)), r = W5(t.ref, n), i = await e.onAssetFetchUrl(t.url), a = /\.[^./\\]+$/.exec(i.name)?.[0] ?? "", o = new File([i], `${r}${a}`, { type: i.type }), s = {
101211
+ let n = new Set(Y5(ie, j).map((e) => e.ref)), r = X5(t.ref, n), i = await e.onAssetFetchUrl(t.url), a = /\.[^./\\]+$/.exec(i.name)?.[0] ?? "", o = new File([i], `${r}${a}`, { type: i.type }), s = {
101162
101212
  ...await e.onAssetUpload(o),
101163
101213
  ref: r,
101164
101214
  name: `${t.name} (copy)`,
@@ -101179,12 +101229,12 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101179
101229
  e.onAssetRemove?.(t), M(t);
101180
101230
  }, Re = (e, t, n) => {
101181
101231
  if (t !== n) for (let r of ie) {
101182
- let i = g5(r.content, e, t, n);
101232
+ let i = S5(r.content, e, t, n);
101183
101233
  i !== r.content && Ce(r.xmlId, i, r.sourceFormat);
101184
101234
  }
101185
101235
  }, ze = (e, t) => {
101186
101236
  for (let n of ie) {
101187
- let r = _5(n.content, e, t);
101237
+ let r = C5(n.content, e, t);
101188
101238
  r !== n.content && Ce(n.xmlId, r, n.sourceFormat);
101189
101239
  }
101190
101240
  };
@@ -101239,7 +101289,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101239
101289
  m(() => {
101240
101290
  let t = Ve.current, n = {}, r = !1;
101241
101291
  if (e.projectAssets !== void 0 && e.projectAssets !== t.projectAssets && (n.projectAssets = e.projectAssets, r = !0), e.divisions !== t.divisions) {
101242
- let t = _7(e.divisions, e.rootDivisionId), i = H5(e.divisions, t?.xmlId, e.projectType, e.title);
101292
+ let t = C7(e.divisions, e.rootDivisionId), i = J5(e.divisions, t?.xmlId, e.projectType, e.title);
101243
101293
  n.divisions = i;
101244
101294
  let a = i.find((e) => e.xmlId === t?.xmlId) ?? t;
101245
101295
  (ae == null || !e.divisions.some((e) => e.xmlId === ae)) && (n.activeDivisionId = a?.xmlId ?? null), !e.title && a?.title && (n.title = a.title), r = !0;
@@ -101258,7 +101308,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101258
101308
  m(() => {
101259
101309
  if (He.current === e.divisions) return;
101260
101310
  He.current = e.divisions;
101261
- let t = _7(e.divisions, e.rootDivisionId), n = H5(e.divisions, t?.xmlId, e.projectType, e.title);
101311
+ let t = C7(e.divisions, e.rootDivisionId), n = J5(e.divisions, t?.xmlId, e.projectType, e.title);
101262
101312
  for (let t of n) {
101263
101313
  if (t.sourceFormat !== "pretext") continue;
101264
101314
  let n = e.divisions.find((e) => e.xmlId === t.xmlId);
@@ -101273,7 +101323,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101273
101323
  let V = se ? F : oe, Ue = v(() => {
101274
101324
  if (!g || !be) return "";
101275
101325
  try {
101276
- return R5(ie, be.xmlId, V, j ?? []);
101326
+ return W5(ie, be.xmlId, V, j ?? []);
101277
101327
  } catch (e) {
101278
101328
  return `<!-- Unable to assemble document source: ${e instanceof Error ? e.message : String(e)} -->`;
101279
101329
  }
@@ -101283,14 +101333,14 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101283
101333
  ie,
101284
101334
  V,
101285
101335
  j
101286
- ]), We = xe ? Se === "pretext" ? I5(ie, xe.xmlId, j) : Oe : void 0, Ge = xe && We !== void 0 ? B5(xe.type, We, V, xe.title) : void 0, Ke = () => _e.current?.rebuild(), qe = () => {
101336
+ ]), We = xe ? Se === "pretext" ? H5(ie, xe.xmlId, j) : Oe : void 0, Ge = xe && We !== void 0 ? K5(xe.type, We, V, xe.title) : void 0, Ke = () => _e.current?.rebuild(), qe = () => {
101287
101337
  e.onSave?.(), _e.current?.rebuild();
101288
101338
  }, Je = (t) => {
101289
101339
  let n = t.ctrlKey || t.metaKey;
101290
101340
  n && t.key === "Enter" && e.onPreviewRebuild ? (t.preventDefault(), Ke()) : n && t.key === "s" && (t.preventDefault(), qe());
101291
101341
  }, Ye = () => {
101292
101342
  if (!xe || !Oe) return;
101293
- let e = O8(), t = {
101343
+ let e = j8(), t = {
101294
101344
  id: e.xmlId,
101295
101345
  xmlId: xe.xmlId,
101296
101346
  title: xe.title,
@@ -101298,7 +101348,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101298
101348
  sourceFormat: Se,
101299
101349
  content: xe.content
101300
101350
  };
101301
- z(Se === "markdown" ? i5(t, { xmlId: e.xmlId }) : V8(t, { xmlId: e.xmlId })), Ce(xe.xmlId, Oe, "pretext"), we(xe.xmlId, { sourceFormat: "pretext" });
101351
+ z(Se === "markdown" ? s5(t, { xmlId: e.xmlId }) : W8(t, { xmlId: e.xmlId })), Ce(xe.xmlId, Oe, "pretext"), we(xe.xmlId, { sourceFormat: "pretext" });
101302
101352
  }, Xe = /* @__PURE__ */ t(fc, {
101303
101353
  ref: ve,
101304
101354
  content: R,
@@ -101325,7 +101375,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101325
101375
  editDisabledReason: Se === "markdown" ? "Visual editing is not available for Markdown documents." : Se === "latex" ? "Visual editing is not available for LaTeX documents." : "",
101326
101376
  onChange: (e) => B(e)
101327
101377
  });
101328
- let Qe = /* @__PURE__ */ t(f7, {
101378
+ let Qe = /* @__PURE__ */ t(v7, {
101329
101379
  isCollapsed: l,
101330
101380
  onToggleCollapse: () => u((e) => !e),
101331
101381
  onOpenAssetPicker: e.projectAssets === void 0 ? void 0 : () => O("isAssetPickerOpen")
@@ -101392,7 +101442,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101392
101442
  }), /* @__PURE__ */ n("div", {
101393
101443
  className: "pretext-plus-editor",
101394
101444
  onKeyDown: Je,
101395
- children: [/* @__PURE__ */ t($5, {
101445
+ children: [/* @__PURE__ */ t(a7, {
101396
101446
  onSaveButton: e.onSaveButton,
101397
101447
  saveButtonLabel: e.saveButtonLabel,
101398
101448
  onCancelButton: e.onCancelButton,
@@ -101401,7 +101451,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101401
101451
  }), /* @__PURE__ */ n("div", {
101402
101452
  className: "pretext-plus-editor__editor-displays",
101403
101453
  children: [
101404
- /* @__PURE__ */ t(p7, {
101454
+ /* @__PURE__ */ t(y7, {
101405
101455
  resetKeys: [R, ae],
101406
101456
  children: nt
101407
101457
  }),
@@ -101434,7 +101484,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101434
101484
  }
101435
101485
  }
101436
101486
  }) : null,
101437
- (h || w || E) && e.projectAssets !== void 0 ? /* @__PURE__ */ t(J5, {
101487
+ (h || w || E) && e.projectAssets !== void 0 ? /* @__PURE__ */ t(e7, {
101438
101488
  open: h || !!w || !!E,
101439
101489
  resolveTarget: w,
101440
101490
  replaceTarget: E,
@@ -101457,7 +101507,7 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101457
101507
  source: Ue,
101458
101508
  onClose: () => k("isFullSourceOpen")
101459
101509
  }) : null,
101460
- N ? /* @__PURE__ */ t(Q5, {
101510
+ N ? /* @__PURE__ */ t(i7, {
101461
101511
  asset: N,
101462
101512
  projectAssets: j ?? [],
101463
101513
  onClose: C,
@@ -101474,6 +101524,6 @@ var _7 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
101474
101524
  });
101475
101525
  };
101476
101526
  //#endregion
101477
- export { fc as CodeEditor, J6 as DocinfoEditor, v7 as Editors, w6 as FeedbackLink, jR as FullPreview, OR as VisualEditor, R5 as assembleFullProjectSource, I5 as assembleProjectSource, k5 as buildDivisionTree, y6 as convertLatexToPretext, A8 as createConclusion, k8 as createIntroduction, G8 as createLatexConclusion, W8 as createLatexIntroduction, U8 as createNewLatexSection, O8 as createNewSection, S6 as derivePretextContent, v6 as detectSourceFormat, I8 as ensureLatexSectionWrapper, N8 as ensureSectionWrapper, X8 as extractDivisionMetadata, z8 as extractLatexDivisionTitle, T5 as findDivisionParent, A5 as getOrphanRoots, O5 as getOrphanedDivisions, q8 as getSectionAttributes, x5 as insertDivisionRef, K8 as mergeTwoSections, C5 as moveDivisionRef, p5 as parseDivisionRefs, AR as postToIframe, S5 as removeDivisionRef, w5 as renameDivisionRef, E5 as reorderDivisionRefs, F8 as rewrapLatexSection, M8 as rewrapSection, P8 as stripLatexSectionWrapper, j8 as stripSectionWrapper, D8 as updateDivisionTitle, R8 as updateLatexSectionTitle, Z8 as updateSectionMetadata, B5 as wrapDivisionForPreview };
101527
+ export { fc as CodeEditor, J6 as DocinfoEditor, w7 as Editors, w6 as FeedbackLink, jR as FullPreview, OR as VisualEditor, W5 as assembleFullProjectSource, H5 as assembleProjectSource, F5 as buildDivisionTree, y6 as convertLatexToPretext, N8 as createConclusion, M8 as createIntroduction, J8 as createLatexConclusion, q8 as createLatexIntroduction, K8 as createNewLatexSection, j8 as createNewSection, S6 as derivePretextContent, v6 as detectSourceFormat, z8 as ensureLatexSectionWrapper, I8 as ensureSectionWrapper, $8 as extractDivisionMetadata, H8 as extractLatexDivisionTitle, j5 as findDivisionParent, I5 as getOrphanRoots, P5 as getOrphanedDivisions, X8 as getSectionAttributes, D5 as insertDivisionRef, Y8 as mergeTwoSections, k5 as moveDivisionRef, y5 as parseDivisionRefs, AR as postToIframe, O5 as removeDivisionRef, A5 as renameDivisionRef, M5 as reorderDivisionRefs, R8 as rewrapLatexSection, F8 as rewrapSection, L8 as stripLatexSectionWrapper, P8 as stripSectionWrapper, A8 as updateDivisionTitle, V8 as updateLatexSectionTitle, e5 as updateSectionMetadata, K5 as wrapDivisionForPreview };
101478
101528
 
101479
101529
  //# sourceMappingURL=index.es.js.map