@embedpdf-editor/vue3-chapter-viewer 1.0.9-beta.1 → 1.0.9-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import { AnnotationLayer, useAnnotationCapability } from "@embedpdf/plugin-annot
24
24
  import { RedactionLayer } from "@embedpdf/plugin-redaction/vue";
25
25
  import { RenderLayer } from "@embedpdf/plugin-render/vue";
26
26
  import { usePdfiumEngine } from "@embedpdf/engines/vue";
27
- const Pe$1 = { position: "relative", height: "100%", width: "100%" }, Ie = { userSelect: "none", WebkitUserSelect: "none" };
27
+ const Ie = { position: "relative", height: "100%", width: "100%" }, Pe$1 = { userSelect: "none", WebkitUserSelect: "none" };
28
28
  function be$1() {
29
29
  var _a2;
30
30
  "undefined" != typeof window && ((_a2 = window.getSelection()) == null ? void 0 : _a2.removeAllRanges());
@@ -404,12 +404,21 @@ const st$1 = class e extends BasePlugin {
404
404
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
405
405
  }
406
406
  scheduleVisibleSegmentLoads(e14) {
407
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
408
- for (const r2 of t2) {
409
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
410
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
407
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
408
+ for (const o2 of t2) {
409
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
410
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
411
411
  }
412
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
412
+ const a2 = [];
413
+ let i2 = true;
414
+ for (; i2; ) {
415
+ i2 = false;
416
+ for (const e15 of r2) {
417
+ const t3 = n9.get(e15);
418
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
419
+ }
420
+ }
421
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
413
422
  }
414
423
  pumpVisibleSegmentBacklog() {
415
424
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -738,7 +747,7 @@ function ft$1(e14) {
738
747
  function vt$1(e14, t2) {
739
748
  return e14 <= 0 || t2 <= 0 ? 0 : Math.ceil(e14 / t2);
740
749
  }
741
- function Pt$1(e14) {
750
+ function It$1(e14) {
742
751
  const t2 = gt$1(e14);
743
752
  if (!t2) return null;
744
753
  const s2 = ut$1(e14), n9 = vt$1(s2, t2), r2 = pt$1(e14.source) ? e14.source.urls : void 0, a2 = [];
@@ -749,8 +758,8 @@ function Pt$1(e14) {
749
758
  }
750
759
  return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
751
760
  }
752
- function It$1(e14, t2) {
753
- const s2 = Pt$1(e14);
761
+ function Pt$1(e14, t2) {
762
+ const s2 = It$1(e14);
754
763
  if (!s2) return { documentId: e14.chapterId, pageIndex: t2 };
755
764
  const n9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
756
765
  if (!n9) {
@@ -760,7 +769,7 @@ function It$1(e14, t2) {
760
769
  return { documentId: n9.documentId, pageIndex: t2 - n9.localPageStart };
761
770
  }
762
771
  function bt$1(e14, t2) {
763
- const s2 = Pt$1(e14);
772
+ const s2 = It$1(e14);
764
773
  if (!s2) return 0;
765
774
  const n9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
766
775
  return (null == n9 ? void 0 : n9.index) ?? Math.floor(t2 / s2.threshold);
@@ -881,10 +890,10 @@ const xt$1 = class e2 extends BasePlugin {
881
890
  t2 && (this.overlapStrategy = t2), this.setManifestInternal(e14);
882
891
  }, getManifest: () => this.manifest, getVirtualPageMap: () => this.virtualPageMap, setVisibleGlobalPages: (e14) => this.handleVisibleChange(e14), visibleRangeNeedsSegmentLoad: (e14) => this.visibleRangeNeedsSegmentLoad(e14), shouldShowChapterLoadError: (e14, t2) => this.shouldShowChapterLoadError(e14, t2), ensureChapterLoaded: (e14) => this.ensureChapterLoaded(e14), ensureSegmentLoaded: (e14, t2) => this.ensureSegmentLoaded(e14, t2), ensureAllSegmentsLoaded: (e14) => this.ensureAllSegmentsLoaded(e14), resolvePageDocument: (e14, t2) => {
883
892
  const s2 = this.findChapter(e14);
884
- return s2 ? It$1(s2, t2) : null;
893
+ return s2 ? Pt$1(s2, t2) : null;
885
894
  }, getSegmentPlan: (e14) => {
886
895
  const t2 = this.findChapter(e14);
887
- return t2 ? Pt$1(t2) : null;
896
+ return t2 ? It$1(t2) : null;
888
897
  }, isSegmentLoaded: (e14, t2) => this.isSegmentDocumentOpen(e14, t2), isSegmentLoadPending: (e14, t2) => this.isSegmentLoadPending(e14, t2), getChapterErrorMessage: (e14) => this.chapterErrorMessages.get(e14), getChapterStatus: (e14) => this.chapterStatus.get(e14) ?? "idle", getChapter: (e14) => this.findChapter(e14), onChapterStatusChange: this.statusChange$.on, onManifestChange: this.manifestChange$.on };
889
898
  }
890
899
  destroy() {
@@ -941,7 +950,7 @@ const xt$1 = class e2 extends BasePlugin {
941
950
  }
942
951
  getSegmentPlanForChapter(e14) {
943
952
  const t2 = this.findChapter(e14);
944
- return t2 ? Pt$1(t2) : null;
953
+ return t2 ? It$1(t2) : null;
945
954
  }
946
955
  anySegmentOpen(e14) {
947
956
  const t2 = this.getSegmentPlanForChapter(e14), s2 = this.documentManager.provides();
@@ -1013,17 +1022,26 @@ const xt$1 = class e2 extends BasePlugin {
1013
1022
  if (!this.virtualPageMap) return Number.MAX_SAFE_INTEGER;
1014
1023
  const n9 = this.findChapter(e14);
1015
1024
  if (!n9) return Number.MAX_SAFE_INTEGER;
1016
- const r2 = Pt$1(n9), a2 = (null == (s2 = null == r2 ? void 0 : r2.segments[t2]) ? void 0 : s2.localPageStart) ?? 0, i2 = this.virtualPageMap.toGlobal(e14, a2);
1025
+ const r2 = It$1(n9), a2 = (null == (s2 = null == r2 ? void 0 : r2.segments[t2]) ? void 0 : s2.localPageStart) ?? 0, i2 = this.virtualPageMap.toGlobal(e14, a2);
1017
1026
  if (i2) return i2.globalPageIndex;
1018
1027
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
1019
1028
  }
1020
1029
  scheduleVisibleSegmentLoads(e14) {
1021
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
1022
- for (const r2 of t2) {
1023
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
1024
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
1030
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
1031
+ for (const o2 of t2) {
1032
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
1033
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
1025
1034
  }
1026
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
1035
+ const a2 = [];
1036
+ let i2 = true;
1037
+ for (; i2; ) {
1038
+ i2 = false;
1039
+ for (const e15 of r2) {
1040
+ const t3 = n9.get(e15);
1041
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
1042
+ }
1043
+ }
1044
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
1027
1045
  }
1028
1046
  pumpVisibleSegmentBacklog() {
1029
1047
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -1060,7 +1078,7 @@ const xt$1 = class e2 extends BasePlugin {
1060
1078
  if (t3 < 0) return;
1061
1079
  const s3 = this.findChapter(e15);
1062
1080
  if (!s3) return;
1063
- const n10 = Pt$1(s3);
1081
+ const n10 = It$1(s3);
1064
1082
  if (n10 && t3 >= n10.segments.length) return;
1065
1083
  const a3 = `${e15}:${t3}`, o3 = this.segmentStartGlobalIndex(e15, t3), l2 = Math.abs(o3 - r2), h3 = i2.get(a3);
1066
1084
  (void 0 === h3 || l2 < h3) && i2.set(a3, l2);
@@ -1094,7 +1112,7 @@ const xt$1 = class e2 extends BasePlugin {
1094
1112
  if (this.config.autoActivateOnLoad ?? 1) {
1095
1113
  const e15 = this.virtualPageMap.atIndex(r2);
1096
1114
  if (e15) {
1097
- const t3 = It$1(this.findChapter(e15.chapterId), e15.localPageIndex);
1115
+ const t3 = Pt$1(this.findChapter(e15.chapterId), e15.localPageIndex);
1098
1116
  if (this.documentManager.provides().isDocumentOpen(t3.documentId)) {
1099
1117
  this.documentManager.provides().getActiveDocumentId() !== t3.documentId && this.documentManager.provides().setActiveDocument(t3.documentId);
1100
1118
  }
@@ -1130,7 +1148,7 @@ const xt$1 = class e2 extends BasePlugin {
1130
1148
  this.prepareChapterForSegmentLoad(e14);
1131
1149
  const n9 = this.findChapter(e14);
1132
1150
  if (!n9) return Promise.resolve("error");
1133
- const r2 = Pt$1(n9);
1151
+ const r2 = It$1(n9);
1134
1152
  if (!r2) return 0 !== t2 ? Promise.resolve(this.isSegmentDocumentOpen(e14, 0) ? "loaded" : "error") : this.ensureSingleDocumentChapter(n9);
1135
1153
  if (t2 < 0 || t2 >= r2.segments.length) return Promise.resolve("error");
1136
1154
  const a2 = r2.segments[t2], i2 = a2.documentId;
@@ -1271,7 +1289,7 @@ const xt$1 = class e2 extends BasePlugin {
1271
1289
  });
1272
1290
  }
1273
1291
  closeChapter(e14) {
1274
- const t2 = this.findChapter(e14), s2 = this.documentManager.provides(), n9 = t2 ? Pt$1(t2) : null, r2 = (e15) => {
1292
+ const t2 = this.findChapter(e14), s2 = this.documentManager.provides(), n9 = t2 ? It$1(t2) : null, r2 = (e15) => {
1275
1293
  if (s2.isDocumentOpen(e15)) {
1276
1294
  s2.closeDocument(e15).wait(() => {
1277
1295
  }, () => {
@@ -1822,12 +1840,21 @@ const jt$1 = class e3 extends BasePlugin {
1822
1840
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
1823
1841
  }
1824
1842
  scheduleVisibleSegmentLoads(e14) {
1825
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
1826
- for (const r2 of t2) {
1827
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
1828
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
1843
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
1844
+ for (const o2 of t2) {
1845
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
1846
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
1829
1847
  }
1830
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
1848
+ const a2 = [];
1849
+ let i2 = true;
1850
+ for (; i2; ) {
1851
+ i2 = false;
1852
+ for (const e15 of r2) {
1853
+ const t3 = n9.get(e15);
1854
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
1855
+ }
1856
+ }
1857
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
1831
1858
  }
1832
1859
  pumpVisibleSegmentBacklog() {
1833
1860
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -2435,12 +2462,21 @@ const ms = class e4 extends BasePlugin {
2435
2462
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
2436
2463
  }
2437
2464
  scheduleVisibleSegmentLoads(e14) {
2438
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
2439
- for (const r2 of t2) {
2440
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
2441
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
2465
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
2466
+ for (const o2 of t2) {
2467
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
2468
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
2469
+ }
2470
+ const a2 = [];
2471
+ let i2 = true;
2472
+ for (; i2; ) {
2473
+ i2 = false;
2474
+ for (const e15 of r2) {
2475
+ const t3 = n9.get(e15);
2476
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
2477
+ }
2442
2478
  }
2443
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
2479
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
2444
2480
  }
2445
2481
  pumpVisibleSegmentBacklog() {
2446
2482
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -2715,7 +2751,7 @@ function vs$1(e14, t2) {
2715
2751
  }
2716
2752
  return true;
2717
2753
  }
2718
- const Ps$1 = class Ps extends BasePlugin {
2754
+ const Is$1 = class Is extends BasePlugin {
2719
2755
  constructor(e14, t2) {
2720
2756
  super(e14, t2), this.layoutChange$ = createBehaviorEmitter(void 0, vs$1), this.visibleChange$ = createBehaviorEmitter(), this.virtualPageMap = null, this.pageSizes = /* @__PURE__ */ new Map(), this.offsets = [], this.totalHeight = 0, this.totalWidth = 0, this.viewportEl = null, this.viewportObservers = null, this.currentVisible = [], this.currentGlobalPageIndex = 0, this.lastLoadIndicesKey = "", this.chapterManagerUnsubs = [], this.chapterManager = this.registry.getPlugin(fs$1.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
2721
2757
  }
@@ -2931,11 +2967,11 @@ const Ps$1 = class Ps extends BasePlugin {
2931
2967
  s2 && this.scrollToIndex(s2.globalPageIndex, t2);
2932
2968
  }
2933
2969
  };
2934
- Ps$1.id = "chapter-scroll";
2935
- let Is$1 = Ps$1;
2970
+ Is$1.id = "chapter-scroll";
2971
+ let Ps$1 = Is$1;
2936
2972
  const bs = class e5 extends BasePlugin {
2937
2973
  constructor(e14, t2) {
2938
- super(e14, t2), this.notesChange$ = createBehaviorEmitter([]), this.noteActivated$ = createEmitter(), this.notes = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(Is$1.id), this.chapterManager = this.registry.getPlugin(Xt$1.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
2974
+ super(e14, t2), this.notesChange$ = createBehaviorEmitter([]), this.noteActivated$ = createEmitter(), this.notes = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(Ps$1.id), this.chapterManager = this.registry.getPlugin(Xt$1.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
2939
2975
  }
2940
2976
  async initialize(t2) {
2941
2977
  if (this.config = t2, t2.callbacks.loadNotes) try {
@@ -3352,12 +3388,21 @@ const zs$1 = class e6 extends BasePlugin {
3352
3388
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
3353
3389
  }
3354
3390
  scheduleVisibleSegmentLoads(e14) {
3355
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
3356
- for (const r2 of t2) {
3357
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
3358
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
3391
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
3392
+ for (const o2 of t2) {
3393
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
3394
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
3359
3395
  }
3360
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
3396
+ const a2 = [];
3397
+ let i2 = true;
3398
+ for (; i2; ) {
3399
+ i2 = false;
3400
+ for (const e15 of r2) {
3401
+ const t3 = n9.get(e15);
3402
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
3403
+ }
3404
+ }
3405
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
3361
3406
  }
3362
3407
  pumpVisibleSegmentBacklog() {
3363
3408
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -3965,12 +4010,21 @@ const ln = class e7 extends BasePlugin {
3965
4010
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
3966
4011
  }
3967
4012
  scheduleVisibleSegmentLoads(e14) {
3968
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
3969
- for (const r2 of t2) {
3970
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
3971
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
4013
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
4014
+ for (const o2 of t2) {
4015
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
4016
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
4017
+ }
4018
+ const a2 = [];
4019
+ let i2 = true;
4020
+ for (; i2; ) {
4021
+ i2 = false;
4022
+ for (const e15 of r2) {
4023
+ const t3 = n9.get(e15);
4024
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
4025
+ }
3972
4026
  }
3973
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
4027
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
3974
4028
  }
3975
4029
  pumpVisibleSegmentBacklog() {
3976
4030
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -4495,7 +4549,7 @@ function vn(e14, t2, s2, n9) {
4495
4549
  if (0 === r2.length) throw new Error("buildParagraphBookmarkAnchor: no rects");
4496
4550
  return { chapterId: e14, localPageIndex: t2, globalPageIndex: null == n9 ? void 0 : n9.globalPageIndex, globalPageNumber: null == n9 ? void 0 : n9.globalPageNumber, rectPdfCoord: pn(r2), rectsPdfCoord: r2, markerAnchor: gn(r2) };
4497
4551
  }
4498
- async function Pn(e14, t2, s2) {
4552
+ async function In(e14, t2, s2) {
4499
4553
  e14.scrollToGlobalPageIndex(t2), await (function(e15, t3, s3 = 2500) {
4500
4554
  const n9 = e15.getLayout().items.find((e16) => e16.globalPageIndex === t3 && !e16.isPlaceholder);
4501
4555
  return n9 ? Promise.resolve(n9) : new Promise((n10) => {
@@ -4508,7 +4562,7 @@ async function Pn(e14, t2, s2) {
4508
4562
  });
4509
4563
  })(e14, t2), e14.scrollToGlobalPdfPoint(t2, s2, { marginTop: 80 });
4510
4564
  }
4511
- const In = class e8 extends BasePlugin {
4565
+ const Pn = class e8 extends BasePlugin {
4512
4566
  constructor(e14, t2) {
4513
4567
  super(e14, t2), this.change$ = createBehaviorEmitter([]), this.entries = /* @__PURE__ */ new Map(), this.chapterScroll = this.registry.getPlugin(un.id), this.chapterManager = this.registry.getPlugin(Gs$1.id), this.documentManager = this.registry.getPlugin(DocumentManagerPlugin.id);
4514
4568
  }
@@ -4582,11 +4636,11 @@ const In = class e8 extends BasePlugin {
4582
4636
  const t3 = e15.rectPdfCoord;
4583
4637
  return t3.origin.y + t3.size.height;
4584
4638
  })(t2.anchor);
4585
- await Pn(s2, r2, a2);
4639
+ await In(s2, r2, a2);
4586
4640
  }
4587
4641
  };
4588
- In.id = "paragraph-bookmark";
4589
- let bn = In;
4642
+ Pn.id = "paragraph-bookmark";
4643
+ let bn = Pn;
4590
4644
  const Sn = { manifest: Ms, create: (e14) => new bn(ws, e14), reducer: (e14) => e14, initialState: {} }, Cn = { "annotation-toolbar": { id: "annotation-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-text", "add-ink", "add-ink-highlighter", "add-insert-text", "add-replace-text", "add-comment", "add-callout"], show: ["overflow-annotation-tools"] }, md: { minWidth: 640, hide: ["overflow-annotation-tools"], show: ["add-text", "add-ink", "add-ink-highlighter", "add-insert-text", "add-replace-text", "add-comment", "add-callout"] } } }, permanent: false, categories: ["annotation"], items: [{ type: "spacer", id: "spacer-3", flex: true }, { type: "group", id: "annotation-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-highlight", commandId: "annotation:add-highlight", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-highlight"] }, { type: "command-button", id: "add-strikeout", commandId: "annotation:add-strikeout", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-strikeout"] }, { type: "command-button", id: "add-underline", commandId: "annotation:add-underline", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-underline"] }, { type: "command-button", id: "add-squiggly", commandId: "annotation:add-squiggly", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-squiggly"] }, { type: "command-button", id: "add-ink", commandId: "annotation:add-ink", variant: "icon", categories: ["annotation", "annotation-ink"] }, { type: "command-button", id: "add-ink-highlighter", commandId: "annotation:add-ink-highlighter", variant: "icon", categories: ["annotation", "annotation-ink"] }, { type: "command-button", id: "add-text", commandId: "annotation:add-text", variant: "icon", categories: ["annotation", "annotation-text"] }, { type: "command-button", id: "add-insert-text", commandId: "annotation:add-insert-text", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-insert-text"] }, { type: "command-button", id: "add-replace-text", commandId: "annotation:add-replace-text", variant: "icon", categories: ["annotation", "annotation-markup", "annotation-replace-text"] }, { type: "command-button", id: "add-comment", commandId: "annotation:add-comment", variant: "icon", categories: ["annotation", "annotation-comment-tool"] }, { type: "command-button", id: "add-callout", commandId: "annotation:add-callout", variant: "icon", categories: ["annotation", "annotation-text"] }, { type: "command-button", id: "overflow-annotation-tools", commandId: "annotation:overflow-tools", variant: "icon", categories: ["annotation", "annotation-overflow"] }, { type: "divider", id: "annotation-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "annotation-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-4", flex: true }] }, "shapes-toolbar": { id: "shapes-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-polygon", "add-polyline"], show: ["overflow-shapes-tools"] }, md: { minWidth: 640, hide: ["overflow-shapes-tools"], show: ["add-polygon", "add-polyline"] } } }, permanent: false, categories: ["annotation", "annotation-shape"], items: [{ type: "spacer", id: "spacer-5", flex: true }, { type: "group", id: "shapes-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-rectangle", commandId: "annotation:add-rectangle", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-rectangle"] }, { type: "command-button", id: "add-circle", commandId: "annotation:add-circle", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-circle"] }, { type: "command-button", id: "add-line", commandId: "annotation:add-line", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-line"] }, { type: "command-button", id: "add-arrow", commandId: "annotation:add-arrow", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-arrow"] }, { type: "command-button", id: "add-polygon", commandId: "annotation:add-polygon", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-polygon"] }, { type: "command-button", id: "add-polyline", commandId: "annotation:add-polyline", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-polyline"] }, { type: "command-button", id: "overflow-shapes-tools", commandId: "annotation:overflow-shapes", variant: "icon", categories: ["annotation", "annotation-shape", "annotation-overflow"] }, { type: "divider", id: "shapes-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "shapes-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-6", flex: true }] }, "form-toolbar": { id: "form-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, responsive: { breakpoints: { sm: { maxWidth: 640, hide: ["add-form-select", "add-form-listbox"], show: ["overflow-forms-tools"] }, md: { minWidth: 640, hide: ["overflow-forms-tools"], show: ["add-form-select", "add-form-listbox"] } } }, permanent: false, categories: ["form"], items: [{ type: "spacer", id: "spacer-form-1", flex: true }, { type: "group", id: "form-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-form-textfield", commandId: "form:add-textfield", variant: "icon", categories: ["form", "form-textfield"] }, { type: "command-button", id: "add-form-checkbox", commandId: "form:add-checkbox", variant: "icon", categories: ["form", "form-checkbox"] }, { type: "command-button", id: "add-form-radio", commandId: "form:add-radio", variant: "icon", categories: ["form", "form-radio"] }, { type: "command-button", id: "add-form-select", commandId: "form:add-select", variant: "icon", categories: ["form", "form-select"] }, { type: "command-button", id: "add-form-listbox", commandId: "form:add-listbox", variant: "icon", categories: ["form", "form-listbox"] }, { type: "command-button", id: "overflow-forms-tools", commandId: "form:overflow-tools", variant: "icon", categories: ["form", "form-overflow"] }, { type: "divider", id: "form-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "command-button", id: "toggle-form-fill-mode", commandId: "form:toggle-fill-mode", variant: "icon", categories: ["form", "form-fill-mode"] }, { type: "divider", id: "form-tools-divider-2", orientation: "vertical" }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-form-2", flex: true }] }, "insert-toolbar": { id: "insert-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, permanent: false, categories: ["insert"], items: [{ type: "spacer", id: "spacer-insert-1", flex: true }, { type: "group", id: "insert-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "add-rubber-stamp", commandId: "insert:add-rubber-stamp", variant: "icon", categories: ["insert", "insert-rubber-stamp"] }, { type: "command-button", id: "add-signature", commandId: "insert:add-signature", variant: "icon", categories: ["insert", "insert-signature"] }, { type: "command-button", id: "add-image", commandId: "insert:add-image", variant: "icon", categories: ["insert", "insert-image"] }, { type: "divider", id: "insert-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "insert-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-insert-2", flex: true }] }, "redaction-toolbar": { id: "redaction-toolbar", position: { placement: "top", slot: "secondary", order: 0 }, permanent: false, categories: ["redaction"], items: [{ type: "spacer", id: "spacer-7", flex: true }, { type: "group", id: "redaction-tools", alignment: "start", gap: 2, items: [{ type: "command-button", id: "redact", commandId: "redaction:redact", variant: "icon", categories: ["redaction", "redaction-combined"] }, { type: "divider", id: "redaction-tools-divider-1", orientation: "vertical" }, { type: "command-button", id: "toggle-redaction-panel", commandId: "panel:toggle-redaction", variant: "icon", categories: ["panel", "panel-redaction"] }, { type: "command-button", id: "toggle-annotation-style", commandId: "panel:toggle-annotation-style", variant: "icon", categories: ["panel", "panel-annotation-style"] }, { type: "divider", id: "redaction-tools-divider-2", orientation: "vertical", visibilityDependsOn: { itemIds: ["toggle-annotation-style"] } }, { type: "command-button", id: "undo-button", commandId: "history:undo", variant: "icon", categories: ["history", "history-undo"] }, { type: "command-button", id: "redo-button", commandId: "history:redo", variant: "icon", categories: ["history", "history-redo"] }] }, { type: "spacer", id: "spacer-8", flex: true }] } };
4591
4645
  class yn {
4592
4646
  constructor() {
@@ -4741,15 +4795,15 @@ function Bn(e14) {
4741
4795
  return e14 instanceof HTMLElement ? e14.clientWidth : 0;
4742
4796
  }
4743
4797
  function _n(a2, i2, o2) {
4744
- const l = isRef(a2) ? a2 : computed(() => a2), { registry: h2 } = useRegistry(), { provides: d2 } = useCapability(DocumentManagerPlugin.id), { provides: c2 } = useCapability(nt$1.id), u2 = ref(P2()), p2 = ref(u2.value), g2 = ref(0), m2 = ref(false), f2 = () => {
4798
+ const l = isRef(a2) ? a2 : computed(() => a2), { registry: h2 } = useRegistry(), { provides: d2 } = useCapability(DocumentManagerPlugin.id), { provides: c2 } = useCapability(nt$1.id), u2 = ref(I2()), p2 = ref(u2.value), g2 = ref(0), m2 = ref(false), f2 = () => {
4745
4799
  var _a2;
4746
4800
  return (_a2 = i2.value) == null ? void 0 : _a2.pageWidth;
4747
4801
  }, v = () => (function(e14) {
4748
4802
  return null != e14 && e14 > 0;
4749
- })(f2()), P2 = () => {
4803
+ })(f2()), I2 = () => {
4750
4804
  var _a2;
4751
4805
  return ((_a2 = i2.value) == null ? void 0 : _a2.initial) ?? 1;
4752
- }, I2 = computed(() => {
4806
+ }, P2 = computed(() => {
4753
4807
  var _a2;
4754
4808
  return (function(e14, t2, s2, n9, r2) {
4755
4809
  if (!e14 || s2 <= 0) return r2;
@@ -4761,11 +4815,11 @@ function _n(a2, i2, o2) {
4761
4815
  })(d2.value, l.value, g2.value, f2(), ((_a2 = i2.value) == null ? void 0 : _a2.max) ?? 3);
4762
4816
  }), b2 = computed(() => {
4763
4817
  var _a2;
4764
- return Math.min(((_a2 = i2.value) == null ? void 0 : _a2.min) ?? 0.5, I2.value);
4818
+ return Math.min(((_a2 = i2.value) == null ? void 0 : _a2.min) ?? 0.5, P2.value);
4765
4819
  });
4766
4820
  let S;
4767
4821
  function C2(e14) {
4768
- const t2 = I2.value, s2 = b2.value, n9 = An(e14, s2, t2);
4822
+ const t2 = P2.value, s2 = b2.value, n9 = An(e14, s2, t2);
4769
4823
  p2.value = n9, u2.value = n9, (function(e15, t3, s3, n10 = 0.5, r2 = 3) {
4770
4824
  const a3 = e15 == null ? void 0 : e15.getStore();
4771
4825
  if (!a3) return;
@@ -4786,7 +4840,7 @@ function _n(a2, i2, o2) {
4786
4840
  n9 <= 0 || C2(On(s2, n9));
4787
4841
  }
4788
4842
  function x(e14) {
4789
- if (!m2.value) return v() ? y(e14) : C2(P2()), void (m2.value = true);
4843
+ if (!m2.value) return v() ? y(e14) : C2(I2()), void (m2.value = true);
4790
4844
  C2(p2.value);
4791
4845
  }
4792
4846
  return watch(() => o2 == null ? void 0 : o2.value, (e14) => {
@@ -4810,11 +4864,11 @@ function _n(a2, i2, o2) {
4810
4864
  })(e14, (e15) => {
4811
4865
  g2.value = e15;
4812
4866
  }) : void 0;
4813
- }, { immediate: true }), onBeforeUnmount(() => S == null ? void 0 : S()), watch([h2, () => P2(), () => v()], () => {
4814
- h2.value && (v() || C2(P2()));
4815
- }, { immediate: true }), watch(I2, (e14) => {
4867
+ }, { immediate: true }), onBeforeUnmount(() => S == null ? void 0 : S()), watch([h2, () => I2(), () => v()], () => {
4868
+ h2.value && (v() || C2(I2()));
4869
+ }, { immediate: true }), watch(P2, (e14) => {
4816
4870
  p2.value > e14 && C2(e14);
4817
- }), watch([c2, l, () => v(), () => P2()], () => {
4871
+ }), watch([c2, l, () => v(), () => I2()], () => {
4818
4872
  const e14 = c2.value;
4819
4873
  if (e14) {
4820
4874
  for (const t2 of l.value.chapters) "loaded" === e14.getChapterStatus(t2.chapterId) && x(t2.chapterId);
@@ -4837,7 +4891,7 @@ function _n(a2, i2, o2) {
4837
4891
  }), { scale: u2, setScale: C2, zoomEnabled: () => {
4838
4892
  var _a2;
4839
4893
  return false !== ((_a2 = i2.value) == null ? void 0 : _a2.enabled);
4840
- }, minZoom: b2, maxZoom: I2 };
4894
+ }, minZoom: b2, maxZoom: P2 };
4841
4895
  }
4842
4896
  function Wn(e14, t2, s2) {
4843
4897
  return Math.min(s2, Math.max(t2, e14));
@@ -5239,12 +5293,21 @@ const pr = class e9 extends BasePlugin {
5239
5293
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
5240
5294
  }
5241
5295
  scheduleVisibleSegmentLoads(e14) {
5242
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
5243
- for (const r2 of t2) {
5244
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
5245
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
5296
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
5297
+ for (const o2 of t2) {
5298
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
5299
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
5300
+ }
5301
+ const a2 = [];
5302
+ let i2 = true;
5303
+ for (; i2; ) {
5304
+ i2 = false;
5305
+ for (const e15 of r2) {
5306
+ const t3 = n9.get(e15);
5307
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
5308
+ }
5246
5309
  }
5247
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
5310
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
5248
5311
  }
5249
5312
  pumpVisibleSegmentBacklog() {
5250
5313
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -5737,7 +5800,7 @@ const fr = class extends BasePlugin {
5737
5800
  };
5738
5801
  fr.id = "chapter-scroll";
5739
5802
  let vr = fr;
5740
- const Pr = ["data-global-page-index", "data-chapter-id", "data-local-page-index"], Ir = /* @__PURE__ */ ((e14, t2) => {
5803
+ const Ir = ["data-global-page-index", "data-chapter-id", "data-local-page-index"], Pr = /* @__PURE__ */ ((e14, t2) => {
5741
5804
  const s2 = e14.__vccOpts || e14;
5742
5805
  for (const [n9, r2] of t2) s2[n9] = r2;
5743
5806
  return s2;
@@ -5754,7 +5817,7 @@ const Pr = ["data-global-page-index", "data-chapter-id", "data-local-page-index"
5754
5817
  null == f2 || f2(), null == (e15 = t2.value) || e15.registerViewport(null);
5755
5818
  }), watch(t2, v), (e15, t3) => {
5756
5819
  var s2, n9, r2;
5757
- return openBlock(), createElementBlock("div", { ref_key: "containerRef", ref: a2, "data-chapter-scroll-viewport": "", class: normalizeClass(e15.$props.class), style: normalizeStyle({ overflow: "auto", overflowX: "hidden", position: "relative", width: "100%", height: "100%", ...e15.$props.style }) }, [createElementVNode("div", { style: normalizeStyle({ position: "relative", width: `${(null == (s2 = m2.value) ? void 0 : s2.totalWidth) ?? 0}px`, height: `${(null == (n9 = m2.value) ? void 0 : n9.totalHeight) ?? 0}px`, margin: "0 auto" }) }, [(openBlock(true), createElementBlock(Fragment, null, renderList((null == (r2 = m2.value) ? void 0 : r2.items) ?? [], (s3) => (openBlock(), createElementBlock("div", { key: s3.globalPageIndex, "data-global-page-index": s3.globalPageIndex, "data-chapter-id": s3.chapterId, "data-local-page-index": s3.localPageIndex, style: normalizeStyle({ position: "absolute", top: `${s3.offsetTop}px`, left: "50%", transform: "translateX(-50%)", width: `${s3.width}px`, height: `${s3.height}px`, backgroundColor: s3.isPlaceholder ? "#f3f4f6" : "#fff", boxShadow: "0 1px 4px rgba(0,0,0,0.08)" }) }, [s3.isPlaceholder ? renderSlot(e15.$slots, "placeholder", { key: 0, item: s3 }, () => [t3[0] || (t3[0] = createElementVNode("div", { class: "chapter-scroll-placeholder" }, "Loading chapter…", -1))], true) : renderSlot(e15.$slots, "page", { key: 1, item: s3 }, void 0, true)], 12, Pr))), 128))], 4)], 6);
5820
+ return openBlock(), createElementBlock("div", { ref_key: "containerRef", ref: a2, "data-chapter-scroll-viewport": "", class: normalizeClass(e15.$props.class), style: normalizeStyle({ overflow: "auto", overflowX: "hidden", position: "relative", width: "100%", height: "100%", ...e15.$props.style }) }, [createElementVNode("div", { style: normalizeStyle({ position: "relative", width: `${(null == (s2 = m2.value) ? void 0 : s2.totalWidth) ?? 0}px`, height: `${(null == (n9 = m2.value) ? void 0 : n9.totalHeight) ?? 0}px`, margin: "0 auto" }) }, [(openBlock(true), createElementBlock(Fragment, null, renderList((null == (r2 = m2.value) ? void 0 : r2.items) ?? [], (s3) => (openBlock(), createElementBlock("div", { key: s3.globalPageIndex, "data-global-page-index": s3.globalPageIndex, "data-chapter-id": s3.chapterId, "data-local-page-index": s3.localPageIndex, style: normalizeStyle({ position: "absolute", top: `${s3.offsetTop}px`, left: "50%", transform: "translateX(-50%)", width: `${s3.width}px`, height: `${s3.height}px`, backgroundColor: s3.isPlaceholder ? "#f3f4f6" : "#fff", boxShadow: "0 1px 4px rgba(0,0,0,0.08)" }) }, [s3.isPlaceholder ? renderSlot(e15.$slots, "placeholder", { key: 0, item: s3 }, () => [t3[0] || (t3[0] = createElementVNode("div", { class: "chapter-scroll-placeholder" }, "Loading chapter…", -1))], true) : renderSlot(e15.$slots, "page", { key: 1, item: s3 }, void 0, true)], 12, Ir))), 128))], 4)], 6);
5758
5821
  };
5759
5822
  } }), [["__scopeId", "data-v-e9ab4da3"]]), br = /* @__PURE__ */ defineComponent({ __name: "ChapterRenderLayer", props: { chapterId: {}, localPageIndex: {}, pdfDocumentId: {}, pdfPageIndex: {}, scale: {}, dpr: {}, class: {} }, setup(e14) {
5760
5823
  const t2 = e14;
@@ -6064,12 +6127,21 @@ const Tr = class e10 extends BasePlugin {
6064
6127
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
6065
6128
  }
6066
6129
  scheduleVisibleSegmentLoads(e14) {
6067
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
6068
- for (const r2 of t2) {
6069
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
6070
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
6130
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
6131
+ for (const o2 of t2) {
6132
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
6133
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
6134
+ }
6135
+ const a2 = [];
6136
+ let i2 = true;
6137
+ for (; i2; ) {
6138
+ i2 = false;
6139
+ for (const e15 of r2) {
6140
+ const t3 = n9.get(e15);
6141
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
6142
+ }
6071
6143
  }
6072
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
6144
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
6073
6145
  }
6074
6146
  pumpVisibleSegmentBacklog() {
6075
6147
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -6677,12 +6749,21 @@ const sa = class e11 extends BasePlugin {
6677
6749
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
6678
6750
  }
6679
6751
  scheduleVisibleSegmentLoads(e14) {
6680
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
6681
- for (const r2 of t2) {
6682
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
6683
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
6752
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
6753
+ for (const o2 of t2) {
6754
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
6755
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
6756
+ }
6757
+ const a2 = [];
6758
+ let i2 = true;
6759
+ for (; i2; ) {
6760
+ i2 = false;
6761
+ for (const e15 of r2) {
6762
+ const t3 = n9.get(e15);
6763
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
6764
+ }
6684
6765
  }
6685
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
6766
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
6686
6767
  }
6687
6768
  pumpVisibleSegmentBacklog() {
6688
6769
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -7303,15 +7384,15 @@ const ca = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "
7303
7384
  d2.value = e16.filter((e17) => e17.chapterId === a2.chapterId && e17.localPageIndex === a2.localPageIndex);
7304
7385
  });
7305
7386
  }, { immediate: true });
7306
- let I2 = null;
7387
+ let P2 = null;
7307
7388
  watch(m2, (e15) => {
7308
- I2 && (document.removeEventListener("mousedown", I2), I2 = null), e15 && (I2 = (t2) => {
7389
+ P2 && (document.removeEventListener("mousedown", P2), P2 = null), e15 && (P2 = (t2) => {
7309
7390
  var _a2;
7310
7391
  const s2 = t2.target;
7311
7392
  ((_a2 = s2.closest) == null ? void 0 : _a2.call(s2, `[data-note-marker-zone="${e15}"]`)) || (m2.value = null, g2.value = null);
7312
- }, document.addEventListener("mousedown", I2));
7393
+ }, document.addEventListener("mousedown", P2));
7313
7394
  }), onBeforeUnmount(() => {
7314
- I2 && document.removeEventListener("mousedown", I2);
7395
+ P2 && document.removeEventListener("mousedown", P2);
7315
7396
  });
7316
7397
  const b2 = computed(() => {
7317
7398
  var _a2;
@@ -7338,14 +7419,14 @@ const ca = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "
7338
7419
  return s3 = e15.noteId, (_a2 = i2.value) == null ? void 0 : _a2.requestDeleteNote(s3), void (m2.value = null);
7339
7420
  var s3;
7340
7421
  } }, " 删除 ", 8, fa)], 36)) : createCommentVNode("", true)], 44, pa)) : createCommentVNode("", true)], 64))), 128))])) : createCommentVNode("", true);
7341
- } }), Pa = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "none" } }, Ia = ["title", "onClick"], ba = ["onClick"], Sa = /* @__PURE__ */ defineComponent({ __name: "BookmarkMarkerLayer", props: { chapterId: {}, localPageIndex: {}, pdfPageWidth: {}, pdfPageHeight: {}, cssPageWidth: {}, cssPageHeight: {}, ui: {} }, setup(e14) {
7422
+ } }), Ia = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "none" } }, Pa = ["title", "onClick"], ba = ["onClick"], Sa = /* @__PURE__ */ defineComponent({ __name: "BookmarkMarkerLayer", props: { chapterId: {}, localPageIndex: {}, pdfPageWidth: {}, pdfPageHeight: {}, cssPageWidth: {}, cssPageHeight: {}, ui: {} }, setup(e14) {
7342
7423
  const a2 = e14, { provides: i2 } = useCapability(bn.id), d2 = ref([]), g2 = ref(null), m2 = ref(null);
7343
- function I2() {
7424
+ function P2() {
7344
7425
  const e15 = i2.value;
7345
7426
  e15 && (d2.value = e15.listBookmarks().filter((e16) => e16.anchor.chapterId === a2.chapterId && e16.anchor.localPageIndex === a2.localPageIndex));
7346
7427
  }
7347
7428
  watch(i2, (e15) => {
7348
- if (e15) return I2(), e15.onBookmarksChange(I2);
7429
+ if (e15) return P2(), e15.onBookmarksChange(P2);
7349
7430
  }, { immediate: true });
7350
7431
  let b2 = null;
7351
7432
  watch(g2, (e15) => {
@@ -7368,8 +7449,8 @@ const ca = { key: 0, style: { position: "absolute", inset: "0", pointerEvents: "
7368
7449
  })(e15);
7369
7450
  return { position: "absolute", left: `${Math.max(0, t2 - 6)}px`, top: `${Math.max(0, s2 - 6)}px`, width: `${S.value + 12}px`, height: `${S.value + 12}px`, pointerEvents: "auto", zIndex: 20 };
7370
7451
  }
7371
- return (t2, s2) => unref(i2) && d2.value.length && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", Pa, [(openBlock(true), createElementBlock(Fragment, null, renderList(d2.value, (e15) => (openBlock(), createElementBlock("div", { key: e15.id, style: normalizeStyle(C2(e15)), onMousedown: s2[1] || (s2[1] = withModifiers(() => {
7372
- }, ["stop"])) }, [createElementVNode("button", { type: "button", title: e15.label, style: normalizeStyle({ position: "absolute", left: "6px", top: "6px", width: `${S.value}px`, height: `${S.value}px`, border: "none", borderRadius: "4px", background: "#3b82f6", color: "#fff", cursor: "pointer", boxShadow: "0 2px 6px rgba(37, 99, 235, 0.35)", fontSize: "11px", padding: 0 }), onClick: withModifiers((t3) => g2.value = g2.value === e15.id ? null : e15.id, ["stop"]) }, " 🔖 ", 12, Ia), g2.value === e15.id ? (openBlock(), createElementBlock("div", { key: 0, ref_for: true, ref_key: "deleteMenuRef", ref: m2, style: { position: "absolute", left: "6px", top: "-36px", zIndex: 30, pointerEvents: "auto", minWidth: "88px", padding: "4px", borderRadius: "6px", background: "#fff", border: "1px solid #e5e7eb", boxShadow: "0 4px 12px rgba(0,0,0,0.12)" }, onClick: s2[0] || (s2[0] = withModifiers(() => {
7452
+ return (t2, s2) => unref(i2) && d2.value.length && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", Ia, [(openBlock(true), createElementBlock(Fragment, null, renderList(d2.value, (e15) => (openBlock(), createElementBlock("div", { key: e15.id, style: normalizeStyle(C2(e15)), onMousedown: s2[1] || (s2[1] = withModifiers(() => {
7453
+ }, ["stop"])) }, [createElementVNode("button", { type: "button", title: e15.label, style: normalizeStyle({ position: "absolute", left: "6px", top: "6px", width: `${S.value}px`, height: `${S.value}px`, border: "none", borderRadius: "4px", background: "#3b82f6", color: "#fff", cursor: "pointer", boxShadow: "0 2px 6px rgba(37, 99, 235, 0.35)", fontSize: "11px", padding: 0 }), onClick: withModifiers((t3) => g2.value = g2.value === e15.id ? null : e15.id, ["stop"]) }, " 🔖 ", 12, Pa), g2.value === e15.id ? (openBlock(), createElementBlock("div", { key: 0, ref_for: true, ref_key: "deleteMenuRef", ref: m2, style: { position: "absolute", left: "6px", top: "-36px", zIndex: 30, pointerEvents: "auto", minWidth: "88px", padding: "4px", borderRadius: "6px", background: "#fff", border: "1px solid #e5e7eb", boxShadow: "0 4px 12px rgba(0,0,0,0.12)" }, onClick: s2[0] || (s2[0] = withModifiers(() => {
7373
7454
  }, ["stop"])) }, [createElementVNode("button", { type: "button", style: { width: "100%", padding: "6px 8px", "font-size": "12px", border: "none", "border-radius": "4px", background: "transparent", color: "#dc2626", cursor: "pointer", "text-align": "left" }, onClick: (t3) => (async function(e16) {
7374
7455
  const t4 = i2.value;
7375
7456
  if (!t4) return;
@@ -7477,13 +7558,13 @@ const ka = /* @__PURE__ */ defineComponent({ __name: "ChapterPageSurface", props
7477
7558
  if (t2) return { background: t2 };
7478
7559
  })((_a2 = s2.features) == null ? void 0 : _a2.selectionToolbar);
7479
7560
  });
7480
- return (t2, s3) => e14.item.isPlaceholder ? createCommentVNode("", true) : (openBlock(), createBlock(unref(GlobalPointerProvider), { key: 0, "document-id": r2.value }, { default: withCtx(() => [createVNode(unref(Rotate), { "document-id": r2.value, "page-index": a2.value, style: { backgroundColor: "#fff" } }, { default: withCtx(() => [createVNode(unref(PagePointerProvider), { "document-id": r2.value, "page-index": a2.value, style: normalizeStyle(unref(Ie)), onPointerdown: unref(be$1) }, { default: withCtx(() => [createVNode(unref(br), { "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-document-id": r2.value, "pdf-page-index": a2.value }, null, 8, ["chapter-id", "local-page-index", "pdf-document-id", "pdf-page-index"]), createVNode(unref(SelectionLayer), { "document-id": r2.value, "page-index": a2.value, "text-style": w2.value, "selection-menu": u2.value }, null, 8, ["document-id", "page-index", "text-style", "selection-menu"]), e14.showRedactionLayer ? (openBlock(), createBlock(unref(RedactionLayer), { key: 0, "document-id": r2.value, "page-index": a2.value, "selection-menu": e14.redactionSelectionMenu }, null, 8, ["document-id", "page-index", "selection-menu"])) : createCommentVNode("", true), createVNode(unref(AnnotationLayer), { "document-id": r2.value, "page-index": a2.value, "selection-menu": v.value }, null, 8, ["document-id", "page-index", "selection-menu"]), e14.showBookmarkMarkers && d2.value ? (openBlock(), createBlock(Sa, { key: 1, "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-page-width": d2.value.size.width, "pdf-page-height": d2.value.size.height, "css-page-width": e14.item.width, "css-page-height": e14.item.height, ui: e14.bookmarkMarkerUi }, null, 8, ["chapter-id", "local-page-index", "pdf-page-width", "pdf-page-height", "css-page-width", "css-page-height", "ui"])) : createCommentVNode("", true), y.value ? (openBlock(), createBlock(resolveDynamicComponent(y.value), { key: 2 })) : createCommentVNode("", true), e14.showNoteMarkers && d2.value ? (openBlock(), createBlock(va, { key: 3, "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-page-width": d2.value.size.width, "pdf-page-height": d2.value.size.height, "css-page-width": e14.item.width, "css-page-height": e14.item.height, ui: e14.noteMarkerUi }, null, 8, ["chapter-id", "local-page-index", "pdf-page-width", "pdf-page-height", "css-page-width", "css-page-height", "ui"])) : createCommentVNode("", true), renderSlot(t2.$slots, "default")]), _: 3 }, 8, ["document-id", "page-index", "style", "onPointerdown"])]), _: 3 }, 8, ["document-id", "page-index"])]), _: 3 }, 8, ["document-id"]));
7561
+ return (t2, s3) => e14.item.isPlaceholder ? createCommentVNode("", true) : (openBlock(), createBlock(unref(GlobalPointerProvider), { key: 0, "document-id": r2.value }, { default: withCtx(() => [createVNode(unref(Rotate), { "document-id": r2.value, "page-index": a2.value, style: { backgroundColor: "#fff" } }, { default: withCtx(() => [createVNode(unref(PagePointerProvider), { "document-id": r2.value, "page-index": a2.value, style: normalizeStyle(unref(Pe$1)), onPointerdown: unref(be$1) }, { default: withCtx(() => [createVNode(unref(br), { "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-document-id": r2.value, "pdf-page-index": a2.value }, null, 8, ["chapter-id", "local-page-index", "pdf-document-id", "pdf-page-index"]), createVNode(unref(SelectionLayer), { "document-id": r2.value, "page-index": a2.value, "text-style": w2.value, "selection-menu": u2.value }, null, 8, ["document-id", "page-index", "text-style", "selection-menu"]), e14.showRedactionLayer ? (openBlock(), createBlock(unref(RedactionLayer), { key: 0, "document-id": r2.value, "page-index": a2.value, "selection-menu": e14.redactionSelectionMenu }, null, 8, ["document-id", "page-index", "selection-menu"])) : createCommentVNode("", true), createVNode(unref(AnnotationLayer), { "document-id": r2.value, "page-index": a2.value, "selection-menu": v.value }, null, 8, ["document-id", "page-index", "selection-menu"]), e14.showBookmarkMarkers && d2.value ? (openBlock(), createBlock(Sa, { key: 1, "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-page-width": d2.value.size.width, "pdf-page-height": d2.value.size.height, "css-page-width": e14.item.width, "css-page-height": e14.item.height, ui: e14.bookmarkMarkerUi }, null, 8, ["chapter-id", "local-page-index", "pdf-page-width", "pdf-page-height", "css-page-width", "css-page-height", "ui"])) : createCommentVNode("", true), y.value ? (openBlock(), createBlock(resolveDynamicComponent(y.value), { key: 2 })) : createCommentVNode("", true), e14.showNoteMarkers && d2.value ? (openBlock(), createBlock(va, { key: 3, "chapter-id": e14.item.chapterId, "local-page-index": e14.item.localPageIndex, "pdf-page-width": d2.value.size.width, "pdf-page-height": d2.value.size.height, "css-page-width": e14.item.width, "css-page-height": e14.item.height, ui: e14.noteMarkerUi }, null, 8, ["chapter-id", "local-page-index", "pdf-page-width", "pdf-page-height", "css-page-width", "css-page-height", "ui"])) : createCommentVNode("", true), renderSlot(t2.$slots, "default")]), _: 3 }, 8, ["document-id", "page-index", "style", "onPointerdown"])]), _: 3 }, 8, ["document-id", "page-index"])]), _: 3 }, 8, ["document-id"]));
7481
7562
  } });
7482
7563
  const Da = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props: { item: {}, pdfPageWidth: {}, pdfPageHeight: {}, cssPageWidth: {}, cssPageHeight: {}, hoverUi: {} }, setup(e14) {
7483
- const a2 = e14, i2 = computed(() => Ca(a2.item)), { provides: d2 } = useCapability(SelectionPlugin.id), { provides: u2 } = useCapability(bn.id), p2 = ref(null), g2 = ref(null), m2 = ref(null), I2 = ref(null), b2 = computed(() => {
7564
+ const a2 = e14, i2 = computed(() => Ca(a2.item)), { provides: d2 } = useCapability(SelectionPlugin.id), { provides: u2 } = useCapability(bn.id), p2 = ref(null), g2 = ref(null), m2 = ref(null), P2 = ref(null), b2 = computed(() => {
7484
7565
  var _a2;
7485
7566
  return ((_a2 = a2.hoverUi) == null ? void 0 : _a2.iconSize) ?? 16;
7486
- }), S = computed(() => I2.value ?? m2.value);
7567
+ }), S = computed(() => P2.value ?? m2.value);
7487
7568
  let C2 = null, y = 0;
7488
7569
  function w2() {
7489
7570
  const e15 = d2.value;
@@ -7510,9 +7591,9 @@ const Da = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props
7510
7591
  };
7511
7592
  }, { immediate: true });
7512
7593
  let x = null;
7513
- watch([g2, () => a2.pdfPageWidth, I2, d2], () => {
7594
+ watch([g2, () => a2.pdfPageWidth, P2, d2], () => {
7514
7595
  x && (document.removeEventListener("mousemove", x), x = null), g2.value && a2.pdfPageWidth && (x = (e15) => {
7515
- if (I2.value) return;
7596
+ if (P2.value) return;
7516
7597
  const t2 = d2.value;
7517
7598
  if (t2) try {
7518
7599
  if (t2.forDocument(i2.value).getState().selecting) return void (m2.value = null);
@@ -7544,7 +7625,7 @@ const Da = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props
7544
7625
  });
7545
7626
  function k2() {
7546
7627
  const e15 = u2.value, t2 = L2.value;
7547
- e15 && t2 && !$2.value && (e15.addBookmark({ label: `书签 ${/* @__PURE__ */ (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" })}`, anchor: t2 }), m2.value = null, I2.value = null);
7628
+ e15 && t2 && !$2.value && (e15.addBookmark({ label: `书签 ${/* @__PURE__ */ (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" })}`, anchor: t2 }), m2.value = null, P2.value = null);
7548
7629
  }
7549
7630
  const D2 = computed(() => {
7550
7631
  const e15 = S.value, t2 = e15 == null ? void 0 : e15[e15.length - 1];
@@ -7554,15 +7635,15 @@ const Da = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props
7554
7635
  });
7555
7636
  return (t2, s2) => {
7556
7637
  var _a2;
7557
- return unref(u2) && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", { key: 0, ref_key: "rootRef", ref: p2, style: { position: "absolute", inset: "0", zIndex: 14, pointerEvents: "none" } }, [D2.value && S.value && !$2.value ? (openBlock(), createElementBlock("div", { key: 0, style: normalizeStyle({ position: "absolute", left: `${D2.value.zoneLeft}px`, top: `${D2.value.zoneTop}px`, width: `${D2.value.size + 20}px`, height: `${(((_a2 = S.value[S.value.length - 1]) == null ? void 0 : _a2.size.height) ?? 0) * (e14.cssPageHeight / e14.pdfPageHeight) + D2.value.size + 12}px`, pointerEvents: "auto" }), onMouseenter: s2[0] || (s2[0] = (e15) => I2.value = S.value), onMouseleave: s2[1] || (s2[1] = (e15) => I2.value = null) }, [createElementVNode("button", { type: "button", title: "添加书签", style: normalizeStyle({ position: "absolute", left: D2.value.iconLeft - D2.value.zoneLeft + "px", top: D2.value.iconTop - D2.value.zoneTop + "px", width: `${D2.value.size}px`, height: `${D2.value.size}px`, cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", background: "#3b82f6", color: "#fff", border: "none", borderRadius: "4px", boxShadow: "0 2px 8px rgba(37, 99, 235, 0.45)", fontSize: "12px", padding: 0 }), onClick: withModifiers(k2, ["stop"]) }, " 🔖 ", 4)], 36)) : createCommentVNode("", true)], 512)) : createCommentVNode("", true);
7638
+ return unref(u2) && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", { key: 0, ref_key: "rootRef", ref: p2, style: { position: "absolute", inset: "0", zIndex: 14, pointerEvents: "none" } }, [D2.value && S.value && !$2.value ? (openBlock(), createElementBlock("div", { key: 0, style: normalizeStyle({ position: "absolute", left: `${D2.value.zoneLeft}px`, top: `${D2.value.zoneTop}px`, width: `${D2.value.size + 20}px`, height: `${(((_a2 = S.value[S.value.length - 1]) == null ? void 0 : _a2.size.height) ?? 0) * (e14.cssPageHeight / e14.pdfPageHeight) + D2.value.size + 12}px`, pointerEvents: "auto" }), onMouseenter: s2[0] || (s2[0] = (e15) => P2.value = S.value), onMouseleave: s2[1] || (s2[1] = (e15) => P2.value = null) }, [createElementVNode("button", { type: "button", title: "添加书签", style: normalizeStyle({ position: "absolute", left: D2.value.iconLeft - D2.value.zoneLeft + "px", top: D2.value.iconTop - D2.value.zoneTop + "px", width: `${D2.value.size}px`, height: `${D2.value.size}px`, cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", background: "#3b82f6", color: "#fff", border: "none", borderRadius: "4px", boxShadow: "0 2px 8px rgba(37, 99, 235, 0.45)", fontSize: "12px", padding: 0 }), onClick: withModifiers(k2, ["stop"]) }, " 🔖 ", 4)], 36)) : createCommentVNode("", true)], 512)) : createCommentVNode("", true);
7558
7639
  };
7559
7640
  } }), Ua = { key: 0, width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "" }, Ea = { key: 1, width: "24", height: "24", viewBox: "0 0 28 28", fill: "none", "aria-hidden": "" }, Va = { key: 0, x: "5", y: "4", width: "18", height: "20", rx: "3", fill: "#fde047" }, Na = { key: 1, d: "M6 22h16", stroke: "#dc2626", "stroke-width": "2.2", "stroke-linecap": "round" }, Ta = { key: 2, d: "M6 22c2-2 3-2 5 0s3 2 5 0 3-2 5 0", stroke: "#dc2626", "stroke-width": "2", "stroke-linecap": "round", fill: "none" }, Fa = { key: 3, d: "M5 14h18", stroke: "#dc2626", "stroke-width": "2.2", "stroke-linecap": "round" }, Aa = { key: 2, width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "" }, Oa = /* @__PURE__ */ defineComponent({ __name: "SelectionToolbarIcons", props: { kind: {} }, setup: (e14) => (t2, s2) => "copy" === e14.kind ? (openBlock(), createElementBlock("svg", Ua, [...s2[0] || (s2[0] = [createElementVNode("rect", { x: "8.5", y: "8.5", width: "11", height: "13", rx: "2.25", fill: "#f1f5f9", stroke: "#94a3b8", "stroke-width": "1.35" }, null, -1), createElementVNode("rect", { x: "4.5", y: "3.5", width: "11", height: "13", rx: "2.25", fill: "#ffffff", stroke: "#334155", "stroke-width": "1.5" }, null, -1), createElementVNode("path", { d: "M7.5 7h5.5a1.5 1.5 0 0 1 1.5 1.5V14", stroke: "#64748b", "stroke-width": "1.2", "stroke-linecap": "round" }, null, -1)])])) : "note" !== e14.kind ? (openBlock(), createElementBlock("svg", Ea, ["highlight" === e14.kind ? (openBlock(), createElementBlock("rect", Va)) : createCommentVNode("", true), s2[1] || (s2[1] = createElementVNode("text", { x: "14", y: "19", "text-anchor": "middle", "font-size": "15", "font-weight": "700", "font-family": "system-ui, -apple-system, sans-serif", fill: "#0f172a" }, " A ", -1)), "underline" === e14.kind ? (openBlock(), createElementBlock("path", Na)) : "squiggly" === e14.kind ? (openBlock(), createElementBlock("path", Ta)) : "strikeout" === e14.kind ? (openBlock(), createElementBlock("path", Fa)) : createCommentVNode("", true)])) : (openBlock(), createElementBlock("svg", Aa, [...s2[2] || (s2[2] = [createElementVNode("path", { d: "M8 3h8l4 4v14H8V3z", fill: "#fef3c7", stroke: "#d97706", "stroke-width": "1.2", "stroke-linejoin": "round" }, null, -1), createElementVNode("path", { d: "M16 3v4h4", stroke: "#d97706", "stroke-width": "1.2" }, null, -1), createElementVNode("path", { d: "M10 12h6M10 16h4", stroke: "#92400e", "stroke-width": "1.2", "stroke-linecap": "round" }, null, -1)])])) }), Ra = ["title", "aria-label", "onMouseenter", "onClick"], za = ["title", "onMouseenter", "onClick"], Ga = { style: { "font-size": "11px", "font-weight": "600" } }, Ba = /* @__PURE__ */ defineComponent({ __name: "SelectionToolbarCard", props: { placementAbove: { type: Boolean }, anchorHeight: {}, hiddenBuiltinActions: {}, extraActions: {}, renderCopyIcon: { type: Function } }, emits: ["action"], setup(e14, { emit: n9 }) {
7560
- const r2 = e14, a2 = n9, i2 = [{ id: "highlight", label: "高亮背景" }, { id: "underline", label: "下划线" }, { id: "squiggly", label: "波浪线" }, { id: "strikeout", label: "删除线" }], d2 = computed(() => new Set(r2.hiddenBuiltinActions ?? [])), g2 = computed(() => !d2.value.has("copy")), f2 = computed(() => i2.filter((e15) => !d2.value.has(e15.id))), v = computed(() => !d2.value.has("note")), I2 = computed(() => [...r2.extraActions ?? []].sort((e15, t2) => (e15.order ?? 0) - (t2.order ?? 0))), b2 = computed(() => f2.value.length > 0 || I2.value.length > 0), w2 = ref(null), M2 = computed(() => ({ position: "absolute", pointerEvents: "auto", left: "50%", transform: "translateX(-50%)", top: r2.placementAbove ? void 0 : `${r2.anchorHeight + 10}px`, bottom: r2.placementAbove ? `${r2.anchorHeight + 10}px` : void 0, display: "flex", alignItems: "center", gap: "2px", padding: "4px 6px", borderRadius: "12px", background: "rgba(255, 255, 255, 0.96)", border: "1px solid rgba(15, 23, 42, 0.06)", boxShadow: "0 2px 8px rgba(15, 23, 42, 0.08), 0 12px 32px rgba(15, 23, 42, 0.1)", backdropFilter: "blur(10px)", WebkitBackdropFilter: "blur(10px)" }));
7641
+ const r2 = e14, a2 = n9, i2 = [{ id: "highlight", label: "高亮背景" }, { id: "underline", label: "下划线" }, { id: "squiggly", label: "波浪线" }, { id: "strikeout", label: "删除线" }], d2 = computed(() => new Set(r2.hiddenBuiltinActions ?? [])), g2 = computed(() => !d2.value.has("copy")), f2 = computed(() => i2.filter((e15) => !d2.value.has(e15.id))), v = computed(() => !d2.value.has("note")), P2 = computed(() => [...r2.extraActions ?? []].sort((e15, t2) => (e15.order ?? 0) - (t2.order ?? 0))), b2 = computed(() => f2.value.length > 0 || P2.value.length > 0), w2 = ref(null), M2 = computed(() => ({ position: "absolute", pointerEvents: "auto", left: "50%", transform: "translateX(-50%)", top: r2.placementAbove ? void 0 : `${r2.anchorHeight + 10}px`, bottom: r2.placementAbove ? `${r2.anchorHeight + 10}px` : void 0, display: "flex", alignItems: "center", gap: "2px", padding: "4px 6px", borderRadius: "12px", background: "rgba(255, 255, 255, 0.96)", border: "1px solid rgba(15, 23, 42, 0.06)", boxShadow: "0 2px 8px rgba(15, 23, 42, 0.08), 0 12px 32px rgba(15, 23, 42, 0.1)", backdropFilter: "blur(10px)", WebkitBackdropFilter: "blur(10px)" }));
7561
7642
  function x(e15, t2 = false) {
7562
7643
  return { display: "flex", alignItems: "center", justifyContent: "center", width: "32px", height: "32px", padding: 0, margin: 0, border: "none", borderRadius: "8px", background: w2.value === e15 ? t2 ? "#fffbeb" : "#f1f5f9" : "transparent", color: t2 ? "#b45309" : "#334155", cursor: "pointer", flexShrink: 0, WebkitAppearance: "none", appearance: "none" };
7563
7644
  }
7564
7645
  const L2 = { width: "1px", height: "20px", margin: "0 4px", background: "rgba(15, 23, 42, 0.1)", flexShrink: 0 };
7565
- return (t2, s2) => (openBlock(), createElementBlock("div", { role: "toolbar", "aria-label": "选区工具", style: normalizeStyle(M2.value) }, [g2.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("button", { type: "button", title: "复制", "aria-label": "复制", style: normalizeStyle(x("copy")), onMouseenter: s2[0] || (s2[0] = (e15) => w2.value = "copy"), onMouseleave: s2[1] || (s2[1] = (e15) => w2.value = null), onClick: s2[2] || (s2[2] = (e15) => a2("action", "copy")) }, [e14.renderCopyIcon ? (openBlock(), createBlock(resolveDynamicComponent(e14.renderCopyIcon), { key: 0 })) : (openBlock(), createBlock(Oa, { key: 1, kind: "copy" }))], 36), b2.value ? (openBlock(), createElementBlock("span", { key: 0, style: L2, "aria-hidden": "" })) : createCommentVNode("", true)], 64)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(f2.value, (e15) => (openBlock(), createElementBlock("button", { key: e15.id, type: "button", title: e15.label, "aria-label": e15.label, style: normalizeStyle(x(e15.id)), onMouseenter: (t3) => w2.value = e15.id, onMouseleave: s2[3] || (s2[3] = (e16) => w2.value = null), onClick: (t3) => a2("action", e15.id) }, [createVNode(Oa, { kind: e15.id }, null, 8, ["kind"])], 44, Ra))), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(I2.value, (e15) => (openBlock(), createElementBlock("button", { key: e15.id, type: "button", title: e15.label, style: normalizeStyle(x(e15.id)), onMouseenter: (t3) => w2.value = e15.id, onMouseleave: s2[4] || (s2[4] = (e16) => w2.value = null), onClick: (t3) => a2("action", e15.id) }, [createElementVNode("span", Ga, toDisplayString(e15.label.slice(0, 2)), 1)], 44, za))), 128)), v.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [b2.value || g2.value ? (openBlock(), createElementBlock("span", { key: 0, style: L2, "aria-hidden": "" })) : createCommentVNode("", true), createElementVNode("button", { type: "button", title: "添加笔记", "aria-label": "添加笔记", style: normalizeStyle(x("note", true)), onMouseenter: s2[5] || (s2[5] = (e15) => w2.value = "note"), onMouseleave: s2[6] || (s2[6] = (e15) => w2.value = null), onClick: s2[7] || (s2[7] = (e15) => a2("action", "note")) }, [createVNode(Oa, { kind: "note" })], 36)], 64)) : createCommentVNode("", true)], 4));
7646
+ return (t2, s2) => (openBlock(), createElementBlock("div", { role: "toolbar", "aria-label": "选区工具", style: normalizeStyle(M2.value) }, [g2.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("button", { type: "button", title: "复制", "aria-label": "复制", style: normalizeStyle(x("copy")), onMouseenter: s2[0] || (s2[0] = (e15) => w2.value = "copy"), onMouseleave: s2[1] || (s2[1] = (e15) => w2.value = null), onClick: s2[2] || (s2[2] = (e15) => a2("action", "copy")) }, [e14.renderCopyIcon ? (openBlock(), createBlock(resolveDynamicComponent(e14.renderCopyIcon), { key: 0 })) : (openBlock(), createBlock(Oa, { key: 1, kind: "copy" }))], 36), b2.value ? (openBlock(), createElementBlock("span", { key: 0, style: L2, "aria-hidden": "" })) : createCommentVNode("", true)], 64)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(f2.value, (e15) => (openBlock(), createElementBlock("button", { key: e15.id, type: "button", title: e15.label, "aria-label": e15.label, style: normalizeStyle(x(e15.id)), onMouseenter: (t3) => w2.value = e15.id, onMouseleave: s2[3] || (s2[3] = (e16) => w2.value = null), onClick: (t3) => a2("action", e15.id) }, [createVNode(Oa, { kind: e15.id }, null, 8, ["kind"])], 44, Ra))), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(P2.value, (e15) => (openBlock(), createElementBlock("button", { key: e15.id, type: "button", title: e15.label, style: normalizeStyle(x(e15.id)), onMouseenter: (t3) => w2.value = e15.id, onMouseleave: s2[4] || (s2[4] = (e16) => w2.value = null), onClick: (t3) => a2("action", e15.id) }, [createElementVNode("span", Ga, toDisplayString(e15.label.slice(0, 2)), 1)], 44, za))), 128)), v.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [b2.value || g2.value ? (openBlock(), createElementBlock("span", { key: 0, style: L2, "aria-hidden": "" })) : createCommentVNode("", true), createElementVNode("button", { type: "button", title: "添加笔记", "aria-label": "添加笔记", style: normalizeStyle(x("note", true)), onMouseenter: s2[5] || (s2[5] = (e15) => w2.value = "note"), onMouseleave: s2[6] || (s2[6] = (e15) => w2.value = null), onClick: s2[7] || (s2[7] = (e15) => a2("action", "note")) }, [createVNode(Oa, { kind: "note" })], 36)], 64)) : createCommentVNode("", true)], 4));
7566
7647
  } }), _a = { highlight: "highlight", underline: "underline", squiggly: "squiggly", strikeout: "strikeout" };
