UNPKG

223 kBJavaScriptView Raw
1/**
2 * @licstart The following is the entire license notice for the
3 * JavaScript code in this page
4 *
5 * Copyright 2022 Mozilla Foundation
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * @licend The above is the entire license notice for the
20 * JavaScript code in this page
21 */
22
23(function webpackUniversalModuleDefinition(root, factory) {
24 if(typeof exports === 'object' && typeof module === 'object')
25 module.exports = factory();
26 else if(typeof define === 'function' && define.amd)
27 define("pdfjs-dist/web/pdf_viewer", [], factory);
28 else if(typeof exports === 'object')
29 exports["pdfjs-dist/web/pdf_viewer"] = factory();
30 else
31 root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory();
32})(globalThis, () => {
33return /******/ (() => { // webpackBootstrap
34/******/ "use strict";
35/******/ var __webpack_modules__ = ([
36/* 0 */,
37/* 1 */
38/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
39
40
41
42Object.defineProperty(exports, "__esModule", ({
43 value: true
44}));
45exports.DefaultXfaLayerFactory = exports.DefaultTextLayerFactory = exports.DefaultStructTreeLayerFactory = exports.DefaultAnnotationLayerFactory = exports.DefaultAnnotationEditorLayerFactory = void 0;
46
47var _annotation_editor_layer_builder = __w_pdfjs_require__(2);
48
49var _annotation_layer_builder = __w_pdfjs_require__(5);
50
51var _l10n_utils = __w_pdfjs_require__(4);
52
53var _pdf_link_service = __w_pdfjs_require__(6);
54
55var _struct_tree_layer_builder = __w_pdfjs_require__(8);
56
57var _text_layer_builder = __w_pdfjs_require__(9);
58
59var _xfa_layer_builder = __w_pdfjs_require__(10);
60
61class DefaultAnnotationLayerFactory {
62 createAnnotationLayerBuilder({
63 pageDiv,
64 pdfPage,
65 annotationStorage = null,
66 imageResourcesPath = "",
67 renderForms = true,
68 l10n = _l10n_utils.NullL10n,
69 enableScripting = false,
70 hasJSActionsPromise = null,
71 mouseState = null,
72 fieldObjectsPromise = null,
73 annotationCanvasMap = null
74 }) {
75 return new _annotation_layer_builder.AnnotationLayerBuilder({
76 pageDiv,
77 pdfPage,
78 imageResourcesPath,
79 renderForms,
80 linkService: new _pdf_link_service.SimpleLinkService(),
81 l10n,
82 annotationStorage,
83 enableScripting,
84 hasJSActionsPromise,
85 fieldObjectsPromise,
86 mouseState,
87 annotationCanvasMap
88 });
89 }
90
91}
92
93exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
94
95class DefaultAnnotationEditorLayerFactory {
96 createAnnotationEditorLayerBuilder({
97 uiManager = null,
98 pageDiv,
99 pdfPage,
100 l10n,
101 annotationStorage = null
102 }) {
103 return new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({
104 uiManager,
105 pageDiv,
106 pdfPage,
107 l10n,
108 annotationStorage
109 });
110 }
111
112}
113
114exports.DefaultAnnotationEditorLayerFactory = DefaultAnnotationEditorLayerFactory;
115
116class DefaultStructTreeLayerFactory {
117 createStructTreeLayerBuilder({
118 pdfPage
119 }) {
120 return new _struct_tree_layer_builder.StructTreeLayerBuilder({
121 pdfPage
122 });
123 }
124
125}
126
127exports.DefaultStructTreeLayerFactory = DefaultStructTreeLayerFactory;
128
129class DefaultTextLayerFactory {
130 createTextLayerBuilder({
131 textLayerDiv,
132 pageIndex,
133 viewport,
134 enhanceTextSelection = false,
135 eventBus,
136 highlighter
137 }) {
138 return new _text_layer_builder.TextLayerBuilder({
139 textLayerDiv,
140 pageIndex,
141 viewport,
142 enhanceTextSelection,
143 eventBus,
144 highlighter
145 });
146 }
147
148}
149
150exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
151
152class DefaultXfaLayerFactory {
153 createXfaLayerBuilder({
154 pageDiv,
155 pdfPage,
156 annotationStorage = null
157 }) {
158 return new _xfa_layer_builder.XfaLayerBuilder({
159 pageDiv,
160 pdfPage,
161 annotationStorage,
162 linkService: new _pdf_link_service.SimpleLinkService()
163 });
164 }
165
166}
167
168exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory;
169
170/***/ }),
171/* 2 */
172/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
173
174
175
176Object.defineProperty(exports, "__esModule", ({
177 value: true
178}));
179exports.AnnotationEditorLayerBuilder = void 0;
180
181var _pdfjsLib = __w_pdfjs_require__(3);
182
183var _l10n_utils = __w_pdfjs_require__(4);
184
185class AnnotationEditorLayerBuilder {
186 #uiManager;
187
188 constructor(options) {
189 this.pageDiv = options.pageDiv;
190 this.pdfPage = options.pdfPage;
191 this.annotationStorage = options.annotationStorage || null;
192 this.l10n = options.l10n || _l10n_utils.NullL10n;
193 this.annotationEditorLayer = null;
194 this.div = null;
195 this._cancelled = false;
196 this.#uiManager = options.uiManager;
197 }
198
199 async render(viewport, intent = "display") {
200 if (intent !== "display") {
201 return;
202 }
203
204 if (this._cancelled) {
205 return;
206 }
207
208 const clonedViewport = viewport.clone({
209 dontFlip: true
210 });
211
212 if (this.div) {
213 this.annotationEditorLayer.update({
214 viewport: clonedViewport
215 });
216 this.show();
217 return;
218 }
219
220 this.div = document.createElement("div");
221 this.div.className = "annotationEditorLayer";
222 this.div.tabIndex = 0;
223 this.pageDiv.append(this.div);
224 this.annotationEditorLayer = new _pdfjsLib.AnnotationEditorLayer({
225 uiManager: this.#uiManager,
226 div: this.div,
227 annotationStorage: this.annotationStorage,
228 pageIndex: this.pdfPage._pageIndex,
229 l10n: this.l10n,
230 viewport: clonedViewport
231 });
232 const parameters = {
233 viewport: clonedViewport,
234 div: this.div,
235 annotations: null,
236 intent
237 };
238 this.annotationEditorLayer.render(parameters);
239 }
240
241 cancel() {
242 this._cancelled = true;
243 this.destroy();
244 }
245
246 hide() {
247 if (!this.div) {
248 return;
249 }
250
251 this.div.hidden = true;
252 }
253
254 show() {
255 if (!this.div) {
256 return;
257 }
258
259 this.div.hidden = false;
260 }
261
262 destroy() {
263 if (!this.div) {
264 return;
265 }
266
267 this.pageDiv = null;
268 this.annotationEditorLayer.destroy();
269 this.div.remove();
270 }
271
272}
273
274exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder;
275
276/***/ }),
277/* 3 */
278/***/ ((module) => {
279
280
281
282let pdfjsLib;
283
284if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
285 pdfjsLib = window["pdfjs-dist/build/pdf"];
286} else {
287 pdfjsLib = require("../build/pdf.js");
288}
289
290module.exports = pdfjsLib;
291
292/***/ }),
293/* 4 */
294/***/ ((__unused_webpack_module, exports) => {
295
296
297
298Object.defineProperty(exports, "__esModule", ({
299 value: true
300}));
301exports.NullL10n = void 0;
302exports.fixupLangCode = fixupLangCode;
303exports.getL10nFallback = getL10nFallback;
304const DEFAULT_L10N_STRINGS = {
305 of_pages: "of {{pagesCount}}",
306 page_of_pages: "({{pageNumber}} of {{pagesCount}})",
307 document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
308 document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
309 document_properties_date_string: "{{date}}, {{time}}",
310 document_properties_page_size_unit_inches: "in",
311 document_properties_page_size_unit_millimeters: "mm",
312 document_properties_page_size_orientation_portrait: "portrait",
313 document_properties_page_size_orientation_landscape: "landscape",
314 document_properties_page_size_name_a3: "A3",
315 document_properties_page_size_name_a4: "A4",
316 document_properties_page_size_name_letter: "Letter",
317 document_properties_page_size_name_legal: "Legal",
318 document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
319 document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
320 document_properties_linearized_yes: "Yes",
321 document_properties_linearized_no: "No",
322 print_progress_percent: "{{progress}}%",
323 "toggle_sidebar.title": "Toggle Sidebar",
324 "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)",
325 additional_layers: "Additional Layers",
326 page_landmark: "Page {{page}}",
327 thumb_page_title: "Page {{page}}",
328 thumb_page_canvas: "Thumbnail of Page {{page}}",
329 find_reached_top: "Reached top of document, continued from bottom",
330 find_reached_bottom: "Reached end of document, continued from top",
331 "find_match_count[one]": "{{current}} of {{total}} match",
332 "find_match_count[other]": "{{current}} of {{total}} matches",
333 "find_match_count_limit[one]": "More than {{limit}} match",
334 "find_match_count_limit[other]": "More than {{limit}} matches",
335 find_not_found: "Phrase not found",
336 error_version_info: "PDF.js v{{version}} (build: {{build}})",
337 error_message: "Message: {{message}}",
338 error_stack: "Stack: {{stack}}",
339 error_file: "File: {{file}}",
340 error_line: "Line: {{line}}",
341 rendering_error: "An error occurred while rendering the page.",
342 page_scale_width: "Page Width",
343 page_scale_fit: "Page Fit",
344 page_scale_auto: "Automatic Zoom",
345 page_scale_actual: "Actual Size",
346 page_scale_percent: "{{scale}}%",
347 loading: "Loading…",
348 loading_error: "An error occurred while loading the PDF.",
349 invalid_file_error: "Invalid or corrupted PDF file.",
350 missing_file_error: "Missing PDF file.",
351 unexpected_response_error: "Unexpected server response.",
352 printing_not_supported: "Warning: Printing is not fully supported by this browser.",
353 printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
354 web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
355 free_text_default_content: "Enter text…",
356 editor_free_text_aria_label: "FreeText Editor",
357 editor_ink_aria_label: "Ink Editor",
358 editor_ink_canvas_aria_label: "User-created image"
359};
360
361function getL10nFallback(key, args) {
362 switch (key) {
363 case "find_match_count":
364 key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
365 break;
366
367 case "find_match_count_limit":
368 key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
369 break;
370 }
371
372 return DEFAULT_L10N_STRINGS[key] || "";
373}
374
375const PARTIAL_LANG_CODES = {
376 en: "en-US",
377 es: "es-ES",
378 fy: "fy-NL",
379 ga: "ga-IE",
380 gu: "gu-IN",
381 hi: "hi-IN",
382 hy: "hy-AM",
383 nb: "nb-NO",
384 ne: "ne-NP",
385 nn: "nn-NO",
386 pa: "pa-IN",
387 pt: "pt-PT",
388 sv: "sv-SE",
389 zh: "zh-CN"
390};
391
392function fixupLangCode(langCode) {
393 return PARTIAL_LANG_CODES[langCode?.toLowerCase()] || langCode;
394}
395
396function formatL10nValue(text, args) {
397 if (!args) {
398 return text;
399 }
400
401 return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
402 return name in args ? args[name] : "{{" + name + "}}";
403 });
404}
405
406const NullL10n = {
407 async getLanguage() {
408 return "en-us";
409 },
410
411 async getDirection() {
412 return "ltr";
413 },
414
415 async get(key, args = null, fallback = getL10nFallback(key, args)) {
416 return formatL10nValue(fallback, args);
417 },
418
419 async translate(element) {}
420
421};
422exports.NullL10n = NullL10n;
423
424/***/ }),
425/* 5 */
426/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
427
428
429
430Object.defineProperty(exports, "__esModule", ({
431 value: true
432}));
433exports.AnnotationLayerBuilder = void 0;
434
435var _pdfjsLib = __w_pdfjs_require__(3);
436
437var _l10n_utils = __w_pdfjs_require__(4);
438
439class AnnotationLayerBuilder {
440 constructor({
441 pageDiv,
442 pdfPage,
443 linkService,
444 downloadManager,
445 annotationStorage = null,
446 imageResourcesPath = "",
447 renderForms = true,
448 l10n = _l10n_utils.NullL10n,
449 enableScripting = false,
450 hasJSActionsPromise = null,
451 fieldObjectsPromise = null,
452 mouseState = null,
453 annotationCanvasMap = null
454 }) {
455 this.pageDiv = pageDiv;
456 this.pdfPage = pdfPage;
457 this.linkService = linkService;
458 this.downloadManager = downloadManager;
459 this.imageResourcesPath = imageResourcesPath;
460 this.renderForms = renderForms;
461 this.l10n = l10n;
462 this.annotationStorage = annotationStorage;
463 this.enableScripting = enableScripting;
464 this._hasJSActionsPromise = hasJSActionsPromise;
465 this._fieldObjectsPromise = fieldObjectsPromise;
466 this._mouseState = mouseState;
467 this._annotationCanvasMap = annotationCanvasMap;
468 this.div = null;
469 this._cancelled = false;
470 }
471
472 async render(viewport, intent = "display") {
473 const [annotations, hasJSActions = false, fieldObjects = null] = await Promise.all([this.pdfPage.getAnnotations({
474 intent
475 }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
476
477 if (this._cancelled || annotations.length === 0) {
478 return;
479 }
480
481 const parameters = {
482 viewport: viewport.clone({
483 dontFlip: true
484 }),
485 div: this.div,
486 annotations,
487 page: this.pdfPage,
488 imageResourcesPath: this.imageResourcesPath,
489 renderForms: this.renderForms,
490 linkService: this.linkService,
491 downloadManager: this.downloadManager,
492 annotationStorage: this.annotationStorage,
493 enableScripting: this.enableScripting,
494 hasJSActions,
495 fieldObjects,
496 mouseState: this._mouseState,
497 annotationCanvasMap: this._annotationCanvasMap
498 };
499
500 if (this.div) {
501 _pdfjsLib.AnnotationLayer.update(parameters);
502 } else {
503 this.div = document.createElement("div");
504 this.div.className = "annotationLayer";
505 this.pageDiv.append(this.div);
506 parameters.div = this.div;
507
508 _pdfjsLib.AnnotationLayer.render(parameters);
509
510 this.l10n.translate(this.div);
511 }
512 }
513
514 cancel() {
515 this._cancelled = true;
516 }
517
518 hide() {
519 if (!this.div) {
520 return;
521 }
522
523 this.div.hidden = true;
524 }
525
526}
527
528exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
529
530/***/ }),
531/* 6 */
532/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
533
534
535
536Object.defineProperty(exports, "__esModule", ({
537 value: true
538}));
539exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0;
540
541var _ui_utils = __w_pdfjs_require__(7);
542
543const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
544const LinkTarget = {
545 NONE: 0,
546 SELF: 1,
547 BLANK: 2,
548 PARENT: 3,
549 TOP: 4
550};
551exports.LinkTarget = LinkTarget;
552
553function addLinkAttributes(link, {
554 url,
555 target,
556 rel,
557 enabled = true
558} = {}) {
559 if (!url || typeof url !== "string") {
560 throw new Error('A valid "url" parameter must provided.');
561 }
562
563 const urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url);
564
565 if (enabled) {
566 link.href = link.title = urlNullRemoved;
567 } else {
568 link.href = "";
569 link.title = `Disabled: ${urlNullRemoved}`;
570
571 link.onclick = () => {
572 return false;
573 };
574 }
575
576 let targetStr = "";
577
578 switch (target) {
579 case LinkTarget.NONE:
580 break;
581
582 case LinkTarget.SELF:
583 targetStr = "_self";
584 break;
585
586 case LinkTarget.BLANK:
587 targetStr = "_blank";
588 break;
589
590 case LinkTarget.PARENT:
591 targetStr = "_parent";
592 break;
593
594 case LinkTarget.TOP:
595 targetStr = "_top";
596 break;
597 }
598
599 link.target = targetStr;
600 link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
601}
602
603class PDFLinkService {
604 #pagesRefCache = new Map();
605
606 constructor({
607 eventBus,
608 externalLinkTarget = null,
609 externalLinkRel = null,
610 ignoreDestinationZoom = false
611 } = {}) {
612 this.eventBus = eventBus;
613 this.externalLinkTarget = externalLinkTarget;
614 this.externalLinkRel = externalLinkRel;
615 this.externalLinkEnabled = true;
616 this._ignoreDestinationZoom = ignoreDestinationZoom;
617 this.baseUrl = null;
618 this.pdfDocument = null;
619 this.pdfViewer = null;
620 this.pdfHistory = null;
621 }
622
623 setDocument(pdfDocument, baseUrl = null) {
624 this.baseUrl = baseUrl;
625 this.pdfDocument = pdfDocument;
626 this.#pagesRefCache.clear();
627 }
628
629 setViewer(pdfViewer) {
630 this.pdfViewer = pdfViewer;
631 }
632
633 setHistory(pdfHistory) {
634 this.pdfHistory = pdfHistory;
635 }
636
637 get pagesCount() {
638 return this.pdfDocument ? this.pdfDocument.numPages : 0;
639 }
640
641 get page() {
642 return this.pdfViewer.currentPageNumber;
643 }
644
645 set page(value) {
646 this.pdfViewer.currentPageNumber = value;
647 }
648
649 get rotation() {
650 return this.pdfViewer.pagesRotation;
651 }
652
653 set rotation(value) {
654 this.pdfViewer.pagesRotation = value;
655 }
656
657 #goToDestinationHelper(rawDest, namedDest = null, explicitDest) {
658 const destRef = explicitDest[0];
659 let pageNumber;
660
661 if (typeof destRef === "object" && destRef !== null) {
662 pageNumber = this._cachedPageNumber(destRef);
663
664 if (!pageNumber) {
665 this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
666 this.cachePageRef(pageIndex + 1, destRef);
667 this.#goToDestinationHelper(rawDest, namedDest, explicitDest);
668 }).catch(() => {
669 console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
670 });
671 return;
672 }
673 } else if (Number.isInteger(destRef)) {
674 pageNumber = destRef + 1;
675 } else {
676 console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
677 return;
678 }
679
680 if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
681 console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
682 return;
683 }
684
685 if (this.pdfHistory) {
686 this.pdfHistory.pushCurrentPosition();
687 this.pdfHistory.push({
688 namedDest,
689 explicitDest,
690 pageNumber
691 });
692 }
693
694 this.pdfViewer.scrollPageIntoView({
695 pageNumber,
696 destArray: explicitDest,
697 ignoreDestinationZoom: this._ignoreDestinationZoom
698 });
699 }
700
701 async goToDestination(dest) {
702 if (!this.pdfDocument) {
703 return;
704 }
705
706 let namedDest, explicitDest;
707
708 if (typeof dest === "string") {
709 namedDest = dest;
710 explicitDest = await this.pdfDocument.getDestination(dest);
711 } else {
712 namedDest = null;
713 explicitDest = await dest;
714 }
715
716 if (!Array.isArray(explicitDest)) {
717 console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
718 return;
719 }
720
721 this.#goToDestinationHelper(dest, namedDest, explicitDest);
722 }
723
724 goToPage(val) {
725 if (!this.pdfDocument) {
726 return;
727 }
728
729 const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
730
731 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
732 console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
733 return;
734 }
735
736 if (this.pdfHistory) {
737 this.pdfHistory.pushCurrentPosition();
738 this.pdfHistory.pushPage(pageNumber);
739 }
740
741 this.pdfViewer.scrollPageIntoView({
742 pageNumber
743 });
744 }
745
746 addLinkAttributes(link, url, newWindow = false) {
747 addLinkAttributes(link, {
748 url,
749 target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
750 rel: this.externalLinkRel,
751 enabled: this.externalLinkEnabled
752 });
753 }
754
755 getDestinationHash(dest) {
756 if (typeof dest === "string") {
757 if (dest.length > 0) {
758 return this.getAnchorUrl("#" + escape(dest));
759 }
760 } else if (Array.isArray(dest)) {
761 const str = JSON.stringify(dest);
762
763 if (str.length > 0) {
764 return this.getAnchorUrl("#" + escape(str));
765 }
766 }
767
768 return this.getAnchorUrl("");
769 }
770
771 getAnchorUrl(anchor) {
772 return (this.baseUrl || "") + anchor;
773 }
774
775 setHash(hash) {
776 if (!this.pdfDocument) {
777 return;
778 }
779
780 let pageNumber, dest;
781
782 if (hash.includes("=")) {
783 const params = (0, _ui_utils.parseQueryString)(hash);
784
785 if (params.has("search")) {
786 this.eventBus.dispatch("findfromurlhash", {
787 source: this,
788 query: params.get("search").replace(/"/g, ""),
789 phraseSearch: params.get("phrase") === "true"
790 });
791 }
792
793 if (params.has("page")) {
794 pageNumber = params.get("page") | 0 || 1;
795 }
796
797 if (params.has("zoom")) {
798 const zoomArgs = params.get("zoom").split(",");
799 const zoomArg = zoomArgs[0];
800 const zoomArgNumber = parseFloat(zoomArg);
801
802 if (!zoomArg.includes("Fit")) {
803 dest = [null, {
804 name: "XYZ"
805 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
806 } else {
807 if (zoomArg === "Fit" || zoomArg === "FitB") {
808 dest = [null, {
809 name: zoomArg
810 }];
811 } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
812 dest = [null, {
813 name: zoomArg
814 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
815 } else if (zoomArg === "FitR") {
816 if (zoomArgs.length !== 5) {
817 console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
818 } else {
819 dest = [null, {
820 name: zoomArg
821 }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
822 }
823 } else {
824 console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
825 }
826 }
827 }
828
829 if (dest) {
830 this.pdfViewer.scrollPageIntoView({
831 pageNumber: pageNumber || this.page,
832 destArray: dest,
833 allowNegativeOffset: true
834 });
835 } else if (pageNumber) {
836 this.page = pageNumber;
837 }
838
839 if (params.has("pagemode")) {
840 this.eventBus.dispatch("pagemode", {
841 source: this,
842 mode: params.get("pagemode")
843 });
844 }
845
846 if (params.has("nameddest")) {
847 this.goToDestination(params.get("nameddest"));
848 }
849 } else {
850 dest = unescape(hash);
851
852 try {
853 dest = JSON.parse(dest);
854
855 if (!Array.isArray(dest)) {
856 dest = dest.toString();
857 }
858 } catch (ex) {}
859
860 if (typeof dest === "string" || PDFLinkService.#isValidExplicitDestination(dest)) {
861 this.goToDestination(dest);
862 return;
863 }
864
865 console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
866 }
867 }
868
869 executeNamedAction(action) {
870 switch (action) {
871 case "GoBack":
872 this.pdfHistory?.back();
873 break;
874
875 case "GoForward":
876 this.pdfHistory?.forward();
877 break;
878
879 case "NextPage":
880 this.pdfViewer.nextPage();
881 break;
882
883 case "PrevPage":
884 this.pdfViewer.previousPage();
885 break;
886
887 case "LastPage":
888 this.page = this.pagesCount;
889 break;
890
891 case "FirstPage":
892 this.page = 1;
893 break;
894
895 default:
896 break;
897 }
898
899 this.eventBus.dispatch("namedaction", {
900 source: this,
901 action
902 });
903 }
904
905 cachePageRef(pageNum, pageRef) {
906 if (!pageRef) {
907 return;
908 }
909
910 const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
911 this.#pagesRefCache.set(refStr, pageNum);
912 }
913
914 _cachedPageNumber(pageRef) {
915 if (!pageRef) {
916 return null;
917 }
918
919 const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
920 return this.#pagesRefCache.get(refStr) || null;
921 }
922
923 isPageVisible(pageNumber) {
924 return this.pdfViewer.isPageVisible(pageNumber);
925 }
926
927 isPageCached(pageNumber) {
928 return this.pdfViewer.isPageCached(pageNumber);
929 }
930
931 static #isValidExplicitDestination(dest) {
932 if (!Array.isArray(dest)) {
933 return false;
934 }
935
936 const destLength = dest.length;
937
938 if (destLength < 2) {
939 return false;
940 }
941
942 const page = dest[0];
943
944 if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
945 return false;
946 }
947
948 const zoom = dest[1];
949
950 if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
951 return false;
952 }
953
954 let allowNull = true;
955
956 switch (zoom.name) {
957 case "XYZ":
958 if (destLength !== 5) {
959 return false;
960 }
961
962 break;
963
964 case "Fit":
965 case "FitB":
966 return destLength === 2;
967
968 case "FitH":
969 case "FitBH":
970 case "FitV":
971 case "FitBV":
972 if (destLength !== 3) {
973 return false;
974 }
975
976 break;
977
978 case "FitR":
979 if (destLength !== 6) {
980 return false;
981 }
982
983 allowNull = false;
984 break;
985
986 default:
987 return false;
988 }
989
990 for (let i = 2; i < destLength; i++) {
991 const param = dest[i];
992
993 if (!(typeof param === "number" || allowNull && param === null)) {
994 return false;
995 }
996 }
997
998 return true;
999 }
1000
1001}
1002
1003exports.PDFLinkService = PDFLinkService;
1004
1005class SimpleLinkService {
1006 constructor() {
1007 this.externalLinkEnabled = true;
1008 }
1009
1010 get pagesCount() {
1011 return 0;
1012 }
1013
1014 get page() {
1015 return 0;
1016 }
1017
1018 set page(value) {}
1019
1020 get rotation() {
1021 return 0;
1022 }
1023
1024 set rotation(value) {}
1025
1026 async goToDestination(dest) {}
1027
1028 goToPage(val) {}
1029
1030 addLinkAttributes(link, url, newWindow = false) {
1031 addLinkAttributes(link, {
1032 url,
1033 enabled: this.externalLinkEnabled
1034 });
1035 }
1036
1037 getDestinationHash(dest) {
1038 return "#";
1039 }
1040
1041 getAnchorUrl(hash) {
1042 return "#";
1043 }
1044
1045 setHash(hash) {}
1046
1047 executeNamedAction(action) {}
1048
1049 cachePageRef(pageNum, pageRef) {}
1050
1051 isPageVisible(pageNumber) {
1052 return true;
1053 }
1054
1055 isPageCached(pageNumber) {
1056 return true;
1057 }
1058
1059}
1060
1061exports.SimpleLinkService = SimpleLinkService;
1062
1063/***/ }),
1064/* 7 */
1065/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
1066
1067
1068
1069Object.defineProperty(exports, "__esModule", ({
1070 value: true
1071}));
1072exports.animationStarted = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RenderingStates = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.OutputScale = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE_DELTA = exports.DEFAULT_SCALE = exports.AutoPrintRegExp = void 0;
1073exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes;
1074exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
1075exports.approximateFraction = approximateFraction;
1076exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
1077exports.docStyle = void 0;
1078exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
1079exports.getPageSizeInches = getPageSizeInches;
1080exports.getVisibleElements = getVisibleElements;
1081exports.isPortraitOrientation = isPortraitOrientation;
1082exports.isValidRotation = isValidRotation;
1083exports.isValidScrollMode = isValidScrollMode;
1084exports.isValidSpreadMode = isValidSpreadMode;
1085exports.noContextMenuHandler = noContextMenuHandler;
1086exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
1087exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
1088exports.parseQueryString = parseQueryString;
1089exports.removeNullCharacters = removeNullCharacters;
1090exports.roundToDivide = roundToDivide;
1091exports.scrollIntoView = scrollIntoView;
1092exports.watchScroll = watchScroll;
1093
1094var _pdfjsLib = __w_pdfjs_require__(3);
1095
1096const DEFAULT_SCALE_VALUE = "auto";
1097exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
1098const DEFAULT_SCALE = 1.0;
1099exports.DEFAULT_SCALE = DEFAULT_SCALE;
1100const DEFAULT_SCALE_DELTA = 1.1;
1101exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA;
1102const MIN_SCALE = 0.1;
1103exports.MIN_SCALE = MIN_SCALE;
1104const MAX_SCALE = 10.0;
1105exports.MAX_SCALE = MAX_SCALE;
1106const UNKNOWN_SCALE = 0;
1107exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
1108const MAX_AUTO_SCALE = 1.25;
1109exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
1110const SCROLLBAR_PADDING = 40;
1111exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
1112const VERTICAL_PADDING = 5;
1113exports.VERTICAL_PADDING = VERTICAL_PADDING;
1114const RenderingStates = {
1115 INITIAL: 0,
1116 RUNNING: 1,
1117 PAUSED: 2,
1118 FINISHED: 3
1119};
1120exports.RenderingStates = RenderingStates;
1121const PresentationModeState = {
1122 UNKNOWN: 0,
1123 NORMAL: 1,
1124 CHANGING: 2,
1125 FULLSCREEN: 3
1126};
1127exports.PresentationModeState = PresentationModeState;
1128const SidebarView = {
1129 UNKNOWN: -1,
1130 NONE: 0,
1131 THUMBS: 1,
1132 OUTLINE: 2,
1133 ATTACHMENTS: 3,
1134 LAYERS: 4
1135};
1136exports.SidebarView = SidebarView;
1137const RendererType = {
1138 CANVAS: "canvas",
1139 SVG: "svg"
1140};
1141exports.RendererType = RendererType;
1142const TextLayerMode = {
1143 DISABLE: 0,
1144 ENABLE: 1,
1145 ENABLE_ENHANCE: 2
1146};
1147exports.TextLayerMode = TextLayerMode;
1148const ScrollMode = {
1149 UNKNOWN: -1,
1150 VERTICAL: 0,
1151 HORIZONTAL: 1,
1152 WRAPPED: 2,
1153 PAGE: 3
1154};
1155exports.ScrollMode = ScrollMode;
1156const SpreadMode = {
1157 UNKNOWN: -1,
1158 NONE: 0,
1159 ODD: 1,
1160 EVEN: 2
1161};
1162exports.SpreadMode = SpreadMode;
1163const AutoPrintRegExp = /\bprint\s*\(/;
1164exports.AutoPrintRegExp = AutoPrintRegExp;
1165
1166class OutputScale {
1167 constructor() {
1168 const pixelRatio = window.devicePixelRatio || 1;
1169 this.sx = pixelRatio;
1170 this.sy = pixelRatio;
1171 }
1172
1173 get scaled() {
1174 return this.sx !== 1 || this.sy !== 1;
1175 }
1176
1177}
1178
1179exports.OutputScale = OutputScale;
1180
1181function scrollIntoView(element, spot, scrollMatches = false) {
1182 let parent = element.offsetParent;
1183
1184 if (!parent) {
1185 console.error("offsetParent is not set -- cannot scroll");
1186 return;
1187 }
1188
1189 let offsetY = element.offsetTop + element.clientTop;
1190 let offsetX = element.offsetLeft + element.clientLeft;
1191
1192 while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
1193 offsetY += parent.offsetTop;
1194 offsetX += parent.offsetLeft;
1195 parent = parent.offsetParent;
1196
1197 if (!parent) {
1198 return;
1199 }
1200 }
1201
1202 if (spot) {
1203 if (spot.top !== undefined) {
1204 offsetY += spot.top;
1205 }
1206
1207 if (spot.left !== undefined) {
1208 offsetX += spot.left;
1209 parent.scrollLeft = offsetX;
1210 }
1211 }
1212
1213 parent.scrollTop = offsetY;
1214}
1215
1216function watchScroll(viewAreaElement, callback) {
1217 const debounceScroll = function (evt) {
1218 if (rAF) {
1219 return;
1220 }
1221
1222 rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
1223 rAF = null;
1224 const currentX = viewAreaElement.scrollLeft;
1225 const lastX = state.lastX;
1226
1227 if (currentX !== lastX) {
1228 state.right = currentX > lastX;
1229 }
1230
1231 state.lastX = currentX;
1232 const currentY = viewAreaElement.scrollTop;
1233 const lastY = state.lastY;
1234
1235 if (currentY !== lastY) {
1236 state.down = currentY > lastY;
1237 }
1238
1239 state.lastY = currentY;
1240 callback(state);
1241 });
1242 };
1243
1244 const state = {
1245 right: true,
1246 down: true,
1247 lastX: viewAreaElement.scrollLeft,
1248 lastY: viewAreaElement.scrollTop,
1249 _eventHandler: debounceScroll
1250 };
1251 let rAF = null;
1252 viewAreaElement.addEventListener("scroll", debounceScroll, true);
1253 return state;
1254}
1255
1256function parseQueryString(query) {
1257 const params = new Map();
1258
1259 for (const [key, value] of new URLSearchParams(query)) {
1260 params.set(key.toLowerCase(), value);
1261 }
1262
1263 return params;
1264}
1265
1266const NullCharactersRegExp = /\x00/g;
1267const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
1268
1269function removeNullCharacters(str, replaceInvisible = false) {
1270 if (typeof str !== "string") {
1271 console.error(`The argument must be a string.`);
1272 return str;
1273 }
1274
1275 if (replaceInvisible) {
1276 str = str.replace(InvisibleCharactersRegExp, " ");
1277 }
1278
1279 return str.replace(NullCharactersRegExp, "");
1280}
1281
1282function approximateFraction(x) {
1283 if (Math.floor(x) === x) {
1284 return [x, 1];
1285 }
1286
1287 const xinv = 1 / x;
1288 const limit = 8;
1289
1290 if (xinv > limit) {
1291 return [1, limit];
1292 } else if (Math.floor(xinv) === xinv) {
1293 return [1, xinv];
1294 }
1295
1296 const x_ = x > 1 ? xinv : x;
1297 let a = 0,
1298 b = 1,
1299 c = 1,
1300 d = 1;
1301
1302 while (true) {
1303 const p = a + c,
1304 q = b + d;
1305
1306 if (q > limit) {
1307 break;
1308 }
1309
1310 if (x_ <= p / q) {
1311 c = p;
1312 d = q;
1313 } else {
1314 a = p;
1315 b = q;
1316 }
1317 }
1318
1319 let result;
1320
1321 if (x_ - a / b < c / d - x_) {
1322 result = x_ === x ? [a, b] : [b, a];
1323 } else {
1324 result = x_ === x ? [c, d] : [d, c];
1325 }
1326
1327 return result;
1328}
1329
1330function roundToDivide(x, div) {
1331 const r = x % div;
1332 return r === 0 ? x : Math.round(x - r + div);
1333}
1334
1335function getPageSizeInches({
1336 view,
1337 userUnit,
1338 rotate
1339}) {
1340 const [x1, y1, x2, y2] = view;
1341 const changeOrientation = rotate % 180 !== 0;
1342 const width = (x2 - x1) / 72 * userUnit;
1343 const height = (y2 - y1) / 72 * userUnit;
1344 return {
1345 width: changeOrientation ? height : width,
1346 height: changeOrientation ? width : height
1347 };
1348}
1349
1350function backtrackBeforeAllVisibleElements(index, views, top) {
1351 if (index < 2) {
1352 return index;
1353 }
1354
1355 let elt = views[index].div;
1356 let pageTop = elt.offsetTop + elt.clientTop;
1357
1358 if (pageTop >= top) {
1359 elt = views[index - 1].div;
1360 pageTop = elt.offsetTop + elt.clientTop;
1361 }
1362
1363 for (let i = index - 2; i >= 0; --i) {
1364 elt = views[i].div;
1365
1366 if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
1367 break;
1368 }
1369
1370 index = i;
1371 }
1372
1373 return index;
1374}
1375
1376function getVisibleElements({
1377 scrollEl,
1378 views,
1379 sortByVisibility = false,
1380 horizontal = false,
1381 rtl = false
1382}) {
1383 const top = scrollEl.scrollTop,
1384 bottom = top + scrollEl.clientHeight;
1385 const left = scrollEl.scrollLeft,
1386 right = left + scrollEl.clientWidth;
1387
1388 function isElementBottomAfterViewTop(view) {
1389 const element = view.div;
1390 const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
1391 return elementBottom > top;
1392 }
1393
1394 function isElementNextAfterViewHorizontally(view) {
1395 const element = view.div;
1396 const elementLeft = element.offsetLeft + element.clientLeft;
1397 const elementRight = elementLeft + element.clientWidth;
1398 return rtl ? elementLeft < right : elementRight > left;
1399 }
1400
1401 const visible = [],
1402 ids = new Set(),
1403 numViews = views.length;
1404 let firstVisibleElementInd = (0, _pdfjsLib.binarySearchFirstItem)(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
1405
1406 if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
1407 firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
1408 }
1409
1410 let lastEdge = horizontal ? right : -1;
1411
1412 for (let i = firstVisibleElementInd; i < numViews; i++) {
1413 const view = views[i],
1414 element = view.div;
1415 const currentWidth = element.offsetLeft + element.clientLeft;
1416 const currentHeight = element.offsetTop + element.clientTop;
1417 const viewWidth = element.clientWidth,
1418 viewHeight = element.clientHeight;
1419 const viewRight = currentWidth + viewWidth;
1420 const viewBottom = currentHeight + viewHeight;
1421
1422 if (lastEdge === -1) {
1423 if (viewBottom >= bottom) {
1424 lastEdge = viewBottom;
1425 }
1426 } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
1427 break;
1428 }
1429
1430 if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
1431 continue;
1432 }
1433
1434 const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
1435 const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
1436 const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
1437 fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
1438 const percent = fractionHeight * fractionWidth * 100 | 0;
1439 visible.push({
1440 id: view.id,
1441 x: currentWidth,
1442 y: currentHeight,
1443 view,
1444 percent,
1445 widthPercent: fractionWidth * 100 | 0
1446 });
1447 ids.add(view.id);
1448 }
1449
1450 const first = visible[0],
1451 last = visible.at(-1);
1452
1453 if (sortByVisibility) {
1454 visible.sort(function (a, b) {
1455 const pc = a.percent - b.percent;
1456
1457 if (Math.abs(pc) > 0.001) {
1458 return -pc;
1459 }
1460
1461 return a.id - b.id;
1462 });
1463 }
1464
1465 return {
1466 first,
1467 last,
1468 views: visible,
1469 ids
1470 };
1471}
1472
1473function noContextMenuHandler(evt) {
1474 evt.preventDefault();
1475}
1476
1477function normalizeWheelEventDirection(evt) {
1478 let delta = Math.hypot(evt.deltaX, evt.deltaY);
1479 const angle = Math.atan2(evt.deltaY, evt.deltaX);
1480
1481 if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
1482 delta = -delta;
1483 }
1484
1485 return delta;
1486}
1487
1488function normalizeWheelEventDelta(evt) {
1489 let delta = normalizeWheelEventDirection(evt);
1490 const MOUSE_DOM_DELTA_PIXEL_MODE = 0;
1491 const MOUSE_DOM_DELTA_LINE_MODE = 1;
1492 const MOUSE_PIXELS_PER_LINE = 30;
1493 const MOUSE_LINES_PER_PAGE = 30;
1494
1495 if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
1496 delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
1497 } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
1498 delta /= MOUSE_LINES_PER_PAGE;
1499 }
1500
1501 return delta;
1502}
1503
1504function isValidRotation(angle) {
1505 return Number.isInteger(angle) && angle % 90 === 0;
1506}
1507
1508function isValidScrollMode(mode) {
1509 return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
1510}
1511
1512function isValidSpreadMode(mode) {
1513 return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
1514}
1515
1516function isPortraitOrientation(size) {
1517 return size.width <= size.height;
1518}
1519
1520const animationStarted = new Promise(function (resolve) {
1521 window.requestAnimationFrame(resolve);
1522});
1523exports.animationStarted = animationStarted;
1524const docStyle = document.documentElement.style;
1525exports.docStyle = docStyle;
1526
1527function clamp(v, min, max) {
1528 return Math.min(Math.max(v, min), max);
1529}
1530
1531class ProgressBar {
1532 #classList = null;
1533 #percent = 0;
1534 #visible = true;
1535
1536 constructor(id) {
1537 if (arguments.length > 1) {
1538 throw new Error("ProgressBar no longer accepts any additional options, " + "please use CSS rules to modify its appearance instead.");
1539 }
1540
1541 const bar = document.getElementById(id);
1542 this.#classList = bar.classList;
1543 }
1544
1545 get percent() {
1546 return this.#percent;
1547 }
1548
1549 set percent(val) {
1550 this.#percent = clamp(val, 0, 100);
1551
1552 if (isNaN(val)) {
1553 this.#classList.add("indeterminate");
1554 return;
1555 }
1556
1557 this.#classList.remove("indeterminate");
1558 docStyle.setProperty("--progressBar-percent", `${this.#percent}%`);
1559 }
1560
1561 setWidth(viewer) {
1562 if (!viewer) {
1563 return;
1564 }
1565
1566 const container = viewer.parentNode;
1567 const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
1568
1569 if (scrollbarWidth > 0) {
1570 docStyle.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
1571 }
1572 }
1573
1574 hide() {
1575 if (!this.#visible) {
1576 return;
1577 }
1578
1579 this.#visible = false;
1580 this.#classList.add("hidden");
1581 }
1582
1583 show() {
1584 if (this.#visible) {
1585 return;
1586 }
1587
1588 this.#visible = true;
1589 this.#classList.remove("hidden");
1590 }
1591
1592}
1593
1594exports.ProgressBar = ProgressBar;
1595
1596function getActiveOrFocusedElement() {
1597 let curRoot = document;
1598 let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
1599
1600 while (curActiveOrFocused?.shadowRoot) {
1601 curRoot = curActiveOrFocused.shadowRoot;
1602 curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
1603 }
1604
1605 return curActiveOrFocused;
1606}
1607
1608function apiPageLayoutToViewerModes(layout) {
1609 let scrollMode = ScrollMode.VERTICAL,
1610 spreadMode = SpreadMode.NONE;
1611
1612 switch (layout) {
1613 case "SinglePage":
1614 scrollMode = ScrollMode.PAGE;
1615 break;
1616
1617 case "OneColumn":
1618 break;
1619
1620 case "TwoPageLeft":
1621 scrollMode = ScrollMode.PAGE;
1622
1623 case "TwoColumnLeft":
1624 spreadMode = SpreadMode.ODD;
1625 break;
1626
1627 case "TwoPageRight":
1628 scrollMode = ScrollMode.PAGE;
1629
1630 case "TwoColumnRight":
1631 spreadMode = SpreadMode.EVEN;
1632 break;
1633 }
1634
1635 return {
1636 scrollMode,
1637 spreadMode
1638 };
1639}
1640
1641function apiPageModeToSidebarView(mode) {
1642 switch (mode) {
1643 case "UseNone":
1644 return SidebarView.NONE;
1645
1646 case "UseThumbs":
1647 return SidebarView.THUMBS;
1648
1649 case "UseOutlines":
1650 return SidebarView.OUTLINE;
1651
1652 case "UseAttachments":
1653 return SidebarView.ATTACHMENTS;
1654
1655 case "UseOC":
1656 return SidebarView.LAYERS;
1657 }
1658
1659 return SidebarView.NONE;
1660}
1661
1662/***/ }),
1663/* 8 */
1664/***/ ((__unused_webpack_module, exports) => {
1665
1666
1667
1668Object.defineProperty(exports, "__esModule", ({
1669 value: true
1670}));
1671exports.StructTreeLayerBuilder = void 0;
1672const PDF_ROLE_TO_HTML_ROLE = {
1673 Document: null,
1674 DocumentFragment: null,
1675 Part: "group",
1676 Sect: "group",
1677 Div: "group",
1678 Aside: "note",
1679 NonStruct: "none",
1680 P: null,
1681 H: "heading",
1682 Title: null,
1683 FENote: "note",
1684 Sub: "group",
1685 Lbl: null,
1686 Span: null,
1687 Em: null,
1688 Strong: null,
1689 Link: "link",
1690 Annot: "note",
1691 Form: "form",
1692 Ruby: null,
1693 RB: null,
1694 RT: null,
1695 RP: null,
1696 Warichu: null,
1697 WT: null,
1698 WP: null,
1699 L: "list",
1700 LI: "listitem",
1701 LBody: null,
1702 Table: "table",
1703 TR: "row",
1704 TH: "columnheader",
1705 TD: "cell",
1706 THead: "columnheader",
1707 TBody: null,
1708 TFoot: null,
1709 Caption: null,
1710 Figure: "figure",
1711 Formula: null,
1712 Artifact: null
1713};
1714const HEADING_PATTERN = /^H(\d+)$/;
1715
1716class StructTreeLayerBuilder {
1717 constructor({
1718 pdfPage
1719 }) {
1720 this.pdfPage = pdfPage;
1721 }
1722
1723 render(structTree) {
1724 return this._walk(structTree);
1725 }
1726
1727 _setAttributes(structElement, htmlElement) {
1728 if (structElement.alt !== undefined) {
1729 htmlElement.setAttribute("aria-label", structElement.alt);
1730 }
1731
1732 if (structElement.id !== undefined) {
1733 htmlElement.setAttribute("aria-owns", structElement.id);
1734 }
1735
1736 if (structElement.lang !== undefined) {
1737 htmlElement.setAttribute("lang", structElement.lang);
1738 }
1739 }
1740
1741 _walk(node) {
1742 if (!node) {
1743 return null;
1744 }
1745
1746 const element = document.createElement("span");
1747
1748 if ("role" in node) {
1749 const {
1750 role
1751 } = node;
1752 const match = role.match(HEADING_PATTERN);
1753
1754 if (match) {
1755 element.setAttribute("role", "heading");
1756 element.setAttribute("aria-level", match[1]);
1757 } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
1758 element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
1759 }
1760 }
1761
1762 this._setAttributes(node, element);
1763
1764 if (node.children) {
1765 if (node.children.length === 1 && "id" in node.children[0]) {
1766 this._setAttributes(node.children[0], element);
1767 } else {
1768 for (const kid of node.children) {
1769 element.append(this._walk(kid));
1770 }
1771 }
1772 }
1773
1774 return element;
1775 }
1776
1777}
1778
1779exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
1780
1781/***/ }),
1782/* 9 */
1783/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
1784
1785
1786
1787Object.defineProperty(exports, "__esModule", ({
1788 value: true
1789}));
1790exports.TextLayerBuilder = void 0;
1791
1792var _pdfjsLib = __w_pdfjs_require__(3);
1793
1794const EXPAND_DIVS_TIMEOUT = 300;
1795
1796class TextLayerBuilder {
1797 constructor({
1798 textLayerDiv,
1799 eventBus,
1800 pageIndex,
1801 viewport,
1802 highlighter = null,
1803 enhanceTextSelection = false
1804 }) {
1805 this.textLayerDiv = textLayerDiv;
1806 this.eventBus = eventBus;
1807 this.textContent = null;
1808 this.textContentItemsStr = [];
1809 this.textContentStream = null;
1810 this.renderingDone = false;
1811 this.pageNumber = pageIndex + 1;
1812 this.viewport = viewport;
1813 this.textDivs = [];
1814 this.textLayerRenderTask = null;
1815 this.highlighter = highlighter;
1816 this.enhanceTextSelection = enhanceTextSelection;
1817
1818 this._bindMouse();
1819 }
1820
1821 _finishRendering() {
1822 this.renderingDone = true;
1823
1824 if (!this.enhanceTextSelection) {
1825 const endOfContent = document.createElement("div");
1826 endOfContent.className = "endOfContent";
1827 this.textLayerDiv.append(endOfContent);
1828 }
1829
1830 this.eventBus.dispatch("textlayerrendered", {
1831 source: this,
1832 pageNumber: this.pageNumber,
1833 numTextDivs: this.textDivs.length
1834 });
1835 }
1836
1837 render(timeout = 0) {
1838 if (!(this.textContent || this.textContentStream) || this.renderingDone) {
1839 return;
1840 }
1841
1842 this.cancel();
1843 this.textDivs.length = 0;
1844 this.highlighter?.setTextMapping(this.textDivs, this.textContentItemsStr);
1845 const textLayerFrag = document.createDocumentFragment();
1846 this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
1847 textContent: this.textContent,
1848 textContentStream: this.textContentStream,
1849 container: textLayerFrag,
1850 viewport: this.viewport,
1851 textDivs: this.textDivs,
1852 textContentItemsStr: this.textContentItemsStr,
1853 timeout,
1854 enhanceTextSelection: this.enhanceTextSelection
1855 });
1856 this.textLayerRenderTask.promise.then(() => {
1857 this.textLayerDiv.append(textLayerFrag);
1858
1859 this._finishRendering();
1860
1861 this.highlighter?.enable();
1862 }, function (reason) {});
1863 }
1864
1865 cancel() {
1866 if (this.textLayerRenderTask) {
1867 this.textLayerRenderTask.cancel();
1868 this.textLayerRenderTask = null;
1869 }
1870
1871 this.highlighter?.disable();
1872 }
1873
1874 setTextContentStream(readableStream) {
1875 this.cancel();
1876 this.textContentStream = readableStream;
1877 }
1878
1879 setTextContent(textContent) {
1880 this.cancel();
1881 this.textContent = textContent;
1882 }
1883
1884 _bindMouse() {
1885 const div = this.textLayerDiv;
1886 let expandDivsTimer = null;
1887 div.addEventListener("mousedown", evt => {
1888 if (this.enhanceTextSelection && this.textLayerRenderTask) {
1889 this.textLayerRenderTask.expandTextDivs(true);
1890
1891 if (expandDivsTimer) {
1892 clearTimeout(expandDivsTimer);
1893 expandDivsTimer = null;
1894 }
1895
1896 return;
1897 }
1898
1899 const end = div.querySelector(".endOfContent");
1900
1901 if (!end) {
1902 return;
1903 }
1904
1905 let adjustTop = evt.target !== div;
1906 adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
1907
1908 if (adjustTop) {
1909 const divBounds = div.getBoundingClientRect();
1910 const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
1911 end.style.top = (r * 100).toFixed(2) + "%";
1912 }
1913
1914 end.classList.add("active");
1915 });
1916 div.addEventListener("mouseup", () => {
1917 if (this.enhanceTextSelection && this.textLayerRenderTask) {
1918 expandDivsTimer = setTimeout(() => {
1919 if (this.textLayerRenderTask) {
1920 this.textLayerRenderTask.expandTextDivs(false);
1921 }
1922
1923 expandDivsTimer = null;
1924 }, EXPAND_DIVS_TIMEOUT);
1925 return;
1926 }
1927
1928 const end = div.querySelector(".endOfContent");
1929
1930 if (!end) {
1931 return;
1932 }
1933
1934 end.style.top = "";
1935 end.classList.remove("active");
1936 });
1937 }
1938
1939}
1940
1941exports.TextLayerBuilder = TextLayerBuilder;
1942
1943/***/ }),
1944/* 10 */
1945/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
1946
1947
1948
1949Object.defineProperty(exports, "__esModule", ({
1950 value: true
1951}));
1952exports.XfaLayerBuilder = void 0;
1953
1954var _pdfjsLib = __w_pdfjs_require__(3);
1955
1956class XfaLayerBuilder {
1957 constructor({
1958 pageDiv,
1959 pdfPage,
1960 annotationStorage = null,
1961 linkService,
1962 xfaHtml = null
1963 }) {
1964 this.pageDiv = pageDiv;
1965 this.pdfPage = pdfPage;
1966 this.annotationStorage = annotationStorage;
1967 this.linkService = linkService;
1968 this.xfaHtml = xfaHtml;
1969 this.div = null;
1970 this._cancelled = false;
1971 }
1972
1973 render(viewport, intent = "display") {
1974 if (intent === "print") {
1975 const parameters = {
1976 viewport: viewport.clone({
1977 dontFlip: true
1978 }),
1979 div: this.div,
1980 xfaHtml: this.xfaHtml,
1981 annotationStorage: this.annotationStorage,
1982 linkService: this.linkService,
1983 intent
1984 };
1985 const div = document.createElement("div");
1986 this.pageDiv.append(div);
1987 parameters.div = div;
1988
1989 const result = _pdfjsLib.XfaLayer.render(parameters);
1990
1991 return Promise.resolve(result);
1992 }
1993
1994 return this.pdfPage.getXfa().then(xfaHtml => {
1995 if (this._cancelled || !xfaHtml) {
1996 return {
1997 textDivs: []
1998 };
1999 }
2000
2001 const parameters = {
2002 viewport: viewport.clone({
2003 dontFlip: true
2004 }),
2005 div: this.div,
2006 xfaHtml,
2007 annotationStorage: this.annotationStorage,
2008 linkService: this.linkService,
2009 intent
2010 };
2011
2012 if (this.div) {
2013 return _pdfjsLib.XfaLayer.update(parameters);
2014 }
2015
2016 this.div = document.createElement("div");
2017 this.pageDiv.append(this.div);
2018 parameters.div = this.div;
2019 return _pdfjsLib.XfaLayer.render(parameters);
2020 }).catch(error => {
2021 console.error(error);
2022 });
2023 }
2024
2025 cancel() {
2026 this._cancelled = true;
2027 }
2028
2029 hide() {
2030 if (!this.div) {
2031 return;
2032 }
2033
2034 this.div.hidden = true;
2035 }
2036
2037}
2038
2039exports.XfaLayerBuilder = XfaLayerBuilder;
2040
2041/***/ }),
2042/* 11 */
2043/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
2044
2045
2046
2047Object.defineProperty(exports, "__esModule", ({
2048 value: true
2049}));
2050exports.PDFViewer = exports.PDFSinglePageViewer = void 0;
2051
2052var _ui_utils = __w_pdfjs_require__(7);
2053
2054var _base_viewer = __w_pdfjs_require__(12);
2055
2056class PDFViewer extends _base_viewer.BaseViewer {}
2057
2058exports.PDFViewer = PDFViewer;
2059
2060class PDFSinglePageViewer extends _base_viewer.BaseViewer {
2061 _resetView() {
2062 super._resetView();
2063
2064 this._scrollMode = _ui_utils.ScrollMode.PAGE;
2065 this._spreadMode = _ui_utils.SpreadMode.NONE;
2066 }
2067
2068 set scrollMode(mode) {}
2069
2070 _updateScrollMode() {}
2071
2072 set spreadMode(mode) {}
2073
2074 _updateSpreadMode() {}
2075
2076}
2077
2078exports.PDFSinglePageViewer = PDFSinglePageViewer;
2079
2080/***/ }),
2081/* 12 */
2082/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
2083
2084
2085
2086Object.defineProperty(exports, "__esModule", ({
2087 value: true
2088}));
2089exports.PagesCountLimit = exports.PDFPageViewBuffer = exports.BaseViewer = void 0;
2090
2091var _pdfjsLib = __w_pdfjs_require__(3);
2092
2093var _ui_utils = __w_pdfjs_require__(7);
2094
2095var _annotation_editor_layer_builder = __w_pdfjs_require__(2);
2096
2097var _annotation_layer_builder = __w_pdfjs_require__(5);
2098
2099var _app_options = __w_pdfjs_require__(13);
2100
2101var _l10n_utils = __w_pdfjs_require__(4);
2102
2103var _pdf_page_view = __w_pdfjs_require__(14);
2104
2105var _pdf_rendering_queue = __w_pdfjs_require__(15);
2106
2107var _pdf_link_service = __w_pdfjs_require__(6);
2108
2109var _struct_tree_layer_builder = __w_pdfjs_require__(8);
2110
2111var _text_highlighter = __w_pdfjs_require__(16);
2112
2113var _text_layer_builder = __w_pdfjs_require__(9);
2114
2115var _xfa_layer_builder = __w_pdfjs_require__(10);
2116
2117const DEFAULT_CACHE_SIZE = 10;
2118const ENABLE_PERMISSIONS_CLASS = "enablePermissions";
2119const PagesCountLimit = {
2120 FORCE_SCROLL_MODE_PAGE: 15000,
2121 FORCE_LAZY_PAGE_INIT: 7500,
2122 PAUSE_EAGER_PAGE_INIT: 250
2123};
2124exports.PagesCountLimit = PagesCountLimit;
2125const ANNOTATION_EDITOR_MODE = _app_options.compatibilityParams.annotationEditorMode ?? _pdfjsLib.AnnotationEditorType.DISABLE;
2126
2127function isValidAnnotationEditorMode(mode) {
2128 return Object.values(_pdfjsLib.AnnotationEditorType).includes(mode) && mode !== _pdfjsLib.AnnotationEditorType.DISABLE;
2129}
2130
2131class PDFPageViewBuffer {
2132 #buf = new Set();
2133 #size = 0;
2134
2135 constructor(size) {
2136 this.#size = size;
2137 }
2138
2139 push(view) {
2140 const buf = this.#buf;
2141
2142 if (buf.has(view)) {
2143 buf.delete(view);
2144 }
2145
2146 buf.add(view);
2147
2148 if (buf.size > this.#size) {
2149 this.#destroyFirstView();
2150 }
2151 }
2152
2153 resize(newSize, idsToKeep = null) {
2154 this.#size = newSize;
2155 const buf = this.#buf;
2156
2157 if (idsToKeep) {
2158 const ii = buf.size;
2159 let i = 1;
2160
2161 for (const view of buf) {
2162 if (idsToKeep.has(view.id)) {
2163 buf.delete(view);
2164 buf.add(view);
2165 }
2166
2167 if (++i > ii) {
2168 break;
2169 }
2170 }
2171 }
2172
2173 while (buf.size > this.#size) {
2174 this.#destroyFirstView();
2175 }
2176 }
2177
2178 has(view) {
2179 return this.#buf.has(view);
2180 }
2181
2182 [Symbol.iterator]() {
2183 return this.#buf.keys();
2184 }
2185
2186 #destroyFirstView() {
2187 const firstView = this.#buf.keys().next().value;
2188 firstView?.destroy();
2189 this.#buf.delete(firstView);
2190 }
2191
2192}
2193
2194exports.PDFPageViewBuffer = PDFPageViewBuffer;
2195
2196class BaseViewer {
2197 #buffer = null;
2198 #annotationEditorMode = _pdfjsLib.AnnotationEditorType.DISABLE;
2199 #annotationEditorUIManager = null;
2200 #annotationMode = _pdfjsLib.AnnotationMode.ENABLE_FORMS;
2201 #enablePermissions = false;
2202 #previousContainerHeight = 0;
2203 #scrollModePageState = null;
2204 #onVisibilityChange = null;
2205
2206 constructor(options) {
2207 if (this.constructor === BaseViewer) {
2208 throw new Error("Cannot initialize BaseViewer.");
2209 }
2210
2211 const viewerVersion = '2.15.349';
2212
2213 if (_pdfjsLib.version !== viewerVersion) {
2214 throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
2215 }
2216
2217 this.container = options.container;
2218 this.viewer = options.viewer || options.container.firstElementChild;
2219
2220 if (!(this.container?.tagName.toUpperCase() === "DIV" && this.viewer?.tagName.toUpperCase() === "DIV")) {
2221 throw new Error("Invalid `container` and/or `viewer` option.");
2222 }
2223
2224 if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
2225 throw new Error("The `container` must be absolutely positioned.");
2226 }
2227
2228 this.eventBus = options.eventBus;
2229 this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
2230 this.downloadManager = options.downloadManager || null;
2231 this.findController = options.findController || null;
2232 this._scriptingManager = options.scriptingManager || null;
2233 this.removePageBorders = options.removePageBorders || false;
2234 this.textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
2235 this.#annotationMode = options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS;
2236 this.#annotationEditorMode = options.annotationEditorMode ?? ANNOTATION_EDITOR_MODE;
2237 this.imageResourcesPath = options.imageResourcesPath || "";
2238 this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
2239 this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
2240 this.useOnlyCssZoom = options.useOnlyCssZoom || false;
2241 this.maxCanvasPixels = options.maxCanvasPixels;
2242 this.l10n = options.l10n || _l10n_utils.NullL10n;
2243 this.#enablePermissions = options.enablePermissions || false;
2244 this.pageColors = options.pageColors || null;
2245
2246 if (this.pageColors && !(CSS.supports("color", this.pageColors.background) && CSS.supports("color", this.pageColors.foreground))) {
2247 if (this.pageColors.background || this.pageColors.foreground) {
2248 console.warn("BaseViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used.");
2249 }
2250
2251 this.pageColors = null;
2252 }
2253
2254 this.defaultRenderingQueue = !options.renderingQueue;
2255
2256 if (this.defaultRenderingQueue) {
2257 this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
2258 this.renderingQueue.setViewer(this);
2259 } else {
2260 this.renderingQueue = options.renderingQueue;
2261 }
2262
2263 this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
2264 this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
2265 this._onBeforeDraw = this._onAfterDraw = null;
2266
2267 this._resetView();
2268
2269 if (this.removePageBorders) {
2270 this.viewer.classList.add("removePageBorders");
2271 }
2272
2273 this.updateContainerHeightCss();
2274 }
2275
2276 get pagesCount() {
2277 return this._pages.length;
2278 }
2279
2280 getPageView(index) {
2281 return this._pages[index];
2282 }
2283
2284 get pageViewsReady() {
2285 if (!this._pagesCapability.settled) {
2286 return false;
2287 }
2288
2289 return this._pages.every(function (pageView) {
2290 return pageView?.pdfPage;
2291 });
2292 }
2293
2294 get renderForms() {
2295 return this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS;
2296 }
2297
2298 get enableScripting() {
2299 return !!this._scriptingManager;
2300 }
2301
2302 get currentPageNumber() {
2303 return this._currentPageNumber;
2304 }
2305
2306 set currentPageNumber(val) {
2307 if (!Number.isInteger(val)) {
2308 throw new Error("Invalid page number.");
2309 }
2310
2311 if (!this.pdfDocument) {
2312 return;
2313 }
2314
2315 if (!this._setCurrentPageNumber(val, true)) {
2316 console.error(`currentPageNumber: "${val}" is not a valid page.`);
2317 }
2318 }
2319
2320 _setCurrentPageNumber(val, resetCurrentPageView = false) {
2321 if (this._currentPageNumber === val) {
2322 if (resetCurrentPageView) {
2323 this.#resetCurrentPageView();
2324 }
2325
2326 return true;
2327 }
2328
2329 if (!(0 < val && val <= this.pagesCount)) {
2330 return false;
2331 }
2332
2333 const previous = this._currentPageNumber;
2334 this._currentPageNumber = val;
2335 this.eventBus.dispatch("pagechanging", {
2336 source: this,
2337 pageNumber: val,
2338 pageLabel: this._pageLabels?.[val - 1] ?? null,
2339 previous
2340 });
2341
2342 if (resetCurrentPageView) {
2343 this.#resetCurrentPageView();
2344 }
2345
2346 return true;
2347 }
2348
2349 get currentPageLabel() {
2350 return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
2351 }
2352
2353 set currentPageLabel(val) {
2354 if (!this.pdfDocument) {
2355 return;
2356 }
2357
2358 let page = val | 0;
2359
2360 if (this._pageLabels) {
2361 const i = this._pageLabels.indexOf(val);
2362
2363 if (i >= 0) {
2364 page = i + 1;
2365 }
2366 }
2367
2368 if (!this._setCurrentPageNumber(page, true)) {
2369 console.error(`currentPageLabel: "${val}" is not a valid page.`);
2370 }
2371 }
2372
2373 get currentScale() {
2374 return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
2375 }
2376
2377 set currentScale(val) {
2378 if (isNaN(val)) {
2379 throw new Error("Invalid numeric scale.");
2380 }
2381
2382 if (!this.pdfDocument) {
2383 return;
2384 }
2385
2386 this._setScale(val, false);
2387 }
2388
2389 get currentScaleValue() {
2390 return this._currentScaleValue;
2391 }
2392
2393 set currentScaleValue(val) {
2394 if (!this.pdfDocument) {
2395 return;
2396 }
2397
2398 this._setScale(val, false);
2399 }
2400
2401 get pagesRotation() {
2402 return this._pagesRotation;
2403 }
2404
2405 set pagesRotation(rotation) {
2406 if (!(0, _ui_utils.isValidRotation)(rotation)) {
2407 throw new Error("Invalid pages rotation angle.");
2408 }
2409
2410 if (!this.pdfDocument) {
2411 return;
2412 }
2413
2414 rotation %= 360;
2415
2416 if (rotation < 0) {
2417 rotation += 360;
2418 }
2419
2420 if (this._pagesRotation === rotation) {
2421 return;
2422 }
2423
2424 this._pagesRotation = rotation;
2425 const pageNumber = this._currentPageNumber;
2426 const updateArgs = {
2427 rotation
2428 };
2429
2430 for (const pageView of this._pages) {
2431 pageView.update(updateArgs);
2432 }
2433
2434 if (this._currentScaleValue) {
2435 this._setScale(this._currentScaleValue, true);
2436 }
2437
2438 this.eventBus.dispatch("rotationchanging", {
2439 source: this,
2440 pagesRotation: rotation,
2441 pageNumber
2442 });
2443
2444 if (this.defaultRenderingQueue) {
2445 this.update();
2446 }
2447 }
2448
2449 get firstPagePromise() {
2450 return this.pdfDocument ? this._firstPageCapability.promise : null;
2451 }
2452
2453 get onePageRendered() {
2454 return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
2455 }
2456
2457 get pagesPromise() {
2458 return this.pdfDocument ? this._pagesCapability.promise : null;
2459 }
2460
2461 #initializePermissions(permissions) {
2462 const params = {
2463 annotationEditorMode: this.#annotationEditorMode,
2464 annotationMode: this.#annotationMode,
2465 textLayerMode: this.textLayerMode
2466 };
2467
2468 if (!permissions) {
2469 return params;
2470 }
2471
2472 if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
2473 this.viewer.classList.add(ENABLE_PERMISSIONS_CLASS);
2474 }
2475
2476 if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_CONTENTS)) {
2477 params.annotationEditorMode = _pdfjsLib.AnnotationEditorType.DISABLE;
2478 }
2479
2480 if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS) {
2481 params.annotationMode = _pdfjsLib.AnnotationMode.ENABLE;
2482 }
2483
2484 return params;
2485 }
2486
2487 #onePageRenderedOrForceFetch() {
2488 if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
2489 return Promise.resolve();
2490 }
2491
2492 const visibilityChangePromise = new Promise(resolve => {
2493 this.#onVisibilityChange = () => {
2494 if (document.visibilityState !== "hidden") {
2495 return;
2496 }
2497
2498 resolve();
2499 document.removeEventListener("visibilitychange", this.#onVisibilityChange);
2500 this.#onVisibilityChange = null;
2501 };
2502
2503 document.addEventListener("visibilitychange", this.#onVisibilityChange);
2504 });
2505 return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
2506 }
2507
2508 setDocument(pdfDocument) {
2509 if (this.pdfDocument) {
2510 this.eventBus.dispatch("pagesdestroy", {
2511 source: this
2512 });
2513
2514 this._cancelRendering();
2515
2516 this._resetView();
2517
2518 if (this.findController) {
2519 this.findController.setDocument(null);
2520 }
2521
2522 if (this._scriptingManager) {
2523 this._scriptingManager.setDocument(null);
2524 }
2525
2526 if (this.#annotationEditorUIManager) {
2527 this.#annotationEditorUIManager.destroy();
2528 this.#annotationEditorUIManager = null;
2529 }
2530 }
2531
2532 this.pdfDocument = pdfDocument;
2533
2534 if (!pdfDocument) {
2535 return;
2536 }
2537
2538 const isPureXfa = pdfDocument.isPureXfa;
2539 const pagesCount = pdfDocument.numPages;
2540 const firstPagePromise = pdfDocument.getPage(1);
2541 const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
2542 const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
2543
2544 if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
2545 console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
2546 const mode = this._scrollMode = _ui_utils.ScrollMode.PAGE;
2547 this.eventBus.dispatch("scrollmodechanged", {
2548 source: this,
2549 mode
2550 });
2551 }
2552
2553 this._pagesCapability.promise.then(() => {
2554 this.eventBus.dispatch("pagesloaded", {
2555 source: this,
2556 pagesCount
2557 });
2558 }, () => {});
2559
2560 this._onBeforeDraw = evt => {
2561 const pageView = this._pages[evt.pageNumber - 1];
2562
2563 if (!pageView) {
2564 return;
2565 }
2566
2567 this.#buffer.push(pageView);
2568 };
2569
2570 this.eventBus._on("pagerender", this._onBeforeDraw);
2571
2572 this._onAfterDraw = evt => {
2573 if (evt.cssTransform || this._onePageRenderedCapability.settled) {
2574 return;
2575 }
2576
2577 this._onePageRenderedCapability.resolve({
2578 timestamp: evt.timestamp
2579 });
2580
2581 this.eventBus._off("pagerendered", this._onAfterDraw);
2582
2583 this._onAfterDraw = null;
2584
2585 if (this.#onVisibilityChange) {
2586 document.removeEventListener("visibilitychange", this.#onVisibilityChange);
2587 this.#onVisibilityChange = null;
2588 }
2589 };
2590
2591 this.eventBus._on("pagerendered", this._onAfterDraw);
2592
2593 Promise.all([firstPagePromise, permissionsPromise]).then(([firstPdfPage, permissions]) => {
2594 if (pdfDocument !== this.pdfDocument) {
2595 return;
2596 }
2597
2598 this._firstPageCapability.resolve(firstPdfPage);
2599
2600 this._optionalContentConfigPromise = optionalContentConfigPromise;
2601 const {
2602 annotationEditorMode,
2603 annotationMode,
2604 textLayerMode
2605 } = this.#initializePermissions(permissions);
2606
2607 if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
2608 const mode = annotationEditorMode;
2609
2610 if (isPureXfa) {
2611 console.warn("Warning: XFA-editing is not implemented.");
2612 } else if (isValidAnnotationEditorMode(mode)) {
2613 this.eventBus.dispatch("annotationeditormodechanged", {
2614 source: this,
2615 mode
2616 });
2617 this.#annotationEditorUIManager = new _pdfjsLib.AnnotationEditorUIManager(this.container, this.eventBus);
2618
2619 if (mode !== _pdfjsLib.AnnotationEditorType.NONE) {
2620 this.#annotationEditorUIManager.updateMode(mode);
2621 }
2622 } else {
2623 console.error(`Invalid AnnotationEditor mode: ${mode}`);
2624 }
2625 }
2626
2627 const viewerElement = this._scrollMode === _ui_utils.ScrollMode.PAGE ? null : this.viewer;
2628 const scale = this.currentScale;
2629 const viewport = firstPdfPage.getViewport({
2630 scale: scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
2631 });
2632 const textLayerFactory = textLayerMode !== _ui_utils.TextLayerMode.DISABLE && !isPureXfa ? this : null;
2633 const annotationLayerFactory = annotationMode !== _pdfjsLib.AnnotationMode.DISABLE ? this : null;
2634 const xfaLayerFactory = isPureXfa ? this : null;
2635 const annotationEditorLayerFactory = this.#annotationEditorUIManager ? this : null;
2636
2637 for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
2638 const pageView = new _pdf_page_view.PDFPageView({
2639 container: viewerElement,
2640 eventBus: this.eventBus,
2641 id: pageNum,
2642 scale,
2643 defaultViewport: viewport.clone(),
2644 optionalContentConfigPromise,
2645 renderingQueue: this.renderingQueue,
2646 textLayerFactory,
2647 textLayerMode,
2648 annotationLayerFactory,
2649 annotationMode,
2650 xfaLayerFactory,
2651 annotationEditorLayerFactory,
2652 textHighlighterFactory: this,
2653 structTreeLayerFactory: this,
2654 imageResourcesPath: this.imageResourcesPath,
2655 renderer: this.renderer,
2656 useOnlyCssZoom: this.useOnlyCssZoom,
2657 maxCanvasPixels: this.maxCanvasPixels,
2658 pageColors: this.pageColors,
2659 l10n: this.l10n
2660 });
2661
2662 this._pages.push(pageView);
2663 }
2664
2665 const firstPageView = this._pages[0];
2666
2667 if (firstPageView) {
2668 firstPageView.setPdfPage(firstPdfPage);
2669 this.linkService.cachePageRef(1, firstPdfPage.ref);
2670 }
2671
2672 if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
2673 this.#ensurePageViewVisible();
2674 } else if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
2675 this._updateSpreadMode();
2676 }
2677
2678 this.#onePageRenderedOrForceFetch().then(async () => {
2679 if (this.findController) {
2680 this.findController.setDocument(pdfDocument);
2681 }
2682
2683 if (this._scriptingManager) {
2684 this._scriptingManager.setDocument(pdfDocument);
2685 }
2686
2687 if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
2688 this._pagesCapability.resolve();
2689
2690 return;
2691 }
2692
2693 let getPagesLeft = pagesCount - 1;
2694
2695 if (getPagesLeft <= 0) {
2696 this._pagesCapability.resolve();
2697
2698 return;
2699 }
2700
2701 for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
2702 const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
2703 const pageView = this._pages[pageNum - 1];
2704
2705 if (!pageView.pdfPage) {
2706 pageView.setPdfPage(pdfPage);
2707 }
2708
2709 this.linkService.cachePageRef(pageNum, pdfPage.ref);
2710
2711 if (--getPagesLeft === 0) {
2712 this._pagesCapability.resolve();
2713 }
2714 }, reason => {
2715 console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
2716
2717 if (--getPagesLeft === 0) {
2718 this._pagesCapability.resolve();
2719 }
2720 });
2721
2722 if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
2723 await promise;
2724 }
2725 }
2726 });
2727 this.eventBus.dispatch("pagesinit", {
2728 source: this
2729 });
2730 pdfDocument.getMetadata().then(({
2731 info
2732 }) => {
2733 if (pdfDocument !== this.pdfDocument) {
2734 return;
2735 }
2736
2737 if (info.Language) {
2738 this.viewer.lang = info.Language;
2739 }
2740 });
2741
2742 if (this.defaultRenderingQueue) {
2743 this.update();
2744 }
2745 }).catch(reason => {
2746 console.error("Unable to initialize viewer", reason);
2747
2748 this._pagesCapability.reject(reason);
2749 });
2750 }
2751
2752 setPageLabels(labels) {
2753 if (!this.pdfDocument) {
2754 return;
2755 }
2756
2757 if (!labels) {
2758 this._pageLabels = null;
2759 } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
2760 this._pageLabels = null;
2761 console.error(`setPageLabels: Invalid page labels.`);
2762 } else {
2763 this._pageLabels = labels;
2764 }
2765
2766 for (let i = 0, ii = this._pages.length; i < ii; i++) {
2767 this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
2768 }
2769 }
2770
2771 _resetView() {
2772 this._pages = [];
2773 this._currentPageNumber = 1;
2774 this._currentScale = _ui_utils.UNKNOWN_SCALE;
2775 this._currentScaleValue = null;
2776 this._pageLabels = null;
2777 this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
2778 this._location = null;
2779 this._pagesRotation = 0;
2780 this._optionalContentConfigPromise = null;
2781 this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
2782 this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
2783 this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
2784 this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
2785 this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN;
2786 this._spreadMode = _ui_utils.SpreadMode.NONE;
2787 this.#scrollModePageState = {
2788 previousPageNumber: 1,
2789 scrollDown: true,
2790 pages: []
2791 };
2792
2793 if (this._onBeforeDraw) {
2794 this.eventBus._off("pagerender", this._onBeforeDraw);
2795
2796 this._onBeforeDraw = null;
2797 }
2798
2799 if (this._onAfterDraw) {
2800 this.eventBus._off("pagerendered", this._onAfterDraw);
2801
2802 this._onAfterDraw = null;
2803 }
2804
2805 if (this.#onVisibilityChange) {
2806 document.removeEventListener("visibilitychange", this.#onVisibilityChange);
2807 this.#onVisibilityChange = null;
2808 }
2809
2810 this.viewer.textContent = "";
2811
2812 this._updateScrollMode();
2813
2814 this.viewer.removeAttribute("lang");
2815 this.viewer.classList.remove(ENABLE_PERMISSIONS_CLASS);
2816 }
2817
2818 #ensurePageViewVisible() {
2819 if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) {
2820 throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
2821 }
2822
2823 const pageNumber = this._currentPageNumber,
2824 state = this.#scrollModePageState,
2825 viewer = this.viewer;
2826 viewer.textContent = "";
2827 state.pages.length = 0;
2828
2829 if (this._spreadMode === _ui_utils.SpreadMode.NONE && !this.isInPresentationMode) {
2830 const pageView = this._pages[pageNumber - 1];
2831 viewer.append(pageView.div);
2832 state.pages.push(pageView);
2833 } else {
2834 const pageIndexSet = new Set(),
2835 parity = this._spreadMode - 1;
2836
2837 if (parity === -1) {
2838 pageIndexSet.add(pageNumber - 1);
2839 } else if (pageNumber % 2 !== parity) {
2840 pageIndexSet.add(pageNumber - 1);
2841 pageIndexSet.add(pageNumber);
2842 } else {
2843 pageIndexSet.add(pageNumber - 2);
2844 pageIndexSet.add(pageNumber - 1);
2845 }
2846
2847 const spread = document.createElement("div");
2848 spread.className = "spread";
2849
2850 if (this.isInPresentationMode) {
2851 const dummyPage = document.createElement("div");
2852 dummyPage.className = "dummyPage";
2853 spread.append(dummyPage);
2854 }
2855
2856 for (const i of pageIndexSet) {
2857 const pageView = this._pages[i];
2858
2859 if (!pageView) {
2860 continue;
2861 }
2862
2863 spread.append(pageView.div);
2864 state.pages.push(pageView);
2865 }
2866
2867 viewer.append(spread);
2868 }
2869
2870 state.scrollDown = pageNumber >= state.previousPageNumber;
2871 state.previousPageNumber = pageNumber;
2872 }
2873
2874 _scrollUpdate() {
2875 if (this.pagesCount === 0) {
2876 return;
2877 }
2878
2879 this.update();
2880 }
2881
2882 #scrollIntoView(pageView, pageSpot = null) {
2883 const {
2884 div,
2885 id
2886 } = pageView;
2887
2888 if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
2889 this._setCurrentPageNumber(id);
2890
2891 this.#ensurePageViewVisible();
2892 this.update();
2893 }
2894
2895 if (!pageSpot && !this.isInPresentationMode) {
2896 const left = div.offsetLeft + div.clientLeft,
2897 right = left + div.clientWidth;
2898 const {
2899 scrollLeft,
2900 clientWidth
2901 } = this.container;
2902
2903 if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
2904 pageSpot = {
2905 left: 0,
2906 top: 0
2907 };
2908 }
2909 }
2910
2911 (0, _ui_utils.scrollIntoView)(div, pageSpot);
2912 }
2913
2914 #isSameScale(newScale) {
2915 return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
2916 }
2917
2918 _setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) {
2919 this._currentScaleValue = newValue.toString();
2920
2921 if (this.#isSameScale(newScale)) {
2922 if (preset) {
2923 this.eventBus.dispatch("scalechanging", {
2924 source: this,
2925 scale: newScale,
2926 presetValue: newValue
2927 });
2928 }
2929
2930 return;
2931 }
2932
2933 _ui_utils.docStyle.setProperty("--scale-factor", newScale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
2934
2935 const updateArgs = {
2936 scale: newScale
2937 };
2938
2939 for (const pageView of this._pages) {
2940 pageView.update(updateArgs);
2941 }
2942
2943 this._currentScale = newScale;
2944
2945 if (!noScroll) {
2946 let page = this._currentPageNumber,
2947 dest;
2948
2949 if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
2950 page = this._location.pageNumber;
2951 dest = [null, {
2952 name: "XYZ"
2953 }, this._location.left, this._location.top, null];
2954 }
2955
2956 this.scrollPageIntoView({
2957 pageNumber: page,
2958 destArray: dest,
2959 allowNegativeOffset: true
2960 });
2961 }
2962
2963 this.eventBus.dispatch("scalechanging", {
2964 source: this,
2965 scale: newScale,
2966 presetValue: preset ? newValue : undefined
2967 });
2968
2969 if (this.defaultRenderingQueue) {
2970 this.update();
2971 }
2972
2973 this.updateContainerHeightCss();
2974 }
2975
2976 get _pageWidthScaleFactor() {
2977 if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL) {
2978 return 2;
2979 }
2980
2981 return 1;
2982 }
2983
2984 _setScale(value, noScroll = false) {
2985 let scale = parseFloat(value);
2986
2987 if (scale > 0) {
2988 this._setScaleUpdatePages(scale, value, noScroll, false);
2989 } else {
2990 const currentPage = this._pages[this._currentPageNumber - 1];
2991
2992 if (!currentPage) {
2993 return;
2994 }
2995
2996 let hPadding = _ui_utils.SCROLLBAR_PADDING,
2997 vPadding = _ui_utils.VERTICAL_PADDING;
2998
2999 if (this.isInPresentationMode) {
3000 hPadding = vPadding = 4;
3001 } else if (this.removePageBorders) {
3002 hPadding = vPadding = 0;
3003 } else if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL) {
3004 [hPadding, vPadding] = [vPadding, hPadding];
3005 }
3006
3007 const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
3008 const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
3009
3010 switch (value) {
3011 case "page-actual":
3012 scale = 1;
3013 break;
3014
3015 case "page-width":
3016 scale = pageWidthScale;
3017 break;
3018
3019 case "page-height":
3020 scale = pageHeightScale;
3021 break;
3022
3023 case "page-fit":
3024 scale = Math.min(pageWidthScale, pageHeightScale);
3025 break;
3026
3027 case "auto":
3028 const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
3029 scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
3030 break;
3031
3032 default:
3033 console.error(`_setScale: "${value}" is an unknown zoom value.`);
3034 return;
3035 }
3036
3037 this._setScaleUpdatePages(scale, value, noScroll, true);
3038 }
3039 }
3040
3041 #resetCurrentPageView() {
3042 const pageView = this._pages[this._currentPageNumber - 1];
3043
3044 if (this.isInPresentationMode) {
3045 this._setScale(this._currentScaleValue, true);
3046 }
3047
3048 this.#scrollIntoView(pageView);
3049 }
3050
3051 pageLabelToPageNumber(label) {
3052 if (!this._pageLabels) {
3053 return null;
3054 }
3055
3056 const i = this._pageLabels.indexOf(label);
3057
3058 if (i < 0) {
3059 return null;
3060 }
3061
3062 return i + 1;
3063 }
3064
3065 scrollPageIntoView({
3066 pageNumber,
3067 destArray = null,
3068 allowNegativeOffset = false,
3069 ignoreDestinationZoom = false
3070 }) {
3071 if (!this.pdfDocument) {
3072 return;
3073 }
3074
3075 const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
3076
3077 if (!pageView) {
3078 console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
3079 return;
3080 }
3081
3082 if (this.isInPresentationMode || !destArray) {
3083 this._setCurrentPageNumber(pageNumber, true);
3084
3085 return;
3086 }
3087
3088 let x = 0,
3089 y = 0;
3090 let width = 0,
3091 height = 0,
3092 widthScale,
3093 heightScale;
3094 const changeOrientation = pageView.rotation % 180 !== 0;
3095 const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
3096 const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
3097 let scale = 0;
3098
3099 switch (destArray[1].name) {
3100 case "XYZ":
3101 x = destArray[2];
3102 y = destArray[3];
3103 scale = destArray[4];
3104 x = x !== null ? x : 0;
3105 y = y !== null ? y : pageHeight;
3106 break;
3107
3108 case "Fit":
3109 case "FitB":
3110 scale = "page-fit";
3111 break;
3112
3113 case "FitH":
3114 case "FitBH":
3115 y = destArray[2];
3116 scale = "page-width";
3117
3118 if (y === null && this._location) {
3119 x = this._location.left;
3120 y = this._location.top;
3121 } else if (typeof y !== "number" || y < 0) {
3122 y = pageHeight;
3123 }
3124
3125 break;
3126
3127 case "FitV":
3128 case "FitBV":
3129 x = destArray[2];
3130 width = pageWidth;
3131 height = pageHeight;
3132 scale = "page-height";
3133 break;
3134
3135 case "FitR":
3136 x = destArray[2];
3137 y = destArray[3];
3138 width = destArray[4] - x;
3139 height = destArray[5] - y;
3140 const hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
3141 const vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
3142 widthScale = (this.container.clientWidth - hPadding) / width / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
3143 heightScale = (this.container.clientHeight - vPadding) / height / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
3144 scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
3145 break;
3146
3147 default:
3148 console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
3149 return;
3150 }
3151
3152 if (!ignoreDestinationZoom) {
3153 if (scale && scale !== this._currentScale) {
3154 this.currentScaleValue = scale;
3155 } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
3156 this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
3157 }
3158 }
3159
3160 if (scale === "page-fit" && !destArray[4]) {
3161 this.#scrollIntoView(pageView);
3162 return;
3163 }
3164
3165 const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
3166 let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
3167 let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
3168
3169 if (!allowNegativeOffset) {
3170 left = Math.max(left, 0);
3171 top = Math.max(top, 0);
3172 }
3173
3174 this.#scrollIntoView(pageView, {
3175 left,
3176 top
3177 });
3178 }
3179
3180 _updateLocation(firstPage) {
3181 const currentScale = this._currentScale;
3182 const currentScaleValue = this._currentScaleValue;
3183 const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
3184 const pageNumber = firstPage.id;
3185 const currentPageView = this._pages[pageNumber - 1];
3186 const container = this.container;
3187 const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
3188 const intLeft = Math.round(topLeft[0]);
3189 const intTop = Math.round(topLeft[1]);
3190 let pdfOpenParams = `#page=${pageNumber}`;
3191
3192 if (!this.isInPresentationMode) {
3193 pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
3194 }
3195
3196 this._location = {
3197 pageNumber,
3198 scale: normalizedScaleValue,
3199 top: intTop,
3200 left: intLeft,
3201 rotation: this._pagesRotation,
3202 pdfOpenParams
3203 };
3204 }
3205
3206 update() {
3207 const visible = this._getVisiblePages();
3208
3209 const visiblePages = visible.views,
3210 numVisiblePages = visiblePages.length;
3211
3212 if (numVisiblePages === 0) {
3213 return;
3214 }
3215
3216 const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
3217 this.#buffer.resize(newCacheSize, visible.ids);
3218 this.renderingQueue.renderHighestPriority(visible);
3219 const isSimpleLayout = this._spreadMode === _ui_utils.SpreadMode.NONE && (this._scrollMode === _ui_utils.ScrollMode.PAGE || this._scrollMode === _ui_utils.ScrollMode.VERTICAL);
3220 const currentId = this._currentPageNumber;
3221 let stillFullyVisible = false;
3222
3223 for (const page of visiblePages) {
3224 if (page.percent < 100) {
3225 break;
3226 }
3227
3228 if (page.id === currentId && isSimpleLayout) {
3229 stillFullyVisible = true;
3230 break;
3231 }
3232 }
3233
3234 this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
3235
3236 this._updateLocation(visible.first);
3237
3238 this.eventBus.dispatch("updateviewarea", {
3239 source: this,
3240 location: this._location
3241 });
3242 }
3243
3244 containsElement(element) {
3245 return this.container.contains(element);
3246 }
3247
3248 focus() {
3249 this.container.focus();
3250 }
3251
3252 get _isContainerRtl() {
3253 return getComputedStyle(this.container).direction === "rtl";
3254 }
3255
3256 get isInPresentationMode() {
3257 return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
3258 }
3259
3260 get isChangingPresentationMode() {
3261 return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
3262 }
3263
3264 get isHorizontalScrollbarEnabled() {
3265 return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
3266 }
3267
3268 get isVerticalScrollbarEnabled() {
3269 return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
3270 }
3271
3272 _getVisiblePages() {
3273 const views = this._scrollMode === _ui_utils.ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages,
3274 horizontal = this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL,
3275 rtl = horizontal && this._isContainerRtl;
3276 return (0, _ui_utils.getVisibleElements)({
3277 scrollEl: this.container,
3278 views,
3279 sortByVisibility: true,
3280 horizontal,
3281 rtl
3282 });
3283 }
3284
3285 isPageVisible(pageNumber) {
3286 if (!this.pdfDocument) {
3287 return false;
3288 }
3289
3290 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
3291 console.error(`isPageVisible: "${pageNumber}" is not a valid page.`);
3292 return false;
3293 }
3294
3295 return this._getVisiblePages().ids.has(pageNumber);
3296 }
3297
3298 isPageCached(pageNumber) {
3299 if (!this.pdfDocument) {
3300 return false;
3301 }
3302
3303 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
3304 console.error(`isPageCached: "${pageNumber}" is not a valid page.`);
3305 return false;
3306 }
3307
3308 const pageView = this._pages[pageNumber - 1];
3309 return this.#buffer.has(pageView);
3310 }
3311
3312 cleanup() {
3313 for (const pageView of this._pages) {
3314 if (pageView.renderingState !== _ui_utils.RenderingStates.FINISHED) {
3315 pageView.reset();
3316 }
3317 }
3318 }
3319
3320 _cancelRendering() {
3321 for (const pageView of this._pages) {
3322 pageView.cancelRendering();
3323 }
3324 }
3325
3326 async #ensurePdfPageLoaded(pageView) {
3327 if (pageView.pdfPage) {
3328 return pageView.pdfPage;
3329 }
3330
3331 try {
3332 const pdfPage = await this.pdfDocument.getPage(pageView.id);
3333
3334 if (!pageView.pdfPage) {
3335 pageView.setPdfPage(pdfPage);
3336 }
3337
3338 if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
3339 this.linkService.cachePageRef(pageView.id, pdfPage.ref);
3340 }
3341
3342 return pdfPage;
3343 } catch (reason) {
3344 console.error("Unable to get page for page view", reason);
3345 return null;
3346 }
3347 }
3348
3349 #getScrollAhead(visible) {
3350 if (visible.first?.id === 1) {
3351 return true;
3352 } else if (visible.last?.id === this.pagesCount) {
3353 return false;
3354 }
3355
3356 switch (this._scrollMode) {
3357 case _ui_utils.ScrollMode.PAGE:
3358 return this.#scrollModePageState.scrollDown;
3359
3360 case _ui_utils.ScrollMode.HORIZONTAL:
3361 return this.scroll.right;
3362 }
3363
3364 return this.scroll.down;
3365 }
3366
3367 #toggleLoadingIconSpinner(visibleIds) {
3368 for (const id of visibleIds) {
3369 const pageView = this._pages[id - 1];
3370 pageView?.toggleLoadingIconSpinner(true);
3371 }
3372
3373 for (const pageView of this.#buffer) {
3374 if (visibleIds.has(pageView.id)) {
3375 continue;
3376 }
3377
3378 pageView.toggleLoadingIconSpinner(false);
3379 }
3380 }
3381
3382 forceRendering(currentlyVisiblePages) {
3383 const visiblePages = currentlyVisiblePages || this._getVisiblePages();
3384
3385 const scrollAhead = this.#getScrollAhead(visiblePages);
3386 const preRenderExtra = this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL;
3387 const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
3388 this.#toggleLoadingIconSpinner(visiblePages.ids);
3389
3390 if (pageView) {
3391 this.#ensurePdfPageLoaded(pageView).then(() => {
3392 this.renderingQueue.renderView(pageView);
3393 });
3394 return true;
3395 }
3396
3397 return false;
3398 }
3399
3400 createTextLayerBuilder({
3401 textLayerDiv,
3402 pageIndex,
3403 viewport,
3404 enhanceTextSelection = false,
3405 eventBus,
3406 highlighter
3407 }) {
3408 return new _text_layer_builder.TextLayerBuilder({
3409 textLayerDiv,
3410 eventBus,
3411 pageIndex,
3412 viewport,
3413 enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection,
3414 highlighter
3415 });
3416 }
3417
3418 createTextHighlighter({
3419 pageIndex,
3420 eventBus
3421 }) {
3422 return new _text_highlighter.TextHighlighter({
3423 eventBus,
3424 pageIndex,
3425 findController: this.isInPresentationMode ? null : this.findController
3426 });
3427 }
3428
3429 createAnnotationLayerBuilder({
3430 pageDiv,
3431 pdfPage,
3432 annotationStorage = this.pdfDocument?.annotationStorage,
3433 imageResourcesPath = "",
3434 renderForms = true,
3435 l10n = _l10n_utils.NullL10n,
3436 enableScripting = this.enableScripting,
3437 hasJSActionsPromise = this.pdfDocument?.hasJSActions(),
3438 mouseState = this._scriptingManager?.mouseState,
3439 fieldObjectsPromise = this.pdfDocument?.getFieldObjects(),
3440 annotationCanvasMap = null
3441 }) {
3442 return new _annotation_layer_builder.AnnotationLayerBuilder({
3443 pageDiv,
3444 pdfPage,
3445 annotationStorage,
3446 imageResourcesPath,
3447 renderForms,
3448 linkService: this.linkService,
3449 downloadManager: this.downloadManager,
3450 l10n,
3451 enableScripting,
3452 hasJSActionsPromise,
3453 mouseState,
3454 fieldObjectsPromise,
3455 annotationCanvasMap
3456 });
3457 }
3458
3459 createAnnotationEditorLayerBuilder({
3460 uiManager = this.#annotationEditorUIManager,
3461 pageDiv,
3462 pdfPage,
3463 l10n,
3464 annotationStorage = this.pdfDocument?.annotationStorage
3465 }) {
3466 return new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({
3467 uiManager,
3468 pageDiv,
3469 pdfPage,
3470 annotationStorage,
3471 l10n
3472 });
3473 }
3474
3475 createXfaLayerBuilder({
3476 pageDiv,
3477 pdfPage,
3478 annotationStorage = this.pdfDocument?.annotationStorage
3479 }) {
3480 return new _xfa_layer_builder.XfaLayerBuilder({
3481 pageDiv,
3482 pdfPage,
3483 annotationStorage,
3484 linkService: this.linkService
3485 });
3486 }
3487
3488 createStructTreeLayerBuilder({
3489 pdfPage
3490 }) {
3491 return new _struct_tree_layer_builder.StructTreeLayerBuilder({
3492 pdfPage
3493 });
3494 }
3495
3496 get hasEqualPageSizes() {
3497 const firstPageView = this._pages[0];
3498
3499 for (let i = 1, ii = this._pages.length; i < ii; ++i) {
3500 const pageView = this._pages[i];
3501
3502 if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
3503 return false;
3504 }
3505 }
3506
3507 return true;
3508 }
3509
3510 getPagesOverview() {
3511 return this._pages.map(pageView => {
3512 const viewport = pageView.pdfPage.getViewport({
3513 scale: 1
3514 });
3515
3516 if (!this.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
3517 return {
3518 width: viewport.width,
3519 height: viewport.height,
3520 rotation: viewport.rotation
3521 };
3522 }
3523
3524 return {
3525 width: viewport.height,
3526 height: viewport.width,
3527 rotation: (viewport.rotation - 90) % 360
3528 };
3529 });
3530 }
3531
3532 get optionalContentConfigPromise() {
3533 if (!this.pdfDocument) {
3534 return Promise.resolve(null);
3535 }
3536
3537 if (!this._optionalContentConfigPromise) {
3538 console.error("optionalContentConfigPromise: Not initialized yet.");
3539 return this.pdfDocument.getOptionalContentConfig();
3540 }
3541
3542 return this._optionalContentConfigPromise;
3543 }
3544
3545 set optionalContentConfigPromise(promise) {
3546 if (!(promise instanceof Promise)) {
3547 throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
3548 }
3549
3550 if (!this.pdfDocument) {
3551 return;
3552 }
3553
3554 if (!this._optionalContentConfigPromise) {
3555 return;
3556 }
3557
3558 this._optionalContentConfigPromise = promise;
3559 const updateArgs = {
3560 optionalContentConfigPromise: promise
3561 };
3562
3563 for (const pageView of this._pages) {
3564 pageView.update(updateArgs);
3565 }
3566
3567 this.update();
3568 this.eventBus.dispatch("optionalcontentconfigchanged", {
3569 source: this,
3570 promise
3571 });
3572 }
3573
3574 get scrollMode() {
3575 return this._scrollMode;
3576 }
3577
3578 set scrollMode(mode) {
3579 if (this._scrollMode === mode) {
3580 return;
3581 }
3582
3583 if (!(0, _ui_utils.isValidScrollMode)(mode)) {
3584 throw new Error(`Invalid scroll mode: ${mode}`);
3585 }
3586
3587 if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
3588 return;
3589 }
3590
3591 this._previousScrollMode = this._scrollMode;
3592 this._scrollMode = mode;
3593 this.eventBus.dispatch("scrollmodechanged", {
3594 source: this,
3595 mode
3596 });
3597
3598 this._updateScrollMode(this._currentPageNumber);
3599 }
3600
3601 _updateScrollMode(pageNumber = null) {
3602 const scrollMode = this._scrollMode,
3603 viewer = this.viewer;
3604 viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
3605 viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
3606
3607 if (!this.pdfDocument || !pageNumber) {
3608 return;
3609 }
3610
3611 if (scrollMode === _ui_utils.ScrollMode.PAGE) {
3612 this.#ensurePageViewVisible();
3613 } else if (this._previousScrollMode === _ui_utils.ScrollMode.PAGE) {
3614 this._updateSpreadMode();
3615 }
3616
3617 if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
3618 this._setScale(this._currentScaleValue, true);
3619 }
3620
3621 this._setCurrentPageNumber(pageNumber, true);
3622
3623 this.update();
3624 }
3625
3626 get spreadMode() {
3627 return this._spreadMode;
3628 }
3629
3630 set spreadMode(mode) {
3631 if (this._spreadMode === mode) {
3632 return;
3633 }
3634
3635 if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
3636 throw new Error(`Invalid spread mode: ${mode}`);
3637 }
3638
3639 this._spreadMode = mode;
3640 this.eventBus.dispatch("spreadmodechanged", {
3641 source: this,
3642 mode
3643 });
3644
3645 this._updateSpreadMode(this._currentPageNumber);
3646 }
3647
3648 _updateSpreadMode(pageNumber = null) {
3649 if (!this.pdfDocument) {
3650 return;
3651 }
3652
3653 const viewer = this.viewer,
3654 pages = this._pages;
3655
3656 if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
3657 this.#ensurePageViewVisible();
3658 } else {
3659 viewer.textContent = "";
3660
3661 if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
3662 for (const pageView of this._pages) {
3663 viewer.append(pageView.div);
3664 }
3665 } else {
3666 const parity = this._spreadMode - 1;
3667 let spread = null;
3668
3669 for (let i = 0, ii = pages.length; i < ii; ++i) {
3670 if (spread === null) {
3671 spread = document.createElement("div");
3672 spread.className = "spread";
3673 viewer.append(spread);
3674 } else if (i % 2 === parity) {
3675 spread = spread.cloneNode(false);
3676 viewer.append(spread);
3677 }
3678
3679 spread.append(pages[i].div);
3680 }
3681 }
3682 }
3683
3684 if (!pageNumber) {
3685 return;
3686 }
3687
3688 if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
3689 this._setScale(this._currentScaleValue, true);
3690 }
3691
3692 this._setCurrentPageNumber(pageNumber, true);
3693
3694 this.update();
3695 }
3696
3697 _getPageAdvance(currentPageNumber, previous = false) {
3698 switch (this._scrollMode) {
3699 case _ui_utils.ScrollMode.WRAPPED:
3700 {
3701 const {
3702 views
3703 } = this._getVisiblePages(),
3704 pageLayout = new Map();
3705
3706 for (const {
3707 id,
3708 y,
3709 percent,
3710 widthPercent
3711 } of views) {
3712 if (percent === 0 || widthPercent < 100) {
3713 continue;
3714 }
3715
3716 let yArray = pageLayout.get(y);
3717
3718 if (!yArray) {
3719 pageLayout.set(y, yArray ||= []);
3720 }
3721
3722 yArray.push(id);
3723 }
3724
3725 for (const yArray of pageLayout.values()) {
3726 const currentIndex = yArray.indexOf(currentPageNumber);
3727
3728 if (currentIndex === -1) {
3729 continue;
3730 }
3731
3732 const numPages = yArray.length;
3733
3734 if (numPages === 1) {
3735 break;
3736 }
3737
3738 if (previous) {
3739 for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
3740 const currentId = yArray[i],
3741 expectedId = yArray[i + 1] - 1;
3742
3743 if (currentId < expectedId) {
3744 return currentPageNumber - expectedId;
3745 }
3746 }
3747 } else {
3748 for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
3749 const currentId = yArray[i],
3750 expectedId = yArray[i - 1] + 1;
3751
3752 if (currentId > expectedId) {
3753 return expectedId - currentPageNumber;
3754 }
3755 }
3756 }
3757
3758 if (previous) {
3759 const firstId = yArray[0];
3760
3761 if (firstId < currentPageNumber) {
3762 return currentPageNumber - firstId + 1;
3763 }
3764 } else {
3765 const lastId = yArray[numPages - 1];
3766
3767 if (lastId > currentPageNumber) {
3768 return lastId - currentPageNumber + 1;
3769 }
3770 }
3771
3772 break;
3773 }
3774
3775 break;
3776 }
3777
3778 case _ui_utils.ScrollMode.HORIZONTAL:
3779 {
3780 break;
3781 }
3782
3783 case _ui_utils.ScrollMode.PAGE:
3784 case _ui_utils.ScrollMode.VERTICAL:
3785 {
3786 if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
3787 break;
3788 }
3789
3790 const parity = this._spreadMode - 1;
3791
3792 if (previous && currentPageNumber % 2 !== parity) {
3793 break;
3794 } else if (!previous && currentPageNumber % 2 === parity) {
3795 break;
3796 }
3797
3798 const {
3799 views
3800 } = this._getVisiblePages(),
3801 expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
3802
3803 for (const {
3804 id,
3805 percent,
3806 widthPercent
3807 } of views) {
3808 if (id !== expectedId) {
3809 continue;
3810 }
3811
3812 if (percent > 0 && widthPercent === 100) {
3813 return 2;
3814 }
3815
3816 break;
3817 }
3818
3819 break;
3820 }
3821 }
3822
3823 return 1;
3824 }
3825
3826 nextPage() {
3827 const currentPageNumber = this._currentPageNumber,
3828 pagesCount = this.pagesCount;
3829
3830 if (currentPageNumber >= pagesCount) {
3831 return false;
3832 }
3833
3834 const advance = this._getPageAdvance(currentPageNumber, false) || 1;
3835 this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
3836 return true;
3837 }
3838
3839 previousPage() {
3840 const currentPageNumber = this._currentPageNumber;
3841
3842 if (currentPageNumber <= 1) {
3843 return false;
3844 }
3845
3846 const advance = this._getPageAdvance(currentPageNumber, true) || 1;
3847 this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
3848 return true;
3849 }
3850
3851 increaseScale(steps = 1) {
3852 let newScale = this._currentScale;
3853
3854 do {
3855 newScale = (newScale * _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2);
3856 newScale = Math.ceil(newScale * 10) / 10;
3857 newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
3858 } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE);
3859
3860 this.currentScaleValue = newScale;
3861 }
3862
3863 decreaseScale(steps = 1) {
3864 let newScale = this._currentScale;
3865
3866 do {
3867 newScale = (newScale / _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2);
3868 newScale = Math.floor(newScale * 10) / 10;
3869 newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
3870 } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE);
3871
3872 this.currentScaleValue = newScale;
3873 }
3874
3875 updateContainerHeightCss() {
3876 const height = this.container.clientHeight;
3877
3878 if (height !== this.#previousContainerHeight) {
3879 this.#previousContainerHeight = height;
3880
3881 _ui_utils.docStyle.setProperty("--viewer-container-height", `${height}px`);
3882 }
3883 }
3884
3885 get annotationEditorMode() {
3886 return this.#annotationEditorUIManager ? this.#annotationEditorMode : _pdfjsLib.AnnotationEditorType.DISABLE;
3887 }
3888
3889 set annotationEditorMode(mode) {
3890 if (!this.#annotationEditorUIManager) {
3891 throw new Error(`The AnnotationEditor is not enabled.`);
3892 }
3893
3894 if (this.#annotationEditorMode === mode) {
3895 return;
3896 }
3897
3898 if (!isValidAnnotationEditorMode(mode)) {
3899 throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
3900 }
3901
3902 if (!this.pdfDocument) {
3903 return;
3904 }
3905
3906 this.#annotationEditorMode = mode;
3907 this.eventBus.dispatch("annotationeditormodechanged", {
3908 source: this,
3909 mode
3910 });
3911 this.#annotationEditorUIManager.updateMode(mode);
3912 }
3913
3914 set annotationEditorParams({
3915 type,
3916 value
3917 }) {
3918 if (!this.#annotationEditorUIManager) {
3919 throw new Error(`The AnnotationEditor is not enabled.`);
3920 }
3921
3922 this.#annotationEditorUIManager.updateParams(type, value);
3923 }
3924
3925}
3926
3927exports.BaseViewer = BaseViewer;
3928
3929/***/ }),
3930/* 13 */
3931/***/ ((__unused_webpack_module, exports) => {
3932
3933
3934
3935Object.defineProperty(exports, "__esModule", ({
3936 value: true
3937}));
3938exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0;
3939const compatibilityParams = Object.create(null);
3940exports.compatibilityParams = compatibilityParams;
3941{
3942 const userAgent = navigator.userAgent || "";
3943 const platform = navigator.platform || "";
3944 const maxTouchPoints = navigator.maxTouchPoints || 1;
3945 const isAndroid = /Android/.test(userAgent);
3946 const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
3947
3948 (function checkCanvasSizeLimitation() {
3949 if (isIOS || isAndroid) {
3950 compatibilityParams.maxCanvasPixels = 5242880;
3951 }
3952 })();
3953
3954 (function checkResizeObserver() {
3955 if (typeof ResizeObserver === "undefined") {
3956 compatibilityParams.annotationEditorMode = -1;
3957 }
3958 })();
3959}
3960const OptionKind = {
3961 VIEWER: 0x02,
3962 API: 0x04,
3963 WORKER: 0x08,
3964 PREFERENCE: 0x80
3965};
3966exports.OptionKind = OptionKind;
3967const defaultOptions = {
3968 annotationEditorMode: {
3969 value: -1,
3970 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
3971 },
3972 annotationMode: {
3973 value: 2,
3974 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
3975 },
3976 cursorToolOnLoad: {
3977 value: 0,
3978 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
3979 },
3980 defaultZoomValue: {
3981 value: "",
3982 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
3983 },
3984 disableHistory: {
3985 value: false,
3986 kind: OptionKind.VIEWER
3987 },
3988 disablePageLabels: {
3989 value: false,
3990 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
3991 },
3992 enablePermissions: {
3993 value: false,
3994 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
3995 },
3996 enablePrintAutoRotate: {
3997 value: true,
3998 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
3999 },
4000 enableScripting: {
4001 value: true,
4002 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4003 },
4004 externalLinkRel: {
4005 value: "noopener noreferrer nofollow",
4006 kind: OptionKind.VIEWER
4007 },
4008 externalLinkTarget: {
4009 value: 0,
4010 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4011 },
4012 historyUpdateUrl: {
4013 value: false,
4014 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4015 },
4016 ignoreDestinationZoom: {
4017 value: false,
4018 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4019 },
4020 imageResourcesPath: {
4021 value: "./images/",
4022 kind: OptionKind.VIEWER
4023 },
4024 maxCanvasPixels: {
4025 value: 16777216,
4026 kind: OptionKind.VIEWER
4027 },
4028 forcePageColors: {
4029 value: false,
4030 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4031 },
4032 pageColorsBackground: {
4033 value: "Canvas",
4034 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4035 },
4036 pageColorsForeground: {
4037 value: "CanvasText",
4038 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4039 },
4040 pdfBugEnabled: {
4041 value: false,
4042 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4043 },
4044 printResolution: {
4045 value: 150,
4046 kind: OptionKind.VIEWER
4047 },
4048 sidebarViewOnLoad: {
4049 value: -1,
4050 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4051 },
4052 scrollModeOnLoad: {
4053 value: -1,
4054 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4055 },
4056 spreadModeOnLoad: {
4057 value: -1,
4058 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4059 },
4060 textLayerMode: {
4061 value: 1,
4062 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4063 },
4064 useOnlyCssZoom: {
4065 value: false,
4066 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4067 },
4068 viewerCssTheme: {
4069 value: 0,
4070 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4071 },
4072 viewOnLoad: {
4073 value: 0,
4074 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4075 },
4076 cMapPacked: {
4077 value: true,
4078 kind: OptionKind.API
4079 },
4080 cMapUrl: {
4081 value: "../web/cmaps/",
4082 kind: OptionKind.API
4083 },
4084 disableAutoFetch: {
4085 value: false,
4086 kind: OptionKind.API + OptionKind.PREFERENCE
4087 },
4088 disableFontFace: {
4089 value: false,
4090 kind: OptionKind.API + OptionKind.PREFERENCE
4091 },
4092 disableRange: {
4093 value: false,
4094 kind: OptionKind.API + OptionKind.PREFERENCE
4095 },
4096 disableStream: {
4097 value: false,
4098 kind: OptionKind.API + OptionKind.PREFERENCE
4099 },
4100 docBaseUrl: {
4101 value: "",
4102 kind: OptionKind.API
4103 },
4104 enableXfa: {
4105 value: true,
4106 kind: OptionKind.API + OptionKind.PREFERENCE
4107 },
4108 fontExtraProperties: {
4109 value: false,
4110 kind: OptionKind.API
4111 },
4112 isEvalSupported: {
4113 value: true,
4114 kind: OptionKind.API
4115 },
4116 maxImageSize: {
4117 value: -1,
4118 kind: OptionKind.API
4119 },
4120 pdfBug: {
4121 value: false,
4122 kind: OptionKind.API
4123 },
4124 standardFontDataUrl: {
4125 value: "../web/standard_fonts/",
4126 kind: OptionKind.API
4127 },
4128 verbosity: {
4129 value: 1,
4130 kind: OptionKind.API
4131 },
4132 workerPort: {
4133 value: null,
4134 kind: OptionKind.WORKER
4135 },
4136 workerSrc: {
4137 value: "../build/pdf.worker.js",
4138 kind: OptionKind.WORKER
4139 }
4140};
4141{
4142 defaultOptions.defaultUrl = {
4143 value: "compressed.tracemonkey-pldi-09.pdf",
4144 kind: OptionKind.VIEWER
4145 };
4146 defaultOptions.disablePreferences = {
4147 value: false,
4148 kind: OptionKind.VIEWER
4149 };
4150 defaultOptions.locale = {
4151 value: navigator.language || "en-US",
4152 kind: OptionKind.VIEWER
4153 };
4154 defaultOptions.renderer = {
4155 value: "canvas",
4156 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4157 };
4158 defaultOptions.sandboxBundleSrc = {
4159 value: "../build/pdf.sandbox.js",
4160 kind: OptionKind.VIEWER
4161 };
4162}
4163const userOptions = Object.create(null);
4164
4165class AppOptions {
4166 constructor() {
4167 throw new Error("Cannot initialize AppOptions.");
4168 }
4169
4170 static get(name) {
4171 const userOption = userOptions[name];
4172
4173 if (userOption !== undefined) {
4174 return userOption;
4175 }
4176
4177 const defaultOption = defaultOptions[name];
4178
4179 if (defaultOption !== undefined) {
4180 return compatibilityParams[name] ?? defaultOption.value;
4181 }
4182
4183 return undefined;
4184 }
4185
4186 static getAll(kind = null) {
4187 const options = Object.create(null);
4188
4189 for (const name in defaultOptions) {
4190 const defaultOption = defaultOptions[name];
4191
4192 if (kind) {
4193 if ((kind & defaultOption.kind) === 0) {
4194 continue;
4195 }
4196
4197 if (kind === OptionKind.PREFERENCE) {
4198 const value = defaultOption.value,
4199 valueType = typeof value;
4200
4201 if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
4202 options[name] = value;
4203 continue;
4204 }
4205
4206 throw new Error(`Invalid type for preference: ${name}`);
4207 }
4208 }
4209
4210 const userOption = userOptions[name];
4211 options[name] = userOption !== undefined ? userOption : compatibilityParams[name] ?? defaultOption.value;
4212 }
4213
4214 return options;
4215 }
4216
4217 static set(name, value) {
4218 userOptions[name] = value;
4219 }
4220
4221 static setAll(options) {
4222 for (const name in options) {
4223 userOptions[name] = options[name];
4224 }
4225 }
4226
4227 static remove(name) {
4228 delete userOptions[name];
4229 }
4230
4231 static _hasUserOptions() {
4232 return Object.keys(userOptions).length > 0;
4233 }
4234
4235}
4236
4237exports.AppOptions = AppOptions;
4238
4239/***/ }),
4240/* 14 */
4241/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
4242
4243
4244
4245Object.defineProperty(exports, "__esModule", ({
4246 value: true
4247}));
4248exports.PDFPageView = void 0;
4249
4250var _pdfjsLib = __w_pdfjs_require__(3);
4251
4252var _ui_utils = __w_pdfjs_require__(7);
4253
4254var _app_options = __w_pdfjs_require__(13);
4255
4256var _l10n_utils = __w_pdfjs_require__(4);
4257
4258const MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216;
4259
4260class PDFPageView {
4261 #annotationMode = _pdfjsLib.AnnotationMode.ENABLE_FORMS;
4262 #useThumbnailCanvas = {
4263 initialOptionalContent: true,
4264 regularAnnotations: true
4265 };
4266
4267 constructor(options) {
4268 const container = options.container;
4269 const defaultViewport = options.defaultViewport;
4270 this.id = options.id;
4271 this.renderingId = "page" + this.id;
4272 this.pdfPage = null;
4273 this.pageLabel = null;
4274 this.rotation = 0;
4275 this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
4276 this.viewport = defaultViewport;
4277 this.pdfPageRotate = defaultViewport.rotation;
4278 this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
4279 this.hasRestrictedScaling = false;
4280 this.textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
4281 this.#annotationMode = options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS;
4282 this.imageResourcesPath = options.imageResourcesPath || "";
4283 this.useOnlyCssZoom = options.useOnlyCssZoom || false;
4284 this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
4285 this.pageColors = options.pageColors || null;
4286 this.eventBus = options.eventBus;
4287 this.renderingQueue = options.renderingQueue;
4288 this.textLayerFactory = options.textLayerFactory;
4289 this.annotationLayerFactory = options.annotationLayerFactory;
4290 this.annotationEditorLayerFactory = options.annotationEditorLayerFactory;
4291 this.xfaLayerFactory = options.xfaLayerFactory;
4292 this.textHighlighter = options.textHighlighterFactory?.createTextHighlighter({
4293 pageIndex: this.id - 1,
4294 eventBus: this.eventBus
4295 });
4296 this.structTreeLayerFactory = options.structTreeLayerFactory;
4297 this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
4298 this.l10n = options.l10n || _l10n_utils.NullL10n;
4299 this.paintTask = null;
4300 this.paintedViewportMap = new WeakMap();
4301 this.renderingState = _ui_utils.RenderingStates.INITIAL;
4302 this.resume = null;
4303 this._renderError = null;
4304 this._isStandalone = !this.renderingQueue?.hasViewer();
4305 this._annotationCanvasMap = null;
4306 this.annotationLayer = null;
4307 this.annotationEditorLayer = null;
4308 this.textLayer = null;
4309 this.zoomLayer = null;
4310 this.xfaLayer = null;
4311 this.structTreeLayer = null;
4312 const div = document.createElement("div");
4313 div.className = "page";
4314 div.style.width = Math.floor(this.viewport.width) + "px";
4315 div.style.height = Math.floor(this.viewport.height) + "px";
4316 div.setAttribute("data-page-number", this.id);
4317 div.setAttribute("role", "region");
4318 this.l10n.get("page_landmark", {
4319 page: this.id
4320 }).then(msg => {
4321 div.setAttribute("aria-label", msg);
4322 });
4323 this.div = div;
4324 container?.append(div);
4325
4326 if (this._isStandalone) {
4327 const {
4328 optionalContentConfigPromise
4329 } = options;
4330
4331 if (optionalContentConfigPromise) {
4332 optionalContentConfigPromise.then(optionalContentConfig => {
4333 if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
4334 return;
4335 }
4336
4337 this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
4338 });
4339 }
4340 }
4341 }
4342
4343 setPdfPage(pdfPage) {
4344 this.pdfPage = pdfPage;
4345 this.pdfPageRotate = pdfPage.rotate;
4346 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
4347 this.viewport = pdfPage.getViewport({
4348 scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
4349 rotation: totalRotation
4350 });
4351 this.reset();
4352 }
4353
4354 destroy() {
4355 this.reset();
4356
4357 if (this.pdfPage) {
4358 this.pdfPage.cleanup();
4359 }
4360 }
4361
4362 async _renderAnnotationLayer() {
4363 let error = null;
4364
4365 try {
4366 await this.annotationLayer.render(this.viewport, "display");
4367 } catch (ex) {
4368 error = ex;
4369 } finally {
4370 this.eventBus.dispatch("annotationlayerrendered", {
4371 source: this,
4372 pageNumber: this.id,
4373 error
4374 });
4375 }
4376 }
4377
4378 async _renderAnnotationEditorLayer() {
4379 let error = null;
4380
4381 try {
4382 await this.annotationEditorLayer.render(this.viewport, "display");
4383 } catch (ex) {
4384 error = ex;
4385 } finally {
4386 this.eventBus.dispatch("annotationeditorlayerrendered", {
4387 source: this,
4388 pageNumber: this.id,
4389 error
4390 });
4391 }
4392 }
4393
4394 async _renderXfaLayer() {
4395 let error = null;
4396
4397 try {
4398 const result = await this.xfaLayer.render(this.viewport, "display");
4399
4400 if (this.textHighlighter) {
4401 this._buildXfaTextContentItems(result.textDivs);
4402 }
4403 } catch (ex) {
4404 error = ex;
4405 } finally {
4406 this.eventBus.dispatch("xfalayerrendered", {
4407 source: this,
4408 pageNumber: this.id,
4409 error
4410 });
4411 }
4412 }
4413
4414 async _buildXfaTextContentItems(textDivs) {
4415 const text = await this.pdfPage.getTextContent();
4416 const items = [];
4417
4418 for (const item of text.items) {
4419 items.push(item.str);
4420 }
4421
4422 this.textHighlighter.setTextMapping(textDivs, items);
4423 this.textHighlighter.enable();
4424 }
4425
4426 _resetZoomLayer(removeFromDOM = false) {
4427 if (!this.zoomLayer) {
4428 return;
4429 }
4430
4431 const zoomLayerCanvas = this.zoomLayer.firstChild;
4432 this.paintedViewportMap.delete(zoomLayerCanvas);
4433 zoomLayerCanvas.width = 0;
4434 zoomLayerCanvas.height = 0;
4435
4436 if (removeFromDOM) {
4437 this.zoomLayer.remove();
4438 }
4439
4440 this.zoomLayer = null;
4441 }
4442
4443 reset({
4444 keepZoomLayer = false,
4445 keepAnnotationLayer = false,
4446 keepAnnotationEditorLayer = false,
4447 keepXfaLayer = false
4448 } = {}) {
4449 this.cancelRendering({
4450 keepAnnotationLayer,
4451 keepAnnotationEditorLayer,
4452 keepXfaLayer
4453 });
4454 this.renderingState = _ui_utils.RenderingStates.INITIAL;
4455 const div = this.div;
4456 div.style.width = Math.floor(this.viewport.width) + "px";
4457 div.style.height = Math.floor(this.viewport.height) + "px";
4458 const childNodes = div.childNodes,
4459 zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
4460 annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
4461 annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null,
4462 xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null;
4463
4464 for (let i = childNodes.length - 1; i >= 0; i--) {
4465 const node = childNodes[i];
4466
4467 switch (node) {
4468 case zoomLayerNode:
4469 case annotationLayerNode:
4470 case annotationEditorLayerNode:
4471 case xfaLayerNode:
4472 continue;
4473 }
4474
4475 node.remove();
4476 }
4477
4478 div.removeAttribute("data-loaded");
4479
4480 if (annotationLayerNode) {
4481 this.annotationLayer.hide();
4482 }
4483
4484 if (annotationEditorLayerNode) {
4485 this.annotationEditorLayer.hide();
4486 } else {
4487 this.annotationEditorLayer?.destroy();
4488 }
4489
4490 if (xfaLayerNode) {
4491 this.xfaLayer.hide();
4492 }
4493
4494 if (!zoomLayerNode) {
4495 if (this.canvas) {
4496 this.paintedViewportMap.delete(this.canvas);
4497 this.canvas.width = 0;
4498 this.canvas.height = 0;
4499 delete this.canvas;
4500 }
4501
4502 this._resetZoomLayer();
4503 }
4504
4505 if (this.svg) {
4506 this.paintedViewportMap.delete(this.svg);
4507 delete this.svg;
4508 }
4509
4510 this.loadingIconDiv = document.createElement("div");
4511 this.loadingIconDiv.className = "loadingIcon notVisible";
4512
4513 if (this._isStandalone) {
4514 this.toggleLoadingIconSpinner(true);
4515 }
4516
4517 this.loadingIconDiv.setAttribute("role", "img");
4518 this.l10n.get("loading").then(msg => {
4519 this.loadingIconDiv?.setAttribute("aria-label", msg);
4520 });
4521 div.append(this.loadingIconDiv);
4522 }
4523
4524 update({
4525 scale = 0,
4526 rotation = null,
4527 optionalContentConfigPromise = null
4528 }) {
4529 this.scale = scale || this.scale;
4530
4531 if (typeof rotation === "number") {
4532 this.rotation = rotation;
4533 }
4534
4535 if (optionalContentConfigPromise instanceof Promise) {
4536 this._optionalContentConfigPromise = optionalContentConfigPromise;
4537 optionalContentConfigPromise.then(optionalContentConfig => {
4538 if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
4539 return;
4540 }
4541
4542 this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
4543 });
4544 }
4545
4546 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
4547 this.viewport = this.viewport.clone({
4548 scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
4549 rotation: totalRotation
4550 });
4551
4552 if (this._isStandalone) {
4553 _ui_utils.docStyle.setProperty("--scale-factor", this.viewport.scale);
4554 }
4555
4556 if (this.svg) {
4557 this.cssTransform({
4558 target: this.svg,
4559 redrawAnnotationLayer: true,
4560 redrawAnnotationEditorLayer: true,
4561 redrawXfaLayer: true
4562 });
4563 this.eventBus.dispatch("pagerendered", {
4564 source: this,
4565 pageNumber: this.id,
4566 cssTransform: true,
4567 timestamp: performance.now(),
4568 error: this._renderError
4569 });
4570 return;
4571 }
4572
4573 let isScalingRestricted = false;
4574
4575 if (this.canvas && this.maxCanvasPixels > 0) {
4576 const outputScale = this.outputScale;
4577
4578 if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
4579 isScalingRestricted = true;
4580 }
4581 }
4582
4583 if (this.canvas) {
4584 if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
4585 this.cssTransform({
4586 target: this.canvas,
4587 redrawAnnotationLayer: true,
4588 redrawAnnotationEditorLayer: true,
4589 redrawXfaLayer: true
4590 });
4591 this.eventBus.dispatch("pagerendered", {
4592 source: this,
4593 pageNumber: this.id,
4594 cssTransform: true,
4595 timestamp: performance.now(),
4596 error: this._renderError
4597 });
4598 return;
4599 }
4600
4601 if (!this.zoomLayer && !this.canvas.hidden) {
4602 this.zoomLayer = this.canvas.parentNode;
4603 this.zoomLayer.style.position = "absolute";
4604 }
4605 }
4606
4607 if (this.zoomLayer) {
4608 this.cssTransform({
4609 target: this.zoomLayer.firstChild
4610 });
4611 }
4612
4613 this.reset({
4614 keepZoomLayer: true,
4615 keepAnnotationLayer: true,
4616 keepAnnotationEditorLayer: true,
4617 keepXfaLayer: true
4618 });
4619 }
4620
4621 cancelRendering({
4622 keepAnnotationLayer = false,
4623 keepAnnotationEditorLayer = false,
4624 keepXfaLayer = false
4625 } = {}) {
4626 if (this.paintTask) {
4627 this.paintTask.cancel();
4628 this.paintTask = null;
4629 }
4630
4631 this.resume = null;
4632
4633 if (this.textLayer) {
4634 this.textLayer.cancel();
4635 this.textLayer = null;
4636 }
4637
4638 if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
4639 this.annotationLayer.cancel();
4640 this.annotationLayer = null;
4641 this._annotationCanvasMap = null;
4642 }
4643
4644 if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
4645 this.annotationEditorLayer.cancel();
4646 this.annotationEditorLayer = null;
4647 }
4648
4649 if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
4650 this.xfaLayer.cancel();
4651 this.xfaLayer = null;
4652 this.textHighlighter?.disable();
4653 }
4654
4655 if (this._onTextLayerRendered) {
4656 this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
4657
4658 this._onTextLayerRendered = null;
4659 }
4660 }
4661
4662 cssTransform({
4663 target,
4664 redrawAnnotationLayer = false,
4665 redrawAnnotationEditorLayer = false,
4666 redrawXfaLayer = false
4667 }) {
4668 const width = this.viewport.width;
4669 const height = this.viewport.height;
4670 const div = this.div;
4671 target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
4672 target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
4673 const relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
4674 const absRotation = Math.abs(relativeRotation);
4675 let scaleX = 1,
4676 scaleY = 1;
4677
4678 if (absRotation === 90 || absRotation === 270) {
4679 scaleX = height / width;
4680 scaleY = width / height;
4681 }
4682
4683 target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
4684
4685 if (this.textLayer) {
4686 const textLayerViewport = this.textLayer.viewport;
4687 const textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
4688 const textAbsRotation = Math.abs(textRelativeRotation);
4689 let scale = width / textLayerViewport.width;
4690
4691 if (textAbsRotation === 90 || textAbsRotation === 270) {
4692 scale = width / textLayerViewport.height;
4693 }
4694
4695 const textLayerDiv = this.textLayer.textLayerDiv;
4696 let transX, transY;
4697
4698 switch (textAbsRotation) {
4699 case 0:
4700 transX = transY = 0;
4701 break;
4702
4703 case 90:
4704 transX = 0;
4705 transY = "-" + textLayerDiv.style.height;
4706 break;
4707
4708 case 180:
4709 transX = "-" + textLayerDiv.style.width;
4710 transY = "-" + textLayerDiv.style.height;
4711 break;
4712
4713 case 270:
4714 transX = "-" + textLayerDiv.style.width;
4715 transY = 0;
4716 break;
4717
4718 default:
4719 console.error("Bad rotation value.");
4720 break;
4721 }
4722
4723 textLayerDiv.style.transform = `rotate(${textAbsRotation}deg) ` + `scale(${scale}) ` + `translate(${transX}, ${transY})`;
4724 textLayerDiv.style.transformOrigin = "0% 0%";
4725 }
4726
4727 if (redrawAnnotationLayer && this.annotationLayer) {
4728 this._renderAnnotationLayer();
4729 }
4730
4731 if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
4732 this._renderAnnotationEditorLayer();
4733 }
4734
4735 if (redrawXfaLayer && this.xfaLayer) {
4736 this._renderXfaLayer();
4737 }
4738 }
4739
4740 get width() {
4741 return this.viewport.width;
4742 }
4743
4744 get height() {
4745 return this.viewport.height;
4746 }
4747
4748 getPagePoint(x, y) {
4749 return this.viewport.convertToPdfPoint(x, y);
4750 }
4751
4752 toggleLoadingIconSpinner(viewVisible = false) {
4753 this.loadingIconDiv?.classList.toggle("notVisible", !viewVisible);
4754 }
4755
4756 draw() {
4757 if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
4758 console.error("Must be in new state before drawing");
4759 this.reset();
4760 }
4761
4762 const {
4763 div,
4764 pdfPage
4765 } = this;
4766
4767 if (!pdfPage) {
4768 this.renderingState = _ui_utils.RenderingStates.FINISHED;
4769
4770 if (this.loadingIconDiv) {
4771 this.loadingIconDiv.remove();
4772 delete this.loadingIconDiv;
4773 }
4774
4775 return Promise.reject(new Error("pdfPage is not loaded"));
4776 }
4777
4778 this.renderingState = _ui_utils.RenderingStates.RUNNING;
4779 const canvasWrapper = document.createElement("div");
4780 canvasWrapper.style.width = div.style.width;
4781 canvasWrapper.style.height = div.style.height;
4782 canvasWrapper.classList.add("canvasWrapper");
4783 const lastDivBeforeTextDiv = this.annotationLayer?.div || this.annotationEditorLayer?.div;
4784
4785 if (lastDivBeforeTextDiv) {
4786 lastDivBeforeTextDiv.before(canvasWrapper);
4787 } else {
4788 div.append(canvasWrapper);
4789 }
4790
4791 let textLayer = null;
4792
4793 if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
4794 const textLayerDiv = document.createElement("div");
4795 textLayerDiv.className = "textLayer";
4796 textLayerDiv.style.width = canvasWrapper.style.width;
4797 textLayerDiv.style.height = canvasWrapper.style.height;
4798
4799 if (lastDivBeforeTextDiv) {
4800 lastDivBeforeTextDiv.before(textLayerDiv);
4801 } else {
4802 div.append(textLayerDiv);
4803 }
4804
4805 textLayer = this.textLayerFactory.createTextLayerBuilder({
4806 textLayerDiv,
4807 pageIndex: this.id - 1,
4808 viewport: this.viewport,
4809 enhanceTextSelection: this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE,
4810 eventBus: this.eventBus,
4811 highlighter: this.textHighlighter
4812 });
4813 }
4814
4815 this.textLayer = textLayer;
4816
4817 if (this.#annotationMode !== _pdfjsLib.AnnotationMode.DISABLE && this.annotationLayerFactory) {
4818 this._annotationCanvasMap ||= new Map();
4819 this.annotationLayer ||= this.annotationLayerFactory.createAnnotationLayerBuilder({
4820 pageDiv: div,
4821 pdfPage,
4822 imageResourcesPath: this.imageResourcesPath,
4823 renderForms: this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS,
4824 l10n: this.l10n,
4825 annotationCanvasMap: this._annotationCanvasMap
4826 });
4827 }
4828
4829 if (this.xfaLayer?.div) {
4830 div.append(this.xfaLayer.div);
4831 }
4832
4833 let renderContinueCallback = null;
4834
4835 if (this.renderingQueue) {
4836 renderContinueCallback = cont => {
4837 if (!this.renderingQueue.isHighestPriority(this)) {
4838 this.renderingState = _ui_utils.RenderingStates.PAUSED;
4839
4840 this.resume = () => {
4841 this.renderingState = _ui_utils.RenderingStates.RUNNING;
4842 cont();
4843 };
4844
4845 return;
4846 }
4847
4848 cont();
4849 };
4850 }
4851
4852 const finishPaintTask = async (error = null) => {
4853 if (paintTask === this.paintTask) {
4854 this.paintTask = null;
4855 }
4856
4857 if (error instanceof _pdfjsLib.RenderingCancelledException) {
4858 this._renderError = null;
4859 return;
4860 }
4861
4862 this._renderError = error;
4863 this.renderingState = _ui_utils.RenderingStates.FINISHED;
4864
4865 if (this.loadingIconDiv) {
4866 this.loadingIconDiv.remove();
4867 delete this.loadingIconDiv;
4868 }
4869
4870 this._resetZoomLayer(true);
4871
4872 this.#useThumbnailCanvas.regularAnnotations = !paintTask.separateAnnots;
4873 this.eventBus.dispatch("pagerendered", {
4874 source: this,
4875 pageNumber: this.id,
4876 cssTransform: false,
4877 timestamp: performance.now(),
4878 error: this._renderError
4879 });
4880
4881 if (error) {
4882 throw error;
4883 }
4884 };
4885
4886 const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
4887 paintTask.onRenderContinue = renderContinueCallback;
4888 this.paintTask = paintTask;
4889 const resultPromise = paintTask.promise.then(() => {
4890 return finishPaintTask(null).then(() => {
4891 if (textLayer) {
4892 const readableStream = pdfPage.streamTextContent({
4893 includeMarkedContent: true
4894 });
4895 textLayer.setTextContentStream(readableStream);
4896 textLayer.render();
4897 }
4898
4899 if (this.annotationLayer) {
4900 this._renderAnnotationLayer().then(() => {
4901 if (this.annotationEditorLayerFactory) {
4902 this.annotationEditorLayer ||= this.annotationEditorLayerFactory.createAnnotationEditorLayerBuilder({
4903 pageDiv: div,
4904 pdfPage,
4905 l10n: this.l10n
4906 });
4907
4908 this._renderAnnotationEditorLayer();
4909 }
4910 });
4911 }
4912 });
4913 }, function (reason) {
4914 return finishPaintTask(reason);
4915 });
4916
4917 if (this.xfaLayerFactory) {
4918 if (!this.xfaLayer) {
4919 this.xfaLayer = this.xfaLayerFactory.createXfaLayerBuilder({
4920 pageDiv: div,
4921 pdfPage
4922 });
4923 }
4924
4925 this._renderXfaLayer();
4926 }
4927
4928 if (this.structTreeLayerFactory && this.textLayer && this.canvas) {
4929 this._onTextLayerRendered = event => {
4930 if (event.pageNumber !== this.id) {
4931 return;
4932 }
4933
4934 this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
4935
4936 this._onTextLayerRendered = null;
4937
4938 if (!this.canvas) {
4939 return;
4940 }
4941
4942 this.pdfPage.getStructTree().then(tree => {
4943 if (!tree) {
4944 return;
4945 }
4946
4947 if (!this.canvas) {
4948 return;
4949 }
4950
4951 const treeDom = this.structTreeLayer.render(tree);
4952 treeDom.classList.add("structTree");
4953 this.canvas.append(treeDom);
4954 });
4955 };
4956
4957 this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
4958
4959 this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder({
4960 pdfPage
4961 });
4962 }
4963
4964 div.setAttribute("data-loaded", true);
4965 this.eventBus.dispatch("pagerender", {
4966 source: this,
4967 pageNumber: this.id
4968 });
4969 return resultPromise;
4970 }
4971
4972 paintOnCanvas(canvasWrapper) {
4973 const renderCapability = (0, _pdfjsLib.createPromiseCapability)();
4974 const result = {
4975 promise: renderCapability.promise,
4976
4977 onRenderContinue(cont) {
4978 cont();
4979 },
4980
4981 cancel() {
4982 renderTask.cancel();
4983 },
4984
4985 get separateAnnots() {
4986 return renderTask.separateAnnots;
4987 }
4988
4989 };
4990 const viewport = this.viewport;
4991 const canvas = document.createElement("canvas");
4992 canvas.setAttribute("role", "presentation");
4993 canvas.hidden = true;
4994 let isCanvasHidden = true;
4995
4996 const showCanvas = function () {
4997 if (isCanvasHidden) {
4998 canvas.hidden = false;
4999 isCanvasHidden = false;
5000 }
5001 };
5002
5003 canvasWrapper.append(canvas);
5004 this.canvas = canvas;
5005 const ctx = canvas.getContext("2d", {
5006 alpha: false
5007 });
5008 const outputScale = this.outputScale = new _ui_utils.OutputScale();
5009
5010 if (this.useOnlyCssZoom) {
5011 const actualSizeViewport = viewport.clone({
5012 scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
5013 });
5014 outputScale.sx *= actualSizeViewport.width / viewport.width;
5015 outputScale.sy *= actualSizeViewport.height / viewport.height;
5016 }
5017
5018 if (this.maxCanvasPixels > 0) {
5019 const pixelsInViewport = viewport.width * viewport.height;
5020 const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
5021
5022 if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
5023 outputScale.sx = maxScale;
5024 outputScale.sy = maxScale;
5025 this.hasRestrictedScaling = true;
5026 } else {
5027 this.hasRestrictedScaling = false;
5028 }
5029 }
5030
5031 const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
5032 const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
5033 canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
5034 canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
5035 canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
5036 canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
5037 this.paintedViewportMap.set(canvas, viewport);
5038 const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
5039 const renderContext = {
5040 canvasContext: ctx,
5041 transform,
5042 viewport: this.viewport,
5043 annotationMode: this.#annotationMode,
5044 optionalContentConfigPromise: this._optionalContentConfigPromise,
5045 annotationCanvasMap: this._annotationCanvasMap,
5046 pageColors: this.pageColors
5047 };
5048 const renderTask = this.pdfPage.render(renderContext);
5049
5050 renderTask.onContinue = function (cont) {
5051 showCanvas();
5052
5053 if (result.onRenderContinue) {
5054 result.onRenderContinue(cont);
5055 } else {
5056 cont();
5057 }
5058 };
5059
5060 renderTask.promise.then(function () {
5061 showCanvas();
5062 renderCapability.resolve();
5063 }, function (error) {
5064 showCanvas();
5065 renderCapability.reject(error);
5066 });
5067 return result;
5068 }
5069
5070 paintOnSvg(wrapper) {
5071 let cancelled = false;
5072
5073 const ensureNotCancelled = () => {
5074 if (cancelled) {
5075 throw new _pdfjsLib.RenderingCancelledException(`Rendering cancelled, page ${this.id}`, "svg");
5076 }
5077 };
5078
5079 const pdfPage = this.pdfPage;
5080 const actualSizeViewport = this.viewport.clone({
5081 scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
5082 });
5083 const promise = pdfPage.getOperatorList({
5084 annotationMode: this.#annotationMode
5085 }).then(opList => {
5086 ensureNotCancelled();
5087 const svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
5088 return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {
5089 ensureNotCancelled();
5090 this.svg = svg;
5091 this.paintedViewportMap.set(svg, actualSizeViewport);
5092 svg.style.width = wrapper.style.width;
5093 svg.style.height = wrapper.style.height;
5094 this.renderingState = _ui_utils.RenderingStates.FINISHED;
5095 wrapper.append(svg);
5096 });
5097 });
5098 return {
5099 promise,
5100
5101 onRenderContinue(cont) {
5102 cont();
5103 },
5104
5105 cancel() {
5106 cancelled = true;
5107 },
5108
5109 get separateAnnots() {
5110 return false;
5111 }
5112
5113 };
5114 }
5115
5116 setPageLabel(label) {
5117 this.pageLabel = typeof label === "string" ? label : null;
5118
5119 if (this.pageLabel !== null) {
5120 this.div.setAttribute("data-page-label", this.pageLabel);
5121 } else {
5122 this.div.removeAttribute("data-page-label");
5123 }
5124 }
5125
5126 get thumbnailCanvas() {
5127 const {
5128 initialOptionalContent,
5129 regularAnnotations
5130 } = this.#useThumbnailCanvas;
5131 return initialOptionalContent && regularAnnotations ? this.canvas : null;
5132 }
5133
5134}
5135
5136exports.PDFPageView = PDFPageView;
5137
5138/***/ }),
5139/* 15 */
5140/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
5141
5142
5143
5144Object.defineProperty(exports, "__esModule", ({
5145 value: true
5146}));
5147exports.PDFRenderingQueue = void 0;
5148
5149var _pdfjsLib = __w_pdfjs_require__(3);
5150
5151var _ui_utils = __w_pdfjs_require__(7);
5152
5153const CLEANUP_TIMEOUT = 30000;
5154
5155class PDFRenderingQueue {
5156 constructor() {
5157 this.pdfViewer = null;
5158 this.pdfThumbnailViewer = null;
5159 this.onIdle = null;
5160 this.highestPriorityPage = null;
5161 this.idleTimeout = null;
5162 this.printing = false;
5163 this.isThumbnailViewEnabled = false;
5164 }
5165
5166 setViewer(pdfViewer) {
5167 this.pdfViewer = pdfViewer;
5168 }
5169
5170 setThumbnailViewer(pdfThumbnailViewer) {
5171 this.pdfThumbnailViewer = pdfThumbnailViewer;
5172 }
5173
5174 isHighestPriority(view) {
5175 return this.highestPriorityPage === view.renderingId;
5176 }
5177
5178 hasViewer() {
5179 return !!this.pdfViewer;
5180 }
5181
5182 renderHighestPriority(currentlyVisiblePages) {
5183 if (this.idleTimeout) {
5184 clearTimeout(this.idleTimeout);
5185 this.idleTimeout = null;
5186 }
5187
5188 if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
5189 return;
5190 }
5191
5192 if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) {
5193 return;
5194 }
5195
5196 if (this.printing) {
5197 return;
5198 }
5199
5200 if (this.onIdle) {
5201 this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
5202 }
5203 }
5204
5205 getHighestPriority(visible, views, scrolledDown, preRenderExtra = false) {
5206 const visibleViews = visible.views,
5207 numVisible = visibleViews.length;
5208
5209 if (numVisible === 0) {
5210 return null;
5211 }
5212
5213 for (let i = 0; i < numVisible; i++) {
5214 const view = visibleViews[i].view;
5215
5216 if (!this.isViewFinished(view)) {
5217 return view;
5218 }
5219 }
5220
5221 const firstId = visible.first.id,
5222 lastId = visible.last.id;
5223
5224 if (lastId - firstId + 1 > numVisible) {
5225 const visibleIds = visible.ids;
5226
5227 for (let i = 1, ii = lastId - firstId; i < ii; i++) {
5228 const holeId = scrolledDown ? firstId + i : lastId - i;
5229
5230 if (visibleIds.has(holeId)) {
5231 continue;
5232 }
5233
5234 const holeView = views[holeId - 1];
5235
5236 if (!this.isViewFinished(holeView)) {
5237 return holeView;
5238 }
5239 }
5240 }
5241
5242 let preRenderIndex = scrolledDown ? lastId : firstId - 2;
5243 let preRenderView = views[preRenderIndex];
5244
5245 if (preRenderView && !this.isViewFinished(preRenderView)) {
5246 return preRenderView;
5247 }
5248
5249 if (preRenderExtra) {
5250 preRenderIndex += scrolledDown ? 1 : -1;
5251 preRenderView = views[preRenderIndex];
5252
5253 if (preRenderView && !this.isViewFinished(preRenderView)) {
5254 return preRenderView;
5255 }
5256 }
5257
5258 return null;
5259 }
5260
5261 isViewFinished(view) {
5262 return view.renderingState === _ui_utils.RenderingStates.FINISHED;
5263 }
5264
5265 renderView(view) {
5266 switch (view.renderingState) {
5267 case _ui_utils.RenderingStates.FINISHED:
5268 return false;
5269
5270 case _ui_utils.RenderingStates.PAUSED:
5271 this.highestPriorityPage = view.renderingId;
5272 view.resume();
5273 break;
5274
5275 case _ui_utils.RenderingStates.RUNNING:
5276 this.highestPriorityPage = view.renderingId;
5277 break;
5278
5279 case _ui_utils.RenderingStates.INITIAL:
5280 this.highestPriorityPage = view.renderingId;
5281 view.draw().finally(() => {
5282 this.renderHighestPriority();
5283 }).catch(reason => {
5284 if (reason instanceof _pdfjsLib.RenderingCancelledException) {
5285 return;
5286 }
5287
5288 console.error(`renderView: "${reason}"`);
5289 });
5290 break;
5291 }
5292
5293 return true;
5294 }
5295
5296}
5297
5298exports.PDFRenderingQueue = PDFRenderingQueue;
5299
5300/***/ }),
5301/* 16 */
5302/***/ ((__unused_webpack_module, exports) => {
5303
5304
5305
5306Object.defineProperty(exports, "__esModule", ({
5307 value: true
5308}));
5309exports.TextHighlighter = void 0;
5310
5311class TextHighlighter {
5312 constructor({
5313 findController,
5314 eventBus,
5315 pageIndex
5316 }) {
5317 this.findController = findController;
5318 this.matches = [];
5319 this.eventBus = eventBus;
5320 this.pageIdx = pageIndex;
5321 this._onUpdateTextLayerMatches = null;
5322 this.textDivs = null;
5323 this.textContentItemsStr = null;
5324 this.enabled = false;
5325 }
5326
5327 setTextMapping(divs, texts) {
5328 this.textDivs = divs;
5329 this.textContentItemsStr = texts;
5330 }
5331
5332 enable() {
5333 if (!this.textDivs || !this.textContentItemsStr) {
5334 throw new Error("Text divs and strings have not been set.");
5335 }
5336
5337 if (this.enabled) {
5338 throw new Error("TextHighlighter is already enabled.");
5339 }
5340
5341 this.enabled = true;
5342
5343 if (!this._onUpdateTextLayerMatches) {
5344 this._onUpdateTextLayerMatches = evt => {
5345 if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
5346 this._updateMatches();
5347 }
5348 };
5349
5350 this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
5351 }
5352
5353 this._updateMatches();
5354 }
5355
5356 disable() {
5357 if (!this.enabled) {
5358 return;
5359 }
5360
5361 this.enabled = false;
5362
5363 if (this._onUpdateTextLayerMatches) {
5364 this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
5365
5366 this._onUpdateTextLayerMatches = null;
5367 }
5368 }
5369
5370 _convertMatches(matches, matchesLength) {
5371 if (!matches) {
5372 return [];
5373 }
5374
5375 const {
5376 textContentItemsStr
5377 } = this;
5378 let i = 0,
5379 iIndex = 0;
5380 const end = textContentItemsStr.length - 1;
5381 const result = [];
5382
5383 for (let m = 0, mm = matches.length; m < mm; m++) {
5384 let matchIdx = matches[m];
5385
5386 while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
5387 iIndex += textContentItemsStr[i].length;
5388 i++;
5389 }
5390
5391 if (i === textContentItemsStr.length) {
5392 console.error("Could not find a matching mapping");
5393 }
5394
5395 const match = {
5396 begin: {
5397 divIdx: i,
5398 offset: matchIdx - iIndex
5399 }
5400 };
5401 matchIdx += matchesLength[m];
5402
5403 while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
5404 iIndex += textContentItemsStr[i].length;
5405 i++;
5406 }
5407
5408 match.end = {
5409 divIdx: i,
5410 offset: matchIdx - iIndex
5411 };
5412 result.push(match);
5413 }
5414
5415 return result;
5416 }
5417
5418 _renderMatches(matches) {
5419 if (matches.length === 0) {
5420 return;
5421 }
5422
5423 const {
5424 findController,
5425 pageIdx
5426 } = this;
5427 const {
5428 textContentItemsStr,
5429 textDivs
5430 } = this;
5431 const isSelectedPage = pageIdx === findController.selected.pageIdx;
5432 const selectedMatchIdx = findController.selected.matchIdx;
5433 const highlightAll = findController.state.highlightAll;
5434 let prevEnd = null;
5435 const infinity = {
5436 divIdx: -1,
5437 offset: undefined
5438 };
5439
5440 function beginText(begin, className) {
5441 const divIdx = begin.divIdx;
5442 textDivs[divIdx].textContent = "";
5443 return appendTextToDiv(divIdx, 0, begin.offset, className);
5444 }
5445
5446 function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
5447 let div = textDivs[divIdx];
5448
5449 if (div.nodeType === Node.TEXT_NODE) {
5450 const span = document.createElement("span");
5451 div.before(span);
5452 span.append(div);
5453 textDivs[divIdx] = span;
5454 div = span;
5455 }
5456
5457 const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
5458 const node = document.createTextNode(content);
5459
5460 if (className) {
5461 const span = document.createElement("span");
5462 span.className = `${className} appended`;
5463 span.append(node);
5464 div.append(span);
5465 return className.includes("selected") ? span.offsetLeft : 0;
5466 }
5467
5468 div.append(node);
5469 return 0;
5470 }
5471
5472 let i0 = selectedMatchIdx,
5473 i1 = i0 + 1;
5474
5475 if (highlightAll) {
5476 i0 = 0;
5477 i1 = matches.length;
5478 } else if (!isSelectedPage) {
5479 return;
5480 }
5481
5482 for (let i = i0; i < i1; i++) {
5483 const match = matches[i];
5484 const begin = match.begin;
5485 const end = match.end;
5486 const isSelected = isSelectedPage && i === selectedMatchIdx;
5487 const highlightSuffix = isSelected ? " selected" : "";
5488 let selectedLeft = 0;
5489
5490 if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
5491 if (prevEnd !== null) {
5492 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
5493 }
5494
5495 beginText(begin);
5496 } else {
5497 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
5498 }
5499
5500 if (begin.divIdx === end.divIdx) {
5501 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
5502 } else {
5503 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
5504
5505 for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
5506 textDivs[n0].className = "highlight middle" + highlightSuffix;
5507 }
5508
5509 beginText(end, "highlight end" + highlightSuffix);
5510 }
5511
5512 prevEnd = end;
5513
5514 if (isSelected) {
5515 findController.scrollMatchIntoView({
5516 element: textDivs[begin.divIdx],
5517 selectedLeft,
5518 pageIndex: pageIdx,
5519 matchIndex: selectedMatchIdx
5520 });
5521 }
5522 }
5523
5524 if (prevEnd) {
5525 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
5526 }
5527 }
5528
5529 _updateMatches() {
5530 if (!this.enabled) {
5531 return;
5532 }
5533
5534 const {
5535 findController,
5536 matches,
5537 pageIdx
5538 } = this;
5539 const {
5540 textContentItemsStr,
5541 textDivs
5542 } = this;
5543 let clearedUntilDivIdx = -1;
5544
5545 for (let i = 0, ii = matches.length; i < ii; i++) {
5546 const match = matches[i];
5547 const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
5548
5549 for (let n = begin, end = match.end.divIdx; n <= end; n++) {
5550 const div = textDivs[n];
5551 div.textContent = textContentItemsStr[n];
5552 div.className = "";
5553 }
5554
5555 clearedUntilDivIdx = match.end.divIdx + 1;
5556 }
5557
5558 if (!findController?.highlightMatches) {
5559 return;
5560 }
5561
5562 const pageMatches = findController.pageMatches[pageIdx] || null;
5563 const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
5564 this.matches = this._convertMatches(pageMatches, pageMatchesLength);
5565
5566 this._renderMatches(this.matches);
5567 }
5568
5569}
5570
5571exports.TextHighlighter = TextHighlighter;
5572
5573/***/ }),
5574/* 17 */
5575/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
5576
5577
5578
5579Object.defineProperty(exports, "__esModule", ({
5580 value: true
5581}));
5582exports.DownloadManager = void 0;
5583
5584var _pdfjsLib = __w_pdfjs_require__(3);
5585
5586;
5587
5588function download(blobUrl, filename) {
5589 const a = document.createElement("a");
5590
5591 if (!a.click) {
5592 throw new Error('DownloadManager: "a.click()" is not supported.');
5593 }
5594
5595 a.href = blobUrl;
5596 a.target = "_parent";
5597
5598 if ("download" in a) {
5599 a.download = filename;
5600 }
5601
5602 (document.body || document.documentElement).append(a);
5603 a.click();
5604 a.remove();
5605}
5606
5607class DownloadManager {
5608 constructor() {
5609 this._openBlobUrls = new WeakMap();
5610 }
5611
5612 downloadUrl(url, filename) {
5613 if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
5614 console.error(`downloadUrl - not a valid URL: ${url}`);
5615 return;
5616 }
5617
5618 download(url + "#pdfjs.action=download", filename);
5619 }
5620
5621 downloadData(data, filename, contentType) {
5622 const blobUrl = URL.createObjectURL(new Blob([data], {
5623 type: contentType
5624 }));
5625 download(blobUrl, filename);
5626 }
5627
5628 openOrDownloadData(element, data, filename) {
5629 const isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
5630 const contentType = isPdfData ? "application/pdf" : "";
5631
5632 if (isPdfData) {
5633 let blobUrl = this._openBlobUrls.get(element);
5634
5635 if (!blobUrl) {
5636 blobUrl = URL.createObjectURL(new Blob([data], {
5637 type: contentType
5638 }));
5639
5640 this._openBlobUrls.set(element, blobUrl);
5641 }
5642
5643 let viewerUrl;
5644 viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
5645
5646 try {
5647 window.open(viewerUrl);
5648 return true;
5649 } catch (ex) {
5650 console.error(`openOrDownloadData: ${ex}`);
5651 URL.revokeObjectURL(blobUrl);
5652
5653 this._openBlobUrls.delete(element);
5654 }
5655 }
5656
5657 this.downloadData(data, filename, contentType);
5658 return false;
5659 }
5660
5661 download(blob, url, filename) {
5662 const blobUrl = URL.createObjectURL(blob);
5663 download(blobUrl, filename);
5664 }
5665
5666}
5667
5668exports.DownloadManager = DownloadManager;
5669
5670/***/ }),
5671/* 18 */
5672/***/ ((__unused_webpack_module, exports) => {
5673
5674
5675
5676Object.defineProperty(exports, "__esModule", ({
5677 value: true
5678}));
5679exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0;
5680exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
5681const WaitOnType = {
5682 EVENT: "event",
5683 TIMEOUT: "timeout"
5684};
5685exports.WaitOnType = WaitOnType;
5686
5687function waitOnEventOrTimeout({
5688 target,
5689 name,
5690 delay = 0
5691}) {
5692 return new Promise(function (resolve, reject) {
5693 if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
5694 throw new Error("waitOnEventOrTimeout - invalid parameters.");
5695 }
5696
5697 function handler(type) {
5698 if (target instanceof EventBus) {
5699 target._off(name, eventHandler);
5700 } else {
5701 target.removeEventListener(name, eventHandler);
5702 }
5703
5704 if (timeout) {
5705 clearTimeout(timeout);
5706 }
5707
5708 resolve(type);
5709 }
5710
5711 const eventHandler = handler.bind(null, WaitOnType.EVENT);
5712
5713 if (target instanceof EventBus) {
5714 target._on(name, eventHandler);
5715 } else {
5716 target.addEventListener(name, eventHandler);
5717 }
5718
5719 const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
5720 const timeout = setTimeout(timeoutHandler, delay);
5721 });
5722}
5723
5724class EventBus {
5725 constructor() {
5726 this._listeners = Object.create(null);
5727 }
5728
5729 on(eventName, listener, options = null) {
5730 this._on(eventName, listener, {
5731 external: true,
5732 once: options?.once
5733 });
5734 }
5735
5736 off(eventName, listener, options = null) {
5737 this._off(eventName, listener, {
5738 external: true,
5739 once: options?.once
5740 });
5741 }
5742
5743 dispatch(eventName, data) {
5744 const eventListeners = this._listeners[eventName];
5745
5746 if (!eventListeners || eventListeners.length === 0) {
5747 return;
5748 }
5749
5750 let externalListeners;
5751
5752 for (const {
5753 listener,
5754 external,
5755 once
5756 } of eventListeners.slice(0)) {
5757 if (once) {
5758 this._off(eventName, listener);
5759 }
5760
5761 if (external) {
5762 (externalListeners ||= []).push(listener);
5763 continue;
5764 }
5765
5766 listener(data);
5767 }
5768
5769 if (externalListeners) {
5770 for (const listener of externalListeners) {
5771 listener(data);
5772 }
5773
5774 externalListeners = null;
5775 }
5776 }
5777
5778 _on(eventName, listener, options = null) {
5779 const eventListeners = this._listeners[eventName] ||= [];
5780 eventListeners.push({
5781 listener,
5782 external: options?.external === true,
5783 once: options?.once === true
5784 });
5785 }
5786
5787 _off(eventName, listener, options = null) {
5788 const eventListeners = this._listeners[eventName];
5789
5790 if (!eventListeners) {
5791 return;
5792 }
5793
5794 for (let i = 0, ii = eventListeners.length; i < ii; i++) {
5795 if (eventListeners[i].listener === listener) {
5796 eventListeners.splice(i, 1);
5797 return;
5798 }
5799 }
5800 }
5801
5802}
5803
5804exports.EventBus = EventBus;
5805
5806class AutomationEventBus extends EventBus {
5807 dispatch(eventName, data) {
5808 throw new Error("Not implemented: AutomationEventBus.dispatch");
5809 }
5810
5811}
5812
5813exports.AutomationEventBus = AutomationEventBus;
5814
5815/***/ }),
5816/* 19 */
5817/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
5818
5819
5820
5821Object.defineProperty(exports, "__esModule", ({
5822 value: true
5823}));
5824exports.GenericL10n = void 0;
5825
5826__w_pdfjs_require__(20);
5827
5828var _l10n_utils = __w_pdfjs_require__(4);
5829
5830const webL10n = document.webL10n;
5831
5832class GenericL10n {
5833 constructor(lang) {
5834 this._lang = lang;
5835 this._ready = new Promise((resolve, reject) => {
5836 webL10n.setLanguage((0, _l10n_utils.fixupLangCode)(lang), () => {
5837 resolve(webL10n);
5838 });
5839 });
5840 }
5841
5842 async getLanguage() {
5843 const l10n = await this._ready;
5844 return l10n.getLanguage();
5845 }
5846
5847 async getDirection() {
5848 const l10n = await this._ready;
5849 return l10n.getDirection();
5850 }
5851
5852 async get(key, args = null, fallback = (0, _l10n_utils.getL10nFallback)(key, args)) {
5853 const l10n = await this._ready;
5854 return l10n.get(key, args, fallback);
5855 }
5856
5857 async translate(element) {
5858 const l10n = await this._ready;
5859 return l10n.translate(element);
5860 }
5861
5862}
5863
5864exports.GenericL10n = GenericL10n;
5865
5866/***/ }),
5867/* 20 */
5868/***/ (() => {
5869
5870
5871
5872document.webL10n = function (window, document, undefined) {
5873 var gL10nData = {};
5874 var gTextData = '';
5875 var gTextProp = 'textContent';
5876 var gLanguage = '';
5877 var gMacros = {};
5878 var gReadyState = 'loading';
5879 var gAsyncResourceLoading = true;
5880
5881 function getL10nResourceLinks() {
5882 return document.querySelectorAll('link[type="application/l10n"]');
5883 }
5884
5885 function getL10nDictionary() {
5886 var script = document.querySelector('script[type="application/l10n"]');
5887 return script ? JSON.parse(script.innerHTML) : null;
5888 }
5889
5890 function getTranslatableChildren(element) {
5891 return element ? element.querySelectorAll('*[data-l10n-id]') : [];
5892 }
5893
5894 function getL10nAttributes(element) {
5895 if (!element) return {};
5896 var l10nId = element.getAttribute('data-l10n-id');
5897 var l10nArgs = element.getAttribute('data-l10n-args');
5898 var args = {};
5899
5900 if (l10nArgs) {
5901 try {
5902 args = JSON.parse(l10nArgs);
5903 } catch (e) {
5904 console.warn('could not parse arguments for #' + l10nId);
5905 }
5906 }
5907
5908 return {
5909 id: l10nId,
5910 args: args
5911 };
5912 }
5913
5914 function xhrLoadText(url, onSuccess, onFailure) {
5915 onSuccess = onSuccess || function _onSuccess(data) {};
5916
5917 onFailure = onFailure || function _onFailure() {};
5918
5919 var xhr = new XMLHttpRequest();
5920 xhr.open('GET', url, gAsyncResourceLoading);
5921
5922 if (xhr.overrideMimeType) {
5923 xhr.overrideMimeType('text/plain; charset=utf-8');
5924 }
5925
5926 xhr.onreadystatechange = function () {
5927 if (xhr.readyState == 4) {
5928 if (xhr.status == 200 || xhr.status === 0) {
5929 onSuccess(xhr.responseText);
5930 } else {
5931 onFailure();
5932 }
5933 }
5934 };
5935
5936 xhr.onerror = onFailure;
5937 xhr.ontimeout = onFailure;
5938
5939 try {
5940 xhr.send(null);
5941 } catch (e) {
5942 onFailure();
5943 }
5944 }
5945
5946 function parseResource(href, lang, successCallback, failureCallback) {
5947 var baseURL = href.replace(/[^\/]*$/, '') || './';
5948
5949 function evalString(text) {
5950 if (text.lastIndexOf('\\') < 0) return text;
5951 return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
5952 }
5953
5954 function parseProperties(text, parsedPropertiesCallback) {
5955 var dictionary = {};
5956 var reBlank = /^\s*|\s*$/;
5957 var reComment = /^\s*#|^\s*$/;
5958 var reSection = /^\s*\[(.*)\]\s*$/;
5959 var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
5960 var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
5961
5962 function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
5963 var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
5964 var currentLang = '*';
5965 var genericLang = lang.split('-', 1)[0];
5966 var skipLang = false;
5967 var match = '';
5968
5969 function nextEntry() {
5970 while (true) {
5971 if (!entries.length) {
5972 parsedRawLinesCallback();
5973 return;
5974 }
5975
5976 var line = entries.shift();
5977 if (reComment.test(line)) continue;
5978
5979 if (extendedSyntax) {
5980 match = reSection.exec(line);
5981
5982 if (match) {
5983 currentLang = match[1].toLowerCase();
5984 skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
5985 continue;
5986 } else if (skipLang) {
5987 continue;
5988 }
5989
5990 match = reImport.exec(line);
5991
5992 if (match) {
5993 loadImport(baseURL + match[1], nextEntry);
5994 return;
5995 }
5996 }
5997
5998 var tmp = line.match(reSplit);
5999
6000 if (tmp && tmp.length == 3) {
6001 dictionary[tmp[1]] = evalString(tmp[2]);
6002 }
6003 }
6004 }
6005
6006 nextEntry();
6007 }
6008
6009 function loadImport(url, callback) {
6010 xhrLoadText(url, function (content) {
6011 parseRawLines(content, false, callback);
6012 }, function () {
6013 console.warn(url + ' not found.');
6014 callback();
6015 });
6016 }
6017
6018 parseRawLines(text, true, function () {
6019 parsedPropertiesCallback(dictionary);
6020 });
6021 }
6022
6023 xhrLoadText(href, function (response) {
6024 gTextData += response;
6025 parseProperties(response, function (data) {
6026 for (var key in data) {
6027 var id,
6028 prop,
6029 index = key.lastIndexOf('.');
6030
6031 if (index > 0) {
6032 id = key.substring(0, index);
6033 prop = key.substring(index + 1);
6034 } else {
6035 id = key;
6036 prop = gTextProp;
6037 }
6038
6039 if (!gL10nData[id]) {
6040 gL10nData[id] = {};
6041 }
6042
6043 gL10nData[id][prop] = data[key];
6044 }
6045
6046 if (successCallback) {
6047 successCallback();
6048 }
6049 });
6050 }, failureCallback);
6051 }
6052
6053 function loadLocale(lang, callback) {
6054 if (lang) {
6055 lang = lang.toLowerCase();
6056 }
6057
6058 callback = callback || function _callback() {};
6059
6060 clear();
6061 gLanguage = lang;
6062 var langLinks = getL10nResourceLinks();
6063 var langCount = langLinks.length;
6064
6065 if (langCount === 0) {
6066 var dict = getL10nDictionary();
6067
6068 if (dict && dict.locales && dict.default_locale) {
6069 console.log('using the embedded JSON directory, early way out');
6070 gL10nData = dict.locales[lang];
6071
6072 if (!gL10nData) {
6073 var defaultLocale = dict.default_locale.toLowerCase();
6074
6075 for (var anyCaseLang in dict.locales) {
6076 anyCaseLang = anyCaseLang.toLowerCase();
6077
6078 if (anyCaseLang === lang) {
6079 gL10nData = dict.locales[lang];
6080 break;
6081 } else if (anyCaseLang === defaultLocale) {
6082 gL10nData = dict.locales[defaultLocale];
6083 }
6084 }
6085 }
6086
6087 callback();
6088 } else {
6089 console.log('no resource to load, early way out');
6090 }
6091
6092 gReadyState = 'complete';
6093 return;
6094 }
6095
6096 var onResourceLoaded = null;
6097 var gResourceCount = 0;
6098
6099 onResourceLoaded = function () {
6100 gResourceCount++;
6101
6102 if (gResourceCount >= langCount) {
6103 callback();
6104 gReadyState = 'complete';
6105 }
6106 };
6107
6108 function L10nResourceLink(link) {
6109 var href = link.href;
6110
6111 this.load = function (lang, callback) {
6112 parseResource(href, lang, callback, function () {
6113 console.warn(href + ' not found.');
6114 console.warn('"' + lang + '" resource not found');
6115 gLanguage = '';
6116 callback();
6117 });
6118 };
6119 }
6120
6121 for (var i = 0; i < langCount; i++) {
6122 var resource = new L10nResourceLink(langLinks[i]);
6123 resource.load(lang, onResourceLoaded);
6124 }
6125 }
6126
6127 function clear() {
6128 gL10nData = {};
6129 gTextData = '';
6130 gLanguage = '';
6131 }
6132
6133 function getPluralRules(lang) {
6134 var locales2rules = {
6135 'af': 3,
6136 'ak': 4,
6137 'am': 4,
6138 'ar': 1,
6139 'asa': 3,
6140 'az': 0,
6141 'be': 11,
6142 'bem': 3,
6143 'bez': 3,
6144 'bg': 3,
6145 'bh': 4,
6146 'bm': 0,
6147 'bn': 3,
6148 'bo': 0,
6149 'br': 20,
6150 'brx': 3,
6151 'bs': 11,
6152 'ca': 3,
6153 'cgg': 3,
6154 'chr': 3,
6155 'cs': 12,
6156 'cy': 17,
6157 'da': 3,
6158 'de': 3,
6159 'dv': 3,
6160 'dz': 0,
6161 'ee': 3,
6162 'el': 3,
6163 'en': 3,
6164 'eo': 3,
6165 'es': 3,
6166 'et': 3,
6167 'eu': 3,
6168 'fa': 0,
6169 'ff': 5,
6170 'fi': 3,
6171 'fil': 4,
6172 'fo': 3,
6173 'fr': 5,
6174 'fur': 3,
6175 'fy': 3,
6176 'ga': 8,
6177 'gd': 24,
6178 'gl': 3,
6179 'gsw': 3,
6180 'gu': 3,
6181 'guw': 4,
6182 'gv': 23,
6183 'ha': 3,
6184 'haw': 3,
6185 'he': 2,
6186 'hi': 4,
6187 'hr': 11,
6188 'hu': 0,
6189 'id': 0,
6190 'ig': 0,
6191 'ii': 0,
6192 'is': 3,
6193 'it': 3,
6194 'iu': 7,
6195 'ja': 0,
6196 'jmc': 3,
6197 'jv': 0,
6198 'ka': 0,
6199 'kab': 5,
6200 'kaj': 3,
6201 'kcg': 3,
6202 'kde': 0,
6203 'kea': 0,
6204 'kk': 3,
6205 'kl': 3,
6206 'km': 0,
6207 'kn': 0,
6208 'ko': 0,
6209 'ksb': 3,
6210 'ksh': 21,
6211 'ku': 3,
6212 'kw': 7,
6213 'lag': 18,
6214 'lb': 3,
6215 'lg': 3,
6216 'ln': 4,
6217 'lo': 0,
6218 'lt': 10,
6219 'lv': 6,
6220 'mas': 3,
6221 'mg': 4,
6222 'mk': 16,
6223 'ml': 3,
6224 'mn': 3,
6225 'mo': 9,
6226 'mr': 3,
6227 'ms': 0,
6228 'mt': 15,
6229 'my': 0,
6230 'nah': 3,
6231 'naq': 7,
6232 'nb': 3,
6233 'nd': 3,
6234 'ne': 3,
6235 'nl': 3,
6236 'nn': 3,
6237 'no': 3,
6238 'nr': 3,
6239 'nso': 4,
6240 'ny': 3,
6241 'nyn': 3,
6242 'om': 3,
6243 'or': 3,
6244 'pa': 3,
6245 'pap': 3,
6246 'pl': 13,
6247 'ps': 3,
6248 'pt': 3,
6249 'rm': 3,
6250 'ro': 9,
6251 'rof': 3,
6252 'ru': 11,
6253 'rwk': 3,
6254 'sah': 0,
6255 'saq': 3,
6256 'se': 7,
6257 'seh': 3,
6258 'ses': 0,
6259 'sg': 0,
6260 'sh': 11,
6261 'shi': 19,
6262 'sk': 12,
6263 'sl': 14,
6264 'sma': 7,
6265 'smi': 7,
6266 'smj': 7,
6267 'smn': 7,
6268 'sms': 7,
6269 'sn': 3,
6270 'so': 3,
6271 'sq': 3,
6272 'sr': 11,
6273 'ss': 3,
6274 'ssy': 3,
6275 'st': 3,
6276 'sv': 3,
6277 'sw': 3,
6278 'syr': 3,
6279 'ta': 3,
6280 'te': 3,
6281 'teo': 3,
6282 'th': 0,
6283 'ti': 4,
6284 'tig': 3,
6285 'tk': 3,
6286 'tl': 4,
6287 'tn': 3,
6288 'to': 0,
6289 'tr': 0,
6290 'ts': 3,
6291 'tzm': 22,
6292 'uk': 11,
6293 'ur': 3,
6294 've': 3,
6295 'vi': 0,
6296 'vun': 3,
6297 'wa': 4,
6298 'wae': 3,
6299 'wo': 0,
6300 'xh': 3,
6301 'xog': 3,
6302 'yo': 0,
6303 'zh': 0,
6304 'zu': 3
6305 };
6306
6307 function isIn(n, list) {
6308 return list.indexOf(n) !== -1;
6309 }
6310
6311 function isBetween(n, start, end) {
6312 return start <= n && n <= end;
6313 }
6314
6315 var pluralRules = {
6316 '0': function (n) {
6317 return 'other';
6318 },
6319 '1': function (n) {
6320 if (isBetween(n % 100, 3, 10)) return 'few';
6321 if (n === 0) return 'zero';
6322 if (isBetween(n % 100, 11, 99)) return 'many';
6323 if (n == 2) return 'two';
6324 if (n == 1) return 'one';
6325 return 'other';
6326 },
6327 '2': function (n) {
6328 if (n !== 0 && n % 10 === 0) return 'many';
6329 if (n == 2) return 'two';
6330 if (n == 1) return 'one';
6331 return 'other';
6332 },
6333 '3': function (n) {
6334 if (n == 1) return 'one';
6335 return 'other';
6336 },
6337 '4': function (n) {
6338 if (isBetween(n, 0, 1)) return 'one';
6339 return 'other';
6340 },
6341 '5': function (n) {
6342 if (isBetween(n, 0, 2) && n != 2) return 'one';
6343 return 'other';
6344 },
6345 '6': function (n) {
6346 if (n === 0) return 'zero';
6347 if (n % 10 == 1 && n % 100 != 11) return 'one';
6348 return 'other';
6349 },
6350 '7': function (n) {
6351 if (n == 2) return 'two';
6352 if (n == 1) return 'one';
6353 return 'other';
6354 },
6355 '8': function (n) {
6356 if (isBetween(n, 3, 6)) return 'few';
6357 if (isBetween(n, 7, 10)) return 'many';
6358 if (n == 2) return 'two';
6359 if (n == 1) return 'one';
6360 return 'other';
6361 },
6362 '9': function (n) {
6363 if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
6364 if (n == 1) return 'one';
6365 return 'other';
6366 },
6367 '10': function (n) {
6368 if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
6369 if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
6370 return 'other';
6371 },
6372 '11': function (n) {
6373 if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
6374 if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
6375 if (n % 10 == 1 && n % 100 != 11) return 'one';
6376 return 'other';
6377 },
6378 '12': function (n) {
6379 if (isBetween(n, 2, 4)) return 'few';
6380 if (n == 1) return 'one';
6381 return 'other';
6382 },
6383 '13': function (n) {
6384 if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
6385 if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
6386 if (n == 1) return 'one';
6387 return 'other';
6388 },
6389 '14': function (n) {
6390 if (isBetween(n % 100, 3, 4)) return 'few';
6391 if (n % 100 == 2) return 'two';
6392 if (n % 100 == 1) return 'one';
6393 return 'other';
6394 },
6395 '15': function (n) {
6396 if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
6397 if (isBetween(n % 100, 11, 19)) return 'many';
6398 if (n == 1) return 'one';
6399 return 'other';
6400 },
6401 '16': function (n) {
6402 if (n % 10 == 1 && n != 11) return 'one';
6403 return 'other';
6404 },
6405 '17': function (n) {
6406 if (n == 3) return 'few';
6407 if (n === 0) return 'zero';
6408 if (n == 6) return 'many';
6409 if (n == 2) return 'two';
6410 if (n == 1) return 'one';
6411 return 'other';
6412 },
6413 '18': function (n) {
6414 if (n === 0) return 'zero';
6415 if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
6416 return 'other';
6417 },
6418 '19': function (n) {
6419 if (isBetween(n, 2, 10)) return 'few';
6420 if (isBetween(n, 0, 1)) return 'one';
6421 return 'other';
6422 },
6423 '20': function (n) {
6424 if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
6425 if (n % 1000000 === 0 && n !== 0) return 'many';
6426 if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
6427 if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
6428 return 'other';
6429 },
6430 '21': function (n) {
6431 if (n === 0) return 'zero';
6432 if (n == 1) return 'one';
6433 return 'other';
6434 },
6435 '22': function (n) {
6436 if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
6437 return 'other';
6438 },
6439 '23': function (n) {
6440 if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
6441 return 'other';
6442 },
6443 '24': function (n) {
6444 if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
6445 if (isIn(n, [2, 12])) return 'two';
6446 if (isIn(n, [1, 11])) return 'one';
6447 return 'other';
6448 }
6449 };
6450 var index = locales2rules[lang.replace(/-.*$/, '')];
6451
6452 if (!(index in pluralRules)) {
6453 console.warn('plural form unknown for [' + lang + ']');
6454 return function () {
6455 return 'other';
6456 };
6457 }
6458
6459 return pluralRules[index];
6460 }
6461
6462 gMacros.plural = function (str, param, key, prop) {
6463 var n = parseFloat(param);
6464 if (isNaN(n)) return str;
6465 if (prop != gTextProp) return str;
6466
6467 if (!gMacros._pluralRules) {
6468 gMacros._pluralRules = getPluralRules(gLanguage);
6469 }
6470
6471 var index = '[' + gMacros._pluralRules(n) + ']';
6472
6473 if (n === 0 && key + '[zero]' in gL10nData) {
6474 str = gL10nData[key + '[zero]'][prop];
6475 } else if (n == 1 && key + '[one]' in gL10nData) {
6476 str = gL10nData[key + '[one]'][prop];
6477 } else if (n == 2 && key + '[two]' in gL10nData) {
6478 str = gL10nData[key + '[two]'][prop];
6479 } else if (key + index in gL10nData) {
6480 str = gL10nData[key + index][prop];
6481 } else if (key + '[other]' in gL10nData) {
6482 str = gL10nData[key + '[other]'][prop];
6483 }
6484
6485 return str;
6486 };
6487
6488 function getL10nData(key, args, fallback) {
6489 var data = gL10nData[key];
6490
6491 if (!data) {
6492 console.warn('#' + key + ' is undefined.');
6493
6494 if (!fallback) {
6495 return null;
6496 }
6497
6498 data = fallback;
6499 }
6500
6501 var rv = {};
6502
6503 for (var prop in data) {
6504 var str = data[prop];
6505 str = substIndexes(str, args, key, prop);
6506 str = substArguments(str, args, key);
6507 rv[prop] = str;
6508 }
6509
6510 return rv;
6511 }
6512
6513 function substIndexes(str, args, key, prop) {
6514 var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
6515 var reMatch = reIndex.exec(str);
6516 if (!reMatch || !reMatch.length) return str;
6517 var macroName = reMatch[1];
6518 var paramName = reMatch[2];
6519 var param;
6520
6521 if (args && paramName in args) {
6522 param = args[paramName];
6523 } else if (paramName in gL10nData) {
6524 param = gL10nData[paramName];
6525 }
6526
6527 if (macroName in gMacros) {
6528 var macro = gMacros[macroName];
6529 str = macro(str, param, key, prop);
6530 }
6531
6532 return str;
6533 }
6534
6535 function substArguments(str, args, key) {
6536 var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
6537 return str.replace(reArgs, function (matched_text, arg) {
6538 if (args && arg in args) {
6539 return args[arg];
6540 }
6541
6542 if (arg in gL10nData) {
6543 return gL10nData[arg];
6544 }
6545
6546 console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
6547 return matched_text;
6548 });
6549 }
6550
6551 function translateElement(element) {
6552 var l10n = getL10nAttributes(element);
6553 if (!l10n.id) return;
6554 var data = getL10nData(l10n.id, l10n.args);
6555
6556 if (!data) {
6557 console.warn('#' + l10n.id + ' is undefined.');
6558 return;
6559 }
6560
6561 if (data[gTextProp]) {
6562 if (getChildElementCount(element) === 0) {
6563 element[gTextProp] = data[gTextProp];
6564 } else {
6565 var children = element.childNodes;
6566 var found = false;
6567
6568 for (var i = 0, l = children.length; i < l; i++) {
6569 if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
6570 if (found) {
6571 children[i].nodeValue = '';
6572 } else {
6573 children[i].nodeValue = data[gTextProp];
6574 found = true;
6575 }
6576 }
6577 }
6578
6579 if (!found) {
6580 var textNode = document.createTextNode(data[gTextProp]);
6581 element.prepend(textNode);
6582 }
6583 }
6584
6585 delete data[gTextProp];
6586 }
6587
6588 for (var k in data) {
6589 element[k] = data[k];
6590 }
6591 }
6592
6593 function getChildElementCount(element) {
6594 if (element.children) {
6595 return element.children.length;
6596 }
6597
6598 if (typeof element.childElementCount !== 'undefined') {
6599 return element.childElementCount;
6600 }
6601
6602 var count = 0;
6603
6604 for (var i = 0; i < element.childNodes.length; i++) {
6605 count += element.nodeType === 1 ? 1 : 0;
6606 }
6607
6608 return count;
6609 }
6610
6611 function translateFragment(element) {
6612 element = element || document.documentElement;
6613 var children = getTranslatableChildren(element);
6614 var elementCount = children.length;
6615
6616 for (var i = 0; i < elementCount; i++) {
6617 translateElement(children[i]);
6618 }
6619
6620 translateElement(element);
6621 }
6622
6623 return {
6624 get: function (key, args, fallbackString) {
6625 var index = key.lastIndexOf('.');
6626 var prop = gTextProp;
6627
6628 if (index > 0) {
6629 prop = key.substring(index + 1);
6630 key = key.substring(0, index);
6631 }
6632
6633 var fallback;
6634
6635 if (fallbackString) {
6636 fallback = {};
6637 fallback[prop] = fallbackString;
6638 }
6639
6640 var data = getL10nData(key, args, fallback);
6641
6642 if (data && prop in data) {
6643 return data[prop];
6644 }
6645
6646 return '{{' + key + '}}';
6647 },
6648 getData: function () {
6649 return gL10nData;
6650 },
6651 getText: function () {
6652 return gTextData;
6653 },
6654 getLanguage: function () {
6655 return gLanguage;
6656 },
6657 setLanguage: function (lang, callback) {
6658 loadLocale(lang, function () {
6659 if (callback) callback();
6660 });
6661 },
6662 getDirection: function () {
6663 var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
6664 var shortCode = gLanguage.split('-', 1)[0];
6665 return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
6666 },
6667 translate: translateFragment,
6668 getReadyState: function () {
6669 return gReadyState;
6670 },
6671 ready: function (callback) {
6672 if (!callback) {
6673 return;
6674 } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
6675 window.setTimeout(function () {
6676 callback();
6677 });
6678 } else if (document.addEventListener) {
6679 document.addEventListener('localized', function once() {
6680 document.removeEventListener('localized', once);
6681 callback();
6682 });
6683 }
6684 }
6685 };
6686}(window, document);
6687
6688/***/ }),
6689/* 21 */
6690/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
6691
6692
6693
6694Object.defineProperty(exports, "__esModule", ({
6695 value: true
6696}));
6697exports.PDFFindController = exports.FindState = void 0;
6698
6699var _pdfjsLib = __w_pdfjs_require__(3);
6700
6701var _pdf_find_utils = __w_pdfjs_require__(22);
6702
6703var _ui_utils = __w_pdfjs_require__(7);
6704
6705const FindState = {
6706 FOUND: 0,
6707 NOT_FOUND: 1,
6708 WRAPPED: 2,
6709 PENDING: 3
6710};
6711exports.FindState = FindState;
6712const FIND_TIMEOUT = 250;
6713const MATCH_SCROLL_OFFSET_TOP = -50;
6714const MATCH_SCROLL_OFFSET_LEFT = -400;
6715const CHARACTERS_TO_NORMALIZE = {
6716 "\u2010": "-",
6717 "\u2018": "'",
6718 "\u2019": "'",
6719 "\u201A": "'",
6720 "\u201B": "'",
6721 "\u201C": '"',
6722 "\u201D": '"',
6723 "\u201E": '"',
6724 "\u201F": '"',
6725 "\u00BC": "1/4",
6726 "\u00BD": "1/2",
6727 "\u00BE": "3/4"
6728};
6729const DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd, 0x0b4d, 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba, 0x0f84, 0x1039, 0x103a, 0x1714, 0x1734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab, 0x1bf2, 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed, 0x0c56, 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74]);
6730const DIACRITICS_EXCEPTION_STR = [...DIACRITICS_EXCEPTION.values()].map(x => String.fromCharCode(x)).join("");
6731const DIACRITICS_REG_EXP = /\p{M}+/gu;
6732const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
6733const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
6734const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
6735const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
6736const SYLLABLES_LENGTHS = new Map();
6737const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
6738let noSyllablesRegExp = null;
6739let withSyllablesRegExp = null;
6740
6741function normalize(text) {
6742 const syllablePositions = [];
6743 let m;
6744
6745 while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
6746 let {
6747 index
6748 } = m;
6749
6750 for (const char of m[0]) {
6751 let len = SYLLABLES_LENGTHS.get(char);
6752
6753 if (!len) {
6754 len = char.normalize("NFD").length;
6755 SYLLABLES_LENGTHS.set(char, len);
6756 }
6757
6758 syllablePositions.push([len, index++]);
6759 }
6760 }
6761
6762 let normalizationRegex;
6763
6764 if (syllablePositions.length === 0 && noSyllablesRegExp) {
6765 normalizationRegex = noSyllablesRegExp;
6766 } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
6767 normalizationRegex = withSyllablesRegExp;
6768 } else {
6769 const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
6770 const regexp = `([${replace}])|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(\\n)`;
6771
6772 if (syllablePositions.length === 0) {
6773 normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
6774 } else {
6775 normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
6776 }
6777 }
6778
6779 const rawDiacriticsPositions = [];
6780
6781 while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
6782 rawDiacriticsPositions.push([m[0].length, m.index]);
6783 }
6784
6785 let normalized = text.normalize("NFD");
6786 const positions = [[0, 0]];
6787 let rawDiacriticsIndex = 0;
6788 let syllableIndex = 0;
6789 let shift = 0;
6790 let shiftOrigin = 0;
6791 let eol = 0;
6792 let hasDiacritics = false;
6793 normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, i) => {
6794 i -= shiftOrigin;
6795
6796 if (p1) {
6797 const replacement = CHARACTERS_TO_NORMALIZE[match];
6798 const jj = replacement.length;
6799
6800 for (let j = 1; j < jj; j++) {
6801 positions.push([i - shift + j, shift - j]);
6802 }
6803
6804 shift -= jj - 1;
6805 return replacement;
6806 }
6807
6808 if (p2) {
6809 const hasTrailingDashEOL = p2.endsWith("\n");
6810 const len = hasTrailingDashEOL ? p2.length - 2 : p2.length;
6811 hasDiacritics = true;
6812 let jj = len;
6813
6814 if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
6815 jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
6816 ++rawDiacriticsIndex;
6817 }
6818
6819 for (let j = 1; j <= jj; j++) {
6820 positions.push([i - 1 - shift + j, shift - j]);
6821 }
6822
6823 shift -= jj;
6824 shiftOrigin += jj;
6825
6826 if (hasTrailingDashEOL) {
6827 i += len - 1;
6828 positions.push([i - shift + 1, 1 + shift]);
6829 shift += 1;
6830 shiftOrigin += 1;
6831 eol += 1;
6832 return p2.slice(0, len);
6833 }
6834
6835 return p2;
6836 }
6837
6838 if (p3) {
6839 positions.push([i - shift + 1, 1 + shift]);
6840 shift += 1;
6841 shiftOrigin += 1;
6842 eol += 1;
6843 return p3.charAt(0);
6844 }
6845
6846 if (p4) {
6847 positions.push([i - shift + 1, shift - 1]);
6848 shift -= 1;
6849 shiftOrigin += 1;
6850 eol += 1;
6851 return " ";
6852 }
6853
6854 if (i + eol === syllablePositions[syllableIndex]?.[1]) {
6855 const newCharLen = syllablePositions[syllableIndex][0] - 1;
6856 ++syllableIndex;
6857
6858 for (let j = 1; j <= newCharLen; j++) {
6859 positions.push([i - (shift - j), shift - j]);
6860 }
6861
6862 shift -= newCharLen;
6863 shiftOrigin += newCharLen;
6864 }
6865
6866 return p5;
6867 });
6868 positions.push([normalized.length, shift]);
6869 return [normalized, positions, hasDiacritics];
6870}
6871
6872function getOriginalIndex(diffs, pos, len) {
6873 if (!diffs) {
6874 return [pos, len];
6875 }
6876
6877 const start = pos;
6878 const end = pos + len;
6879 let i = (0, _pdfjsLib.binarySearchFirstItem)(diffs, x => x[0] >= start);
6880
6881 if (diffs[i][0] > start) {
6882 --i;
6883 }
6884
6885 let j = (0, _pdfjsLib.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
6886
6887 if (diffs[j][0] > end) {
6888 --j;
6889 }
6890
6891 return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]];
6892}
6893
6894class PDFFindController {
6895 constructor({
6896 linkService,
6897 eventBus
6898 }) {
6899 this._linkService = linkService;
6900 this._eventBus = eventBus;
6901 this.#reset();
6902
6903 eventBus._on("find", this.#onFind.bind(this));
6904
6905 eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
6906 }
6907
6908 get highlightMatches() {
6909 return this._highlightMatches;
6910 }
6911
6912 get pageMatches() {
6913 return this._pageMatches;
6914 }
6915
6916 get pageMatchesLength() {
6917 return this._pageMatchesLength;
6918 }
6919
6920 get selected() {
6921 return this._selected;
6922 }
6923
6924 get state() {
6925 return this._state;
6926 }
6927
6928 setDocument(pdfDocument) {
6929 if (this._pdfDocument) {
6930 this.#reset();
6931 }
6932
6933 if (!pdfDocument) {
6934 return;
6935 }
6936
6937 this._pdfDocument = pdfDocument;
6938
6939 this._firstPageCapability.resolve();
6940 }
6941
6942 #onFind(state) {
6943 if (!state) {
6944 return;
6945 }
6946
6947 const pdfDocument = this._pdfDocument;
6948 const {
6949 type
6950 } = state;
6951
6952 if (this._state === null || this.#shouldDirtyMatch(state)) {
6953 this._dirtyMatch = true;
6954 }
6955
6956 this._state = state;
6957
6958 if (type !== "highlightallchange") {
6959 this.#updateUIState(FindState.PENDING);
6960 }
6961
6962 this._firstPageCapability.promise.then(() => {
6963 if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
6964 return;
6965 }
6966
6967 this.#extractText();
6968 const findbarClosed = !this._highlightMatches;
6969 const pendingTimeout = !!this._findTimeout;
6970
6971 if (this._findTimeout) {
6972 clearTimeout(this._findTimeout);
6973 this._findTimeout = null;
6974 }
6975
6976 if (!type) {
6977 this._findTimeout = setTimeout(() => {
6978 this.#nextMatch();
6979 this._findTimeout = null;
6980 }, FIND_TIMEOUT);
6981 } else if (this._dirtyMatch) {
6982 this.#nextMatch();
6983 } else if (type === "again") {
6984 this.#nextMatch();
6985
6986 if (findbarClosed && this._state.highlightAll) {
6987 this.#updateAllPages();
6988 }
6989 } else if (type === "highlightallchange") {
6990 if (pendingTimeout) {
6991 this.#nextMatch();
6992 } else {
6993 this._highlightMatches = true;
6994 }
6995
6996 this.#updateAllPages();
6997 } else {
6998 this.#nextMatch();
6999 }
7000 });
7001 }
7002
7003 scrollMatchIntoView({
7004 element = null,
7005 selectedLeft = 0,
7006 pageIndex = -1,
7007 matchIndex = -1
7008 }) {
7009 if (!this._scrollMatches || !element) {
7010 return;
7011 } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
7012 return;
7013 } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
7014 return;
7015 }
7016
7017 this._scrollMatches = false;
7018 const spot = {
7019 top: MATCH_SCROLL_OFFSET_TOP,
7020 left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
7021 };
7022 (0, _ui_utils.scrollIntoView)(element, spot, true);
7023 }
7024
7025 #reset() {
7026 this._highlightMatches = false;
7027 this._scrollMatches = false;
7028 this._pdfDocument = null;
7029 this._pageMatches = [];
7030 this._pageMatchesLength = [];
7031 this._state = null;
7032 this._selected = {
7033 pageIdx: -1,
7034 matchIdx: -1
7035 };
7036 this._offset = {
7037 pageIdx: null,
7038 matchIdx: null,
7039 wrapped: false
7040 };
7041 this._extractTextPromises = [];
7042 this._pageContents = [];
7043 this._pageDiffs = [];
7044 this._hasDiacritics = [];
7045 this._matchesCountTotal = 0;
7046 this._pagesToSearch = null;
7047 this._pendingFindMatches = new Set();
7048 this._resumePageIdx = null;
7049 this._dirtyMatch = false;
7050 clearTimeout(this._findTimeout);
7051 this._findTimeout = null;
7052 this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
7053 }
7054
7055 get #query() {
7056 if (this._state.query !== this._rawQuery) {
7057 this._rawQuery = this._state.query;
7058 [this._normalizedQuery] = normalize(this._state.query);
7059 }
7060
7061 return this._normalizedQuery;
7062 }
7063
7064 #shouldDirtyMatch(state) {
7065 if (state.query !== this._state.query) {
7066 return true;
7067 }
7068
7069 switch (state.type) {
7070 case "again":
7071 const pageNumber = this._selected.pageIdx + 1;
7072 const linkService = this._linkService;
7073
7074 if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
7075 return true;
7076 }
7077
7078 return false;
7079
7080 case "highlightallchange":
7081 return false;
7082 }
7083
7084 return true;
7085 }
7086
7087 #isEntireWord(content, startIdx, length) {
7088 let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
7089
7090 if (match) {
7091 const first = content.charCodeAt(startIdx);
7092 const limit = match[1].charCodeAt(0);
7093
7094 if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
7095 return false;
7096 }
7097 }
7098
7099 match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
7100
7101 if (match) {
7102 const last = content.charCodeAt(startIdx + length - 1);
7103 const limit = match[1].charCodeAt(0);
7104
7105 if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) {
7106 return false;
7107 }
7108 }
7109
7110 return true;
7111 }
7112
7113 #calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
7114 const matches = [],
7115 matchesLength = [];
7116 const diffs = this._pageDiffs[pageIndex];
7117 let match;
7118
7119 while ((match = query.exec(pageContent)) !== null) {
7120 if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
7121 continue;
7122 }
7123
7124 const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
7125
7126 if (matchLen) {
7127 matches.push(matchPos);
7128 matchesLength.push(matchLen);
7129 }
7130 }
7131
7132 this._pageMatches[pageIndex] = matches;
7133 this._pageMatchesLength[pageIndex] = matchesLength;
7134 }
7135
7136 #convertToRegExpString(query, hasDiacritics) {
7137 const {
7138 matchDiacritics
7139 } = this._state;
7140 let isUnicode = false;
7141 query = query.replace(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
7142 if (p1) {
7143 return `[ ]*\\${p1}[ ]*`;
7144 }
7145
7146 if (p2) {
7147 return `[ ]*${p2}[ ]*`;
7148 }
7149
7150 if (p3) {
7151 return "[ ]+";
7152 }
7153
7154 if (matchDiacritics) {
7155 return p4 || p5;
7156 }
7157
7158 if (p4) {
7159 return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
7160 }
7161
7162 if (hasDiacritics) {
7163 isUnicode = true;
7164 return `${p5}\\p{M}*`;
7165 }
7166
7167 return p5;
7168 });
7169 const trailingSpaces = "[ ]*";
7170
7171 if (query.endsWith(trailingSpaces)) {
7172 query = query.slice(0, query.length - trailingSpaces.length);
7173 }
7174
7175 if (matchDiacritics) {
7176 if (hasDiacritics) {
7177 isUnicode = true;
7178 query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
7179 }
7180 }
7181
7182 return [isUnicode, query];
7183 }
7184
7185 #calculateMatch(pageIndex) {
7186 let query = this.#query;
7187
7188 if (query.length === 0) {
7189 return;
7190 }
7191
7192 const {
7193 caseSensitive,
7194 entireWord,
7195 phraseSearch
7196 } = this._state;
7197 const pageContent = this._pageContents[pageIndex];
7198 const hasDiacritics = this._hasDiacritics[pageIndex];
7199 let isUnicode = false;
7200
7201 if (phraseSearch) {
7202 [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
7203 } else {
7204 const match = query.match(/\S+/g);
7205
7206 if (match) {
7207 query = match.sort().reverse().map(q => {
7208 const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
7209 isUnicode ||= isUnicodePart;
7210 return `(${queryPart})`;
7211 }).join("|");
7212 }
7213 }
7214
7215 const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
7216 query = new RegExp(query, flags);
7217 this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
7218
7219 if (this._state.highlightAll) {
7220 this.#updatePage(pageIndex);
7221 }
7222
7223 if (this._resumePageIdx === pageIndex) {
7224 this._resumePageIdx = null;
7225 this.#nextPageMatch();
7226 }
7227
7228 const pageMatchesCount = this._pageMatches[pageIndex].length;
7229
7230 if (pageMatchesCount > 0) {
7231 this._matchesCountTotal += pageMatchesCount;
7232 this.#updateUIResultsCount();
7233 }
7234 }
7235
7236 #extractText() {
7237 if (this._extractTextPromises.length > 0) {
7238 return;
7239 }
7240
7241 let promise = Promise.resolve();
7242
7243 for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
7244 const extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
7245 this._extractTextPromises[i] = extractTextCapability.promise;
7246 promise = promise.then(() => {
7247 return this._pdfDocument.getPage(i + 1).then(pdfPage => {
7248 return pdfPage.getTextContent();
7249 }).then(textContent => {
7250 const strBuf = [];
7251
7252 for (const textItem of textContent.items) {
7253 strBuf.push(textItem.str);
7254
7255 if (textItem.hasEOL) {
7256 strBuf.push("\n");
7257 }
7258 }
7259
7260 [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
7261 extractTextCapability.resolve();
7262 }, reason => {
7263 console.error(`Unable to get text content for page ${i + 1}`, reason);
7264 this._pageContents[i] = "";
7265 this._pageDiffs[i] = null;
7266 this._hasDiacritics[i] = false;
7267 extractTextCapability.resolve();
7268 });
7269 });
7270 }
7271 }
7272
7273 #updatePage(index) {
7274 if (this._scrollMatches && this._selected.pageIdx === index) {
7275 this._linkService.page = index + 1;
7276 }
7277
7278 this._eventBus.dispatch("updatetextlayermatches", {
7279 source: this,
7280 pageIndex: index
7281 });
7282 }
7283
7284 #updateAllPages() {
7285 this._eventBus.dispatch("updatetextlayermatches", {
7286 source: this,
7287 pageIndex: -1
7288 });
7289 }
7290
7291 #nextMatch() {
7292 const previous = this._state.findPrevious;
7293 const currentPageIndex = this._linkService.page - 1;
7294 const numPages = this._linkService.pagesCount;
7295 this._highlightMatches = true;
7296
7297 if (this._dirtyMatch) {
7298 this._dirtyMatch = false;
7299 this._selected.pageIdx = this._selected.matchIdx = -1;
7300 this._offset.pageIdx = currentPageIndex;
7301 this._offset.matchIdx = null;
7302 this._offset.wrapped = false;
7303 this._resumePageIdx = null;
7304 this._pageMatches.length = 0;
7305 this._pageMatchesLength.length = 0;
7306 this._matchesCountTotal = 0;
7307 this.#updateAllPages();
7308
7309 for (let i = 0; i < numPages; i++) {
7310 if (this._pendingFindMatches.has(i)) {
7311 continue;
7312 }
7313
7314 this._pendingFindMatches.add(i);
7315
7316 this._extractTextPromises[i].then(() => {
7317 this._pendingFindMatches.delete(i);
7318
7319 this.#calculateMatch(i);
7320 });
7321 }
7322 }
7323
7324 if (this.#query === "") {
7325 this.#updateUIState(FindState.FOUND);
7326 return;
7327 }
7328
7329 if (this._resumePageIdx) {
7330 return;
7331 }
7332
7333 const offset = this._offset;
7334 this._pagesToSearch = numPages;
7335
7336 if (offset.matchIdx !== null) {
7337 const numPageMatches = this._pageMatches[offset.pageIdx].length;
7338
7339 if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
7340 offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
7341 this.#updateMatch(true);
7342 return;
7343 }
7344
7345 this.#advanceOffsetPage(previous);
7346 }
7347
7348 this.#nextPageMatch();
7349 }
7350
7351 #matchesReady(matches) {
7352 const offset = this._offset;
7353 const numMatches = matches.length;
7354 const previous = this._state.findPrevious;
7355
7356 if (numMatches) {
7357 offset.matchIdx = previous ? numMatches - 1 : 0;
7358 this.#updateMatch(true);
7359 return true;
7360 }
7361
7362 this.#advanceOffsetPage(previous);
7363
7364 if (offset.wrapped) {
7365 offset.matchIdx = null;
7366
7367 if (this._pagesToSearch < 0) {
7368 this.#updateMatch(false);
7369 return true;
7370 }
7371 }
7372
7373 return false;
7374 }
7375
7376 #nextPageMatch() {
7377 if (this._resumePageIdx !== null) {
7378 console.error("There can only be one pending page.");
7379 }
7380
7381 let matches = null;
7382
7383 do {
7384 const pageIdx = this._offset.pageIdx;
7385 matches = this._pageMatches[pageIdx];
7386
7387 if (!matches) {
7388 this._resumePageIdx = pageIdx;
7389 break;
7390 }
7391 } while (!this.#matchesReady(matches));
7392 }
7393
7394 #advanceOffsetPage(previous) {
7395 const offset = this._offset;
7396 const numPages = this._linkService.pagesCount;
7397 offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
7398 offset.matchIdx = null;
7399 this._pagesToSearch--;
7400
7401 if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
7402 offset.pageIdx = previous ? numPages - 1 : 0;
7403 offset.wrapped = true;
7404 }
7405 }
7406
7407 #updateMatch(found = false) {
7408 let state = FindState.NOT_FOUND;
7409 const wrapped = this._offset.wrapped;
7410 this._offset.wrapped = false;
7411
7412 if (found) {
7413 const previousPage = this._selected.pageIdx;
7414 this._selected.pageIdx = this._offset.pageIdx;
7415 this._selected.matchIdx = this._offset.matchIdx;
7416 state = wrapped ? FindState.WRAPPED : FindState.FOUND;
7417
7418 if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
7419 this.#updatePage(previousPage);
7420 }
7421 }
7422
7423 this.#updateUIState(state, this._state.findPrevious);
7424
7425 if (this._selected.pageIdx !== -1) {
7426 this._scrollMatches = true;
7427 this.#updatePage(this._selected.pageIdx);
7428 }
7429 }
7430
7431 #onFindBarClose(evt) {
7432 const pdfDocument = this._pdfDocument;
7433
7434 this._firstPageCapability.promise.then(() => {
7435 if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
7436 return;
7437 }
7438
7439 if (this._findTimeout) {
7440 clearTimeout(this._findTimeout);
7441 this._findTimeout = null;
7442 }
7443
7444 if (this._resumePageIdx) {
7445 this._resumePageIdx = null;
7446 this._dirtyMatch = true;
7447 }
7448
7449 this.#updateUIState(FindState.FOUND);
7450 this._highlightMatches = false;
7451 this.#updateAllPages();
7452 });
7453 }
7454
7455 #requestMatchesCount() {
7456 const {
7457 pageIdx,
7458 matchIdx
7459 } = this._selected;
7460 let current = 0,
7461 total = this._matchesCountTotal;
7462
7463 if (matchIdx !== -1) {
7464 for (let i = 0; i < pageIdx; i++) {
7465 current += this._pageMatches[i]?.length || 0;
7466 }
7467
7468 current += matchIdx + 1;
7469 }
7470
7471 if (current < 1 || current > total) {
7472 current = total = 0;
7473 }
7474
7475 return {
7476 current,
7477 total
7478 };
7479 }
7480
7481 #updateUIResultsCount() {
7482 this._eventBus.dispatch("updatefindmatchescount", {
7483 source: this,
7484 matchesCount: this.#requestMatchesCount()
7485 });
7486 }
7487
7488 #updateUIState(state, previous = false) {
7489 this._eventBus.dispatch("updatefindcontrolstate", {
7490 source: this,
7491 state,
7492 previous,
7493 matchesCount: this.#requestMatchesCount(),
7494 rawQuery: this._state?.query ?? null
7495 });
7496 }
7497
7498}
7499
7500exports.PDFFindController = PDFFindController;
7501
7502/***/ }),
7503/* 22 */
7504/***/ ((__unused_webpack_module, exports) => {
7505
7506
7507
7508Object.defineProperty(exports, "__esModule", ({
7509 value: true
7510}));
7511exports.CharacterType = void 0;
7512exports.getCharacterType = getCharacterType;
7513const CharacterType = {
7514 SPACE: 0,
7515 ALPHA_LETTER: 1,
7516 PUNCT: 2,
7517 HAN_LETTER: 3,
7518 KATAKANA_LETTER: 4,
7519 HIRAGANA_LETTER: 5,
7520 HALFWIDTH_KATAKANA_LETTER: 6,
7521 THAI_LETTER: 7
7522};
7523exports.CharacterType = CharacterType;
7524
7525function isAlphabeticalScript(charCode) {
7526 return charCode < 0x2e80;
7527}
7528
7529function isAscii(charCode) {
7530 return (charCode & 0xff80) === 0;
7531}
7532
7533function isAsciiAlpha(charCode) {
7534 return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
7535}
7536
7537function isAsciiDigit(charCode) {
7538 return charCode >= 0x30 && charCode <= 0x39;
7539}
7540
7541function isAsciiSpace(charCode) {
7542 return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
7543}
7544
7545function isHan(charCode) {
7546 return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
7547}
7548
7549function isKatakana(charCode) {
7550 return charCode >= 0x30a0 && charCode <= 0x30ff;
7551}
7552
7553function isHiragana(charCode) {
7554 return charCode >= 0x3040 && charCode <= 0x309f;
7555}
7556
7557function isHalfwidthKatakana(charCode) {
7558 return charCode >= 0xff60 && charCode <= 0xff9f;
7559}
7560
7561function isThai(charCode) {
7562 return (charCode & 0xff80) === 0x0e00;
7563}
7564
7565function getCharacterType(charCode) {
7566 if (isAlphabeticalScript(charCode)) {
7567 if (isAscii(charCode)) {
7568 if (isAsciiSpace(charCode)) {
7569 return CharacterType.SPACE;
7570 } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
7571 return CharacterType.ALPHA_LETTER;
7572 }
7573
7574 return CharacterType.PUNCT;
7575 } else if (isThai(charCode)) {
7576 return CharacterType.THAI_LETTER;
7577 } else if (charCode === 0xa0) {
7578 return CharacterType.SPACE;
7579 }
7580
7581 return CharacterType.ALPHA_LETTER;
7582 }
7583
7584 if (isHan(charCode)) {
7585 return CharacterType.HAN_LETTER;
7586 } else if (isKatakana(charCode)) {
7587 return CharacterType.KATAKANA_LETTER;
7588 } else if (isHiragana(charCode)) {
7589 return CharacterType.HIRAGANA_LETTER;
7590 } else if (isHalfwidthKatakana(charCode)) {
7591 return CharacterType.HALFWIDTH_KATAKANA_LETTER;
7592 }
7593
7594 return CharacterType.ALPHA_LETTER;
7595}
7596
7597/***/ }),
7598/* 23 */
7599/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
7600
7601
7602
7603Object.defineProperty(exports, "__esModule", ({
7604 value: true
7605}));
7606exports.PDFHistory = void 0;
7607exports.isDestArraysEqual = isDestArraysEqual;
7608exports.isDestHashesEqual = isDestHashesEqual;
7609
7610var _ui_utils = __w_pdfjs_require__(7);
7611
7612var _event_utils = __w_pdfjs_require__(18);
7613
7614const HASH_CHANGE_TIMEOUT = 1000;
7615const POSITION_UPDATED_THRESHOLD = 50;
7616const UPDATE_VIEWAREA_TIMEOUT = 1000;
7617
7618function getCurrentHash() {
7619 return document.location.hash;
7620}
7621
7622class PDFHistory {
7623 constructor({
7624 linkService,
7625 eventBus
7626 }) {
7627 this.linkService = linkService;
7628 this.eventBus = eventBus;
7629 this._initialized = false;
7630 this._fingerprint = "";
7631 this.reset();
7632 this._boundEvents = null;
7633
7634 this.eventBus._on("pagesinit", () => {
7635 this._isPagesLoaded = false;
7636
7637 this.eventBus._on("pagesloaded", evt => {
7638 this._isPagesLoaded = !!evt.pagesCount;
7639 }, {
7640 once: true
7641 });
7642 });
7643 }
7644
7645 initialize({
7646 fingerprint,
7647 resetHistory = false,
7648 updateUrl = false
7649 }) {
7650 if (!fingerprint || typeof fingerprint !== "string") {
7651 console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
7652 return;
7653 }
7654
7655 if (this._initialized) {
7656 this.reset();
7657 }
7658
7659 const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
7660 this._fingerprint = fingerprint;
7661 this._updateUrl = updateUrl === true;
7662 this._initialized = true;
7663
7664 this._bindEvents();
7665
7666 const state = window.history.state;
7667 this._popStateInProgress = false;
7668 this._blockHashChange = 0;
7669 this._currentHash = getCurrentHash();
7670 this._numPositionUpdates = 0;
7671 this._uid = this._maxUid = 0;
7672 this._destination = null;
7673 this._position = null;
7674
7675 if (!this._isValidState(state, true) || resetHistory) {
7676 const {
7677 hash,
7678 page,
7679 rotation
7680 } = this._parseCurrentHash(true);
7681
7682 if (!hash || reInitialized || resetHistory) {
7683 this._pushOrReplaceState(null, true);
7684
7685 return;
7686 }
7687
7688 this._pushOrReplaceState({
7689 hash,
7690 page,
7691 rotation
7692 }, true);
7693
7694 return;
7695 }
7696
7697 const destination = state.destination;
7698
7699 this._updateInternalState(destination, state.uid, true);
7700
7701 if (destination.rotation !== undefined) {
7702 this._initialRotation = destination.rotation;
7703 }
7704
7705 if (destination.dest) {
7706 this._initialBookmark = JSON.stringify(destination.dest);
7707 this._destination.page = null;
7708 } else if (destination.hash) {
7709 this._initialBookmark = destination.hash;
7710 } else if (destination.page) {
7711 this._initialBookmark = `page=${destination.page}`;
7712 }
7713 }
7714
7715 reset() {
7716 if (this._initialized) {
7717 this._pageHide();
7718
7719 this._initialized = false;
7720
7721 this._unbindEvents();
7722 }
7723
7724 if (this._updateViewareaTimeout) {
7725 clearTimeout(this._updateViewareaTimeout);
7726 this._updateViewareaTimeout = null;
7727 }
7728
7729 this._initialBookmark = null;
7730 this._initialRotation = null;
7731 }
7732
7733 push({
7734 namedDest = null,
7735 explicitDest,
7736 pageNumber
7737 }) {
7738 if (!this._initialized) {
7739 return;
7740 }
7741
7742 if (namedDest && typeof namedDest !== "string") {
7743 console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
7744 return;
7745 } else if (!Array.isArray(explicitDest)) {
7746 console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
7747 return;
7748 } else if (!this._isValidPage(pageNumber)) {
7749 if (pageNumber !== null || this._destination) {
7750 console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
7751 return;
7752 }
7753 }
7754
7755 const hash = namedDest || JSON.stringify(explicitDest);
7756
7757 if (!hash) {
7758 return;
7759 }
7760
7761 let forceReplace = false;
7762
7763 if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
7764 if (this._destination.page) {
7765 return;
7766 }
7767
7768 forceReplace = true;
7769 }
7770
7771 if (this._popStateInProgress && !forceReplace) {
7772 return;
7773 }
7774
7775 this._pushOrReplaceState({
7776 dest: explicitDest,
7777 hash,
7778 page: pageNumber,
7779 rotation: this.linkService.rotation
7780 }, forceReplace);
7781
7782 if (!this._popStateInProgress) {
7783 this._popStateInProgress = true;
7784 Promise.resolve().then(() => {
7785 this._popStateInProgress = false;
7786 });
7787 }
7788 }
7789
7790 pushPage(pageNumber) {
7791 if (!this._initialized) {
7792 return;
7793 }
7794
7795 if (!this._isValidPage(pageNumber)) {
7796 console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
7797 return;
7798 }
7799
7800 if (this._destination?.page === pageNumber) {
7801 return;
7802 }
7803
7804 if (this._popStateInProgress) {
7805 return;
7806 }
7807
7808 this._pushOrReplaceState({
7809 dest: null,
7810 hash: `page=${pageNumber}`,
7811 page: pageNumber,
7812 rotation: this.linkService.rotation
7813 });
7814
7815 if (!this._popStateInProgress) {
7816 this._popStateInProgress = true;
7817 Promise.resolve().then(() => {
7818 this._popStateInProgress = false;
7819 });
7820 }
7821 }
7822
7823 pushCurrentPosition() {
7824 if (!this._initialized || this._popStateInProgress) {
7825 return;
7826 }
7827
7828 this._tryPushCurrentPosition();
7829 }
7830
7831 back() {
7832 if (!this._initialized || this._popStateInProgress) {
7833 return;
7834 }
7835
7836 const state = window.history.state;
7837
7838 if (this._isValidState(state) && state.uid > 0) {
7839 window.history.back();
7840 }
7841 }
7842
7843 forward() {
7844 if (!this._initialized || this._popStateInProgress) {
7845 return;
7846 }
7847
7848 const state = window.history.state;
7849
7850 if (this._isValidState(state) && state.uid < this._maxUid) {
7851 window.history.forward();
7852 }
7853 }
7854
7855 get popStateInProgress() {
7856 return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
7857 }
7858
7859 get initialBookmark() {
7860 return this._initialized ? this._initialBookmark : null;
7861 }
7862
7863 get initialRotation() {
7864 return this._initialized ? this._initialRotation : null;
7865 }
7866
7867 _pushOrReplaceState(destination, forceReplace = false) {
7868 const shouldReplace = forceReplace || !this._destination;
7869 const newState = {
7870 fingerprint: this._fingerprint,
7871 uid: shouldReplace ? this._uid : this._uid + 1,
7872 destination
7873 };
7874
7875 this._updateInternalState(destination, newState.uid);
7876
7877 let newUrl;
7878
7879 if (this._updateUrl && destination?.hash) {
7880 const baseUrl = document.location.href.split("#")[0];
7881
7882 if (!baseUrl.startsWith("file://")) {
7883 newUrl = `${baseUrl}#${destination.hash}`;
7884 }
7885 }
7886
7887 if (shouldReplace) {
7888 window.history.replaceState(newState, "", newUrl);
7889 } else {
7890 window.history.pushState(newState, "", newUrl);
7891 }
7892 }
7893
7894 _tryPushCurrentPosition(temporary = false) {
7895 if (!this._position) {
7896 return;
7897 }
7898
7899 let position = this._position;
7900
7901 if (temporary) {
7902 position = Object.assign(Object.create(null), this._position);
7903 position.temporary = true;
7904 }
7905
7906 if (!this._destination) {
7907 this._pushOrReplaceState(position);
7908
7909 return;
7910 }
7911
7912 if (this._destination.temporary) {
7913 this._pushOrReplaceState(position, true);
7914
7915 return;
7916 }
7917
7918 if (this._destination.hash === position.hash) {
7919 return;
7920 }
7921
7922 if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
7923 return;
7924 }
7925
7926 let forceReplace = false;
7927
7928 if (this._destination.page >= position.first && this._destination.page <= position.page) {
7929 if (this._destination.dest !== undefined || !this._destination.first) {
7930 return;
7931 }
7932
7933 forceReplace = true;
7934 }
7935
7936 this._pushOrReplaceState(position, forceReplace);
7937 }
7938
7939 _isValidPage(val) {
7940 return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
7941 }
7942
7943 _isValidState(state, checkReload = false) {
7944 if (!state) {
7945 return false;
7946 }
7947
7948 if (state.fingerprint !== this._fingerprint) {
7949 if (checkReload) {
7950 if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
7951 return false;
7952 }
7953
7954 const [perfEntry] = performance.getEntriesByType("navigation");
7955
7956 if (perfEntry?.type !== "reload") {
7957 return false;
7958 }
7959 } else {
7960 return false;
7961 }
7962 }
7963
7964 if (!Number.isInteger(state.uid) || state.uid < 0) {
7965 return false;
7966 }
7967
7968 if (state.destination === null || typeof state.destination !== "object") {
7969 return false;
7970 }
7971
7972 return true;
7973 }
7974
7975 _updateInternalState(destination, uid, removeTemporary = false) {
7976 if (this._updateViewareaTimeout) {
7977 clearTimeout(this._updateViewareaTimeout);
7978 this._updateViewareaTimeout = null;
7979 }
7980
7981 if (removeTemporary && destination?.temporary) {
7982 delete destination.temporary;
7983 }
7984
7985 this._destination = destination;
7986 this._uid = uid;
7987 this._maxUid = Math.max(this._maxUid, uid);
7988 this._numPositionUpdates = 0;
7989 }
7990
7991 _parseCurrentHash(checkNameddest = false) {
7992 const hash = unescape(getCurrentHash()).substring(1);
7993 const params = (0, _ui_utils.parseQueryString)(hash);
7994 const nameddest = params.get("nameddest") || "";
7995 let page = params.get("page") | 0;
7996
7997 if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
7998 page = null;
7999 }
8000
8001 return {
8002 hash,
8003 page,
8004 rotation: this.linkService.rotation
8005 };
8006 }
8007
8008 _updateViewarea({
8009 location
8010 }) {
8011 if (this._updateViewareaTimeout) {
8012 clearTimeout(this._updateViewareaTimeout);
8013 this._updateViewareaTimeout = null;
8014 }
8015
8016 this._position = {
8017 hash: location.pdfOpenParams.substring(1),
8018 page: this.linkService.page,
8019 first: location.pageNumber,
8020 rotation: location.rotation
8021 };
8022
8023 if (this._popStateInProgress) {
8024 return;
8025 }
8026
8027 if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
8028 this._numPositionUpdates++;
8029 }
8030
8031 if (UPDATE_VIEWAREA_TIMEOUT > 0) {
8032 this._updateViewareaTimeout = setTimeout(() => {
8033 if (!this._popStateInProgress) {
8034 this._tryPushCurrentPosition(true);
8035 }
8036
8037 this._updateViewareaTimeout = null;
8038 }, UPDATE_VIEWAREA_TIMEOUT);
8039 }
8040 }
8041
8042 _popState({
8043 state
8044 }) {
8045 const newHash = getCurrentHash(),
8046 hashChanged = this._currentHash !== newHash;
8047 this._currentHash = newHash;
8048
8049 if (!state) {
8050 this._uid++;
8051
8052 const {
8053 hash,
8054 page,
8055 rotation
8056 } = this._parseCurrentHash();
8057
8058 this._pushOrReplaceState({
8059 hash,
8060 page,
8061 rotation
8062 }, true);
8063
8064 return;
8065 }
8066
8067 if (!this._isValidState(state)) {
8068 return;
8069 }
8070
8071 this._popStateInProgress = true;
8072
8073 if (hashChanged) {
8074 this._blockHashChange++;
8075 (0, _event_utils.waitOnEventOrTimeout)({
8076 target: window,
8077 name: "hashchange",
8078 delay: HASH_CHANGE_TIMEOUT
8079 }).then(() => {
8080 this._blockHashChange--;
8081 });
8082 }
8083
8084 const destination = state.destination;
8085
8086 this._updateInternalState(destination, state.uid, true);
8087
8088 if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
8089 this.linkService.rotation = destination.rotation;
8090 }
8091
8092 if (destination.dest) {
8093 this.linkService.goToDestination(destination.dest);
8094 } else if (destination.hash) {
8095 this.linkService.setHash(destination.hash);
8096 } else if (destination.page) {
8097 this.linkService.page = destination.page;
8098 }
8099
8100 Promise.resolve().then(() => {
8101 this._popStateInProgress = false;
8102 });
8103 }
8104
8105 _pageHide() {
8106 if (!this._destination || this._destination.temporary) {
8107 this._tryPushCurrentPosition();
8108 }
8109 }
8110
8111 _bindEvents() {
8112 if (this._boundEvents) {
8113 return;
8114 }
8115
8116 this._boundEvents = {
8117 updateViewarea: this._updateViewarea.bind(this),
8118 popState: this._popState.bind(this),
8119 pageHide: this._pageHide.bind(this)
8120 };
8121
8122 this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
8123
8124 window.addEventListener("popstate", this._boundEvents.popState);
8125 window.addEventListener("pagehide", this._boundEvents.pageHide);
8126 }
8127
8128 _unbindEvents() {
8129 if (!this._boundEvents) {
8130 return;
8131 }
8132
8133 this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
8134
8135 window.removeEventListener("popstate", this._boundEvents.popState);
8136 window.removeEventListener("pagehide", this._boundEvents.pageHide);
8137 this._boundEvents = null;
8138 }
8139
8140}
8141
8142exports.PDFHistory = PDFHistory;
8143
8144function isDestHashesEqual(destHash, pushHash) {
8145 if (typeof destHash !== "string" || typeof pushHash !== "string") {
8146 return false;
8147 }
8148
8149 if (destHash === pushHash) {
8150 return true;
8151 }
8152
8153 const nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest");
8154
8155 if (nameddest === pushHash) {
8156 return true;
8157 }
8158
8159 return false;
8160}
8161
8162function isDestArraysEqual(firstDest, secondDest) {
8163 function isEntryEqual(first, second) {
8164 if (typeof first !== typeof second) {
8165 return false;
8166 }
8167
8168 if (Array.isArray(first) || Array.isArray(second)) {
8169 return false;
8170 }
8171
8172 if (first !== null && typeof first === "object" && second !== null) {
8173 if (Object.keys(first).length !== Object.keys(second).length) {
8174 return false;
8175 }
8176
8177 for (const key in first) {
8178 if (!isEntryEqual(first[key], second[key])) {
8179 return false;
8180 }
8181 }
8182
8183 return true;
8184 }
8185
8186 return first === second || Number.isNaN(first) && Number.isNaN(second);
8187 }
8188
8189 if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
8190 return false;
8191 }
8192
8193 if (firstDest.length !== secondDest.length) {
8194 return false;
8195 }
8196
8197 for (let i = 0, ii = firstDest.length; i < ii; i++) {
8198 if (!isEntryEqual(firstDest[i], secondDest[i])) {
8199 return false;
8200 }
8201 }
8202
8203 return true;
8204}
8205
8206/***/ }),
8207/* 24 */
8208/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
8209
8210
8211
8212Object.defineProperty(exports, "__esModule", ({
8213 value: true
8214}));
8215exports.PDFScriptingManager = void 0;
8216
8217var _ui_utils = __w_pdfjs_require__(7);
8218
8219var _pdfjsLib = __w_pdfjs_require__(3);
8220
8221class PDFScriptingManager {
8222 constructor({
8223 eventBus,
8224 sandboxBundleSrc = null,
8225 scriptingFactory = null,
8226 docPropertiesLookup = null
8227 }) {
8228 this._pdfDocument = null;
8229 this._pdfViewer = null;
8230 this._closeCapability = null;
8231 this._destroyCapability = null;
8232 this._scripting = null;
8233 this._mouseState = Object.create(null);
8234 this._ready = false;
8235 this._eventBus = eventBus;
8236 this._sandboxBundleSrc = sandboxBundleSrc;
8237 this._scriptingFactory = scriptingFactory;
8238 this._docPropertiesLookup = docPropertiesLookup;
8239
8240 if (!this._scriptingFactory) {
8241 window.addEventListener("updatefromsandbox", event => {
8242 this._eventBus.dispatch("updatefromsandbox", {
8243 source: window,
8244 detail: event.detail
8245 });
8246 });
8247 }
8248 }
8249
8250 setViewer(pdfViewer) {
8251 this._pdfViewer = pdfViewer;
8252 }
8253
8254 async setDocument(pdfDocument) {
8255 if (this._pdfDocument) {
8256 await this._destroyScripting();
8257 }
8258
8259 this._pdfDocument = pdfDocument;
8260
8261 if (!pdfDocument) {
8262 return;
8263 }
8264
8265 const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
8266
8267 if (!objects && !docActions) {
8268 await this._destroyScripting();
8269 return;
8270 }
8271
8272 if (pdfDocument !== this._pdfDocument) {
8273 return;
8274 }
8275
8276 try {
8277 this._scripting = this._createScripting();
8278 } catch (error) {
8279 console.error(`PDFScriptingManager.setDocument: "${error?.message}".`);
8280 await this._destroyScripting();
8281 return;
8282 }
8283
8284 this._internalEvents.set("updatefromsandbox", event => {
8285 if (event?.source !== window) {
8286 return;
8287 }
8288
8289 this._updateFromSandbox(event.detail);
8290 });
8291
8292 this._internalEvents.set("dispatcheventinsandbox", event => {
8293 this._scripting?.dispatchEventInSandbox(event.detail);
8294 });
8295
8296 this._internalEvents.set("pagechanging", ({
8297 pageNumber,
8298 previous
8299 }) => {
8300 if (pageNumber === previous) {
8301 return;
8302 }
8303
8304 this._dispatchPageClose(previous);
8305
8306 this._dispatchPageOpen(pageNumber);
8307 });
8308
8309 this._internalEvents.set("pagerendered", ({
8310 pageNumber
8311 }) => {
8312 if (!this._pageOpenPending.has(pageNumber)) {
8313 return;
8314 }
8315
8316 if (pageNumber !== this._pdfViewer.currentPageNumber) {
8317 return;
8318 }
8319
8320 this._dispatchPageOpen(pageNumber);
8321 });
8322
8323 this._internalEvents.set("pagesdestroy", async event => {
8324 await this._dispatchPageClose(this._pdfViewer.currentPageNumber);
8325 await this._scripting?.dispatchEventInSandbox({
8326 id: "doc",
8327 name: "WillClose"
8328 });
8329 this._closeCapability?.resolve();
8330 });
8331
8332 this._domEvents.set("mousedown", event => {
8333 this._mouseState.isDown = true;
8334 });
8335
8336 this._domEvents.set("mouseup", event => {
8337 this._mouseState.isDown = false;
8338 });
8339
8340 for (const [name, listener] of this._internalEvents) {
8341 this._eventBus._on(name, listener);
8342 }
8343
8344 for (const [name, listener] of this._domEvents) {
8345 window.addEventListener(name, listener, true);
8346 }
8347
8348 try {
8349 const docProperties = await this._getDocProperties();
8350
8351 if (pdfDocument !== this._pdfDocument) {
8352 return;
8353 }
8354
8355 await this._scripting.createSandbox({
8356 objects,
8357 calculationOrder,
8358 appInfo: {
8359 platform: navigator.platform,
8360 language: navigator.language
8361 },
8362 docInfo: { ...docProperties,
8363 actions: docActions
8364 }
8365 });
8366
8367 this._eventBus.dispatch("sandboxcreated", {
8368 source: this
8369 });
8370 } catch (error) {
8371 console.error(`PDFScriptingManager.setDocument: "${error?.message}".`);
8372 await this._destroyScripting();
8373 return;
8374 }
8375
8376 await this._scripting?.dispatchEventInSandbox({
8377 id: "doc",
8378 name: "Open"
8379 });
8380 await this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true);
8381 Promise.resolve().then(() => {
8382 if (pdfDocument === this._pdfDocument) {
8383 this._ready = true;
8384 }
8385 });
8386 }
8387
8388 async dispatchWillSave(detail) {
8389 return this._scripting?.dispatchEventInSandbox({
8390 id: "doc",
8391 name: "WillSave"
8392 });
8393 }
8394
8395 async dispatchDidSave(detail) {
8396 return this._scripting?.dispatchEventInSandbox({
8397 id: "doc",
8398 name: "DidSave"
8399 });
8400 }
8401
8402 async dispatchWillPrint(detail) {
8403 return this._scripting?.dispatchEventInSandbox({
8404 id: "doc",
8405 name: "WillPrint"
8406 });
8407 }
8408
8409 async dispatchDidPrint(detail) {
8410 return this._scripting?.dispatchEventInSandbox({
8411 id: "doc",
8412 name: "DidPrint"
8413 });
8414 }
8415
8416 get mouseState() {
8417 return this._mouseState;
8418 }
8419
8420 get destroyPromise() {
8421 return this._destroyCapability?.promise || null;
8422 }
8423
8424 get ready() {
8425 return this._ready;
8426 }
8427
8428 get _internalEvents() {
8429 return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
8430 }
8431
8432 get _domEvents() {
8433 return (0, _pdfjsLib.shadow)(this, "_domEvents", new Map());
8434 }
8435
8436 get _pageOpenPending() {
8437 return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
8438 }
8439
8440 get _visitedPages() {
8441 return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
8442 }
8443
8444 async _updateFromSandbox(detail) {
8445 const isInPresentationMode = this._pdfViewer.isInPresentationMode || this._pdfViewer.isChangingPresentationMode;
8446 const {
8447 id,
8448 siblings,
8449 command,
8450 value
8451 } = detail;
8452
8453 if (!id) {
8454 switch (command) {
8455 case "clear":
8456 console.clear();
8457 break;
8458
8459 case "error":
8460 console.error(value);
8461 break;
8462
8463 case "layout":
8464 if (isInPresentationMode) {
8465 return;
8466 }
8467
8468 const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(value);
8469 this._pdfViewer.spreadMode = modes.spreadMode;
8470 break;
8471
8472 case "page-num":
8473 this._pdfViewer.currentPageNumber = value + 1;
8474 break;
8475
8476 case "print":
8477 await this._pdfViewer.pagesPromise;
8478
8479 this._eventBus.dispatch("print", {
8480 source: this
8481 });
8482
8483 break;
8484
8485 case "println":
8486 console.log(value);
8487 break;
8488
8489 case "zoom":
8490 if (isInPresentationMode) {
8491 return;
8492 }
8493
8494 this._pdfViewer.currentScaleValue = value;
8495 break;
8496
8497 case "SaveAs":
8498 this._eventBus.dispatch("download", {
8499 source: this
8500 });
8501
8502 break;
8503
8504 case "FirstPage":
8505 this._pdfViewer.currentPageNumber = 1;
8506 break;
8507
8508 case "LastPage":
8509 this._pdfViewer.currentPageNumber = this._pdfViewer.pagesCount;
8510 break;
8511
8512 case "NextPage":
8513 this._pdfViewer.nextPage();
8514
8515 break;
8516
8517 case "PrevPage":
8518 this._pdfViewer.previousPage();
8519
8520 break;
8521
8522 case "ZoomViewIn":
8523 if (isInPresentationMode) {
8524 return;
8525 }
8526
8527 this._pdfViewer.increaseScale();
8528
8529 break;
8530
8531 case "ZoomViewOut":
8532 if (isInPresentationMode) {
8533 return;
8534 }
8535
8536 this._pdfViewer.decreaseScale();
8537
8538 break;
8539 }
8540
8541 return;
8542 }
8543
8544 if (isInPresentationMode) {
8545 if (detail.focus) {
8546 return;
8547 }
8548 }
8549
8550 delete detail.id;
8551 delete detail.siblings;
8552 const ids = siblings ? [id, ...siblings] : [id];
8553
8554 for (const elementId of ids) {
8555 const element = document.querySelector(`[data-element-id="${elementId}"]`);
8556
8557 if (element) {
8558 element.dispatchEvent(new CustomEvent("updatefromsandbox", {
8559 detail
8560 }));
8561 } else {
8562 this._pdfDocument?.annotationStorage.setValue(elementId, detail);
8563 }
8564 }
8565 }
8566
8567 async _dispatchPageOpen(pageNumber, initialize = false) {
8568 const pdfDocument = this._pdfDocument,
8569 visitedPages = this._visitedPages;
8570
8571 if (initialize) {
8572 this._closeCapability = (0, _pdfjsLib.createPromiseCapability)();
8573 }
8574
8575 if (!this._closeCapability) {
8576 return;
8577 }
8578
8579 const pageView = this._pdfViewer.getPageView(pageNumber - 1);
8580
8581 if (pageView?.renderingState !== _ui_utils.RenderingStates.FINISHED) {
8582 this._pageOpenPending.add(pageNumber);
8583
8584 return;
8585 }
8586
8587 this._pageOpenPending.delete(pageNumber);
8588
8589 const actionsPromise = (async () => {
8590 const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
8591
8592 if (pdfDocument !== this._pdfDocument) {
8593 return;
8594 }
8595
8596 await this._scripting?.dispatchEventInSandbox({
8597 id: "page",
8598 name: "PageOpen",
8599 pageNumber,
8600 actions
8601 });
8602 })();
8603
8604 visitedPages.set(pageNumber, actionsPromise);
8605 }
8606
8607 async _dispatchPageClose(pageNumber) {
8608 const pdfDocument = this._pdfDocument,
8609 visitedPages = this._visitedPages;
8610
8611 if (!this._closeCapability) {
8612 return;
8613 }
8614
8615 if (this._pageOpenPending.has(pageNumber)) {
8616 return;
8617 }
8618
8619 const actionsPromise = visitedPages.get(pageNumber);
8620
8621 if (!actionsPromise) {
8622 return;
8623 }
8624
8625 visitedPages.set(pageNumber, null);
8626 await actionsPromise;
8627
8628 if (pdfDocument !== this._pdfDocument) {
8629 return;
8630 }
8631
8632 await this._scripting?.dispatchEventInSandbox({
8633 id: "page",
8634 name: "PageClose",
8635 pageNumber
8636 });
8637 }
8638
8639 async _getDocProperties() {
8640 if (this._docPropertiesLookup) {
8641 return this._docPropertiesLookup(this._pdfDocument);
8642 }
8643
8644 const {
8645 docPropertiesLookup
8646 } = __w_pdfjs_require__(25);
8647
8648 return docPropertiesLookup(this._pdfDocument);
8649 }
8650
8651 _createScripting() {
8652 this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)();
8653
8654 if (this._scripting) {
8655 throw new Error("_createScripting: Scripting already exists.");
8656 }
8657
8658 if (this._scriptingFactory) {
8659 return this._scriptingFactory.createScripting({
8660 sandboxBundleSrc: this._sandboxBundleSrc
8661 });
8662 }
8663
8664 const {
8665 GenericScripting
8666 } = __w_pdfjs_require__(25);
8667
8668 return new GenericScripting(this._sandboxBundleSrc);
8669 }
8670
8671 async _destroyScripting() {
8672 if (!this._scripting) {
8673 this._pdfDocument = null;
8674 this._destroyCapability?.resolve();
8675 return;
8676 }
8677
8678 if (this._closeCapability) {
8679 await Promise.race([this._closeCapability.promise, new Promise(resolve => {
8680 setTimeout(resolve, 1000);
8681 })]).catch(reason => {});
8682 this._closeCapability = null;
8683 }
8684
8685 this._pdfDocument = null;
8686
8687 try {
8688 await this._scripting.destroySandbox();
8689 } catch (ex) {}
8690
8691 for (const [name, listener] of this._internalEvents) {
8692 this._eventBus._off(name, listener);
8693 }
8694
8695 this._internalEvents.clear();
8696
8697 for (const [name, listener] of this._domEvents) {
8698 window.removeEventListener(name, listener, true);
8699 }
8700
8701 this._domEvents.clear();
8702
8703 this._pageOpenPending.clear();
8704
8705 this._visitedPages.clear();
8706
8707 this._scripting = null;
8708 delete this._mouseState.isDown;
8709 this._ready = false;
8710 this._destroyCapability?.resolve();
8711 }
8712
8713}
8714
8715exports.PDFScriptingManager = PDFScriptingManager;
8716
8717/***/ }),
8718/* 25 */
8719/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
8720
8721
8722
8723Object.defineProperty(exports, "__esModule", ({
8724 value: true
8725}));
8726exports.GenericScripting = void 0;
8727exports.docPropertiesLookup = docPropertiesLookup;
8728
8729var _pdfjsLib = __w_pdfjs_require__(3);
8730
8731async function docPropertiesLookup(pdfDocument) {
8732 const url = "",
8733 baseUrl = url.split("#")[0];
8734 let {
8735 info,
8736 metadata,
8737 contentDispositionFilename,
8738 contentLength
8739 } = await pdfDocument.getMetadata();
8740
8741 if (!contentLength) {
8742 const {
8743 length
8744 } = await pdfDocument.getDownloadInfo();
8745 contentLength = length;
8746 }
8747
8748 return { ...info,
8749 baseURL: baseUrl,
8750 filesize: contentLength,
8751 filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
8752 metadata: metadata?.getRaw(),
8753 authors: metadata?.get("dc:creator"),
8754 numPages: pdfDocument.numPages,
8755 URL: url
8756 };
8757}
8758
8759class GenericScripting {
8760 constructor(sandboxBundleSrc) {
8761 this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(() => {
8762 return window.pdfjsSandbox.QuickJSSandbox();
8763 });
8764 }
8765
8766 async createSandbox(data) {
8767 const sandbox = await this._ready;
8768 sandbox.create(data);
8769 }
8770
8771 async dispatchEventInSandbox(event) {
8772 const sandbox = await this._ready;
8773 setTimeout(() => sandbox.dispatchEvent(event), 0);
8774 }
8775
8776 async destroySandbox() {
8777 const sandbox = await this._ready;
8778 sandbox.nukeSandbox();
8779 }
8780
8781}
8782
8783exports.GenericScripting = GenericScripting;
8784
8785/***/ })
8786/******/ ]);
8787/************************************************************************/
8788/******/ // The module cache
8789/******/ var __webpack_module_cache__ = {};
8790/******/
8791/******/ // The require function
8792/******/ function __w_pdfjs_require__(moduleId) {
8793/******/ // Check if module is in cache
8794/******/ var cachedModule = __webpack_module_cache__[moduleId];
8795/******/ if (cachedModule !== undefined) {
8796/******/ return cachedModule.exports;
8797/******/ }
8798/******/ // Create a new module (and put it into the cache)
8799/******/ var module = __webpack_module_cache__[moduleId] = {
8800/******/ // no module.id needed
8801/******/ // no module.loaded needed
8802/******/ exports: {}
8803/******/ };
8804/******/
8805/******/ // Execute the module function
8806/******/ __webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__);
8807/******/
8808/******/ // Return the exports of the module
8809/******/ return module.exports;
8810/******/ }
8811/******/
8812/************************************************************************/
8813var __webpack_exports__ = {};
8814// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
8815(() => {
8816var exports = __webpack_exports__;
8817
8818
8819Object.defineProperty(exports, "__esModule", ({
8820 value: true
8821}));
8822Object.defineProperty(exports, "AnnotationLayerBuilder", ({
8823 enumerable: true,
8824 get: function () {
8825 return _annotation_layer_builder.AnnotationLayerBuilder;
8826 }
8827}));
8828Object.defineProperty(exports, "DefaultAnnotationLayerFactory", ({
8829 enumerable: true,
8830 get: function () {
8831 return _default_factory.DefaultAnnotationLayerFactory;
8832 }
8833}));
8834Object.defineProperty(exports, "DefaultStructTreeLayerFactory", ({
8835 enumerable: true,
8836 get: function () {
8837 return _default_factory.DefaultStructTreeLayerFactory;
8838 }
8839}));
8840Object.defineProperty(exports, "DefaultTextLayerFactory", ({
8841 enumerable: true,
8842 get: function () {
8843 return _default_factory.DefaultTextLayerFactory;
8844 }
8845}));
8846Object.defineProperty(exports, "DefaultXfaLayerFactory", ({
8847 enumerable: true,
8848 get: function () {
8849 return _default_factory.DefaultXfaLayerFactory;
8850 }
8851}));
8852Object.defineProperty(exports, "DownloadManager", ({
8853 enumerable: true,
8854 get: function () {
8855 return _download_manager.DownloadManager;
8856 }
8857}));
8858Object.defineProperty(exports, "EventBus", ({
8859 enumerable: true,
8860 get: function () {
8861 return _event_utils.EventBus;
8862 }
8863}));
8864Object.defineProperty(exports, "GenericL10n", ({
8865 enumerable: true,
8866 get: function () {
8867 return _genericl10n.GenericL10n;
8868 }
8869}));
8870Object.defineProperty(exports, "LinkTarget", ({
8871 enumerable: true,
8872 get: function () {
8873 return _pdf_link_service.LinkTarget;
8874 }
8875}));
8876Object.defineProperty(exports, "NullL10n", ({
8877 enumerable: true,
8878 get: function () {
8879 return _l10n_utils.NullL10n;
8880 }
8881}));
8882Object.defineProperty(exports, "PDFFindController", ({
8883 enumerable: true,
8884 get: function () {
8885 return _pdf_find_controller.PDFFindController;
8886 }
8887}));
8888Object.defineProperty(exports, "PDFHistory", ({
8889 enumerable: true,
8890 get: function () {
8891 return _pdf_history.PDFHistory;
8892 }
8893}));
8894Object.defineProperty(exports, "PDFLinkService", ({
8895 enumerable: true,
8896 get: function () {
8897 return _pdf_link_service.PDFLinkService;
8898 }
8899}));
8900Object.defineProperty(exports, "PDFPageView", ({
8901 enumerable: true,
8902 get: function () {
8903 return _pdf_page_view.PDFPageView;
8904 }
8905}));
8906Object.defineProperty(exports, "PDFScriptingManager", ({
8907 enumerable: true,
8908 get: function () {
8909 return _pdf_scripting_manager.PDFScriptingManager;
8910 }
8911}));
8912Object.defineProperty(exports, "PDFSinglePageViewer", ({
8913 enumerable: true,
8914 get: function () {
8915 return _pdf_viewer.PDFSinglePageViewer;
8916 }
8917}));
8918Object.defineProperty(exports, "PDFViewer", ({
8919 enumerable: true,
8920 get: function () {
8921 return _pdf_viewer.PDFViewer;
8922 }
8923}));
8924Object.defineProperty(exports, "ProgressBar", ({
8925 enumerable: true,
8926 get: function () {
8927 return _ui_utils.ProgressBar;
8928 }
8929}));
8930Object.defineProperty(exports, "SimpleLinkService", ({
8931 enumerable: true,
8932 get: function () {
8933 return _pdf_link_service.SimpleLinkService;
8934 }
8935}));
8936Object.defineProperty(exports, "StructTreeLayerBuilder", ({
8937 enumerable: true,
8938 get: function () {
8939 return _struct_tree_layer_builder.StructTreeLayerBuilder;
8940 }
8941}));
8942Object.defineProperty(exports, "TextLayerBuilder", ({
8943 enumerable: true,
8944 get: function () {
8945 return _text_layer_builder.TextLayerBuilder;
8946 }
8947}));
8948Object.defineProperty(exports, "XfaLayerBuilder", ({
8949 enumerable: true,
8950 get: function () {
8951 return _xfa_layer_builder.XfaLayerBuilder;
8952 }
8953}));
8954Object.defineProperty(exports, "parseQueryString", ({
8955 enumerable: true,
8956 get: function () {
8957 return _ui_utils.parseQueryString;
8958 }
8959}));
8960
8961var _default_factory = __w_pdfjs_require__(1);
8962
8963var _pdf_link_service = __w_pdfjs_require__(6);
8964
8965var _ui_utils = __w_pdfjs_require__(7);
8966
8967var _pdf_viewer = __w_pdfjs_require__(11);
8968
8969var _annotation_layer_builder = __w_pdfjs_require__(5);
8970
8971var _download_manager = __w_pdfjs_require__(17);
8972
8973var _event_utils = __w_pdfjs_require__(18);
8974
8975var _genericl10n = __w_pdfjs_require__(19);
8976
8977var _l10n_utils = __w_pdfjs_require__(4);
8978
8979var _pdf_find_controller = __w_pdfjs_require__(21);
8980
8981var _pdf_history = __w_pdfjs_require__(23);
8982
8983var _pdf_page_view = __w_pdfjs_require__(14);
8984
8985var _pdf_scripting_manager = __w_pdfjs_require__(24);
8986
8987var _struct_tree_layer_builder = __w_pdfjs_require__(8);
8988
8989var _text_layer_builder = __w_pdfjs_require__(9);
8990
8991var _xfa_layer_builder = __w_pdfjs_require__(10);
8992
8993const pdfjsVersion = '2.15.349';
8994const pdfjsBuild = 'b8aa9c622';
8995})();
8996
8997/******/ return __webpack_exports__;
8998/******/ })()
8999;
9000});
9001//# sourceMappingURL=pdf_viewer.js.map
\No newline at end of file