7567
7648
  const Wa = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props: { className: {}, features: {}, buildSelectionMenu: {}, annotationSelectionMenu: {}, redactionSelectionMenu: {}, showNoteMarkers: { type: Boolean, default: true }, showBookmarkMarkers: { type: Boolean, default: true }, showRedactionLayer: { type: Boolean, default: false }, renderPageOverlay: {}, onExtraSelectionAction: {} }, setup(e14) {
7568
7649
  const s2 = e14, n9 = computed(() => s2.features), { hostRef: r2 } = Kn(n9), a2 = computed(() => {
@@ -7596,7 +7677,7 @@ const Wa = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
7596
7677
  }), v = computed(() => {
7597
7678
  var _a2, _b;
7598
7679
  return u2.value && false !== ((_b = (_a2 = s2.features) == null ? void 0 : _a2.bookmarks) == null ? void 0 : _b.enabled);
7599
- }), P2 = (function(e15, s3) {
7680
+ }), I2 = (function(e15, s3) {
7600
7681
  const n10 = computed(() => {
7601
7682
  var _a2;
7602
7683
  return (_a2 = e15()) == null ? void 0 : _a2.selectionToolbar;
@@ -7643,8 +7724,8 @@ const Wa = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
7643
7724
  };
7644
7725
  });
7645
7726
  })(() => s2.features, { onExtraAction: s2.onExtraSelectionAction }), C2 = computed(() => {
7646
- if (s2.buildSelectionMenu || P2.value) return (e15) => {
7647
- const t2 = P2.value ? P2.value(e15) : e15.defaultMenu;
7727
+ if (s2.buildSelectionMenu || I2.value) return (e15) => {
7728
+ const t2 = I2.value ? I2.value(e15) : e15.defaultMenu;
7648
7729
  return s2.buildSelectionMenu ? s2.buildSelectionMenu({ ...e15, defaultMenu: t2 }) : t2;
7649
7730
  };
7650
7731
  }), { provides: y } = useCapability(DocumentManagerPlugin.id);
@@ -7662,7 +7743,7 @@ const Wa = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
7662
7743
  const n10 = (_a2 = s2.renderPageOverlay) == null ? void 0 : _a2.call(s2, e15);
7663
7744
  if (n10 && t2.push(n10), t2.length) return h$1("div", t2);
7664
7745
  }
7665
- return (t2, s3) => (openBlock(), createElementBlock("div", { ref_key: "hostRef", ref: r2, class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(Pe$1)) }, [createVNode(unref(Ir), { class: normalizeClass(e14.className), style: normalizeStyle(a2.value) }, { page: withCtx(({ item: t3 }) => {
7746
+ return (t2, s3) => (openBlock(), createElementBlock("div", { ref_key: "hostRef", ref: r2, class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(Ie)) }, [createVNode(unref(Pr), { class: normalizeClass(e14.className), style: normalizeStyle(a2.value) }, { page: withCtx(({ item: t3 }) => {
7666
7747
  var _a2, _b, _c, _d;
7667
7748
  return [createVNode(ka, { item: t3, features: e14.features, "show-note-markers": p2.value, "show-bookmark-markers": m2.value, "show-redaction-layer": e14.showRedactionLayer, "note-marker-ui": (_b = (_a2 = e14.features) == null ? void 0 : _a2.notes) == null ? void 0 : _b.marker, "bookmark-marker-ui": (_d = (_c = e14.features) == null ? void 0 : _c.bookmarks) == null ? void 0 : _d.marker, "build-selection-menu": C2.value, "create-note": unref(i2), "annotation-selection-menu": e14.annotationSelectionMenu, "redaction-selection-menu": e14.redactionSelectionMenu, "render-page-overlay": x }, null, 8, ["item", "features", "show-note-markers", "show-bookmark-markers", "show-redaction-layer", "note-marker-ui", "bookmark-marker-ui", "build-selection-menu", "create-note", "annotation-selection-menu", "redaction-selection-menu"])];
7668
7749
  }), _: 1 }, 8, ["class", "style"]), renderSlot(t2.$slots, "default")], 6));
@@ -7673,7 +7754,7 @@ const Wa = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
7673
7754
  const t2 = ke$1(e15.features), { plugins: s3 } = Un({ ...e15.editorOptions, features: t2 });
7674
7755
  return { plugins: s3, features: t2, editorOptions: { ...e15.editorOptions, features: t2 } };
7675
7756
  })({ engine: s2.engine, options: s2.options, editorOptions: s2.editorOptions, features: s2.features }));
7676
- return (t2, s3) => (openBlock(), createElementBlock("div", { class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(Pe$1)) }, [createVNode(unref(EmbedPDF), { engine: e14.engine, plugins: n9.value.plugins }, { default: withCtx(({ pluginsReady: s4 }) => [s4 ? (openBlock(), createElementBlock("div", qa, [renderSlot(t2.$slots, "prepend"), createVNode(Wa, { class: normalizeClass(e14.viewportClassName), style: { flex: 1, minHeight: 0 }, features: n9.value.features, "on-extra-selection-action": e14.onExtraSelectionAction }, null, 8, ["class", "features", "on-extra-selection-action"]), renderSlot(t2.$slots, "default")])) : createCommentVNode("", true)]), _: 3 }, 8, ["engine", "plugins"])], 6));
7757
+ return (t2, s3) => (openBlock(), createElementBlock("div", { class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(Ie)) }, [createVNode(unref(EmbedPDF), { engine: e14.engine, plugins: n9.value.plugins }, { default: withCtx(({ pluginsReady: s4 }) => [s4 ? (openBlock(), createElementBlock("div", qa, [renderSlot(t2.$slots, "prepend"), createVNode(Wa, { class: normalizeClass(e14.viewportClassName), style: { flex: 1, minHeight: 0 }, features: n9.value.features, "on-extra-selection-action": e14.onExtraSelectionAction }, null, 8, ["class", "features", "on-extra-selection-action"]), renderSlot(t2.$slots, "default")])) : createCommentVNode("", true)]), _: 3 }, 8, ["engine", "plugins"])], 6));
7677
7758
  } }), Ka = { class: "chapter-tree-row" }, ja = ["aria-expanded"], Xa = { key: 1, class: "chapter-tree-toggle-spacer", "aria-hidden": "" }, Za = { class: "chapter-tree-label" }, Ya = { class: "chapter-tree-meta" }, Qa = { key: 0 }, Ja = (e14, t2) => {
7678
7759
  const s2 = e14.__vccOpts || e14;
7679
7760
  for (const [n9, r2] of t2) s2[n9] = r2;
@@ -8034,12 +8115,21 @@ const B = class n extends BasePlugin {
8034
8115
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
8035
8116
  }
8036
8117
  scheduleVisibleSegmentLoads(e14) {
8037
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
8038
- for (const r2 of t2) {
8039
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
8040
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
8118
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
8119
+ for (const o2 of t2) {
8120
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
8121
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
8041
8122
  }
8042
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
8123
+ const a2 = [];
8124
+ let i2 = true;
8125
+ for (; i2; ) {
8126
+ i2 = false;
8127
+ for (const e15 of r2) {
8128
+ const t3 = n9.get(e15);
8129
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
8130
+ }
8131
+ }
8132
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
8043
8133
  }
8044
8134
  pumpVisibleSegmentBacklog() {
8045
8135
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -8647,12 +8737,21 @@ const ce = class n2 extends BasePlugin {
8647
8737
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
8648
8738
  }
8649
8739
  scheduleVisibleSegmentLoads(e14) {
8650
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
8651
- for (const r2 of t2) {
8652
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
8653
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
8740
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
8741
+ for (const o2 of t2) {
8742
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
8743
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
8654
8744
  }
8655
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
8745
+ const a2 = [];
8746
+ let i2 = true;
8747
+ for (; i2; ) {
8748
+ i2 = false;
8749
+ for (const e15 of r2) {
8750
+ const t3 = n9.get(e15);
8751
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
8752
+ }
8753
+ }
8754
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
8656
8755
  }
8657
8756
  pumpVisibleSegmentBacklog() {
8658
8757
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -9448,12 +9547,21 @@ const Ee = class n3 extends BasePlugin {
9448
9547
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
9449
9548
  }
9450
9549
  scheduleVisibleSegmentLoads(e14) {
9451
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
9452
- for (const r2 of t2) {
9453
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
9454
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
9550
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
9551
+ for (const o2 of t2) {
9552
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
9553
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
9554
+ }
9555
+ const a2 = [];
9556
+ let i2 = true;
9557
+ for (; i2; ) {
9558
+ i2 = false;
9559
+ for (const e15 of r2) {
9560
+ const t3 = n9.get(e15);
9561
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
9562
+ }
9455
9563
  }
9456
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
9564
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
9457
9565
  }
9458
9566
  pumpVisibleSegmentBacklog() {
9459
9567
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -10061,12 +10169,21 @@ const et2 = class n4 extends BasePlugin {
10061
10169
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
10062
10170
  }
10063
10171
  scheduleVisibleSegmentLoads(e14) {
10064
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
10065
- for (const r2 of t2) {
10066
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
10067
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
10172
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
10173
+ for (const o2 of t2) {
10174
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
10175
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
10068
10176
  }
10069
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
10177
+ const a2 = [];
10178
+ let i2 = true;
10179
+ for (; i2; ) {
10180
+ i2 = false;
10181
+ for (const e15 of r2) {
10182
+ const t3 = n9.get(e15);
10183
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
10184
+ }
10185
+ }
10186
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
10070
10187
  }
10071
10188
  pumpVisibleSegmentBacklog() {
10072
10189
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -10977,12 +11094,21 @@ const Mt = class n6 extends BasePlugin {
10977
11094
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
10978
11095
  }
10979
11096
  scheduleVisibleSegmentLoads(e14) {
10980
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
10981
- for (const r2 of t2) {
10982
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
10983
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
11097
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
11098
+ for (const o2 of t2) {
11099
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
11100
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
11101
+ }
11102
+ const a2 = [];
11103
+ let i2 = true;
11104
+ for (; i2; ) {
11105
+ i2 = false;
11106
+ for (const e15 of r2) {
11107
+ const t3 = n9.get(e15);
11108
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
11109
+ }
10984
11110
  }
10985
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
11111
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
10986
11112
  }
10987
11113
  pumpVisibleSegmentBacklog() {
10988
11114
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -11590,12 +11716,21 @@ const Kt = class n7 extends BasePlugin {
11590
11716
  return 1e4 * this.manifest.chapters.findIndex((t3) => t3.chapterId === e14) + t2;
11591
11717
  }
11592
11718
  scheduleVisibleSegmentLoads(e14) {
11593
- const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = [];
11594
- for (const r2 of t2) {
11595
- const e15 = `${r2.chapterId}:${r2.segmentIndex}`;
11596
- s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(r2.chapterId, r2.segmentIndex) || n9.push({ chapterId: r2.chapterId, segmentIndex: r2.segmentIndex }));
11719
+ const t2 = [...e14].sort((e15, t3) => e15.priority - t3.priority), s2 = /* @__PURE__ */ new Set(), n9 = /* @__PURE__ */ new Map(), r2 = [];
11720
+ for (const o2 of t2) {
11721
+ const e15 = `${o2.chapterId}:${o2.segmentIndex}`;
11722
+ s2.has(e15) || (s2.add(e15), this.isSegmentDocumentOpen(o2.chapterId, o2.segmentIndex) || (n9.has(o2.chapterId) || (n9.set(o2.chapterId, []), r2.push(o2.chapterId)), n9.get(o2.chapterId).push({ chapterId: o2.chapterId, segmentIndex: o2.segmentIndex })));
11723
+ }
11724
+ const a2 = [];
11725
+ let i2 = true;
11726
+ for (; i2; ) {
11727
+ i2 = false;
11728
+ for (const e15 of r2) {
11729
+ const t3 = n9.get(e15);
11730
+ t3 && 0 !== t3.length && (a2.push(t3.shift()), i2 = true);
11731
+ }
11597
11732
  }
11598
- this.visibleSegmentBacklog = n9, this.pumpVisibleSegmentBacklog();
11733
+ this.visibleSegmentBacklog = a2, this.pumpVisibleSegmentBacklog();
11599
11734
  }
11600
11735
  pumpVisibleSegmentBacklog() {
11601
11736
  const e14 = Math.max(1, this.config.maxConcurrentSegmentLoads ?? 1);
@@ -12218,7 +12353,7 @@ function fs(e14) {
12218
12353
  function vs(e14, t2) {
12219
12354
  return `${e14}#s${t2}`;
12220
12355
  }
12221
- function Is(e14) {
12356
+ function Is2(e14) {
12222
12357
  const t2 = (function(e15) {
12223
12358
  if (null != e15.segmentPageThreshold && e15.segmentPageThreshold > 0) return e15.segmentPageThreshold;
12224
12359
  const t3 = e15.source;
@@ -12238,8 +12373,8 @@ function Is(e14) {
12238
12373
  }
12239
12374
  return { chapterId: e14.chapterId, threshold: t2, pageCount: s2, segments: a2 };
12240
12375
  }
12241
- function Ps2(e14, t2) {
12242
- const s2 = Is(e14);
12376
+ function Ps(e14, t2) {
12377
+ const s2 = Is2(e14);
12243
12378
  if (!s2) return 0;
12244
12379
  const n9 = s2.segments.find((e15) => t2 >= e15.localPageStart && t2 <= e15.localPageEnd);
12245
12380
  return (n9 == null ? void 0 : n9.index) ?? Math.floor(t2 / s2.threshold);
@@ -12370,7 +12505,7 @@ async function Gs(e14, t2, s2) {
12370
12505
  if (!i3) return;
12371
12506
  const o3 = /* @__PURE__ */ new Map();
12372
12507
  for (const h3 of n10) {
12373
- const e16 = h3.annotation.pageIndex, t4 = Ps2(i3, e16), s4 = a3.segments[t4];
12508
+ const e16 = h3.annotation.pageIndex, t4 = Ps(i3, e16), s4 = a3.segments[t4];
12374
12509
  if (!s4) continue;
12375
12510
  const n11 = o3.get(t4) ?? [];
12376
12511
  n11.push({ ...h3, annotation: { ...h3.annotation, pageIndex: e16 - s4.localPageStart } }), o3.set(t4, n11);
@@ -12887,13 +13022,29 @@ const _ChapterManagerPlugin = class _ChapterManagerPlugin2 extends BasePlugin {
12887
13022
  scheduleVisibleSegmentLoads(ranked) {
12888
13023
  const sorted = [...ranked].sort((a2, b2) => a2.priority - b2.priority);
12889
13024
  const seen = /* @__PURE__ */ new Set();
12890
- const nextBacklog = [];
13025
+ const grouped = /* @__PURE__ */ new Map();
13026
+ const chapterOrder = [];
12891
13027
  for (const t2 of sorted) {
12892
13028
  const k2 = `${t2.chapterId}:${t2.segmentIndex}`;
12893
13029
  if (seen.has(k2)) continue;
12894
13030
  seen.add(k2);
12895
13031
  if (this.isSegmentDocumentOpen(t2.chapterId, t2.segmentIndex)) continue;
12896
- nextBacklog.push({ chapterId: t2.chapterId, segmentIndex: t2.segmentIndex });
13032
+ if (!grouped.has(t2.chapterId)) {
13033
+ grouped.set(t2.chapterId, []);
13034
+ chapterOrder.push(t2.chapterId);
13035
+ }
13036
+ grouped.get(t2.chapterId).push({ chapterId: t2.chapterId, segmentIndex: t2.segmentIndex });
13037
+ }
13038
+ const nextBacklog = [];
13039
+ let remaining = true;
13040
+ while (remaining) {
13041
+ remaining = false;
13042
+ for (const chapterId of chapterOrder) {
13043
+ const queue = grouped.get(chapterId);
13044
+ if (!queue || queue.length === 0) continue;
13045
+ nextBacklog.push(queue.shift());
13046
+ remaining = true;
13047
+ }
12897
13048
  }
12898
13049
  this.visibleSegmentBacklog = nextBacklog;
12899
13050
  this.pumpVisibleSegmentBacklog();