UNPKG

659 kBJavaScriptView Raw
1/**
2 * @licstart The following is the entire license notice for the
3 * JavaScript code in this page
4 *
5 * Copyright 2023 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/******/ var __webpack_modules__ = ({
24
25/***/ 8394:
26/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
27
28/* harmony export */ __webpack_require__.d(__webpack_exports__, {
29/* harmony export */ "default": () => (/* binding */ canvasSize)
30/* harmony export */ });
31function _iterableToArrayLimit(arr, i) {
32 var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
33 if (null != _i) {
34 var _s,
35 _e,
36 _x,
37 _r,
38 _arr = [],
39 _n = !0,
40 _d = !1;
41 try {
42 if (_x = (_i = _i.call(arr)).next, 0 === i) {
43 if (Object(_i) !== _i) return;
44 _n = !1;
45 } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
46 } catch (err) {
47 _d = !0, _e = err;
48 } finally {
49 try {
50 if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
51 } finally {
52 if (_d) throw _e;
53 }
54 }
55 return _arr;
56 }
57}
58function ownKeys(object, enumerableOnly) {
59 var keys = Object.keys(object);
60 if (Object.getOwnPropertySymbols) {
61 var symbols = Object.getOwnPropertySymbols(object);
62 enumerableOnly && (symbols = symbols.filter(function (sym) {
63 return Object.getOwnPropertyDescriptor(object, sym).enumerable;
64 })), keys.push.apply(keys, symbols);
65 }
66 return keys;
67}
68function _objectSpread2(target) {
69 for (var i = 1; i < arguments.length; i++) {
70 var source = null != arguments[i] ? arguments[i] : {};
71 i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
72 _defineProperty(target, key, source[key]);
73 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
74 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
75 });
76 }
77 return target;
78}
79function _defineProperty(obj, key, value) {
80 key = _toPropertyKey(key);
81 if (key in obj) {
82 Object.defineProperty(obj, key, {
83 value: value,
84 enumerable: true,
85 configurable: true,
86 writable: true
87 });
88 } else {
89 obj[key] = value;
90 }
91 return obj;
92}
93function _objectWithoutPropertiesLoose(source, excluded) {
94 if (source == null) return {};
95 var target = {};
96 var sourceKeys = Object.keys(source);
97 var key, i;
98 for (i = 0; i < sourceKeys.length; i++) {
99 key = sourceKeys[i];
100 if (excluded.indexOf(key) >= 0) continue;
101 target[key] = source[key];
102 }
103 return target;
104}
105function _objectWithoutProperties(source, excluded) {
106 if (source == null) return {};
107 var target = _objectWithoutPropertiesLoose(source, excluded);
108 var key, i;
109 if (Object.getOwnPropertySymbols) {
110 var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
111 for (i = 0; i < sourceSymbolKeys.length; i++) {
112 key = sourceSymbolKeys[i];
113 if (excluded.indexOf(key) >= 0) continue;
114 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
115 target[key] = source[key];
116 }
117 }
118 return target;
119}
120function _slicedToArray(arr, i) {
121 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
122}
123function _toConsumableArray(arr) {
124 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
125}
126function _arrayWithoutHoles(arr) {
127 if (Array.isArray(arr)) return _arrayLikeToArray(arr);
128}
129function _arrayWithHoles(arr) {
130 if (Array.isArray(arr)) return arr;
131}
132function _iterableToArray(iter) {
133 if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
134}
135function _unsupportedIterableToArray(o, minLen) {
136 if (!o) return;
137 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
138 var n = Object.prototype.toString.call(o).slice(8, -1);
139 if (n === "Object" && o.constructor) n = o.constructor.name;
140 if (n === "Map" || n === "Set") return Array.from(o);
141 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
142}
143function _arrayLikeToArray(arr, len) {
144 if (len == null || len > arr.length) len = arr.length;
145 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
146 return arr2;
147}
148function _nonIterableSpread() {
149 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
150}
151function _nonIterableRest() {
152 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
153}
154function _toPrimitive(input, hint) {
155 if (typeof input !== "object" || input === null) return input;
156 var prim = input[Symbol.toPrimitive];
157 if (prim !== undefined) {
158 var res = prim.call(input, hint || "default");
159 if (typeof res !== "object") return res;
160 throw new TypeError("@@toPrimitive must return a primitive value.");
161 }
162 return (hint === "string" ? String : Number)(input);
163}
164function _toPropertyKey(arg) {
165 var key = _toPrimitive(arg, "string");
166 return typeof key === "symbol" ? key : String(key);
167}
168function canvasTest(settings) {
169 var size = settings.sizes.shift();
170 var width = Math.max(Math.ceil(size[0]), 1);
171 var height = Math.max(Math.ceil(size[1]), 1);
172 var fill = [width - 1, height - 1, 1, 1];
173 var job = Date.now();
174 var isWorker = typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
175 var cropCvs, testCvs;
176 if (isWorker) {
177 cropCvs = new OffscreenCanvas(1, 1);
178 testCvs = new OffscreenCanvas(width, height);
179 } else {
180 cropCvs = document.createElement("canvas");
181 cropCvs.width = 1;
182 cropCvs.height = 1;
183 testCvs = document.createElement("canvas");
184 testCvs.width = width;
185 testCvs.height = height;
186 }
187 var cropCtx = cropCvs.getContext("2d");
188 var testCtx = testCvs.getContext("2d");
189 if (testCtx) {
190 testCtx.fillRect.apply(testCtx, fill);
191 cropCtx.drawImage(testCvs, width - 1, height - 1, 1, 1, 0, 0, 1, 1);
192 }
193 var isTestPass = cropCtx && cropCtx.getImageData(0, 0, 1, 1).data[3] !== 0;
194 var benchmark = Date.now() - job;
195 [cropCvs, testCvs].forEach(function (cvs) {
196 cvs.height = 0;
197 cvs.width = 0;
198 });
199 if (isWorker) {
200 postMessage({
201 width: width,
202 height: height,
203 benchmark: benchmark,
204 isTestPass: isTestPass
205 });
206 if (!isTestPass && settings.sizes.length) {
207 canvasTest(settings);
208 }
209 } else if (isTestPass) {
210 settings.onSuccess(width, height, benchmark);
211 } else {
212 settings.onError(width, height, benchmark);
213 if (settings.sizes.length) {
214 canvasTest(settings);
215 }
216 }
217 return isTestPass;
218}
219var testSizes = {
220 area: [16384, 14188, 11402, 11180, 10836, 8192, 4096, 1],
221 height: [8388607, 65535, 32767, 16384, 8192, 4096, 1],
222 width: [4194303, 65535, 32767, 16384, 8192, 4096, 1]
223};
224var _excluded = ["onError", "onSuccess"];
225var defaults = {
226 max: null,
227 min: 1,
228 sizes: [],
229 step: 1024,
230 usePromise: false,
231 useWorker: false,
232 onError: Function.prototype,
233 onSuccess: Function.prototype
234};
235var workerJobs = {};
236function createSizesArray(settings) {
237 var isArea = settings.width === settings.height;
238 var isWidth = settings.height === 1;
239 var isHeight = settings.width === 1;
240 var sizes = [];
241 if (!settings.width || !settings.height) {
242 settings.sizes.forEach(function (testSize) {
243 var width = isArea || isWidth ? testSize : 1;
244 var height = isArea || isHeight ? testSize : 1;
245 sizes.push([width, height]);
246 });
247 } else {
248 var testMin = settings.min || defaults.min;
249 var testStep = settings.step || defaults.step;
250 var testSize = Math.max(settings.width, settings.height);
251 while (testSize >= testMin) {
252 var width = isArea || isWidth ? testSize : 1;
253 var height = isArea || isHeight ? testSize : 1;
254 sizes.push([width, height]);
255 testSize -= testStep;
256 }
257 }
258 return sizes;
259}
260function handleMethod(settings) {
261 var hasCanvasSupport = window && "HTMLCanvasElement" in window;
262 var hasOffscreenCanvasSupport = window && "OffscreenCanvas" in window;
263 var jobID = Date.now();
264 var _onError = settings.onError,
265 _onSuccess = settings.onSuccess,
266 settingsWithoutCallbacks = _objectWithoutProperties(settings, _excluded);
267 var worker = null;
268 if (!hasCanvasSupport) {
269 return false;
270 }
271 if (settings.useWorker && hasOffscreenCanvasSupport) {
272 var js = "\n var canvasTest = ".concat(canvasTest.toString(), ";\n onmessage = function(e) {\n canvasTest(e.data);\n };\n ");
273 var blob = new Blob([js], {
274 type: "application/javascript"
275 });
276 var blobURL = URL.createObjectURL(blob);
277 worker = new Worker(blobURL);
278 URL.revokeObjectURL(blobURL);
279 worker.onmessage = function (e) {
280 var _e$data = e.data,
281 width = _e$data.width,
282 height = _e$data.height,
283 benchmark = _e$data.benchmark,
284 isTestPass = _e$data.isTestPass;
285 if (isTestPass) {
286 workerJobs[jobID].onSuccess(width, height, benchmark);
287 delete workerJobs[jobID];
288 } else {
289 workerJobs[jobID].onError(width, height, benchmark);
290 }
291 };
292 }
293 if (settings.usePromise) {
294 return new Promise(function (resolve, reject) {
295 var promiseSettings = _objectSpread2(_objectSpread2({}, settings), {}, {
296 onError: function onError(width, height, benchmark) {
297 var isLastTest;
298 if (settings.sizes.length === 0) {
299 isLastTest = true;
300 } else {
301 var _settings$sizes$slice = settings.sizes.slice(-1),
302 _settings$sizes$slice2 = _slicedToArray(_settings$sizes$slice, 1),
303 _settings$sizes$slice3 = _slicedToArray(_settings$sizes$slice2[0], 2),
304 lastWidth = _settings$sizes$slice3[0],
305 lastHeight = _settings$sizes$slice3[1];
306 isLastTest = width === lastWidth && height === lastHeight;
307 }
308 _onError(width, height, benchmark);
309 if (isLastTest) {
310 reject({
311 width: width,
312 height: height,
313 benchmark: benchmark
314 });
315 }
316 },
317 onSuccess: function onSuccess(width, height, benchmark) {
318 _onSuccess(width, height, benchmark);
319 resolve({
320 width: width,
321 height: height,
322 benchmark: benchmark
323 });
324 }
325 });
326 if (worker) {
327 var onError = promiseSettings.onError,
328 onSuccess = promiseSettings.onSuccess;
329 workerJobs[jobID] = {
330 onError: onError,
331 onSuccess: onSuccess
332 };
333 worker.postMessage(settingsWithoutCallbacks);
334 } else {
335 canvasTest(promiseSettings);
336 }
337 });
338 } else {
339 if (worker) {
340 workerJobs[jobID] = {
341 onError: _onError,
342 onSuccess: _onSuccess
343 };
344 worker.postMessage(settingsWithoutCallbacks);
345 } else {
346 return canvasTest(settings);
347 }
348 }
349}
350var canvasSize = {
351 maxArea: function maxArea() {
352 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
353 var sizes = createSizesArray({
354 width: options.max,
355 height: options.max,
356 min: options.min,
357 step: options.step,
358 sizes: _toConsumableArray(testSizes.area)
359 });
360 var settings = _objectSpread2(_objectSpread2(_objectSpread2({}, defaults), options), {}, {
361 sizes: sizes
362 });
363 return handleMethod(settings);
364 },
365 maxHeight: function maxHeight() {
366 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
367 var sizes = createSizesArray({
368 width: 1,
369 height: options.max,
370 min: options.min,
371 step: options.step,
372 sizes: _toConsumableArray(testSizes.height)
373 });
374 var settings = _objectSpread2(_objectSpread2(_objectSpread2({}, defaults), options), {}, {
375 sizes: sizes
376 });
377 return handleMethod(settings);
378 },
379 maxWidth: function maxWidth() {
380 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
381 var sizes = createSizesArray({
382 width: options.max,
383 height: 1,
384 min: options.min,
385 step: options.step,
386 sizes: _toConsumableArray(testSizes.width)
387 });
388 var settings = _objectSpread2(_objectSpread2(_objectSpread2({}, defaults), options), {}, {
389 sizes: sizes
390 });
391 return handleMethod(settings);
392 },
393 test: function test() {
394 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
395 var settings = _objectSpread2(_objectSpread2({}, defaults), options);
396 settings.sizes = _toConsumableArray(settings.sizes);
397 if (settings.width && settings.height) {
398 settings.sizes = [[settings.width, settings.height]];
399 }
400 return handleMethod(settings);
401 }
402};
403
404
405/***/ }),
406
407/***/ 588:
408/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
409
410
411// EXPORTS
412__webpack_require__.d(__webpack_exports__, {
413 FluentBundle: () => (/* reexport */ FluentBundle),
414 FluentResource: () => (/* reexport */ FluentResource)
415});
416
417// UNUSED EXPORTS: FluentDateTime, FluentNone, FluentNumber, FluentType
418
419;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/types.js
420class FluentType {
421 constructor(value) {
422 this.value = value;
423 }
424 valueOf() {
425 return this.value;
426 }
427}
428class FluentNone extends FluentType {
429 constructor(value = "???") {
430 super(value);
431 }
432 toString(scope) {
433 return `{${this.value}}`;
434 }
435}
436class FluentNumber extends FluentType {
437 constructor(value, opts = {}) {
438 super(value);
439 this.opts = opts;
440 }
441 toString(scope) {
442 try {
443 const nf = scope.memoizeIntlObject(Intl.NumberFormat, this.opts);
444 return nf.format(this.value);
445 } catch (err) {
446 scope.reportError(err);
447 return this.value.toString(10);
448 }
449 }
450}
451class FluentDateTime extends FluentType {
452 constructor(value, opts = {}) {
453 super(value);
454 this.opts = opts;
455 }
456 toString(scope) {
457 try {
458 const dtf = scope.memoizeIntlObject(Intl.DateTimeFormat, this.opts);
459 return dtf.format(this.value);
460 } catch (err) {
461 scope.reportError(err);
462 return new Date(this.value).toISOString();
463 }
464 }
465}
466;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/resolver.js
467
468const MAX_PLACEABLES = 100;
469const FSI = "\u2068";
470const PDI = "\u2069";
471function match(scope, selector, key) {
472 if (key === selector) {
473 return true;
474 }
475 if (key instanceof FluentNumber && selector instanceof FluentNumber && key.value === selector.value) {
476 return true;
477 }
478 if (selector instanceof FluentNumber && typeof key === "string") {
479 let category = scope.memoizeIntlObject(Intl.PluralRules, selector.opts).select(selector.value);
480 if (key === category) {
481 return true;
482 }
483 }
484 return false;
485}
486function getDefault(scope, variants, star) {
487 if (variants[star]) {
488 return resolvePattern(scope, variants[star].value);
489 }
490 scope.reportError(new RangeError("No default"));
491 return new FluentNone();
492}
493function getArguments(scope, args) {
494 const positional = [];
495 const named = Object.create(null);
496 for (const arg of args) {
497 if (arg.type === "narg") {
498 named[arg.name] = resolveExpression(scope, arg.value);
499 } else {
500 positional.push(resolveExpression(scope, arg));
501 }
502 }
503 return {
504 positional,
505 named
506 };
507}
508function resolveExpression(scope, expr) {
509 switch (expr.type) {
510 case "str":
511 return expr.value;
512 case "num":
513 return new FluentNumber(expr.value, {
514 minimumFractionDigits: expr.precision
515 });
516 case "var":
517 return resolveVariableReference(scope, expr);
518 case "mesg":
519 return resolveMessageReference(scope, expr);
520 case "term":
521 return resolveTermReference(scope, expr);
522 case "func":
523 return resolveFunctionReference(scope, expr);
524 case "select":
525 return resolveSelectExpression(scope, expr);
526 default:
527 return new FluentNone();
528 }
529}
530function resolveVariableReference(scope, {
531 name
532}) {
533 let arg;
534 if (scope.params) {
535 if (Object.prototype.hasOwnProperty.call(scope.params, name)) {
536 arg = scope.params[name];
537 } else {
538 return new FluentNone(`$${name}`);
539 }
540 } else if (scope.args && Object.prototype.hasOwnProperty.call(scope.args, name)) {
541 arg = scope.args[name];
542 } else {
543 scope.reportError(new ReferenceError(`Unknown variable: $${name}`));
544 return new FluentNone(`$${name}`);
545 }
546 if (arg instanceof FluentType) {
547 return arg;
548 }
549 switch (typeof arg) {
550 case "string":
551 return arg;
552 case "number":
553 return new FluentNumber(arg);
554 case "object":
555 if (arg instanceof Date) {
556 return new FluentDateTime(arg.getTime());
557 }
558 default:
559 scope.reportError(new TypeError(`Variable type not supported: $${name}, ${typeof arg}`));
560 return new FluentNone(`$${name}`);
561 }
562}
563function resolveMessageReference(scope, {
564 name,
565 attr
566}) {
567 const message = scope.bundle._messages.get(name);
568 if (!message) {
569 scope.reportError(new ReferenceError(`Unknown message: ${name}`));
570 return new FluentNone(name);
571 }
572 if (attr) {
573 const attribute = message.attributes[attr];
574 if (attribute) {
575 return resolvePattern(scope, attribute);
576 }
577 scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`));
578 return new FluentNone(`${name}.${attr}`);
579 }
580 if (message.value) {
581 return resolvePattern(scope, message.value);
582 }
583 scope.reportError(new ReferenceError(`No value: ${name}`));
584 return new FluentNone(name);
585}
586function resolveTermReference(scope, {
587 name,
588 attr,
589 args
590}) {
591 const id = `-${name}`;
592 const term = scope.bundle._terms.get(id);
593 if (!term) {
594 scope.reportError(new ReferenceError(`Unknown term: ${id}`));
595 return new FluentNone(id);
596 }
597 if (attr) {
598 const attribute = term.attributes[attr];
599 if (attribute) {
600 scope.params = getArguments(scope, args).named;
601 const resolved = resolvePattern(scope, attribute);
602 scope.params = null;
603 return resolved;
604 }
605 scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`));
606 return new FluentNone(`${id}.${attr}`);
607 }
608 scope.params = getArguments(scope, args).named;
609 const resolved = resolvePattern(scope, term.value);
610 scope.params = null;
611 return resolved;
612}
613function resolveFunctionReference(scope, {
614 name,
615 args
616}) {
617 let func = scope.bundle._functions[name];
618 if (!func) {
619 scope.reportError(new ReferenceError(`Unknown function: ${name}()`));
620 return new FluentNone(`${name}()`);
621 }
622 if (typeof func !== "function") {
623 scope.reportError(new TypeError(`Function ${name}() is not callable`));
624 return new FluentNone(`${name}()`);
625 }
626 try {
627 let resolved = getArguments(scope, args);
628 return func(resolved.positional, resolved.named);
629 } catch (err) {
630 scope.reportError(err);
631 return new FluentNone(`${name}()`);
632 }
633}
634function resolveSelectExpression(scope, {
635 selector,
636 variants,
637 star
638}) {
639 let sel = resolveExpression(scope, selector);
640 if (sel instanceof FluentNone) {
641 return getDefault(scope, variants, star);
642 }
643 for (const variant of variants) {
644 const key = resolveExpression(scope, variant.key);
645 if (match(scope, sel, key)) {
646 return resolvePattern(scope, variant.value);
647 }
648 }
649 return getDefault(scope, variants, star);
650}
651function resolveComplexPattern(scope, ptn) {
652 if (scope.dirty.has(ptn)) {
653 scope.reportError(new RangeError("Cyclic reference"));
654 return new FluentNone();
655 }
656 scope.dirty.add(ptn);
657 const result = [];
658 const useIsolating = scope.bundle._useIsolating && ptn.length > 1;
659 for (const elem of ptn) {
660 if (typeof elem === "string") {
661 result.push(scope.bundle._transform(elem));
662 continue;
663 }
664 scope.placeables++;
665 if (scope.placeables > MAX_PLACEABLES) {
666 scope.dirty.delete(ptn);
667 throw new RangeError(`Too many placeables expanded: ${scope.placeables}, ` + `max allowed is ${MAX_PLACEABLES}`);
668 }
669 if (useIsolating) {
670 result.push(FSI);
671 }
672 result.push(resolveExpression(scope, elem).toString(scope));
673 if (useIsolating) {
674 result.push(PDI);
675 }
676 }
677 scope.dirty.delete(ptn);
678 return result.join("");
679}
680function resolvePattern(scope, value) {
681 if (typeof value === "string") {
682 return scope.bundle._transform(value);
683 }
684 return resolveComplexPattern(scope, value);
685}
686;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/scope.js
687class Scope {
688 constructor(bundle, errors, args) {
689 this.dirty = new WeakSet();
690 this.params = null;
691 this.placeables = 0;
692 this.bundle = bundle;
693 this.errors = errors;
694 this.args = args;
695 }
696 reportError(error) {
697 if (!this.errors || !(error instanceof Error)) {
698 throw error;
699 }
700 this.errors.push(error);
701 }
702 memoizeIntlObject(ctor, opts) {
703 let cache = this.bundle._intls.get(ctor);
704 if (!cache) {
705 cache = {};
706 this.bundle._intls.set(ctor, cache);
707 }
708 let id = JSON.stringify(opts);
709 if (!cache[id]) {
710 cache[id] = new ctor(this.bundle.locales, opts);
711 }
712 return cache[id];
713 }
714}
715;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/builtins.js
716
717function values(opts, allowed) {
718 const unwrapped = Object.create(null);
719 for (const [name, opt] of Object.entries(opts)) {
720 if (allowed.includes(name)) {
721 unwrapped[name] = opt.valueOf();
722 }
723 }
724 return unwrapped;
725}
726const NUMBER_ALLOWED = ["unitDisplay", "currencyDisplay", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"];
727function NUMBER(args, opts) {
728 let arg = args[0];
729 if (arg instanceof FluentNone) {
730 return new FluentNone(`NUMBER(${arg.valueOf()})`);
731 }
732 if (arg instanceof FluentNumber) {
733 return new FluentNumber(arg.valueOf(), {
734 ...arg.opts,
735 ...values(opts, NUMBER_ALLOWED)
736 });
737 }
738 if (arg instanceof FluentDateTime) {
739 return new FluentNumber(arg.valueOf(), {
740 ...values(opts, NUMBER_ALLOWED)
741 });
742 }
743 throw new TypeError("Invalid argument to NUMBER");
744}
745const DATETIME_ALLOWED = ["dateStyle", "timeStyle", "fractionalSecondDigits", "dayPeriod", "hour12", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"];
746function DATETIME(args, opts) {
747 let arg = args[0];
748 if (arg instanceof FluentNone) {
749 return new FluentNone(`DATETIME(${arg.valueOf()})`);
750 }
751 if (arg instanceof FluentDateTime) {
752 return new FluentDateTime(arg.valueOf(), {
753 ...arg.opts,
754 ...values(opts, DATETIME_ALLOWED)
755 });
756 }
757 if (arg instanceof FluentNumber) {
758 return new FluentDateTime(arg.valueOf(), {
759 ...values(opts, DATETIME_ALLOWED)
760 });
761 }
762 throw new TypeError("Invalid argument to DATETIME");
763}
764;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/memoizer.js
765const cache = new Map();
766function getMemoizerForLocale(locales) {
767 const stringLocale = Array.isArray(locales) ? locales.join(" ") : locales;
768 let memoizer = cache.get(stringLocale);
769 if (memoizer === undefined) {
770 memoizer = new Map();
771 cache.set(stringLocale, memoizer);
772 }
773 return memoizer;
774}
775;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/bundle.js
776
777
778
779
780
781class FluentBundle {
782 constructor(locales, {
783 functions,
784 useIsolating = true,
785 transform = v => v
786 } = {}) {
787 this._terms = new Map();
788 this._messages = new Map();
789 this.locales = Array.isArray(locales) ? locales : [locales];
790 this._functions = {
791 NUMBER: NUMBER,
792 DATETIME: DATETIME,
793 ...functions
794 };
795 this._useIsolating = useIsolating;
796 this._transform = transform;
797 this._intls = getMemoizerForLocale(locales);
798 }
799 hasMessage(id) {
800 return this._messages.has(id);
801 }
802 getMessage(id) {
803 return this._messages.get(id);
804 }
805 addResource(res, {
806 allowOverrides = false
807 } = {}) {
808 const errors = [];
809 for (let i = 0; i < res.body.length; i++) {
810 let entry = res.body[i];
811 if (entry.id.startsWith("-")) {
812 if (allowOverrides === false && this._terms.has(entry.id)) {
813 errors.push(new Error(`Attempt to override an existing term: "${entry.id}"`));
814 continue;
815 }
816 this._terms.set(entry.id, entry);
817 } else {
818 if (allowOverrides === false && this._messages.has(entry.id)) {
819 errors.push(new Error(`Attempt to override an existing message: "${entry.id}"`));
820 continue;
821 }
822 this._messages.set(entry.id, entry);
823 }
824 }
825 return errors;
826 }
827 formatPattern(pattern, args = null, errors = null) {
828 if (typeof pattern === "string") {
829 return this._transform(pattern);
830 }
831 let scope = new Scope(this, errors, args);
832 try {
833 let value = resolveComplexPattern(scope, pattern);
834 return value.toString(scope);
835 } catch (err) {
836 if (scope.errors && err instanceof Error) {
837 scope.errors.push(err);
838 return new FluentNone().toString(scope);
839 }
840 throw err;
841 }
842 }
843}
844;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/resource.js
845const RE_MESSAGE_START = /^(-?[a-zA-Z][\w-]*) *= */gm;
846const RE_ATTRIBUTE_START = /\.([a-zA-Z][\w-]*) *= */y;
847const RE_VARIANT_START = /\*?\[/y;
848const RE_NUMBER_LITERAL = /(-?[0-9]+(?:\.([0-9]+))?)/y;
849const RE_IDENTIFIER = /([a-zA-Z][\w-]*)/y;
850const RE_REFERENCE = /([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y;
851const RE_FUNCTION_NAME = /^[A-Z][A-Z0-9_-]*$/;
852const RE_TEXT_RUN = /([^{}\n\r]+)/y;
853const RE_STRING_RUN = /([^\\"\n\r]*)/y;
854const RE_STRING_ESCAPE = /\\([\\"])/y;
855const RE_UNICODE_ESCAPE = /\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y;
856const RE_LEADING_NEWLINES = /^\n+/;
857const RE_TRAILING_SPACES = / +$/;
858const RE_BLANK_LINES = / *\r?\n/g;
859const RE_INDENT = /( *)$/;
860const TOKEN_BRACE_OPEN = /{\s*/y;
861const TOKEN_BRACE_CLOSE = /\s*}/y;
862const TOKEN_BRACKET_OPEN = /\[\s*/y;
863const TOKEN_BRACKET_CLOSE = /\s*] */y;
864const TOKEN_PAREN_OPEN = /\s*\(\s*/y;
865const TOKEN_ARROW = /\s*->\s*/y;
866const TOKEN_COLON = /\s*:\s*/y;
867const TOKEN_COMMA = /\s*,?\s*/y;
868const TOKEN_BLANK = /\s+/y;
869class FluentResource {
870 constructor(source) {
871 this.body = [];
872 RE_MESSAGE_START.lastIndex = 0;
873 let cursor = 0;
874 while (true) {
875 let next = RE_MESSAGE_START.exec(source);
876 if (next === null) {
877 break;
878 }
879 cursor = RE_MESSAGE_START.lastIndex;
880 try {
881 this.body.push(parseMessage(next[1]));
882 } catch (err) {
883 if (err instanceof SyntaxError) {
884 continue;
885 }
886 throw err;
887 }
888 }
889 function test(re) {
890 re.lastIndex = cursor;
891 return re.test(source);
892 }
893 function consumeChar(char, errorClass) {
894 if (source[cursor] === char) {
895 cursor++;
896 return true;
897 }
898 if (errorClass) {
899 throw new errorClass(`Expected ${char}`);
900 }
901 return false;
902 }
903 function consumeToken(re, errorClass) {
904 if (test(re)) {
905 cursor = re.lastIndex;
906 return true;
907 }
908 if (errorClass) {
909 throw new errorClass(`Expected ${re.toString()}`);
910 }
911 return false;
912 }
913 function match(re) {
914 re.lastIndex = cursor;
915 let result = re.exec(source);
916 if (result === null) {
917 throw new SyntaxError(`Expected ${re.toString()}`);
918 }
919 cursor = re.lastIndex;
920 return result;
921 }
922 function match1(re) {
923 return match(re)[1];
924 }
925 function parseMessage(id) {
926 let value = parsePattern();
927 let attributes = parseAttributes();
928 if (value === null && Object.keys(attributes).length === 0) {
929 throw new SyntaxError("Expected message value or attributes");
930 }
931 return {
932 id,
933 value,
934 attributes
935 };
936 }
937 function parseAttributes() {
938 let attrs = Object.create(null);
939 while (test(RE_ATTRIBUTE_START)) {
940 let name = match1(RE_ATTRIBUTE_START);
941 let value = parsePattern();
942 if (value === null) {
943 throw new SyntaxError("Expected attribute value");
944 }
945 attrs[name] = value;
946 }
947 return attrs;
948 }
949 function parsePattern() {
950 let first;
951 if (test(RE_TEXT_RUN)) {
952 first = match1(RE_TEXT_RUN);
953 }
954 if (source[cursor] === "{" || source[cursor] === "}") {
955 return parsePatternElements(first ? [first] : [], Infinity);
956 }
957 let indent = parseIndent();
958 if (indent) {
959 if (first) {
960 return parsePatternElements([first, indent], indent.length);
961 }
962 indent.value = trim(indent.value, RE_LEADING_NEWLINES);
963 return parsePatternElements([indent], indent.length);
964 }
965 if (first) {
966 return trim(first, RE_TRAILING_SPACES);
967 }
968 return null;
969 }
970 function parsePatternElements(elements = [], commonIndent) {
971 while (true) {
972 if (test(RE_TEXT_RUN)) {
973 elements.push(match1(RE_TEXT_RUN));
974 continue;
975 }
976 if (source[cursor] === "{") {
977 elements.push(parsePlaceable());
978 continue;
979 }
980 if (source[cursor] === "}") {
981 throw new SyntaxError("Unbalanced closing brace");
982 }
983 let indent = parseIndent();
984 if (indent) {
985 elements.push(indent);
986 commonIndent = Math.min(commonIndent, indent.length);
987 continue;
988 }
989 break;
990 }
991 let lastIndex = elements.length - 1;
992 let lastElement = elements[lastIndex];
993 if (typeof lastElement === "string") {
994 elements[lastIndex] = trim(lastElement, RE_TRAILING_SPACES);
995 }
996 let baked = [];
997 for (let element of elements) {
998 if (element instanceof Indent) {
999 element = element.value.slice(0, element.value.length - commonIndent);
1000 }
1001 if (element) {
1002 baked.push(element);
1003 }
1004 }
1005 return baked;
1006 }
1007 function parsePlaceable() {
1008 consumeToken(TOKEN_BRACE_OPEN, SyntaxError);
1009 let selector = parseInlineExpression();
1010 if (consumeToken(TOKEN_BRACE_CLOSE)) {
1011 return selector;
1012 }
1013 if (consumeToken(TOKEN_ARROW)) {
1014 let variants = parseVariants();
1015 consumeToken(TOKEN_BRACE_CLOSE, SyntaxError);
1016 return {
1017 type: "select",
1018 selector,
1019 ...variants
1020 };
1021 }
1022 throw new SyntaxError("Unclosed placeable");
1023 }
1024 function parseInlineExpression() {
1025 if (source[cursor] === "{") {
1026 return parsePlaceable();
1027 }
1028 if (test(RE_REFERENCE)) {
1029 let [, sigil, name, attr = null] = match(RE_REFERENCE);
1030 if (sigil === "$") {
1031 return {
1032 type: "var",
1033 name
1034 };
1035 }
1036 if (consumeToken(TOKEN_PAREN_OPEN)) {
1037 let args = parseArguments();
1038 if (sigil === "-") {
1039 return {
1040 type: "term",
1041 name,
1042 attr,
1043 args
1044 };
1045 }
1046 if (RE_FUNCTION_NAME.test(name)) {
1047 return {
1048 type: "func",
1049 name,
1050 args
1051 };
1052 }
1053 throw new SyntaxError("Function names must be all upper-case");
1054 }
1055 if (sigil === "-") {
1056 return {
1057 type: "term",
1058 name,
1059 attr,
1060 args: []
1061 };
1062 }
1063 return {
1064 type: "mesg",
1065 name,
1066 attr
1067 };
1068 }
1069 return parseLiteral();
1070 }
1071 function parseArguments() {
1072 let args = [];
1073 while (true) {
1074 switch (source[cursor]) {
1075 case ")":
1076 cursor++;
1077 return args;
1078 case undefined:
1079 throw new SyntaxError("Unclosed argument list");
1080 }
1081 args.push(parseArgument());
1082 consumeToken(TOKEN_COMMA);
1083 }
1084 }
1085 function parseArgument() {
1086 let expr = parseInlineExpression();
1087 if (expr.type !== "mesg") {
1088 return expr;
1089 }
1090 if (consumeToken(TOKEN_COLON)) {
1091 return {
1092 type: "narg",
1093 name: expr.name,
1094 value: parseLiteral()
1095 };
1096 }
1097 return expr;
1098 }
1099 function parseVariants() {
1100 let variants = [];
1101 let count = 0;
1102 let star;
1103 while (test(RE_VARIANT_START)) {
1104 if (consumeChar("*")) {
1105 star = count;
1106 }
1107 let key = parseVariantKey();
1108 let value = parsePattern();
1109 if (value === null) {
1110 throw new SyntaxError("Expected variant value");
1111 }
1112 variants[count++] = {
1113 key,
1114 value
1115 };
1116 }
1117 if (count === 0) {
1118 return null;
1119 }
1120 if (star === undefined) {
1121 throw new SyntaxError("Expected default variant");
1122 }
1123 return {
1124 variants,
1125 star
1126 };
1127 }
1128 function parseVariantKey() {
1129 consumeToken(TOKEN_BRACKET_OPEN, SyntaxError);
1130 let key;
1131 if (test(RE_NUMBER_LITERAL)) {
1132 key = parseNumberLiteral();
1133 } else {
1134 key = {
1135 type: "str",
1136 value: match1(RE_IDENTIFIER)
1137 };
1138 }
1139 consumeToken(TOKEN_BRACKET_CLOSE, SyntaxError);
1140 return key;
1141 }
1142 function parseLiteral() {
1143 if (test(RE_NUMBER_LITERAL)) {
1144 return parseNumberLiteral();
1145 }
1146 if (source[cursor] === '"') {
1147 return parseStringLiteral();
1148 }
1149 throw new SyntaxError("Invalid expression");
1150 }
1151 function parseNumberLiteral() {
1152 let [, value, fraction = ""] = match(RE_NUMBER_LITERAL);
1153 let precision = fraction.length;
1154 return {
1155 type: "num",
1156 value: parseFloat(value),
1157 precision
1158 };
1159 }
1160 function parseStringLiteral() {
1161 consumeChar('"', SyntaxError);
1162 let value = "";
1163 while (true) {
1164 value += match1(RE_STRING_RUN);
1165 if (source[cursor] === "\\") {
1166 value += parseEscapeSequence();
1167 continue;
1168 }
1169 if (consumeChar('"')) {
1170 return {
1171 type: "str",
1172 value
1173 };
1174 }
1175 throw new SyntaxError("Unclosed string literal");
1176 }
1177 }
1178 function parseEscapeSequence() {
1179 if (test(RE_STRING_ESCAPE)) {
1180 return match1(RE_STRING_ESCAPE);
1181 }
1182 if (test(RE_UNICODE_ESCAPE)) {
1183 let [, codepoint4, codepoint6] = match(RE_UNICODE_ESCAPE);
1184 let codepoint = parseInt(codepoint4 || codepoint6, 16);
1185 return codepoint <= 0xd7ff || 0xe000 <= codepoint ? String.fromCodePoint(codepoint) : "�";
1186 }
1187 throw new SyntaxError("Unknown escape sequence");
1188 }
1189 function parseIndent() {
1190 let start = cursor;
1191 consumeToken(TOKEN_BLANK);
1192 switch (source[cursor]) {
1193 case ".":
1194 case "[":
1195 case "*":
1196 case "}":
1197 case undefined:
1198 return false;
1199 case "{":
1200 return makeIndent(source.slice(start, cursor));
1201 }
1202 if (source[cursor - 1] === " ") {
1203 return makeIndent(source.slice(start, cursor));
1204 }
1205 return false;
1206 }
1207 function trim(text, re) {
1208 return text.replace(re, "");
1209 }
1210 function makeIndent(blank) {
1211 let value = blank.replace(RE_BLANK_LINES, "\n");
1212 let length = RE_INDENT.exec(blank)[1].length;
1213 return new Indent(value, length);
1214 }
1215 }
1216}
1217class Indent {
1218 constructor(value, length) {
1219 this.value = value;
1220 this.length = length;
1221 }
1222}
1223;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/index.js
1224
1225
1226
1227
1228/***/ }),
1229
1230/***/ 5273:
1231/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1232
1233
1234// EXPORTS
1235__webpack_require__.d(__webpack_exports__, {
1236 DOMLocalization: () => (/* reexport */ DOMLocalization)
1237});
1238
1239// UNUSED EXPORTS: Localization
1240
1241;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/overlay.js
1242const reOverlay = /<|&#?\w+;/;
1243const TEXT_LEVEL_ELEMENTS = {
1244 "http://www.w3.org/1999/xhtml": ["em", "strong", "small", "s", "cite", "q", "dfn", "abbr", "data", "time", "code", "var", "samp", "kbd", "sub", "sup", "i", "b", "u", "mark", "bdi", "bdo", "span", "br", "wbr"]
1245};
1246const LOCALIZABLE_ATTRIBUTES = {
1247 "http://www.w3.org/1999/xhtml": {
1248 global: ["title", "aria-label", "aria-valuetext"],
1249 a: ["download"],
1250 area: ["download", "alt"],
1251 input: ["alt", "placeholder"],
1252 menuitem: ["label"],
1253 menu: ["label"],
1254 optgroup: ["label"],
1255 option: ["label"],
1256 track: ["label"],
1257 img: ["alt"],
1258 textarea: ["placeholder"],
1259 th: ["abbr"]
1260 },
1261 "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul": {
1262 global: ["accesskey", "aria-label", "aria-valuetext", "label", "title", "tooltiptext"],
1263 description: ["value"],
1264 key: ["key", "keycode"],
1265 label: ["value"],
1266 textbox: ["placeholder", "value"]
1267 }
1268};
1269function translateElement(element, translation) {
1270 const {
1271 value
1272 } = translation;
1273 if (typeof value === "string") {
1274 if (element.localName === "title" && element.namespaceURI === "http://www.w3.org/1999/xhtml") {
1275 element.textContent = value;
1276 } else if (!reOverlay.test(value)) {
1277 element.textContent = value;
1278 } else {
1279 const templateElement = element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml", "template");
1280 templateElement.innerHTML = value;
1281 overlayChildNodes(templateElement.content, element);
1282 }
1283 }
1284 overlayAttributes(translation, element);
1285}
1286function overlayChildNodes(fromFragment, toElement) {
1287 for (const childNode of fromFragment.childNodes) {
1288 if (childNode.nodeType === childNode.TEXT_NODE) {
1289 continue;
1290 }
1291 if (childNode.hasAttribute("data-l10n-name")) {
1292 const sanitized = getNodeForNamedElement(toElement, childNode);
1293 fromFragment.replaceChild(sanitized, childNode);
1294 continue;
1295 }
1296 if (isElementAllowed(childNode)) {
1297 const sanitized = createSanitizedElement(childNode);
1298 fromFragment.replaceChild(sanitized, childNode);
1299 continue;
1300 }
1301 console.warn(`An element of forbidden type "${childNode.localName}" was found in ` + "the translation. Only safe text-level elements and elements with " + "data-l10n-name are allowed.");
1302 fromFragment.replaceChild(createTextNodeFromTextContent(childNode), childNode);
1303 }
1304 toElement.textContent = "";
1305 toElement.appendChild(fromFragment);
1306}
1307function hasAttribute(attributes, name) {
1308 if (!attributes) {
1309 return false;
1310 }
1311 for (let attr of attributes) {
1312 if (attr.name === name) {
1313 return true;
1314 }
1315 }
1316 return false;
1317}
1318function overlayAttributes(fromElement, toElement) {
1319 const explicitlyAllowed = toElement.hasAttribute("data-l10n-attrs") ? toElement.getAttribute("data-l10n-attrs").split(",").map(i => i.trim()) : null;
1320 for (const attr of Array.from(toElement.attributes)) {
1321 if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && !hasAttribute(fromElement.attributes, attr.name)) {
1322 toElement.removeAttribute(attr.name);
1323 }
1324 }
1325 if (!fromElement.attributes) {
1326 return;
1327 }
1328 for (const attr of Array.from(fromElement.attributes)) {
1329 if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && toElement.getAttribute(attr.name) !== attr.value) {
1330 toElement.setAttribute(attr.name, attr.value);
1331 }
1332 }
1333}
1334function getNodeForNamedElement(sourceElement, translatedChild) {
1335 const childName = translatedChild.getAttribute("data-l10n-name");
1336 const sourceChild = sourceElement.querySelector(`[data-l10n-name="${childName}"]`);
1337 if (!sourceChild) {
1338 console.warn(`An element named "${childName}" wasn't found in the source.`);
1339 return createTextNodeFromTextContent(translatedChild);
1340 }
1341 if (sourceChild.localName !== translatedChild.localName) {
1342 console.warn(`An element named "${childName}" was found in the translation ` + `but its type ${translatedChild.localName} didn't match the ` + `element found in the source (${sourceChild.localName}).`);
1343 return createTextNodeFromTextContent(translatedChild);
1344 }
1345 sourceElement.removeChild(sourceChild);
1346 const clone = sourceChild.cloneNode(false);
1347 return shallowPopulateUsing(translatedChild, clone);
1348}
1349function createSanitizedElement(element) {
1350 const clone = element.ownerDocument.createElement(element.localName);
1351 return shallowPopulateUsing(element, clone);
1352}
1353function createTextNodeFromTextContent(element) {
1354 return element.ownerDocument.createTextNode(element.textContent);
1355}
1356function isElementAllowed(element) {
1357 const allowed = TEXT_LEVEL_ELEMENTS[element.namespaceURI];
1358 return allowed && allowed.includes(element.localName);
1359}
1360function isAttrNameLocalizable(name, element, explicitlyAllowed = null) {
1361 if (explicitlyAllowed && explicitlyAllowed.includes(name)) {
1362 return true;
1363 }
1364 const allowed = LOCALIZABLE_ATTRIBUTES[element.namespaceURI];
1365 if (!allowed) {
1366 return false;
1367 }
1368 const attrName = name.toLowerCase();
1369 const elemName = element.localName;
1370 if (allowed.global.includes(attrName)) {
1371 return true;
1372 }
1373 if (!allowed[elemName]) {
1374 return false;
1375 }
1376 if (allowed[elemName].includes(attrName)) {
1377 return true;
1378 }
1379 if (element.namespaceURI === "http://www.w3.org/1999/xhtml" && elemName === "input" && attrName === "value") {
1380 const type = element.type.toLowerCase();
1381 if (type === "submit" || type === "button" || type === "reset") {
1382 return true;
1383 }
1384 }
1385 return false;
1386}
1387function shallowPopulateUsing(fromElement, toElement) {
1388 toElement.textContent = fromElement.textContent;
1389 overlayAttributes(fromElement, toElement);
1390 return toElement;
1391}
1392;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_iterable.mjs
1393class CachedIterable extends Array {
1394 static from(iterable) {
1395 if (iterable instanceof this) {
1396 return iterable;
1397 }
1398 return new this(iterable);
1399 }
1400}
1401;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_sync_iterable.mjs
1402
1403class CachedSyncIterable extends CachedIterable {
1404 constructor(iterable) {
1405 super();
1406 if (Symbol.iterator in Object(iterable)) {
1407 this.iterator = iterable[Symbol.iterator]();
1408 } else {
1409 throw new TypeError("Argument must implement the iteration protocol.");
1410 }
1411 }
1412 [Symbol.iterator]() {
1413 const cached = this;
1414 let cur = 0;
1415 return {
1416 next() {
1417 if (cached.length <= cur) {
1418 cached.push(cached.iterator.next());
1419 }
1420 return cached[cur++];
1421 }
1422 };
1423 }
1424 touchNext(count = 1) {
1425 let idx = 0;
1426 while (idx++ < count) {
1427 const last = this[this.length - 1];
1428 if (last && last.done) {
1429 break;
1430 }
1431 this.push(this.iterator.next());
1432 }
1433 return this[this.length - 1];
1434 }
1435}
1436;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_async_iterable.mjs
1437
1438class CachedAsyncIterable extends CachedIterable {
1439 constructor(iterable) {
1440 super();
1441 if (Symbol.asyncIterator in Object(iterable)) {
1442 this.iterator = iterable[Symbol.asyncIterator]();
1443 } else if (Symbol.iterator in Object(iterable)) {
1444 this.iterator = iterable[Symbol.iterator]();
1445 } else {
1446 throw new TypeError("Argument must implement the iteration protocol.");
1447 }
1448 }
1449 [Symbol.asyncIterator]() {
1450 const cached = this;
1451 let cur = 0;
1452 return {
1453 async next() {
1454 if (cached.length <= cur) {
1455 cached.push(cached.iterator.next());
1456 }
1457 return cached[cur++];
1458 }
1459 };
1460 }
1461 async touchNext(count = 1) {
1462 let idx = 0;
1463 while (idx++ < count) {
1464 const last = this[this.length - 1];
1465 if (last && (await last).done) {
1466 break;
1467 }
1468 this.push(this.iterator.next());
1469 }
1470 return this[this.length - 1];
1471 }
1472}
1473;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/index.mjs
1474
1475
1476;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/localization.js
1477
1478class Localization {
1479 constructor(resourceIds = [], generateBundles) {
1480 this.resourceIds = resourceIds;
1481 this.generateBundles = generateBundles;
1482 this.onChange(true);
1483 }
1484 addResourceIds(resourceIds, eager = false) {
1485 this.resourceIds.push(...resourceIds);
1486 this.onChange(eager);
1487 return this.resourceIds.length;
1488 }
1489 removeResourceIds(resourceIds) {
1490 this.resourceIds = this.resourceIds.filter(r => !resourceIds.includes(r));
1491 this.onChange();
1492 return this.resourceIds.length;
1493 }
1494 async formatWithFallback(keys, method) {
1495 const translations = [];
1496 let hasAtLeastOneBundle = false;
1497 for await (const bundle of this.bundles) {
1498 hasAtLeastOneBundle = true;
1499 const missingIds = keysFromBundle(method, bundle, keys, translations);
1500 if (missingIds.size === 0) {
1501 break;
1502 }
1503 if (typeof console !== "undefined") {
1504 const locale = bundle.locales[0];
1505 const ids = Array.from(missingIds).join(", ");
1506 console.warn(`[fluent] Missing translations in ${locale}: ${ids}`);
1507 }
1508 }
1509 if (!hasAtLeastOneBundle && typeof console !== "undefined") {
1510 console.warn(`[fluent] Request for keys failed because no resource bundles got generated.
1511 keys: ${JSON.stringify(keys)}.
1512 resourceIds: ${JSON.stringify(this.resourceIds)}.`);
1513 }
1514 return translations;
1515 }
1516 formatMessages(keys) {
1517 return this.formatWithFallback(keys, messageFromBundle);
1518 }
1519 formatValues(keys) {
1520 return this.formatWithFallback(keys, valueFromBundle);
1521 }
1522 async formatValue(id, args) {
1523 const [val] = await this.formatValues([{
1524 id,
1525 args
1526 }]);
1527 return val;
1528 }
1529 handleEvent() {
1530 this.onChange();
1531 }
1532 onChange(eager = false) {
1533 this.bundles = CachedAsyncIterable.from(this.generateBundles(this.resourceIds));
1534 if (eager) {
1535 this.bundles.touchNext(2);
1536 }
1537 }
1538}
1539function valueFromBundle(bundle, errors, message, args) {
1540 if (message.value) {
1541 return bundle.formatPattern(message.value, args, errors);
1542 }
1543 return null;
1544}
1545function messageFromBundle(bundle, errors, message, args) {
1546 const formatted = {
1547 value: null,
1548 attributes: null
1549 };
1550 if (message.value) {
1551 formatted.value = bundle.formatPattern(message.value, args, errors);
1552 }
1553 let attrNames = Object.keys(message.attributes);
1554 if (attrNames.length > 0) {
1555 formatted.attributes = new Array(attrNames.length);
1556 for (let [i, name] of attrNames.entries()) {
1557 let value = bundle.formatPattern(message.attributes[name], args, errors);
1558 formatted.attributes[i] = {
1559 name,
1560 value
1561 };
1562 }
1563 }
1564 return formatted;
1565}
1566function keysFromBundle(method, bundle, keys, translations) {
1567 const messageErrors = [];
1568 const missingIds = new Set();
1569 keys.forEach(({
1570 id,
1571 args
1572 }, i) => {
1573 if (translations[i] !== undefined) {
1574 return;
1575 }
1576 let message = bundle.getMessage(id);
1577 if (message) {
1578 messageErrors.length = 0;
1579 translations[i] = method(bundle, messageErrors, message, args);
1580 if (messageErrors.length > 0 && typeof console !== "undefined") {
1581 const locale = bundle.locales[0];
1582 const errors = messageErrors.join(", ");
1583 console.warn(`[fluent][resolver] errors in ${locale}/${id}: ${errors}.`);
1584 }
1585 } else {
1586 missingIds.add(id);
1587 }
1588 });
1589 return missingIds;
1590}
1591;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/dom_localization.js
1592
1593
1594const L10NID_ATTR_NAME = "data-l10n-id";
1595const L10NARGS_ATTR_NAME = "data-l10n-args";
1596const L10N_ELEMENT_QUERY = `[${L10NID_ATTR_NAME}]`;
1597class DOMLocalization extends Localization {
1598 constructor(resourceIds, generateBundles) {
1599 super(resourceIds, generateBundles);
1600 this.roots = new Set();
1601 this.pendingrAF = null;
1602 this.pendingElements = new Set();
1603 this.windowElement = null;
1604 this.mutationObserver = null;
1605 this.observerConfig = {
1606 attributes: true,
1607 characterData: false,
1608 childList: true,
1609 subtree: true,
1610 attributeFilter: [L10NID_ATTR_NAME, L10NARGS_ATTR_NAME]
1611 };
1612 }
1613 onChange(eager = false) {
1614 super.onChange(eager);
1615 if (this.roots) {
1616 this.translateRoots();
1617 }
1618 }
1619 setAttributes(element, id, args) {
1620 element.setAttribute(L10NID_ATTR_NAME, id);
1621 if (args) {
1622 element.setAttribute(L10NARGS_ATTR_NAME, JSON.stringify(args));
1623 } else {
1624 element.removeAttribute(L10NARGS_ATTR_NAME);
1625 }
1626 return element;
1627 }
1628 getAttributes(element) {
1629 return {
1630 id: element.getAttribute(L10NID_ATTR_NAME),
1631 args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null)
1632 };
1633 }
1634 connectRoot(newRoot) {
1635 for (const root of this.roots) {
1636 if (root === newRoot || root.contains(newRoot) || newRoot.contains(root)) {
1637 throw new Error("Cannot add a root that overlaps with existing root.");
1638 }
1639 }
1640 if (this.windowElement) {
1641 if (this.windowElement !== newRoot.ownerDocument.defaultView) {
1642 throw new Error(`Cannot connect a root:
1643 DOMLocalization already has a root from a different window.`);
1644 }
1645 } else {
1646 this.windowElement = newRoot.ownerDocument.defaultView;
1647 this.mutationObserver = new this.windowElement.MutationObserver(mutations => this.translateMutations(mutations));
1648 }
1649 this.roots.add(newRoot);
1650 this.mutationObserver.observe(newRoot, this.observerConfig);
1651 }
1652 disconnectRoot(root) {
1653 this.roots.delete(root);
1654 this.pauseObserving();
1655 if (this.roots.size === 0) {
1656 this.mutationObserver = null;
1657 this.windowElement = null;
1658 this.pendingrAF = null;
1659 this.pendingElements.clear();
1660 return true;
1661 }
1662 this.resumeObserving();
1663 return false;
1664 }
1665 translateRoots() {
1666 const roots = Array.from(this.roots);
1667 return Promise.all(roots.map(root => this.translateFragment(root)));
1668 }
1669 pauseObserving() {
1670 if (!this.mutationObserver) {
1671 return;
1672 }
1673 this.translateMutations(this.mutationObserver.takeRecords());
1674 this.mutationObserver.disconnect();
1675 }
1676 resumeObserving() {
1677 if (!this.mutationObserver) {
1678 return;
1679 }
1680 for (const root of this.roots) {
1681 this.mutationObserver.observe(root, this.observerConfig);
1682 }
1683 }
1684 translateMutations(mutations) {
1685 for (const mutation of mutations) {
1686 switch (mutation.type) {
1687 case "attributes":
1688 if (mutation.target.hasAttribute("data-l10n-id")) {
1689 this.pendingElements.add(mutation.target);
1690 }
1691 break;
1692 case "childList":
1693 for (const addedNode of mutation.addedNodes) {
1694 if (addedNode.nodeType === addedNode.ELEMENT_NODE) {
1695 if (addedNode.childElementCount) {
1696 for (const element of this.getTranslatables(addedNode)) {
1697 this.pendingElements.add(element);
1698 }
1699 } else if (addedNode.hasAttribute(L10NID_ATTR_NAME)) {
1700 this.pendingElements.add(addedNode);
1701 }
1702 }
1703 }
1704 break;
1705 }
1706 }
1707 if (this.pendingElements.size > 0) {
1708 if (this.pendingrAF === null) {
1709 this.pendingrAF = this.windowElement.requestAnimationFrame(() => {
1710 this.translateElements(Array.from(this.pendingElements));
1711 this.pendingElements.clear();
1712 this.pendingrAF = null;
1713 });
1714 }
1715 }
1716 }
1717 translateFragment(frag) {
1718 return this.translateElements(this.getTranslatables(frag));
1719 }
1720 async translateElements(elements) {
1721 if (!elements.length) {
1722 return undefined;
1723 }
1724 const keys = elements.map(this.getKeysForElement);
1725 const translations = await this.formatMessages(keys);
1726 return this.applyTranslations(elements, translations);
1727 }
1728 applyTranslations(elements, translations) {
1729 this.pauseObserving();
1730 for (let i = 0; i < elements.length; i++) {
1731 if (translations[i] !== undefined) {
1732 translateElement(elements[i], translations[i]);
1733 }
1734 }
1735 this.resumeObserving();
1736 }
1737 getTranslatables(element) {
1738 const nodes = Array.from(element.querySelectorAll(L10N_ELEMENT_QUERY));
1739 if (typeof element.hasAttribute === "function" && element.hasAttribute(L10NID_ATTR_NAME)) {
1740 nodes.push(element);
1741 }
1742 return nodes;
1743 }
1744 getKeysForElement(element) {
1745 return {
1746 id: element.getAttribute(L10NID_ATTR_NAME),
1747 args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null)
1748 };
1749 }
1750}
1751;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/index.js
1752
1753
1754
1755/***/ }),
1756
1757/***/ 4292:
1758/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1759
1760/* harmony export */ __webpack_require__.d(__webpack_exports__, {
1761/* harmony export */ warn: () => (/* binding */ warn)
1762/* harmony export */ });
1763/* unused harmony exports AbortException, AnnotationActionEventType, AnnotationBorderStyleType, AnnotationEditorParamsType, AnnotationEditorPrefix, AnnotationEditorType, AnnotationFieldFlag, AnnotationFlag, AnnotationMode, AnnotationPrefix, AnnotationReplyType, AnnotationType, assert, BaseException, BASELINE_FACTOR, bytesToString, CMapCompressionType, createValidAbsoluteUrl, DocumentActionEventType, FeatureTest, FONT_IDENTITY_MATRIX, FormatError, getModificationDate, getUuid, getVerbosityLevel, IDENTITY_MATRIX, ImageKind, info, InvalidPDFException, isArrayEqual, isNodeJS, LINE_DESCENT_FACTOR, LINE_FACTOR, MAX_IMAGE_SIZE_TO_CACHE, MissingPDFException, normalizeUnicode, objectFromMap, objectSize, OPS, PageActionEventType, PasswordException, PasswordResponses, PermissionFlag, RenderingIntentFlag, setVerbosityLevel, shadow, string32, stringToBytes, stringToPDFString, stringToUTF8String, TextRenderingMode, UnexpectedResponseException, UnknownErrorException, unreachable, utf8StringToString, Util, VerbosityLevel */
1764const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
1765const IDENTITY_MATRIX = (/* unused pure expression or super */ null && ([1, 0, 0, 1, 0, 0]));
1766const FONT_IDENTITY_MATRIX = (/* unused pure expression or super */ null && ([0.001, 0, 0, 0.001, 0, 0]));
1767const MAX_IMAGE_SIZE_TO_CACHE = 10e6;
1768const LINE_FACTOR = 1.35;
1769const LINE_DESCENT_FACTOR = 0.35;
1770const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
1771const RenderingIntentFlag = {
1772 ANY: 0x01,
1773 DISPLAY: 0x02,
1774 PRINT: 0x04,
1775 SAVE: 0x08,
1776 ANNOTATIONS_FORMS: 0x10,
1777 ANNOTATIONS_STORAGE: 0x20,
1778 ANNOTATIONS_DISABLE: 0x40,
1779 OPLIST: 0x100
1780};
1781const AnnotationMode = {
1782 DISABLE: 0,
1783 ENABLE: 1,
1784 ENABLE_FORMS: 2,
1785 ENABLE_STORAGE: 3
1786};
1787const AnnotationEditorPrefix = "pdfjs_internal_editor_";
1788const AnnotationEditorType = {
1789 DISABLE: -1,
1790 NONE: 0,
1791 FREETEXT: 3,
1792 HIGHLIGHT: 9,
1793 STAMP: 13,
1794 INK: 15
1795};
1796const AnnotationEditorParamsType = {
1797 RESIZE: 1,
1798 CREATE: 2,
1799 FREETEXT_SIZE: 11,
1800 FREETEXT_COLOR: 12,
1801 FREETEXT_OPACITY: 13,
1802 INK_COLOR: 21,
1803 INK_THICKNESS: 22,
1804 INK_OPACITY: 23,
1805 HIGHLIGHT_COLOR: 31,
1806 HIGHLIGHT_DEFAULT_COLOR: 32,
1807 HIGHLIGHT_THICKNESS: 33,
1808 HIGHLIGHT_FREE: 34,
1809 HIGHLIGHT_SHOW_ALL: 35
1810};
1811const PermissionFlag = {
1812 PRINT: 0x04,
1813 MODIFY_CONTENTS: 0x08,
1814 COPY: 0x10,
1815 MODIFY_ANNOTATIONS: 0x20,
1816 FILL_INTERACTIVE_FORMS: 0x100,
1817 COPY_FOR_ACCESSIBILITY: 0x200,
1818 ASSEMBLE: 0x400,
1819 PRINT_HIGH_QUALITY: 0x800
1820};
1821const TextRenderingMode = {
1822 FILL: 0,
1823 STROKE: 1,
1824 FILL_STROKE: 2,
1825 INVISIBLE: 3,
1826 FILL_ADD_TO_PATH: 4,
1827 STROKE_ADD_TO_PATH: 5,
1828 FILL_STROKE_ADD_TO_PATH: 6,
1829 ADD_TO_PATH: 7,
1830 FILL_STROKE_MASK: 3,
1831 ADD_TO_PATH_FLAG: 4
1832};
1833const ImageKind = {
1834 GRAYSCALE_1BPP: 1,
1835 RGB_24BPP: 2,
1836 RGBA_32BPP: 3
1837};
1838const AnnotationType = {
1839 TEXT: 1,
1840 LINK: 2,
1841 FREETEXT: 3,
1842 LINE: 4,
1843 SQUARE: 5,
1844 CIRCLE: 6,
1845 POLYGON: 7,
1846 POLYLINE: 8,
1847 HIGHLIGHT: 9,
1848 UNDERLINE: 10,
1849 SQUIGGLY: 11,
1850 STRIKEOUT: 12,
1851 STAMP: 13,
1852 CARET: 14,
1853 INK: 15,
1854 POPUP: 16,
1855 FILEATTACHMENT: 17,
1856 SOUND: 18,
1857 MOVIE: 19,
1858 WIDGET: 20,
1859 SCREEN: 21,
1860 PRINTERMARK: 22,
1861 TRAPNET: 23,
1862 WATERMARK: 24,
1863 THREED: 25,
1864 REDACT: 26
1865};
1866const AnnotationReplyType = {
1867 GROUP: "Group",
1868 REPLY: "R"
1869};
1870const AnnotationFlag = {
1871 INVISIBLE: 0x01,
1872 HIDDEN: 0x02,
1873 PRINT: 0x04,
1874 NOZOOM: 0x08,
1875 NOROTATE: 0x10,
1876 NOVIEW: 0x20,
1877 READONLY: 0x40,
1878 LOCKED: 0x80,
1879 TOGGLENOVIEW: 0x100,
1880 LOCKEDCONTENTS: 0x200
1881};
1882const AnnotationFieldFlag = {
1883 READONLY: 0x0000001,
1884 REQUIRED: 0x0000002,
1885 NOEXPORT: 0x0000004,
1886 MULTILINE: 0x0001000,
1887 PASSWORD: 0x0002000,
1888 NOTOGGLETOOFF: 0x0004000,
1889 RADIO: 0x0008000,
1890 PUSHBUTTON: 0x0010000,
1891 COMBO: 0x0020000,
1892 EDIT: 0x0040000,
1893 SORT: 0x0080000,
1894 FILESELECT: 0x0100000,
1895 MULTISELECT: 0x0200000,
1896 DONOTSPELLCHECK: 0x0400000,
1897 DONOTSCROLL: 0x0800000,
1898 COMB: 0x1000000,
1899 RICHTEXT: 0x2000000,
1900 RADIOSINUNISON: 0x2000000,
1901 COMMITONSELCHANGE: 0x4000000
1902};
1903const AnnotationBorderStyleType = {
1904 SOLID: 1,
1905 DASHED: 2,
1906 BEVELED: 3,
1907 INSET: 4,
1908 UNDERLINE: 5
1909};
1910const AnnotationActionEventType = {
1911 E: "Mouse Enter",
1912 X: "Mouse Exit",
1913 D: "Mouse Down",
1914 U: "Mouse Up",
1915 Fo: "Focus",
1916 Bl: "Blur",
1917 PO: "PageOpen",
1918 PC: "PageClose",
1919 PV: "PageVisible",
1920 PI: "PageInvisible",
1921 K: "Keystroke",
1922 F: "Format",
1923 V: "Validate",
1924 C: "Calculate"
1925};
1926const DocumentActionEventType = {
1927 WC: "WillClose",
1928 WS: "WillSave",
1929 DS: "DidSave",
1930 WP: "WillPrint",
1931 DP: "DidPrint"
1932};
1933const PageActionEventType = {
1934 O: "PageOpen",
1935 C: "PageClose"
1936};
1937const VerbosityLevel = {
1938 ERRORS: 0,
1939 WARNINGS: 1,
1940 INFOS: 5
1941};
1942const CMapCompressionType = {
1943 NONE: 0,
1944 BINARY: 1
1945};
1946const OPS = {
1947 dependency: 1,
1948 setLineWidth: 2,
1949 setLineCap: 3,
1950 setLineJoin: 4,
1951 setMiterLimit: 5,
1952 setDash: 6,
1953 setRenderingIntent: 7,
1954 setFlatness: 8,
1955 setGState: 9,
1956 save: 10,
1957 restore: 11,
1958 transform: 12,
1959 moveTo: 13,
1960 lineTo: 14,
1961 curveTo: 15,
1962 curveTo2: 16,
1963 curveTo3: 17,
1964 closePath: 18,
1965 rectangle: 19,
1966 stroke: 20,
1967 closeStroke: 21,
1968 fill: 22,
1969 eoFill: 23,
1970 fillStroke: 24,
1971 eoFillStroke: 25,
1972 closeFillStroke: 26,
1973 closeEOFillStroke: 27,
1974 endPath: 28,
1975 clip: 29,
1976 eoClip: 30,
1977 beginText: 31,
1978 endText: 32,
1979 setCharSpacing: 33,
1980 setWordSpacing: 34,
1981 setHScale: 35,
1982 setLeading: 36,
1983 setFont: 37,
1984 setTextRenderingMode: 38,
1985 setTextRise: 39,
1986 moveText: 40,
1987 setLeadingMoveText: 41,
1988 setTextMatrix: 42,
1989 nextLine: 43,
1990 showText: 44,
1991 showSpacedText: 45,
1992 nextLineShowText: 46,
1993 nextLineSetSpacingShowText: 47,
1994 setCharWidth: 48,
1995 setCharWidthAndBounds: 49,
1996 setStrokeColorSpace: 50,
1997 setFillColorSpace: 51,
1998 setStrokeColor: 52,
1999 setStrokeColorN: 53,
2000 setFillColor: 54,
2001 setFillColorN: 55,
2002 setStrokeGray: 56,
2003 setFillGray: 57,
2004 setStrokeRGBColor: 58,
2005 setFillRGBColor: 59,
2006 setStrokeCMYKColor: 60,
2007 setFillCMYKColor: 61,
2008 shadingFill: 62,
2009 beginInlineImage: 63,
2010 beginImageData: 64,
2011 endInlineImage: 65,
2012 paintXObject: 66,
2013 markPoint: 67,
2014 markPointProps: 68,
2015 beginMarkedContent: 69,
2016 beginMarkedContentProps: 70,
2017 endMarkedContent: 71,
2018 beginCompat: 72,
2019 endCompat: 73,
2020 paintFormXObjectBegin: 74,
2021 paintFormXObjectEnd: 75,
2022 beginGroup: 76,
2023 endGroup: 77,
2024 beginAnnotation: 80,
2025 endAnnotation: 81,
2026 paintImageMaskXObject: 83,
2027 paintImageMaskXObjectGroup: 84,
2028 paintImageXObject: 85,
2029 paintInlineImageXObject: 86,
2030 paintInlineImageXObjectGroup: 87,
2031 paintImageXObjectRepeat: 88,
2032 paintImageMaskXObjectRepeat: 89,
2033 paintSolidColorImageMask: 90,
2034 constructPath: 91
2035};
2036const PasswordResponses = {
2037 NEED_PASSWORD: 1,
2038 INCORRECT_PASSWORD: 2
2039};
2040let verbosity = VerbosityLevel.WARNINGS;
2041function setVerbosityLevel(level) {
2042 if (Number.isInteger(level)) {
2043 verbosity = level;
2044 }
2045}
2046function getVerbosityLevel() {
2047 return verbosity;
2048}
2049function info(msg) {
2050 if (verbosity >= VerbosityLevel.INFOS) {
2051 if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {
2052 console.log(`Info: ${msg}`);
2053 } else if (Window && globalThis.ngxConsole) {
2054 globalThis.ngxConsole.log(`Info: ${msg}`);
2055 } else {
2056 console.log(`Info: ${msg}`);
2057 }
2058 }
2059}
2060function warn(msg) {
2061 if (verbosity >= VerbosityLevel.WARNINGS) {
2062 if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {
2063 console.log(`Warning: ${msg}`);
2064 } else if (Window && globalThis.ngxConsole) {
2065 globalThis.ngxConsole.log(`Warning: ${msg}`);
2066 } else {
2067 console.log(`Warning: ${msg}`);
2068 }
2069 }
2070}
2071function unreachable(msg) {
2072 throw new Error(msg);
2073}
2074function assert(cond, msg) {
2075 if (!cond) {
2076 unreachable(msg);
2077 }
2078}
2079function _isValidProtocol(url) {
2080 switch (url?.protocol) {
2081 case "http:":
2082 case "https:":
2083 case "ftp:":
2084 case "mailto:":
2085 case "tel:":
2086 case "capacitor":
2087 return true;
2088 default:
2089 return false;
2090 }
2091}
2092function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
2093 if (!url) {
2094 return null;
2095 }
2096 try {
2097 if (options && typeof url === "string") {
2098 if (options.addDefaultProtocol && url.startsWith("www.")) {
2099 const dots = url.match(/\./g);
2100 if (dots?.length >= 2) {
2101 url = `http://${url}`;
2102 }
2103 }
2104 if (options.tryConvertEncoding) {
2105 try {
2106 url = stringToUTF8String(url);
2107 } catch {}
2108 }
2109 }
2110 const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
2111 if (_isValidProtocol(absoluteUrl)) {
2112 return absoluteUrl;
2113 }
2114 } catch {}
2115 return null;
2116}
2117function shadow(obj, prop, value, nonSerializable = false) {
2118 Object.defineProperty(obj, prop, {
2119 value,
2120 enumerable: !nonSerializable,
2121 configurable: true,
2122 writable: false
2123 });
2124 return value;
2125}
2126const BaseException = function BaseExceptionClosure() {
2127 function BaseException(message, name) {
2128 if (this.constructor === BaseException) {
2129 unreachable("Cannot initialize BaseException.");
2130 }
2131 this.message = message;
2132 this.name = name;
2133 }
2134 BaseException.prototype = new Error();
2135 BaseException.constructor = BaseException;
2136 return BaseException;
2137}();
2138class PasswordException extends BaseException {
2139 constructor(msg, code) {
2140 super(msg, "PasswordException");
2141 this.code = code;
2142 }
2143}
2144class UnknownErrorException extends BaseException {
2145 constructor(msg, details) {
2146 super(msg, "UnknownErrorException");
2147 this.details = details;
2148 }
2149}
2150class InvalidPDFException extends BaseException {
2151 constructor(msg) {
2152 super(msg, "InvalidPDFException");
2153 }
2154}
2155class MissingPDFException extends BaseException {
2156 constructor(msg) {
2157 super(msg, "MissingPDFException");
2158 }
2159}
2160class UnexpectedResponseException extends BaseException {
2161 constructor(msg, status) {
2162 super(msg, "UnexpectedResponseException");
2163 this.status = status;
2164 }
2165}
2166class FormatError extends BaseException {
2167 constructor(msg) {
2168 super(msg, "FormatError");
2169 }
2170}
2171class AbortException extends BaseException {
2172 constructor(msg) {
2173 super(msg, "AbortException");
2174 }
2175}
2176function bytesToString(bytes) {
2177 if (typeof bytes !== "object" || bytes?.length === undefined) {
2178 unreachable("Invalid argument for bytesToString");
2179 }
2180 const length = bytes.length;
2181 const MAX_ARGUMENT_COUNT = 8192;
2182 if (length < MAX_ARGUMENT_COUNT) {
2183 return String.fromCharCode.apply(null, bytes);
2184 }
2185 const strBuf = [];
2186 for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
2187 const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
2188 const chunk = bytes.subarray(i, chunkEnd);
2189 strBuf.push(String.fromCharCode.apply(null, chunk));
2190 }
2191 return strBuf.join("");
2192}
2193function stringToBytes(str) {
2194 if (typeof str !== "string") {
2195 unreachable("Invalid argument for stringToBytes");
2196 }
2197 const length = str.length;
2198 const bytes = new Uint8Array(length);
2199 for (let i = 0; i < length; ++i) {
2200 bytes[i] = str.charCodeAt(i) & 0xff;
2201 }
2202 return bytes;
2203}
2204function string32(value) {
2205 return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
2206}
2207function objectSize(obj) {
2208 return Object.keys(obj).length;
2209}
2210function objectFromMap(map) {
2211 const obj = Object.create(null);
2212 for (const [key, value] of map) {
2213 obj[key] = value;
2214 }
2215 return obj;
2216}
2217function isLittleEndian() {
2218 const buffer8 = new Uint8Array(4);
2219 buffer8[0] = 1;
2220 const view32 = new Uint32Array(buffer8.buffer, 0, 1);
2221 return view32[0] === 1;
2222}
2223function isEvalSupported() {
2224 try {
2225 new Function("");
2226 return true;
2227 } catch {
2228 return false;
2229 }
2230}
2231class FeatureTest {
2232 static get isLittleEndian() {
2233 return shadow(this, "isLittleEndian", isLittleEndian());
2234 }
2235 static get isEvalSupported() {
2236 return shadow(this, "isEvalSupported", isEvalSupported());
2237 }
2238 static get isOffscreenCanvasSupported() {
2239 return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
2240 }
2241 static get platform() {
2242 if (typeof navigator !== "undefined" && typeof navigator?.platform === "string") {
2243 return shadow(this, "platform", {
2244 isMac: navigator.platform.includes("Mac")
2245 });
2246 }
2247 return shadow(this, "platform", {
2248 isMac: false
2249 });
2250 }
2251 static get isCSSRoundSupported() {
2252 return shadow(this, "isCSSRoundSupported", globalThis.CSS?.supports?.("width: round(1.5px, 1px)"));
2253 }
2254}
2255const hexNumbers = Array.from(Array(256).keys(), n => n.toString(16).padStart(2, "0"));
2256class Util {
2257 static makeHexColor(r, g, b) {
2258 return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
2259 }
2260 static scaleMinMax(transform, minMax) {
2261 let temp;
2262 if (transform[0]) {
2263 if (transform[0] < 0) {
2264 temp = minMax[0];
2265 minMax[0] = minMax[2];
2266 minMax[2] = temp;
2267 }
2268 minMax[0] *= transform[0];
2269 minMax[2] *= transform[0];
2270 if (transform[3] < 0) {
2271 temp = minMax[1];
2272 minMax[1] = minMax[3];
2273 minMax[3] = temp;
2274 }
2275 minMax[1] *= transform[3];
2276 minMax[3] *= transform[3];
2277 } else {
2278 temp = minMax[0];
2279 minMax[0] = minMax[1];
2280 minMax[1] = temp;
2281 temp = minMax[2];
2282 minMax[2] = minMax[3];
2283 minMax[3] = temp;
2284 if (transform[1] < 0) {
2285 temp = minMax[1];
2286 minMax[1] = minMax[3];
2287 minMax[3] = temp;
2288 }
2289 minMax[1] *= transform[1];
2290 minMax[3] *= transform[1];
2291 if (transform[2] < 0) {
2292 temp = minMax[0];
2293 minMax[0] = minMax[2];
2294 minMax[2] = temp;
2295 }
2296 minMax[0] *= transform[2];
2297 minMax[2] *= transform[2];
2298 }
2299 minMax[0] += transform[4];
2300 minMax[1] += transform[5];
2301 minMax[2] += transform[4];
2302 minMax[3] += transform[5];
2303 }
2304 static transform(m1, m2) {
2305 return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
2306 }
2307 static applyTransform(p, m) {
2308 const xt = p[0] * m[0] + p[1] * m[2] + m[4];
2309 const yt = p[0] * m[1] + p[1] * m[3] + m[5];
2310 return [xt, yt];
2311 }
2312 static applyInverseTransform(p, m) {
2313 const d = m[0] * m[3] - m[1] * m[2];
2314 const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
2315 const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
2316 return [xt, yt];
2317 }
2318 static getAxialAlignedBoundingBox(r, m) {
2319 const p1 = this.applyTransform(r, m);
2320 const p2 = this.applyTransform(r.slice(2, 4), m);
2321 const p3 = this.applyTransform([r[0], r[3]], m);
2322 const p4 = this.applyTransform([r[2], r[1]], m);
2323 return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
2324 }
2325 static inverseTransform(m) {
2326 const d = m[0] * m[3] - m[1] * m[2];
2327 return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
2328 }
2329 static singularValueDecompose2dScale(m) {
2330 const transpose = [m[0], m[2], m[1], m[3]];
2331 const a = m[0] * transpose[0] + m[1] * transpose[2];
2332 const b = m[0] * transpose[1] + m[1] * transpose[3];
2333 const c = m[2] * transpose[0] + m[3] * transpose[2];
2334 const d = m[2] * transpose[1] + m[3] * transpose[3];
2335 const first = (a + d) / 2;
2336 const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
2337 const sx = first + second || 1;
2338 const sy = first - second || 1;
2339 return [Math.sqrt(sx), Math.sqrt(sy)];
2340 }
2341 static normalizeRect(rect) {
2342 const r = rect.slice(0);
2343 if (rect[0] > rect[2]) {
2344 r[0] = rect[2];
2345 r[2] = rect[0];
2346 }
2347 if (rect[1] > rect[3]) {
2348 r[1] = rect[3];
2349 r[3] = rect[1];
2350 }
2351 return r;
2352 }
2353 static intersect(rect1, rect2) {
2354 const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
2355 const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
2356 if (xLow > xHigh) {
2357 return null;
2358 }
2359 const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
2360 const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
2361 if (yLow > yHigh) {
2362 return null;
2363 }
2364 return [xLow, yLow, xHigh, yHigh];
2365 }
2366 static #getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {
2367 if (t <= 0 || t >= 1) {
2368 return;
2369 }
2370 const mt = 1 - t;
2371 const tt = t * t;
2372 const ttt = tt * t;
2373 const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;
2374 const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;
2375 minMax[0] = Math.min(minMax[0], x);
2376 minMax[1] = Math.min(minMax[1], y);
2377 minMax[2] = Math.max(minMax[2], x);
2378 minMax[3] = Math.max(minMax[3], y);
2379 }
2380 static #getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
2381 if (Math.abs(a) < 1e-12) {
2382 if (Math.abs(b) >= 1e-12) {
2383 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, -c / b, minMax);
2384 }
2385 return;
2386 }
2387 const delta = b ** 2 - 4 * c * a;
2388 if (delta < 0) {
2389 return;
2390 }
2391 const sqrtDelta = Math.sqrt(delta);
2392 const a2 = 2 * a;
2393 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
2394 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
2395 }
2396 static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
2397 if (minMax) {
2398 minMax[0] = Math.min(minMax[0], x0, x3);
2399 minMax[1] = Math.min(minMax[1], y0, y3);
2400 minMax[2] = Math.max(minMax[2], x0, x3);
2401 minMax[3] = Math.max(minMax[3], y0, y3);
2402 } else {
2403 minMax = [Math.min(x0, x3), Math.min(y0, y3), Math.max(x0, x3), Math.max(y0, y3)];
2404 }
2405 this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-x0 + 3 * (x1 - x2) + x3), 6 * (x0 - 2 * x1 + x2), 3 * (x1 - x0), minMax);
2406 this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-y0 + 3 * (y1 - y2) + y3), 6 * (y0 - 2 * y1 + y2), 3 * (y1 - y0), minMax);
2407 return minMax;
2408 }
2409}
2410const PDFStringTranslateTable = (/* unused pure expression or super */ null && ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac]));
2411function stringToPDFString(str) {
2412 if (str[0] >= "\xEF") {
2413 let encoding;
2414 if (str[0] === "\xFE" && str[1] === "\xFF") {
2415 encoding = "utf-16be";
2416 if (str.length % 2 === 1) {
2417 str = str.slice(0, -1);
2418 }
2419 } else if (str[0] === "\xFF" && str[1] === "\xFE") {
2420 encoding = "utf-16le";
2421 if (str.length % 2 === 1) {
2422 str = str.slice(0, -1);
2423 }
2424 } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
2425 encoding = "utf-8";
2426 }
2427 if (encoding) {
2428 try {
2429 const decoder = new TextDecoder(encoding, {
2430 fatal: true
2431 });
2432 const buffer = stringToBytes(str);
2433 const decoded = decoder.decode(buffer);
2434 if (!decoded.includes("\x1b")) {
2435 return decoded;
2436 }
2437 return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
2438 } catch (ex) {
2439 warn(`stringToPDFString: "${ex}".`);
2440 }
2441 }
2442 }
2443 const strBuf = [];
2444 for (let i = 0, ii = str.length; i < ii; i++) {
2445 const charCode = str.charCodeAt(i);
2446 if (charCode === 0x1b) {
2447 while (++i < ii && str.charCodeAt(i) !== 0x1b) {}
2448 continue;
2449 }
2450 const code = PDFStringTranslateTable[charCode];
2451 strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
2452 }
2453 return strBuf.join("");
2454}
2455function stringToUTF8String(str) {
2456 return decodeURIComponent(escape(str));
2457}
2458function utf8StringToString(str) {
2459 return unescape(encodeURIComponent(str));
2460}
2461function isArrayEqual(arr1, arr2) {
2462 if (arr1.length !== arr2.length) {
2463 return false;
2464 }
2465 for (let i = 0, ii = arr1.length; i < ii; i++) {
2466 if (arr1[i] !== arr2[i]) {
2467 return false;
2468 }
2469 }
2470 return true;
2471}
2472function getModificationDate(date = new Date()) {
2473 const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
2474 return buffer.join("");
2475}
2476let NormalizeRegex = null;
2477let NormalizationMap = null;
2478function normalizeUnicode(str) {
2479 if (!NormalizeRegex) {
2480 NormalizeRegex = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;
2481 NormalizationMap = new Map([["ſt", "ſt"]]);
2482 }
2483 return str.replaceAll(NormalizeRegex, (_, p1, p2) => p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2));
2484}
2485function getUuid() {
2486 if (typeof crypto !== "undefined" && typeof crypto?.randomUUID === "function") {
2487 return crypto.randomUUID();
2488 }
2489 const buf = new Uint8Array(32);
2490 if (typeof crypto !== "undefined" && typeof crypto?.getRandomValues === "function") {
2491 crypto.getRandomValues(buf);
2492 } else {
2493 for (let i = 0; i < 32; i++) {
2494 buf[i] = Math.floor(Math.random() * 255);
2495 }
2496 }
2497 return bytesToString(buf);
2498}
2499const AnnotationPrefix = "pdfjs_internal_id_";
2500
2501
2502/***/ }),
2503
2504/***/ 259:
2505/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
2506
2507__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
2508/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2509/* harmony export */ AltTextManager: () => (/* binding */ AltTextManager)
2510/* harmony export */ });
2511/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
2512var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
2513pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
2514
2515class AltTextManager {
2516 #boundUpdateUIState = this.#updateUIState.bind(this);
2517 #boundSetPosition = this.#setPosition.bind(this);
2518 #boundOnClick = this.#onClick.bind(this);
2519 #currentEditor = null;
2520 #cancelButton;
2521 #dialog;
2522 #eventBus;
2523 #hasUsedPointer = false;
2524 #optionDescription;
2525 #optionDecorative;
2526 #overlayManager;
2527 #saveButton;
2528 #textarea;
2529 #uiManager;
2530 #previousAltText = null;
2531 #svgElement = null;
2532 #rectElement = null;
2533 #container;
2534 #telemetryData = null;
2535 constructor({
2536 dialog,
2537 optionDescription,
2538 optionDecorative,
2539 textarea,
2540 cancelButton,
2541 saveButton
2542 }, container, overlayManager, eventBus) {
2543 this.#dialog = dialog;
2544 this.#optionDescription = optionDescription;
2545 this.#optionDecorative = optionDecorative;
2546 this.#textarea = textarea;
2547 this.#cancelButton = cancelButton;
2548 this.#saveButton = saveButton;
2549 this.#overlayManager = overlayManager;
2550 this.#eventBus = eventBus;
2551 this.#container = container;
2552 dialog.addEventListener("close", this.#close.bind(this));
2553 dialog.addEventListener("contextmenu", event => {
2554 if (event.target !== this.#textarea) {
2555 event.preventDefault();
2556 }
2557 });
2558 cancelButton.addEventListener("click", this.#finish.bind(this));
2559 saveButton.addEventListener("click", this.#save.bind(this));
2560 optionDescription.addEventListener("change", this.#boundUpdateUIState);
2561 optionDecorative.addEventListener("change", this.#boundUpdateUIState);
2562 this.#overlayManager.register(dialog);
2563 }
2564 get _elements() {
2565 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_elements", [this.#optionDescription, this.#optionDecorative, this.#textarea, this.#saveButton, this.#cancelButton]);
2566 }
2567 #createSVGElement() {
2568 if (this.#svgElement) {
2569 return;
2570 }
2571 const svgFactory = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.DOMSVGFactory();
2572 const svg = this.#svgElement = svgFactory.createElement("svg");
2573 svg.setAttribute("width", "0");
2574 svg.setAttribute("height", "0");
2575 const defs = svgFactory.createElement("defs");
2576 svg.append(defs);
2577 const mask = svgFactory.createElement("mask");
2578 defs.append(mask);
2579 mask.setAttribute("id", "alttext-manager-mask");
2580 mask.setAttribute("maskContentUnits", "objectBoundingBox");
2581 let rect = svgFactory.createElement("rect");
2582 mask.append(rect);
2583 rect.setAttribute("fill", "white");
2584 rect.setAttribute("width", "1");
2585 rect.setAttribute("height", "1");
2586 rect.setAttribute("x", "0");
2587 rect.setAttribute("y", "0");
2588 rect = this.#rectElement = svgFactory.createElement("rect");
2589 mask.append(rect);
2590 rect.setAttribute("fill", "black");
2591 this.#dialog.append(svg);
2592 }
2593 async editAltText(uiManager, editor) {
2594 if (this.#currentEditor || !editor) {
2595 return;
2596 }
2597 this.#createSVGElement();
2598 this.#hasUsedPointer = false;
2599 for (const element of this._elements) {
2600 element.addEventListener("click", this.#boundOnClick);
2601 }
2602 const {
2603 altText,
2604 decorative
2605 } = editor.altTextData;
2606 if (decorative === true) {
2607 this.#optionDecorative.checked = true;
2608 this.#optionDescription.checked = false;
2609 } else {
2610 this.#optionDecorative.checked = false;
2611 this.#optionDescription.checked = true;
2612 }
2613 this.#previousAltText = this.#textarea.value = altText?.trim() || "";
2614 this.#updateUIState();
2615 this.#currentEditor = editor;
2616 this.#uiManager = uiManager;
2617 this.#uiManager.removeEditListeners();
2618 this.#eventBus._on("resize", this.#boundSetPosition);
2619 try {
2620 await this.#overlayManager.open(this.#dialog);
2621 this.#setPosition();
2622 } catch (ex) {
2623 this.#close();
2624 throw ex;
2625 }
2626 }
2627 #setPosition() {
2628 if (!this.#currentEditor) {
2629 return;
2630 }
2631 const dialog = this.#dialog;
2632 const {
2633 style
2634 } = dialog;
2635 const {
2636 x: containerX,
2637 y: containerY,
2638 width: containerW,
2639 height: containerH
2640 } = this.#container.getBoundingClientRect();
2641 const {
2642 innerWidth: windowW,
2643 innerHeight: windowH
2644 } = window;
2645 const {
2646 width: dialogW,
2647 height: dialogH
2648 } = dialog.getBoundingClientRect();
2649 const {
2650 x,
2651 y,
2652 width,
2653 height
2654 } = this.#currentEditor.getClientDimensions();
2655 const MARGIN = 10;
2656 const isLTR = this.#uiManager.direction === "ltr";
2657 const xs = Math.max(x, containerX);
2658 const xe = Math.min(x + width, containerX + containerW);
2659 const ys = Math.max(y, containerY);
2660 const ye = Math.min(y + height, containerY + containerH);
2661 this.#rectElement.setAttribute("width", `${(xe - xs) / windowW}`);
2662 this.#rectElement.setAttribute("height", `${(ye - ys) / windowH}`);
2663 this.#rectElement.setAttribute("x", `${xs / windowW}`);
2664 this.#rectElement.setAttribute("y", `${ys / windowH}`);
2665 let left = null;
2666 let top = Math.max(y, 0);
2667 top += Math.min(windowH - (top + dialogH), 0);
2668 if (isLTR) {
2669 if (x + width + MARGIN + dialogW < windowW) {
2670 left = x + width + MARGIN;
2671 } else if (x > dialogW + MARGIN) {
2672 left = x - dialogW - MARGIN;
2673 }
2674 } else if (x > dialogW + MARGIN) {
2675 left = x - dialogW - MARGIN;
2676 } else if (x + width + MARGIN + dialogW < windowW) {
2677 left = x + width + MARGIN;
2678 }
2679 if (left === null) {
2680 top = null;
2681 left = Math.max(x, 0);
2682 left += Math.min(windowW - (left + dialogW), 0);
2683 if (y > dialogH + MARGIN) {
2684 top = y - dialogH - MARGIN;
2685 } else if (y + height + MARGIN + dialogH < windowH) {
2686 top = y + height + MARGIN;
2687 }
2688 }
2689 if (top !== null) {
2690 dialog.classList.add("positioned");
2691 if (isLTR) {
2692 style.left = `${left}px`;
2693 } else {
2694 style.right = `${windowW - left - dialogW}px`;
2695 }
2696 style.top = `${top}px`;
2697 } else {
2698 dialog.classList.remove("positioned");
2699 style.left = "";
2700 style.top = "";
2701 }
2702 }
2703 #finish() {
2704 if (this.#overlayManager.active === this.#dialog) {
2705 this.#overlayManager.close(this.#dialog);
2706 }
2707 }
2708 #close() {
2709 this.#currentEditor._reportTelemetry(this.#telemetryData || {
2710 action: "alt_text_cancel",
2711 alt_text_keyboard: !this.#hasUsedPointer
2712 });
2713 this.#telemetryData = null;
2714 this.#removeOnClickListeners();
2715 this.#uiManager?.addEditListeners();
2716 this.#eventBus._off("resize", this.#boundSetPosition);
2717 this.#currentEditor.altTextFinish();
2718 this.#currentEditor = null;
2719 this.#uiManager = null;
2720 }
2721 #updateUIState() {
2722 this.#textarea.disabled = this.#optionDecorative.checked;
2723 }
2724 #save() {
2725 const altText = this.#textarea.value.trim();
2726 const decorative = this.#optionDecorative.checked;
2727 this.#currentEditor.altTextData = {
2728 altText,
2729 decorative
2730 };
2731 this.#telemetryData = {
2732 action: "alt_text_save",
2733 alt_text_description: !!altText,
2734 alt_text_edit: !!this.#previousAltText && this.#previousAltText !== altText,
2735 alt_text_decorative: decorative,
2736 alt_text_keyboard: !this.#hasUsedPointer
2737 };
2738 this.#finish();
2739 }
2740 #onClick(evt) {
2741 if (evt.detail === 0) {
2742 return;
2743 }
2744 this.#hasUsedPointer = true;
2745 this.#removeOnClickListeners();
2746 }
2747 #removeOnClickListeners() {
2748 for (const element of this._elements) {
2749 element.removeEventListener("click", this.#boundOnClick);
2750 }
2751 }
2752 destroy() {
2753 this.#uiManager = null;
2754 this.#finish();
2755 this.#svgElement?.remove();
2756 this.#svgElement = this.#rectElement = null;
2757 }
2758}
2759
2760__webpack_async_result__();
2761} catch(e) { __webpack_async_result__(e); } });
2762
2763/***/ }),
2764
2765/***/ 283:
2766/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
2767
2768__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
2769/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2770/* harmony export */ AnnotationEditorLayerBuilder: () => (/* binding */ AnnotationEditorLayerBuilder)
2771/* harmony export */ });
2772/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
2773/* harmony import */ var web_null_l10n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(410);
2774var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_null_l10n__WEBPACK_IMPORTED_MODULE_1__]);
2775([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_null_l10n__WEBPACK_IMPORTED_MODULE_1__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
2776
2777
2778class AnnotationEditorLayerBuilder {
2779 #annotationLayer = null;
2780 #drawLayer = null;
2781 #onAppend = null;
2782 #textLayer = null;
2783 #uiManager;
2784 constructor(options) {
2785 this.pdfPage = options.pdfPage;
2786 this.accessibilityManager = options.accessibilityManager;
2787 this.l10n = options.l10n;
2788 this.l10n ||= new web_null_l10n__WEBPACK_IMPORTED_MODULE_1__.GenericL10n();
2789 this.annotationEditorLayer = null;
2790 this.div = null;
2791 this._cancelled = false;
2792 this.#uiManager = options.uiManager;
2793 this.#annotationLayer = options.annotationLayer || null;
2794 this.#textLayer = options.textLayer || null;
2795 this.#drawLayer = options.drawLayer || null;
2796 this.#onAppend = options.onAppend || null;
2797 this.eventBus = options.eventBus;
2798 }
2799 async render(viewport, intent = "display") {
2800 if (intent !== "display") {
2801 return;
2802 }
2803 if (this._cancelled) {
2804 return;
2805 }
2806 const clonedViewport = viewport.clone({
2807 dontFlip: true
2808 });
2809 if (this.div) {
2810 this.annotationEditorLayer.update({
2811 viewport: clonedViewport
2812 });
2813 this.show();
2814 return;
2815 }
2816 const div = this.div = document.createElement("div");
2817 div.className = "annotationEditorLayer";
2818 div.hidden = true;
2819 div.dir = this.#uiManager.direction;
2820 this.#onAppend?.(div);
2821 this.annotationEditorLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorLayer({
2822 uiManager: this.#uiManager,
2823 div,
2824 accessibilityManager: this.accessibilityManager,
2825 pageIndex: this.pdfPage.pageNumber - 1,
2826 l10n: this.l10n,
2827 viewport: clonedViewport,
2828 annotationLayer: this.#annotationLayer,
2829 textLayer: this.#textLayer,
2830 drawLayer: this.#drawLayer,
2831 eventBus: this.eventBus
2832 });
2833 const parameters = {
2834 viewport: clonedViewport,
2835 div,
2836 annotations: null,
2837 intent
2838 };
2839 this.annotationEditorLayer.render(parameters);
2840 this.show();
2841 }
2842 cancel() {
2843 this._cancelled = true;
2844 if (!this.div) {
2845 return;
2846 }
2847 this.annotationEditorLayer.destroy();
2848 }
2849 hide() {
2850 if (!this.div) {
2851 return;
2852 }
2853 this.div.hidden = true;
2854 }
2855 show() {
2856 if (!this.div || this.annotationEditorLayer.isInvisible) {
2857 return;
2858 }
2859 this.div.hidden = false;
2860 }
2861}
2862
2863__webpack_async_result__();
2864} catch(e) { __webpack_async_result__(e); } });
2865
2866/***/ }),
2867
2868/***/ 226:
2869/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
2870
2871__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
2872/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2873/* harmony export */ AnnotationEditorParams: () => (/* binding */ AnnotationEditorParams)
2874/* harmony export */ });
2875/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
2876var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
2877pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
2878
2879class AnnotationEditorParams {
2880 constructor(options, eventBus) {
2881 this.eventBus = eventBus;
2882 this.#bindListeners(options);
2883 }
2884 #bindListeners({
2885 editorFreeTextFontSize,
2886 editorFreeTextColor,
2887 editorInkColor,
2888 editorInkThickness,
2889 editorInkOpacity,
2890 editorStampAddImage,
2891 editorFreeHighlightThickness,
2892 editorHighlightShowAll
2893 }) {
2894 const dispatchEvent = (typeStr, value) => {
2895 this.eventBus.dispatch("switchannotationeditorparams", {
2896 source: this,
2897 type: pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType[typeStr],
2898 value
2899 });
2900 };
2901 editorFreeTextFontSize.addEventListener("input", function () {
2902 dispatchEvent("FREETEXT_SIZE", this.valueAsNumber);
2903 });
2904 editorFreeTextColor.addEventListener("input", function () {
2905 dispatchEvent("FREETEXT_COLOR", this.value);
2906 });
2907 editorInkColor.addEventListener("input", function () {
2908 dispatchEvent("INK_COLOR", this.value);
2909 });
2910 editorInkThickness.addEventListener("input", function () {
2911 dispatchEvent("INK_THICKNESS", this.valueAsNumber);
2912 });
2913 editorInkOpacity.addEventListener("input", function () {
2914 dispatchEvent("INK_OPACITY", this.valueAsNumber);
2915 });
2916 editorStampAddImage.addEventListener("click", () => {
2917 dispatchEvent("CREATE");
2918 });
2919 editorFreeHighlightThickness.addEventListener("input", function () {
2920 dispatchEvent("HIGHLIGHT_THICKNESS", this.valueAsNumber);
2921 });
2922 editorHighlightShowAll.addEventListener("click", function () {
2923 const checked = this.getAttribute("aria-pressed") === "true";
2924 this.setAttribute("aria-pressed", !checked);
2925 dispatchEvent("HIGHLIGHT_SHOW_ALL", !checked);
2926 });
2927 this.eventBus._on("annotationeditorparamschanged", evt => {
2928 for (const [type, value] of evt.details) {
2929 switch (type) {
2930 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.FREETEXT_SIZE:
2931 editorFreeTextFontSize.value = value;
2932 break;
2933 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.FREETEXT_COLOR:
2934 editorFreeTextColor.value = value;
2935 break;
2936 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_COLOR:
2937 editorInkColor.value = value;
2938 break;
2939 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_THICKNESS:
2940 editorInkThickness.value = value;
2941 break;
2942 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_OPACITY:
2943 editorInkOpacity.value = value;
2944 break;
2945 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
2946 editorFreeHighlightThickness.value = value;
2947 break;
2948 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.HIGHLIGHT_FREE:
2949 editorFreeHighlightThickness.disabled = !value;
2950 break;
2951 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
2952 editorHighlightShowAll.setAttribute("aria-pressed", value);
2953 break;
2954 }
2955 }
2956 });
2957 }
2958}
2959
2960__webpack_async_result__();
2961} catch(e) { __webpack_async_result__(e); } });
2962
2963/***/ }),
2964
2965/***/ 2707:
2966/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
2967
2968__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
2969/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2970/* harmony export */ AnnotationLayerBuilder: () => (/* binding */ AnnotationLayerBuilder)
2971/* harmony export */ });
2972/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
2973/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
2974var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
2975pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
2976
2977
2978class AnnotationLayerBuilder {
2979 #onAppend = null;
2980 #eventAbortController = null;
2981 constructor({
2982 pdfPage,
2983 linkService,
2984 downloadManager,
2985 annotationStorage = null,
2986 imageResourcesPath = "",
2987 renderForms = true,
2988 enableScripting = false,
2989 hasJSActionsPromise = null,
2990 fieldObjectsPromise = null,
2991 annotationCanvasMap = null,
2992 accessibilityManager = null,
2993 annotationEditorUIManager = null,
2994 onAppend = null
2995 }) {
2996 this.pdfPage = pdfPage;
2997 this.linkService = linkService;
2998 this.downloadManager = downloadManager;
2999 this.imageResourcesPath = imageResourcesPath;
3000 this.renderForms = renderForms;
3001 this.annotationStorage = annotationStorage;
3002 this.enableScripting = enableScripting;
3003 this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
3004 this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
3005 this._annotationCanvasMap = annotationCanvasMap;
3006 this._accessibilityManager = accessibilityManager;
3007 this._annotationEditorUIManager = annotationEditorUIManager;
3008 this.#onAppend = onAppend;
3009 this.annotationLayer = null;
3010 this.div = null;
3011 this._cancelled = false;
3012 this._eventBus = linkService.eventBus;
3013 }
3014 async render(viewport, intent = "display") {
3015 if (this.div) {
3016 if (this._cancelled || !this.annotationLayer) {
3017 return;
3018 }
3019 this.annotationLayer.update({
3020 viewport: viewport.clone({
3021 dontFlip: true
3022 })
3023 });
3024 return;
3025 }
3026 const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
3027 intent
3028 }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
3029 if (this._cancelled) {
3030 return;
3031 }
3032 const div = this.div = document.createElement("div");
3033 div.className = "annotationLayer";
3034 this.#onAppend?.(div);
3035 if (annotations.length === 0) {
3036 this.hide();
3037 return;
3038 }
3039 this.annotationLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationLayer({
3040 div,
3041 accessibilityManager: this._accessibilityManager,
3042 annotationCanvasMap: this._annotationCanvasMap,
3043 annotationEditorUIManager: this._annotationEditorUIManager,
3044 page: this.pdfPage,
3045 viewport: viewport.clone({
3046 dontFlip: true
3047 })
3048 });
3049 await this.annotationLayer.render({
3050 annotations,
3051 imageResourcesPath: this.imageResourcesPath,
3052 renderForms: this.renderForms,
3053 linkService: this.linkService,
3054 downloadManager: this.downloadManager,
3055 annotationStorage: this.annotationStorage,
3056 enableScripting: this.enableScripting,
3057 hasJSActions,
3058 fieldObjects
3059 });
3060 if (this.linkService.isInPresentationMode) {
3061 this.#updatePresentationModeState(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN);
3062 }
3063 if (!this.#eventAbortController) {
3064 this.#eventAbortController = new AbortController();
3065 this._eventBus?._on("presentationmodechanged", evt => {
3066 this.#updatePresentationModeState(evt.state);
3067 }, {
3068 signal: this.#eventAbortController.signal
3069 });
3070 }
3071 }
3072 cancel() {
3073 this._cancelled = true;
3074 this.#eventAbortController?.abort();
3075 this.#eventAbortController = null;
3076 }
3077 hide() {
3078 if (!this.div) {
3079 return;
3080 }
3081 if (!document.querySelector("[data-pdfjsprinting=true]")) {
3082 this.div.hidden = true;
3083 }
3084 }
3085 #updatePresentationModeState(state) {
3086 if (!this.div) {
3087 return;
3088 }
3089 let disableFormElements = false;
3090 switch (state) {
3091 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN:
3092 disableFormElements = true;
3093 break;
3094 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL:
3095 break;
3096 default:
3097 return;
3098 }
3099 for (const section of this.div.childNodes) {
3100 if (section.hasAttribute("data-internal-link")) {
3101 continue;
3102 }
3103 section.inert = disableFormElements;
3104 }
3105 }
3106}
3107
3108__webpack_async_result__();
3109} catch(e) { __webpack_async_result__(e); } });
3110
3111/***/ }),
3112
3113/***/ 1621:
3114/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
3115
3116__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
3117/* harmony export */ __webpack_require__.d(__webpack_exports__, {
3118/* harmony export */ PDFViewerApplication: () => (/* binding */ PDFViewerApplication)
3119/* harmony export */ });
3120/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
3121/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
3122/* harmony import */ var _ngx_extended_pdf_viewer_version_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(5756);
3123/* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9840);
3124/* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5656);
3125/* harmony import */ var web_external_services__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6750);
3126/* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(787);
3127/* harmony import */ var web_alt_text_manager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(259);
3128/* harmony import */ var web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(226);
3129/* harmony import */ var _caret_browsing_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(3973);
3130/* harmony import */ var web_download_manager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1544);
3131/* harmony import */ var _overlay_manager_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(6174);
3132/* harmony import */ var _password_prompt_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(2690);
3133/* harmony import */ var web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(9251);
3134/* harmony import */ var web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(5993);
3135/* harmony import */ var web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(164);
3136/* harmony import */ var web_pdf_find_bar__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(2226);
3137/* harmony import */ var _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(9814);
3138/* harmony import */ var _pdf_history_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(8543);
3139/* harmony import */ var web_pdf_layer_viewer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(4275);
3140/* harmony import */ var web_pdf_outline_viewer__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(5514);
3141/* harmony import */ var web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(8917);
3142/* harmony import */ var web_print_service__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(1144);
3143/* harmony import */ var _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(6615);
3144/* harmony import */ var _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(5942);
3145/* harmony import */ var web_pdf_sidebar__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(2275);
3146/* harmony import */ var web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(8280);
3147/* harmony import */ var _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(6285);
3148/* harmony import */ var web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(1900);
3149/* harmony import */ var web_toolbar__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(6297);
3150/* harmony import */ var _view_history_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(9226);
3151var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__, web_external_services__WEBPACK_IMPORTED_MODULE_4__, web_alt_text_manager__WEBPACK_IMPORTED_MODULE_6__, web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_7__, web_download_manager__WEBPACK_IMPORTED_MODULE_8__, _password_prompt_js__WEBPACK_IMPORTED_MODULE_9__, web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_10__, web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_11__, web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_12__, web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_18__, web_print_service__WEBPACK_IMPORTED_MODULE_19__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_20__, _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_21__, web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_23__, _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_24__, web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_25__, web_toolbar__WEBPACK_IMPORTED_MODULE_26__]);
3152([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__, web_external_services__WEBPACK_IMPORTED_MODULE_4__, web_alt_text_manager__WEBPACK_IMPORTED_MODULE_6__, web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_7__, web_download_manager__WEBPACK_IMPORTED_MODULE_8__, _password_prompt_js__WEBPACK_IMPORTED_MODULE_9__, web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_10__, web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_11__, web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_12__, web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_18__, web_print_service__WEBPACK_IMPORTED_MODULE_19__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_20__, _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_21__, web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_23__, _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_24__, web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_25__, web_toolbar__WEBPACK_IMPORTED_MODULE_26__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185const FORCE_PAGES_LOADED_TIMEOUT = 10;
3186const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
3187const ViewOnLoad = {
3188 UNKNOWN: -1,
3189 PREVIOUS: 0,
3190 INITIAL: 1
3191};
3192const PDFViewerApplication = {
3193 initialBookmark: document.location.hash.substring(1),
3194 _initializedCapability: {
3195 ...Promise.withResolvers(),
3196 settled: false
3197 },
3198 appConfig: null,
3199 pdfDocument: null,
3200 pdfLoadingTask: null,
3201 printService: null,
3202 pdfViewer: null,
3203 pdfThumbnailViewer: null,
3204 pdfRenderingQueue: null,
3205 pdfPresentationMode: null,
3206 pdfDocumentProperties: null,
3207 pdfLinkService: null,
3208 pdfHistory: null,
3209 pdfSidebar: null,
3210 pdfOutlineViewer: null,
3211 pdfAttachmentViewer: null,
3212 pdfLayerViewer: null,
3213 pdfCursorTools: null,
3214 pdfScriptingManager: null,
3215 store: null,
3216 downloadManager: null,
3217 overlayManager: null,
3218 preferences: null,
3219 toolbar: null,
3220 secondaryToolbar: null,
3221 eventBus: null,
3222 l10n: null,
3223 annotationEditorParams: null,
3224 isInitialViewSet: false,
3225 downloadComplete: false,
3226 isViewerEmbedded: window.parent !== window,
3227 url: "",
3228 baseUrl: "",
3229 _downloadUrl: "",
3230 _eventBusAbortController: null,
3231 _windowAbortController: null,
3232 documentInfo: null,
3233 metadata: null,
3234 _contentDispositionFilename: null,
3235 _contentLength: null,
3236 _saveInProgress: false,
3237 _wheelUnusedTicks: 0,
3238 _wheelUnusedFactor: 1,
3239 _touchUnusedTicks: 0,
3240 _touchUnusedFactor: 1,
3241 _PDFBug: null,
3242 _hasAnnotationEditors: false,
3243 _title: document.title,
3244 _printAnnotationStoragePromise: null,
3245 _touchInfo: null,
3246 _isCtrlKeyDown: false,
3247 _nimbusDataPromise: null,
3248 _caretBrowsing: null,
3249 _isScrolling: false,
3250 async initialize(appConfig) {
3251 let l10nPromise;
3252 this.appConfig = appConfig;
3253 try {
3254 await this.preferences.initializedPromise;
3255 } catch (ex) {
3256 console.error(`initialize: "${ex.message}".`);
3257 }
3258 if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pdfBugEnabled")) {
3259 await this._parseHashParams();
3260 }
3261 let mode;
3262 switch (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("viewerCssTheme")) {
3263 case 1:
3264 mode = "is-light";
3265 break;
3266 case 2:
3267 mode = "is-dark";
3268 break;
3269 }
3270 if (mode) {
3271 document.documentElement.classList.add(mode);
3272 }
3273 l10nPromise = this.externalServices.createL10n();
3274 this.l10n = await l10nPromise;
3275 document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
3276 this.l10n.translate(appConfig.appContainer || document.documentElement);
3277 if (this.isViewerEmbedded && _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkTarget") === _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__.LinkTarget.NONE) {
3278 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("externalLinkTarget", _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__.LinkTarget.TOP);
3279 }
3280 await this._initializeViewerComponents();
3281 this.bindEvents();
3282 this.bindWindowEvents();
3283 this._initializedCapability.settled = true;
3284 this._initializedCapability.resolve();
3285 this.initializeLoadingBar();
3286 },
3287 async _parseHashParams() {
3288 const hash = document.location.hash.substring(1);
3289 if (!hash) {
3290 return;
3291 }
3292 const {
3293 mainContainer,
3294 viewerContainer
3295 } = this.appConfig,
3296 params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
3297 if (params.get("disableworker") === "true") {
3298 try {
3299 await loadFakeWorker();
3300 } catch (ex) {
3301 console.error(`_parseHashParams: "${ex.message}".`);
3302 }
3303 }
3304 if (params.has("disablerange")) {
3305 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableRange", params.get("disablerange") === "true");
3306 }
3307 if (params.has("disablestream")) {
3308 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableStream", params.get("disablestream") === "true");
3309 }
3310 if (params.has("disableautofetch")) {
3311 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
3312 }
3313 if (params.has("disablefontface")) {
3314 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
3315 }
3316 if (params.has("disablehistory")) {
3317 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableHistory", params.get("disablehistory") === "true");
3318 }
3319 if (params.has("verbosity")) {
3320 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("verbosity", params.get("verbosity") | 0);
3321 }
3322 if (params.has("textlayer")) {
3323 switch (params.get("textlayer")) {
3324 case "off":
3325 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("textLayerMode", _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.TextLayerMode.DISABLE);
3326 break;
3327 case "visible":
3328 case "shadow":
3329 case "hover":
3330 viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
3331 try {
3332 await loadPDFBug(this);
3333 this._PDFBug.loadCSS();
3334 } catch (ex) {
3335 console.error(`_parseHashParams: "${ex.message}".`);
3336 }
3337 break;
3338 }
3339 }
3340 if (params.has("pdfbug")) {
3341 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("pdfBug", true);
3342 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("fontExtraProperties", true);
3343 const enabled = params.get("pdfbug").split(",");
3344 try {
3345 await loadPDFBug(this);
3346 this._PDFBug.init(mainContainer, enabled);
3347 } catch (ex) {
3348 console.error(`_parseHashParams: "${ex.message}".`);
3349 }
3350 }
3351 if (params.has("locale")) {
3352 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("locale", params.get("locale"));
3353 }
3354 },
3355 async _initializeViewerComponents() {
3356 const {
3357 appConfig,
3358 externalServices,
3359 l10n
3360 } = this;
3361 const eventBus = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("isInAutomation") ? new _event_utils_js__WEBPACK_IMPORTED_MODULE_3__.AutomationEventBus() : new _event_utils_js__WEBPACK_IMPORTED_MODULE_3__.EventBus();
3362 this.eventBus = eventBus;
3363 this.overlayManager = new _overlay_manager_js__WEBPACK_IMPORTED_MODULE_28__.OverlayManager();
3364 const pdfRenderingQueue = new _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_20__.PDFRenderingQueue();
3365 pdfRenderingQueue.onIdle = this._cleanup.bind(this);
3366 this.pdfRenderingQueue = pdfRenderingQueue;
3367 const pdfLinkService = new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__.PDFLinkService({
3368 eventBus,
3369 externalLinkTarget: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkTarget"),
3370 externalLinkRel: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkRel"),
3371 ignoreDestinationZoom: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("ignoreDestinationZoom")
3372 });
3373 this.pdfLinkService = pdfLinkService;
3374 const downloadManager = this.downloadManager = new web_download_manager__WEBPACK_IMPORTED_MODULE_8__.DownloadManager();
3375 const findController = new _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_14__.PDFFindController({
3376 linkService: pdfLinkService,
3377 eventBus,
3378 pageViewMode: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pageViewMode"),
3379 updateMatchesCountOnProgress: true
3380 });
3381 this.findController = findController;
3382 const pdfScriptingManager = new _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_21__.PDFScriptingManager({
3383 eventBus,
3384 externalServices,
3385 docProperties: this._scriptingDocProperties.bind(this)
3386 });
3387 this.pdfScriptingManager = pdfScriptingManager;
3388 const container = appConfig.mainContainer,
3389 viewer = appConfig.viewerContainer;
3390 const annotationEditorMode = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("annotationEditorMode");
3391 const pageColors = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
3392 background: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pageColorsBackground"),
3393 foreground: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pageColorsForeground")
3394 } : null;
3395 const altTextManager = appConfig.altTextDialog ? new web_alt_text_manager__WEBPACK_IMPORTED_MODULE_6__.AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null;
3396 const pdfViewer = new _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_24__.PDFViewer({
3397 container,
3398 viewer,
3399 eventBus,
3400 renderingQueue: pdfRenderingQueue,
3401 linkService: pdfLinkService,
3402 downloadManager,
3403 altTextManager,
3404 findController,
3405 scriptingManager: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableScripting") && pdfScriptingManager,
3406 l10n,
3407 textLayerMode: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("textLayerMode"),
3408 annotationMode: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("annotationMode"),
3409 annotationEditorMode,
3410 annotationEditorHighlightColors: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("highlightEditorColors"),
3411 enableHighlightFloatingButton: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableHighlightFloatingButton"),
3412 imageResourcesPath: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("imageResourcesPath"),
3413 removePageBorders: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("removePageBorders"),
3414 enablePrintAutoRotate: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enablePrintAutoRotate"),
3415 maxCanvasPixels: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("maxCanvasPixels"),
3416 pageViewMode: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pageViewMode"),
3417 enablePermissions: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enablePermissions"),
3418 pageColors,
3419 mlManager: this.mlManager
3420 });
3421 this.pdfViewer = pdfViewer;
3422 pdfRenderingQueue.setViewer(pdfViewer);
3423 pdfLinkService.setViewer(pdfViewer);
3424 pdfScriptingManager.setViewer(pdfViewer);
3425 if (appConfig.sidebar?.thumbnailView) {
3426 this.pdfThumbnailViewer = new web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_23__.PDFThumbnailViewer({
3427 container: appConfig.sidebar.thumbnailView,
3428 eventBus,
3429 renderingQueue: pdfRenderingQueue,
3430 linkService: pdfLinkService,
3431 pageColors
3432 });
3433 pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
3434 }
3435 if (!this.isViewerEmbedded && !_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disableHistory")) {
3436 this.pdfHistory = new _pdf_history_js__WEBPACK_IMPORTED_MODULE_15__.PDFHistory({
3437 linkService: pdfLinkService,
3438 eventBus
3439 });
3440 pdfLinkService.setHistory(this.pdfHistory);
3441 }
3442 if (!this.supportsIntegratedFind && appConfig.findBar) {
3443 this.findBar = new web_pdf_find_bar__WEBPACK_IMPORTED_MODULE_13__.PDFFindBar(appConfig.findBar, eventBus);
3444 }
3445 if (appConfig.annotationEditorParams) {
3446 if (annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.DISABLE) {
3447 if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableStampEditor")) {
3448 appConfig.toolbar?.editorStampButton?.classList.remove("hidden");
3449 }
3450 const editorHighlightButton = appConfig.toolbar?.editorHighlightButton;
3451 if (editorHighlightButton && _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableHighlightEditor")) {
3452 editorHighlightButton.hidden = false;
3453 }
3454 this.annotationEditorParams = new web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_7__.AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
3455 } else {
3456 for (const id of ["editorModeButtons", "editorModeSeparator"]) {
3457 document.getElementById(id)?.classList.add("hidden");
3458 }
3459 }
3460 }
3461 if (appConfig.documentProperties) {
3462 this.pdfDocumentProperties = new web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_12__.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
3463 }
3464 if (appConfig.secondaryToolbar?.cursorHandToolButton) {
3465 this.pdfCursorTools = new web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_11__.PDFCursorTools({
3466 container,
3467 eventBus,
3468 cursorToolOnLoad: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("cursorToolOnLoad")
3469 });
3470 }
3471 if (appConfig.toolbar) {
3472 this.toolbar = new web_toolbar__WEBPACK_IMPORTED_MODULE_26__.Toolbar(appConfig.toolbar, eventBus);
3473 }
3474 if (appConfig.secondaryToolbar) {
3475 this.secondaryToolbar = new web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_25__.SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
3476 }
3477 if (this.supportsFullscreen && (appConfig.toolbar?.presentationModeButton || appConfig.secondaryToolbar?.presentationModeButton)) {
3478 this.pdfPresentationMode = new web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_18__.PDFPresentationMode({
3479 container,
3480 pdfViewer,
3481 eventBus
3482 });
3483 }
3484 const prompt = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("passwordPrompt");
3485 if (!prompt) {
3486 if (appConfig.passwordOverlay) {
3487 this.passwordPrompt = new _password_prompt_js__WEBPACK_IMPORTED_MODULE_9__.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.isViewerEmbedded);
3488 }
3489 } else {
3490 this.passwordPrompt = prompt;
3491 }
3492 if (appConfig.sidebar?.outlineView) {
3493 this.pdfOutlineViewer = new web_pdf_outline_viewer__WEBPACK_IMPORTED_MODULE_17__.PDFOutlineViewer({
3494 container: appConfig.sidebar.outlineView,
3495 eventBus,
3496 l10n,
3497 linkService: pdfLinkService,
3498 downloadManager
3499 });
3500 }
3501 if (appConfig.sidebar?.attachmentsView) {
3502 this.pdfAttachmentViewer = new web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_10__.PDFAttachmentViewer({
3503 container: appConfig.sidebar.attachmentsView,
3504 eventBus,
3505 l10n,
3506 downloadManager
3507 });
3508 }
3509 if (appConfig.sidebar?.layersView) {
3510 this.pdfLayerViewer = new web_pdf_layer_viewer__WEBPACK_IMPORTED_MODULE_16__.PDFLayerViewer({
3511 container: appConfig.sidebar.layersView,
3512 eventBus,
3513 l10n
3514 });
3515 }
3516 if (appConfig.sidebar) {
3517 this.pdfSidebar = new web_pdf_sidebar__WEBPACK_IMPORTED_MODULE_22__.PDFSidebar({
3518 elements: appConfig.sidebar,
3519 eventBus,
3520 l10n
3521 });
3522 this.pdfSidebar.onToggled = this.forceRendering.bind(this);
3523 this.pdfSidebar.onUpdateThumbnails = () => {
3524 for (const pageView of pdfViewer.getCachedPageViews()) {
3525 if (pageView.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
3526 this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView);
3527 }
3528 }
3529 this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
3530 };
3531 }
3532 },
3533 async run(config) {
3534 this.preferences = new web_external_services__WEBPACK_IMPORTED_MODULE_4__.Preferences();
3535 await this.initialize(config);
3536 const {
3537 appConfig,
3538 eventBus
3539 } = this;
3540 let file;
3541 const queryString = document.location.search.substring(1);
3542 const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(queryString);
3543 file = params.get("file") ?? _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultUrl");
3544 validateFileURL(file);
3545 const fileInput = this._openFileInput = document.createElement("input");
3546 fileInput.id = "fileInput";
3547 fileInput.hidden = true;
3548 fileInput.type = "file";
3549 fileInput.value = null;
3550 fileInput.accept = ".pdf,application/pdf";
3551 document.body.append(fileInput);
3552 fileInput.addEventListener("change", function (evt) {
3553 const {
3554 files
3555 } = evt.target;
3556 if (!files || files.length === 0) {
3557 return;
3558 }
3559 eventBus.dispatch("fileinputchange", {
3560 source: this,
3561 fileInput: evt.target
3562 });
3563 });
3564 appConfig.mainContainer.addEventListener("dragover", function (evt) {
3565 if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableDragAndDrop")) {
3566 evt.preventDefault();
3567 evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
3568 }
3569 });
3570 appConfig.mainContainer.addEventListener("drop", function (evt) {
3571 evt.preventDefault();
3572 const {
3573 files
3574 } = evt.dataTransfer;
3575 if (!files || files.length === 0) {
3576 return;
3577 }
3578 eventBus.dispatch("fileinputchange", {
3579 source: this,
3580 fileInput: evt.dataTransfer,
3581 dropEvent: evt
3582 });
3583 });
3584 if (!_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsDocumentFonts")) {
3585 _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableFontFace", true);
3586 this.l10n.get("pdfjs-web-fonts-disabled").then(msg => {
3587 console.warn(msg);
3588 });
3589 }
3590 if (!this.supportsPrinting) {
3591 appConfig.toolbar?.print?.classList.add("hidden");
3592 appConfig.secondaryToolbar?.printButton.classList.add("hidden");
3593 }
3594 if (!this.supportsFullscreen) {
3595 appConfig.toolbar.presentationModeButton.classList.add("hidden");
3596 appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
3597 }
3598 if (this.supportsIntegratedFind) {
3599 appConfig.toolbar?.viewFind?.classList.add("hidden");
3600 }
3601 if (file) {
3602 this.open({
3603 url: file
3604 });
3605 } else {
3606 this._hideViewBookmark();
3607 }
3608 },
3609 get externalServices() {
3610 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "externalServices", new web_external_services__WEBPACK_IMPORTED_MODULE_4__.ExternalServices());
3611 },
3612 get mlManager() {
3613 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "mlManager", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableML") === true ? new web_external_services__WEBPACK_IMPORTED_MODULE_4__.MLManager() : null);
3614 },
3615 get initialized() {
3616 return this._initializedCapability.settled;
3617 },
3618 get initializedPromise() {
3619 return this._initializedCapability.promise;
3620 },
3621 zoomIn(steps, scaleFactor) {
3622 if (this.pdfViewer.isInPresentationMode) {
3623 return;
3624 }
3625 this.pdfViewer.increaseScale({
3626 drawingDelay: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomDelay"),
3627 steps,
3628 scaleFactor
3629 });
3630 },
3631 zoomOut(steps, scaleFactor) {
3632 if (this.pdfViewer.isInPresentationMode) {
3633 return;
3634 }
3635 this.pdfViewer.decreaseScale({
3636 drawingDelay: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomDelay"),
3637 steps,
3638 scaleFactor
3639 });
3640 },
3641 zoomReset() {
3642 if (this.pdfViewer.isInPresentationMode) {
3643 return;
3644 }
3645 this.pdfViewer.currentScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SCALE_VALUE;
3646 },
3647 get pagesCount() {
3648 return this.pdfDocument ? this.pdfDocument.numPages : 0;
3649 },
3650 get page() {
3651 return this.pdfViewer.currentPageNumber;
3652 },
3653 set page(val) {
3654 this.pdfViewer.currentPageNumber = val;
3655 },
3656 get supportsPrinting() {
3657 return web_print_service__WEBPACK_IMPORTED_MODULE_19__.PDFPrintServiceFactory.supportsPrinting;
3658 },
3659 get supportsFullscreen() {
3660 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsFullscreen", document.fullscreenEnabled);
3661 },
3662 get supportsPinchToZoom() {
3663 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsPinchToZoom", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsPinchToZoom"));
3664 },
3665 get supportsIntegratedFind() {
3666 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsIntegratedFind", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsIntegratedFind"));
3667 },
3668 initializeLoadingBar() {
3669 const barElement = document.getElementById("loadingBar");
3670 const bar = barElement ? new _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ProgressBar(barElement) : null;
3671 bar?.hide();
3672 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "loadingBar", bar);
3673 },
3674 get supportsMouseWheelZoomCtrlKey() {
3675 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsMouseWheelZoomCtrlKey", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsMouseWheelZoomCtrlKey"));
3676 },
3677 get supportsMouseWheelZoomMetaKey() {
3678 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsMouseWheelZoomMetaKey", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsMouseWheelZoomMetaKey"));
3679 },
3680 get supportsCaretBrowsingMode() {
3681 return _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsCaretBrowsingMode");
3682 },
3683 moveCaret(isUp, select) {
3684 this._caretBrowsing ||= new _caret_browsing_js__WEBPACK_IMPORTED_MODULE_29__.CaretBrowsingMode(this.appConfig.mainContainer, this.appConfig.viewerContainer, this.appConfig.toolbar?.container);
3685 this._caretBrowsing.moveCaret(isUp, select);
3686 },
3687 setTitleUsingUrl(url = "", downloadUrl = null) {},
3688 setTitle(title = this._title) {
3689 this._title = title;
3690 if (this.isViewerEmbedded) {
3691 return;
3692 }
3693 const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
3694 document.title = `${editorIndicator ? "* " : ""}${title}`;
3695 },
3696 get _docFilename() {
3697 return this._contentDispositionFilename || (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getPdfFilenameFromUrl)(this.url);
3698 },
3699 _hideViewBookmark() {
3700 if (!this.appConfig) {
3701 return;
3702 }
3703 const {
3704 secondaryToolbar
3705 } = this.appConfig;
3706 secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
3707 if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
3708 document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
3709 }
3710 },
3711 async close() {
3712 this._unblockDocumentLoadEvent();
3713 this._hideViewBookmark();
3714 if (!this.pdfLoadingTask) {
3715 return;
3716 }
3717 if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) {
3718 try {
3719 await this.save();
3720 } catch {}
3721 }
3722 const promises = [];
3723 promises.push(this.pdfLoadingTask.destroy());
3724 this.pdfLoadingTask = null;
3725 if (this.pdfDocument) {
3726 this.pdfDocument = null;
3727 this.pdfThumbnailViewer?.setDocument(null);
3728 this.pdfViewer.setDocument(null);
3729 this.pdfLinkService.setDocument(null);
3730 this.pdfDocumentProperties?.setDocument(null);
3731 }
3732 this.pdfLinkService.externalLinkEnabled = true;
3733 this.store = null;
3734 this.isInitialViewSet = false;
3735 this.downloadComplete = false;
3736 this.url = "";
3737 this.baseUrl = "";
3738 this._downloadUrl = "";
3739 this.documentInfo = null;
3740 this.metadata = null;
3741 this._contentDispositionFilename = null;
3742 this._contentLength = null;
3743 this._saveInProgress = false;
3744 this._hasAnnotationEditors = false;
3745 promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close());
3746 this.setTitle();
3747 this.pdfSidebar?.reset();
3748 this.pdfOutlineViewer?.reset();
3749 this.pdfAttachmentViewer?.reset();
3750 this.pdfLayerViewer?.reset();
3751 this.pdfHistory?.reset();
3752 this.findBar?.reset();
3753 this.toolbar?.reset();
3754 this.secondaryToolbar?.reset();
3755 this._PDFBug?.cleanup();
3756 await Promise.all(promises);
3757 },
3758 async open(args) {
3759 window.adjacentPagesLoader = undefined;
3760 this.pdfViewer?.destroyBookMode();
3761 window.ngxZone.runOutsideAngular(async () => {
3762 if (this.pdfLoadingTask) {
3763 await this.close();
3764 }
3765 const workerParams = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.getAll(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.OptionKind.WORKER);
3766 if (workerParams.workerSrc.constructor.name === "Function") {
3767 workerParams.workerSrc = workerParams.workerSrc();
3768 }
3769 Object.assign(pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions, workerParams);
3770 if (args.url) {
3771 this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
3772 }
3773 const apiParams = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.getAll(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.OptionKind.API);
3774 const loadingTask = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getDocument)({
3775 ...apiParams,
3776 ...args
3777 });
3778 this.pdfLoadingTask = loadingTask;
3779 loadingTask.onPassword = (updateCallback, reason) => {
3780 if (this.isViewerEmbedded) {
3781 this._unblockDocumentLoadEvent();
3782 }
3783 this.pdfLinkService.externalLinkEnabled = false;
3784 this.passwordPrompt.setUpdateCallback(updateCallback, reason);
3785 this.passwordPrompt.open();
3786 };
3787 loadingTask.onProgress = ({
3788 loaded,
3789 total
3790 }) => {
3791 this.progress(loaded / total);
3792 this.eventBus?.dispatch("progress", {
3793 source: this,
3794 type: "load",
3795 total,
3796 loaded,
3797 percent: 100 * loaded / total
3798 });
3799 };
3800 return loadingTask.promise.then(pdfDocument => {
3801 this.load(pdfDocument);
3802 }, reason => {
3803 if (loadingTask !== this.pdfLoadingTask) {
3804 return undefined;
3805 }
3806 let key = "pdfjs-loading-error";
3807 if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.InvalidPDFException) {
3808 key = "pdfjs-invalid-file-error";
3809 } else if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.MissingPDFException) {
3810 key = "pdfjs-missing-file-error";
3811 } else if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.UnexpectedResponseException) {
3812 key = "pdfjs-unexpected-response-error";
3813 }
3814 if (PDFViewerApplication.onError) {
3815 PDFViewerApplication.onError(reason);
3816 }
3817 return this._documentError(key, {
3818 message: reason.message
3819 }).then(() => {
3820 throw reason;
3821 });
3822 });
3823 });
3824 },
3825 _ensureDownloadComplete() {
3826 if (this.pdfDocument && this.downloadComplete) {
3827 return;
3828 }
3829 throw new Error("PDF document not downloaded.");
3830 },
3831 async download(options = {}) {
3832 const url = this._downloadUrl,
3833 filename = this._docFilename;
3834 try {
3835 this._ensureDownloadComplete();
3836 const data = await this.pdfDocument.getData();
3837 const blob = new Blob([data], {
3838 type: "application/pdf"
3839 });
3840 await this.downloadManager.download(blob, url, filename, options);
3841 } catch {
3842 await this.downloadManager.downloadUrl(url, filename, options);
3843 }
3844 },
3845 async save(options = {}) {
3846 if (this._saveInProgress) {
3847 return;
3848 }
3849 this._saveInProgress = true;
3850 await this.pdfScriptingManager.dispatchWillSave();
3851 const url = this._downloadUrl,
3852 filename = this._docFilename;
3853 try {
3854 this._ensureDownloadComplete();
3855 const data = await this.pdfDocument.saveDocument();
3856 const blob = new Blob([data], {
3857 type: "application/pdf"
3858 });
3859 await this.downloadManager.download(blob, url, filename, options);
3860 } catch (reason) {
3861 globalThis.ngxConsole.error(`Error when saving the document: ${reason.message}`);
3862 await this.download(options);
3863 } finally {
3864 await this.pdfScriptingManager.dispatchDidSave();
3865 this._saveInProgress = false;
3866 }
3867 if (this._hasAnnotationEditors) {
3868 this.externalServices.reportTelemetry({
3869 type: "editing",
3870 data: {
3871 type: "save",
3872 stats: this.pdfDocument?.annotationStorage.editorStats
3873 }
3874 });
3875 }
3876 },
3877 downloadOrSave(options = {}) {
3878 if (this.pdfDocument?.annotationStorage.size > 0) {
3879 this.save(options);
3880 } else {
3881 this.download(options);
3882 }
3883 },
3884 async _exportWithAnnotations() {
3885 if (this._saveInProgress) {
3886 throw new Error(`Already downloading`);
3887 }
3888 this._saveInProgress = true;
3889 await this.pdfScriptingManager.dispatchWillSave();
3890 try {
3891 this._ensureDownloadComplete();
3892 const data = await this.pdfDocument.saveDocument();
3893 const blob = new Blob([data], {
3894 type: "application/pdf"
3895 });
3896 return blob;
3897 } catch (reason) {
3898 throw new Error(`Error when saving the document: ${reason.message}`);
3899 } finally {
3900 await this.pdfScriptingManager.dispatchDidSave();
3901 this._saveInProgress = false;
3902 }
3903 },
3904 async _exportWithoutAnnotations() {
3905 try {
3906 this._ensureDownloadComplete();
3907 const data = await this.pdfDocument.getData();
3908 const blob = new Blob([data], {
3909 type: "application/pdf"
3910 });
3911 return blob;
3912 } catch (reason) {
3913 throw new Error(`Error when saving the document: ${reason.message}`);
3914 }
3915 },
3916 async export() {
3917 if (this.pdfDocument?.annotationStorage.size > 0) {
3918 return this._exportWithAnnotations();
3919 }
3920 return this._exportWithoutAnnotations();
3921 },
3922 openInExternalApp() {
3923 this.downloadOrSave({
3924 openInExternalApp: true
3925 });
3926 },
3927 async _documentError(key, moreInfo = null) {
3928 this._unblockDocumentLoadEvent();
3929 const message = await this._otherError(key || "pdfjs-loading-error", moreInfo);
3930 this.eventBus.dispatch("documenterror", {
3931 source: this,
3932 message,
3933 reason: moreInfo?.message ?? null
3934 });
3935 },
3936 async _otherError(key, moreInfo = null) {
3937 const message = await this.l10n.get(key);
3938 const moreInfoText = [`PDF.js v${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.version || "?"} (build: ${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.build || "?"})`];
3939 if (moreInfo) {
3940 moreInfoText.push(`Message: ${moreInfo.message}`);
3941 if (moreInfo.stack) {
3942 moreInfoText.push(`Stack: ${moreInfo.stack}`);
3943 } else {
3944 if (moreInfo.filename) {
3945 moreInfoText.push(`File: ${moreInfo.filename}`);
3946 }
3947 if (moreInfo.lineNumber) {
3948 moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
3949 }
3950 }
3951 }
3952 console.error(`${message}\n\n${moreInfoText.join("\n")}`);
3953 return message;
3954 },
3955 progress(level) {
3956 if (!this.loadingBar || this.downloadComplete) {
3957 return;
3958 }
3959 const percent = Math.round(level * 100);
3960 if (percent <= this.loadingBar.percent) {
3961 return;
3962 }
3963 this.loadingBar.percent = percent;
3964 if (this.pdfDocument?.loadingParams.disableAutoFetch ?? _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disableAutoFetch")) {
3965 this.loadingBar.setDisableAutoFetch();
3966 }
3967 },
3968 load(pdfDocument) {
3969 this.pdfDocument = pdfDocument;
3970 pdfDocument.getDownloadInfo().then(({
3971 length
3972 }) => {
3973 this._contentLength = length;
3974 this.downloadComplete = true;
3975 this.loadingBar?.hide();
3976 firstPagePromise.then(() => {
3977 this.eventBus?.dispatch("documentloaded", {
3978 source: this
3979 });
3980 });
3981 });
3982 const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {});
3983 const pageModePromise = pdfDocument.getPageMode().catch(() => {});
3984 const openActionPromise = pdfDocument.getOpenAction().catch(() => {});
3985 this.toolbar?.setPagesCount(pdfDocument.numPages, false);
3986 this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
3987 this.pdfLinkService.setDocument(pdfDocument);
3988 this.pdfDocumentProperties?.setDocument(pdfDocument);
3989 const pdfViewer = this.pdfViewer;
3990 pdfViewer.setDocument(pdfDocument);
3991 const {
3992 firstPagePromise,
3993 onePageRendered,
3994 pagesPromise
3995 } = pdfViewer;
3996 this.pdfThumbnailViewer?.setDocument(pdfDocument);
3997 const storedPromise = (this.store = new _view_history_js__WEBPACK_IMPORTED_MODULE_27__.ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
3998 page: null,
3999 zoom: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SCALE_VALUE,
4000 scrollLeft: "0",
4001 scrollTop: "0",
4002 rotation: null,
4003 sidebarView: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN,
4004 scrollMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN,
4005 spreadMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN
4006 }).catch(() => {});
4007 firstPagePromise.then(pdfPage => {
4008 this.loadingBar?.setWidth(this.appConfig.viewerContainer);
4009 this._initializeAnnotationStorageCallbacks(pdfDocument);
4010 Promise.all([_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, stored, pageLayout, pageMode, openAction]) => {
4011 const viewOnLoad = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("viewOnLoad");
4012 this._initializePdfHistory({
4013 fingerprint: pdfDocument.fingerprints[0],
4014 viewOnLoad,
4015 initialDest: openAction?.dest
4016 });
4017 const initialBookmark = this.initialBookmark;
4018 const zoom = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomValue");
4019 let hash = zoom ? `zoom=${zoom}` : null;
4020 let rotation = null;
4021 let sidebarView = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("sidebarViewOnLoad");
4022 let scrollMode = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("scrollModeOnLoad");
4023 let spreadMode = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("spreadModeOnLoad");
4024 if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
4025 hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
4026 rotation = parseInt(stored.rotation, 10);
4027 if (sidebarView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
4028 sidebarView = stored.sidebarView | 0;
4029 }
4030 if (scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN) {
4031 scrollMode = stored.scrollMode | 0;
4032 }
4033 if (spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN) {
4034 spreadMode = stored.spreadMode | 0;
4035 }
4036 }
4037 if (pageMode && sidebarView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
4038 sidebarView = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageModeToSidebarView)(pageMode);
4039 }
4040 if (pageLayout && scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN && spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN) {
4041 const modes = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageLayoutToViewerModes)(pageLayout);
4042 spreadMode = modes.spreadMode;
4043 }
4044 this.setInitialView(hash, {
4045 rotation,
4046 sidebarView,
4047 scrollMode,
4048 spreadMode
4049 });
4050 this.eventBus.dispatch("documentinit", {
4051 source: this
4052 });
4053 if (!this.isViewerEmbedded) {
4054 pdfViewer.focus();
4055 }
4056 await Promise.race([pagesPromise, new Promise(resolve => {
4057 setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
4058 })]);
4059 if (!initialBookmark && !hash) {
4060 return;
4061 }
4062 if (pdfViewer.hasEqualPageSizes) {
4063 return;
4064 }
4065 this.initialBookmark = initialBookmark;
4066 pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
4067 this.setInitialView(hash);
4068 }).catch(() => {
4069 this.setInitialView();
4070 }).then(function () {
4071 pdfViewer.update();
4072 });
4073 });
4074 pagesPromise.then(() => {
4075 this._unblockDocumentLoadEvent();
4076 this._initializeAutoPrint(pdfDocument, openActionPromise);
4077 }, reason => {
4078 if (PDFViewerApplication.onError) {
4079 PDFViewerApplication.onError(reason);
4080 }
4081 this._documentError("pdfjs-loading-error", {
4082 message: reason.message
4083 });
4084 });
4085 onePageRendered.then(data => {
4086 this.externalServices.reportTelemetry({
4087 type: "pageInfo",
4088 timestamp: data.timestamp
4089 });
4090 if (this.pdfOutlineViewer) {
4091 pdfDocument.getOutline().then(outline => {
4092 if (pdfDocument !== this.pdfDocument) {
4093 return;
4094 }
4095 this.pdfOutlineViewer.render({
4096 outline,
4097 pdfDocument
4098 });
4099 });
4100 }
4101 if (this.pdfAttachmentViewer) {
4102 pdfDocument.getAttachments().then(attachments => {
4103 if (pdfDocument !== this.pdfDocument) {
4104 return;
4105 }
4106 this.pdfAttachmentViewer.render({
4107 attachments
4108 });
4109 });
4110 }
4111 if (this.pdfLayerViewer) {
4112 pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
4113 if (pdfDocument !== this.pdfDocument) {
4114 return;
4115 }
4116 this.pdfLayerViewer.render({
4117 optionalContentConfig,
4118 pdfDocument
4119 });
4120 });
4121 }
4122 });
4123 this._initializePageLabels(pdfDocument);
4124 this._initializeMetadata(pdfDocument);
4125 },
4126 async _scriptingDocProperties(pdfDocument) {
4127 if (!this.documentInfo) {
4128 await new Promise(resolve => {
4129 this.eventBus._on("metadataloaded", resolve, {
4130 once: true
4131 });
4132 });
4133 if (pdfDocument !== this.pdfDocument) {
4134 return null;
4135 }
4136 }
4137 if (!this._contentLength) {
4138 await new Promise(resolve => {
4139 this.eventBus._on("documentloaded", resolve, {
4140 once: true
4141 });
4142 });
4143 if (pdfDocument !== this.pdfDocument) {
4144 return null;
4145 }
4146 }
4147 return {
4148 ...this.documentInfo,
4149 baseURL: this.baseUrl,
4150 filesize: this._contentLength,
4151 filename: this._docFilename,
4152 metadata: this.metadata?.getRaw(),
4153 authors: this.metadata?.get("dc:creator"),
4154 numPages: this.pagesCount,
4155 URL: this.url
4156 };
4157 },
4158 async _initializeAutoPrint(pdfDocument, openActionPromise) {
4159 const [openAction, jsActions] = await Promise.all([openActionPromise, this.pdfViewer.enableScripting ? null : pdfDocument.getJSActions()]);
4160 if (pdfDocument !== this.pdfDocument) {
4161 return;
4162 }
4163 let triggerAutoPrint = openAction?.action === "Print";
4164 if (jsActions) {
4165 globalThis.ngxConsole.warn("Warning: JavaScript support is not enabled");
4166 for (const name in jsActions) {
4167 if (triggerAutoPrint) {
4168 break;
4169 }
4170 switch (name) {
4171 case "WillClose":
4172 case "WillSave":
4173 case "DidSave":
4174 case "WillPrint":
4175 case "DidPrint":
4176 continue;
4177 }
4178 triggerAutoPrint = jsActions[name].some(js => _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.AutoPrintRegExp.test(js));
4179 }
4180 }
4181 if (triggerAutoPrint) {
4182 this.triggerPrinting();
4183 }
4184 },
4185 async _initializeMetadata(pdfDocument) {
4186 const {
4187 info,
4188 metadata,
4189 contentDispositionFilename,
4190 contentLength
4191 } = await pdfDocument.getMetadata();
4192 if (pdfDocument !== this.pdfDocument) {
4193 return;
4194 }
4195 this.documentInfo = info;
4196 this.metadata = metadata;
4197 this._contentDispositionFilename ??= contentDispositionFilename;
4198 this._contentLength ??= contentLength;
4199 const options = window.PDFViewerApplicationOptions;
4200 if (!options || options.get("verbosity") > 0) {
4201 globalThis.ngxConsole.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.version || "?"} [${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.build || "?"}]) modified by ngx-extended-pdf-viewer ${_ngx_extended_pdf_viewer_version_js__WEBPACK_IMPORTED_MODULE_30__.ngxExtendedPdfViewerVersion}`);
4202 }
4203 let pdfTitle = info.Title;
4204 const metadataTitle = metadata?.get("dc:title");
4205 if (metadataTitle) {
4206 if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
4207 pdfTitle = metadataTitle;
4208 }
4209 }
4210 if (pdfTitle) {
4211 this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`);
4212 } else if (this._contentDispositionFilename) {
4213 this.setTitle(this._contentDispositionFilename);
4214 }
4215 if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
4216 if (pdfDocument.loadingParams.enableXfa) {
4217 globalThis.ngxConsole.warn("Warning: XFA Foreground documents are not supported");
4218 } else {
4219 globalThis.ngxConsole.warn("Warning: XFA support is not enabled");
4220 }
4221 } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) {
4222 console.warn("Warning: Interactive form support is not enabled");
4223 }
4224 if (info.IsSignaturesPresent) {
4225 console.warn("Warning: Digital signatures validation is not supported");
4226 }
4227 this.eventBus.dispatch("metadataloaded", {
4228 source: this
4229 });
4230 },
4231 async _initializePageLabels(pdfDocument) {
4232 const labels = await pdfDocument.getPageLabels();
4233 if (pdfDocument !== this.pdfDocument) {
4234 return;
4235 }
4236 if (!labels || _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disablePageLabels")) {
4237 return;
4238 }
4239 const numLabels = labels.length;
4240 let standardLabels = 0,
4241 emptyLabels = 0;
4242 for (let i = 0; i < numLabels; i++) {
4243 const label = labels[i];
4244 if (label === (i + 1).toString()) {
4245 standardLabels++;
4246 } else if (label === "") {
4247 emptyLabels++;
4248 } else {
4249 break;
4250 }
4251 }
4252 if (standardLabels >= numLabels || emptyLabels >= numLabels) {
4253 return;
4254 }
4255 const {
4256 pdfViewer,
4257 pdfThumbnailViewer,
4258 toolbar
4259 } = this;
4260 pdfViewer.setPageLabels(labels);
4261 pdfThumbnailViewer?.setPageLabels(labels);
4262 toolbar?.setPagesCount(numLabels, true);
4263 toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
4264 },
4265 _initializePdfHistory({
4266 fingerprint,
4267 viewOnLoad,
4268 initialDest = null
4269 }) {
4270 if (!this.pdfHistory) {
4271 return;
4272 }
4273 this.pdfHistory.initialize({
4274 fingerprint,
4275 resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
4276 updateUrl: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("historyUpdateUrl")
4277 });
4278 if (this.pdfHistory.initialBookmark) {
4279 this.initialBookmark = this.pdfHistory.initialBookmark;
4280 this.initialRotation = this.pdfHistory.initialRotation;
4281 }
4282 if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
4283 this.initialBookmark = JSON.stringify(initialDest);
4284 this.pdfHistory.push({
4285 explicitDest: initialDest,
4286 pageNumber: null
4287 });
4288 }
4289 },
4290 _initializeAnnotationStorageCallbacks(pdfDocument) {
4291 if (pdfDocument !== this.pdfDocument) {
4292 return;
4293 }
4294 const {
4295 annotationStorage
4296 } = pdfDocument;
4297 annotationStorage.onSetModified = () => {
4298 window.addEventListener("beforeunload", beforeUnload);
4299 this._annotationStorageModified = true;
4300 };
4301 annotationStorage.onResetModified = () => {
4302 window.removeEventListener("beforeunload", beforeUnload);
4303 delete this._annotationStorageModified;
4304 };
4305 annotationStorage.onAnnotationEditor = typeStr => {
4306 this._hasAnnotationEditors = !!typeStr;
4307 this.setTitle();
4308 };
4309 },
4310 setInitialView(storedHash, {
4311 rotation,
4312 sidebarView,
4313 scrollMode,
4314 spreadMode
4315 } = {}) {
4316 const setRotation = angle => {
4317 if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(angle)) {
4318 this.pdfViewer.pagesRotation = angle;
4319 }
4320 };
4321 const setViewerModes = (scroll, spread) => {
4322 if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidScrollMode)(scroll)) {
4323 this.pdfViewer.scrollMode = scroll;
4324 }
4325 if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidSpreadMode)(spread)) {
4326 this.pdfViewer.spreadMode = spread;
4327 }
4328 };
4329 this.isInitialViewSet = true;
4330 this.pdfSidebar?.setInitialView(sidebarView);
4331 setViewerModes(scrollMode, spreadMode);
4332 if (this.initialBookmark) {
4333 setRotation(this.initialRotation);
4334 delete this.initialRotation;
4335 this.pdfLinkService.setHash(this.initialBookmark);
4336 this.initialBookmark = null;
4337 } else if (storedHash) {
4338 setRotation(rotation);
4339 this.pdfLinkService.setHash(storedHash);
4340 }
4341 this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
4342 this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);
4343 if (!this.pdfViewer.currentScaleValue) {
4344 const defaultZoomOption = PDFViewerApplicationOptions.get('defaultZoomValue');
4345 if (defaultZoomOption) {
4346 this.pdfViewer.currentScaleValue = defaultZoomOption;
4347 }
4348 }
4349 },
4350 _cleanup() {
4351 if (!this.pdfDocument) {
4352 return;
4353 }
4354 this.pdfViewer.cleanup();
4355 this.pdfThumbnailViewer?.cleanup();
4356 this.pdfDocument.cleanup(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("fontExtraProperties"));
4357 },
4358 forceRendering() {
4359 this.pdfRenderingQueue.printing = !!this.printService;
4360 this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
4361 this.pdfRenderingQueue.renderHighestPriority();
4362 },
4363 beforePrint() {
4364 this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => this.pdfDocument?.annotationStorage.print);
4365 if (this.printService) {
4366 return;
4367 }
4368 if (!this.supportsPrinting) {
4369 this._otherError("pdfjs-printing-not-supported");
4370 return;
4371 }
4372 if (!this.pdfViewer.pageViewsReady) {
4373 this.l10n.get("pdfjs-printing-not-ready").then(msg => {
4374 window.alert(msg);
4375 });
4376 return;
4377 }
4378 this.printService = web_print_service__WEBPACK_IMPORTED_MODULE_19__.PDFPrintServiceFactory.createPrintService({
4379 pdfDocument: this.pdfDocument,
4380 pagesOverview: this.pdfViewer.getPagesOverview(),
4381 printContainer: this.appConfig.printContainer,
4382 printResolution: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("printResolution"),
4383 printAnnotationStoragePromise: this._printAnnotationStoragePromise,
4384 eventBus: this.pdfViewer.eventBus
4385 });
4386 this.forceRendering();
4387 this.setTitle();
4388 this.printService.layout();
4389 if (this._hasAnnotationEditors) {
4390 this.externalServices.reportTelemetry({
4391 type: "editing",
4392 data: {
4393 type: "print",
4394 stats: this.pdfDocument?.annotationStorage.editorStats
4395 }
4396 });
4397 }
4398 },
4399 afterPrint() {
4400 if (this._printAnnotationStoragePromise) {
4401 this._printAnnotationStoragePromise.then(() => {
4402 this.pdfScriptingManager.dispatchDidPrint();
4403 });
4404 this._printAnnotationStoragePromise = null;
4405 }
4406 if (this.printService) {
4407 this.printService.destroy();
4408 this.printService = null;
4409 this.pdfDocument?.annotationStorage.resetModified();
4410 }
4411 this.forceRendering();
4412 this.setTitle();
4413 },
4414 rotatePages(delta) {
4415 this.pdfViewer.pagesRotation += delta;
4416 },
4417 requestPresentationMode() {
4418 this.pdfPresentationMode?.request();
4419 },
4420 triggerPrinting() {
4421 if (!this.supportsPrinting) {
4422 return;
4423 }
4424 window.printPDF();
4425 },
4426 bindEvents() {
4427 if (this._eventBusAbortController) {
4428 return;
4429 }
4430 this._eventBusAbortController = new AbortController();
4431 const {
4432 eventBus,
4433 _eventBusAbortController: {
4434 signal
4435 }
4436 } = this;
4437 eventBus._on("resize", webViewerResize, {
4438 signal
4439 });
4440 eventBus._on("hashchange", webViewerHashchange, {
4441 signal
4442 });
4443 eventBus._on("beforeprint", this.beforePrint.bind(this), {
4444 signal
4445 });
4446 eventBus._on("afterprint", this.afterPrint.bind(this), {
4447 signal
4448 });
4449 eventBus._on("pagerender", webViewerPageRender, {
4450 signal
4451 });
4452 eventBus._on("pagerendered", webViewerPageRendered, {
4453 signal
4454 });
4455 eventBus._on("updateviewarea", webViewerUpdateViewarea, {
4456 signal
4457 });
4458 eventBus._on("pagechanging", webViewerPageChanging, {
4459 signal
4460 });
4461 eventBus._on("scalechanging", webViewerScaleChanging, {
4462 signal
4463 });
4464 eventBus._on("rotationchanging", webViewerRotationChanging, {
4465 signal
4466 });
4467 eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged, {
4468 signal
4469 });
4470 eventBus._on("pagemode", webViewerPageMode, {
4471 signal
4472 });
4473 eventBus._on("namedaction", webViewerNamedAction, {
4474 signal
4475 });
4476 eventBus._on("presentationmodechanged", webViewerPresentationModeChanged, {
4477 signal
4478 });
4479 eventBus._on("presentationmode", webViewerPresentationMode, {
4480 signal
4481 });
4482 eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode, {
4483 signal
4484 });
4485 eventBus._on("switchannotationeditorparams", webViewerSwitchAnnotationEditorParams, {
4486 signal
4487 });
4488 eventBus._on("print", webViewerPrint, {
4489 signal
4490 });
4491 eventBus._on("download", webViewerDownload, {
4492 signal
4493 });
4494 eventBus._on("firstpage", webViewerFirstPage, {
4495 signal
4496 });
4497 eventBus._on("lastpage", webViewerLastPage, {
4498 signal
4499 });
4500 eventBus._on("nextpage", webViewerNextPage, {
4501 signal
4502 });
4503 eventBus._on("previouspage", webViewerPreviousPage, {
4504 signal
4505 });
4506 eventBus._on("zoomin", webViewerZoomIn, {
4507 signal
4508 });
4509 eventBus._on("zoomout", webViewerZoomOut, {
4510 signal
4511 });
4512 eventBus._on("zoomreset", webViewerZoomReset, {
4513 signal
4514 });
4515 eventBus._on("pagenumberchanged", webViewerPageNumberChanged, {
4516 signal
4517 });
4518 eventBus._on("scalechanged", webViewerScaleChanged, {
4519 signal
4520 });
4521 eventBus._on("rotatecw", webViewerRotateCw, {
4522 signal
4523 });
4524 eventBus._on("rotateccw", webViewerRotateCcw, {
4525 signal
4526 });
4527 eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig, {
4528 signal
4529 });
4530 eventBus._on("switchscrollmode", webViewerSwitchScrollMode, {
4531 signal
4532 });
4533 eventBus._on("scrollmodechanged", webViewerScrollModeChanged, {
4534 signal
4535 });
4536 eventBus._on("switchspreadmode", webViewerSwitchSpreadMode, {
4537 signal
4538 });
4539 eventBus._on("spreadmodechanged", webViewerSpreadModeChanged, {
4540 signal
4541 });
4542 eventBus._on("documentproperties", webViewerDocumentProperties, {
4543 signal
4544 });
4545 eventBus._on("findfromurlhash", webViewerFindFromUrlHash, {
4546 signal
4547 });
4548 eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount, {
4549 signal
4550 });
4551 eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState, {
4552 signal
4553 });
4554 if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pdfBug")) {
4555 eventBus._on("pagerendered", reportPageStatsPDFBug, {
4556 signal
4557 });
4558 eventBus._on("pagechanging", reportPageStatsPDFBug, {
4559 signal
4560 });
4561 }
4562 eventBus._on("fileinputchange", webViewerFileInputChange, {
4563 signal
4564 });
4565 eventBus._on("openfile", webViewerOpenFile, {
4566 signal
4567 });
4568 },
4569 bindWindowEvents() {
4570 if (this._windowAbortController) {
4571 return;
4572 }
4573 this._windowAbortController = new AbortController();
4574 const {
4575 eventBus,
4576 appConfig: {
4577 mainContainer
4578 },
4579 _windowAbortController: {
4580 signal
4581 }
4582 } = this;
4583 function addWindowResolutionChange(evt = null) {
4584 if (evt) {
4585 webViewerResolutionChange(evt);
4586 }
4587 const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
4588 mediaQueryList.addEventListener("change", addWindowResolutionChange, {
4589 once: true,
4590 signal
4591 });
4592 }
4593 addWindowResolutionChange();
4594 window.addEventListener("visibilitychange", webViewerVisibilityChange, {
4595 signal
4596 });
4597 const viewerContainer = document.getElementById("viewerContainer");
4598 viewerContainer?.addEventListener("wheel", webViewerWheel, {
4599 passive: false,
4600 signal
4601 });
4602 mainContainer?.addEventListener("touchstart", webViewerTouchStart, {
4603 passive: false,
4604 signal
4605 });
4606 mainContainer?.addEventListener("touchmove", webViewerTouchMove, {
4607 passive: false,
4608 signal
4609 });
4610 mainContainer?.addEventListener("touchend", webViewerTouchEnd, {
4611 passive: false,
4612 signal
4613 });
4614 window.addEventListener("click", webViewerClick, {
4615 signal
4616 });
4617 window.addEventListener("keydown", webViewerKeyDown, {
4618 signal
4619 });
4620 window.addEventListener("keyup", webViewerKeyUp, {
4621 signal
4622 });
4623 window.addEventListener("resize", () => {
4624 eventBus.dispatch("resize", {
4625 source: window
4626 });
4627 }, {
4628 signal
4629 });
4630 window.addEventListener("hashchange", () => {
4631 eventBus.dispatch("hashchange", {
4632 source: window,
4633 hash: document.location.hash.substring(1)
4634 });
4635 }, {
4636 signal
4637 });
4638 window.addEventListener("beforeprint", () => {
4639 eventBus.dispatch("beforeprint", {
4640 source: window
4641 });
4642 }, {
4643 signal
4644 });
4645 window.addEventListener("afterprint", () => {
4646 eventBus.dispatch("afterprint", {
4647 source: window
4648 });
4649 }, {
4650 signal
4651 });
4652 window.addEventListener("updatefromsandbox", event => {
4653 eventBus.dispatch("updatefromsandbox", {
4654 source: window,
4655 detail: event.detail
4656 });
4657 }, {
4658 signal
4659 });
4660 if (!("onscrollend" in document.documentElement)) {
4661 return;
4662 }
4663 ({
4664 scrollTop: this._lastScrollTop,
4665 scrollLeft: this._lastScrollLeft
4666 } = mainContainer);
4667 const scrollend = () => {
4668 ({
4669 scrollTop: this._lastScrollTop,
4670 scrollLeft: this._lastScrollLeft
4671 } = mainContainer);
4672 this._isScrolling = false;
4673 mainContainer.addEventListener("scroll", scroll, {
4674 passive: true,
4675 signal
4676 });
4677 mainContainer.removeEventListener("scrollend", scrollend, {
4678 signal
4679 });
4680 mainContainer.removeEventListener("blur", scrollend, {
4681 signal
4682 });
4683 };
4684 const scroll = () => {
4685 if (this._isCtrlKeyDown) {
4686 return;
4687 }
4688 if (this._lastScrollTop === mainContainer.scrollTop && this._lastScrollLeft === mainContainer.scrollLeft) {
4689 return;
4690 }
4691 mainContainer.removeEventListener("scroll", scroll, {
4692 passive: true,
4693 signal
4694 });
4695 this._isScrolling = true;
4696 mainContainer.addEventListener("scrollend", scrollend, {
4697 signal
4698 });
4699 mainContainer.addEventListener("blur", scrollend, {
4700 signal
4701 });
4702 };
4703 mainContainer.addEventListener("scroll", scroll, {
4704 passive: true,
4705 signal
4706 });
4707 },
4708 unbindEvents() {
4709 this._eventBusAbortController?.abort();
4710 this._eventBusAbortController = null;
4711 },
4712 unbindWindowEvents() {
4713 this._windowAbortController?.abort();
4714 this._windowAbortController = null;
4715 },
4716 _accumulateTicks(ticks, prop) {
4717 if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
4718 this[prop] = 0;
4719 }
4720 this[prop] += ticks;
4721 const wholeTicks = Math.trunc(this[prop]);
4722 this[prop] -= wholeTicks;
4723 return wholeTicks;
4724 },
4725 _accumulateFactor(previousScale, factor, prop) {
4726 if (factor === 1) {
4727 return 1;
4728 }
4729 if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) {
4730 this[prop] = 1;
4731 }
4732 const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale);
4733 this[prop] = factor / newFactor;
4734 return newFactor;
4735 },
4736 _centerAtPos(previousScale, x, y) {
4737 const {
4738 pdfViewer
4739 } = this;
4740 const scaleDiff = pdfViewer.currentScale / previousScale - 1;
4741 if (scaleDiff !== 0) {
4742 const [top, left] = pdfViewer.containerTopLeft;
4743 pdfViewer.container.scrollLeft += (x - left) * scaleDiff;
4744 pdfViewer.container.scrollTop += (y - top) * scaleDiff;
4745 }
4746 },
4747 _unblockDocumentLoadEvent() {
4748 document.blockUnblockOnload?.(false);
4749 this._unblockDocumentLoadEvent = () => {};
4750 },
4751 get scriptingReady() {
4752 return this.pdfScriptingManager.ready;
4753 }
4754};
4755(0,web_external_services__WEBPACK_IMPORTED_MODULE_4__.initCom)(PDFViewerApplication);
4756{
4757 web_print_service__WEBPACK_IMPORTED_MODULE_19__.PDFPrintServiceFactory.initGlobals(PDFViewerApplication);
4758}
4759{
4760 const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
4761 var validateFileURL = function (file) {
4762 if (!file) {
4763 return;
4764 }
4765 try {
4766 const viewerOrigin = new URL(window.location.href).origin || "null";
4767 if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
4768 return;
4769 }
4770 const fileOrigin = new URL(file, window.location.href).origin;
4771 if (fileOrigin !== viewerOrigin) {
4772 throw new Error("file origin does not match viewer's");
4773 }
4774 } catch (ex) {
4775 if (PDFViewerApplication.onError) {
4776 PDFViewerApplication.onError(ex);
4777 }
4778 PDFViewerApplication._documentError("pdfjs-loading-error", {
4779 message: ex.message
4780 });
4781 throw ex;
4782 }
4783 };
4784}
4785async function loadFakeWorker() {
4786 pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions.workerSrc ||= _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("workerSrc");
4787 if (pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions.workerSrc.constructor.name === "Function") {
4788 pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions.workerSrc = pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions.workerSrc();
4789 }
4790}
4791async function loadPDFBug(self) {}
4792function reportPageStatsPDFBug({
4793 pageNumber
4794}) {
4795 if (!globalThis.Stats?.enabled) {
4796 return;
4797 }
4798 const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
4799 globalThis.Stats.add(pageNumber, pageView?.pdfPage?.stats);
4800}
4801function webViewerPageRender({
4802 pageNumber
4803}) {
4804 if (pageNumber === PDFViewerApplication.page) {
4805 PDFViewerApplication.toolbar?.updateLoadingIndicatorState(true);
4806 }
4807}
4808function webViewerPageRendered({
4809 pageNumber,
4810 error
4811}) {
4812 if (pageNumber === PDFViewerApplication.page) {
4813 PDFViewerApplication.toolbar?.updateLoadingIndicatorState(false);
4814 }
4815 if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
4816 const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
4817 const thumbnailView = PDFViewerApplication.pdfThumbnailViewer?.getThumbnail(pageNumber - 1);
4818 if (pageView) {
4819 thumbnailView?.setImage(pageView);
4820 }
4821 }
4822 if (error) {
4823 PDFViewerApplication._otherError("pdfjs-rendering-error", error);
4824 }
4825}
4826function webViewerPageMode({
4827 mode
4828}) {
4829 let view;
4830 switch (mode) {
4831 case "thumbs":
4832 view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
4833 break;
4834 case "bookmarks":
4835 case "outline":
4836 view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE;
4837 break;
4838 case "attachments":
4839 view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS;
4840 break;
4841 case "layers":
4842 view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS;
4843 break;
4844 case "none":
4845 view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE;
4846 break;
4847 default:
4848 globalThis.ngxConsole.error('Invalid "pagemode" hash parameter: ' + mode);
4849 return;
4850 }
4851 PDFViewerApplication.pdfSidebar?.switchView(view, true);
4852}
4853function webViewerNamedAction(evt) {
4854 switch (evt.action) {
4855 case "GoToPage":
4856 PDFViewerApplication.appConfig.toolbar?.pageNumber.select();
4857 break;
4858 case "Find":
4859 if (!PDFViewerApplication.supportsIntegratedFind) {
4860 PDFViewerApplication.findBar?.toggle();
4861 }
4862 break;
4863 case "Print":
4864 PDFViewerApplication.triggerPrinting();
4865 break;
4866 case "SaveAs":
4867 PDFViewerApplication.downloadOrSave();
4868 break;
4869 }
4870}
4871function webViewerPresentationModeChanged(evt) {
4872 PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
4873}
4874function webViewerSidebarViewChanged({
4875 view
4876}) {
4877 PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
4878 if (PDFViewerApplication.isInitialViewSet) {
4879 PDFViewerApplication.store?.set("sidebarView", view).catch(() => {});
4880 }
4881}
4882function webViewerUpdateViewarea({
4883 location
4884}) {
4885 if (PDFViewerApplication.isInitialViewSet) {
4886 const settings = {};
4887 if (location.pageNumber !== undefined || location.pageNumber !== null) {
4888 settings.page = location.pageNumber;
4889 }
4890 if (location.scale) {
4891 settings.zoom = location.scale;
4892 }
4893 if (location.left) {
4894 settings.scrollLeft = location.left;
4895 }
4896 if (location.top) {
4897 settings.scrollTop = location.top;
4898 }
4899 if (location.rotation !== undefined || location.rotation !== null) {
4900 settings.rotation = location.rotation;
4901 }
4902 PDFViewerApplication.store?.setMultiple(settings).catch(() => {});
4903 }
4904 if (PDFViewerApplication.appConfig.secondaryToolbar) {
4905 const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
4906 PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
4907 }
4908}
4909function webViewerScrollModeChanged(evt) {
4910 if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
4911 PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {});
4912 }
4913}
4914function webViewerSpreadModeChanged(evt) {
4915 if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
4916 PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {});
4917 }
4918}
4919function webViewerResize() {
4920 const {
4921 pdfDocument,
4922 pdfViewer,
4923 pdfRenderingQueue
4924 } = PDFViewerApplication;
4925 if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
4926 return;
4927 }
4928 if (!pdfDocument) {
4929 return;
4930 }
4931 const currentScaleValue = pdfViewer.currentScaleValue;
4932 if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
4933 pdfViewer.currentScaleValue = currentScaleValue;
4934 }
4935 pdfViewer.update();
4936}
4937function webViewerHashchange(evt) {
4938 const hash = evt.hash;
4939 if (!hash) {
4940 return;
4941 }
4942 if (!PDFViewerApplication.isInitialViewSet) {
4943 PDFViewerApplication.initialBookmark = hash;
4944 } else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) {
4945 PDFViewerApplication.pdfLinkService.setHash(hash);
4946 }
4947}
4948{
4949 var webViewerFileInputChange = function (evt) {
4950 if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
4951 return;
4952 }
4953 const file = evt.fileInput.files[0];
4954 PDFViewerApplication.open({
4955 url: URL.createObjectURL(file),
4956 originalUrl: file.name
4957 });
4958 if (globalThis.setNgxExtendedPdfViewerSource) {
4959 globalThis.setNgxExtendedPdfViewerSource(file.name ?? URL.createObjectURL(file));
4960 }
4961 };
4962 var webViewerOpenFile = function (evt) {
4963 PDFViewerApplication._openFileInput?.click();
4964 };
4965}
4966function webViewerPresentationMode() {
4967 PDFViewerApplication.requestPresentationMode();
4968}
4969function webViewerSwitchAnnotationEditorMode(evt) {
4970 PDFViewerApplication.pdfViewer.annotationEditorMode = evt;
4971}
4972function webViewerSwitchAnnotationEditorParams(evt) {
4973 PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
4974}
4975function webViewerPrint() {
4976 PDFViewerApplication.triggerPrinting();
4977}
4978function webViewerDownload() {
4979 PDFViewerApplication.downloadOrSave();
4980}
4981function webViewerFirstPage() {
4982 PDFViewerApplication.page = 1;
4983}
4984function webViewerLastPage() {
4985 PDFViewerApplication.page = PDFViewerApplication.pagesCount;
4986}
4987function webViewerNextPage() {
4988 PDFViewerApplication.pdfViewer.nextPage();
4989}
4990function webViewerPreviousPage() {
4991 PDFViewerApplication.pdfViewer.previousPage();
4992}
4993function webViewerZoomIn() {
4994 PDFViewerApplication.zoomIn();
4995}
4996function webViewerZoomOut() {
4997 PDFViewerApplication.zoomOut();
4998}
4999function webViewerZoomReset() {
5000 PDFViewerApplication.zoomReset();
5001}
5002function webViewerPageNumberChanged(evt) {
5003 const pdfViewer = PDFViewerApplication.pdfViewer;
5004 if (evt.value !== "") {
5005 PDFViewerApplication.pdfLinkService.goToPage(evt.value);
5006 }
5007 if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
5008 PDFViewerApplication.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
5009 }
5010}
5011function webViewerScaleChanged(evt) {
5012 PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
5013}
5014function webViewerRotateCw() {
5015 PDFViewerApplication.rotatePages(90);
5016}
5017function webViewerRotateCcw() {
5018 PDFViewerApplication.rotatePages(-90);
5019}
5020function webViewerOptionalContentConfig(evt) {
5021 PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
5022}
5023function webViewerSwitchScrollMode(evt) {
5024 PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
5025}
5026function webViewerSwitchSpreadMode(evt) {
5027 PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
5028}
5029function webViewerDocumentProperties() {
5030 PDFViewerApplication.pdfDocumentProperties?.open();
5031}
5032function webViewerFindFromUrlHash(evt) {
5033 PDFViewerApplication.eventBus.dispatch("find", {
5034 source: evt.source,
5035 type: "",
5036 query: evt.query,
5037 caseSensitive: false,
5038 entireWord: false,
5039 highlightAll: true,
5040 findPrevious: false,
5041 matchDiacritics: true
5042 });
5043}
5044function webViewerUpdateFindMatchesCount({
5045 matchesCount
5046}) {
5047 if (PDFViewerApplication.supportsIntegratedFind) {
5048 PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
5049 } else {
5050 PDFViewerApplication.findBar?.updateResultsCount(matchesCount);
5051 }
5052}
5053function webViewerUpdateFindControlState({
5054 state,
5055 previous,
5056 matchesCount,
5057 rawQuery
5058}) {
5059 if (PDFViewerApplication.supportsIntegratedFind) {
5060 PDFViewerApplication.externalServices.updateFindControlState({
5061 result: state,
5062 findPrevious: previous,
5063 matchesCount,
5064 rawQuery
5065 });
5066 } else {
5067 PDFViewerApplication.findBar?.updateUIState(state, previous, matchesCount);
5068 }
5069}
5070function webViewerScaleChanging(evt) {
5071 PDFViewerApplication.toolbar?.setPageScale(evt.presetValue, evt.scale);
5072 PDFViewerApplication.pdfViewer.update(evt.noScroll);
5073}
5074function webViewerRotationChanging(evt) {
5075 if (PDFViewerApplication.pdfThumbnailViewer) {
5076 PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
5077 }
5078 PDFViewerApplication.forceRendering();
5079 PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
5080}
5081function webViewerPageChanging({
5082 pageNumber,
5083 pageLabel
5084}) {
5085 PDFViewerApplication.toolbar?.setPageNumber(pageNumber, pageLabel);
5086 PDFViewerApplication.secondaryToolbar?.setPageNumber(pageNumber);
5087 if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
5088 PDFViewerApplication.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber);
5089 }
5090 const currentPage = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
5091 PDFViewerApplication.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING);
5092 const pageNumberInput = document.getElementById("pageNumber");
5093 if (pageNumberInput) {
5094 const pageScrollEvent = new CustomEvent("page-change");
5095 pageNumberInput.dispatchEvent(pageScrollEvent);
5096 }
5097}
5098function webViewerResolutionChange(evt) {
5099 PDFViewerApplication.pdfViewer.refresh();
5100}
5101function webViewerVisibilityChange(evt) {
5102 if (document.visibilityState === "visible") {
5103 setZoomDisabledTimeout();
5104 }
5105}
5106let zoomDisabledTimeout = null;
5107function setZoomDisabledTimeout() {
5108 if (zoomDisabledTimeout) {
5109 clearTimeout(zoomDisabledTimeout);
5110 }
5111 zoomDisabledTimeout = setTimeout(function () {
5112 zoomDisabledTimeout = null;
5113 }, WHEEL_ZOOM_DISABLED_TIMEOUT);
5114}
5115function webViewerWheel(evt) {
5116 const element = document.getElementById("viewerContainer");
5117 const hover = element.parentNode.querySelector(":hover");
5118 if (hover !== element) {
5119 return;
5120 }
5121 const {
5122 pdfViewer,
5123 supportsMouseWheelZoomCtrlKey,
5124 supportsMouseWheelZoomMetaKey,
5125 supportsPinchToZoom
5126 } = PDFViewerApplication;
5127 if (pdfViewer.isInPresentationMode) {
5128 return;
5129 }
5130 const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
5131 if (window.isKeyIgnored && window.isKeyIgnored(cmd, "WHEEL")) {
5132 return;
5133 }
5134 const deltaMode = evt.deltaMode;
5135 let scaleFactor = Math.exp(-evt.deltaY / 100);
5136 const isBuiltInMac = false;
5137 const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
5138 if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
5139 evt.preventDefault();
5140 if (PDFViewerApplication._isScrolling || zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
5141 return;
5142 }
5143 const previousScale = pdfViewer.currentScale;
5144 if (isPinchToZoom && supportsPinchToZoom) {
5145 scaleFactor = PDFViewerApplication._accumulateFactor(previousScale, scaleFactor, "_wheelUnusedFactor");
5146 if (scaleFactor < 1) {
5147 PDFViewerApplication.zoomOut(null, scaleFactor);
5148 } else if (scaleFactor > 1) {
5149 PDFViewerApplication.zoomIn(null, scaleFactor);
5150 } else {
5151 return;
5152 }
5153 } else {
5154 const delta = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.normalizeWheelEventDirection)(evt);
5155 let ticks = 0;
5156 if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
5157 if (Math.abs(delta) >= 1) {
5158 ticks = Math.sign(delta);
5159 } else {
5160 ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks");
5161 }
5162 } else {
5163 const PIXELS_PER_LINE_SCALE = 30;
5164 ticks = PDFViewerApplication._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
5165 }
5166 if (ticks < 0) {
5167 PDFViewerApplication.zoomOut(-ticks);
5168 } else if (ticks > 0) {
5169 PDFViewerApplication.zoomIn(ticks);
5170 } else {
5171 return;
5172 }
5173 }
5174 PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY);
5175 }
5176}
5177function webViewerTouchStart(evt) {
5178 if (PDFViewerApplication.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
5179 return;
5180 }
5181 evt.preventDefault();
5182 if (evt.touches.length !== 2 || PDFViewerApplication.overlayManager.active) {
5183 PDFViewerApplication._touchInfo = null;
5184 return;
5185 }
5186 let [touch0, touch1] = evt.touches;
5187 if (touch0.identifier > touch1.identifier) {
5188 [touch0, touch1] = [touch1, touch0];
5189 }
5190 PDFViewerApplication._touchInfo = {
5191 touch0X: touch0.pageX,
5192 touch0Y: touch0.pageY,
5193 touch1X: touch1.pageX,
5194 touch1Y: touch1.pageY
5195 };
5196}
5197function webViewerTouchMove(evt) {
5198 if (!PDFViewerApplication._touchInfo || evt.touches.length !== 2) {
5199 return;
5200 }
5201 const {
5202 pdfViewer,
5203 _touchInfo,
5204 supportsPinchToZoom
5205 } = PDFViewerApplication;
5206 let [touch0, touch1] = evt.touches;
5207 if (touch0.identifier > touch1.identifier) {
5208 [touch0, touch1] = [touch1, touch0];
5209 }
5210 const {
5211 pageX: page0X,
5212 pageY: page0Y
5213 } = touch0;
5214 const {
5215 pageX: page1X,
5216 pageY: page1Y
5217 } = touch1;
5218 const {
5219 touch0X: pTouch0X,
5220 touch0Y: pTouch0Y,
5221 touch1X: pTouch1X,
5222 touch1Y: pTouch1Y
5223 } = _touchInfo;
5224 if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) {
5225 return;
5226 }
5227 _touchInfo.touch0X = page0X;
5228 _touchInfo.touch0Y = page0Y;
5229 _touchInfo.touch1X = page1X;
5230 _touchInfo.touch1Y = page1Y;
5231 if (pTouch0X === page0X && pTouch0Y === page0Y) {
5232 const v1X = pTouch1X - page0X;
5233 const v1Y = pTouch1Y - page0Y;
5234 const v2X = page1X - page0X;
5235 const v2Y = page1Y - page0Y;
5236 const det = v1X * v2Y - v1Y * v2X;
5237 if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
5238 return;
5239 }
5240 } else if (pTouch1X === page1X && pTouch1Y === page1Y) {
5241 const v1X = pTouch0X - page1X;
5242 const v1Y = pTouch0Y - page1Y;
5243 const v2X = page0X - page1X;
5244 const v2Y = page0Y - page1Y;
5245 const det = v1X * v2Y - v1Y * v2X;
5246 if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
5247 return;
5248 }
5249 } else {
5250 const diff0X = page0X - pTouch0X;
5251 const diff1X = page1X - pTouch1X;
5252 const diff0Y = page0Y - pTouch0Y;
5253 const diff1Y = page1Y - pTouch1Y;
5254 const dotProduct = diff0X * diff1X + diff0Y * diff1Y;
5255 if (dotProduct >= 0) {
5256 return;
5257 }
5258 }
5259 evt.preventDefault();
5260 const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
5261 const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
5262 const previousScale = pdfViewer.currentScale;
5263 if (supportsPinchToZoom) {
5264 const newScaleFactor = PDFViewerApplication._accumulateFactor(previousScale, distance / pDistance, "_touchUnusedFactor");
5265 if (newScaleFactor < 1) {
5266 PDFViewerApplication.zoomOut(null, newScaleFactor);
5267 } else if (newScaleFactor > 1) {
5268 PDFViewerApplication.zoomIn(null, newScaleFactor);
5269 } else {
5270 return;
5271 }
5272 } else {
5273 const PIXELS_PER_LINE_SCALE = 30;
5274 const ticks = PDFViewerApplication._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
5275 if (ticks < 0) {
5276 PDFViewerApplication.zoomOut(-ticks);
5277 } else if (ticks > 0) {
5278 PDFViewerApplication.zoomIn(ticks);
5279 } else {
5280 return;
5281 }
5282 }
5283 PDFViewerApplication._centerAtPos(previousScale, (page0X + page1X) / 2, (page0Y + page1Y) / 2);
5284}
5285function webViewerTouchEnd(evt) {
5286 if (!PDFViewerApplication._touchInfo) {
5287 return;
5288 }
5289 evt.preventDefault();
5290 PDFViewerApplication._touchInfo = null;
5291 PDFViewerApplication._touchUnusedTicks = 0;
5292 PDFViewerApplication._touchUnusedFactor = 1;
5293}
5294function webViewerClick(evt) {
5295 if (!PDFViewerApplication.secondaryToolbar?.isOpen) {
5296 return;
5297 }
5298 const appConfig = PDFViewerApplication.appConfig;
5299 if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar?.toggleButton) {
5300 if (evt.target && evt.target.parentElement === appConfig.secondaryToolbar.toggleButton) {
5301 return;
5302 }
5303 if (evt.target && evt.target.parentElement && evt.target.parentElement.parentElement === appConfig.secondaryToolbar.toggleButton) {
5304 return;
5305 }
5306 PDFViewerApplication.secondaryToolbar.close();
5307 }
5308}
5309function webViewerKeyUp(evt) {
5310 if (evt.key === "Control") {
5311 PDFViewerApplication._isCtrlKeyDown = false;
5312 }
5313}
5314function webViewerKeyDown(evt) {
5315 PDFViewerApplication._isCtrlKeyDown = evt.key === "Control";
5316 if (PDFViewerApplication.overlayManager.active) {
5317 return;
5318 }
5319 const {
5320 eventBus,
5321 pdfViewer
5322 } = PDFViewerApplication;
5323 const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
5324 let handled = false,
5325 ensureViewerFocused = false;
5326 const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
5327 if (window.isKeyIgnored && window.isKeyIgnored(cmd, evt.keyCode)) {
5328 return;
5329 }
5330 if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
5331 switch (evt.keyCode) {
5332 case 70:
5333 if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
5334 PDFViewerApplication.findBar?.open();
5335 handled = true;
5336 }
5337 break;
5338 case 71:
5339 if (!PDFViewerApplication.supportsIntegratedFind) {
5340 const {
5341 state
5342 } = PDFViewerApplication.findController;
5343 if (state) {
5344 const newState = {
5345 source: window,
5346 type: "again",
5347 findPrevious: cmd === 5 || cmd === 12
5348 };
5349 eventBus.dispatch("find", {
5350 ...state,
5351 ...newState
5352 });
5353 }
5354 handled = true;
5355 }
5356 break;
5357 case 61:
5358 case 107:
5359 case 187:
5360 case 171:
5361 PDFViewerApplication.zoomIn();
5362 handled = true;
5363 break;
5364 case 173:
5365 case 109:
5366 case 189:
5367 PDFViewerApplication.zoomOut();
5368 handled = true;
5369 break;
5370 case 48:
5371 case 96:
5372 if (!isViewerInPresentationMode) {
5373 setTimeout(function () {
5374 PDFViewerApplication.zoomReset();
5375 });
5376 handled = false;
5377 }
5378 break;
5379 case 38:
5380 if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
5381 PDFViewerApplication.page = 1;
5382 handled = true;
5383 ensureViewerFocused = true;
5384 }
5385 break;
5386 case 40:
5387 if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
5388 PDFViewerApplication.page = PDFViewerApplication.pagesCount;
5389 handled = true;
5390 ensureViewerFocused = true;
5391 }
5392 break;
5393 }
5394 }
5395 if (cmd === 1 || cmd === 8) {
5396 switch (evt.keyCode) {
5397 case 83:
5398 eventBus.dispatch("download", {
5399 source: window
5400 });
5401 handled = true;
5402 break;
5403 case 79:
5404 {
5405 eventBus.dispatch("openfile", {
5406 source: window
5407 });
5408 handled = true;
5409 }
5410 break;
5411 }
5412 }
5413 if (cmd === 3 || cmd === 10) {
5414 switch (evt.keyCode) {
5415 case 80:
5416 PDFViewerApplication.requestPresentationMode();
5417 handled = true;
5418 PDFViewerApplication.externalServices.reportTelemetry({
5419 type: "buttons",
5420 data: {
5421 id: "presentationModeKeyboard"
5422 }
5423 });
5424 break;
5425 case 71:
5426 if (PDFViewerApplication.appConfig.toolbar) {
5427 PDFViewerApplication.appConfig.toolbar.pageNumber.select();
5428 handled = true;
5429 }
5430 break;
5431 }
5432 }
5433 if (handled) {
5434 if (ensureViewerFocused && !isViewerInPresentationMode) {
5435 pdfViewer.focus();
5436 }
5437 evt.preventDefault();
5438 return;
5439 }
5440 const curElement = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getActiveOrFocusedElement)();
5441 const curElementTagName = curElement?.tagName.toUpperCase();
5442 if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElementTagName === "BUTTON" && (evt.keyCode === 13 || evt.keyCode === 32) || curElement?.isContentEditable) {
5443 if (evt.keyCode !== 27) {
5444 return;
5445 }
5446 }
5447 if (cmd === 0) {
5448 let turnPage = 0,
5449 turnOnlyIfPageFit = false;
5450 switch (evt.keyCode) {
5451 case 38:
5452 if (PDFViewerApplication.supportsCaretBrowsingMode) {
5453 PDFViewerApplication.moveCaret(true, false);
5454 handled = true;
5455 break;
5456 }
5457 case 33:
5458 if (pdfViewer.isVerticalScrollbarEnabled) {
5459 turnOnlyIfPageFit = true;
5460 }
5461 turnPage = -1;
5462 break;
5463 case 8:
5464 if (!isViewerInPresentationMode) {
5465 turnOnlyIfPageFit = true;
5466 }
5467 turnPage = -1;
5468 break;
5469 case 37:
5470 if (PDFViewerApplication.supportsCaretBrowsingMode) {
5471 return;
5472 }
5473 if (pdfViewer.isHorizontalScrollbarEnabled) {
5474 turnOnlyIfPageFit = true;
5475 }
5476 case 75:
5477 case 80:
5478 turnPage = -1;
5479 break;
5480 case 27:
5481 if (PDFViewerApplication.secondaryToolbar?.isOpen) {
5482 PDFViewerApplication.secondaryToolbar.close();
5483 handled = true;
5484 }
5485 if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar?.opened) {
5486 PDFViewerApplication.findBar.close();
5487 handled = true;
5488 }
5489 break;
5490 case 40:
5491 if (PDFViewerApplication.supportsCaretBrowsingMode) {
5492 PDFViewerApplication.moveCaret(false, false);
5493 handled = true;
5494 break;
5495 }
5496 case 34:
5497 if (pdfViewer.isVerticalScrollbarEnabled) {
5498 turnOnlyIfPageFit = true;
5499 }
5500 turnPage = 1;
5501 break;
5502 case 13:
5503 case 32:
5504 if (!isViewerInPresentationMode) {
5505 turnOnlyIfPageFit = true;
5506 }
5507 turnPage = 1;
5508 break;
5509 case 39:
5510 if (PDFViewerApplication.supportsCaretBrowsingMode) {
5511 return;
5512 }
5513 if (pdfViewer.isHorizontalScrollbarEnabled) {
5514 turnOnlyIfPageFit = true;
5515 }
5516 case 74:
5517 case 78:
5518 turnPage = 1;
5519 break;
5520 case 36:
5521 if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
5522 PDFViewerApplication.page = 1;
5523 handled = true;
5524 ensureViewerFocused = true;
5525 }
5526 break;
5527 case 35:
5528 if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
5529 PDFViewerApplication.page = PDFViewerApplication.pagesCount;
5530 handled = true;
5531 ensureViewerFocused = true;
5532 }
5533 break;
5534 case 83:
5535 PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT);
5536 break;
5537 case 72:
5538 PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND);
5539 break;
5540 case 82:
5541 PDFViewerApplication.rotatePages(90);
5542 break;
5543 case 115:
5544 PDFViewerApplication.pdfSidebar?.toggle();
5545 break;
5546 }
5547 if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
5548 if (turnPage > 0) {
5549 pdfViewer.nextPage();
5550 } else {
5551 pdfViewer.previousPage();
5552 }
5553 handled = true;
5554 }
5555 }
5556 if (cmd === 4) {
5557 switch (evt.keyCode) {
5558 case 13:
5559 case 32:
5560 if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
5561 break;
5562 }
5563 pdfViewer.previousPage();
5564 handled = true;
5565 break;
5566 case 38:
5567 PDFViewerApplication.moveCaret(true, true);
5568 handled = true;
5569 break;
5570 case 40:
5571 PDFViewerApplication.moveCaret(false, true);
5572 handled = true;
5573 break;
5574 case 82:
5575 PDFViewerApplication.rotatePages(-90);
5576 break;
5577 }
5578 }
5579 if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
5580 pdfViewer.focus();
5581 }
5582 if (handled) {
5583 evt.preventDefault();
5584 }
5585}
5586function beforeUnload(evt) {
5587 evt.preventDefault();
5588 evt.returnValue = "";
5589 return false;
5590}
5591function webViewerAnnotationEditorStatesChanged(data) {
5592 PDFViewerApplication.externalServices.updateEditorStates(data);
5593}
5594function webViewerReportTelemetry({
5595 details
5596}) {
5597 PDFViewerApplication.externalServices.reportTelemetry(details);
5598}
5599
5600__webpack_async_result__();
5601} catch(e) { __webpack_async_result__(e); } });
5602
5603/***/ }),
5604
5605/***/ 9840:
5606/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5607
5608/* harmony export */ __webpack_require__.d(__webpack_exports__, {
5609/* harmony export */ AppOptions: () => (/* binding */ AppOptions),
5610/* harmony export */ OptionKind: () => (/* binding */ OptionKind)
5611/* harmony export */ });
5612{
5613 var compatibilityParams = Object.create(null);
5614 const userAgent = navigator.userAgent || "";
5615 const platform = navigator.platform || "";
5616 const maxTouchPoints = navigator.maxTouchPoints || 1;
5617 const isAndroid = /Android/.test(userAgent);
5618 const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
5619 (function checkCanvasSizeLimitation() {
5620 if (isIOS || isAndroid) {
5621 compatibilityParams.maxCanvasPixels = 5242880;
5622 }
5623 })();
5624}
5625const OptionKind = {
5626 BROWSER: 0x01,
5627 VIEWER: 0x02,
5628 API: 0x04,
5629 WORKER: 0x08,
5630 PREFERENCE: 0x80
5631};
5632const defaultOptions = {
5633 canvasMaxAreaInBytes: {
5634 value: -1,
5635 kind: OptionKind.BROWSER + OptionKind.API
5636 },
5637 isInAutomation: {
5638 value: false,
5639 kind: OptionKind.BROWSER
5640 },
5641 supportsCaretBrowsingMode: {
5642 value: false,
5643 kind: OptionKind.BROWSER
5644 },
5645 supportsDocumentFonts: {
5646 value: true,
5647 kind: OptionKind.BROWSER
5648 },
5649 supportsIntegratedFind: {
5650 value: false,
5651 kind: OptionKind.BROWSER
5652 },
5653 supportsMouseWheelZoomCtrlKey: {
5654 value: true,
5655 kind: OptionKind.BROWSER
5656 },
5657 supportsMouseWheelZoomMetaKey: {
5658 value: true,
5659 kind: OptionKind.BROWSER
5660 },
5661 supportsPinchToZoom: {
5662 value: true,
5663 kind: OptionKind.BROWSER
5664 },
5665 annotationEditorMode: {
5666 value: 0,
5667 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5668 },
5669 annotationMode: {
5670 value: 2,
5671 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5672 },
5673 cursorToolOnLoad: {
5674 value: 0,
5675 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5676 },
5677 debuggerSrc: {
5678 value: "./debugger.mjs",
5679 kind: OptionKind.VIEWER
5680 },
5681 defaultZoomDelay: {
5682 value: 400,
5683 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5684 },
5685 defaultZoomValue: {
5686 value: "",
5687 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5688 },
5689 disableHistory: {
5690 value: false,
5691 kind: OptionKind.VIEWER
5692 },
5693 disablePageLabels: {
5694 value: false,
5695 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5696 },
5697 enableHighlightEditor: {
5698 value: false,
5699 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5700 },
5701 enableHighlightFloatingButton: {
5702 value: false,
5703 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5704 },
5705 enableML: {
5706 value: false,
5707 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5708 },
5709 enablePermissions: {
5710 value: false,
5711 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5712 },
5713 enablePrintAutoRotate: {
5714 value: true,
5715 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5716 },
5717 enableScripting: {
5718 value: true,
5719 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5720 },
5721 enableStampEditor: {
5722 value: true,
5723 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5724 },
5725 externalLinkRel: {
5726 value: "noopener noreferrer nofollow",
5727 kind: OptionKind.VIEWER
5728 },
5729 externalLinkTarget: {
5730 value: 0,
5731 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5732 },
5733 highlightEditorColors: {
5734 value: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
5735 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5736 },
5737 historyUpdateUrl: {
5738 value: false,
5739 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5740 },
5741 ignoreDestinationZoom: {
5742 value: false,
5743 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5744 },
5745 imageResourcesPath: {
5746 value: "./images/",
5747 kind: OptionKind.VIEWER
5748 },
5749 maxCanvasPixels: {
5750 value: 2 ** 25,
5751 kind: OptionKind.VIEWER
5752 },
5753 forcePageColors: {
5754 value: false,
5755 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5756 },
5757 pageColorsBackground: {
5758 value: "Canvas",
5759 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5760 },
5761 pageColorsForeground: {
5762 value: "CanvasText",
5763 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5764 },
5765 pdfBugEnabled: {
5766 value: false,
5767 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5768 },
5769 printResolution: {
5770 value: 150,
5771 kind: OptionKind.VIEWER
5772 },
5773 removePageBorders: {
5774 value: false,
5775 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5776 },
5777 sidebarViewOnLoad: {
5778 value: -1,
5779 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5780 },
5781 scrollModeOnLoad: {
5782 value: -1,
5783 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5784 },
5785 spreadModeOnLoad: {
5786 value: -1,
5787 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5788 },
5789 textLayerMode: {
5790 value: 1,
5791 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5792 },
5793 viewOnLoad: {
5794 value: 0,
5795 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5796 },
5797 cMapPacked: {
5798 value: true,
5799 kind: OptionKind.API
5800 },
5801 cMapUrl: {
5802 value: "../web/cmaps/",
5803 kind: OptionKind.API
5804 },
5805 disableAutoFetch: {
5806 value: false,
5807 kind: OptionKind.API + OptionKind.PREFERENCE
5808 },
5809 disableFontFace: {
5810 value: false,
5811 kind: OptionKind.API + OptionKind.PREFERENCE
5812 },
5813 disableRange: {
5814 value: false,
5815 kind: OptionKind.API + OptionKind.PREFERENCE
5816 },
5817 disableStream: {
5818 value: false,
5819 kind: OptionKind.API + OptionKind.PREFERENCE
5820 },
5821 docBaseUrl: {
5822 value: "",
5823 kind: OptionKind.API
5824 },
5825 enableXfa: {
5826 value: true,
5827 kind: OptionKind.API + OptionKind.PREFERENCE
5828 },
5829 fontExtraProperties: {
5830 value: false,
5831 kind: OptionKind.API
5832 },
5833 isEvalSupported: {
5834 value: true,
5835 kind: OptionKind.API
5836 },
5837 isOffscreenCanvasSupported: {
5838 value: true,
5839 kind: OptionKind.API
5840 },
5841 maxImageSize: {
5842 value: -1,
5843 kind: OptionKind.API
5844 },
5845 pdfBug: {
5846 value: false,
5847 kind: OptionKind.API
5848 },
5849 standardFontDataUrl: {
5850 value: "../web/standard_fonts/",
5851 kind: OptionKind.API
5852 },
5853 verbosity: {
5854 value: 1,
5855 kind: OptionKind.API
5856 },
5857 workerPort: {
5858 value: null,
5859 kind: OptionKind.WORKER
5860 },
5861 workerSrc: {
5862 value: "./assets/pdf.worker.mjs",
5863 kind: OptionKind.WORKER
5864 }
5865};
5866{
5867 defaultOptions.defaultUrl = {
5868 value: "compressed.tracemonkey-pldi-09.pdf",
5869 kind: OptionKind.VIEWER
5870 };
5871 defaultOptions.sandboxBundleSrc = {
5872 value: "../build/pdf.sandbox.mjs",
5873 kind: OptionKind.VIEWER
5874 };
5875 defaultOptions.viewerCssTheme = {
5876 value: 0,
5877 kind: OptionKind.VIEWER + OptionKind.PREFERENCE
5878 };
5879}
5880{
5881 defaultOptions.disablePreferences = {
5882 value: false,
5883 kind: OptionKind.VIEWER
5884 };
5885 defaultOptions.locale = {
5886 value: navigator.language || "en-US",
5887 kind: OptionKind.VIEWER
5888 };
5889}
5890const userOptions = Object.create(null);
5891{
5892 for (const name in compatibilityParams) {
5893 userOptions[name] = compatibilityParams[name];
5894 }
5895}
5896if (globalThis.pdfDefaultOptions) {
5897 for (const key in globalThis.pdfDefaultOptions) {
5898 userOptions[key] = globalThis.pdfDefaultOptions[key];
5899 }
5900}
5901class AppOptions {
5902 constructor() {
5903 throw new Error("Cannot initialize AppOptions.");
5904 }
5905 static get(name) {
5906 return userOptions[name] ?? defaultOptions[name]?.value ?? undefined;
5907 }
5908 static getAll(kind = null, defaultOnly = false) {
5909 const options = Object.create(null);
5910 for (const name in defaultOptions) {
5911 const defaultOption = defaultOptions[name];
5912 if (kind && !(kind & defaultOption.kind)) {
5913 continue;
5914 }
5915 options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? defaultOption.value;
5916 }
5917 return options;
5918 }
5919 static set(name, value) {
5920 userOptions[name] = value;
5921 }
5922 static setAll(options, init = false) {
5923 if (init) {
5924 if (this.get("disablePreferences")) {
5925 return;
5926 }
5927 for (const name in userOptions) {
5928 if (compatibilityParams[name] !== undefined) {
5929 continue;
5930 }
5931 console.warn("setAll: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
5932 break;
5933 }
5934 }
5935 for (const name in options) {
5936 userOptions[name] = options[name];
5937 }
5938 }
5939 static remove(name) {
5940 delete userOptions[name];
5941 const val = compatibilityParams[name];
5942 if (val !== undefined) {
5943 userOptions[name] = val;
5944 }
5945 }
5946}
5947
5948
5949/***/ }),
5950
5951/***/ 2961:
5952/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5953
5954/* harmony export */ __webpack_require__.d(__webpack_exports__, {
5955/* harmony export */ BaseTreeViewer: () => (/* binding */ BaseTreeViewer)
5956/* harmony export */ });
5957/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
5958
5959const TREEITEM_OFFSET_TOP = -100;
5960const TREEITEM_SELECTED_CLASS = "selected";
5961class BaseTreeViewer {
5962 constructor(options) {
5963 if (this.constructor === BaseTreeViewer) {
5964 throw new Error("Cannot initialize BaseTreeViewer.");
5965 }
5966 this.container = options.container;
5967 this.eventBus = options.eventBus;
5968 this._l10n = options.l10n;
5969 this.reset();
5970 }
5971 reset() {
5972 this._pdfDocument = null;
5973 this._lastToggleIsShow = true;
5974 this._currentTreeItem = null;
5975 this.container.textContent = "";
5976 this.container.classList.remove("treeWithDeepNesting");
5977 }
5978 _dispatchEvent(count) {
5979 throw new Error("Not implemented: _dispatchEvent");
5980 }
5981 _bindLink(element, params) {
5982 throw new Error("Not implemented: _bindLink");
5983 }
5984 _normalizeTextContent(str) {
5985 return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(str, true) || "\u2013";
5986 }
5987 _addToggleButton(div, hidden = false) {
5988 const toggler = document.createElement("div");
5989 toggler.className = "treeItemToggler";
5990 if (hidden) {
5991 toggler.classList.add("treeItemsHidden");
5992 }
5993 toggler.onclick = evt => {
5994 evt.stopPropagation();
5995 toggler.classList.toggle("treeItemsHidden");
5996 if (evt.shiftKey) {
5997 const shouldShowAll = !toggler.classList.contains("treeItemsHidden");
5998 this._toggleTreeItem(div, shouldShowAll);
5999 }
6000 };
6001 div.prepend(toggler);
6002 }
6003 _toggleTreeItem(root, show = false) {
6004 this._l10n.pause();
6005 this._lastToggleIsShow = show;
6006 for (const toggler of root.querySelectorAll(".treeItemToggler")) {
6007 toggler.classList.toggle("treeItemsHidden", !show);
6008 }
6009 this._l10n.resume();
6010 }
6011 _toggleAllTreeItems() {
6012 this._toggleTreeItem(this.container, !this._lastToggleIsShow);
6013 }
6014 _finishRendering(fragment, count, hasAnyNesting = false) {
6015 if (hasAnyNesting) {
6016 this.container.classList.add("treeWithDeepNesting");
6017 this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
6018 }
6019 this._l10n.pause();
6020 this.container.append(fragment);
6021 this._l10n.resume();
6022 this._dispatchEvent(count);
6023 }
6024 render(params) {
6025 throw new Error("Not implemented: render");
6026 }
6027 _updateCurrentTreeItem(treeItem = null) {
6028 if (this._currentTreeItem) {
6029 this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
6030 this._currentTreeItem = null;
6031 }
6032 if (treeItem) {
6033 treeItem.classList.add(TREEITEM_SELECTED_CLASS);
6034 this._currentTreeItem = treeItem;
6035 }
6036 }
6037 _scrollToCurrentTreeItem(treeItem) {
6038 if (!treeItem) {
6039 return;
6040 }
6041 this._l10n.pause();
6042 let currentNode = treeItem.parentNode;
6043 while (currentNode && currentNode !== this.container) {
6044 if (currentNode.classList.contains("treeItem")) {
6045 const toggler = currentNode.firstElementChild;
6046 toggler?.classList.remove("treeItemsHidden");
6047 }
6048 currentNode = currentNode.parentNode;
6049 }
6050 this._l10n.resume();
6051 this._updateCurrentTreeItem(treeItem);
6052 this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
6053 }
6054}
6055
6056
6057/***/ }),
6058
6059/***/ 3973:
6060/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6061
6062/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6063/* harmony export */ CaretBrowsingMode: () => (/* binding */ CaretBrowsingMode)
6064/* harmony export */ });
6065const PRECISION = 1e-1;
6066class CaretBrowsingMode {
6067 #mainContainer;
6068 #toolBarHeight;
6069 #viewerContainer;
6070 constructor(mainContainer, viewerContainer, toolbarContainer) {
6071 this.#mainContainer = mainContainer;
6072 this.#viewerContainer = viewerContainer;
6073 this.#toolBarHeight = toolbarContainer?.getBoundingClientRect().height ?? 0;
6074 }
6075 #isOnSameLine(rect1, rect2) {
6076 const top1 = rect1.y;
6077 const bot1 = rect1.bottom;
6078 const mid1 = rect1.y + rect1.height / 2;
6079 const top2 = rect2.y;
6080 const bot2 = rect2.bottom;
6081 const mid2 = rect2.y + rect2.height / 2;
6082 return top1 <= mid2 && mid2 <= bot1 || top2 <= mid1 && mid1 <= bot2;
6083 }
6084 #isUnderOver(rect, x, y, isUp) {
6085 const midY = rect.y + rect.height / 2;
6086 return (isUp ? y >= midY : y <= midY) && rect.x - PRECISION <= x && x <= rect.right + PRECISION;
6087 }
6088 #isVisible(rect) {
6089 return rect.top >= this.#toolBarHeight && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
6090 }
6091 #getCaretPosition(selection, isUp) {
6092 const {
6093 focusNode,
6094 focusOffset
6095 } = selection;
6096 const range = document.createRange();
6097 range.setStart(focusNode, focusOffset);
6098 range.setEnd(focusNode, focusOffset);
6099 const rect = range.getBoundingClientRect();
6100 return [rect.x, isUp ? rect.top : rect.bottom];
6101 }
6102 static #caretPositionFromPoint(x, y) {
6103 if (!document.caretPositionFromPoint) {
6104 const {
6105 startContainer: offsetNode,
6106 startOffset: offset
6107 } = document.caretRangeFromPoint(x, y);
6108 return {
6109 offsetNode,
6110 offset
6111 };
6112 }
6113 return document.caretPositionFromPoint(x, y);
6114 }
6115 #setCaretPositionHelper(selection, caretX, select, element, rect) {
6116 rect ||= element.getBoundingClientRect();
6117 if (caretX <= rect.x + PRECISION) {
6118 if (select) {
6119 selection.extend(element.firstChild, 0);
6120 } else {
6121 selection.setPosition(element.firstChild, 0);
6122 }
6123 return;
6124 }
6125 if (rect.right - PRECISION <= caretX) {
6126 const {
6127 lastChild
6128 } = element;
6129 if (select) {
6130 selection.extend(lastChild, lastChild.length);
6131 } else {
6132 selection.setPosition(lastChild, lastChild.length);
6133 }
6134 return;
6135 }
6136 const midY = rect.y + rect.height / 2;
6137 let caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
6138 let parentElement = caretPosition.offsetNode?.parentElement;
6139 if (parentElement && parentElement !== element) {
6140 const elementsAtPoint = document.elementsFromPoint(caretX, midY);
6141 const savedVisibilities = [];
6142 for (const el of elementsAtPoint) {
6143 if (el === element) {
6144 break;
6145 }
6146 const {
6147 style
6148 } = el;
6149 savedVisibilities.push([el, style.visibility]);
6150 style.visibility = "hidden";
6151 }
6152 caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
6153 parentElement = caretPosition.offsetNode?.parentElement;
6154 for (const [el, visibility] of savedVisibilities) {
6155 el.style.visibility = visibility;
6156 }
6157 }
6158 if (parentElement !== element) {
6159 if (select) {
6160 selection.extend(element.firstChild, 0);
6161 } else {
6162 selection.setPosition(element.firstChild, 0);
6163 }
6164 return;
6165 }
6166 if (select) {
6167 selection.extend(caretPosition.offsetNode, caretPosition.offset);
6168 } else {
6169 selection.setPosition(caretPosition.offsetNode, caretPosition.offset);
6170 }
6171 }
6172 #setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX) {
6173 if (this.#isVisible(newLineElementRect)) {
6174 this.#setCaretPositionHelper(selection, caretX, select, newLineElement, newLineElementRect);
6175 return;
6176 }
6177 this.#mainContainer.addEventListener("scrollend", this.#setCaretPositionHelper.bind(this, selection, caretX, select, newLineElement, null), {
6178 once: true
6179 });
6180 newLineElement.scrollIntoView();
6181 }
6182 #getNodeOnNextPage(textLayer, isUp) {
6183 while (true) {
6184 const page = textLayer.closest(".page");
6185 const pageNumber = parseInt(page.getAttribute("data-page-number"));
6186 const nextPage = isUp ? pageNumber - 1 : pageNumber + 1;
6187 textLayer = this.#viewerContainer.querySelector(`.page[data-page-number="${nextPage}"] .textLayer`);
6188 if (!textLayer) {
6189 return null;
6190 }
6191 const walker = document.createTreeWalker(textLayer, NodeFilter.SHOW_TEXT);
6192 const node = isUp ? walker.lastChild() : walker.firstChild();
6193 if (node) {
6194 return node;
6195 }
6196 }
6197 }
6198 moveCaret(isUp, select) {
6199 const selection = document.getSelection();
6200 if (selection.rangeCount === 0) {
6201 return;
6202 }
6203 const {
6204 focusNode
6205 } = selection;
6206 const focusElement = focusNode.nodeType !== Node.ELEMENT_NODE ? focusNode.parentElement : focusNode;
6207 const root = focusElement.closest(".textLayer");
6208 if (!root) {
6209 return;
6210 }
6211 const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
6212 walker.currentNode = focusNode;
6213 const focusRect = focusElement.getBoundingClientRect();
6214 let newLineElement = null;
6215 const nodeIterator = (isUp ? walker.previousSibling : walker.nextSibling).bind(walker);
6216 while (nodeIterator()) {
6217 const element = walker.currentNode.parentElement;
6218 if (!this.#isOnSameLine(focusRect, element.getBoundingClientRect())) {
6219 newLineElement = element;
6220 break;
6221 }
6222 }
6223 if (!newLineElement) {
6224 const node = this.#getNodeOnNextPage(root, isUp);
6225 if (!node) {
6226 return;
6227 }
6228 if (select) {
6229 const lastNode = (isUp ? walker.firstChild() : walker.lastChild()) || focusNode;
6230 selection.extend(lastNode, isUp ? 0 : lastNode.length);
6231 const range = document.createRange();
6232 range.setStart(node, isUp ? node.length : 0);
6233 range.setEnd(node, isUp ? node.length : 0);
6234 selection.addRange(range);
6235 return;
6236 }
6237 const [caretX] = this.#getCaretPosition(selection, isUp);
6238 const {
6239 parentElement
6240 } = node;
6241 this.#setCaretPosition(select, selection, parentElement, parentElement.getBoundingClientRect(), caretX);
6242 return;
6243 }
6244 const [caretX, caretY] = this.#getCaretPosition(selection, isUp);
6245 const newLineElementRect = newLineElement.getBoundingClientRect();
6246 if (this.#isUnderOver(newLineElementRect, caretX, caretY, isUp)) {
6247 this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX);
6248 return;
6249 }
6250 while (nodeIterator()) {
6251 const element = walker.currentNode.parentElement;
6252 const elementRect = element.getBoundingClientRect();
6253 if (!this.#isOnSameLine(newLineElementRect, elementRect)) {
6254 break;
6255 }
6256 if (this.#isUnderOver(elementRect, caretX, caretY, isUp)) {
6257 this.#setCaretPosition(select, selection, element, elementRect, caretX);
6258 return;
6259 }
6260 }
6261 this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX);
6262 }
6263}
6264
6265
6266/***/ }),
6267
6268/***/ 1544:
6269/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
6270
6271__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
6272/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6273/* harmony export */ DownloadManager: () => (/* binding */ DownloadManager)
6274/* harmony export */ });
6275/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
6276var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
6277pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
6278
6279function download(blobUrl, filename) {
6280 const a = document.createElement("a");
6281 if (!a.click) {
6282 throw new Error('DownloadManager: "a.click()" is not supported.');
6283 }
6284 a.href = blobUrl;
6285 a.target = "_parent";
6286 if ("download" in a) {
6287 a.download = filename;
6288 }
6289 (document.body || document.documentElement).append(a);
6290 a.click();
6291 a.remove();
6292}
6293class DownloadManager {
6294 #openBlobUrls = new WeakMap();
6295 downloadUrl(url, filename, _options) {
6296 if (!(0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.createValidAbsoluteUrl)(url, "http://example.com")) {
6297 globalThis.ngxConsole.error(`downloadUrl - not a valid URL: ${url}`);
6298 return;
6299 }
6300 download(url + "#pdfjs.action=download", filename);
6301 }
6302 downloadData(data, filename, contentType) {
6303 const blobUrl = URL.createObjectURL(new Blob([data], {
6304 type: contentType
6305 }));
6306 download(blobUrl, filename);
6307 }
6308 openOrDownloadData(data, filename, dest = null) {
6309 const isPdfData = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.isPdfFile)(filename);
6310 const contentType = isPdfData ? "application/pdf" : "";
6311 if (isPdfData) {
6312 let blobUrl = this.#openBlobUrls.get(data);
6313 if (!blobUrl) {
6314 blobUrl = URL.createObjectURL(new Blob([data], {
6315 type: contentType
6316 }));
6317 this.#openBlobUrls.set(data, blobUrl);
6318 }
6319 try {
6320 window.open(blobUrl);
6321 return true;
6322 } catch (ex) {
6323 globalThis.ngxConsole.error(`openOrDownloadData: ${ex}`);
6324 URL.revokeObjectURL(blobUrl);
6325 this.#openBlobUrls.delete(data);
6326 }
6327 }
6328 this.downloadData(data, filename, contentType);
6329 return false;
6330 }
6331 download(blob, url, filename, _options) {
6332 const blobUrl = URL.createObjectURL(blob);
6333 download(blobUrl, filename);
6334 }
6335}
6336
6337__webpack_async_result__();
6338} catch(e) { __webpack_async_result__(e); } });
6339
6340/***/ }),
6341
6342/***/ 3088:
6343/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
6344
6345__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
6346/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6347/* harmony export */ DrawLayerBuilder: () => (/* binding */ DrawLayerBuilder)
6348/* harmony export */ });
6349/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
6350var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
6351pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
6352
6353class DrawLayerBuilder {
6354 #drawLayer = null;
6355 constructor(options) {
6356 this.pageIndex = options.pageIndex;
6357 }
6358 async render(intent = "display") {
6359 if (intent !== "display" || this.#drawLayer || this._cancelled) {
6360 return;
6361 }
6362 this.#drawLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.DrawLayer({
6363 pageIndex: this.pageIndex
6364 });
6365 }
6366 cancel() {
6367 this._cancelled = true;
6368 if (!this.#drawLayer) {
6369 return;
6370 }
6371 this.#drawLayer.destroy();
6372 this.#drawLayer = null;
6373 }
6374 setParent(parent) {
6375 this.#drawLayer?.setParent(parent);
6376 }
6377 getDrawLayer() {
6378 return this.#drawLayer;
6379 }
6380}
6381
6382__webpack_async_result__();
6383} catch(e) { __webpack_async_result__(e); } });
6384
6385/***/ }),
6386
6387/***/ 5656:
6388/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6389
6390/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6391/* harmony export */ AutomationEventBus: () => (/* binding */ AutomationEventBus),
6392/* harmony export */ EventBus: () => (/* binding */ EventBus),
6393/* harmony export */ waitOnEventOrTimeout: () => (/* binding */ waitOnEventOrTimeout)
6394/* harmony export */ });
6395/* unused harmony export WaitOnType */
6396const WaitOnType = {
6397 EVENT: "event",
6398 TIMEOUT: "timeout"
6399};
6400async function waitOnEventOrTimeout({
6401 target,
6402 name,
6403 delay = 0
6404}) {
6405 if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
6406 throw new Error("waitOnEventOrTimeout - invalid parameters.");
6407 }
6408 const {
6409 promise,
6410 resolve
6411 } = Promise.withResolvers();
6412 const ac = new AbortController();
6413 function handler(type) {
6414 ac.abort();
6415 clearTimeout(timeout);
6416 resolve(type);
6417 }
6418 const evtMethod = target instanceof EventBus ? "_on" : "addEventListener";
6419 target[evtMethod](name, handler.bind(null, WaitOnType.EVENT), {
6420 signal: ac.signal
6421 });
6422 const timeout = setTimeout(handler.bind(null, WaitOnType.TIMEOUT), delay);
6423 return promise;
6424}
6425class EventBus {
6426 #listeners = Object.create(null);
6427 on(eventName, listener, options = null) {
6428 this._on(eventName, listener, {
6429 external: true,
6430 once: options?.once,
6431 signal: options?.signal
6432 });
6433 }
6434 off(eventName, listener, options = null) {
6435 this._off(eventName, listener);
6436 }
6437 dispatch(eventName, data) {
6438 const eventListeners = this.#listeners[eventName];
6439 if (!eventListeners || eventListeners.length === 0) {
6440 return;
6441 }
6442 let externalListeners;
6443 for (const {
6444 listener,
6445 external,
6446 once
6447 } of eventListeners.slice(0)) {
6448 if (once) {
6449 this._off(eventName, listener);
6450 }
6451 if (external) {
6452 (externalListeners ||= []).push(listener);
6453 continue;
6454 }
6455 listener(data);
6456 }
6457 if (externalListeners) {
6458 for (const listener of externalListeners) {
6459 listener(data);
6460 }
6461 externalListeners = null;
6462 }
6463 }
6464 _on(eventName, listener, options = null) {
6465 let rmAbort = null;
6466 if (options?.signal instanceof AbortSignal) {
6467 const {
6468 signal
6469 } = options;
6470 if (signal.aborted) {
6471 console.error("Cannot use an `aborted` signal.");
6472 return;
6473 }
6474 const onAbort = () => this._off(eventName, listener);
6475 rmAbort = () => signal.removeEventListener("abort", onAbort);
6476 signal.addEventListener("abort", onAbort);
6477 }
6478 const eventListeners = this.#listeners[eventName] ||= [];
6479 eventListeners.push({
6480 listener,
6481 external: options?.external === true,
6482 once: options?.once === true,
6483 rmAbort
6484 });
6485 }
6486 _off(eventName, listener, options = null) {
6487 const eventListeners = this.#listeners[eventName];
6488 if (!eventListeners) {
6489 return;
6490 }
6491 for (let i = 0, ii = eventListeners.length; i < ii; i++) {
6492 const evt = eventListeners[i];
6493 if (evt.listener === listener) {
6494 evt.rmAbort?.();
6495 eventListeners.splice(i, 1);
6496 return;
6497 }
6498 }
6499 }
6500}
6501class AutomationEventBus extends EventBus {
6502 dispatch(eventName, data) {
6503 throw new Error("Not implemented: AutomationEventBus.dispatch");
6504 }
6505}
6506
6507
6508/***/ }),
6509
6510/***/ 4290:
6511/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6512
6513/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6514/* harmony export */ BaseExternalServices: () => (/* binding */ BaseExternalServices)
6515/* harmony export */ });
6516class BaseExternalServices {
6517 constructor() {
6518 if (this.constructor === BaseExternalServices) {
6519 throw new Error("Cannot initialize BaseExternalServices.");
6520 }
6521 }
6522 updateFindControlState(data) {}
6523 updateFindMatchesCount(data) {}
6524 initPassiveLoading() {}
6525 reportTelemetry(data) {}
6526 async createL10n() {
6527 throw new Error("Not implemented: createL10n");
6528 }
6529 createScripting() {
6530 throw new Error("Not implemented: createScripting");
6531 }
6532 updateEditorStates(data) {
6533 throw new Error("Not implemented: updateEditorStates");
6534 }
6535 async getNimbusExperimentData() {}
6536}
6537
6538
6539/***/ }),
6540
6541/***/ 289:
6542/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
6543
6544__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
6545/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6546/* harmony export */ GenericScripting: () => (/* binding */ GenericScripting)
6547/* harmony export */ });
6548/* unused harmony export docProperties */
6549/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
6550var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
6551pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
6552
6553async function docProperties(pdfDocument) {
6554 const url = "",
6555 baseUrl = url.split("#", 1)[0];
6556 let {
6557 info,
6558 metadata,
6559 contentDispositionFilename,
6560 contentLength
6561 } = await pdfDocument.getMetadata();
6562 if (!contentLength) {
6563 const {
6564 length
6565 } = await pdfDocument.getDownloadInfo();
6566 contentLength = length;
6567 }
6568 return {
6569 ...info,
6570 baseURL: baseUrl,
6571 filesize: contentLength,
6572 filename: contentDispositionFilename || getPdfFilenameFromUrl(url),
6573 metadata: metadata?.getRaw(),
6574 authors: metadata?.get("dc:creator"),
6575 numPages: pdfDocument.numPages,
6576 URL: url
6577 };
6578}
6579class GenericScripting {
6580 constructor(sandboxBundleSrc) {
6581 if (sandboxBundleSrc?.constructor?.name === "Function") {
6582 sandboxBundleSrc = sandboxBundleSrc();
6583 }
6584 this._ready = new Promise((resolve, reject) => {
6585 const sandbox = import( /*webpackIgnore: true*/sandboxBundleSrc);
6586 sandbox.then(pdfjsSandbox => {
6587 resolve(pdfjsSandbox.QuickJSSandbox());
6588 }).catch(reject);
6589 });
6590 }
6591 async createSandbox(data) {
6592 const sandbox = await this._ready;
6593 sandbox.create(data);
6594 }
6595 async dispatchEventInSandbox(event) {
6596 const sandbox = await this._ready;
6597 setTimeout(() => sandbox.dispatchEvent(event), 0);
6598 }
6599 async destroySandbox() {
6600 const sandbox = await this._ready;
6601 sandbox.nukeSandbox();
6602 }
6603}
6604
6605__webpack_async_result__();
6606} catch(e) { __webpack_async_result__(e); } });
6607
6608/***/ }),
6609
6610/***/ 6750:
6611/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
6612
6613__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
6614/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6615/* harmony export */ ExternalServices: () => (/* binding */ ExternalServices),
6616/* harmony export */ MLManager: () => (/* binding */ MLManager),
6617/* harmony export */ Preferences: () => (/* binding */ Preferences),
6618/* harmony export */ initCom: () => (/* binding */ initCom)
6619/* harmony export */ });
6620/* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9840);
6621/* harmony import */ var _external_services_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4290);
6622/* harmony import */ var _preferences_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8224);
6623/* harmony import */ var _genericl10n_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(410);
6624/* harmony import */ var _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(289);
6625var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_genericl10n_js__WEBPACK_IMPORTED_MODULE_2__, _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__]);
6626([_genericl10n_js__WEBPACK_IMPORTED_MODULE_2__, _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
6627
6628
6629
6630
6631
6632function initCom(app) {}
6633class Preferences extends _preferences_js__WEBPACK_IMPORTED_MODULE_1__.BasePreferences {
6634 async _writeToStorage(prefObj) {
6635 try {
6636 localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
6637 } catch (safariSecurityException) {}
6638 }
6639 async _readFromStorage(prefObj) {
6640 try {
6641 return {
6642 prefs: JSON.parse(localStorage.getItem("pdfjs.preferences"))
6643 };
6644 } catch (safariSecurityException) {
6645 return {};
6646 }
6647 }
6648}
6649class ExternalServices extends _external_services_js__WEBPACK_IMPORTED_MODULE_4__.BaseExternalServices {
6650 async createL10n() {
6651 return new _genericl10n_js__WEBPACK_IMPORTED_MODULE_2__.GenericL10n(_app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.get("locale"));
6652 }
6653 createScripting() {
6654 return new _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__.GenericScripting(_app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.get("sandboxBundleSrc"));
6655 }
6656}
6657class MLManager {
6658 async guess() {
6659 return null;
6660 }
6661}
6662
6663__webpack_async_result__();
6664} catch(e) { __webpack_async_result__(e); } });
6665
6666/***/ }),
6667
6668/***/ 410:
6669/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
6670
6671__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
6672/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6673/* harmony export */ GenericL10n: () => (/* binding */ GenericL10n)
6674/* harmony export */ });
6675/* harmony import */ var fluent_bundle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(588);
6676/* harmony import */ var fluent_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5273);
6677/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2603);
6678/* harmony import */ var _l10n_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4693);
6679var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__]);
6680pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
6681
6682
6683
6684
6685function createBundle(lang, text) {
6686 const resource = new fluent_bundle__WEBPACK_IMPORTED_MODULE_0__.FluentResource(text);
6687 const bundle = new fluent_bundle__WEBPACK_IMPORTED_MODULE_0__.FluentBundle(lang);
6688 const errors = bundle.addResource(resource);
6689 if (errors.length) {
6690 console.error("L10n errors", errors);
6691 }
6692 return bundle;
6693}
6694class GenericL10n extends _l10n_js__WEBPACK_IMPORTED_MODULE_3__.L10n {
6695 constructor(lang) {
6696 super({
6697 lang
6698 });
6699 const generateBundles = !lang ? GenericL10n.#generateBundlesFallback.bind(GenericL10n, this.getLanguage()) : GenericL10n.#generateBundles.bind(GenericL10n, "en-us", this.getLanguage());
6700 this._setL10n(new fluent_dom__WEBPACK_IMPORTED_MODULE_1__.DOMLocalization([], generateBundles));
6701 }
6702 static async *#generateBundles(defaultLang, baseLang) {
6703 const {
6704 baseURL,
6705 paths
6706 } = await this.#getPaths();
6707 const langs = [baseLang];
6708 if (defaultLang !== baseLang) {
6709 const shortLang = baseLang.split("-", 1)[0];
6710 if (shortLang !== baseLang) {
6711 langs.push(shortLang);
6712 }
6713 langs.push(defaultLang);
6714 }
6715 for (const lang of langs) {
6716 const bundle = await this.#createBundle(lang, baseURL, paths);
6717 if (bundle) {
6718 yield bundle;
6719 }
6720 if (lang === "en-us") {
6721 yield this.#createBundleFallback(lang);
6722 }
6723 }
6724 }
6725 static async #createBundle(lang, baseURL, paths) {
6726 const path = paths[lang];
6727 if (!path) {
6728 return null;
6729 }
6730 const url = new URL(path, baseURL);
6731 const text = await (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__.fetchData)(url, "text");
6732 return createBundle(lang, text);
6733 }
6734 static async #getPaths() {
6735 try {
6736 const {
6737 href
6738 } = document.querySelector(`link[type="application/l10n"]`);
6739 const paths = await (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__.fetchData)(href, "json");
6740 return {
6741 baseURL: href.replace(/[^/]*$/, "") || "./",
6742 paths
6743 };
6744 } catch {}
6745 return {
6746 baseURL: "./",
6747 paths: Object.create(null)
6748 };
6749 }
6750 static async *#generateBundlesFallback(lang) {
6751 yield this.#createBundleFallback(lang);
6752 }
6753 static async #createBundleFallback(lang) {
6754 const text = "pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties\u2026\npdfjs-document-properties-button-label = Document Properties\u2026\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-kb = { $size_kb } KB ({ $size_b } bytes)\npdfjs-document-properties-mb = { $size_mb } MB ({ $size_b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-string = { $date }, { $time }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } \xD7 { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } \xD7 { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing\u2026\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document\u2026\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-string = { $date }, { $time }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text =\n .aria-label = Text Editor\npdfjs-free-text-default-content = Start typing\u2026\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can\u2019t see the image or when it doesn\u2019t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, \u201CA young man sits down at a table to eat a meal\u201D\npdfjs-editor-resizer-label-top-left = Top left corner \u2014 resize\npdfjs-editor-resizer-label-top-middle = Top middle \u2014 resize\npdfjs-editor-resizer-label-top-right = Top right corner \u2014 resize\npdfjs-editor-resizer-label-middle-right = Middle right \u2014 resize\npdfjs-editor-resizer-label-bottom-right = Bottom right corner \u2014 resize\npdfjs-editor-resizer-label-bottom-middle = Bottom middle \u2014 resize\npdfjs-editor-resizer-label-bottom-left = Bottom left corner \u2014 resize\npdfjs-editor-resizer-label-middle-left = Middle left \u2014 resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all";
6755 return createBundle(lang, text);
6756 }
6757}
6758
6759__webpack_async_result__();
6760} catch(e) { __webpack_async_result__(e); } });
6761
6762/***/ }),
6763
6764/***/ 2640:
6765/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6766
6767/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6768/* harmony export */ GrabToPan: () => (/* binding */ GrabToPan)
6769/* harmony export */ });
6770const CSS_CLASS_GRAB = "grab-to-pan-grab";
6771class GrabToPan {
6772 constructor({
6773 element
6774 }) {
6775 this.element = element;
6776 this.document = element.ownerDocument;
6777 this.activate = this.activate.bind(this);
6778 this.deactivate = this.deactivate.bind(this);
6779 this.toggle = this.toggle.bind(this);
6780 this._onMouseDown = this.#onMouseDown.bind(this);
6781 this._onMouseMove = this.#onMouseMove.bind(this);
6782 this._endPan = this.#endPan.bind(this);
6783 const overlay = this.overlay = document.createElement("div");
6784 overlay.className = "grab-to-pan-grabbing";
6785 }
6786 activate() {
6787 if (!this.active) {
6788 this.active = true;
6789 this.element.addEventListener("mousedown", this._onMouseDown);
6790 this.element.classList.add(CSS_CLASS_GRAB);
6791 }
6792 }
6793 deactivate() {
6794 if (this.active) {
6795 this.active = false;
6796 this.element.removeEventListener("mousedown", this._onMouseDown);
6797 this._endPan();
6798 this.element.classList.remove(CSS_CLASS_GRAB);
6799 }
6800 }
6801 toggle() {
6802 if (this.active) {
6803 this.deactivate();
6804 } else {
6805 this.activate();
6806 }
6807 }
6808 ignoreTarget(node) {
6809 if (document.querySelector(".stf__item")) {
6810 return true;
6811 }
6812 return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
6813 }
6814 #onMouseDown(event) {
6815 if (event.button !== 0 || this.ignoreTarget(event.target)) {
6816 return;
6817 }
6818 if (event.originalTarget) {
6819 try {
6820 event.originalTarget.tagName;
6821 } catch {
6822 return;
6823 }
6824 }
6825 this.scrollLeftStart = this.element.scrollLeft;
6826 this.scrollTopStart = this.element.scrollTop;
6827 this.clientXStart = event.clientX;
6828 this.clientYStart = event.clientY;
6829 if (isOverPerfectScrollbar(this.clientXStart, this.clientYStart, "ps__rail-x")) {
6830 return;
6831 }
6832 if (isOverPerfectScrollbar(this.clientXStart, this.clientYStart, "ps__rail-y")) {
6833 return;
6834 }
6835 this.document.addEventListener("mousemove", this._onMouseMove, true);
6836 this.document.addEventListener("mouseup", this._endPan, true);
6837 this.element.addEventListener("scroll", this._endPan, true);
6838 event.preventDefault();
6839 event.stopPropagation();
6840 const focusedElement = document.activeElement;
6841 if (focusedElement && !focusedElement.contains(event.target)) {
6842 focusedElement.blur();
6843 }
6844 }
6845 #onMouseMove(event) {
6846 this.element.removeEventListener("scroll", this._endPan, true);
6847 if (!(event.buttons & 1)) {
6848 this._endPan();
6849 return;
6850 }
6851 const xDiff = event.clientX - this.clientXStart;
6852 const yDiff = event.clientY - this.clientYStart;
6853 this.element.scrollTo({
6854 top: this.scrollTopStart - yDiff,
6855 left: this.scrollLeftStart - xDiff,
6856 behavior: "instant"
6857 });
6858 if (!this.overlay.parentNode) {
6859 document.body.append(this.overlay);
6860 }
6861 }
6862 #endPan() {
6863 this.element.removeEventListener("scroll", this._endPan, true);
6864 this.document.removeEventListener("mousemove", this._onMouseMove, true);
6865 this.document.removeEventListener("mouseup", this._endPan, true);
6866 this.overlay.remove();
6867 }
6868}
6869function isOverPerfectScrollbar(x, y, divName) {
6870 const perfectScrollbar = document.getElementsByClassName(divName);
6871 if (perfectScrollbar && perfectScrollbar.length === 1) {
6872 var {
6873 top,
6874 right,
6875 bottom,
6876 left
6877 } = perfectScrollbar[0].getBoundingClientRect();
6878 if (y >= top && y <= bottom) {
6879 if (x <= right && x >= left) {
6880 return true;
6881 }
6882 }
6883 }
6884 return false;
6885}
6886
6887
6888/***/ }),
6889
6890/***/ 4693:
6891/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6892
6893/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6894/* harmony export */ L10n: () => (/* binding */ L10n)
6895/* harmony export */ });
6896/* unused harmony export GenericL10n */
6897class L10n {
6898 #dir;
6899 #lang;
6900 #l10n;
6901 constructor({
6902 lang,
6903 isRTL
6904 }, l10n = null) {
6905 this.#lang = L10n.#fixupLangCode(lang);
6906 this.#l10n = l10n;
6907 this.#dir = isRTL ?? L10n.#isRTL(this.#lang) ? "rtl" : "ltr";
6908 }
6909 _setL10n(l10n) {
6910 this.#l10n = l10n;
6911 }
6912 getLanguage() {
6913 return this.#lang;
6914 }
6915 getDirection() {
6916 return this.#dir;
6917 }
6918 async get(ids, args = null, fallback) {
6919 if (Array.isArray(ids)) {
6920 ids = ids.map(id => ({
6921 id
6922 }));
6923 const messages = await this.#l10n.formatMessages(ids);
6924 return messages.map(message => message.value);
6925 }
6926 const messages = await this.#l10n.formatMessages([{
6927 id: ids,
6928 args
6929 }]);
6930 return messages?.[0].value || fallback;
6931 }
6932 async translate(element) {
6933 try {
6934 this.#l10n.connectRoot(element);
6935 await this.#l10n.translateRoots();
6936 } catch {}
6937 }
6938 pause() {
6939 this.#l10n.pauseObserving();
6940 }
6941 resume() {
6942 this.#l10n.resumeObserving();
6943 }
6944 static #fixupLangCode(langCode) {
6945 langCode = langCode?.toLowerCase() || "en-us";
6946 const PARTIAL_LANG_CODES = {
6947 en: "en-us",
6948 es: "es-es",
6949 fy: "fy-nl",
6950 ga: "ga-ie",
6951 gu: "gu-in",
6952 hi: "hi-in",
6953 hy: "hy-am",
6954 nb: "nb-no",
6955 ne: "ne-np",
6956 nn: "nn-no",
6957 pa: "pa-in",
6958 pt: "pt-pt",
6959 sv: "sv-se",
6960 zh: "zh-cn"
6961 };
6962 return PARTIAL_LANG_CODES[langCode] || langCode;
6963 }
6964 static #isRTL(lang) {
6965 const shortCode = lang.split("-", 1)[0];
6966 return ["ar", "he", "fa", "ps", "ur"].includes(shortCode);
6967 }
6968}
6969const GenericL10n = null;
6970
6971
6972/***/ }),
6973
6974/***/ 5756:
6975/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6976
6977/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6978/* harmony export */ ngxExtendedPdfViewerVersion: () => (/* binding */ ngxExtendedPdfViewerVersion)
6979/* harmony export */ });
6980const ngxExtendedPdfViewerVersion = '20.0.1';
6981
6982/***/ }),
6983
6984/***/ 6174:
6985/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6986
6987/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6988/* harmony export */ OverlayManager: () => (/* binding */ OverlayManager)
6989/* harmony export */ });
6990class OverlayManager {
6991 #overlays = new WeakMap();
6992 #active = null;
6993 get active() {
6994 return this.#active;
6995 }
6996 async register(dialog, canForceClose = false) {
6997 if (typeof dialog !== "object") {
6998 throw new Error("Not enough parameters.");
6999 } else if (this.#overlays.has(dialog)) {
7000 throw new Error("The overlay is already registered.");
7001 }
7002 this.#overlays.set(dialog, {
7003 canForceClose
7004 });
7005 dialog.addEventListener("cancel", evt => {
7006 this.#active = null;
7007 });
7008 }
7009 async open(dialog) {
7010 if (!this.#overlays.has(dialog)) {
7011 throw new Error("The overlay does not exist.");
7012 } else if (this.#active) {
7013 if (this.#active === dialog) {
7014 throw new Error("The overlay is already active.");
7015 } else if (this.#overlays.get(dialog).canForceClose) {
7016 await this.close();
7017 } else {
7018 throw new Error("Another overlay is currently active.");
7019 }
7020 }
7021 this.#active = dialog;
7022 dialog.showModal();
7023 dialog.classList.remove("hidden");
7024 }
7025 async close(dialog = this.#active) {
7026 if (!this.#overlays.has(dialog)) {
7027 throw new Error("The overlay does not exist.");
7028 } else if (!this.#active) {
7029 throw new Error("The overlay is currently not active.");
7030 } else if (this.#active !== dialog) {
7031 throw new Error("Another overlay is currently active.");
7032 }
7033 dialog.close();
7034 this.#active = null;
7035 }
7036}
7037
7038
7039/***/ }),
7040
7041/***/ 553:
7042/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7043
7044/* harmony export */ __webpack_require__.d(__webpack_exports__, {
7045/* harmony export */ PageFlip: () => (/* binding */ PageFlip)
7046/* harmony export */ });
7047class Page {
7048 constructor(render, density) {
7049 this.state = {
7050 angle: 0,
7051 area: [],
7052 position: {
7053 x: 0,
7054 y: 0
7055 },
7056 hardAngle: 0,
7057 hardDrawingAngle: 0
7058 };
7059 this.createdDensity = density;
7060 this.nowDrawingDensity = this.createdDensity;
7061 this.render = render;
7062 }
7063 setDensity(density) {
7064 this.createdDensity = density;
7065 this.nowDrawingDensity = density;
7066 }
7067 setDrawingDensity(density) {
7068 this.nowDrawingDensity = density;
7069 }
7070 setPosition(pagePos) {
7071 this.state.position = pagePos;
7072 }
7073 setAngle(angle) {
7074 this.state.angle = angle;
7075 }
7076 setArea(area) {
7077 this.state.area = area;
7078 }
7079 setHardDrawingAngle(angle) {
7080 this.state.hardDrawingAngle = angle;
7081 }
7082 setHardAngle(angle) {
7083 this.state.hardAngle = angle;
7084 this.state.hardDrawingAngle = angle;
7085 }
7086 setOrientation(orientation) {
7087 this.orientation = orientation;
7088 }
7089 getDrawingDensity() {
7090 return this.nowDrawingDensity;
7091 }
7092 getDensity() {
7093 return this.createdDensity;
7094 }
7095 getHardAngle() {
7096 return this.state.hardAngle;
7097 }
7098}
7099class ImagePage extends Page {
7100 constructor(render, href, density) {
7101 super(render, density);
7102 this.image = null;
7103 this.isLoad = false;
7104 this.loadingAngle = 0;
7105 this.image = new Image();
7106 this.image.src = href;
7107 }
7108 draw(tempDensity) {
7109 const options = window.pdfDefaultOptions.activateWillReadFrequentlyFlag ? {
7110 willReadFrequently: true
7111 } : undefined;
7112 const ctx = canvas.getContext("2d", options);
7113 const pagePos = this.render.convertToGlobal(this.state.position);
7114 const pageWidth = this.render.getRect().pageWidth;
7115 const pageHeight = this.render.getRect().height;
7116 ctx.save();
7117 ctx.translate(pagePos.x, pagePos.y);
7118 ctx.beginPath();
7119 for (let p of this.state.area) {
7120 if (p !== null) {
7121 p = this.render.convertToGlobal(p);
7122 ctx.lineTo(p.x - pagePos.x, p.y - pagePos.y);
7123 }
7124 }
7125 ctx.rotate(this.state.angle);
7126 ctx.clip();
7127 if (!this.isLoad) {
7128 this.drawLoader(ctx, {
7129 x: 0,
7130 y: 0
7131 }, pageWidth, pageHeight);
7132 } else {
7133 ctx.drawImage(this.image, 0, 0, pageWidth, pageHeight);
7134 }
7135 ctx.restore();
7136 }
7137 simpleDraw(orient) {
7138 const rect = this.render.getRect();
7139 const options = window.pdfDefaultOptions.activateWillReadFrequentlyFlag ? {
7140 willReadFrequently: true
7141 } : undefined;
7142 const ctx = canvas.getContext("2d", options);
7143 const pageWidth = rect.pageWidth;
7144 const pageHeight = rect.height;
7145 const x = orient === 1 ? rect.left + rect.pageWidth : rect.left;
7146 const y = rect.top;
7147 if (!this.isLoad) {
7148 this.drawLoader(ctx, {
7149 x,
7150 y
7151 }, pageWidth, pageHeight);
7152 } else {
7153 ctx.drawImage(this.image, x, y, pageWidth, pageHeight);
7154 }
7155 }
7156 drawLoader(ctx, shiftPos, pageWidth, pageHeight) {
7157 ctx.beginPath();
7158 ctx.strokeStyle = 'rgb(200, 200, 200)';
7159 ctx.fillStyle = 'rgb(255, 255, 255)';
7160 ctx.lineWidth = 1;
7161 ctx.rect(shiftPos.x + 1, shiftPos.y + 1, pageWidth - 1, pageHeight - 1);
7162 ctx.stroke();
7163 ctx.fill();
7164 const middlePoint = {
7165 x: shiftPos.x + pageWidth / 2,
7166 y: shiftPos.y + pageHeight / 2
7167 };
7168 ctx.beginPath();
7169 ctx.lineWidth = 10;
7170 ctx.arc(middlePoint.x, middlePoint.y, 20, this.loadingAngle, 3 * Math.PI / 2 + this.loadingAngle);
7171 ctx.stroke();
7172 ctx.closePath();
7173 this.loadingAngle += 0.07;
7174 if (this.loadingAngle >= 2 * Math.PI) {
7175 this.loadingAngle = 0;
7176 }
7177 }
7178 load() {
7179 if (!this.isLoad) this.image.onload = () => {
7180 this.isLoad = true;
7181 };
7182 }
7183 newTemporaryCopy() {
7184 return this;
7185 }
7186 getTemporaryCopy() {
7187 return this;
7188 }
7189 hideTemporaryCopy() {}
7190}
7191class PageCollection {
7192 constructor(app, render) {
7193 this.pages = [];
7194 this.currentPageIndex = 0;
7195 this.currentSpreadIndex = 0;
7196 this.landscapeSpread = [];
7197 this.portraitSpread = [];
7198 this.render = render;
7199 this.app = app;
7200 this.currentPageIndex = 0;
7201 this.isShowCover = this.app.getSettings().showCover;
7202 }
7203 destroy() {
7204 this.pages = [];
7205 }
7206 createSpread() {
7207 this.landscapeSpread = [];
7208 this.portraitSpread = [];
7209 for (let i = 0; i < this.pages.length; i++) {
7210 this.portraitSpread.push([i]);
7211 }
7212 let start = 0;
7213 if (this.isShowCover) {
7214 this.pages[0].setDensity("hard");
7215 this.landscapeSpread.push([start]);
7216 start++;
7217 }
7218 for (let i = start; i < this.pages.length; i += 2) {
7219 if (i < this.pages.length - 1) this.landscapeSpread.push([i, i + 1]);else {
7220 this.landscapeSpread.push([i]);
7221 this.pages[i].setDensity("hard");
7222 }
7223 }
7224 }
7225 getSpread() {
7226 return this.render.getOrientation() === "landscape" ? this.landscapeSpread : this.portraitSpread;
7227 }
7228 getSpreadIndexByPage(pageNum) {
7229 const spread = this.getSpread();
7230 for (let i = 0; i < spread.length; i++) if (pageNum === spread[i][0] || pageNum === spread[i][1]) return i;
7231 return null;
7232 }
7233 getPageCount() {
7234 return this.pages.length;
7235 }
7236 getPages() {
7237 return this.pages;
7238 }
7239 getPage(pageIndex) {
7240 if (pageIndex >= 0 && pageIndex < this.pages.length) {
7241 return this.pages[pageIndex];
7242 }
7243 throw new Error('Invalid page number');
7244 }
7245 nextBy(current) {
7246 const idx = this.pages.indexOf(current);
7247 if (idx < this.pages.length - 1) return this.pages[idx + 1];
7248 return null;
7249 }
7250 prevBy(current) {
7251 const idx = this.pages.indexOf(current);
7252 if (idx > 0) return this.pages[idx - 1];
7253 return null;
7254 }
7255 getFlippingPage(direction) {
7256 const current = this.currentSpreadIndex;
7257 if (this.render.getOrientation() === "portrait") {
7258 return direction === 0 ? this.pages[current].newTemporaryCopy() : this.pages[current - 1];
7259 } else {
7260 const spread = direction === 0 ? this.getSpread()[current + 1] : this.getSpread()[current - 1];
7261 if (spread.length === 1) return this.pages[spread[0]];
7262 return direction === 0 ? this.pages[spread[0]] : this.pages[spread[1]];
7263 }
7264 }
7265 getBottomPage(direction) {
7266 const current = this.currentSpreadIndex;
7267 if (this.render.getOrientation() === "portrait") {
7268 return direction === 0 ? this.pages[current + 1] : this.pages[current - 1];
7269 } else {
7270 const spread = direction === 0 ? this.getSpread()[current + 1] : this.getSpread()[current - 1];
7271 if (spread.length === 1) return this.pages[spread[0]];
7272 return direction === 0 ? this.pages[spread[1]] : this.pages[spread[0]];
7273 }
7274 }
7275 showNext() {
7276 if (this.currentSpreadIndex < this.getSpread().length) {
7277 this.currentSpreadIndex++;
7278 this.showSpread();
7279 }
7280 }
7281 showPrev() {
7282 if (this.currentSpreadIndex > 0) {
7283 this.currentSpreadIndex--;
7284 this.showSpread();
7285 }
7286 }
7287 getCurrentPageIndex() {
7288 return this.currentPageIndex;
7289 }
7290 show(pageNum = null) {
7291 if (pageNum === null) pageNum = this.currentPageIndex;
7292 if (pageNum < 0 || pageNum >= this.pages.length) return;
7293 const spreadIndex = this.getSpreadIndexByPage(pageNum);
7294 if (spreadIndex !== null) {
7295 this.currentSpreadIndex = spreadIndex;
7296 this.showSpread();
7297 }
7298 }
7299 getCurrentSpreadIndex() {
7300 return this.currentSpreadIndex;
7301 }
7302 setCurrentSpreadIndex(newIndex) {
7303 if (newIndex >= 0 && newIndex < this.getSpread().length) {
7304 this.currentSpreadIndex = newIndex;
7305 } else {
7306 throw new Error('Invalid page');
7307 }
7308 }
7309 showSpread() {
7310 const spread = this.getSpread()[this.currentSpreadIndex];
7311 if (spread.length === 2) {
7312 this.render.setLeftPage(this.pages[spread[0]]);
7313 this.render.setRightPage(this.pages[spread[1]]);
7314 } else {
7315 if (this.render.getOrientation() === "landscape") {
7316 if (spread[0] === this.pages.length - 1) {
7317 this.render.setLeftPage(this.pages[spread[0]]);
7318 this.render.setRightPage(null);
7319 } else {
7320 this.render.setLeftPage(null);
7321 this.render.setRightPage(this.pages[spread[0]]);
7322 }
7323 } else {
7324 this.render.setLeftPage(null);
7325 this.render.setRightPage(this.pages[spread[0]]);
7326 }
7327 }
7328 this.currentPageIndex = spread[0];
7329 this.app.updatePageIndex(this.currentPageIndex);
7330 }
7331}
7332class ImagePageCollection extends PageCollection {
7333 constructor(app, render, imagesHref) {
7334 super(app, render);
7335 this.imagesHref = imagesHref;
7336 }
7337 load() {
7338 for (const href of this.imagesHref) {
7339 const page = new ImagePage(this.render, href, "soft");
7340 page.load();
7341 this.pages.push(page);
7342 }
7343 this.createSpread();
7344 }
7345}
7346class Helper {
7347 static GetDistanceBetweenTwoPoint(point1, point2) {
7348 if (point1 === null || point2 === null) {
7349 return Infinity;
7350 }
7351 return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
7352 }
7353 static GetSegmentLength(segment) {
7354 return Helper.GetDistanceBetweenTwoPoint(segment[0], segment[1]);
7355 }
7356 static GetAngleBetweenTwoLine(line1, line2) {
7357 const A1 = line1[0].y - line1[1].y;
7358 const A2 = line2[0].y - line2[1].y;
7359 const B1 = line1[1].x - line1[0].x;
7360 const B2 = line2[1].x - line2[0].x;
7361 return Math.acos((A1 * A2 + B1 * B2) / (Math.sqrt(A1 * A1 + B1 * B1) * Math.sqrt(A2 * A2 + B2 * B2)));
7362 }
7363 static PointInRect(rect, pos) {
7364 if (pos === null) {
7365 return null;
7366 }
7367 if (pos.x >= rect.left && pos.x <= rect.width + rect.left && pos.y >= rect.top && pos.y <= rect.top + rect.height) {
7368 return pos;
7369 }
7370 return null;
7371 }
7372 static GetRotatedPoint(transformedPoint, startPoint, angle) {
7373 return {
7374 x: transformedPoint.x * Math.cos(angle) + transformedPoint.y * Math.sin(angle) + startPoint.x,
7375 y: transformedPoint.y * Math.cos(angle) - transformedPoint.x * Math.sin(angle) + startPoint.y
7376 };
7377 }
7378 static LimitPointToCircle(startPoint, radius, limitedPoint) {
7379 if (Helper.GetDistanceBetweenTwoPoint(startPoint, limitedPoint) <= radius) {
7380 return limitedPoint;
7381 }
7382 const a = startPoint.x;
7383 const b = startPoint.y;
7384 const n = limitedPoint.x;
7385 const m = limitedPoint.y;
7386 let x = Math.sqrt(Math.pow(radius, 2) * Math.pow(a - n, 2) / (Math.pow(a - n, 2) + Math.pow(b - m, 2))) + a;
7387 if (limitedPoint.x < 0) {
7388 x *= -1;
7389 }
7390 let y = (x - a) * (b - m) / (a - n) + b;
7391 if (a - n + b === 0) {
7392 y = radius;
7393 }
7394 return {
7395 x,
7396 y
7397 };
7398 }
7399 static GetIntersectBetweenTwoSegment(rectBorder, one, two) {
7400 return Helper.PointInRect(rectBorder, Helper.GetIntersectBeetwenTwoLine(one, two));
7401 }
7402 static GetIntersectBeetwenTwoLine(one, two) {
7403 const A1 = one[0].y - one[1].y;
7404 const A2 = two[0].y - two[1].y;
7405 const B1 = one[1].x - one[0].x;
7406 const B2 = two[1].x - two[0].x;
7407 const C1 = one[0].x * one[1].y - one[1].x * one[0].y;
7408 const C2 = two[0].x * two[1].y - two[1].x * two[0].y;
7409 const det1 = A1 * C2 - A2 * C1;
7410 const det2 = B1 * C2 - B2 * C1;
7411 const x = -((C1 * B2 - C2 * B1) / (A1 * B2 - A2 * B1));
7412 const y = -((A1 * C2 - A2 * C1) / (A1 * B2 - A2 * B1));
7413 if (isFinite(x) && isFinite(y)) {
7414 return {
7415 x,
7416 y
7417 };
7418 } else {
7419 if (Math.abs(det1 - det2) < 0.1) throw new Error('Segment included');
7420 }
7421 return null;
7422 }
7423 static GetCordsFromTwoPoint(pointOne, pointTwo) {
7424 const sizeX = Math.abs(pointOne.x - pointTwo.x);
7425 const sizeY = Math.abs(pointOne.y - pointTwo.y);
7426 const lengthLine = Math.max(sizeX, sizeY);
7427 const result = [pointOne];
7428 function getCord(c1, c2, size, length, index) {
7429 if (c2 > c1) {
7430 return c1 + index * (size / length);
7431 } else if (c2 < c1) {
7432 return c1 - index * (size / length);
7433 }
7434 return c1;
7435 }
7436 for (let i = 1; i <= lengthLine; i += 1) {
7437 result.push({
7438 x: getCord(pointOne.x, pointTwo.x, sizeX, lengthLine, i),
7439 y: getCord(pointOne.y, pointTwo.y, sizeY, lengthLine, i)
7440 });
7441 }
7442 return result;
7443 }
7444}
7445class HTMLPage extends Page {
7446 constructor(render, element, density) {
7447 super(render, density);
7448 this.copiedElement = null;
7449 this.temporaryCopy = null;
7450 this.isLoad = false;
7451 this.element = element;
7452 this.element.classList.add('stf__item');
7453 this.element.classList.add('--' + density);
7454 }
7455 newTemporaryCopy() {
7456 if (this.nowDrawingDensity === "hard") {
7457 return this;
7458 }
7459 if (this.temporaryCopy === null) {
7460 this.copiedElement = this.element.cloneNode(true);
7461 this.element.parentElement.appendChild(this.copiedElement);
7462 this.temporaryCopy = new HTMLPage(this.render, this.copiedElement, this.nowDrawingDensity);
7463 }
7464 return this.getTemporaryCopy();
7465 }
7466 getTemporaryCopy() {
7467 return this.temporaryCopy;
7468 }
7469 hideTemporaryCopy() {
7470 if (this.temporaryCopy !== null) {
7471 this.copiedElement.remove();
7472 this.copiedElement = null;
7473 this.temporaryCopy = null;
7474 }
7475 }
7476 draw(tempDensity) {
7477 const density = tempDensity ? tempDensity : this.nowDrawingDensity;
7478 const pagePos = this.render.convertToGlobal(this.state.position);
7479 const pageWidth = this.render.getRect().pageWidth;
7480 const pageHeight = this.render.getRect().height;
7481 this.element.classList.remove('--simple');
7482 const commonStyle = `
7483 position: absolute;
7484 display: block;
7485 z-index: ${this.element.style.zIndex};
7486 left: 0;
7487 top: 0;
7488 width: ${pageWidth}px;
7489 height: ${pageHeight}px;
7490 `;
7491 density === "hard" ? this.drawHard(commonStyle) : this.drawSoft(pagePos, commonStyle);
7492 }
7493 drawHard(commonStyle = '') {
7494 const pos = this.render.getRect().left + this.render.getRect().width / 2;
7495 const angle = this.state.hardDrawingAngle;
7496 const newStyle = commonStyle + `
7497 backface-visibility: hidden;
7498 -webkit-backface-visibility: hidden;
7499 clip-path: none;
7500 -webkit-clip-path: none;
7501 ` + (this.orientation === 0 ? `transform-origin: ${this.render.getRect().pageWidth}px 0;
7502 transform: translate3d(0, 0, 0) rotateY(${angle}deg);` : `transform-origin: 0 0;
7503 transform: translate3d(${pos}px, 0, 0) rotateY(${angle}deg);`);
7504 this.element.style.cssText = newStyle;
7505 }
7506 drawSoft(position, commonStyle = '') {
7507 let polygon = 'polygon( ';
7508 for (const p of this.state.area) {
7509 if (p !== null) {
7510 let g = this.render.getDirection() === 1 ? {
7511 x: -p.x + this.state.position.x,
7512 y: p.y - this.state.position.y
7513 } : {
7514 x: p.x - this.state.position.x,
7515 y: p.y - this.state.position.y
7516 };
7517 g = Helper.GetRotatedPoint(g, {
7518 x: 0,
7519 y: 0
7520 }, this.state.angle);
7521 polygon += g.x + 'px ' + g.y + 'px, ';
7522 }
7523 }
7524 polygon = polygon.slice(0, -2);
7525 polygon += ')';
7526 const newStyle = commonStyle + `transform-origin: 0 0; clip-path: ${polygon}; -webkit-clip-path: ${polygon};` + (this.render.isSafari() && this.state.angle === 0 ? `transform: translate(${position.x}px, ${position.y}px);` : `transform: translate3d(${position.x}px, ${position.y}px, 0) rotate(${this.state.angle}rad);`);
7527 this.element.style.cssText = newStyle;
7528 }
7529 simpleDraw(orient) {
7530 const rect = this.render.getRect();
7531 const pageWidth = rect.pageWidth;
7532 const pageHeight = rect.height;
7533 const x = orient === 1 ? rect.left + rect.pageWidth : rect.left;
7534 const y = rect.top;
7535 this.element.classList.add('--simple');
7536 this.element.style.cssText = `
7537 position: absolute;
7538 display: block;
7539 height: ${pageHeight}px;
7540 left: ${x}px;
7541 top: ${y}px;
7542 width: ${pageWidth}px;
7543 z-index: ${this.render.getSettings().startZIndex + 1};`;
7544 }
7545 getElement() {
7546 return this.element;
7547 }
7548 load() {
7549 this.isLoad = true;
7550 }
7551 setOrientation(orientation) {
7552 super.setOrientation(orientation);
7553 this.element.classList.remove('--left', '--right');
7554 this.element.classList.add(orientation === 1 ? '--right' : '--left');
7555 }
7556 setDrawingDensity(density) {
7557 this.element.classList.remove('--soft', '--hard');
7558 this.element.classList.add('--' + density);
7559 super.setDrawingDensity(density);
7560 }
7561}
7562class HTMLPageCollection extends PageCollection {
7563 constructor(app, render, element, items) {
7564 super(app, render);
7565 this.element = element;
7566 this.pagesElement = items;
7567 }
7568 load() {
7569 for (const pageElement of this.pagesElement) {
7570 const page = new HTMLPage(this.render, pageElement, pageElement.dataset['density'] === 'hard' ? "hard" : "soft");
7571 page.load();
7572 this.pages.push(page);
7573 }
7574 this.createSpread();
7575 }
7576}
7577class FlipCalculation {
7578 constructor(direction, corner, pageWidth, pageHeight) {
7579 this.direction = direction;
7580 this.corner = corner;
7581 this.topIntersectPoint = null;
7582 this.sideIntersectPoint = null;
7583 this.bottomIntersectPoint = null;
7584 this.pageWidth = parseInt(pageWidth, 10);
7585 this.pageHeight = parseInt(pageHeight, 10);
7586 }
7587 calc(localPos) {
7588 try {
7589 this.position = this.calcAngleAndPosition(localPos);
7590 this.calculateIntersectPoint(this.position);
7591 return true;
7592 } catch (e) {
7593 return false;
7594 }
7595 }
7596 getFlippingClipArea() {
7597 const result = [];
7598 let clipBottom = false;
7599 result.push(this.rect.topLeft);
7600 result.push(this.topIntersectPoint);
7601 if (this.sideIntersectPoint === null) {
7602 clipBottom = true;
7603 } else {
7604 result.push(this.sideIntersectPoint);
7605 if (this.bottomIntersectPoint === null) clipBottom = false;
7606 }
7607 result.push(this.bottomIntersectPoint);
7608 if (clipBottom || this.corner === "bottom") {
7609 result.push(this.rect.bottomLeft);
7610 }
7611 return result;
7612 }
7613 getBottomClipArea() {
7614 const result = [];
7615 result.push(this.topIntersectPoint);
7616 if (this.corner === "top") {
7617 result.push({
7618 x: this.pageWidth,
7619 y: 0
7620 });
7621 } else {
7622 if (this.topIntersectPoint !== null) {
7623 result.push({
7624 x: this.pageWidth,
7625 y: 0
7626 });
7627 }
7628 result.push({
7629 x: this.pageWidth,
7630 y: this.pageHeight
7631 });
7632 }
7633 if (this.sideIntersectPoint !== null) {
7634 if (Helper.GetDistanceBetweenTwoPoint(this.sideIntersectPoint, this.topIntersectPoint) >= 10) result.push(this.sideIntersectPoint);
7635 } else {
7636 if (this.corner === "top") {
7637 result.push({
7638 x: this.pageWidth,
7639 y: this.pageHeight
7640 });
7641 }
7642 }
7643 result.push(this.bottomIntersectPoint);
7644 result.push(this.topIntersectPoint);
7645 return result;
7646 }
7647 getAngle() {
7648 if (this.direction === 0) {
7649 return -this.angle;
7650 }
7651 return this.angle;
7652 }
7653 getRect() {
7654 return this.rect;
7655 }
7656 getPosition() {
7657 return this.position;
7658 }
7659 getActiveCorner() {
7660 if (this.direction === 0) {
7661 return this.rect.topLeft;
7662 }
7663 return this.rect.topRight;
7664 }
7665 getDirection() {
7666 return this.direction;
7667 }
7668 getFlippingProgress() {
7669 return Math.abs((this.position.x - this.pageWidth) / (2 * this.pageWidth) * 100);
7670 }
7671 getCorner() {
7672 return this.corner;
7673 }
7674 getBottomPagePosition() {
7675 if (this.direction === 1) {
7676 return {
7677 x: this.pageWidth,
7678 y: 0
7679 };
7680 }
7681 return {
7682 x: 0,
7683 y: 0
7684 };
7685 }
7686 getShadowStartPoint() {
7687 if (this.corner === "top") {
7688 return this.topIntersectPoint;
7689 } else {
7690 if (this.sideIntersectPoint !== null) return this.sideIntersectPoint;
7691 return this.topIntersectPoint;
7692 }
7693 }
7694 getShadowAngle() {
7695 const angle = Helper.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(), [{
7696 x: 0,
7697 y: 0
7698 }, {
7699 x: this.pageWidth,
7700 y: 0
7701 }]);
7702 if (this.direction === 0) {
7703 return angle;
7704 }
7705 return Math.PI - angle;
7706 }
7707 calcAngleAndPosition(pos) {
7708 let result = pos;
7709 this.updateAngleAndGeometry(result);
7710 if (this.corner === "top") {
7711 result = this.checkPositionAtCenterLine(result, {
7712 x: 0,
7713 y: 0
7714 }, {
7715 x: 0,
7716 y: this.pageHeight
7717 });
7718 } else {
7719 result = this.checkPositionAtCenterLine(result, {
7720 x: 0,
7721 y: this.pageHeight
7722 }, {
7723 x: 0,
7724 y: 0
7725 });
7726 }
7727 if (Math.abs(result.x - this.pageWidth) < 1 && Math.abs(result.y) < 1) {
7728 throw new Error('Point is too small');
7729 }
7730 return result;
7731 }
7732 updateAngleAndGeometry(pos) {
7733 this.angle = this.calculateAngle(pos);
7734 this.rect = this.getPageRect(pos);
7735 }
7736 calculateAngle(pos) {
7737 const left = this.pageWidth - pos.x + 1;
7738 const top = this.corner === "bottom" ? this.pageHeight - pos.y : pos.y;
7739 let angle = 2 * Math.acos(left / Math.sqrt(top * top + left * left));
7740 if (top < 0) angle = -angle;
7741 const da = Math.PI - angle;
7742 if (!isFinite(angle) || da >= 0 && da < 0.003) throw new Error('The G point is too small');
7743 if (this.corner === "bottom") angle = -angle;
7744 return angle;
7745 }
7746 getPageRect(localPos) {
7747 if (this.corner === "top") {
7748 return this.getRectFromBasePoint([{
7749 x: 0,
7750 y: 0
7751 }, {
7752 x: this.pageWidth,
7753 y: 0
7754 }, {
7755 x: 0,
7756 y: this.pageHeight
7757 }, {
7758 x: this.pageWidth,
7759 y: this.pageHeight
7760 }], localPos);
7761 }
7762 return this.getRectFromBasePoint([{
7763 x: 0,
7764 y: -this.pageHeight
7765 }, {
7766 x: this.pageWidth,
7767 y: -this.pageHeight
7768 }, {
7769 x: 0,
7770 y: 0
7771 }, {
7772 x: this.pageWidth,
7773 y: 0
7774 }], localPos);
7775 }
7776 getRectFromBasePoint(points, localPos) {
7777 return {
7778 topLeft: this.getRotatedPoint(points[0], localPos),
7779 topRight: this.getRotatedPoint(points[1], localPos),
7780 bottomLeft: this.getRotatedPoint(points[2], localPos),
7781 bottomRight: this.getRotatedPoint(points[3], localPos)
7782 };
7783 }
7784 getRotatedPoint(transformedPoint, startPoint) {
7785 return {
7786 x: transformedPoint.x * Math.cos(this.angle) + transformedPoint.y * Math.sin(this.angle) + startPoint.x,
7787 y: transformedPoint.y * Math.cos(this.angle) - transformedPoint.x * Math.sin(this.angle) + startPoint.y
7788 };
7789 }
7790 calculateIntersectPoint(pos) {
7791 const boundRect = {
7792 left: -1,
7793 top: -1,
7794 width: this.pageWidth + 2,
7795 height: this.pageHeight + 2
7796 };
7797 if (this.corner === "top") {
7798 this.topIntersectPoint = Helper.GetIntersectBetweenTwoSegment(boundRect, [pos, this.rect.topRight], [{
7799 x: 0,
7800 y: 0
7801 }, {
7802 x: this.pageWidth,
7803 y: 0
7804 }]);
7805 this.sideIntersectPoint = Helper.GetIntersectBetweenTwoSegment(boundRect, [pos, this.rect.bottomLeft], [{
7806 x: this.pageWidth,
7807 y: 0
7808 }, {
7809 x: this.pageWidth,
7810 y: this.pageHeight
7811 }]);
7812 this.bottomIntersectPoint = Helper.GetIntersectBetweenTwoSegment(boundRect, [this.rect.bottomLeft, this.rect.bottomRight], [{
7813 x: 0,
7814 y: this.pageHeight
7815 }, {
7816 x: this.pageWidth,
7817 y: this.pageHeight
7818 }]);
7819 } else {
7820 this.topIntersectPoint = Helper.GetIntersectBetweenTwoSegment(boundRect, [this.rect.topLeft, this.rect.topRight], [{
7821 x: 0,
7822 y: 0
7823 }, {
7824 x: this.pageWidth,
7825 y: 0
7826 }]);
7827 this.sideIntersectPoint = Helper.GetIntersectBetweenTwoSegment(boundRect, [pos, this.rect.topLeft], [{
7828 x: this.pageWidth,
7829 y: 0
7830 }, {
7831 x: this.pageWidth,
7832 y: this.pageHeight
7833 }]);
7834 this.bottomIntersectPoint = Helper.GetIntersectBetweenTwoSegment(boundRect, [this.rect.bottomLeft, this.rect.bottomRight], [{
7835 x: 0,
7836 y: this.pageHeight
7837 }, {
7838 x: this.pageWidth,
7839 y: this.pageHeight
7840 }]);
7841 }
7842 }
7843 checkPositionAtCenterLine(checkedPos, centerOne, centerTwo) {
7844 let result = checkedPos;
7845 const tmp = Helper.LimitPointToCircle(centerOne, this.pageWidth, result);
7846 if (result !== tmp) {
7847 result = tmp;
7848 this.updateAngleAndGeometry(result);
7849 }
7850 const rad = Math.sqrt(Math.pow(this.pageWidth, 2) + Math.pow(this.pageHeight, 2));
7851 let checkPointOne = this.rect.bottomRight;
7852 let checkPointTwo = this.rect.topLeft;
7853 if (this.corner === "bottom") {
7854 checkPointOne = this.rect.topRight;
7855 checkPointTwo = this.rect.bottomLeft;
7856 }
7857 if (checkPointOne.x <= 0) {
7858 const bottomPoint = Helper.LimitPointToCircle(centerTwo, rad, checkPointTwo);
7859 if (bottomPoint !== result) {
7860 result = bottomPoint;
7861 this.updateAngleAndGeometry(result);
7862 }
7863 }
7864 return result;
7865 }
7866 getSegmentToShadowLine() {
7867 const first = this.getShadowStartPoint();
7868 const second = first !== this.sideIntersectPoint && this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.bottomIntersectPoint;
7869 return [first, second];
7870 }
7871}
7872class Flip {
7873 constructor(render, app) {
7874 this.flippingPage = null;
7875 this.bottomPage = null;
7876 this.calc = null;
7877 this.state = "read";
7878 this.render = render;
7879 this.app = app;
7880 }
7881 fold(globalPos) {
7882 this.setState("user_fold");
7883 if (this.calc === null) this.start(globalPos);
7884 this.do(this.render.convertToPage(globalPos));
7885 }
7886 flip(globalPos) {
7887 if (this.app.getSettings().disableFlipByClick && !this.isPointOnCorners(globalPos)) return;
7888 if (this.calc !== null) this.render.finishAnimation();
7889 if (!this.start(globalPos)) return;
7890 const rect = this.getBoundsRect();
7891 this.setState("flipping");
7892 const topMargins = rect.height / 10;
7893 const yStart = this.calc.getCorner() === "bottom" ? rect.height - topMargins : topMargins;
7894 const yDest = this.calc.getCorner() === "bottom" ? rect.height : 0;
7895 this.calc.calc({
7896 x: rect.pageWidth - topMargins,
7897 y: yStart
7898 });
7899 this.animateFlippingTo({
7900 x: rect.pageWidth - topMargins,
7901 y: yStart
7902 }, {
7903 x: -rect.pageWidth,
7904 y: yDest
7905 }, true);
7906 }
7907 start(globalPos) {
7908 this.reset();
7909 const bookPos = this.render.convertToBook(globalPos);
7910 const rect = this.getBoundsRect();
7911 const direction = this.getDirectionByPoint(bookPos);
7912 const flipCorner = bookPos.y >= rect.height / 2 ? "bottom" : "top";
7913 if (!this.checkDirection(direction)) return false;
7914 try {
7915 this.flippingPage = this.app.getPageCollection().getFlippingPage(direction);
7916 this.bottomPage = this.app.getPageCollection().getBottomPage(direction);
7917 if (this.render.getOrientation() === "landscape") {
7918 if (direction === 1) {
7919 const nextPage = this.app.getPageCollection().nextBy(this.flippingPage);
7920 if (nextPage !== null) {
7921 if (this.flippingPage.getDensity() !== nextPage.getDensity()) {
7922 this.flippingPage.setDrawingDensity("hard");
7923 nextPage.setDrawingDensity("hard");
7924 }
7925 }
7926 } else {
7927 const prevPage = this.app.getPageCollection().prevBy(this.flippingPage);
7928 if (prevPage !== null) {
7929 if (this.flippingPage.getDensity() !== prevPage.getDensity()) {
7930 this.flippingPage.setDrawingDensity("hard");
7931 prevPage.setDrawingDensity("hard");
7932 }
7933 }
7934 }
7935 }
7936 this.render.setDirection(direction);
7937 this.calc = new FlipCalculation(direction, flipCorner, rect.pageWidth.toString(10), rect.height.toString(10));
7938 return true;
7939 } catch (e) {
7940 return false;
7941 }
7942 }
7943 do(pagePos) {
7944 if (this.calc === null) return;
7945 if (this.calc.calc(pagePos)) {
7946 const progress = this.calc.getFlippingProgress();
7947 this.bottomPage.setArea(this.calc.getBottomClipArea());
7948 this.bottomPage.setPosition(this.calc.getBottomPagePosition());
7949 this.bottomPage.setAngle(0);
7950 this.bottomPage.setHardAngle(0);
7951 this.flippingPage.setArea(this.calc.getFlippingClipArea());
7952 this.flippingPage.setPosition(this.calc.getActiveCorner());
7953 this.flippingPage.setAngle(this.calc.getAngle());
7954 if (this.calc.getDirection() === 0) {
7955 this.flippingPage.setHardAngle(90 * (200 - progress * 2) / 100);
7956 } else {
7957 this.flippingPage.setHardAngle(-90 * (200 - progress * 2) / 100);
7958 }
7959 this.render.setPageRect(this.calc.getRect());
7960 this.render.setBottomPage(this.bottomPage);
7961 this.render.setFlippingPage(this.flippingPage);
7962 this.render.setShadowData(this.calc.getShadowStartPoint(), this.calc.getShadowAngle(), progress, this.calc.getDirection());
7963 }
7964 }
7965 flipToPage(page, corner) {
7966 const current = this.app.getPageCollection().getCurrentSpreadIndex();
7967 const next = this.app.getPageCollection().getSpreadIndexByPage(page);
7968 try {
7969 if (next > current) {
7970 this.app.getPageCollection().setCurrentSpreadIndex(next - 1);
7971 this.flipNext(corner);
7972 }
7973 if (next < current) {
7974 this.app.getPageCollection().setCurrentSpreadIndex(next + 1);
7975 this.flipPrev(corner);
7976 }
7977 } catch (e) {}
7978 }
7979 flipNext(corner) {
7980 this.flip({
7981 x: this.render.getRect().left + this.render.getRect().pageWidth * 2 - 10,
7982 y: corner === "top" ? 1 : this.render.getRect().height - 2
7983 });
7984 }
7985 flipPrev(corner) {
7986 this.flip({
7987 x: 10,
7988 y: corner === "top" ? 1 : this.render.getRect().height - 2
7989 });
7990 }
7991 stopMove() {
7992 if (this.calc === null) return;
7993 const pos = this.calc.getPosition();
7994 const rect = this.getBoundsRect();
7995 const y = this.calc.getCorner() === "bottom" ? rect.height : 0;
7996 if (pos.x <= 0) this.animateFlippingTo(pos, {
7997 x: -rect.pageWidth,
7998 y
7999 }, true);else this.animateFlippingTo(pos, {
8000 x: rect.pageWidth,
8001 y
8002 }, false);
8003 }
8004 showCorner(globalPos) {
8005 if (!this.checkState("read", "fold_corner")) return;
8006 const rect = this.getBoundsRect();
8007 const pageWidth = rect.pageWidth;
8008 if (this.isPointOnCorners(globalPos)) {
8009 if (this.calc === null) {
8010 if (!this.start(globalPos)) return;
8011 this.setState("fold_corner");
8012 this.calc.calc({
8013 x: pageWidth - 1,
8014 y: 1
8015 });
8016 const fixedCornerSize = 50;
8017 const yStart = this.calc.getCorner() === "bottom" ? rect.height - 1 : 1;
8018 const yDest = this.calc.getCorner() === "bottom" ? rect.height - fixedCornerSize : fixedCornerSize;
8019 this.animateFlippingTo({
8020 x: pageWidth - 1,
8021 y: yStart
8022 }, {
8023 x: pageWidth - fixedCornerSize,
8024 y: yDest
8025 }, false, false);
8026 } else {
8027 this.do(this.render.convertToPage(globalPos));
8028 }
8029 } else {
8030 this.setState("read");
8031 this.render.finishAnimation();
8032 this.stopMove();
8033 }
8034 }
8035 animateFlippingTo(start, dest, isTurned, needReset = true) {
8036 const points = Helper.GetCordsFromTwoPoint(start, dest);
8037 const frames = [];
8038 for (const p of points) frames.push(() => this.do(p));
8039 const duration = this.getAnimationDuration(points.length);
8040 this.render.startAnimation(frames, duration, () => {
8041 if (!this.calc) return;
8042 if (isTurned) {
8043 if (this.calc.getDirection() === 1) this.app.turnToPrevPage();else this.app.turnToNextPage();
8044 }
8045 if (needReset) {
8046 this.render.setBottomPage(null);
8047 this.render.setFlippingPage(null);
8048 this.render.clearShadow();
8049 this.setState("read");
8050 this.reset();
8051 }
8052 });
8053 }
8054 getCalculation() {
8055 return this.calc;
8056 }
8057 getState() {
8058 return this.state;
8059 }
8060 setState(newState) {
8061 if (this.state !== newState) {
8062 this.app.updateState(newState);
8063 this.state = newState;
8064 }
8065 }
8066 getDirectionByPoint(touchPos) {
8067 const rect = this.getBoundsRect();
8068 if (this.render.getOrientation() === "portrait") {
8069 if (touchPos.x - rect.pageWidth <= rect.width / 5) {
8070 return 1;
8071 }
8072 } else if (touchPos.x < rect.width / 2) {
8073 return 1;
8074 }
8075 return 0;
8076 }
8077 getAnimationDuration(size) {
8078 const defaultTime = this.app.getSettings().flippingTime;
8079 if (size >= 1000) return defaultTime;
8080 return size / 1000 * defaultTime;
8081 }
8082 checkDirection(direction) {
8083 if (direction === 0) return this.app.getCurrentPageIndex() < this.app.getPageCount() - 1;
8084 return this.app.getCurrentPageIndex() >= 1;
8085 }
8086 reset() {
8087 this.calc = null;
8088 this.flippingPage = null;
8089 this.bottomPage = null;
8090 }
8091 getBoundsRect() {
8092 return this.render.getRect();
8093 }
8094 checkState(...states) {
8095 for (const state of states) {
8096 if (this.state === state) return true;
8097 }
8098 return false;
8099 }
8100 isPointOnCorners(globalPos) {
8101 const rect = this.getBoundsRect();
8102 const pageWidth = rect.pageWidth;
8103 const operatingDistance = Math.sqrt(Math.pow(pageWidth, 2) + Math.pow(rect.height, 2)) / 5;
8104 const bookPos = this.render.convertToBook(globalPos);
8105 return bookPos.x > 0 && bookPos.y > 0 && bookPos.x < rect.width && bookPos.y < rect.height && (bookPos.x < operatingDistance || bookPos.x > rect.width - operatingDistance) && (bookPos.y < operatingDistance || bookPos.y > rect.height - operatingDistance);
8106 }
8107}
8108class Render {
8109 constructor(app, setting) {
8110 this.leftPage = null;
8111 this.rightPage = null;
8112 this.flippingPage = null;
8113 this.bottomPage = null;
8114 this.direction = null;
8115 this.orientation = null;
8116 this.shadow = null;
8117 this.animation = null;
8118 this.pageRect = null;
8119 this.boundsRect = null;
8120 this.timer = 0;
8121 this.safari = false;
8122 this.setting = setting;
8123 this.app = app;
8124 const regex = new RegExp('Version\\/[\\d\\.]+.*Safari/');
8125 this.safari = regex.exec(window.navigator.userAgent) !== null;
8126 }
8127 render(timer) {
8128 if (this.animation !== null) {
8129 const frameIndex = Math.round((timer - this.animation.startedAt) / this.animation.durationFrame);
8130 if (frameIndex < this.animation.frames.length) {
8131 this.animation.frames[frameIndex]();
8132 } else {
8133 this.animation.onAnimateEnd();
8134 this.animation = null;
8135 }
8136 }
8137 this.timer = timer;
8138 this.drawFrame();
8139 }
8140 start() {
8141 this.update();
8142 const loop = timer => {
8143 window.ngxZone.runOutsideAngular(() => {
8144 this.render(timer);
8145 requestAnimationFrame(loop);
8146 });
8147 };
8148 window.ngxZone.runOutsideAngular(() => {
8149 requestAnimationFrame(loop);
8150 });
8151 }
8152 startAnimation(frames, duration, onAnimateEnd) {
8153 this.finishAnimation();
8154 this.animation = {
8155 frames,
8156 duration,
8157 durationFrame: duration / frames.length,
8158 onAnimateEnd,
8159 startedAt: this.timer
8160 };
8161 }
8162 finishAnimation() {
8163 if (this.animation !== null) {
8164 this.animation.frames[this.animation.frames.length - 1]();
8165 if (this.animation.onAnimateEnd !== null) {
8166 this.animation.onAnimateEnd();
8167 }
8168 }
8169 this.animation = null;
8170 }
8171 update() {
8172 this.boundsRect = null;
8173 const orientation = this.calculateBoundsRect();
8174 if (this.orientation !== orientation) {
8175 this.orientation = orientation;
8176 this.app.updateOrientation(orientation);
8177 }
8178 }
8179 calculateBoundsRect() {
8180 let orientation = "landscape";
8181 const blockWidth = this.getBlockWidth();
8182 const middlePoint = {
8183 x: blockWidth / 2,
8184 y: this.getBlockHeight() / 2
8185 };
8186 const ratio = this.setting.width / this.setting.height;
8187 let pageWidth = this.setting.width;
8188 let pageHeight = this.setting.height;
8189 let left = middlePoint.x - pageWidth;
8190 if (this.setting.size === "stretch") {
8191 if (blockWidth < this.setting.minWidth * 2 && this.app.getSettings().usePortrait) orientation = "portrait";
8192 pageWidth = orientation === "portrait" ? this.getBlockWidth() : this.getBlockWidth() / 2;
8193 if (pageWidth > this.setting.maxWidth) pageWidth = this.setting.maxWidth;
8194 pageHeight = pageWidth / ratio;
8195 if (pageHeight > this.getBlockHeight()) {
8196 pageHeight = this.getBlockHeight();
8197 pageWidth = pageHeight * ratio;
8198 }
8199 left = orientation === "portrait" ? middlePoint.x - pageWidth / 2 - pageWidth : middlePoint.x - pageWidth;
8200 } else {
8201 if (blockWidth < pageWidth * 2) {
8202 if (this.app.getSettings().usePortrait) {
8203 orientation = "portrait";
8204 left = middlePoint.x - pageWidth / 2 - pageWidth;
8205 }
8206 }
8207 }
8208 this.boundsRect = {
8209 left,
8210 top: middlePoint.y - pageHeight / 2,
8211 width: pageWidth * 2,
8212 height: pageHeight,
8213 pageWidth: pageWidth
8214 };
8215 return orientation;
8216 }
8217 setShadowData(pos, angle, progress, direction) {
8218 if (!this.app.getSettings().drawShadow) return;
8219 const maxShadowOpacity = 100 * this.getSettings().maxShadowOpacity;
8220 this.shadow = {
8221 pos,
8222 angle,
8223 width: this.getRect().pageWidth * 3 / 4 * progress / 100,
8224 opacity: (100 - progress) * maxShadowOpacity / 100 / 100,
8225 direction,
8226 progress: progress * 2
8227 };
8228 }
8229 clearShadow() {
8230 this.shadow = null;
8231 }
8232 getBlockWidth() {
8233 return this.app.getUI().getDistElement().offsetWidth;
8234 }
8235 getBlockHeight() {
8236 return this.app.getUI().getDistElement().offsetHeight;
8237 }
8238 getDirection() {
8239 return this.direction;
8240 }
8241 getRect() {
8242 if (this.boundsRect === null) this.calculateBoundsRect();
8243 return this.boundsRect;
8244 }
8245 getSettings() {
8246 return this.app.getSettings();
8247 }
8248 getOrientation() {
8249 return this.orientation;
8250 }
8251 setPageRect(pageRect) {
8252 this.pageRect = pageRect;
8253 }
8254 setDirection(direction) {
8255 this.direction = direction;
8256 }
8257 setRightPage(page) {
8258 if (page !== null) page.setOrientation(1);
8259 this.rightPage = page;
8260 }
8261 setLeftPage(page) {
8262 if (page !== null) page.setOrientation(0);
8263 this.leftPage = page;
8264 }
8265 setBottomPage(page) {
8266 if (page !== null) page.setOrientation(this.direction === 1 ? 0 : 1);
8267 this.bottomPage = page;
8268 }
8269 setFlippingPage(page) {
8270 if (page !== null) page.setOrientation(this.direction === 0 && this.orientation !== "portrait" ? 0 : 1);
8271 this.flippingPage = page;
8272 }
8273 convertToBook(pos) {
8274 const rect = this.getRect();
8275 return {
8276 x: pos.x - rect.left,
8277 y: pos.y - rect.top
8278 };
8279 }
8280 isSafari() {
8281 return this.safari;
8282 }
8283 convertToPage(pos, direction) {
8284 if (!direction) direction = this.direction;
8285 const rect = this.getRect();
8286 const x = direction === 0 ? pos.x - rect.left - rect.width / 2 : rect.width / 2 - pos.x + rect.left;
8287 return {
8288 x,
8289 y: pos.y - rect.top
8290 };
8291 }
8292 convertToGlobal(pos, direction) {
8293 if (!direction) direction = this.direction;
8294 if (pos == null) return null;
8295 const rect = this.getRect();
8296 const x = direction === 0 ? pos.x + rect.left + rect.width / 2 : rect.width / 2 - pos.x + rect.left;
8297 return {
8298 x,
8299 y: pos.y + rect.top
8300 };
8301 }
8302 convertRectToGlobal(rect, direction) {
8303 if (!direction) direction = this.direction;
8304 return {
8305 topLeft: this.convertToGlobal(rect.topLeft, direction),
8306 topRight: this.convertToGlobal(rect.topRight, direction),
8307 bottomLeft: this.convertToGlobal(rect.bottomLeft, direction),
8308 bottomRight: this.convertToGlobal(rect.bottomRight, direction)
8309 };
8310 }
8311}
8312class CanvasRender extends Render {
8313 constructor(app, setting, inCanvas) {
8314 super(app, setting);
8315 this.canvas = inCanvas;
8316 const options = window.pdfDefaultOptions.activateWillReadFrequentlyFlag ? {
8317 willReadFrequently: true
8318 } : undefined;
8319 const ctx = canvas.getContext("2d", options);
8320 }
8321 getContext() {
8322 return this.ctx;
8323 }
8324 reload() {}
8325 drawFrame() {
8326 this.clear();
8327 if (this.orientation !== "portrait") if (this.leftPage != null) this.leftPage.simpleDraw(0);
8328 if (this.rightPage != null) this.rightPage.simpleDraw(1);
8329 if (this.bottomPage != null) this.bottomPage.draw();
8330 this.drawBookShadow();
8331 if (this.flippingPage != null) this.flippingPage.draw();
8332 if (this.shadow != null) {
8333 this.drawOuterShadow();
8334 this.drawInnerShadow();
8335 }
8336 const rect = this.getRect();
8337 if (this.orientation === "portrait") {
8338 this.ctx.beginPath();
8339 this.ctx.rect(rect.left + rect.pageWidth, rect.top, rect.width, rect.height);
8340 this.ctx.clip();
8341 }
8342 }
8343 drawBookShadow() {
8344 const rect = this.getRect();
8345 this.ctx.save();
8346 this.ctx.beginPath();
8347 const shadowSize = rect.width / 20;
8348 this.ctx.rect(rect.left, rect.top, rect.width, rect.height);
8349 const shadowPos = {
8350 x: rect.left + rect.width / 2 - shadowSize / 2,
8351 y: 0
8352 };
8353 this.ctx.translate(shadowPos.x, shadowPos.y);
8354 const outerGradient = this.ctx.createLinearGradient(0, 0, shadowSize, 0);
8355 outerGradient.addColorStop(0, 'rgba(0, 0, 0, 0)');
8356 outerGradient.addColorStop(0.4, 'rgba(0, 0, 0, 0.2)');
8357 outerGradient.addColorStop(0.49, 'rgba(0, 0, 0, 0.1)');
8358 outerGradient.addColorStop(0.5, 'rgba(0, 0, 0, 0.5)');
8359 outerGradient.addColorStop(0.51, 'rgba(0, 0, 0, 0.4)');
8360 outerGradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
8361 this.ctx.clip();
8362 this.ctx.fillStyle = outerGradient;
8363 this.ctx.fillRect(0, 0, shadowSize, rect.height * 2);
8364 this.ctx.restore();
8365 }
8366 drawOuterShadow() {
8367 const rect = this.getRect();
8368 this.ctx.save();
8369 this.ctx.beginPath();
8370 this.ctx.rect(rect.left, rect.top, rect.width, rect.height);
8371 const shadowPos = this.convertToGlobal({
8372 x: this.shadow.pos.x,
8373 y: this.shadow.pos.y
8374 });
8375 this.ctx.translate(shadowPos.x, shadowPos.y);
8376 this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
8377 const outerGradient = this.ctx.createLinearGradient(0, 0, this.shadow.width, 0);
8378 if (this.shadow.direction === 0) {
8379 this.ctx.translate(0, -100);
8380 outerGradient.addColorStop(0, 'rgba(0, 0, 0, ' + this.shadow.opacity + ')');
8381 outerGradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
8382 } else {
8383 this.ctx.translate(-this.shadow.width, -100);
8384 outerGradient.addColorStop(0, 'rgba(0, 0, 0, 0)');
8385 outerGradient.addColorStop(1, 'rgba(0, 0, 0, ' + this.shadow.opacity + ')');
8386 }
8387 this.ctx.clip();
8388 this.ctx.fillStyle = outerGradient;
8389 this.ctx.fillRect(0, 0, this.shadow.width, rect.height * 2);
8390 this.ctx.restore();
8391 }
8392 drawInnerShadow() {
8393 const rect = this.getRect();
8394 this.ctx.save();
8395 this.ctx.beginPath();
8396 const shadowPos = this.convertToGlobal({
8397 x: this.shadow.pos.x,
8398 y: this.shadow.pos.y
8399 });
8400 const pageRect = this.convertRectToGlobal(this.pageRect);
8401 this.ctx.moveTo(pageRect.topLeft.x, pageRect.topLeft.y);
8402 this.ctx.lineTo(pageRect.topRight.x, pageRect.topRight.y);
8403 this.ctx.lineTo(pageRect.bottomRight.x, pageRect.bottomRight.y);
8404 this.ctx.lineTo(pageRect.bottomLeft.x, pageRect.bottomLeft.y);
8405 this.ctx.translate(shadowPos.x, shadowPos.y);
8406 this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
8407 const isw = this.shadow.width * 3 / 4;
8408 const innerGradient = this.ctx.createLinearGradient(0, 0, isw, 0);
8409 if (this.shadow.direction === 0) {
8410 this.ctx.translate(-isw, -100);
8411 innerGradient.addColorStop(1, 'rgba(0, 0, 0, ' + this.shadow.opacity + ')');
8412 innerGradient.addColorStop(0.9, 'rgba(0, 0, 0, 0.05)');
8413 innerGradient.addColorStop(0.7, 'rgba(0, 0, 0, ' + this.shadow.opacity + ')');
8414 innerGradient.addColorStop(0, 'rgba(0, 0, 0, 0)');
8415 } else {
8416 this.ctx.translate(0, -100);
8417 innerGradient.addColorStop(0, 'rgba(0, 0, 0, ' + this.shadow.opacity + ')');
8418 innerGradient.addColorStop(0.1, 'rgba(0, 0, 0, 0.05)');
8419 innerGradient.addColorStop(0.3, 'rgba(0, 0, 0, ' + this.shadow.opacity + ')');
8420 innerGradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
8421 }
8422 this.ctx.clip();
8423 this.ctx.fillStyle = innerGradient;
8424 this.ctx.fillRect(0, 0, isw, rect.height * 2);
8425 this.ctx.restore();
8426 }
8427 clear() {
8428 this.ctx.fillStyle = 'white';
8429 this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
8430 }
8431}
8432class UI {
8433 constructor(inBlock, app, setting) {
8434 this.touchPoint = null;
8435 this.swipeTimeout = 250;
8436 this.onResize = () => {
8437 this.update();
8438 };
8439 this.onMouseDown = e => {
8440 if (this.checkTarget(e.target)) {
8441 const pos = this.getMousePos(e.clientX, e.clientY);
8442 this.app.startUserTouch(pos);
8443 e.preventDefault();
8444 }
8445 };
8446 this.onTouchStart = e => {
8447 if (this.checkTarget(e.target)) {
8448 if (e.changedTouches.length > 0) {
8449 const t = e.changedTouches[0];
8450 const pos = this.getMousePos(t.clientX, t.clientY);
8451 this.touchPoint = {
8452 point: pos,
8453 time: Date.now()
8454 };
8455 setTimeout(() => {
8456 if (this.touchPoint !== null) {
8457 this.app.startUserTouch(pos);
8458 }
8459 }, this.swipeTimeout);
8460 if (!this.app.getSettings().mobileScrollSupport) e.preventDefault();
8461 }
8462 }
8463 };
8464 this.onMouseUp = e => {
8465 const pos = this.getMousePos(e.clientX, e.clientY);
8466 this.app.userStop(pos);
8467 };
8468 this.onMouseMove = e => {
8469 const pos = this.getMousePos(e.clientX, e.clientY);
8470 this.app.userMove(pos, false);
8471 };
8472 this.onTouchMove = e => {
8473 if (e.changedTouches.length > 0) {
8474 const t = e.changedTouches[0];
8475 const pos = this.getMousePos(t.clientX, t.clientY);
8476 if (this.app.getSettings().mobileScrollSupport) {
8477 if (this.touchPoint !== null) {
8478 if (Math.abs(this.touchPoint.point.x - pos.x) > 10 || this.app.getState() !== "read") {
8479 if (e.cancelable) this.app.userMove(pos, true);
8480 }
8481 }
8482 if (this.app.getState() !== "read") {
8483 e.preventDefault();
8484 }
8485 } else {
8486 this.app.userMove(pos, true);
8487 }
8488 }
8489 };
8490 this.onTouchEnd = e => {
8491 if (e.changedTouches.length > 0) {
8492 const t = e.changedTouches[0];
8493 const pos = this.getMousePos(t.clientX, t.clientY);
8494 let isSwipe = false;
8495 if (this.touchPoint !== null) {
8496 const dx = pos.x - this.touchPoint.point.x;
8497 const distY = Math.abs(pos.y - this.touchPoint.point.y);
8498 if (Math.abs(dx) > this.swipeDistance && distY < this.swipeDistance * 2 && Date.now() - this.touchPoint.time < this.swipeTimeout) {
8499 if (dx > 0) {
8500 this.app.flipPrev(this.touchPoint.point.y < this.app.getRender().getRect().height / 2 ? "top" : "bottom");
8501 } else {
8502 this.app.flipNext(this.touchPoint.point.y < this.app.getRender().getRect().height / 2 ? "top" : "bottom");
8503 }
8504 isSwipe = true;
8505 }
8506 this.touchPoint = null;
8507 }
8508 this.app.userStop(pos, isSwipe);
8509 }
8510 };
8511 this.parentElement = inBlock;
8512 inBlock.classList.add('stf__parent');
8513 inBlock.insertAdjacentHTML('afterbegin', '<div class="stf__wrapper"></div>');
8514 this.wrapper = inBlock.querySelector('.stf__wrapper');
8515 this.app = app;
8516 const k = this.app.getSettings().usePortrait ? 1 : 2;
8517 inBlock.style.minWidth = setting.minWidth * k + 'px';
8518 inBlock.style.minHeight = setting.minHeight + 'px';
8519 if (setting.size === "fixed") {
8520 inBlock.style.minWidth = setting.width * k + 'px';
8521 inBlock.style.minHeight = setting.height + 'px';
8522 }
8523 if (setting.autoSize) {
8524 inBlock.style.width = '100%';
8525 inBlock.style.maxWidth = setting.maxWidth * 2 + 'px';
8526 }
8527 inBlock.style.display = 'block';
8528 window.addEventListener('resize', this.onResize, false);
8529 this.swipeDistance = setting.swipeDistance;
8530 }
8531 destroy() {
8532 if (this.app.getSettings().useMouseEvents) this.removeHandlers();
8533 this.distElement.remove();
8534 this.wrapper.remove();
8535 }
8536 getDistElement() {
8537 return this.distElement;
8538 }
8539 getWrapper() {
8540 return this.wrapper;
8541 }
8542 setOrientationStyle(orientation) {
8543 this.wrapper.classList.remove('--portrait', '--landscape');
8544 if (orientation === "portrait") {
8545 if (this.app.getSettings().autoSize) this.wrapper.style.paddingBottom = this.app.getSettings().height / this.app.getSettings().width * 100 + '%';
8546 this.wrapper.classList.add('--portrait');
8547 } else {
8548 if (this.app.getSettings().autoSize) this.wrapper.style.paddingBottom = this.app.getSettings().height / (this.app.getSettings().width * 2) * 100 + '%';
8549 this.wrapper.classList.add('--landscape');
8550 }
8551 this.update();
8552 }
8553 removeHandlers() {
8554 window.removeEventListener('resize', this.onResize);
8555 this.distElement.removeEventListener('mousedown', this.onMouseDown);
8556 this.distElement.removeEventListener('touchstart', this.onTouchStart);
8557 window.removeEventListener('mousemove', this.onMouseMove);
8558 window.removeEventListener('touchmove', this.onTouchMove);
8559 window.removeEventListener('mouseup', this.onMouseUp);
8560 window.removeEventListener('touchend', this.onTouchEnd);
8561 }
8562 setHandlers() {
8563 window.addEventListener('resize', this.onResize, false);
8564 if (!this.app.getSettings().useMouseEvents) return;
8565 this.distElement.addEventListener('mousedown', this.onMouseDown);
8566 this.distElement.addEventListener('touchstart', this.onTouchStart);
8567 window.addEventListener('mousemove', this.onMouseMove);
8568 window.addEventListener('touchmove', this.onTouchMove, {
8569 passive: !this.app.getSettings().mobileScrollSupport
8570 });
8571 window.addEventListener('mouseup', this.onMouseUp);
8572 window.addEventListener('touchend', this.onTouchEnd);
8573 }
8574 getMousePos(x, y) {
8575 const rect = this.distElement.getBoundingClientRect();
8576 return {
8577 x: x - rect.left,
8578 y: y - rect.top
8579 };
8580 }
8581 checkTarget(targer) {
8582 if (!this.app.getSettings().clickEventForward) return true;
8583 if (['a', 'button'].includes(targer.tagName.toLowerCase())) {
8584 return false;
8585 }
8586 return true;
8587 }
8588}
8589class HTMLUI extends UI {
8590 constructor(inBlock, app, setting, items) {
8591 super(inBlock, app, setting);
8592 this.wrapper.insertAdjacentHTML('afterbegin', '<div class="stf__block"></div>');
8593 this.distElement = inBlock.querySelector('.stf__block');
8594 this.items = items;
8595 for (const item of items) {
8596 this.distElement.appendChild(item);
8597 }
8598 this.setHandlers();
8599 }
8600 clear() {
8601 for (const item of this.items) {
8602 this.parentElement.appendChild(item);
8603 }
8604 }
8605 updateItems(items) {
8606 this.removeHandlers();
8607 this.distElement.innerHTML = '';
8608 for (const item of items) {
8609 this.distElement.appendChild(item);
8610 }
8611 this.items = items;
8612 this.setHandlers();
8613 }
8614 update() {
8615 this.app.getRender().update();
8616 }
8617}
8618class CanvasUI extends UI {
8619 constructor(inBlock, app, setting) {
8620 super(inBlock, app, setting);
8621 this.wrapper.innerHTML = '<canvas class="stf__canvas"></canvas>';
8622 this.canvas = inBlock.querySelectorAll('canvas')[0];
8623 this.distElement = this.canvas;
8624 this.resizeCanvas();
8625 this.setHandlers();
8626 }
8627 resizeCanvas() {
8628 const cs = getComputedStyle(this.canvas);
8629 const width = parseInt(cs.getPropertyValue('width'), 10);
8630 const height = parseInt(cs.getPropertyValue('height'), 10);
8631 this.canvas.width = width;
8632 this.canvas.height = height;
8633 }
8634 getCanvas() {
8635 return this.canvas;
8636 }
8637 update() {
8638 this.resizeCanvas();
8639 this.app.getRender().update();
8640 }
8641}
8642class EventObject {
8643 constructor() {
8644 this.events = new Map();
8645 }
8646 on(eventName, callback) {
8647 if (!this.events.has(eventName)) {
8648 this.events.set(eventName, [callback]);
8649 } else {
8650 this.events.get(eventName).push(callback);
8651 }
8652 return this;
8653 }
8654 off(event) {
8655 this.events.delete(event);
8656 }
8657 trigger(eventName, app, data = null) {
8658 if (!this.events.has(eventName)) return;
8659 for (const callback of this.events.get(eventName)) {
8660 callback({
8661 data,
8662 object: app
8663 });
8664 }
8665 }
8666}
8667class HTMLRender extends Render {
8668 constructor(app, setting, element) {
8669 super(app, setting);
8670 this.outerShadow = null;
8671 this.innerShadow = null;
8672 this.hardShadow = null;
8673 this.hardInnerShadow = null;
8674 this.element = element;
8675 this.createShadows();
8676 }
8677 createShadows() {
8678 this.element.insertAdjacentHTML('beforeend', `<div class="stf__outerShadow"></div>
8679 <div class="stf__innerShadow"></div>
8680 <div class="stf__hardShadow"></div>
8681 <div class="stf__hardInnerShadow"></div>`);
8682 this.outerShadow = this.element.querySelector('.stf__outerShadow');
8683 this.innerShadow = this.element.querySelector('.stf__innerShadow');
8684 this.hardShadow = this.element.querySelector('.stf__hardShadow');
8685 this.hardInnerShadow = this.element.querySelector('.stf__hardInnerShadow');
8686 }
8687 clearShadow() {
8688 super.clearShadow();
8689 this.outerShadow.style.cssText = 'display: none';
8690 this.innerShadow.style.cssText = 'display: none';
8691 this.hardShadow.style.cssText = 'display: none';
8692 this.hardInnerShadow.style.cssText = 'display: none';
8693 }
8694 reload() {
8695 const testShadow = this.element.querySelector('.stf__outerShadow');
8696 if (!testShadow) {
8697 this.createShadows();
8698 }
8699 }
8700 drawHardInnerShadow() {
8701 const rect = this.getRect();
8702 const progress = this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress;
8703 let innerShadowSize = (100 - progress) * (2.5 * rect.pageWidth) / 100 + 20;
8704 if (innerShadowSize > rect.pageWidth) innerShadowSize = rect.pageWidth;
8705 let newStyle = `
8706 display: block;
8707 z-index: ${(this.getSettings().startZIndex + 5).toString(10)};
8708 width: ${innerShadowSize}px;
8709 height: ${rect.height}px;
8710 background: linear-gradient(to right,
8711 rgba(0, 0, 0, ${this.shadow.opacity * progress / 100}) 5%,
8712 rgba(0, 0, 0, 0) 100%);
8713 left: ${rect.left + rect.width / 2}px;
8714 transform-origin: 0 0;
8715 `;
8716 newStyle += this.getDirection() === 0 && this.shadow.progress > 100 || this.getDirection() === 1 && this.shadow.progress <= 100 ? `transform: translate3d(0, 0, 0);` : `transform: translate3d(0, 0, 0) rotateY(180deg);`;
8717 this.hardInnerShadow.style.cssText = newStyle;
8718 }
8719 drawHardOuterShadow() {
8720 const rect = this.getRect();
8721 const progress = this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress;
8722 let shadowSize = (100 - progress) * (2.5 * rect.pageWidth) / 100 + 20;
8723 if (shadowSize > rect.pageWidth) shadowSize = rect.pageWidth;
8724 let newStyle = `
8725 display: block;
8726 z-index: ${(this.getSettings().startZIndex + 4).toString(10)};
8727 width: ${shadowSize}px;
8728 height: ${rect.height}px;
8729 background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
8730 left: ${rect.left + rect.width / 2}px;
8731 transform-origin: 0 0;
8732 `;
8733 newStyle += this.getDirection() === 0 && this.shadow.progress > 100 || this.getDirection() === 1 && this.shadow.progress <= 100 ? `transform: translate3d(0, 0, 0) rotateY(180deg);` : `transform: translate3d(0, 0, 0);`;
8734 this.hardShadow.style.cssText = newStyle;
8735 }
8736 drawInnerShadow() {
8737 const rect = this.getRect();
8738 const innerShadowSize = this.shadow.width * 3 / 4;
8739 const shadowTranslate = this.getDirection() === 0 ? innerShadowSize : 0;
8740 const shadowDirection = this.getDirection() === 0 ? 'to left' : 'to right';
8741 const shadowPos = this.convertToGlobal(this.shadow.pos);
8742 const angle = this.shadow.angle + 3 * Math.PI / 2;
8743 const clip = [this.pageRect.topLeft, this.pageRect.topRight, this.pageRect.bottomRight, this.pageRect.bottomLeft];
8744 let polygon = 'polygon( ';
8745 for (const p of clip) {
8746 let g = this.getDirection() === 1 ? {
8747 x: -p.x + this.shadow.pos.x,
8748 y: p.y - this.shadow.pos.y
8749 } : {
8750 x: p.x - this.shadow.pos.x,
8751 y: p.y - this.shadow.pos.y
8752 };
8753 g = Helper.GetRotatedPoint(g, {
8754 x: shadowTranslate,
8755 y: 100
8756 }, angle);
8757 polygon += g.x + 'px ' + g.y + 'px, ';
8758 }
8759 polygon = polygon.slice(0, -2);
8760 polygon += ')';
8761 const newStyle = `
8762 display: block;
8763 z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
8764 width: ${innerShadowSize}px;
8765 height: ${rect.height * 2}px;
8766 background: linear-gradient(${shadowDirection},
8767 rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
8768 rgba(0, 0, 0, 0.05) 15%,
8769 rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
8770 rgba(0, 0, 0, 0) 100%);
8771 transform-origin: ${shadowTranslate}px 100px;
8772 transform: translate3d(${shadowPos.x - shadowTranslate}px, ${shadowPos.y - 100}px, 0) rotate(${angle}rad);
8773 clip-path: ${polygon};
8774 -webkit-clip-path: ${polygon};
8775 `;
8776 this.innerShadow.style.cssText = newStyle;
8777 }
8778 drawOuterShadow() {
8779 const rect = this.getRect();
8780 const shadowPos = this.convertToGlobal({
8781 x: this.shadow.pos.x,
8782 y: this.shadow.pos.y
8783 });
8784 const angle = this.shadow.angle + 3 * Math.PI / 2;
8785 const shadowTranslate = this.getDirection() === 1 ? this.shadow.width : 0;
8786 const shadowDirection = this.getDirection() === 0 ? 'to right' : 'to left';
8787 const clip = [{
8788 x: 0,
8789 y: 0
8790 }, {
8791 x: rect.pageWidth,
8792 y: 0
8793 }, {
8794 x: rect.pageWidth,
8795 y: rect.height
8796 }, {
8797 x: 0,
8798 y: rect.height
8799 }];
8800 let polygon = 'polygon( ';
8801 for (const p of clip) {
8802 if (p !== null) {
8803 let g = this.getDirection() === 1 ? {
8804 x: -p.x + this.shadow.pos.x,
8805 y: p.y - this.shadow.pos.y
8806 } : {
8807 x: p.x - this.shadow.pos.x,
8808 y: p.y - this.shadow.pos.y
8809 };
8810 g = Helper.GetRotatedPoint(g, {
8811 x: shadowTranslate,
8812 y: 100
8813 }, angle);
8814 polygon += g.x + 'px ' + g.y + 'px, ';
8815 }
8816 }
8817 polygon = polygon.slice(0, -2);
8818 polygon += ')';
8819 const newStyle = `
8820 display: block;
8821 z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
8822 width: ${this.shadow.width}px;
8823 height: ${rect.height * 2}px;
8824 background: linear-gradient(${shadowDirection}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
8825 transform-origin: ${shadowTranslate}px 100px;
8826 transform: translate3d(${shadowPos.x - shadowTranslate}px, ${shadowPos.y - 100}px, 0) rotate(${angle}rad);
8827 clip-path: ${polygon};
8828 -webkit-clip-path: ${polygon};
8829 `;
8830 this.outerShadow.style.cssText = newStyle;
8831 }
8832 drawLeftPage() {
8833 if (this.orientation === "portrait" || this.leftPage === null) return;
8834 if (this.direction === 1 && this.flippingPage !== null && this.flippingPage.getDrawingDensity() === "hard") {
8835 const angle = this.flippingPage.getHardAngle();
8836 if (angle < -90) {
8837 this.leftPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10);
8838 this.leftPage.setHardDrawingAngle(180 + this.flippingPage.getHardAngle());
8839 this.leftPage.draw(this.flippingPage.getDrawingDensity());
8840 } else {
8841 this.leftPage.getElement().style.display = "none";
8842 }
8843 } else {
8844 this.leftPage.simpleDraw(0);
8845 }
8846 }
8847 drawRightPage() {
8848 if (this.rightPage === null) return;
8849 if (this.direction === 0 && this.flippingPage !== null && this.flippingPage.getDrawingDensity() === "hard") {
8850 const angle = this.flippingPage.getHardAngle();
8851 if (angle > 90) {
8852 this.rightPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10);
8853 this.rightPage.setHardDrawingAngle(180 + this.flippingPage.getHardAngle());
8854 this.rightPage.draw(this.flippingPage.getDrawingDensity());
8855 } else {
8856 this.rightPage.getElement().style.display = "none";
8857 }
8858 } else {
8859 this.rightPage.simpleDraw(1);
8860 }
8861 }
8862 drawBottomPage() {
8863 if (this.bottomPage === null) return;
8864 const tempDensity = this.flippingPage != null ? this.flippingPage.getDrawingDensity() : null;
8865 if (!(this.orientation === "portrait" && this.direction === 1)) {
8866 this.bottomPage.getElement().style.zIndex = (this.getSettings().startZIndex + 3).toString(10);
8867 this.bottomPage.draw(tempDensity);
8868 }
8869 }
8870 drawFrame() {
8871 if (this.flippingPage !== null) {
8872 if (this.flippingPage.getHardAngle() === this.lastAngle) {
8873 return;
8874 }
8875 this.lastAngle = this.flippingPage.getHardAngle();
8876 } else {
8877 this.lastAngle = -1234;
8878 }
8879 this.clear();
8880 this.drawLeftPage();
8881 this.drawRightPage();
8882 this.drawBottomPage();
8883 if (this.flippingPage != null) {
8884 const angle = this.flippingPage.state.hardDrawingAngle;
8885 if (angle <= 90) {
8886 this.flippingPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10);
8887 this.flippingPage.draw();
8888 } else {
8889 this.flippingPage.getElement().style.display = "none";
8890 }
8891 }
8892 if (this.shadow != null && this.flippingPage !== null) {
8893 if (this.flippingPage.getDrawingDensity() === "soft") {
8894 this.drawOuterShadow();
8895 this.drawInnerShadow();
8896 } else {
8897 this.drawHardOuterShadow();
8898 this.drawHardInnerShadow();
8899 }
8900 }
8901 }
8902 clear() {
8903 for (const page of this.app.getPageCollection().getPages()) {
8904 if (page !== this.leftPage && page !== this.rightPage && page !== this.flippingPage && page !== this.bottomPage) {
8905 const style = page.getElement().style;
8906 if (style.display !== 'none') {
8907 style.cssText = 'display: none';
8908 }
8909 }
8910 if (page.getTemporaryCopy() !== this.flippingPage) {
8911 page.hideTemporaryCopy();
8912 }
8913 }
8914 }
8915 update() {
8916 super.update();
8917 if (this.rightPage !== null) {
8918 this.rightPage.setOrientation(1);
8919 }
8920 if (this.leftPage !== null) {
8921 this.leftPage.setOrientation(0);
8922 }
8923 }
8924}
8925class Settings {
8926 constructor() {
8927 this._default = {
8928 startPage: 0,
8929 size: "fixed",
8930 width: 0,
8931 height: 0,
8932 minWidth: 0,
8933 maxWidth: 0,
8934 minHeight: 0,
8935 maxHeight: 0,
8936 drawShadow: true,
8937 flippingTime: 1000,
8938 usePortrait: true,
8939 startZIndex: 0,
8940 autoSize: true,
8941 maxShadowOpacity: 1,
8942 showCover: false,
8943 mobileScrollSupport: true,
8944 swipeDistance: 30,
8945 clickEventForward: true,
8946 useMouseEvents: true,
8947 showPageCorners: true,
8948 disableFlipByClick: false
8949 };
8950 }
8951 getSettings(userSetting) {
8952 const result = this._default;
8953 Object.assign(result, userSetting);
8954 if (result.size !== "stretch" && result.size !== "fixed") throw new Error('Invalid size type. Available only "fixed" and "stretch" value');
8955 if (result.width <= 0 || result.height <= 0) throw new Error('Invalid width or height');
8956 if (result.flippingTime <= 0) throw new Error('Invalid flipping time');
8957 if (result.size === "stretch") {
8958 if (result.minWidth <= 0) result.minWidth = 100;
8959 if (result.maxWidth < result.minWidth) result.maxWidth = 2000;
8960 if (result.minHeight <= 0) result.minHeight = 100;
8961 if (result.maxHeight < result.minHeight) result.maxHeight = 2000;
8962 } else {
8963 result.minWidth = result.width;
8964 result.maxWidth = result.width;
8965 result.minHeight = result.height;
8966 result.maxHeight = result.height;
8967 }
8968 return result;
8969 }
8970}
8971function styleInject(css, ref) {
8972 if (ref === void 0) ref = {};
8973 var insertAt = ref.insertAt;
8974 if (!css || typeof document === 'undefined') {
8975 return;
8976 }
8977 var head = document.head || document.getElementsByTagName('head')[0];
8978 var style = document.createElement('style');
8979 style.type = 'text/css';
8980 if (insertAt === 'top') {
8981 if (head.firstChild) {
8982 head.insertBefore(style, head.firstChild);
8983 } else {
8984 head.appendChild(style);
8985 }
8986 } else {
8987 head.appendChild(style);
8988 }
8989 if (style.styleSheet) {
8990 style.styleSheet.cssText = css;
8991 } else {
8992 style.appendChild(document.createTextNode(css));
8993 }
8994}
8995var css_248z = ".stf__parent {\n position: relative;\n display: block;\n box-sizing: border-box;\n transform: translateZ(0);\n\n -ms-touch-action: pan-y;\n touch-action: pan-y;\n}\n\n.sft__wrapper {\n position: relative;\n width: 100%;\n box-sizing: border-box;\n}\n\n.stf__parent canvas {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n}\n\n.stf__block {\n position: absolute;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n perspective: 2000px;\n}\n\n.stf__item {\n display: none;\n position: absolute;\n transform-style: preserve-3d;\n}\n\n.stf__outerShadow {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.stf__innerShadow {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.stf__hardShadow {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.stf__hardInnerShadow {\n position: absolute;\n left: 0;\n top: 0;\n}";
8996styleInject(css_248z);
8997class PageFlip extends EventObject {
8998 constructor(inBlock, setting) {
8999 super();
9000 this.isUserTouch = false;
9001 this.isUserMove = false;
9002 this.setting = null;
9003 this.pages = null;
9004 this.setting = new Settings().getSettings(setting);
9005 this.block = inBlock;
9006 }
9007 destroy() {
9008 this.ui.destroy();
9009 }
9010 update() {
9011 this.render.update();
9012 this.pages.show();
9013 }
9014 loadFromImages(imagesHref) {
9015 this.ui = new CanvasUI(this.block, this, this.setting);
9016 const canvas = this.ui.getCanvas();
9017 this.render = new CanvasRender(this, this.setting, canvas);
9018 this.flipController = new Flip(this.render, this);
9019 this.pages = new ImagePageCollection(this, this.render, imagesHref);
9020 this.pages.load();
9021 this.render.start();
9022 this.pages.show(this.setting.startPage);
9023 setTimeout(() => {
9024 this.ui.update();
9025 this.trigger('init', this, {
9026 page: this.setting.startPage,
9027 mode: this.render.getOrientation()
9028 });
9029 }, 1);
9030 }
9031 loadFromHTML(items) {
9032 this.ui = new HTMLUI(this.block, this, this.setting, items);
9033 this.render = new HTMLRender(this, this.setting, this.ui.getDistElement());
9034 this.flipController = new Flip(this.render, this);
9035 this.pages = new HTMLPageCollection(this, this.render, this.ui.getDistElement(), items);
9036 this.pages.load();
9037 this.render.start();
9038 this.pages.show(this.setting.startPage);
9039 setTimeout(() => {
9040 this.ui.update();
9041 this.trigger('init', this, {
9042 page: this.setting.startPage,
9043 mode: this.render.getOrientation()
9044 });
9045 }, 1);
9046 }
9047 updateFromImages(imagesHref) {
9048 const current = this.pages.getCurrentPageIndex();
9049 this.pages.destroy();
9050 this.pages = new ImagePageCollection(this, this.render, imagesHref);
9051 this.pages.load();
9052 this.pages.show(current);
9053 this.trigger('update', this, {
9054 page: current,
9055 mode: this.render.getOrientation()
9056 });
9057 }
9058 updateFromHtml(items) {
9059 const current = this.pages.getCurrentPageIndex();
9060 this.pages.destroy();
9061 this.pages = new HTMLPageCollection(this, this.render, this.ui.getDistElement(), items);
9062 this.pages.load();
9063 this.ui.updateItems(items);
9064 this.render.reload();
9065 this.pages.show(current);
9066 this.trigger('update', this, {
9067 page: current,
9068 mode: this.render.getOrientation()
9069 });
9070 }
9071 clear() {
9072 this.pages.destroy();
9073 this.ui.clear();
9074 }
9075 turnToPrevPage() {
9076 this.pages.showPrev();
9077 }
9078 turnToNextPage() {
9079 this.pages.showNext();
9080 }
9081 turnToPage(page) {
9082 this.pages.show(page);
9083 }
9084 flipNext(corner = "top") {
9085 this.flipController.flipNext(corner);
9086 }
9087 flipPrev(corner = "top") {
9088 this.flipController.flipPrev(corner);
9089 }
9090 flip(page, corner = "top") {
9091 this.flipController.flipToPage(page, corner);
9092 }
9093 updateState(newState) {
9094 this.trigger('changeState', this, newState);
9095 }
9096 updatePageIndex(newPage) {
9097 this.trigger('flip', this, newPage);
9098 }
9099 updateOrientation(newOrientation) {
9100 this.ui.setOrientationStyle(newOrientation);
9101 this.update();
9102 this.trigger('changeOrientation', this, newOrientation);
9103 }
9104 getPageCount() {
9105 return this.pages.getPageCount();
9106 }
9107 getCurrentPageIndex() {
9108 return this.pages.getCurrentPageIndex();
9109 }
9110 getPage(pageIndex) {
9111 return this.pages.getPage(pageIndex);
9112 }
9113 getRender() {
9114 return this.render;
9115 }
9116 getFlipController() {
9117 return this.flipController;
9118 }
9119 getOrientation() {
9120 return this.render.getOrientation();
9121 }
9122 getBoundsRect() {
9123 return this.render.getRect();
9124 }
9125 getSettings() {
9126 return this.setting;
9127 }
9128 getUI() {
9129 return this.ui;
9130 }
9131 getState() {
9132 return this.flipController.getState();
9133 }
9134 getPageCollection() {
9135 return this.pages;
9136 }
9137 startUserTouch(pos) {
9138 this.mousePosition = pos;
9139 this.isUserTouch = true;
9140 this.isUserMove = false;
9141 }
9142 userMove(pos, isTouch) {
9143 if (!this.isUserTouch && !isTouch && this.setting.showPageCorners) {
9144 this.flipController.showCorner(pos);
9145 } else if (this.isUserTouch) {
9146 if (Helper.GetDistanceBetweenTwoPoint(this.mousePosition, pos) > 5) {
9147 this.isUserMove = true;
9148 this.flipController.fold(pos);
9149 }
9150 }
9151 }
9152 userStop(pos, isSwipe = false) {
9153 if (this.isUserTouch) {
9154 this.isUserTouch = false;
9155 if (!isSwipe) {
9156 if (!this.isUserMove) this.flipController.flip(pos);else this.flipController.stopMove();
9157 }
9158 }
9159 }
9160}
9161
9162
9163/***/ }),
9164
9165/***/ 2690:
9166/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
9167
9168__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
9169/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9170/* harmony export */ PasswordPrompt: () => (/* binding */ PasswordPrompt)
9171/* harmony export */ });
9172/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
9173var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
9174pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
9175
9176class PasswordPrompt {
9177 #activeCapability = null;
9178 #updateCallback = null;
9179 #reason = null;
9180 constructor(options, overlayManager, isViewerEmbedded = false) {
9181 this.dialog = options.dialog;
9182 this.label = options.label;
9183 this.input = options.input;
9184 this.submitButton = options.submitButton;
9185 this.cancelButton = options.cancelButton;
9186 this.overlayManager = overlayManager;
9187 this._isViewerEmbedded = isViewerEmbedded;
9188 this.submitButton.addEventListener("click", this.#verify.bind(this));
9189 this.cancelButton.addEventListener("click", this.close.bind(this));
9190 this.input.addEventListener("keydown", e => {
9191 if (e.keyCode === 13) {
9192 this.#verify();
9193 }
9194 });
9195 this.overlayManager.register(this.dialog, true);
9196 this.dialog.addEventListener("close", this.#cancel.bind(this));
9197 }
9198 async open() {
9199 await this.#activeCapability?.promise;
9200 this.#activeCapability = Promise.withResolvers();
9201 try {
9202 await this.overlayManager.open(this.dialog);
9203 this.input.type = "password";
9204 this.input.focus();
9205 } catch (ex) {
9206 this.#activeCapability.resolve();
9207 throw ex;
9208 }
9209 const passwordIncorrect = this.#reason === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PasswordResponses.INCORRECT_PASSWORD;
9210 if (!this._isViewerEmbedded || passwordIncorrect) {
9211 this.input.focus();
9212 }
9213 this.label.setAttribute("data-l10n-id", `pdfjs-password-${passwordIncorrect ? "invalid" : "label"}`);
9214 }
9215 async close() {
9216 if (this.overlayManager.active === this.dialog) {
9217 this.overlayManager.close(this.dialog);
9218 this.input.value = "";
9219 this.input.type = "hidden";
9220 }
9221 }
9222 #verify() {
9223 const password = this.input.value;
9224 if (password?.length > 0) {
9225 this.#invokeCallback(password);
9226 }
9227 }
9228 #cancel() {
9229 this.#invokeCallback(new Error("PasswordPrompt cancelled."));
9230 this.#activeCapability.resolve();
9231 }
9232 #invokeCallback(password) {
9233 if (!this.#updateCallback) {
9234 return;
9235 }
9236 this.close();
9237 this.input.value = "";
9238 this.#updateCallback(password);
9239 this.#updateCallback = null;
9240 }
9241 async setUpdateCallback(updateCallback, reason) {
9242 if (this.#activeCapability) {
9243 await this.#activeCapability.promise;
9244 }
9245 this.#updateCallback = updateCallback;
9246 this.#reason = reason;
9247 }
9248}
9249
9250__webpack_async_result__();
9251} catch(e) { __webpack_async_result__(e); } });
9252
9253/***/ }),
9254
9255/***/ 9251:
9256/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
9257
9258__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
9259/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9260/* harmony export */ PDFAttachmentViewer: () => (/* binding */ PDFAttachmentViewer)
9261/* harmony export */ });
9262/* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2961);
9263/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
9264/* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5656);
9265var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
9266pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
9267
9268
9269
9270class PDFAttachmentViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__.BaseTreeViewer {
9271 constructor(options) {
9272 super(options);
9273 this.downloadManager = options.downloadManager;
9274 this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this));
9275 }
9276 reset(keepRenderedCapability = false) {
9277 super.reset();
9278 this._attachments = null;
9279 if (!keepRenderedCapability) {
9280 this._renderedCapability = Promise.withResolvers();
9281 }
9282 this._pendingDispatchEvent = false;
9283 }
9284 async _dispatchEvent(attachmentsCount) {
9285 this._renderedCapability.resolve();
9286 if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
9287 this._pendingDispatchEvent = true;
9288 await (0,_event_utils_js__WEBPACK_IMPORTED_MODULE_2__.waitOnEventOrTimeout)({
9289 target: this.eventBus,
9290 name: "annotationlayerrendered",
9291 delay: 1000
9292 });
9293 if (!this._pendingDispatchEvent) {
9294 return;
9295 }
9296 }
9297 this._pendingDispatchEvent = false;
9298 this.eventBus.dispatch("attachmentsloaded", {
9299 source: this,
9300 attachmentsCount
9301 });
9302 }
9303 _bindLink(element, {
9304 content,
9305 filename
9306 }) {
9307 element.onclick = () => {
9308 this.downloadManager.openOrDownloadData(content, filename);
9309 return false;
9310 };
9311 }
9312 render({
9313 attachments,
9314 keepRenderedCapability = false
9315 }) {
9316 if (this._attachments) {
9317 this.reset(keepRenderedCapability);
9318 }
9319 this._attachments = attachments || null;
9320 if (!attachments) {
9321 this._dispatchEvent(0);
9322 return;
9323 }
9324 const fragment = document.createDocumentFragment();
9325 let attachmentsCount = 0;
9326 for (const name in attachments) {
9327 const item = attachments[name];
9328 const content = item.content,
9329 filename = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getFilenameFromUrl)(item.filename, true);
9330 const div = document.createElement("div");
9331 div.className = "treeItem";
9332 const element = document.createElement("a");
9333 this._bindLink(element, {
9334 content,
9335 filename
9336 });
9337 element.textContent = this._normalizeTextContent(filename);
9338 div.append(element);
9339 fragment.append(div);
9340 attachmentsCount++;
9341 }
9342 this._finishRendering(fragment, attachmentsCount);
9343 }
9344 #appendAttachment({
9345 filename,
9346 content
9347 }) {
9348 const renderedPromise = this._renderedCapability.promise;
9349 renderedPromise.then(() => {
9350 if (renderedPromise !== this._renderedCapability.promise) {
9351 return;
9352 }
9353 const attachments = this._attachments || Object.create(null);
9354 for (const name in attachments) {
9355 if (filename === name) {
9356 return;
9357 }
9358 }
9359 attachments[filename] = {
9360 filename,
9361 content
9362 };
9363 this.render({
9364 attachments,
9365 keepRenderedCapability: true
9366 });
9367 });
9368 }
9369}
9370
9371__webpack_async_result__();
9372} catch(e) { __webpack_async_result__(e); } });
9373
9374/***/ }),
9375
9376/***/ 5993:
9377/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
9378
9379__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
9380/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9381/* harmony export */ PDFCursorTools: () => (/* binding */ PDFCursorTools)
9382/* harmony export */ });
9383/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
9384/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
9385/* harmony import */ var _grab_to_pan_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2640);
9386var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
9387pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
9388
9389
9390
9391class PDFCursorTools {
9392 #active = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT;
9393 #prevActive = null;
9394 constructor({
9395 container,
9396 eventBus,
9397 cursorToolOnLoad = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT
9398 }) {
9399 this.container = container;
9400 this.eventBus = eventBus;
9401 this.#addEventListeners();
9402 Promise.resolve().then(() => {
9403 this.switchTool(cursorToolOnLoad);
9404 });
9405 }
9406 get activeTool() {
9407 return this.#active;
9408 }
9409 switchTool(tool) {
9410 if (this.#prevActive !== null) {
9411 return;
9412 }
9413 if (tool === this.#active) {
9414 return;
9415 }
9416 const disableActiveTool = () => {
9417 switch (this.#active) {
9418 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT:
9419 break;
9420 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.HAND:
9421 this._handTool.deactivate();
9422 break;
9423 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.ZOOM:
9424 }
9425 };
9426 switch (tool) {
9427 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT:
9428 disableActiveTool();
9429 break;
9430 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.HAND:
9431 disableActiveTool();
9432 this._handTool.activate();
9433 break;
9434 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.ZOOM:
9435 default:
9436 globalThis.ngxConsole.error(`switchTool: "${tool}" is an unsupported value.`);
9437 return;
9438 }
9439 this.#active = tool;
9440 this.eventBus.dispatch("cursortoolchanged", {
9441 source: this,
9442 tool
9443 });
9444 }
9445 #addEventListeners() {
9446 this.eventBus._on("switchcursortool", evt => {
9447 if (!evt.reset) {
9448 this.switchTool(evt.tool);
9449 } else if (this.#prevActive !== null) {
9450 annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
9451 presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL;
9452 enableActive();
9453 }
9454 });
9455 let annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE,
9456 presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL;
9457 const disableActive = () => {
9458 const prevActive = this.#active;
9459 this.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT);
9460 this.#prevActive ??= prevActive;
9461 };
9462 const enableActive = () => {
9463 const prevActive = this.#prevActive;
9464 if (prevActive !== null && annotationEditorMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE && presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL) {
9465 this.#prevActive = null;
9466 this.switchTool(prevActive);
9467 }
9468 };
9469 this.eventBus._on("annotationeditormodechanged", ({
9470 mode
9471 }) => {
9472 annotationEditorMode = mode;
9473 if (mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE) {
9474 enableActive();
9475 } else {
9476 disableActive();
9477 }
9478 });
9479 this.eventBus._on("presentationmodechanged", ({
9480 state
9481 }) => {
9482 presentationModeState = state;
9483 if (state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL) {
9484 enableActive();
9485 } else if (state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN) {
9486 disableActive();
9487 }
9488 });
9489 }
9490 get _handTool() {
9491 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_handTool", new _grab_to_pan_js__WEBPACK_IMPORTED_MODULE_2__.GrabToPan({
9492 element: this.container
9493 }));
9494 }
9495}
9496
9497__webpack_async_result__();
9498} catch(e) { __webpack_async_result__(e); } });
9499
9500/***/ }),
9501
9502/***/ 164:
9503/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
9504
9505__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
9506/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9507/* harmony export */ PDFDocumentProperties: () => (/* binding */ PDFDocumentProperties)
9508/* harmony export */ });
9509/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
9510/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
9511var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
9512pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
9513
9514
9515const DEFAULT_FIELD_CONTENT = "-";
9516const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
9517const US_PAGE_NAMES = {
9518 "8.5x11": "letter",
9519 "8.5x14": "legal"
9520};
9521const METRIC_PAGE_NAMES = {
9522 "297x420": "a-three",
9523 "210x297": "a-four"
9524};
9525function getPageName(size, isPortrait, pageNames) {
9526 const width = isPortrait ? size.width : size.height;
9527 const height = isPortrait ? size.height : size.width;
9528 return pageNames[`${width}x${height}`];
9529}
9530class PDFDocumentProperties {
9531 #fieldData = null;
9532 constructor({
9533 dialog,
9534 fields,
9535 closeButton
9536 }, overlayManager, eventBus, l10n, fileNameLookup) {
9537 this.dialog = dialog;
9538 this.fields = fields;
9539 this.overlayManager = overlayManager;
9540 this.l10n = l10n;
9541 this._fileNameLookup = fileNameLookup;
9542 this.eventBus = eventBus;
9543 this.#reset();
9544 closeButton.addEventListener("click", this.close.bind(this));
9545 this.overlayManager.register(this.dialog);
9546 eventBus._on("pagechanging", evt => {
9547 this._currentPageNumber = evt.pageNumber;
9548 });
9549 eventBus._on("rotationchanging", evt => {
9550 this._pagesRotation = evt.pagesRotation;
9551 });
9552 this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage());
9553 }
9554 async open() {
9555 await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
9556 this.eventBus.dispatch("propertiesdialogopen", this);
9557 const currentPageNumber = this._currentPageNumber;
9558 const pagesRotation = this._pagesRotation;
9559 if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) {
9560 this.#updateUI();
9561 return;
9562 }
9563 const {
9564 info,
9565 contentLength
9566 } = await this.pdfDocument.getMetadata();
9567 const [fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized] = await Promise.all([this._fileNameLookup(), this.#parseFileSize(contentLength), this.#parseDate(info.CreationDate), this.#parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
9568 return this.#parsePageSize((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getPageSizeInches)(pdfPage), pagesRotation);
9569 }), this.#parseLinearization(info.IsLinearized)]);
9570 this.#fieldData = Object.freeze({
9571 fileName,
9572 fileSize,
9573 title: info.Title,
9574 author: info.Author,
9575 subject: info.Subject,
9576 keywords: info.Keywords,
9577 creationDate,
9578 modificationDate,
9579 creator: info.Creator,
9580 producer: info.Producer,
9581 version: info.PDFFormatVersion,
9582 pageCount: this.pdfDocument.numPages,
9583 pageSize,
9584 linearized: isLinearized,
9585 _currentPageNumber: currentPageNumber,
9586 _pagesRotation: pagesRotation
9587 });
9588 this.#updateUI();
9589 const {
9590 length
9591 } = await this.pdfDocument.getDownloadInfo();
9592 if (contentLength === length) {
9593 return;
9594 }
9595 const data = Object.assign(Object.create(null), this.#fieldData);
9596 data.fileSize = await this.#parseFileSize(length);
9597 this.#fieldData = Object.freeze(data);
9598 this.#updateUI();
9599 }
9600 async close() {
9601 this.overlayManager.close(this.dialog);
9602 this.eventBus.dispatch("propertiesdialogclose", this);
9603 }
9604 setDocument(pdfDocument) {
9605 if (this.pdfDocument) {
9606 this.#reset();
9607 this.#updateUI(true);
9608 }
9609 if (!pdfDocument) {
9610 return;
9611 }
9612 this.pdfDocument = pdfDocument;
9613 this._dataAvailableCapability.resolve();
9614 }
9615 #reset() {
9616 this.pdfDocument = null;
9617 this.#fieldData = null;
9618 this._dataAvailableCapability = Promise.withResolvers();
9619 this._currentPageNumber = 1;
9620 this._pagesRotation = 0;
9621 }
9622 #updateUI(reset = false) {
9623 if (reset || !this.#fieldData) {
9624 for (const id in this.fields) {
9625 this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
9626 }
9627 return;
9628 }
9629 if (this.overlayManager.active !== this.dialog) {
9630 return;
9631 }
9632 for (const id in this.fields) {
9633 const content = this.#fieldData[id];
9634 this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
9635 }
9636 }
9637 async #parseFileSize(fileSize = 0) {
9638 const kb = fileSize / 1024,
9639 mb = kb / 1024;
9640 if (!kb) {
9641 return undefined;
9642 }
9643 return this.l10n.get(`pdfjs-document-properties-${mb >= 1 ? "mb" : "kb"}`, {
9644 size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
9645 size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
9646 size_b: fileSize.toLocaleString()
9647 });
9648 }
9649 async #parsePageSize(pageSizeInches, pagesRotation) {
9650 if (!pageSizeInches) {
9651 return undefined;
9652 }
9653 if (pagesRotation % 180 !== 0) {
9654 pageSizeInches = {
9655 width: pageSizeInches.height,
9656 height: pageSizeInches.width
9657 };
9658 }
9659 const isPortrait = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isPortraitOrientation)(pageSizeInches);
9660 let sizeInches = {
9661 width: Math.round(pageSizeInches.width * 100) / 100,
9662 height: Math.round(pageSizeInches.height * 100) / 100
9663 };
9664 let sizeMillimeters = {
9665 width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
9666 height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
9667 };
9668 let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
9669 if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
9670 const exactMillimeters = {
9671 width: pageSizeInches.width * 25.4,
9672 height: pageSizeInches.height * 25.4
9673 };
9674 const intMillimeters = {
9675 width: Math.round(sizeMillimeters.width),
9676 height: Math.round(sizeMillimeters.height)
9677 };
9678 if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
9679 rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
9680 if (rawName) {
9681 sizeInches = {
9682 width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
9683 height: Math.round(intMillimeters.height / 25.4 * 100) / 100
9684 };
9685 sizeMillimeters = intMillimeters;
9686 }
9687 }
9688 }
9689 const [{
9690 width,
9691 height
9692 }, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get(`pdfjs-document-properties-page-size-unit-${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName && this.l10n.get(`pdfjs-document-properties-page-size-name-${rawName}`), this.l10n.get(`pdfjs-document-properties-page-size-orientation-${isPortrait ? "portrait" : "landscape"}`)]);
9693 return this.l10n.get(`pdfjs-document-properties-page-size-dimension-${name ? "name-" : ""}string`, {
9694 width: width.toLocaleString(),
9695 height: height.toLocaleString(),
9696 unit,
9697 name,
9698 orientation
9699 });
9700 }
9701 async #parseDate(inputDate) {
9702 const dateObject = pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PDFDateString.toDateObject(inputDate);
9703 if (!dateObject) {
9704 return undefined;
9705 }
9706 return this.l10n.get("pdfjs-document-properties-date-string", {
9707 date: dateObject.toLocaleDateString(),
9708 time: dateObject.toLocaleTimeString()
9709 });
9710 }
9711 #parseLinearization(isLinearized) {
9712 return this.l10n.get(`pdfjs-document-properties-linearized-${isLinearized ? "yes" : "no"}`);
9713 }
9714}
9715
9716__webpack_async_result__();
9717} catch(e) { __webpack_async_result__(e); } });
9718
9719/***/ }),
9720
9721/***/ 2226:
9722/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9723
9724/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9725/* harmony export */ PDFFindBar: () => (/* binding */ PDFFindBar)
9726/* harmony export */ });
9727/* harmony import */ var _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9814);
9728/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
9729
9730
9731const MATCHES_COUNT_LIMIT = 1000;
9732class PDFFindBar {
9733 #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
9734 constructor(options, eventBus) {
9735 this.opened = false;
9736 this.bar = options.bar;
9737 this.toggleButton = options.toggleButton;
9738 this.findField = options.findField;
9739 this.highlightAll = options.highlightAllCheckbox;
9740 this.currentPage = options.findCurrentPageCheckbox;
9741 this.pageRange = options.findPageRangeField;
9742 this.caseSensitive = options.caseSensitiveCheckbox;
9743 this.matchDiacritics = options.matchDiacriticsCheckbox;
9744 this.entireWord = options.entireWordCheckbox;
9745 this.findMsg = options.findMsg;
9746 this.findResultsCount = options.findResultsCount;
9747 this.findPreviousButton = options.findPreviousButton;
9748 this.findNextButton = options.findNextButton;
9749 this.eventBus = eventBus;
9750 this.toggleButton.addEventListener("click", () => {
9751 this.toggle();
9752 });
9753 this.findField.addEventListener("input", () => {
9754 this.dispatchEvent("");
9755 });
9756 this.bar.addEventListener("keydown", e => {
9757 switch (e.keyCode) {
9758 case 13:
9759 if (e.target === this.findField) {
9760 this.dispatchEvent("again", e.shiftKey);
9761 }
9762 break;
9763 case 27:
9764 this.close();
9765 break;
9766 }
9767 });
9768 this.findPreviousButton.addEventListener("click", () => {
9769 this.dispatchEvent("again", true);
9770 });
9771 this.findNextButton.addEventListener("click", () => {
9772 this.dispatchEvent("again", false);
9773 });
9774 this.highlightAll.addEventListener("click", () => {
9775 this.dispatchEvent("highlightallchange");
9776 });
9777 this.caseSensitive.addEventListener("click", () => {
9778 this.dispatchEvent("casesensitivitychange");
9779 });
9780 this.entireWord.addEventListener("click", () => {
9781 this.dispatchEvent("entirewordchange");
9782 });
9783 this.matchDiacritics?.addEventListener("click", () => {
9784 this.dispatchEvent("diacriticmatchingchange");
9785 });
9786 }
9787 reset() {
9788 this.updateUIState();
9789 }
9790 dispatchEvent(type, findPrev = false) {
9791 this.eventBus.dispatch("find", {
9792 source: this,
9793 type,
9794 query: this.findField.value,
9795 caseSensitive: this.caseSensitive.checked,
9796 entireWord: this.entireWord.checked,
9797 highlightAll: this.highlightAll.checked,
9798 findPrevious: findPrev,
9799 matchDiacritics: this.matchDiacritics.checked
9800 });
9801 }
9802 updateUIState(state, previous, matchesCount) {
9803 const {
9804 findField,
9805 findMsg
9806 } = this;
9807 let findMsgId = "",
9808 status = "";
9809 switch (state) {
9810 case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.FOUND:
9811 break;
9812 case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.PENDING:
9813 status = "pending";
9814 break;
9815 case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.NOT_FOUND:
9816 findMsgId = "pdfjs-find-not-found";
9817 status = "notFound";
9818 break;
9819 case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.WRAPPED:
9820 findMsgId = `pdfjs-find-reached-${previous ? "top" : "bottom"}`;
9821 break;
9822 }
9823 findField.setAttribute("data-status", status);
9824 findField.setAttribute("aria-invalid", state === _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.NOT_FOUND);
9825 findMsg.setAttribute("data-status", status);
9826 if (findMsgId) {
9827 findMsg.setAttribute("data-l10n-id", findMsgId);
9828 } else {
9829 findMsg.removeAttribute("data-l10n-id");
9830 findMsg.textContent = "";
9831 }
9832 this.updateResultsCount(matchesCount);
9833 }
9834 updateResultsCount({
9835 current = 0,
9836 total = 0
9837 } = {}) {
9838 const {
9839 findResultsCount
9840 } = this;
9841 if (total > 0) {
9842 const limit = MATCHES_COUNT_LIMIT;
9843 findResultsCount.setAttribute("data-l10n-id", `pdfjs-find-match-count${total > limit ? "-limit" : ""}`);
9844 findResultsCount.setAttribute("data-l10n-args", JSON.stringify({
9845 limit,
9846 current,
9847 total
9848 }));
9849 } else {
9850 findResultsCount.removeAttribute("data-l10n-id");
9851 findResultsCount.textContent = "";
9852 }
9853 }
9854 open() {
9855 if (!this.opened) {
9856 this.#resizeObserver.observe(this.bar.parentNode);
9857 this.#resizeObserver.observe(this.bar);
9858 this.opened = true;
9859 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleExpandedBtn)(this.toggleButton, true, this.bar);
9860 }
9861 this.findField.select();
9862 this.findField.focus();
9863 this.dispatchEvent("");
9864 this.eventBus.dispatch("findbaropen", {
9865 source: this
9866 });
9867 }
9868 close() {
9869 if (!this.opened) {
9870 return;
9871 }
9872 this.#resizeObserver.disconnect();
9873 this.opened = false;
9874 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleExpandedBtn)(this.toggleButton, false, this.bar);
9875 this.eventBus.dispatch("findbarclose", {
9876 source: this
9877 });
9878 }
9879 toggle() {
9880 if (this.opened) {
9881 this.close();
9882 } else {
9883 this.open();
9884 }
9885 }
9886 #resizeObserverCallback(entries) {
9887 const {
9888 bar
9889 } = this;
9890 bar.classList.remove("wrapContainers");
9891 const findbarHeight = bar.clientHeight;
9892 const inputContainerHeight = bar.firstElementChild.clientHeight;
9893 if (findbarHeight > inputContainerHeight) {
9894 bar.classList.add("wrapContainers");
9895 }
9896 }
9897}
9898
9899
9900/***/ }),
9901
9902/***/ 9814:
9903/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9904
9905
9906// EXPORTS
9907__webpack_require__.d(__webpack_exports__, {
9908 FindState: () => (/* binding */ FindState),
9909 PDFFindController: () => (/* binding */ PDFFindController)
9910});
9911
9912// EXTERNAL MODULE: ./web/ui_utils.js
9913var ui_utils = __webpack_require__(7256);
9914;// CONCATENATED MODULE: ./web/pdf_find_utils.js
9915const CharacterType = {
9916 SPACE: 0,
9917 ALPHA_LETTER: 1,
9918 PUNCT: 2,
9919 HAN_LETTER: 3,
9920 KATAKANA_LETTER: 4,
9921 HIRAGANA_LETTER: 5,
9922 HALFWIDTH_KATAKANA_LETTER: 6,
9923 THAI_LETTER: 7
9924};
9925function isAlphabeticalScript(charCode) {
9926 return charCode < 0x2e80;
9927}
9928function isAscii(charCode) {
9929 return (charCode & 0xff80) === 0;
9930}
9931function isAsciiAlpha(charCode) {
9932 return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
9933}
9934function isAsciiDigit(charCode) {
9935 return charCode >= 0x30 && charCode <= 0x39;
9936}
9937function isAsciiSpace(charCode) {
9938 return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
9939}
9940function isHan(charCode) {
9941 return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
9942}
9943function isKatakana(charCode) {
9944 return charCode >= 0x30a0 && charCode <= 0x30ff;
9945}
9946function isHiragana(charCode) {
9947 return charCode >= 0x3040 && charCode <= 0x309f;
9948}
9949function isHalfwidthKatakana(charCode) {
9950 return charCode >= 0xff60 && charCode <= 0xff9f;
9951}
9952function isThai(charCode) {
9953 return (charCode & 0xff80) === 0x0e00;
9954}
9955function getCharacterType(charCode) {
9956 if (isAlphabeticalScript(charCode)) {
9957 if (isAscii(charCode)) {
9958 if (isAsciiSpace(charCode)) {
9959 return CharacterType.SPACE;
9960 } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
9961 return CharacterType.ALPHA_LETTER;
9962 }
9963 return CharacterType.PUNCT;
9964 } else if (isThai(charCode)) {
9965 return CharacterType.THAI_LETTER;
9966 } else if (charCode === 0xa0) {
9967 return CharacterType.SPACE;
9968 }
9969 return CharacterType.ALPHA_LETTER;
9970 }
9971 if (isHan(charCode)) {
9972 return CharacterType.HAN_LETTER;
9973 } else if (isKatakana(charCode)) {
9974 return CharacterType.KATAKANA_LETTER;
9975 } else if (isHiragana(charCode)) {
9976 return CharacterType.HIRAGANA_LETTER;
9977 } else if (isHalfwidthKatakana(charCode)) {
9978 return CharacterType.HALFWIDTH_KATAKANA_LETTER;
9979 }
9980 return CharacterType.ALPHA_LETTER;
9981}
9982let NormalizeWithNFKC;
9983function getNormalizeWithNFKC() {
9984 NormalizeWithNFKC ||= ` ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`;
9985 return NormalizeWithNFKC;
9986}
9987
9988;// CONCATENATED MODULE: ./web/pdf_find_controller.js
9989
9990
9991const FindState = {
9992 FOUND: 0,
9993 NOT_FOUND: 1,
9994 WRAPPED: 2,
9995 PENDING: 3
9996};
9997const FIND_TIMEOUT = 250;
9998const MATCH_SCROLL_OFFSET_TOP = -50;
9999const MATCH_SCROLL_OFFSET_LEFT = -400;
10000const CHARACTERS_TO_NORMALIZE = {
10001 "\u2010": "-",
10002 "\u2018": "'",
10003 "\u2019": "'",
10004 "\u201A": "'",
10005 "\u201B": "'",
10006 "\u201C": '"',
10007 "\u201D": '"',
10008 "\u201E": '"',
10009 "\u201F": '"',
10010 "\u00BC": "1/4",
10011 "\u00BD": "1/2",
10012 "\u00BE": "3/4"
10013};
10014const 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]);
10015let DIACRITICS_EXCEPTION_STR;
10016const DIACRITICS_REG_EXP = /\p{M}+/gu;
10017const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
10018const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
10019const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
10020const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
10021const SYLLABLES_LENGTHS = new Map();
10022const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
10023const NFKC_CHARS_TO_NORMALIZE = new Map();
10024let noSyllablesRegExp = null;
10025let withSyllablesRegExp = null;
10026function normalize(text) {
10027 const syllablePositions = [];
10028 let m;
10029 while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
10030 let {
10031 index
10032 } = m;
10033 for (const char of m[0]) {
10034 let len = SYLLABLES_LENGTHS.get(char);
10035 if (!len) {
10036 len = char.normalize("NFD").length;
10037 SYLLABLES_LENGTHS.set(char, len);
10038 }
10039 syllablePositions.push([len, index++]);
10040 }
10041 }
10042 let normalizationRegex;
10043 if (syllablePositions.length === 0 && noSyllablesRegExp) {
10044 normalizationRegex = noSyllablesRegExp;
10045 } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
10046 normalizationRegex = withSyllablesRegExp;
10047 } else {
10048 const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
10049 const toNormalizeWithNFKC = getNormalizeWithNFKC();
10050 const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
10051 const HKDiacritics = "(?:\u3099|\u309A)";
10052 const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
10053 if (syllablePositions.length === 0) {
10054 normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
10055 } else {
10056 normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
10057 }
10058 }
10059 const rawDiacriticsPositions = [];
10060 while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
10061 rawDiacriticsPositions.push([m[0].length, m.index]);
10062 }
10063 let normalized = text.normalize("NFD");
10064 const positions = [[0, 0]];
10065 let rawDiacriticsIndex = 0;
10066 let syllableIndex = 0;
10067 let shift = 0;
10068 let shiftOrigin = 0;
10069 let eol = 0;
10070 let hasDiacritics = false;
10071 normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => {
10072 i -= shiftOrigin;
10073 if (p1) {
10074 const replacement = CHARACTERS_TO_NORMALIZE[p1];
10075 const jj = replacement.length;
10076 for (let j = 1; j < jj; j++) {
10077 positions.push([i - shift + j, shift - j]);
10078 }
10079 shift -= jj - 1;
10080 return replacement;
10081 }
10082 if (p2) {
10083 let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
10084 if (!replacement) {
10085 replacement = p2.normalize("NFKC");
10086 NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
10087 }
10088 const jj = replacement.length;
10089 for (let j = 1; j < jj; j++) {
10090 positions.push([i - shift + j, shift - j]);
10091 }
10092 shift -= jj - 1;
10093 return replacement;
10094 }
10095 if (p3) {
10096 hasDiacritics = true;
10097 if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
10098 ++rawDiacriticsIndex;
10099 } else {
10100 positions.push([i - 1 - shift + 1, shift - 1]);
10101 shift -= 1;
10102 shiftOrigin += 1;
10103 }
10104 positions.push([i - shift + 1, shift]);
10105 shiftOrigin += 1;
10106 eol += 1;
10107 return p3.charAt(0);
10108 }
10109 if (p4) {
10110 const hasTrailingDashEOL = p4.endsWith("\n");
10111 const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
10112 hasDiacritics = true;
10113 let jj = len;
10114 if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
10115 jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
10116 ++rawDiacriticsIndex;
10117 }
10118 for (let j = 1; j <= jj; j++) {
10119 positions.push([i - 1 - shift + j, shift - j]);
10120 }
10121 shift -= jj;
10122 shiftOrigin += jj;
10123 if (hasTrailingDashEOL) {
10124 i += len - 1;
10125 positions.push([i - shift + 1, 1 + shift]);
10126 shift += 1;
10127 shiftOrigin += 1;
10128 eol += 1;
10129 return p4.slice(0, len);
10130 }
10131 return p4;
10132 }
10133 if (p5) {
10134 const len = p5.length - 2;
10135 positions.push([i - shift + len, 1 + shift]);
10136 shift += 1;
10137 shiftOrigin += 1;
10138 eol += 1;
10139 return p5.slice(0, -2);
10140 }
10141 if (p6) {
10142 const len = p6.length - 1;
10143 positions.push([i - shift + len, shift]);
10144 shiftOrigin += 1;
10145 eol += 1;
10146 return p6.slice(0, -1);
10147 }
10148 if (p7) {
10149 positions.push([i - shift + 1, shift - 1]);
10150 shift -= 1;
10151 shiftOrigin += 1;
10152 eol += 1;
10153 return " ";
10154 }
10155 if (i + eol === syllablePositions[syllableIndex]?.[1]) {
10156 const newCharLen = syllablePositions[syllableIndex][0] - 1;
10157 ++syllableIndex;
10158 for (let j = 1; j <= newCharLen; j++) {
10159 positions.push([i - (shift - j), shift - j]);
10160 }
10161 shift -= newCharLen;
10162 shiftOrigin += newCharLen;
10163 }
10164 return p8;
10165 });
10166 positions.push([normalized.length, shift]);
10167 return [normalized, positions, hasDiacritics];
10168}
10169function getOriginalIndex(diffs, pos, len) {
10170 if (!diffs) {
10171 return [pos, len];
10172 }
10173 const start = pos;
10174 const end = pos + len - 1;
10175 let i = (0,ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start);
10176 if (diffs[i][0] > start) {
10177 --i;
10178 }
10179 let j = (0,ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
10180 if (diffs[j][0] > end) {
10181 --j;
10182 }
10183 const oldStart = start + diffs[i][1];
10184 const oldEnd = end + diffs[j][1];
10185 const oldLen = oldEnd + 1 - oldStart;
10186 return [oldStart, oldLen];
10187}
10188class PDFFindController {
10189 #state = null;
10190 #updateMatchesCountOnProgress = true;
10191 #visitedPagesCount = 0;
10192 constructor({
10193 linkService,
10194 eventBus,
10195 updateMatchesCountOnProgress = true,
10196 pageViewMode
10197 }) {
10198 this._linkService = linkService;
10199 this._eventBus = eventBus;
10200 this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress;
10201 this._pageViewMode = pageViewMode;
10202 this.onIsPageVisible = null;
10203 this.#reset();
10204 eventBus._on("find", this.#onFind.bind(this));
10205 eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
10206 }
10207 get highlightMatches() {
10208 return this._highlightMatches;
10209 }
10210 get pageMatches() {
10211 return this._pageMatches;
10212 }
10213 get pageMatchesLength() {
10214 return this._pageMatchesLength;
10215 }
10216 get selected() {
10217 return this._selected;
10218 }
10219 get state() {
10220 return this.#state;
10221 }
10222 setDocument(pdfDocument) {
10223 if (this._pdfDocument) {
10224 this.#reset();
10225 }
10226 if (!pdfDocument) {
10227 return;
10228 }
10229 this._pdfDocument = pdfDocument;
10230 this._firstPageCapability.resolve();
10231 }
10232 #onFind(state) {
10233 if (!state) {
10234 return;
10235 }
10236 const pdfDocument = this._pdfDocument;
10237 const {
10238 type
10239 } = state;
10240 if (this.#state === null || this.#shouldDirtyMatch(state)) {
10241 this._dirtyMatch = true;
10242 }
10243 this.#state = state;
10244 if (type !== "highlightallchange") {
10245 this.#updateUIState(FindState.PENDING);
10246 } else {
10247 const hasMatches = this._pageMatches.some(matches => matches.length > 0);
10248 const emptyQuery = !this.state?.query;
10249 const reportAsFound = emptyQuery || hasMatches;
10250 this.#updateUIState(reportAsFound ? FindState.FOUND : FindState.NOT_FOUND);
10251 }
10252 this._firstPageCapability.promise.then(() => {
10253 if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
10254 return;
10255 }
10256 this.#extractText();
10257 const findbarClosed = !this._highlightMatches;
10258 const pendingTimeout = !!this._findTimeout;
10259 if (this._findTimeout) {
10260 clearTimeout(this._findTimeout);
10261 this._findTimeout = null;
10262 }
10263 if (!type) {
10264 this._findTimeout = setTimeout(() => {
10265 this.#nextMatch();
10266 this._findTimeout = null;
10267 }, FIND_TIMEOUT);
10268 } else if (this._dirtyMatch) {
10269 this.#nextMatch();
10270 } else if (type === "again") {
10271 this.#nextMatch();
10272 if (findbarClosed && this.#state.highlightAll) {
10273 this.#updateAllPages();
10274 }
10275 } else if (type === "highlightallchange") {
10276 if (pendingTimeout) {
10277 this.#nextMatch();
10278 } else {
10279 this._highlightMatches = true;
10280 }
10281 this.#updateAllPages();
10282 } else {
10283 this.#nextMatch();
10284 }
10285 });
10286 }
10287 scrollMatchIntoView({
10288 element = null,
10289 selectedLeft = 0,
10290 pageIndex = -1,
10291 matchIndex = -1
10292 }) {
10293 if (!this._scrollMatches || !element) {
10294 return;
10295 } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
10296 return;
10297 } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
10298 return;
10299 }
10300 this._scrollMatches = false;
10301 const spot = {
10302 top: MATCH_SCROLL_OFFSET_TOP,
10303 left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
10304 };
10305 (0,ui_utils.scrollIntoView)(element, spot, true, this._pageViewMode === 'infinite-scroll');
10306 }
10307 #reset() {
10308 this._highlightMatches = false;
10309 this._scrollMatches = false;
10310 this._pdfDocument = null;
10311 this._pageMatches = [];
10312 this._pageMatchesLength = [];
10313 this.#visitedPagesCount = 0;
10314 this.#state = null;
10315 this._selected = {
10316 pageIdx: -1,
10317 matchIdx: -1
10318 };
10319 this._offset = {
10320 pageIdx: null,
10321 matchIdx: null,
10322 wrapped: false
10323 };
10324 this._extractTextPromises = [];
10325 this._pageContents = [];
10326 this._pageDiffs = [];
10327 this._hasDiacritics = [];
10328 this._matchesCountTotal = 0;
10329 this._pagesToSearch = null;
10330 this._pendingFindMatches = new Set();
10331 this._resumePageIdx = null;
10332 this._dirtyMatch = false;
10333 clearTimeout(this._findTimeout);
10334 this._findTimeout = null;
10335 this._firstPageCapability = Promise.withResolvers();
10336 }
10337 get #query() {
10338 const {
10339 query
10340 } = this.#state;
10341 if (typeof query === "string") {
10342 if (query !== this._rawQuery) {
10343 this._rawQuery = query;
10344 [this._normalizedQuery] = normalize(query);
10345 }
10346 return this._normalizedQuery;
10347 }
10348 return (query || []).filter(q => !!q).map(q => normalize(q)[0]);
10349 }
10350 #shouldDirtyMatch(state) {
10351 const newQuery = state.query,
10352 prevQuery = this.#state.query;
10353 const newType = typeof newQuery,
10354 prevType = typeof prevQuery;
10355 if (newType !== prevType) {
10356 return true;
10357 }
10358 if (newType === "string") {
10359 if (newQuery !== prevQuery) {
10360 return true;
10361 }
10362 } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
10363 return true;
10364 }
10365 switch (state.type) {
10366 case "again":
10367 const pageNumber = this._selected.pageIdx + 1;
10368 const linkService = this._linkService;
10369 return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true);
10370 case "highlightallchange":
10371 return false;
10372 }
10373 return true;
10374 }
10375 #isEntireWord(content, startIdx, length) {
10376 let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
10377 if (match) {
10378 const first = content.charCodeAt(startIdx);
10379 const limit = match[1].charCodeAt(0);
10380 if (getCharacterType(first) === getCharacterType(limit)) {
10381 return false;
10382 }
10383 }
10384 match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
10385 if (match) {
10386 const last = content.charCodeAt(startIdx + length - 1);
10387 const limit = match[1].charCodeAt(0);
10388 if (getCharacterType(last) === getCharacterType(limit)) {
10389 return false;
10390 }
10391 }
10392 return true;
10393 }
10394 #calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
10395 const matches = this._pageMatches[pageIndex] = [];
10396 const matchesLength = this._pageMatchesLength[pageIndex] = [];
10397 if (!query) {
10398 return;
10399 }
10400 const diffs = this._pageDiffs[pageIndex];
10401 let match;
10402 while ((match = query.exec(pageContent)) !== null) {
10403 if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
10404 continue;
10405 }
10406 const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
10407 if (matchLen) {
10408 matches.push(matchPos);
10409 matchesLength.push(matchLen);
10410 }
10411 }
10412 }
10413 #convertToRegExpString(query, hasDiacritics) {
10414 const {
10415 matchDiacritics
10416 } = this.#state;
10417 let isUnicode = false;
10418 query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
10419 if (p1) {
10420 return `[ ]*\\${p1}[ ]*`;
10421 }
10422 if (p2) {
10423 return `[ ]*${p2}[ ]*`;
10424 }
10425 if (p3) {
10426 return "[ ]+";
10427 }
10428 if (matchDiacritics) {
10429 return p4 || p5;
10430 }
10431 if (p4) {
10432 return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
10433 }
10434 if (hasDiacritics) {
10435 isUnicode = true;
10436 return `${p5}\\p{M}*`;
10437 }
10438 return p5;
10439 });
10440 const trailingSpaces = "[ ]*";
10441 if (query.endsWith(trailingSpaces)) {
10442 query = query.slice(0, query.length - trailingSpaces.length);
10443 }
10444 if (matchDiacritics) {
10445 if (hasDiacritics) {
10446 DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION);
10447 isUnicode = true;
10448 query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
10449 }
10450 }
10451 return [isUnicode, query];
10452 }
10453 #calculateMatch(pageIndex) {
10454 let query = this.#query;
10455 if (query.length === 0) {
10456 return;
10457 }
10458 const {
10459 caseSensitive,
10460 entireWord
10461 } = this.#state;
10462 const pageContent = this._pageContents[pageIndex];
10463 const hasDiacritics = this._hasDiacritics[pageIndex];
10464 let isUnicode = false;
10465 if (typeof query === "string") {
10466 [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
10467 } else {
10468 query = query.sort().reverse().map(q => {
10469 const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
10470 isUnicode ||= isUnicodePart;
10471 return `(${queryPart})`;
10472 }).join("|");
10473 }
10474 const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
10475 query = query ? new RegExp(query, flags) : null;
10476 this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
10477 if (this.#state.highlightAll) {
10478 this.#updatePage(pageIndex);
10479 }
10480 if (this._resumePageIdx === pageIndex) {
10481 this._resumePageIdx = null;
10482 this.#nextPageMatch();
10483 }
10484 const pageMatchesCount = this._pageMatches[pageIndex].length;
10485 this._matchesCountTotal += pageMatchesCount;
10486 if (this.#updateMatchesCountOnProgress) {
10487 if (pageMatchesCount > 0) {
10488 this.#updateUIResultsCount();
10489 }
10490 } else if (++this.#visitedPagesCount === this._linkService.pagesCount) {
10491 this.#updateUIResultsCount();
10492 }
10493 }
10494 #extractText() {
10495 if (this._extractTextPromises.length > 0) {
10496 return;
10497 }
10498 let deferred = Promise.resolve();
10499 const textOptions = {
10500 disableNormalization: true
10501 };
10502 for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
10503 const {
10504 promise,
10505 resolve
10506 } = Promise.withResolvers();
10507 this._extractTextPromises[i] = promise;
10508 deferred = deferred.then(() => {
10509 return this._pdfDocument.getPage(i + 1).then(pdfPage => pdfPage.getTextContent(textOptions)).then(textContent => {
10510 const strBuf = [];
10511 for (const textItem of textContent.items) {
10512 strBuf.push(textItem.str);
10513 if (textItem.hasEOL) {
10514 strBuf.push("\n");
10515 }
10516 }
10517 [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
10518 resolve();
10519 }, reason => {
10520 console.error(`Unable to get text content for page ${i + 1}`, reason);
10521 this._pageContents[i] = "";
10522 this._pageDiffs[i] = null;
10523 this._hasDiacritics[i] = false;
10524 resolve();
10525 });
10526 });
10527 }
10528 }
10529 #updatePage(index) {
10530 if (this._scrollMatches && this._selected.pageIdx === index) {
10531 this._linkService.page = index + 1;
10532 }
10533 this._eventBus.dispatch("updatetextlayermatches", {
10534 source: this,
10535 pageIndex: index
10536 });
10537 }
10538 #updateAllPages() {
10539 this._eventBus.dispatch("updatetextlayermatches", {
10540 source: this,
10541 pageIndex: -1
10542 });
10543 }
10544 #nextMatch() {
10545 const previous = this.#state.findPrevious;
10546 const currentPageIndex = this._linkService.page - 1;
10547 const numPages = this._linkService.pagesCount;
10548 this._highlightMatches = true;
10549 if (this._dirtyMatch) {
10550 this._dirtyMatch = false;
10551 this._selected.pageIdx = this._selected.matchIdx = -1;
10552 this._offset.pageIdx = currentPageIndex;
10553 this._offset.matchIdx = null;
10554 this._offset.wrapped = false;
10555 this._resumePageIdx = null;
10556 this._pageMatches.length = 0;
10557 this._pageMatchesLength.length = 0;
10558 this.#visitedPagesCount = 0;
10559 this._matchesCountTotal = 0;
10560 this.#updateAllPages();
10561 for (let i = 0; i < numPages; i++) {
10562 if (this._pendingFindMatches.has(i)) {
10563 continue;
10564 }
10565 this._pendingFindMatches.add(i);
10566 this._extractTextPromises[i].then(() => {
10567 this._pendingFindMatches.delete(i);
10568 this.#calculateMatch(i);
10569 });
10570 }
10571 }
10572 const query = this.#query;
10573 if (query.length === 0) {
10574 this.#updateUIState(FindState.FOUND);
10575 return;
10576 }
10577 if (this._resumePageIdx) {
10578 return;
10579 }
10580 const offset = this._offset;
10581 this._pagesToSearch = numPages;
10582 if (offset.matchIdx !== null) {
10583 const numPageMatches = this._pageMatches[offset.pageIdx].length;
10584 if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
10585 offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
10586 this.#updateMatch(true);
10587 return;
10588 }
10589 this.#advanceOffsetPage(previous);
10590 }
10591 this.#nextPageMatch();
10592 }
10593 #matchesReady(matches) {
10594 const offset = this._offset;
10595 const numMatches = matches.length;
10596 const previous = this.#state.findPrevious;
10597 if (numMatches) {
10598 offset.matchIdx = previous ? numMatches - 1 : 0;
10599 this.#updateMatch(true);
10600 return true;
10601 }
10602 this.#advanceOffsetPage(previous);
10603 if (offset.wrapped) {
10604 offset.matchIdx = null;
10605 if (this._pagesToSearch < 0) {
10606 this.#updateMatch(false);
10607 return true;
10608 }
10609 }
10610 return false;
10611 }
10612 #nextPageMatch() {
10613 if (this._resumePageIdx !== null) {
10614 console.error("There can only be one pending page.");
10615 }
10616 let matches = null;
10617 do {
10618 const pageIdx = this._offset.pageIdx;
10619 matches = this._pageMatches[pageIdx];
10620 if (!matches) {
10621 this._resumePageIdx = pageIdx;
10622 break;
10623 }
10624 } while (!this.#matchesReady(matches));
10625 }
10626 #advanceOffsetPage(previous) {
10627 const offset = this._offset;
10628 const numPages = this._linkService.pagesCount;
10629 offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
10630 offset.matchIdx = null;
10631 this._pagesToSearch--;
10632 if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
10633 offset.pageIdx = previous ? numPages - 1 : 0;
10634 offset.wrapped = true;
10635 }
10636 }
10637 #updateMatch(found = false) {
10638 let state = FindState.NOT_FOUND;
10639 const wrapped = this._offset.wrapped;
10640 this._offset.wrapped = false;
10641 if (found) {
10642 const previousPage = this._selected.pageIdx;
10643 this._selected.pageIdx = this._offset.pageIdx;
10644 this._selected.matchIdx = this._offset.matchIdx;
10645 state = wrapped ? FindState.WRAPPED : FindState.FOUND;
10646 if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
10647 this.#updatePage(previousPage);
10648 }
10649 }
10650 this.#updateUIState(state, this.#state.findPrevious);
10651 if (this._selected.pageIdx !== -1) {
10652 this._scrollMatches = true;
10653 this.#updatePage(this._selected.pageIdx);
10654 }
10655 }
10656 #onFindBarClose(evt) {
10657 const pdfDocument = this._pdfDocument;
10658 this._firstPageCapability.promise.then(() => {
10659 if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
10660 return;
10661 }
10662 if (this._findTimeout) {
10663 clearTimeout(this._findTimeout);
10664 this._findTimeout = null;
10665 }
10666 if (this._resumePageIdx) {
10667 this._resumePageIdx = null;
10668 this._dirtyMatch = true;
10669 }
10670 this.#updateUIState(FindState.FOUND);
10671 this._highlightMatches = false;
10672 this.#updateAllPages();
10673 });
10674 }
10675 #requestMatchesCount() {
10676 const {
10677 pageIdx,
10678 matchIdx
10679 } = this._selected;
10680 let current = 0,
10681 total = this._matchesCountTotal;
10682 if (matchIdx !== -1) {
10683 for (let i = 0; i < pageIdx; i++) {
10684 current += this._pageMatches[i]?.length || 0;
10685 }
10686 current += matchIdx + 1;
10687 }
10688 if (current < 1 || current > total) {
10689 current = total = 0;
10690 }
10691 return {
10692 current,
10693 total
10694 };
10695 }
10696 #updateUIResultsCount() {
10697 this._eventBus.dispatch("updatefindmatchescount", {
10698 source: this,
10699 matchesCount: this.#requestMatchesCount()
10700 });
10701 }
10702 #updateUIState(state, previous = false) {
10703 if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) {
10704 return;
10705 }
10706 this._eventBus.dispatch("updatefindcontrolstate", {
10707 source: this,
10708 state,
10709 previous,
10710 matchesCount: this.#requestMatchesCount(),
10711 rawQuery: this.#state?.query ?? null
10712 });
10713 }
10714}
10715
10716
10717/***/ }),
10718
10719/***/ 8543:
10720/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10721
10722/* harmony export */ __webpack_require__.d(__webpack_exports__, {
10723/* harmony export */ PDFHistory: () => (/* binding */ PDFHistory)
10724/* harmony export */ });
10725/* unused harmony exports isDestArraysEqual, isDestHashesEqual */
10726/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
10727/* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5656);
10728
10729
10730const HASH_CHANGE_TIMEOUT = 1000;
10731const POSITION_UPDATED_THRESHOLD = 50;
10732const UPDATE_VIEWAREA_TIMEOUT = 1000;
10733function getCurrentHash() {
10734 return document.location.hash;
10735}
10736class PDFHistory {
10737 #eventAbortController = null;
10738 constructor({
10739 linkService,
10740 eventBus
10741 }) {
10742 this.linkService = linkService;
10743 this.eventBus = eventBus;
10744 this._initialized = false;
10745 this._fingerprint = "";
10746 this.reset();
10747 this.eventBus._on("pagesinit", () => {
10748 this._isPagesLoaded = false;
10749 this.eventBus._on("pagesloaded", evt => {
10750 this._isPagesLoaded = !!evt.pagesCount;
10751 }, {
10752 once: true
10753 });
10754 });
10755 }
10756 initialize({
10757 fingerprint,
10758 resetHistory = false,
10759 updateUrl = false
10760 }) {
10761 if (!fingerprint || typeof fingerprint !== "string") {
10762 globalThis.ngxConsole.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
10763 return;
10764 }
10765 if (this._initialized) {
10766 this.reset();
10767 }
10768 const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
10769 this._fingerprint = fingerprint;
10770 this._updateUrl = updateUrl === true;
10771 this._initialized = true;
10772 this.#bindEvents();
10773 const state = window.history.state;
10774 this._popStateInProgress = false;
10775 this._blockHashChange = 0;
10776 this._currentHash = getCurrentHash();
10777 this._numPositionUpdates = 0;
10778 this._uid = this._maxUid = 0;
10779 this._destination = null;
10780 this._position = null;
10781 if (!this.#isValidState(state, true) || resetHistory) {
10782 const {
10783 hash,
10784 page,
10785 rotation
10786 } = this.#parseCurrentHash(true);
10787 if (!hash || reInitialized || resetHistory) {
10788 this.#pushOrReplaceState(null, true);
10789 return;
10790 }
10791 this.#pushOrReplaceState({
10792 hash,
10793 page,
10794 rotation
10795 }, true);
10796 return;
10797 }
10798 const destination = state.destination;
10799 this.#updateInternalState(destination, state.uid, true);
10800 if (destination.rotation !== undefined) {
10801 this._initialRotation = destination.rotation;
10802 }
10803 if (destination.dest) {
10804 this._initialBookmark = JSON.stringify(destination.dest);
10805 this._destination.page = null;
10806 } else if (destination.hash) {
10807 this._initialBookmark = destination.hash;
10808 } else if (destination.page) {
10809 this._initialBookmark = `page=${destination.page}`;
10810 }
10811 }
10812 reset() {
10813 if (this._initialized) {
10814 this.#pageHide();
10815 this._initialized = false;
10816 this.#unbindEvents();
10817 }
10818 if (this._updateViewareaTimeout) {
10819 clearTimeout(this._updateViewareaTimeout);
10820 this._updateViewareaTimeout = null;
10821 }
10822 this._initialBookmark = null;
10823 this._initialRotation = null;
10824 }
10825 push({
10826 namedDest = null,
10827 explicitDest,
10828 pageNumber
10829 }) {
10830 if (!this._initialized) {
10831 return;
10832 }
10833 if (namedDest && typeof namedDest !== "string") {
10834 globalThis.ngxConsole.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
10835 return;
10836 } else if (!Array.isArray(explicitDest)) {
10837 globalThis.ngxConsole.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
10838 return;
10839 } else if (!this.#isValidPage(pageNumber)) {
10840 if (pageNumber !== null || this._destination) {
10841 globalThis.ngxConsole.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
10842 return;
10843 }
10844 }
10845 const hash = namedDest || JSON.stringify(explicitDest);
10846 if (!hash) {
10847 return;
10848 }
10849 let forceReplace = false;
10850 if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
10851 if (this._destination.page) {
10852 return;
10853 }
10854 forceReplace = true;
10855 }
10856 if (this._popStateInProgress && !forceReplace) {
10857 return;
10858 }
10859 this.#pushOrReplaceState({
10860 dest: explicitDest,
10861 hash,
10862 page: pageNumber,
10863 rotation: this.linkService.rotation
10864 }, forceReplace);
10865 if (!this._popStateInProgress) {
10866 this._popStateInProgress = true;
10867 Promise.resolve().then(() => {
10868 this._popStateInProgress = false;
10869 });
10870 }
10871 }
10872 pushPage(pageNumber) {
10873 if (!this._initialized) {
10874 return;
10875 }
10876 if (!this.#isValidPage(pageNumber)) {
10877 globalThis.ngxConsole.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
10878 return;
10879 }
10880 if (this._destination?.page === pageNumber) {
10881 return;
10882 }
10883 if (this._popStateInProgress) {
10884 return;
10885 }
10886 this.#pushOrReplaceState({
10887 dest: null,
10888 hash: `page=${pageNumber}`,
10889 page: pageNumber,
10890 rotation: this.linkService.rotation
10891 });
10892 if (!this._popStateInProgress) {
10893 this._popStateInProgress = true;
10894 Promise.resolve().then(() => {
10895 this._popStateInProgress = false;
10896 });
10897 }
10898 }
10899 pushCurrentPosition() {
10900 if (!this._initialized || this._popStateInProgress) {
10901 return;
10902 }
10903 this.#tryPushCurrentPosition();
10904 }
10905 back() {
10906 if (!this._initialized || this._popStateInProgress) {
10907 return;
10908 }
10909 const state = window.history.state;
10910 if (this.#isValidState(state) && state.uid > 0) {
10911 window.history.back();
10912 }
10913 }
10914 forward() {
10915 if (!this._initialized || this._popStateInProgress) {
10916 return;
10917 }
10918 const state = window.history.state;
10919 if (this.#isValidState(state) && state.uid < this._maxUid) {
10920 window.history.forward();
10921 }
10922 }
10923 get popStateInProgress() {
10924 return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
10925 }
10926 get initialBookmark() {
10927 return this._initialized ? this._initialBookmark : null;
10928 }
10929 get initialRotation() {
10930 return this._initialized ? this._initialRotation : null;
10931 }
10932 #pushOrReplaceState(destination, forceReplace = false) {
10933 const shouldReplace = forceReplace || !this._destination;
10934 const newState = {
10935 fingerprint: this._fingerprint,
10936 uid: shouldReplace ? this._uid : this._uid + 1,
10937 destination
10938 };
10939 this.#updateInternalState(destination, newState.uid);
10940 let newUrl;
10941 if (this._updateUrl && destination?.hash) {
10942 const baseUrl = document.location.href.split("#", 1)[0];
10943 if (!baseUrl.startsWith("file://")) {
10944 newUrl = `${baseUrl}#${destination.hash}`;
10945 }
10946 }
10947 if (shouldReplace) {
10948 window.history.replaceState(newState, "", newUrl);
10949 } else {
10950 window.history.pushState(newState, "", newUrl);
10951 }
10952 }
10953 #tryPushCurrentPosition(temporary = false) {
10954 if (!this._position) {
10955 return;
10956 }
10957 let position = this._position;
10958 if (temporary) {
10959 position = Object.assign(Object.create(null), this._position);
10960 position.temporary = true;
10961 }
10962 if (!this._destination) {
10963 this.#pushOrReplaceState(position);
10964 return;
10965 }
10966 if (this._destination.temporary) {
10967 this.#pushOrReplaceState(position, true);
10968 return;
10969 }
10970 if (this._destination.hash === position.hash) {
10971 return;
10972 }
10973 if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
10974 return;
10975 }
10976 let forceReplace = false;
10977 if (this._destination.page >= position.first && this._destination.page <= position.page) {
10978 if (this._destination.dest !== undefined || !this._destination.first) {
10979 return;
10980 }
10981 forceReplace = true;
10982 }
10983 this.#pushOrReplaceState(position, forceReplace);
10984 }
10985 #isValidPage(val) {
10986 return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
10987 }
10988 #isValidState(state, checkReload = false) {
10989 if (!state) {
10990 return false;
10991 }
10992 if (state.fingerprint !== this._fingerprint) {
10993 if (checkReload) {
10994 if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
10995 return false;
10996 }
10997 const [perfEntry] = performance.getEntriesByType("navigation");
10998 if (perfEntry?.type !== "reload") {
10999 return false;
11000 }
11001 } else {
11002 return false;
11003 }
11004 }
11005 if (!Number.isInteger(state.uid) || state.uid < 0) {
11006 return false;
11007 }
11008 if (state.destination === null || typeof state.destination !== "object") {
11009 return false;
11010 }
11011 return true;
11012 }
11013 #updateInternalState(destination, uid, removeTemporary = false) {
11014 if (this._updateViewareaTimeout) {
11015 clearTimeout(this._updateViewareaTimeout);
11016 this._updateViewareaTimeout = null;
11017 }
11018 if (removeTemporary && destination?.temporary) {
11019 delete destination.temporary;
11020 }
11021 this._destination = destination;
11022 this._uid = uid;
11023 this._maxUid = Math.max(this._maxUid, uid);
11024 this._numPositionUpdates = 0;
11025 }
11026 #parseCurrentHash(checkNameddest = false) {
11027 const hash = unescape(getCurrentHash()).substring(1);
11028 const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
11029 const nameddest = params.get("nameddest") || "";
11030 let page = params.get("page") | 0;
11031 if (!this.#isValidPage(page) || checkNameddest && nameddest.length > 0) {
11032 page = null;
11033 }
11034 return {
11035 hash,
11036 page,
11037 rotation: this.linkService.rotation
11038 };
11039 }
11040 #updateViewarea({
11041 location
11042 }) {
11043 if (this._updateViewareaTimeout) {
11044 clearTimeout(this._updateViewareaTimeout);
11045 this._updateViewareaTimeout = null;
11046 }
11047 this._position = {
11048 hash: location.pdfOpenParams.substring(1),
11049 page: this.linkService.page,
11050 first: location.pageNumber,
11051 rotation: location.rotation
11052 };
11053 if (this._popStateInProgress) {
11054 return;
11055 }
11056 if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
11057 this._numPositionUpdates++;
11058 }
11059 if (UPDATE_VIEWAREA_TIMEOUT > 0) {
11060 this._updateViewareaTimeout = setTimeout(() => {
11061 if (!this._popStateInProgress) {
11062 this.#tryPushCurrentPosition(true);
11063 }
11064 this._updateViewareaTimeout = null;
11065 }, UPDATE_VIEWAREA_TIMEOUT);
11066 }
11067 }
11068 #popState({
11069 state
11070 }) {
11071 const newHash = getCurrentHash(),
11072 hashChanged = this._currentHash !== newHash;
11073 this._currentHash = newHash;
11074 if (!state) {
11075 this._uid++;
11076 const {
11077 hash,
11078 page,
11079 rotation
11080 } = this.#parseCurrentHash();
11081 this.#pushOrReplaceState({
11082 hash,
11083 page,
11084 rotation
11085 }, true);
11086 return;
11087 }
11088 if (!this.#isValidState(state)) {
11089 return;
11090 }
11091 this._popStateInProgress = true;
11092 if (hashChanged) {
11093 this._blockHashChange++;
11094 (0,_event_utils_js__WEBPACK_IMPORTED_MODULE_1__.waitOnEventOrTimeout)({
11095 target: window,
11096 name: "hashchange",
11097 delay: HASH_CHANGE_TIMEOUT
11098 }).then(() => {
11099 this._blockHashChange--;
11100 });
11101 }
11102 const destination = state.destination;
11103 this.#updateInternalState(destination, state.uid, true);
11104 if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(destination.rotation)) {
11105 this.linkService.rotation = destination.rotation;
11106 }
11107 if (destination.dest) {
11108 this.linkService.goToDestination(destination.dest);
11109 } else if (destination.hash) {
11110 this.linkService.setHash(destination.hash);
11111 } else if (destination.page) {
11112 this.linkService.page = destination.page;
11113 }
11114 Promise.resolve().then(() => {
11115 this._popStateInProgress = false;
11116 });
11117 }
11118 #pageHide() {
11119 if (!this._destination || this._destination.temporary) {
11120 this.#tryPushCurrentPosition();
11121 }
11122 }
11123 #bindEvents() {
11124 if (this.#eventAbortController) {
11125 return;
11126 }
11127 this.#eventAbortController = new AbortController();
11128 const {
11129 signal
11130 } = this.#eventAbortController;
11131 this.eventBus._on("updateviewarea", this.#updateViewarea.bind(this), {
11132 signal
11133 });
11134 window.addEventListener("popstate", this.#popState.bind(this), {
11135 signal
11136 });
11137 window.addEventListener("pagehide", this.#pageHide.bind(this), {
11138 signal
11139 });
11140 }
11141 #unbindEvents() {
11142 this.#eventAbortController?.abort();
11143 this.#eventAbortController = null;
11144 }
11145}
11146function isDestHashesEqual(destHash, pushHash) {
11147 if (typeof destHash !== "string" || typeof pushHash !== "string") {
11148 return false;
11149 }
11150 if (destHash === pushHash) {
11151 return true;
11152 }
11153 const nameddest = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(destHash).get("nameddest");
11154 if (nameddest === pushHash) {
11155 return true;
11156 }
11157 return false;
11158}
11159function isDestArraysEqual(firstDest, secondDest) {
11160 function isEntryEqual(first, second) {
11161 if (typeof first !== typeof second) {
11162 return false;
11163 }
11164 if (Array.isArray(first) || Array.isArray(second)) {
11165 return false;
11166 }
11167 if (first !== null && typeof first === "object" && second !== null) {
11168 if (Object.keys(first).length !== Object.keys(second).length) {
11169 return false;
11170 }
11171 for (const key in first) {
11172 if (!isEntryEqual(first[key], second[key])) {
11173 return false;
11174 }
11175 }
11176 return true;
11177 }
11178 return first === second || Number.isNaN(first) && Number.isNaN(second);
11179 }
11180 if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
11181 return false;
11182 }
11183 if (firstDest.length !== secondDest.length) {
11184 return false;
11185 }
11186 for (let i = 0, ii = firstDest.length; i < ii; i++) {
11187 if (!isEntryEqual(firstDest[i], secondDest[i])) {
11188 return false;
11189 }
11190 }
11191 return true;
11192}
11193
11194
11195/***/ }),
11196
11197/***/ 4275:
11198/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11199
11200/* harmony export */ __webpack_require__.d(__webpack_exports__, {
11201/* harmony export */ PDFLayerViewer: () => (/* binding */ PDFLayerViewer)
11202/* harmony export */ });
11203/* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2961);
11204
11205class PDFLayerViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__.BaseTreeViewer {
11206 constructor(options) {
11207 super(options);
11208 this.eventBus._on("optionalcontentconfigchanged", evt => {
11209 this.#updateLayers(evt.promise);
11210 });
11211 this.eventBus._on("resetlayers", () => {
11212 this.#updateLayers();
11213 });
11214 this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
11215 }
11216 reset() {
11217 super.reset();
11218 this._optionalContentConfig = null;
11219 this._optionalContentHash = null;
11220 }
11221 _dispatchEvent(layersCount) {
11222 this.eventBus.dispatch("layersloaded", {
11223 source: this,
11224 layersCount
11225 });
11226 }
11227 _bindLink(element, {
11228 groupId,
11229 input
11230 }) {
11231 const setVisibility = () => {
11232 this._optionalContentConfig.setVisibility(groupId, input.checked);
11233 this._optionalContentHash = this._optionalContentConfig.getHash();
11234 this.eventBus.dispatch("optionalcontentconfig", {
11235 source: this,
11236 promise: Promise.resolve(this._optionalContentConfig)
11237 });
11238 };
11239 element.onclick = evt => {
11240 if (evt.target === input) {
11241 setVisibility();
11242 return true;
11243 } else if (evt.target !== element) {
11244 return true;
11245 }
11246 input.checked = !input.checked;
11247 setVisibility();
11248 return false;
11249 };
11250 }
11251 async _setNestedName(element, {
11252 name = null
11253 }) {
11254 if (typeof name === "string") {
11255 element.textContent = this._normalizeTextContent(name);
11256 return;
11257 }
11258 element.textContent = await this._l10n.get("pdfjs-additional-layers");
11259 element.style.fontStyle = "italic";
11260 }
11261 _addToggleButton(div, {
11262 name = null
11263 }) {
11264 super._addToggleButton(div, name === null);
11265 }
11266 _toggleAllTreeItems() {
11267 if (!this._optionalContentConfig) {
11268 return;
11269 }
11270 super._toggleAllTreeItems();
11271 }
11272 render({
11273 optionalContentConfig,
11274 pdfDocument
11275 }) {
11276 if (this._optionalContentConfig) {
11277 this.reset();
11278 }
11279 this._optionalContentConfig = optionalContentConfig || null;
11280 this._pdfDocument = pdfDocument || null;
11281 const groups = optionalContentConfig?.getOrder();
11282 if (!groups) {
11283 this._dispatchEvent(0);
11284 return;
11285 }
11286 this._optionalContentHash = optionalContentConfig.getHash();
11287 const fragment = document.createDocumentFragment(),
11288 queue = [{
11289 parent: fragment,
11290 groups
11291 }];
11292 let layersCount = 0,
11293 hasAnyNesting = false;
11294 while (queue.length > 0) {
11295 const levelData = queue.shift();
11296 for (const groupId of levelData.groups) {
11297 const div = document.createElement("div");
11298 div.className = "treeItem";
11299 const element = document.createElement("a");
11300 div.append(element);
11301 if (typeof groupId === "object") {
11302 hasAnyNesting = true;
11303 this._addToggleButton(div, groupId);
11304 this._setNestedName(element, groupId);
11305 const itemsDiv = document.createElement("div");
11306 itemsDiv.className = "treeItems";
11307 div.append(itemsDiv);
11308 queue.push({
11309 parent: itemsDiv,
11310 groups: groupId.order
11311 });
11312 } else {
11313 const group = optionalContentConfig.getGroup(groupId);
11314 const input = document.createElement("input");
11315 this._bindLink(element, {
11316 groupId,
11317 input
11318 });
11319 input.type = "checkbox";
11320 input.checked = group.visible;
11321 const label = document.createElement("label");
11322 label.textContent = this._normalizeTextContent(group.name);
11323 label.append(input);
11324 element.append(label);
11325 layersCount++;
11326 }
11327 levelData.parent.append(div);
11328 }
11329 }
11330 this._finishRendering(fragment, layersCount, hasAnyNesting);
11331 }
11332 async #updateLayers(promise = null) {
11333 if (!this._optionalContentConfig) {
11334 return;
11335 }
11336 const pdfDocument = this._pdfDocument;
11337 const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig({
11338 intent: "display"
11339 }));
11340 if (pdfDocument !== this._pdfDocument) {
11341 return;
11342 }
11343 if (promise) {
11344 if (optionalContentConfig.getHash() === this._optionalContentHash) {
11345 return;
11346 }
11347 } else {
11348 this.eventBus.dispatch("optionalcontentconfig", {
11349 source: this,
11350 promise: Promise.resolve(optionalContentConfig)
11351 });
11352 }
11353 this.render({
11354 optionalContentConfig,
11355 pdfDocument: this._pdfDocument
11356 });
11357 }
11358}
11359
11360
11361/***/ }),
11362
11363/***/ 787:
11364/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11365
11366/* harmony export */ __webpack_require__.d(__webpack_exports__, {
11367/* harmony export */ LinkTarget: () => (/* binding */ LinkTarget),
11368/* harmony export */ PDFLinkService: () => (/* binding */ PDFLinkService),
11369/* harmony export */ SimpleLinkService: () => (/* binding */ SimpleLinkService)
11370/* harmony export */ });
11371/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
11372
11373const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
11374const LinkTarget = {
11375 NONE: 0,
11376 SELF: 1,
11377 BLANK: 2,
11378 PARENT: 3,
11379 TOP: 4
11380};
11381function addLinkAttributes(link, {
11382 url,
11383 target,
11384 rel,
11385 enabled = true
11386} = {}) {
11387 if (!url || typeof url !== "string") {
11388 throw new Error('A valid "url" parameter must provided.');
11389 }
11390 if (enabled) {
11391 link.href = link.title = url;
11392 } else {
11393 link.href = "";
11394 link.title = `Disabled: ${url}`;
11395 link.onclick = () => false;
11396 }
11397 let targetStr = "";
11398 switch (target) {
11399 case LinkTarget.NONE:
11400 break;
11401 case LinkTarget.SELF:
11402 targetStr = "_self";
11403 break;
11404 case LinkTarget.BLANK:
11405 targetStr = "_blank";
11406 break;
11407 case LinkTarget.PARENT:
11408 targetStr = "_parent";
11409 break;
11410 case LinkTarget.TOP:
11411 targetStr = "_top";
11412 break;
11413 }
11414 link.target = targetStr;
11415 link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
11416}
11417class PDFLinkService {
11418 #pagesRefCache = new Map();
11419 constructor({
11420 eventBus,
11421 externalLinkTarget = null,
11422 externalLinkRel = null,
11423 ignoreDestinationZoom = false
11424 } = {}) {
11425 this.eventBus = eventBus;
11426 this.externalLinkTarget = externalLinkTarget;
11427 this.externalLinkRel = externalLinkRel;
11428 this.externalLinkEnabled = true;
11429 this._ignoreDestinationZoom = ignoreDestinationZoom;
11430 this.baseUrl = null;
11431 this.pdfDocument = null;
11432 this.pdfViewer = null;
11433 this.pdfHistory = null;
11434 }
11435 setDocument(pdfDocument, baseUrl = null) {
11436 this.baseUrl = baseUrl;
11437 this.pdfDocument = pdfDocument;
11438 this.#pagesRefCache.clear();
11439 }
11440 setViewer(pdfViewer) {
11441 this.pdfViewer = pdfViewer;
11442 }
11443 setHistory(pdfHistory) {
11444 this.pdfHistory = pdfHistory;
11445 }
11446 get pagesCount() {
11447 return this.pdfDocument ? this.pdfDocument.numPages : 0;
11448 }
11449 get page() {
11450 return this.pdfViewer.currentPageNumber;
11451 }
11452 set page(value) {
11453 this.pdfViewer.currentPageNumber = value;
11454 }
11455 get rotation() {
11456 return this.pdfViewer.pagesRotation;
11457 }
11458 set rotation(value) {
11459 this.pdfViewer.pagesRotation = value;
11460 }
11461 get isInPresentationMode() {
11462 return this.pdfViewer.isInPresentationMode;
11463 }
11464 #goToDestinationHelper(rawDest, namedDest = null, explicitDest) {
11465 const destRef = explicitDest[0];
11466 let pageNumber;
11467 if (typeof destRef === "object" && destRef !== null) {
11468 pageNumber = this._cachedPageNumber(destRef);
11469 if (!pageNumber) {
11470 this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
11471 this.cachePageRef(pageIndex + 1, destRef);
11472 this.#goToDestinationHelper(rawDest, namedDest, explicitDest);
11473 }).catch(() => {
11474 globalThis.ngxConsole.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
11475 });
11476 return;
11477 }
11478 } else if (Number.isInteger(destRef)) {
11479 pageNumber = destRef + 1;
11480 } else {
11481 globalThis.ngxConsole.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
11482 return;
11483 }
11484 if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
11485 globalThis.ngxConsole.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
11486 return;
11487 }
11488 if (this.pdfHistory) {
11489 this.pdfHistory.pushCurrentPosition();
11490 this.pdfHistory.push({
11491 namedDest,
11492 explicitDest,
11493 pageNumber
11494 });
11495 }
11496 this.pdfViewer.scrollPageIntoView({
11497 pageNumber,
11498 destArray: explicitDest,
11499 ignoreDestinationZoom: this._ignoreDestinationZoom
11500 });
11501 }
11502 async goToDestination(dest) {
11503 if (!this.pdfDocument) {
11504 return;
11505 }
11506 let namedDest, explicitDest;
11507 if (typeof dest === "string") {
11508 namedDest = dest;
11509 explicitDest = await this.pdfDocument.getDestination(dest);
11510 } else {
11511 namedDest = null;
11512 explicitDest = await dest;
11513 }
11514 if (!Array.isArray(explicitDest)) {
11515 globalThis.ngxConsole.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
11516 return;
11517 }
11518 this.#goToDestinationHelper(dest, namedDest, explicitDest);
11519 }
11520 goToPage(val) {
11521 if (!this.pdfDocument) {
11522 return;
11523 }
11524 const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
11525 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
11526 globalThis.ngxConsole.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
11527 return;
11528 }
11529 if (this.pdfHistory) {
11530 this.pdfHistory.pushCurrentPosition();
11531 this.pdfHistory.pushPage(pageNumber);
11532 }
11533 if (this.pdfViewer.pageViewMode === "book") {
11534 if (this.pdfViewer.pageFlip) {
11535 this.pdfViewer.ensureAdjacentPagesAreLoaded();
11536 const evenPage = this.pdfViewer.currentPageNumber - this.pdfViewer.currentPageNumber % 2;
11537 const evenTargetPage = pageNumber - pageNumber % 2;
11538 if (evenPage === evenTargetPage - 2) {
11539 this.pdfViewer.pageFlip.flipNext();
11540 } else if (evenPage === evenTargetPage + 2) {
11541 this.pdfViewer.pageFlip.flipPrev();
11542 } else {
11543 this.pdfViewer.pageFlip.turnToPage(pageNumber - 1);
11544 }
11545 }
11546 } else {
11547 this.pdfViewer.scrollPageIntoView({
11548 pageNumber
11549 });
11550 }
11551 }
11552 addLinkAttributes(link, url, newWindow = false) {
11553 addLinkAttributes(link, {
11554 url,
11555 target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
11556 rel: this.externalLinkRel,
11557 enabled: this.externalLinkEnabled
11558 });
11559 }
11560 getDestinationHash(dest) {
11561 if (typeof dest === "string") {
11562 if (dest.length > 0) {
11563 return this.getAnchorUrl("#" + escape(dest));
11564 }
11565 } else if (Array.isArray(dest)) {
11566 const str = JSON.stringify(dest);
11567 if (str.length > 0) {
11568 return this.getAnchorUrl("#" + escape(str));
11569 }
11570 }
11571 return this.getAnchorUrl("");
11572 }
11573 getAnchorUrl(anchor) {
11574 return this.baseUrl ? this.baseUrl + anchor : anchor;
11575 }
11576 setHash(hash) {
11577 if (!this.pdfDocument) {
11578 return;
11579 }
11580 let pageNumber, dest;
11581 if (hash.includes("=")) {
11582 const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
11583 if (params.has("search")) {
11584 const query = params.get("search").replaceAll('"', ""),
11585 phrase = params.get("phrase") === "true";
11586 this.eventBus.dispatch("findfromurlhash", {
11587 source: this,
11588 query: phrase ? query : query.match(/\S+/g)
11589 });
11590 }
11591 if (params.has("page")) {
11592 pageNumber = params.get("page") | 0 || 1;
11593 }
11594 if (params.has("zoom")) {
11595 const zoomArgs = params.get("zoom").split(",");
11596 const zoomArg = zoomArgs[0];
11597 const zoomArgNumber = parseFloat(zoomArg);
11598 if (!zoomArg.includes("Fit")) {
11599 dest = [null, {
11600 name: "XYZ"
11601 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
11602 } else if (zoomArg === "Fit" || zoomArg === "FitB") {
11603 dest = [null, {
11604 name: zoomArg
11605 }];
11606 } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
11607 dest = [null, {
11608 name: zoomArg
11609 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
11610 } else if (zoomArg === "FitR") {
11611 if (zoomArgs.length !== 5) {
11612 globalThis.ngxConsole.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
11613 } else {
11614 dest = [null, {
11615 name: zoomArg
11616 }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
11617 }
11618 } else {
11619 globalThis.ngxConsole.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
11620 }
11621 }
11622 if (dest) {
11623 this.pdfViewer.scrollPageIntoView({
11624 pageNumber: pageNumber || this.page,
11625 destArray: dest,
11626 allowNegativeOffset: true
11627 });
11628 } else if (pageNumber) {
11629 this.page = pageNumber;
11630 }
11631 if (params.has("pagemode")) {
11632 this.eventBus.dispatch("pagemode", {
11633 source: this,
11634 mode: params.get("pagemode")
11635 });
11636 }
11637 if (params.has("nameddest")) {
11638 this.goToDestination(params.get("nameddest"));
11639 }
11640 return;
11641 }
11642 dest = unescape(hash);
11643 try {
11644 dest = JSON.parse(dest);
11645 if (!Array.isArray(dest)) {
11646 dest = dest.toString();
11647 }
11648 } catch {}
11649 if (typeof dest === "string" || PDFLinkService.#isValidExplicitDest(dest)) {
11650 this.goToDestination(dest);
11651 return;
11652 }
11653 console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
11654 }
11655 executeNamedAction(action) {
11656 switch (action) {
11657 case "GoBack":
11658 this.pdfHistory?.back();
11659 break;
11660 case "GoForward":
11661 this.pdfHistory?.forward();
11662 break;
11663 case "NextPage":
11664 this.pdfViewer.nextPage();
11665 break;
11666 case "PrevPage":
11667 this.pdfViewer.previousPage();
11668 break;
11669 case "LastPage":
11670 this.page = this.pagesCount;
11671 break;
11672 case "FirstPage":
11673 this.page = 1;
11674 break;
11675 default:
11676 break;
11677 }
11678 this.eventBus.dispatch("namedaction", {
11679 source: this,
11680 action
11681 });
11682 }
11683 async executeSetOCGState(action) {
11684 const pdfDocument = this.pdfDocument;
11685 const optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
11686 if (pdfDocument !== this.pdfDocument) {
11687 return;
11688 }
11689 optionalContentConfig.setOCGState(action);
11690 this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
11691 }
11692 cachePageRef(pageNum, pageRef) {
11693 if (!pageRef) {
11694 return;
11695 }
11696 const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
11697 this.#pagesRefCache.set(refStr, pageNum);
11698 }
11699 _cachedPageNumber(pageRef) {
11700 if (!pageRef) {
11701 return null;
11702 }
11703 const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
11704 return this.#pagesRefCache.get(refStr) || null;
11705 }
11706 static #isValidExplicitDest(dest) {
11707 if (!Array.isArray(dest) || dest.length < 2) {
11708 return false;
11709 }
11710 const [page, zoom, ...args] = dest;
11711 if (!(typeof page === "object" && Number.isInteger(page?.num) && Number.isInteger(page?.gen)) && !Number.isInteger(page)) {
11712 return false;
11713 }
11714 if (!(typeof zoom === "object" && typeof zoom?.name === "string")) {
11715 return false;
11716 }
11717 let allowNull = true;
11718 switch (zoom.name) {
11719 case "XYZ":
11720 if (args.length !== 3) {
11721 return false;
11722 }
11723 break;
11724 case "Fit":
11725 case "FitB":
11726 return args.length === 0;
11727 case "FitH":
11728 case "FitBH":
11729 case "FitV":
11730 case "FitBV":
11731 if (args.length !== 1) {
11732 return false;
11733 }
11734 break;
11735 case "FitR":
11736 if (args.length !== 4) {
11737 return false;
11738 }
11739 allowNull = false;
11740 break;
11741 default:
11742 return false;
11743 }
11744 for (const arg of args) {
11745 if (!(typeof arg === "number" || allowNull && arg === null)) {
11746 return false;
11747 }
11748 }
11749 return true;
11750 }
11751}
11752class SimpleLinkService {
11753 constructor() {
11754 this.externalLinkEnabled = true;
11755 }
11756 get pagesCount() {
11757 return 0;
11758 }
11759 get page() {
11760 return 0;
11761 }
11762 set page(value) {}
11763 get rotation() {
11764 return 0;
11765 }
11766 set rotation(value) {}
11767 get isInPresentationMode() {
11768 return false;
11769 }
11770 async goToDestination(dest) {}
11771 goToPage(val) {}
11772 addLinkAttributes(link, url, newWindow = false) {
11773 addLinkAttributes(link, {
11774 url,
11775 enabled: this.externalLinkEnabled
11776 });
11777 }
11778 getDestinationHash(dest) {
11779 return "#";
11780 }
11781 getAnchorUrl(hash) {
11782 return "#";
11783 }
11784 setHash(hash) {}
11785 executeNamedAction(action) {}
11786 executeSetOCGState(action) {}
11787 cachePageRef(pageNum, pageRef) {}
11788}
11789
11790
11791/***/ }),
11792
11793/***/ 5514:
11794/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11795
11796/* harmony export */ __webpack_require__.d(__webpack_exports__, {
11797/* harmony export */ PDFOutlineViewer: () => (/* binding */ PDFOutlineViewer)
11798/* harmony export */ });
11799/* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2961);
11800/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
11801
11802
11803class PDFOutlineViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__.BaseTreeViewer {
11804 constructor(options) {
11805 super(options);
11806 this.linkService = options.linkService;
11807 this.downloadManager = options.downloadManager;
11808 this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
11809 this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this));
11810 this.eventBus._on("pagechanging", evt => {
11811 this._currentPageNumber = evt.pageNumber;
11812 });
11813 this.eventBus._on("pagesloaded", evt => {
11814 this._isPagesLoaded = !!evt.pagesCount;
11815 this._currentOutlineItemCapability?.resolve(this._isPagesLoaded);
11816 });
11817 this.eventBus._on("sidebarviewchanged", evt => {
11818 this._sidebarView = evt.view;
11819 });
11820 }
11821 reset() {
11822 super.reset();
11823 this._outline = null;
11824 this._pageNumberToDestHashCapability = null;
11825 this._currentPageNumber = 1;
11826 this._isPagesLoaded = null;
11827 this._currentOutlineItemCapability?.resolve(false);
11828 this._currentOutlineItemCapability = null;
11829 }
11830 _dispatchEvent(outlineCount) {
11831 this._currentOutlineItemCapability = Promise.withResolvers();
11832 if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
11833 this._currentOutlineItemCapability.resolve(false);
11834 } else if (this._isPagesLoaded !== null) {
11835 this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
11836 }
11837 this.eventBus.dispatch("outlineloaded", {
11838 source: this,
11839 outlineCount,
11840 currentOutlineItemPromise: this._currentOutlineItemCapability.promise
11841 });
11842 }
11843 _bindLink(element, {
11844 url,
11845 newWindow,
11846 action,
11847 attachment,
11848 dest,
11849 setOCGState
11850 }) {
11851 const {
11852 linkService
11853 } = this;
11854 if (url) {
11855 linkService.addLinkAttributes(element, url, newWindow);
11856 return;
11857 }
11858 if (action) {
11859 element.href = linkService.getAnchorUrl("");
11860 element.onclick = () => {
11861 linkService.executeNamedAction(action);
11862 return false;
11863 };
11864 return;
11865 }
11866 if (attachment) {
11867 element.href = linkService.getAnchorUrl("");
11868 element.onclick = () => {
11869 this.downloadManager.openOrDownloadData(attachment.content, attachment.filename);
11870 return false;
11871 };
11872 return;
11873 }
11874 if (setOCGState) {
11875 element.href = linkService.getAnchorUrl("");
11876 element.onclick = () => {
11877 linkService.executeSetOCGState(setOCGState);
11878 return false;
11879 };
11880 return;
11881 }
11882 element.href = linkService.getDestinationHash(dest);
11883 element.onclick = evt => {
11884 this._updateCurrentTreeItem(evt.target.parentNode);
11885 if (dest) {
11886 linkService.goToDestination(dest);
11887 }
11888 return false;
11889 };
11890 }
11891 _setStyles(element, {
11892 bold,
11893 italic
11894 }) {
11895 if (bold) {
11896 element.style.fontWeight = "bold";
11897 }
11898 if (italic) {
11899 element.style.fontStyle = "italic";
11900 }
11901 }
11902 _addToggleButton(div, {
11903 count,
11904 items
11905 }) {
11906 let hidden = false;
11907 if (count < 0) {
11908 let totalCount = items.length;
11909 if (totalCount > 0) {
11910 const queue = [...items];
11911 while (queue.length > 0) {
11912 const {
11913 count: nestedCount,
11914 items: nestedItems
11915 } = queue.shift();
11916 if (nestedCount > 0 && nestedItems.length > 0) {
11917 totalCount += nestedItems.length;
11918 queue.push(...nestedItems);
11919 }
11920 }
11921 }
11922 if (Math.abs(count) === totalCount) {
11923 hidden = true;
11924 }
11925 }
11926 super._addToggleButton(div, hidden);
11927 }
11928 _toggleAllTreeItems() {
11929 if (!this._outline) {
11930 return;
11931 }
11932 super._toggleAllTreeItems();
11933 }
11934 render({
11935 outline,
11936 pdfDocument
11937 }) {
11938 if (this._outline) {
11939 this.reset();
11940 }
11941 this._outline = outline || null;
11942 this._pdfDocument = pdfDocument || null;
11943 if (!outline) {
11944 this._dispatchEvent(0);
11945 return;
11946 }
11947 const fragment = document.createDocumentFragment();
11948 const queue = [{
11949 parent: fragment,
11950 items: outline
11951 }];
11952 let outlineCount = 0,
11953 hasAnyNesting = false;
11954 while (queue.length > 0) {
11955 const levelData = queue.shift();
11956 for (const item of levelData.items) {
11957 const div = document.createElement("div");
11958 div.className = "treeItem";
11959 const element = document.createElement("a");
11960 this._bindLink(element, item);
11961 this._setStyles(element, item);
11962 element.textContent = this._normalizeTextContent(item.title);
11963 div.append(element);
11964 if (item.items.length > 0) {
11965 hasAnyNesting = true;
11966 this._addToggleButton(div, item);
11967 const itemsDiv = document.createElement("div");
11968 itemsDiv.className = "treeItems";
11969 div.append(itemsDiv);
11970 queue.push({
11971 parent: itemsDiv,
11972 items: item.items
11973 });
11974 }
11975 levelData.parent.append(div);
11976 outlineCount++;
11977 }
11978 }
11979 this._finishRendering(fragment, outlineCount, hasAnyNesting);
11980 }
11981 async _currentOutlineItem() {
11982 if (!this._isPagesLoaded) {
11983 throw new Error("_currentOutlineItem: All pages have not been loaded.");
11984 }
11985 if (!this._outline || !this._pdfDocument) {
11986 return;
11987 }
11988 const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
11989 if (!pageNumberToDestHash) {
11990 return;
11991 }
11992 this._updateCurrentTreeItem(null);
11993 if (this._sidebarView !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SidebarView.OUTLINE) {
11994 return;
11995 }
11996 for (let i = this._currentPageNumber; i > 0; i--) {
11997 const destHash = pageNumberToDestHash.get(i);
11998 if (!destHash) {
11999 continue;
12000 }
12001 const linkElement = this.container.querySelector(`a[href="${destHash}"]`);
12002 if (!linkElement) {
12003 continue;
12004 }
12005 this._scrollToCurrentTreeItem(linkElement.parentNode);
12006 break;
12007 }
12008 }
12009 async _getPageNumberToDestHash(pdfDocument) {
12010 if (this._pageNumberToDestHashCapability) {
12011 return this._pageNumberToDestHashCapability.promise;
12012 }
12013 this._pageNumberToDestHashCapability = Promise.withResolvers();
12014 const pageNumberToDestHash = new Map(),
12015 pageNumberNesting = new Map();
12016 const queue = [{
12017 nesting: 0,
12018 items: this._outline
12019 }];
12020 while (queue.length > 0) {
12021 const levelData = queue.shift(),
12022 currentNesting = levelData.nesting;
12023 for (const {
12024 dest,
12025 items
12026 } of levelData.items) {
12027 let explicitDest, pageNumber;
12028 if (typeof dest === "string") {
12029 explicitDest = await pdfDocument.getDestination(dest);
12030 if (pdfDocument !== this._pdfDocument) {
12031 return null;
12032 }
12033 } else {
12034 explicitDest = dest;
12035 }
12036 if (Array.isArray(explicitDest)) {
12037 const [destRef] = explicitDest;
12038 if (typeof destRef === "object" && destRef !== null) {
12039 pageNumber = this.linkService._cachedPageNumber(destRef);
12040 if (!pageNumber) {
12041 try {
12042 pageNumber = (await pdfDocument.getPageIndex(destRef)) + 1;
12043 if (pdfDocument !== this._pdfDocument) {
12044 return null;
12045 }
12046 this.linkService.cachePageRef(pageNumber, destRef);
12047 } catch {}
12048 }
12049 } else if (Number.isInteger(destRef)) {
12050 pageNumber = destRef + 1;
12051 }
12052 if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
12053 const destHash = this.linkService.getDestinationHash(dest);
12054 pageNumberToDestHash.set(pageNumber, destHash);
12055 pageNumberNesting.set(pageNumber, currentNesting);
12056 }
12057 }
12058 if (items.length > 0) {
12059 queue.push({
12060 nesting: currentNesting + 1,
12061 items
12062 });
12063 }
12064 }
12065 }
12066 this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
12067 return this._pageNumberToDestHashCapability.promise;
12068 }
12069}
12070
12071
12072/***/ }),
12073
12074/***/ 9966:
12075/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
12076
12077__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
12078/* harmony export */ __webpack_require__.d(__webpack_exports__, {
12079/* harmony export */ PDFPageView: () => (/* binding */ PDFPageView)
12080/* harmony export */ });
12081/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
12082/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
12083/* harmony import */ var _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(283);
12084/* harmony import */ var _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2707);
12085/* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9840);
12086/* harmony import */ var _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3088);
12087/* harmony import */ var web_null_l10n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(410);
12088/* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(787);
12089/* harmony import */ var _struct_tree_layer_builder_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6698);
12090/* harmony import */ var _text_accessibility_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(5860);
12091/* harmony import */ var canvas_size__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(8394);
12092/* harmony import */ var _src_shared_util_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(4292);
12093/* harmony import */ var _text_highlighter_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(2027);
12094/* harmony import */ var _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(7765);
12095/* harmony import */ var _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(2973);
12096var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__, _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__, _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__, web_null_l10n__WEBPACK_IMPORTED_MODULE_6__, _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_12__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_13__]);
12097([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__, _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__, _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__, web_null_l10n__WEBPACK_IMPORTED_MODULE_6__, _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_12__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_13__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113const DEFAULT_LAYER_PROPERTIES = null;
12114const LAYERS_ORDER = new Map([["canvasWrapper", 0], ["textLayer", 1], ["annotationLayer", 2], ["annotationEditorLayer", 3], ["xfaLayer", 3]]);
12115class PDFPageView {
12116 #annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
12117 #hasRestrictedScaling = false;
12118 #layerProperties = null;
12119 #loadingId = null;
12120 #previousRotation = null;
12121 #renderError = null;
12122 #renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL;
12123 #textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
12124 #useThumbnailCanvas = {
12125 directDrawing: true,
12126 initialOptionalContent: true,
12127 regularAnnotations: true
12128 };
12129 #viewportMap = new WeakMap();
12130 #layers = [null, null, null, null];
12131 constructor(options) {
12132 const container = options.container;
12133 const defaultViewport = options.defaultViewport;
12134 this.id = options.id;
12135 this.renderingId = "page" + this.id;
12136 this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
12137 this.pdfPage = null;
12138 this.pageLabel = null;
12139 this.rotation = 0;
12140 this.scale = options.scale || _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
12141 this.viewport = defaultViewport;
12142 this.pdfPageRotate = defaultViewport.rotation;
12143 this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
12144 this.#textLayerMode = options.textLayerMode ?? _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
12145 this.#annotationMode = options.annotationMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
12146 this.imageResourcesPath = options.imageResourcesPath || "";
12147 this.maxCanvasPixels = options.maxCanvasPixels ?? _app_options_js__WEBPACK_IMPORTED_MODULE_4__.AppOptions.get("maxCanvasPixels");
12148 this.pageColors = options.pageColors || null;
12149 this.eventBus = options.eventBus;
12150 this.renderingQueue = options.renderingQueue;
12151 this.l10n = options.l10n;
12152 this.l10n ||= new web_null_l10n__WEBPACK_IMPORTED_MODULE_6__.GenericL10n();
12153 this.renderTask = null;
12154 this.resume = null;
12155 this._isStandalone = !this.renderingQueue?.hasViewer();
12156 this._container = container;
12157 this._annotationCanvasMap = null;
12158 this.annotationLayer = null;
12159 this.annotationEditorLayer = null;
12160 this.textLayer = null;
12161 this.zoomLayer = null;
12162 this.xfaLayer = null;
12163 this.structTreeLayer = null;
12164 this.drawLayer = null;
12165 const div = document.createElement("div");
12166 div.className = "page";
12167 div.setAttribute("data-page-number", this.id);
12168 div.setAttribute("role", "region");
12169 div.setAttribute("data-l10n-id", "pdfjs-page-landmark");
12170 div.setAttribute("data-l10n-args", JSON.stringify({
12171 page: this.id
12172 }));
12173 this.div = div;
12174 this.#setDimensions();
12175 container?.append(div);
12176 if (this._isStandalone) {
12177 container?.style.setProperty("--scale-factor", this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS);
12178 const {
12179 optionalContentConfigPromise
12180 } = options;
12181 if (optionalContentConfigPromise) {
12182 optionalContentConfigPromise.then(optionalContentConfig => {
12183 if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
12184 return;
12185 }
12186 this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
12187 });
12188 }
12189 if (!options.l10n) {
12190 this.l10n.translate(this.div);
12191 }
12192 }
12193 }
12194 #addLayer(div, name) {
12195 const pos = LAYERS_ORDER.get(name);
12196 const oldDiv = this.#layers[pos];
12197 this.#layers[pos] = div;
12198 if (oldDiv) {
12199 oldDiv.replaceWith(div);
12200 return;
12201 }
12202 for (let i = pos - 1; i >= 0; i--) {
12203 const layer = this.#layers[i];
12204 if (layer) {
12205 layer.after(div);
12206 return;
12207 }
12208 }
12209 this.div.prepend(div);
12210 }
12211 get renderingState() {
12212 return this.#renderingState;
12213 }
12214 set renderingState(state) {
12215 if (state === this.#renderingState) {
12216 return;
12217 }
12218 this.#renderingState = state;
12219 if (this.#loadingId) {
12220 clearTimeout(this.#loadingId);
12221 this.#loadingId = null;
12222 }
12223 switch (state) {
12224 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED:
12225 this.div.classList.remove("loading");
12226 break;
12227 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING:
12228 this.div.classList.add("loadingIcon");
12229 this.#loadingId = setTimeout(() => {
12230 this.div.classList.add("loading");
12231 this.#loadingId = null;
12232 }, 0);
12233 break;
12234 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL:
12235 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED:
12236 this.div.classList.remove("loadingIcon", "loading");
12237 break;
12238 }
12239 }
12240 #setDimensions() {
12241 const {
12242 viewport
12243 } = this;
12244 if (this.pdfPage) {
12245 if (this.#previousRotation === viewport.rotation) {
12246 return;
12247 }
12248 this.#previousRotation = viewport.rotation;
12249 }
12250 (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.setLayerDimensions)(this.div, viewport, true, false);
12251 }
12252 setPdfPage(pdfPage) {
12253 if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) {
12254 this._container?.style.setProperty("--hcm-highlight-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight"));
12255 this._container?.style.setProperty("--hcm-highlight-selected-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "Highlight"));
12256 }
12257 this.pdfPage = pdfPage;
12258 this.pdfPageRotate = pdfPage.rotate;
12259 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
12260 this.viewport = pdfPage.getViewport({
12261 scale: this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS,
12262 rotation: totalRotation
12263 });
12264 this.#setDimensions();
12265 this.reset();
12266 }
12267 destroy() {
12268 this.reset();
12269 this.pdfPage?.cleanup();
12270 }
12271 get _textHighlighter() {
12272 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_textHighlighter", new _text_highlighter_js__WEBPACK_IMPORTED_MODULE_14__.TextHighlighter({
12273 pageIndex: this.id - 1,
12274 eventBus: this.eventBus,
12275 findController: this.#layerProperties.findController
12276 }));
12277 }
12278 async #renderAnnotationLayer() {
12279 let error = null;
12280 try {
12281 await this.annotationLayer.render(this.viewport, "display");
12282 } catch (ex) {
12283 console.error(`#renderAnnotationLayer: "${ex}".`);
12284 error = ex;
12285 } finally {
12286 this.eventBus.dispatch("annotationlayerrendered", {
12287 source: this,
12288 pageNumber: this.id,
12289 error
12290 });
12291 }
12292 }
12293 async #renderAnnotationEditorLayer() {
12294 let error = null;
12295 try {
12296 await this.annotationEditorLayer.render(this.viewport, "display");
12297 } catch (ex) {
12298 console.error(`#renderAnnotationEditorLayer: "${ex}".`);
12299 error = ex;
12300 } finally {
12301 this.eventBus.dispatch("annotationeditorlayerrendered", {
12302 source: this,
12303 pageNumber: this.id,
12304 error
12305 });
12306 }
12307 }
12308 async #renderDrawLayer() {
12309 try {
12310 await this.drawLayer.render("display");
12311 } catch (ex) {
12312 console.error(`#renderDrawLayer: "${ex}".`);
12313 }
12314 }
12315 async #renderXfaLayer() {
12316 let error = null;
12317 try {
12318 const result = await this.xfaLayer.render(this.viewport, "display");
12319 if (result?.textDivs && this._textHighlighter) {
12320 this.#buildXfaTextContentItems(result.textDivs);
12321 }
12322 } catch (ex) {
12323 console.error(`#renderXfaLayer: "${ex}".`);
12324 error = ex;
12325 } finally {
12326 if (this.xfaLayer?.div) {
12327 this.l10n.pause();
12328 this.#addLayer(this.xfaLayer.div, "xfaLayer");
12329 this.l10n.resume();
12330 }
12331 this.eventBus.dispatch("xfalayerrendered", {
12332 source: this,
12333 pageNumber: this.id,
12334 error
12335 });
12336 }
12337 }
12338 async #renderTextLayer() {
12339 const {
12340 pdfPage,
12341 textLayer,
12342 viewport
12343 } = this;
12344 if (!textLayer) {
12345 return;
12346 }
12347 let error = null;
12348 try {
12349 if (!textLayer.renderingDone) {
12350 const readableStream = pdfPage.streamTextContent({
12351 includeMarkedContent: true,
12352 disableNormalization: true
12353 });
12354 textLayer.setTextContentSource(readableStream);
12355 }
12356 await textLayer.render(viewport);
12357 } catch (ex) {
12358 if (ex instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AbortException) {
12359 return;
12360 }
12361 console.error(`#renderTextLayer: "${ex}".`);
12362 error = ex;
12363 }
12364 this.eventBus.dispatch("textlayerrendered", {
12365 source: this,
12366 pageNumber: this.id,
12367 numTextDivs: textLayer.numTextDivs,
12368 error
12369 });
12370 this.#renderStructTreeLayer();
12371 }
12372 async #renderStructTreeLayer() {
12373 if (!this.textLayer) {
12374 return;
12375 }
12376 this.structTreeLayer ||= new _struct_tree_layer_builder_js__WEBPACK_IMPORTED_MODULE_8__.StructTreeLayerBuilder();
12377 const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null);
12378 const treeDom = this.structTreeLayer?.render(tree);
12379 if (treeDom) {
12380 this.l10n.pause();
12381 this.canvas?.append(treeDom);
12382 this.l10n.resume();
12383 }
12384 this.structTreeLayer?.show();
12385 }
12386 async #buildXfaTextContentItems(textDivs) {
12387 const text = await this.pdfPage.getTextContent();
12388 const items = [];
12389 for (const item of text.items) {
12390 items.push(item.str);
12391 }
12392 this._textHighlighter.setTextMapping(textDivs, items);
12393 this._textHighlighter.enable();
12394 }
12395 _resetZoomLayer(removeFromDOM = false) {
12396 if (!this.zoomLayer) {
12397 return;
12398 }
12399 const zoomLayerCanvas = this.zoomLayer.firstChild;
12400 this.#viewportMap.delete(zoomLayerCanvas);
12401 zoomLayerCanvas.width = 0;
12402 zoomLayerCanvas.height = 0;
12403 if (removeFromDOM) {
12404 this.zoomLayer.remove();
12405 }
12406 this.zoomLayer = null;
12407 }
12408 reset({
12409 keepZoomLayer = false,
12410 keepAnnotationLayer = false,
12411 keepAnnotationEditorLayer = false,
12412 keepXfaLayer = false,
12413 keepTextLayer = false
12414 } = {}) {
12415 this.cancelRendering({
12416 keepAnnotationLayer,
12417 keepAnnotationEditorLayer,
12418 keepXfaLayer,
12419 keepTextLayer
12420 });
12421 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL;
12422 const div = this.div;
12423 const childNodes = div.childNodes,
12424 zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
12425 annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
12426 annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null,
12427 xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null,
12428 textLayerNode = keepTextLayer && this.textLayer?.div || null;
12429 for (let i = childNodes.length - 1; i >= 0; i--) {
12430 const node = childNodes[i];
12431 switch (node) {
12432 case zoomLayerNode:
12433 case annotationLayerNode:
12434 case annotationEditorLayerNode:
12435 case xfaLayerNode:
12436 case textLayerNode:
12437 continue;
12438 }
12439 node.remove();
12440 const layerIndex = this.#layers.indexOf(node);
12441 if (layerIndex >= 0) {
12442 this.#layers[layerIndex] = null;
12443 }
12444 }
12445 div.removeAttribute("data-loaded");
12446 if (annotationLayerNode) {
12447 this.annotationLayer.hide();
12448 }
12449 if (annotationEditorLayerNode) {
12450 this.annotationEditorLayer.hide();
12451 }
12452 if (xfaLayerNode) {
12453 this.xfaLayer.hide();
12454 }
12455 if (textLayerNode) {
12456 this.textLayer.hide();
12457 }
12458 this.structTreeLayer?.hide();
12459 if (!zoomLayerNode) {
12460 if (this.canvas) {
12461 this.#viewportMap.delete(this.canvas);
12462 this.canvas.width = 0;
12463 this.canvas.height = 0;
12464 delete this.canvas;
12465 }
12466 this._resetZoomLayer();
12467 }
12468 }
12469 update({
12470 scale = 0,
12471 rotation = null,
12472 optionalContentConfigPromise = null,
12473 drawingDelay = -1
12474 }) {
12475 this.scale = scale || this.scale;
12476 if (typeof rotation === "number") {
12477 this.rotation = rotation;
12478 }
12479 if (optionalContentConfigPromise instanceof Promise) {
12480 this._optionalContentConfigPromise = optionalContentConfigPromise;
12481 optionalContentConfigPromise.then(optionalContentConfig => {
12482 if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
12483 return;
12484 }
12485 this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
12486 });
12487 }
12488 this.#useThumbnailCanvas.directDrawing = true;
12489 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
12490 this.viewport = this.viewport.clone({
12491 scale: this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS,
12492 rotation: totalRotation
12493 });
12494 this.#setDimensions();
12495 if (this._isStandalone) {
12496 this._container?.style.setProperty("--scale-factor", this.viewport.scale);
12497 }
12498 if (this.canvas) {
12499 let onlyCssZoom = false;
12500 if (this.#hasRestrictedScaling) {
12501 if (this.maxCanvasPixels === 0) {
12502 onlyCssZoom = true;
12503 } else if (this.maxCanvasPixels > 0) {
12504 const {
12505 width,
12506 height
12507 } = this.viewport;
12508 const {
12509 sx,
12510 sy
12511 } = this.outputScale;
12512 onlyCssZoom = (Math.floor(width) * sx | 0) * (Math.floor(height) * sy | 0) > this.maxCanvasPixels;
12513 }
12514 }
12515 const postponeDrawing = !onlyCssZoom && drawingDelay >= 0 && drawingDelay < 1000;
12516 if (postponeDrawing || onlyCssZoom) {
12517 if (postponeDrawing && this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED) {
12518 this.cancelRendering({
12519 keepZoomLayer: true,
12520 keepAnnotationLayer: true,
12521 keepAnnotationEditorLayer: true,
12522 keepXfaLayer: true,
12523 keepTextLayer: true,
12524 cancelExtraDelay: drawingDelay
12525 });
12526 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
12527 this.#useThumbnailCanvas.directDrawing = false;
12528 }
12529 this.cssTransform({
12530 target: this.canvas,
12531 redrawAnnotationLayer: true,
12532 redrawAnnotationEditorLayer: true,
12533 redrawXfaLayer: true,
12534 redrawTextLayer: !postponeDrawing,
12535 hideTextLayer: postponeDrawing
12536 });
12537 if (postponeDrawing) {
12538 return;
12539 }
12540 this.eventBus.dispatch("pagerendered", {
12541 source: this,
12542 pageNumber: this.id,
12543 cssTransform: true,
12544 timestamp: performance.now(),
12545 error: this.#renderError
12546 });
12547 return;
12548 }
12549 if (!this.zoomLayer && !this.canvas.hidden) {
12550 this.zoomLayer = this.canvas.parentNode;
12551 this.zoomLayer.style.position = "absolute";
12552 }
12553 }
12554 if (this.zoomLayer) {
12555 this.cssTransform({
12556 target: this.zoomLayer.firstChild
12557 });
12558 }
12559 this.reset({
12560 keepZoomLayer: true,
12561 keepAnnotationLayer: true,
12562 keepAnnotationEditorLayer: true,
12563 keepXfaLayer: true,
12564 keepTextLayer: true
12565 });
12566 }
12567 cancelRendering({
12568 keepAnnotationLayer = false,
12569 keepAnnotationEditorLayer = false,
12570 keepXfaLayer = false,
12571 keepTextLayer = false,
12572 cancelExtraDelay = 0
12573 } = {}) {
12574 if (this.renderTask) {
12575 this.renderTask.cancel(cancelExtraDelay);
12576 this.renderTask = null;
12577 }
12578 this.resume = null;
12579 if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) {
12580 this.textLayer.cancel();
12581 this.textLayer = null;
12582 }
12583 if (this.structTreeLayer && !this.textLayer) {
12584 this.structTreeLayer = null;
12585 }
12586 if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
12587 this.annotationLayer.cancel();
12588 this.annotationLayer = null;
12589 this._annotationCanvasMap = null;
12590 }
12591 if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
12592 if (this.drawLayer) {
12593 this.drawLayer.cancel();
12594 this.drawLayer = null;
12595 }
12596 this.annotationEditorLayer.cancel();
12597 this.annotationEditorLayer = null;
12598 }
12599 if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
12600 this.xfaLayer.cancel();
12601 this.xfaLayer = null;
12602 this._textHighlighter?.disable();
12603 }
12604 }
12605 cssTransform({
12606 target,
12607 redrawAnnotationLayer = false,
12608 redrawAnnotationEditorLayer = false,
12609 redrawXfaLayer = false,
12610 redrawTextLayer = false,
12611 hideTextLayer = false
12612 }) {
12613 if (!target.hasAttribute("zooming")) {
12614 target.setAttribute("zooming", true);
12615 const {
12616 style
12617 } = target;
12618 style.width = style.height = "";
12619 }
12620 const originalViewport = this.#viewportMap.get(target);
12621 if (this.viewport !== originalViewport) {
12622 const relativeRotation = this.viewport.rotation - originalViewport.rotation;
12623 const absRotation = Math.abs(relativeRotation);
12624 let scaleX = 1,
12625 scaleY = 1;
12626 if (absRotation === 90 || absRotation === 270) {
12627 const {
12628 width,
12629 height
12630 } = this.viewport;
12631 scaleX = height / width;
12632 scaleY = width / height;
12633 }
12634 target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
12635 }
12636 if (redrawAnnotationLayer && this.annotationLayer) {
12637 this.#renderAnnotationLayer();
12638 }
12639 if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
12640 if (this.drawLayer) {
12641 this.#renderDrawLayer();
12642 }
12643 this.#renderAnnotationEditorLayer();
12644 }
12645 if (redrawXfaLayer && this.xfaLayer) {
12646 this.#renderXfaLayer();
12647 }
12648 if (this.textLayer) {
12649 if (hideTextLayer) {
12650 this.textLayer.hide();
12651 this.structTreeLayer?.hide();
12652 } else if (redrawTextLayer) {
12653 this.#renderTextLayer();
12654 }
12655 }
12656 }
12657 get width() {
12658 return this.viewport.width;
12659 }
12660 get height() {
12661 return this.viewport.height;
12662 }
12663 getPagePoint(x, y) {
12664 return this.viewport.convertToPdfPoint(x, y);
12665 }
12666 async #finishRenderTask(renderTask, error = null) {
12667 if (renderTask === this.renderTask) {
12668 this.renderTask = null;
12669 }
12670 if (error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException) {
12671 this.#renderError = null;
12672 return;
12673 }
12674 this.#renderError = error;
12675 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
12676 this._resetZoomLayer(true);
12677 this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots;
12678 this.eventBus.dispatch("pagerendered", {
12679 source: this,
12680 pageNumber: this.id,
12681 cssTransform: false,
12682 timestamp: performance.now(),
12683 error: this.#renderError
12684 });
12685 if (error) {
12686 throw error;
12687 }
12688 }
12689 async draw() {
12690 if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL) {
12691 globalThis.ngxConsole.error("Must be in new state before drawing");
12692 this.reset();
12693 }
12694 const {
12695 div,
12696 l10n,
12697 pageColors,
12698 pdfPage,
12699 viewport
12700 } = this;
12701 if (!pdfPage) {
12702 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
12703 throw new Error("pdfPage is not loaded");
12704 }
12705 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING;
12706 const canvasWrapper = document.createElement("div");
12707 canvasWrapper.classList.add("canvasWrapper");
12708 canvasWrapper.setAttribute("aria-hidden", true);
12709 this.#addLayer(canvasWrapper, "canvasWrapper");
12710 if (!this.textLayer && this.#textLayerMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.DISABLE && !pdfPage.isPureXfa) {
12711 this._accessibilityManager ||= new _text_accessibility_js__WEBPACK_IMPORTED_MODULE_9__.TextAccessibilityManager();
12712 this.textLayer = new _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_12__.TextLayerBuilder({
12713 highlighter: this._textHighlighter,
12714 accessibilityManager: this._accessibilityManager,
12715 enablePermissions: this.#textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS,
12716 onAppend: textLayerDiv => {
12717 this.l10n.pause();
12718 this.#addLayer(textLayerDiv, "textLayer");
12719 this.l10n.resume();
12720 }
12721 });
12722 }
12723 if (!this.annotationLayer && this.#annotationMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.DISABLE) {
12724 const {
12725 annotationStorage,
12726 annotationEditorUIManager,
12727 downloadManager,
12728 enableScripting,
12729 fieldObjectsPromise,
12730 hasJSActionsPromise,
12731 linkService
12732 } = this.#layerProperties;
12733 this._annotationCanvasMap ||= new Map();
12734 this.annotationLayer = new _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__.AnnotationLayerBuilder({
12735 pdfPage,
12736 annotationStorage,
12737 imageResourcesPath: this.imageResourcesPath,
12738 renderForms: this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS,
12739 linkService,
12740 downloadManager,
12741 enableScripting,
12742 hasJSActionsPromise,
12743 fieldObjectsPromise,
12744 annotationCanvasMap: this._annotationCanvasMap,
12745 accessibilityManager: this._accessibilityManager,
12746 annotationEditorUIManager,
12747 onAppend: annotationLayerDiv => {
12748 this.#addLayer(annotationLayerDiv, "annotationLayer");
12749 }
12750 });
12751 }
12752 const renderContinueCallback = cont => {
12753 showCanvas?.(false);
12754 if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) {
12755 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED;
12756 this.resume = () => {
12757 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING;
12758 cont();
12759 };
12760 return;
12761 }
12762 cont();
12763 };
12764 let {
12765 width,
12766 height
12767 } = viewport;
12768 const canvas = document.createElement("canvas");
12769 canvas.setAttribute("role", "presentation");
12770 canvas.hidden = true;
12771 const hasHCM = !!(pageColors?.background && pageColors?.foreground);
12772 let showCanvas = isLastShow => {
12773 if (!hasHCM || isLastShow) {
12774 canvas.hidden = false;
12775 showCanvas = null;
12776 }
12777 };
12778 canvasWrapper.append(canvas);
12779 this.canvas = canvas;
12780 const options = window.pdfDefaultOptions.activateWillReadFrequentlyFlag ? {
12781 willReadFrequently: true,
12782 alpha: false
12783 } : {
12784 alpha: false
12785 };
12786 const ctx = canvas.getContext("2d", options);
12787 const outputScale = this.outputScale = new _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.OutputScale();
12788 if (this.maxCanvasPixels === 0) {
12789 const invScale = 1 / this.scale;
12790 outputScale.sx *= invScale;
12791 outputScale.sy *= invScale;
12792 this.#hasRestrictedScaling = true;
12793 } else if (this.maxCanvasPixels > 0) {
12794 const pixelsInViewport = width * height;
12795 const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
12796 if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
12797 outputScale.sx = maxScale;
12798 outputScale.sy = maxScale;
12799 this.#hasRestrictedScaling = true;
12800 } else {
12801 this.#hasRestrictedScaling = false;
12802 }
12803 }
12804 const sfx = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.approximateFraction)(outputScale.sx);
12805 const sfy = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.approximateFraction)(outputScale.sy);
12806 width = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(width * outputScale.sx, sfx[0]);
12807 height = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(height * outputScale.sy, sfy[0]);
12808 let divisor = 1;
12809 if (width >= 4096 || height >= 4096) {
12810 if (!!this.maxWidth || !canvas_size__WEBPACK_IMPORTED_MODULE_10__["default"].test({
12811 width,
12812 height
12813 })) {
12814 const max = this.determineMaxDimensions();
12815 divisor = Math.max(width / max, height / max);
12816 if (divisor > 1) {
12817 const newScale = Math.floor(100 * this.scale / divisor) / 100;
12818 divisor = this.scale / newScale;
12819 viewport.width /= divisor;
12820 viewport.height /= divisor;
12821 (0,_src_shared_util_js__WEBPACK_IMPORTED_MODULE_11__.warn)(`Page ${this.id}: Reduced the maximum zoom to ${newScale} because the browser can't render larger canvases.`);
12822 } else {
12823 divisor = 1;
12824 }
12825 }
12826 }
12827 canvas.width = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
12828 canvas.height = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
12829 const {
12830 style
12831 } = canvas;
12832 style.width = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(viewport.width, sfx[1]) + "px";
12833 style.height = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(viewport.height, sfy[1]) + "px";
12834 this.#viewportMap.set(canvas, viewport);
12835 const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
12836 const renderContext = {
12837 canvasContext: ctx,
12838 transform,
12839 viewport,
12840 annotationMode: this.#annotationMode,
12841 optionalContentConfigPromise: this._optionalContentConfigPromise,
12842 annotationCanvasMap: this._annotationCanvasMap,
12843 pageColors
12844 };
12845 const renderTask = this.renderTask = this.pdfPage.render(renderContext);
12846 renderTask.onContinue = renderContinueCallback;
12847 const resultPromise = renderTask.promise.then(async () => {
12848 showCanvas?.(true);
12849 await this.#finishRenderTask(renderTask);
12850 this.#renderTextLayer();
12851 if (this.annotationLayer) {
12852 await this.#renderAnnotationLayer();
12853 }
12854 const {
12855 annotationEditorUIManager
12856 } = this.#layerProperties;
12857 if (!annotationEditorUIManager) {
12858 return;
12859 }
12860 this.drawLayer ||= new _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__.DrawLayerBuilder({
12861 pageIndex: this.id
12862 });
12863 await this.#renderDrawLayer();
12864 this.drawLayer.setParent(canvasWrapper);
12865 if (!this.annotationEditorLayer) {
12866 this.annotationEditorLayer = new _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__.AnnotationEditorLayerBuilder({
12867 uiManager: annotationEditorUIManager,
12868 pdfPage,
12869 l10n,
12870 accessibilityManager: this._accessibilityManager,
12871 annotationLayer: this.annotationLayer?.annotationLayer,
12872 textLayer: this.textLayer,
12873 drawLayer: this.drawLayer.getDrawLayer(),
12874 onAppend: annotationEditorLayerDiv => {
12875 this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer");
12876 },
12877 eventBus: this.eventBus
12878 });
12879 }
12880 this.#renderAnnotationEditorLayer();
12881 }, error => {
12882 if (!(error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException)) {
12883 showCanvas?.(true);
12884 }
12885 return this.#finishRenderTask(renderTask, error);
12886 });
12887 if (pdfPage.isPureXfa) {
12888 if (!this.xfaLayer) {
12889 const {
12890 annotationStorage,
12891 linkService
12892 } = this.#layerProperties;
12893 this.xfaLayer = new _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_13__.XfaLayerBuilder({
12894 pdfPage,
12895 annotationStorage,
12896 linkService
12897 });
12898 }
12899 this.#renderXfaLayer();
12900 }
12901 div.setAttribute("data-loaded", true);
12902 this.eventBus.dispatch("pagerender", {
12903 source: this,
12904 pageNumber: this.id
12905 });
12906 return resultPromise;
12907 }
12908 setPageLabel(label) {
12909 this.pageLabel = typeof label === "string" ? label : null;
12910 this.div.setAttribute("data-l10n-args", JSON.stringify({
12911 page: this.pageLabel ?? this.id
12912 }));
12913 if (this.pageLabel !== null) {
12914 this.div.setAttribute("data-page-label", this.pageLabel);
12915 } else {
12916 this.div.removeAttribute("data-page-label");
12917 }
12918 }
12919 determineMaxDimensions() {
12920 if (this.maxWidth) {
12921 return this.maxWidth;
12922 }
12923 const checklist = [4096, 8192, 10836, 11180, 11402, 14188, 16384];
12924 for (const width of checklist) {
12925 if (!canvas_size__WEBPACK_IMPORTED_MODULE_10__["default"].test({
12926 width: width + 1,
12927 height: width + 1
12928 })) {
12929 this.maxWidth = width;
12930 return this.maxWidth;
12931 }
12932 }
12933 return 16384;
12934 }
12935 get thumbnailCanvas() {
12936 const {
12937 directDrawing,
12938 initialOptionalContent,
12939 regularAnnotations
12940 } = this.#useThumbnailCanvas;
12941 return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null;
12942 }
12943}
12944
12945__webpack_async_result__();
12946} catch(e) { __webpack_async_result__(e); } });
12947
12948/***/ }),
12949
12950/***/ 8917:
12951/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
12952
12953__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
12954/* harmony export */ __webpack_require__.d(__webpack_exports__, {
12955/* harmony export */ PDFPresentationMode: () => (/* binding */ PDFPresentationMode)
12956/* harmony export */ });
12957/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
12958/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
12959var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
12960pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
12961
12962
12963const DELAY_BEFORE_HIDING_CONTROLS = 3000;
12964const ACTIVE_SELECTOR = "pdfPresentationMode";
12965const CONTROLS_SELECTOR = "pdfPresentationModeControls";
12966const MOUSE_SCROLL_COOLDOWN_TIME = 50;
12967const PAGE_SWITCH_THRESHOLD = 0.1;
12968const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
12969const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
12970class PDFPresentationMode {
12971 #state = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.UNKNOWN;
12972 #args = null;
12973 #fullscreenChangeAbortController = null;
12974 #windowAbortController = null;
12975 constructor({
12976 container,
12977 pdfViewer,
12978 eventBus
12979 }) {
12980 this.container = container;
12981 this.pdfViewer = pdfViewer;
12982 this.eventBus = eventBus;
12983 this.contextMenuOpen = false;
12984 this.mouseScrollTimeStamp = 0;
12985 this.mouseScrollDelta = 0;
12986 this.touchSwipeState = null;
12987 }
12988 async request() {
12989 const {
12990 container,
12991 pdfViewer
12992 } = this;
12993 if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
12994 return false;
12995 }
12996 this.#addFullscreenChangeListeners();
12997 this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.CHANGING);
12998 const promise = container.requestFullscreen();
12999 this.#args = {
13000 pageNumber: pdfViewer.currentPageNumber,
13001 scaleValue: pdfViewer.currentScaleValue,
13002 scrollMode: pdfViewer.scrollMode,
13003 spreadMode: null,
13004 annotationEditorMode: null
13005 };
13006 if (pdfViewer.spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
13007 console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
13008 this.#args.spreadMode = pdfViewer.spreadMode;
13009 }
13010 if (pdfViewer.annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.DISABLE) {
13011 this.#args.annotationEditorMode = pdfViewer.annotationEditorMode;
13012 }
13013 try {
13014 await promise;
13015 pdfViewer.focus();
13016 return true;
13017 } catch {
13018 this.#removeFullscreenChangeListeners();
13019 this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL);
13020 }
13021 return false;
13022 }
13023 get active() {
13024 return this.#state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.CHANGING || this.#state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.FULLSCREEN;
13025 }
13026 #mouseWheel(evt) {
13027 if (!this.active) {
13028 return;
13029 }
13030 evt.preventDefault();
13031 const delta = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.normalizeWheelEventDelta)(evt);
13032 const currentTime = Date.now();
13033 const storedTime = this.mouseScrollTimeStamp;
13034 if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
13035 return;
13036 }
13037 if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
13038 this.#resetMouseScrollState();
13039 }
13040 this.mouseScrollDelta += delta;
13041 if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
13042 const totalDelta = this.mouseScrollDelta;
13043 this.#resetMouseScrollState();
13044 const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
13045 if (success) {
13046 this.mouseScrollTimeStamp = currentTime;
13047 }
13048 }
13049 }
13050 #notifyStateChange(state) {
13051 this.#state = state;
13052 this.eventBus.dispatch("presentationmodechanged", {
13053 source: this,
13054 state
13055 });
13056 }
13057 #enter() {
13058 this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.FULLSCREEN);
13059 this.container.classList.add(ACTIVE_SELECTOR);
13060 setTimeout(() => {
13061 this.pdfViewer.scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE;
13062 if (this.#args.spreadMode !== null) {
13063 this.pdfViewer.spreadMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE;
13064 }
13065 this.pdfViewer.currentPageNumber = this.#args.pageNumber;
13066 this.pdfViewer.currentScaleValue = "page-fit";
13067 if (this.#args.annotationEditorMode !== null) {
13068 this.pdfViewer.annotationEditorMode = {
13069 mode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.NONE
13070 };
13071 }
13072 }, 0);
13073 this.#addWindowListeners();
13074 this.#showControls();
13075 this.contextMenuOpen = false;
13076 document.getSelection().empty();
13077 }
13078 #exit() {
13079 const pageNumber = this.pdfViewer.currentPageNumber;
13080 this.container.classList.remove(ACTIVE_SELECTOR);
13081 setTimeout(() => {
13082 this.#removeFullscreenChangeListeners();
13083 this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL);
13084 this.pdfViewer.scrollMode = this.#args.scrollMode;
13085 if (this.#args.spreadMode !== null) {
13086 this.pdfViewer.spreadMode = this.#args.spreadMode;
13087 }
13088 this.pdfViewer.currentScaleValue = this.#args.scaleValue;
13089 this.pdfViewer.currentPageNumber = pageNumber;
13090 if (this.#args.annotationEditorMode !== null) {
13091 this.pdfViewer.annotationEditorMode = {
13092 mode: this.#args.annotationEditorMode
13093 };
13094 }
13095 this.#args = null;
13096 }, 0);
13097 this.#removeWindowListeners();
13098 this.#hideControls();
13099 this.#resetMouseScrollState();
13100 this.contextMenuOpen = false;
13101 }
13102 _prepareFullscreenMode() {
13103 const domElement = document.getElementsByClassName("zoom")[0].parentElement;
13104 const parent = domElement.parentElement;
13105 this.ngxContainer = parent;
13106 for (let i = 0; i < parent.childElementCount; i++) {
13107 if (parent.children.item(i) === domElement) {
13108 this.ngxContainerIndex = i;
13109 }
13110 }
13111 parent.removeChild(domElement);
13112 document.body.append(domElement);
13113 const siblings = document.body.children;
13114 for (let i = 0; i < siblings.length; i++) {
13115 const s = siblings.item(i);
13116 if (s !== domElement && s instanceof HTMLElement) {
13117 s.classList.add("hidden-by-fullscreen");
13118 }
13119 }
13120 document.getElementById("sidebarContainer").classList.add("hidden-by-fullscreen");
13121 document.getElementsByClassName("toolbar")[0].classList.add("hidden-by-fullscreen");
13122 }
13123 _tidyUpFullscreenMode() {
13124 if (this.ngxContainer) {
13125 const domElement = document.getElementsByClassName("zoom")[0].parentElement;
13126 document.body.removeChild(domElement);
13127 if (this.ngxContainerIndex >= this.ngxContainer.childElementCount) {
13128 this.ngxContainer.append(domElement);
13129 } else {
13130 this.ngxContainer.insertBefore(domElement, this.ngxContainer.children.item(this.ngxContainerIndex));
13131 }
13132 this.ngxContainer = undefined;
13133 const siblings = document.body.children;
13134 for (let i = 0; i < siblings.length; i++) {
13135 const s = siblings.item(i);
13136 if (s !== domElement && s instanceof HTMLElement) {
13137 if (s.classList.contains("hidden-by-fullscreen")) {
13138 s.classList.remove("hidden-by-fullscreen");
13139 }
13140 }
13141 }
13142 document.getElementById("sidebarContainer").classList.remove("hidden-by-fullscreen");
13143 document.getElementsByClassName("toolbar")[0].classList.remove("hidden-by-fullscreen");
13144 }
13145 }
13146 #mouseDown(evt) {
13147 if (this.contextMenuOpen) {
13148 this.contextMenuOpen = false;
13149 evt.preventDefault();
13150 return;
13151 }
13152 if (evt.button !== 0) {
13153 return;
13154 }
13155 if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) {
13156 return;
13157 }
13158 evt.preventDefault();
13159 if (evt.shiftKey) {
13160 this.pdfViewer.previousPage();
13161 } else {
13162 this.pdfViewer.nextPage();
13163 }
13164 }
13165 #contextMenu() {
13166 this.contextMenuOpen = true;
13167 }
13168 #showControls() {
13169 if (this.controlsTimeout) {
13170 clearTimeout(this.controlsTimeout);
13171 } else {
13172 this.container.classList.add(CONTROLS_SELECTOR);
13173 }
13174 this.controlsTimeout = setTimeout(() => {
13175 this.container.classList.remove(CONTROLS_SELECTOR);
13176 delete this.controlsTimeout;
13177 }, DELAY_BEFORE_HIDING_CONTROLS);
13178 }
13179 #hideControls() {
13180 if (!this.controlsTimeout) {
13181 return;
13182 }
13183 clearTimeout(this.controlsTimeout);
13184 this.container.classList.remove(CONTROLS_SELECTOR);
13185 delete this.controlsTimeout;
13186 }
13187 #resetMouseScrollState() {
13188 this.mouseScrollTimeStamp = 0;
13189 this.mouseScrollDelta = 0;
13190 }
13191 #touchSwipe(evt) {
13192 if (!this.active) {
13193 return;
13194 }
13195 if (evt.touches.length > 1) {
13196 this.touchSwipeState = null;
13197 return;
13198 }
13199 switch (evt.type) {
13200 case "touchstart":
13201 this.touchSwipeState = {
13202 startX: evt.touches[0].pageX,
13203 startY: evt.touches[0].pageY,
13204 endX: evt.touches[0].pageX,
13205 endY: evt.touches[0].pageY
13206 };
13207 break;
13208 case "touchmove":
13209 if (this.touchSwipeState === null) {
13210 return;
13211 }
13212 this.touchSwipeState.endX = evt.touches[0].pageX;
13213 this.touchSwipeState.endY = evt.touches[0].pageY;
13214 evt.preventDefault();
13215 break;
13216 case "touchend":
13217 if (this.touchSwipeState === null) {
13218 return;
13219 }
13220 let delta = 0;
13221 const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
13222 const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
13223 const absAngle = Math.abs(Math.atan2(dy, dx));
13224 if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
13225 delta = dx;
13226 } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
13227 delta = dy;
13228 }
13229 if (delta > 0) {
13230 this.pdfViewer.previousPage();
13231 } else if (delta < 0) {
13232 this.pdfViewer.nextPage();
13233 }
13234 break;
13235 }
13236 }
13237 #addWindowListeners() {
13238 if (this.#windowAbortController) {
13239 return;
13240 }
13241 this.#windowAbortController = new AbortController();
13242 const {
13243 signal
13244 } = this.#windowAbortController;
13245 const touchSwipeBind = this.#touchSwipe.bind(this);
13246 window.addEventListener("mousemove", this.#showControls.bind(this), {
13247 signal
13248 });
13249 window.addEventListener("mousedown", this.#mouseDown.bind(this), {
13250 signal
13251 });
13252 window.addEventListener("wheel", this.#mouseWheel.bind(this), {
13253 passive: false,
13254 signal
13255 });
13256 window.addEventListener("keydown", this.#resetMouseScrollState.bind(this), {
13257 signal
13258 });
13259 window.addEventListener("contextmenu", this.#contextMenu.bind(this), {
13260 signal
13261 });
13262 window.addEventListener("touchstart", touchSwipeBind, {
13263 signal
13264 });
13265 window.addEventListener("touchmove", touchSwipeBind, {
13266 signal
13267 });
13268 window.addEventListener("touchend", touchSwipeBind, {
13269 signal
13270 });
13271 }
13272 #removeWindowListeners() {
13273 this.#windowAbortController?.abort();
13274 this.#windowAbortController = null;
13275 }
13276 #addFullscreenChangeListeners() {
13277 if (this.#fullscreenChangeAbortController) {
13278 return;
13279 }
13280 this.#fullscreenChangeAbortController = new AbortController();
13281 window.addEventListener("fullscreenchange", () => {
13282 if (document.fullscreenElement) {
13283 this.#enter();
13284 } else {
13285 this.#exit();
13286 }
13287 }, {
13288 signal: this.#fullscreenChangeAbortController.signal
13289 });
13290 }
13291 #removeFullscreenChangeListeners() {
13292 this.#fullscreenChangeAbortController?.abort();
13293 this.#fullscreenChangeAbortController = null;
13294 }
13295}
13296
13297__webpack_async_result__();
13298} catch(e) { __webpack_async_result__(e); } });
13299
13300/***/ }),
13301
13302/***/ 1144:
13303/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
13304
13305__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
13306/* harmony export */ __webpack_require__.d(__webpack_exports__, {
13307/* harmony export */ PDFPrintServiceFactory: () => (/* binding */ PDFPrintServiceFactory)
13308/* harmony export */ });
13309/* harmony import */ var canvas_size__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8394);
13310/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
13311/* harmony import */ var _print_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(659);
13312/* harmony import */ var _src_shared_util_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4292);
13313var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__, _print_utils_js__WEBPACK_IMPORTED_MODULE_2__]);
13314([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__, _print_utils_js__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
13315
13316
13317
13318
13319let activeService = null;
13320let dialog = null;
13321let overlayManager = null;
13322let viewerApp = {
13323 initialized: false
13324};
13325function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
13326 const scratchCanvas = activeService.scratchCanvas;
13327 let PRINT_UNITS = printResolution / pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PixelsPerInch.PDF;
13328 let scale = 1;
13329 const canvasWidth = Math.floor(size.width * PRINT_UNITS);
13330 const canvasHeight = Math.floor(size.height * PRINT_UNITS);
13331 if (canvasWidth >= 4096 || canvasHeight >= 4096) {
13332 if (!canvas_size__WEBPACK_IMPORTED_MODULE_0__["default"].test({
13333 width: canvasWidth,
13334 height: canvasHeight
13335 })) {
13336 const max = determineMaxDimensions();
13337 scale = Math.min(max / canvasWidth, max / canvasHeight) * 0.95;
13338 }
13339 (0,_src_shared_util_js__WEBPACK_IMPORTED_MODULE_3__.warn)("Page " + pageNumber + ": Reduced the [printResolution] to " + Math.floor(printResolution * scale) + " because the browser can't render larger canvases. If you see blank page in the print preview, reduce [printResolution] manually to a lower value.");
13340 }
13341 PRINT_UNITS *= scale;
13342 scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
13343 scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
13344 const options = window.pdfDefaultOptions.activateWillReadFrequentlyFlag ? {
13345 willReadFrequently: true
13346 } : undefined;
13347 const ctx = scratchCanvas.getContext("2d", options);
13348 ctx.save();
13349 ctx.fillStyle = "rgb(255, 255, 255)";
13350 ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
13351 ctx.restore();
13352 return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function ([pdfPage, printAnnotationStorage]) {
13353 const renderContext = {
13354 canvasContext: ctx,
13355 transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
13356 viewport: pdfPage.getViewport({
13357 scale: 1,
13358 rotation: size.rotation
13359 }),
13360 intent: "print",
13361 annotationMode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationMode.ENABLE_STORAGE,
13362 optionalContentConfigPromise,
13363 printAnnotationStorage
13364 };
13365 const renderTask = pdfPage.render(renderContext);
13366 return renderTask.promise.catch(reason => {
13367 if (!(reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.RenderingCancelledException)) {
13368 console.error(reason);
13369 }
13370 throw reason;
13371 });
13372 });
13373}
13374function determineMaxDimensions() {
13375 const checklist = [4096, 8192, 10836, 11180, 11402, 14188, 16384];
13376 for (let width of checklist) {
13377 if (!canvas_size__WEBPACK_IMPORTED_MODULE_0__["default"].test({
13378 width: width + 1,
13379 height: width + 1
13380 })) {
13381 return width;
13382 }
13383 }
13384 return 16384;
13385}
13386class PDFPrintService {
13387 constructor({
13388 pdfDocument,
13389 pagesOverview,
13390 printContainer,
13391 printResolution,
13392 printAnnotationStoragePromise = null,
13393 eventBus
13394 }) {
13395 this.pdfDocument = pdfDocument;
13396 this.pagesOverview = pagesOverview;
13397 this.printContainer = printContainer;
13398 this._printResolution = printResolution || 150;
13399 this._optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
13400 intent: "print"
13401 });
13402 this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve();
13403 this.currentPage = -1;
13404 this.scratchCanvas = document.createElement("canvas");
13405 this.eventBus = eventBus;
13406 }
13407 layout() {
13408 this.throwIfInactive();
13409 const body = document.querySelector("body");
13410 body.setAttribute("data-pdfjsprinting", true);
13411 const html = document.querySelector("html");
13412 html.setAttribute("data-pdfjsprinting", true);
13413 const {
13414 width,
13415 height
13416 } = this.pagesOverview[0];
13417 const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height);
13418 if (!hasEqualPageSizes) {
13419 globalThis.ngxConsole.warn("Not all pages have the same size. The printed result may be incorrect!");
13420 }
13421 this.pageStyleSheet = document.createElement("style");
13422 this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`;
13423 body.append(this.pageStyleSheet);
13424 }
13425 destroy() {
13426 if (activeService !== this) {
13427 return;
13428 }
13429 this.printContainer.textContent = "";
13430 const body = document.querySelector("body");
13431 body.removeAttribute("data-pdfjsprinting");
13432 const html = document.querySelector("html");
13433 html.removeAttribute("data-pdfjsprinting");
13434 if (this.pageStyleSheet) {
13435 this.pageStyleSheet.remove();
13436 this.pageStyleSheet = null;
13437 }
13438 this.scratchCanvas.width = this.scratchCanvas.height = 0;
13439 this.scratchCanvas = null;
13440 activeService = null;
13441 ensureOverlay().then(function () {
13442 if (overlayManager.active === dialog) {
13443 overlayManager.close(dialog);
13444 }
13445 });
13446 }
13447 renderPages() {
13448 if (this.pdfDocument.isPureXfa) {
13449 (0,_print_utils_js__WEBPACK_IMPORTED_MODULE_2__.getXfaHtmlForPrinting)(this.printContainer, this.pdfDocument);
13450 return Promise.resolve();
13451 }
13452 const pageCount = this.pagesOverview.length;
13453 const renderNextPage = (resolve, reject) => {
13454 this.throwIfInactive();
13455 while (true) {
13456 ++this.currentPage;
13457 if (this.currentPage >= pageCount) {
13458 break;
13459 }
13460 if (!window.isInPDFPrintRange || window.isInPDFPrintRange(this.currentPage)) {
13461 break;
13462 }
13463 }
13464 if (this.currentPage >= pageCount) {
13465 renderProgress(window.filteredPageCount | pageCount, window.filteredPageCount | pageCount, this.eventBus);
13466 resolve();
13467 return;
13468 }
13469 const index = this.currentPage;
13470 renderProgress(index, window.filteredPageCount | pageCount, this.eventBus);
13471 renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () {
13472 renderNextPage(resolve, reject);
13473 }, reject);
13474 };
13475 return new Promise(renderNextPage);
13476 }
13477 useRenderedPage() {
13478 this.throwIfInactive();
13479 const img = document.createElement("img");
13480 const scratchCanvas = this.scratchCanvas;
13481 if ("toBlob" in scratchCanvas) {
13482 scratchCanvas.toBlob(function (blob) {
13483 img.src = URL.createObjectURL(blob);
13484 });
13485 } else {
13486 img.src = scratchCanvas.toDataURL();
13487 }
13488 const wrapper = document.createElement("div");
13489 wrapper.className = "printedPage";
13490 wrapper.append(img);
13491 this.printContainer.append(wrapper);
13492 return new Promise(function (resolve, reject) {
13493 img.onload = resolve;
13494 img.onerror = reject;
13495 });
13496 }
13497 performPrint() {
13498 this.throwIfInactive();
13499 return new Promise(resolve => {
13500 setTimeout(() => {
13501 if (!this.active) {
13502 resolve();
13503 return;
13504 }
13505 print.call(window);
13506 const isIOS = navigator.platform && ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
13507 setTimeout(resolve, isIOS ? 1500 : 20);
13508 }, 0);
13509 });
13510 }
13511 get active() {
13512 return this === activeService;
13513 }
13514 throwIfInactive() {
13515 if (!this.active) {
13516 throw new Error("This print request was cancelled or completed.");
13517 }
13518 }
13519}
13520const print = window.print;
13521window.printPDF = function printPdf() {
13522 if (!PDFViewerApplication.enablePrint) {
13523 return;
13524 }
13525 if (activeService) {
13526 globalThis.ngxConsole.warn("Ignored window.printPDF() because of a pending print job.");
13527 return;
13528 }
13529 ensureOverlay().then(function () {
13530 if (activeService) {
13531 overlayManager.open(dialog);
13532 }
13533 });
13534 try {
13535 dispatchEvent("beforeprint");
13536 } finally {
13537 if (!activeService) {
13538 globalThis.ngxConsole.error("Expected print service to be initialized.");
13539 ensureOverlay().then(function () {
13540 if (overlayManager.active === dialog) {
13541 overlayManager.close(dialog);
13542 }
13543 });
13544 return;
13545 }
13546 const activeServiceOnEntry = activeService;
13547 activeService.renderPages().then(function () {
13548 const progressIndicator = document.getElementById("printServiceDialog");
13549 if (progressIndicator) {
13550 progressIndicator.classList.add("hidden");
13551 }
13552 return activeServiceOnEntry.performPrint();
13553 }).catch(function () {}).then(function () {
13554 if (activeServiceOnEntry.active) {
13555 abort();
13556 }
13557 });
13558 }
13559};
13560function dispatchEvent(eventType) {
13561 const event = new CustomEvent(eventType, {
13562 bubbles: false,
13563 cancelable: false,
13564 detail: "custom"
13565 });
13566 window.dispatchEvent(event);
13567}
13568function abort() {
13569 if (activeService) {
13570 activeService.destroy();
13571 dispatchEvent("afterprint");
13572 }
13573}
13574function renderProgress(index, total, eventBus) {
13575 dialog = document.getElementById("printServiceDialog");
13576 const progress = Math.round(100 * index / total);
13577 const progressBar = dialog.querySelector("progress");
13578 const progressPerc = dialog.querySelector(".relative-progress");
13579 progressBar.value = progress;
13580 progressPerc.setAttribute("data-l10n-args", JSON.stringify({
13581 progress
13582 }));
13583 eventBus.dispatch("progress", {
13584 source: this,
13585 type: "print",
13586 total,
13587 page: index,
13588 percent: 100 * index / total
13589 });
13590}
13591window.addEventListener("keydown", function (event) {
13592 if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
13593 window.print();
13594 event.preventDefault();
13595 event.stopImmediatePropagation();
13596 }
13597}, true);
13598if ("onbeforeprint" in window) {
13599 const stopPropagationIfNeeded = function (event) {
13600 if (event.detail !== "custom") {
13601 event.stopImmediatePropagation();
13602 }
13603 };
13604 window.addEventListener("beforeprint", stopPropagationIfNeeded);
13605 window.addEventListener("afterprint", stopPropagationIfNeeded);
13606}
13607let overlayPromise;
13608function ensureOverlay() {
13609 if (!overlayPromise) {
13610 overlayManager = viewerApp.overlayManager;
13611 if (!overlayManager) {
13612 throw new Error("The overlay manager has not yet been initialized.");
13613 }
13614 dialog = document.getElementById("printServiceDialog");
13615 overlayPromise = overlayManager.register(dialog, true);
13616 document.getElementById("printCancel").onclick = abort;
13617 dialog.addEventListener("close", abort);
13618 }
13619 return overlayPromise;
13620}
13621class PDFPrintServiceFactory {
13622 static initGlobals(app) {
13623 viewerApp = app;
13624 }
13625 static get supportsPrinting() {
13626 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsPrinting", true);
13627 }
13628 static createPrintService(params) {
13629 if (activeService) {
13630 throw new Error("The print service is created and active.");
13631 }
13632 return activeService = new PDFPrintService(params);
13633 }
13634}
13635
13636__webpack_async_result__();
13637} catch(e) { __webpack_async_result__(e); } });
13638
13639/***/ }),
13640
13641/***/ 6615:
13642/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
13643
13644__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
13645/* harmony export */ __webpack_require__.d(__webpack_exports__, {
13646/* harmony export */ PDFRenderingQueue: () => (/* binding */ PDFRenderingQueue)
13647/* harmony export */ });
13648/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
13649/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
13650var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
13651pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
13652
13653
13654const CLEANUP_TIMEOUT = 30000;
13655class PDFRenderingQueue {
13656 constructor() {
13657 this.pdfViewer = null;
13658 this.pdfThumbnailViewer = null;
13659 this.onIdle = null;
13660 this.highestPriorityPage = null;
13661 this.idleTimeout = null;
13662 this.printing = false;
13663 this.isThumbnailViewEnabled = false;
13664 Object.defineProperty(this, "hasViewer", {
13665 value: () => !!this.pdfViewer
13666 });
13667 }
13668 setViewer(pdfViewer) {
13669 this.pdfViewer = pdfViewer;
13670 }
13671 setThumbnailViewer(pdfThumbnailViewer) {
13672 this.pdfThumbnailViewer = pdfThumbnailViewer;
13673 }
13674 isHighestPriority(view) {
13675 return this.highestPriorityPage === view.renderingId;
13676 }
13677 renderHighestPriority(currentlyVisiblePages) {
13678 if (this.idleTimeout) {
13679 clearTimeout(this.idleTimeout);
13680 this.idleTimeout = null;
13681 }
13682 if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
13683 return;
13684 }
13685 if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) {
13686 return;
13687 }
13688 if (this.printing) {
13689 return;
13690 }
13691 if (this.onIdle) {
13692 this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
13693 }
13694 }
13695 getHighestPriority(visible, views, scrolledDown, preRenderExtra = false) {
13696 const visibleViews = visible.views,
13697 numVisible = visibleViews.length;
13698 if (numVisible === 0) {
13699 return null;
13700 }
13701 for (let i = 0; i < numVisible; i++) {
13702 const view = visibleViews[i].view;
13703 if (!this.isViewFinished(view)) {
13704 return view;
13705 }
13706 }
13707 const firstId = visible.first.id,
13708 lastId = visible.last.id;
13709 if (lastId - firstId + 1 > numVisible) {
13710 const visibleIds = visible.ids;
13711 for (let i = 1, ii = lastId - firstId; i < ii; i++) {
13712 const holeId = scrolledDown ? firstId + i : lastId - i;
13713 if (visibleIds.has(holeId)) {
13714 continue;
13715 }
13716 const holeView = views[holeId - 1];
13717 if (!this.isViewFinished(holeView)) {
13718 return holeView;
13719 }
13720 }
13721 }
13722 let preRenderIndex = scrolledDown ? lastId : firstId - 2;
13723 let preRenderView = views[preRenderIndex];
13724 if (preRenderView && !this.isViewFinished(preRenderView)) {
13725 return preRenderView;
13726 }
13727 if (preRenderExtra) {
13728 preRenderIndex += scrolledDown ? 1 : -1;
13729 preRenderView = views[preRenderIndex];
13730 if (preRenderView && !this.isViewFinished(preRenderView)) {
13731 return preRenderView;
13732 }
13733 }
13734 return null;
13735 }
13736 isViewFinished(view) {
13737 return view.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
13738 }
13739 renderView(view) {
13740 switch (view.renderingState) {
13741 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED:
13742 return false;
13743 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED:
13744 this.highestPriorityPage = view.renderingId;
13745 view.resume();
13746 break;
13747 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING:
13748 this.highestPriorityPage = view.renderingId;
13749 break;
13750 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL:
13751 this.highestPriorityPage = view.renderingId;
13752 view.draw().finally(() => {
13753 this.renderHighestPriority();
13754 }).catch(reason => {
13755 if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException) {
13756 return;
13757 }
13758 globalThis.ngxConsole.error(`renderView: "${reason}"`);
13759 });
13760 break;
13761 }
13762 return true;
13763 }
13764}
13765
13766__webpack_async_result__();
13767} catch(e) { __webpack_async_result__(e); } });
13768
13769/***/ }),
13770
13771/***/ 5942:
13772/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
13773
13774__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
13775/* harmony export */ __webpack_require__.d(__webpack_exports__, {
13776/* harmony export */ PDFScriptingManager: () => (/* binding */ PDFScriptingManager)
13777/* harmony export */ });
13778/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
13779/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
13780var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
13781pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
13782
13783
13784class PDFScriptingManager {
13785 #closeCapability = null;
13786 #destroyCapability = null;
13787 #docProperties = null;
13788 #eventAbortController = null;
13789 #eventBus = null;
13790 #externalServices = null;
13791 #pdfDocument = null;
13792 #pdfViewer = null;
13793 #ready = false;
13794 #scripting = null;
13795 #willPrintCapability = null;
13796 constructor({
13797 eventBus,
13798 externalServices = null,
13799 docProperties = null
13800 }) {
13801 this.#eventBus = eventBus;
13802 this.#externalServices = externalServices;
13803 this.#docProperties = docProperties;
13804 }
13805 setViewer(pdfViewer) {
13806 this.#pdfViewer = pdfViewer;
13807 }
13808 async setDocument(pdfDocument) {
13809 if (this.#pdfDocument) {
13810 await this.#destroyScripting();
13811 }
13812 this.#pdfDocument = pdfDocument;
13813 if (!pdfDocument) {
13814 return;
13815 }
13816 const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
13817 if (!objects && !docActions) {
13818 await this.#destroyScripting();
13819 return;
13820 }
13821 if (pdfDocument !== this.#pdfDocument) {
13822 return;
13823 }
13824 try {
13825 this.#scripting = this.#initScripting();
13826 } catch (error) {
13827 globalThis.ngxConsole.error(`setDocument: "${error.message}".`);
13828 await this.#destroyScripting();
13829 return;
13830 }
13831 const eventBus = this.#eventBus;
13832 this.#eventAbortController = new AbortController();
13833 const {
13834 signal
13835 } = this.#eventAbortController;
13836 eventBus._on("updatefromsandbox", event => {
13837 if (event?.source === window) {
13838 this.#updateFromSandbox(event.detail);
13839 }
13840 }, {
13841 signal
13842 });
13843 eventBus._on("dispatcheventinsandbox", event => {
13844 this.#scripting?.dispatchEventInSandbox(event.detail);
13845 }, {
13846 signal
13847 });
13848 eventBus._on("pagechanging", ({
13849 pageNumber,
13850 previous
13851 }) => {
13852 if (pageNumber === previous) {
13853 return;
13854 }
13855 this.#dispatchPageClose(previous);
13856 this.#dispatchPageOpen(pageNumber);
13857 }, {
13858 signal
13859 });
13860 eventBus._on("pagerendered", ({
13861 pageNumber
13862 }) => {
13863 if (!this._pageOpenPending.has(pageNumber)) {
13864 return;
13865 }
13866 if (pageNumber !== this.#pdfViewer.currentPageNumber) {
13867 return;
13868 }
13869 this.#dispatchPageOpen(pageNumber);
13870 }, {
13871 signal
13872 });
13873 eventBus._on("pagesdestroy", async () => {
13874 await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber);
13875 await this.#scripting?.dispatchEventInSandbox({
13876 id: "doc",
13877 name: "WillClose"
13878 });
13879 this.#closeCapability?.resolve();
13880 }, {
13881 signal
13882 });
13883 try {
13884 const docProperties = await this.#docProperties(pdfDocument);
13885 if (pdfDocument !== this.#pdfDocument) {
13886 return;
13887 }
13888 await this.#scripting.createSandbox({
13889 objects,
13890 calculationOrder,
13891 appInfo: {
13892 platform: navigator.platform,
13893 language: navigator.language
13894 },
13895 docInfo: {
13896 ...docProperties,
13897 actions: docActions
13898 }
13899 });
13900 eventBus.dispatch("sandboxcreated", {
13901 source: this
13902 });
13903 } catch (error) {
13904 globalThis.ngxConsole.error(`setDocument: "${error.message}".`);
13905 await this.#destroyScripting();
13906 return;
13907 }
13908 await this.#scripting?.dispatchEventInSandbox({
13909 id: "doc",
13910 name: "Open"
13911 });
13912 await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true);
13913 Promise.resolve().then(() => {
13914 if (pdfDocument === this.#pdfDocument) {
13915 this.#ready = true;
13916 }
13917 });
13918 }
13919 async dispatchWillSave() {
13920 return this.#scripting?.dispatchEventInSandbox({
13921 id: "doc",
13922 name: "WillSave"
13923 });
13924 }
13925 async dispatchDidSave() {
13926 return this.#scripting?.dispatchEventInSandbox({
13927 id: "doc",
13928 name: "DidSave"
13929 });
13930 }
13931 async dispatchWillPrint() {
13932 if (!this.#scripting) {
13933 return;
13934 }
13935 await this.#willPrintCapability?.promise;
13936 this.#willPrintCapability = Promise.withResolvers();
13937 try {
13938 await this.#scripting.dispatchEventInSandbox({
13939 id: "doc",
13940 name: "WillPrint"
13941 });
13942 } catch (ex) {
13943 this.#willPrintCapability.resolve();
13944 this.#willPrintCapability = null;
13945 throw ex;
13946 }
13947 await this.#willPrintCapability.promise;
13948 }
13949 async dispatchDidPrint() {
13950 return this.#scripting?.dispatchEventInSandbox({
13951 id: "doc",
13952 name: "DidPrint"
13953 });
13954 }
13955 get destroyPromise() {
13956 return this.#destroyCapability?.promise || null;
13957 }
13958 get ready() {
13959 return this.#ready;
13960 }
13961 get _pageOpenPending() {
13962 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_pageOpenPending", new Set());
13963 }
13964 get _visitedPages() {
13965 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_visitedPages", new Map());
13966 }
13967 async #updateFromSandbox(detail) {
13968 const pdfViewer = this.#pdfViewer;
13969 const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode;
13970 const {
13971 id,
13972 siblings,
13973 command,
13974 value
13975 } = detail;
13976 if (!id) {
13977 switch (command) {
13978 case "clear":
13979 globalThis.ngxConsole.clear();
13980 break;
13981 case "error":
13982 globalThis.ngxConsole.error(value);
13983 break;
13984 case "layout":
13985 if (!isInPresentationMode) {
13986 const modes = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageLayoutToViewerModes)(value);
13987 pdfViewer.spreadMode = modes.spreadMode;
13988 }
13989 break;
13990 case "page-num":
13991 pdfViewer.currentPageNumber = value + 1;
13992 break;
13993 case "print":
13994 await pdfViewer.pagesPromise;
13995 this.#eventBus.dispatch("print", {
13996 source: this
13997 });
13998 break;
13999 case "println":
14000 globalThis.ngxConsole.log(value);
14001 break;
14002 case "zoom":
14003 if (!isInPresentationMode) {
14004 pdfViewer.currentScaleValue = value;
14005 }
14006 break;
14007 case "SaveAs":
14008 this.#eventBus.dispatch("download", {
14009 source: this
14010 });
14011 break;
14012 case "FirstPage":
14013 pdfViewer.currentPageNumber = 1;
14014 break;
14015 case "LastPage":
14016 pdfViewer.currentPageNumber = pdfViewer.pagesCount;
14017 break;
14018 case "NextPage":
14019 pdfViewer.nextPage();
14020 break;
14021 case "PrevPage":
14022 pdfViewer.previousPage();
14023 break;
14024 case "ZoomViewIn":
14025 if (!isInPresentationMode) {
14026 pdfViewer.increaseScale();
14027 }
14028 break;
14029 case "ZoomViewOut":
14030 if (!isInPresentationMode) {
14031 pdfViewer.decreaseScale();
14032 }
14033 break;
14034 case "WillPrintFinished":
14035 this.#willPrintCapability?.resolve();
14036 this.#willPrintCapability = null;
14037 break;
14038 }
14039 return;
14040 }
14041 if (isInPresentationMode && detail.focus) {
14042 return;
14043 }
14044 delete detail.id;
14045 delete detail.siblings;
14046 const ids = siblings ? [id, ...siblings] : [id];
14047 for (const elementId of ids) {
14048 const element = document.querySelector(`[data-element-id="${elementId}"]`);
14049 if (element) {
14050 element.dispatchEvent(new CustomEvent("updatefromsandbox", {
14051 detail
14052 }));
14053 } else {
14054 this.#pdfDocument?.annotationStorage.setValue(elementId, detail);
14055 }
14056 }
14057 }
14058 async #dispatchPageOpen(pageNumber, initialize = false) {
14059 const pdfDocument = this.#pdfDocument,
14060 visitedPages = this._visitedPages;
14061 if (initialize) {
14062 this.#closeCapability = Promise.withResolvers();
14063 }
14064 if (!this.#closeCapability) {
14065 return;
14066 }
14067 const pageView = this.#pdfViewer.getPageView(pageNumber - 1);
14068 if (pageView?.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
14069 this._pageOpenPending.add(pageNumber);
14070 return;
14071 }
14072 this._pageOpenPending.delete(pageNumber);
14073 const actionsPromise = (async () => {
14074 const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
14075 if (pdfDocument !== this.#pdfDocument) {
14076 return;
14077 }
14078 await this.#scripting?.dispatchEventInSandbox({
14079 id: "page",
14080 name: "PageOpen",
14081 pageNumber,
14082 actions
14083 });
14084 })();
14085 visitedPages.set(pageNumber, actionsPromise);
14086 }
14087 async #dispatchPageClose(pageNumber) {
14088 const pdfDocument = this.#pdfDocument,
14089 visitedPages = this._visitedPages;
14090 if (!this.#closeCapability) {
14091 return;
14092 }
14093 if (this._pageOpenPending.has(pageNumber)) {
14094 return;
14095 }
14096 const actionsPromise = visitedPages.get(pageNumber);
14097 if (!actionsPromise) {
14098 return;
14099 }
14100 visitedPages.set(pageNumber, null);
14101 await actionsPromise;
14102 if (pdfDocument !== this.#pdfDocument) {
14103 return;
14104 }
14105 await this.#scripting?.dispatchEventInSandbox({
14106 id: "page",
14107 name: "PageClose",
14108 pageNumber
14109 });
14110 }
14111 #initScripting() {
14112 this.#destroyCapability = Promise.withResolvers();
14113 if (this.#scripting) {
14114 throw new Error("#initScripting: Scripting already exists.");
14115 }
14116 return this.#externalServices.createScripting();
14117 }
14118 async #destroyScripting() {
14119 if (!this.#scripting) {
14120 this.#pdfDocument = null;
14121 this.#destroyCapability?.resolve();
14122 return;
14123 }
14124 if (this.#closeCapability) {
14125 await Promise.race([this.#closeCapability.promise, new Promise(resolve => {
14126 setTimeout(resolve, 1000);
14127 })]).catch(() => {});
14128 this.#closeCapability = null;
14129 }
14130 this.#pdfDocument = null;
14131 try {
14132 await this.#scripting.destroySandbox();
14133 } catch {}
14134 this.#willPrintCapability?.reject(new Error("Scripting destroyed."));
14135 this.#willPrintCapability = null;
14136 this.#eventAbortController?.abort();
14137 this.#eventAbortController = null;
14138 this._pageOpenPending.clear();
14139 this._visitedPages.clear();
14140 this.#scripting = null;
14141 this.#ready = false;
14142 this.#destroyCapability?.resolve();
14143 }
14144}
14145
14146__webpack_async_result__();
14147} catch(e) { __webpack_async_result__(e); } });
14148
14149/***/ }),
14150
14151/***/ 2275:
14152/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
14153
14154/* harmony export */ __webpack_require__.d(__webpack_exports__, {
14155/* harmony export */ PDFSidebar: () => (/* binding */ PDFSidebar)
14156/* harmony export */ });
14157/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
14158
14159const SIDEBAR_WIDTH_VAR = "--sidebar-width";
14160const SIDEBAR_MIN_WIDTH = 200;
14161const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
14162const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
14163class PDFSidebar {
14164 #isRTL = false;
14165 #mouseMoveBound = this.#mouseMove.bind(this);
14166 #mouseUpBound = this.#mouseUp.bind(this);
14167 #outerContainerWidth = null;
14168 #width = null;
14169 constructor({
14170 elements,
14171 eventBus,
14172 l10n
14173 }) {
14174 this.isOpen = false;
14175 this.active = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
14176 this.isInitialViewSet = false;
14177 this.isInitialEventDispatched = false;
14178 this.onToggled = null;
14179 this.onUpdateThumbnails = null;
14180 this.outerContainer = elements.outerContainer;
14181 this.sidebarContainer = elements.sidebarContainer;
14182 this.toggleButton = elements.toggleButton;
14183 this.resizer = elements.resizer;
14184 this.thumbnailButton = elements.thumbnailButton;
14185 this.outlineButton = elements.outlineButton;
14186 this.attachmentsButton = elements.attachmentsButton;
14187 this.layersButton = elements.layersButton;
14188 this.thumbnailView = elements.thumbnailView;
14189 this.outlineView = elements.outlineView;
14190 this.attachmentsView = elements.attachmentsView;
14191 this.layersView = elements.layersView;
14192 this._currentOutlineItemButton = elements.currentOutlineItemButton;
14193 this.eventBus = eventBus;
14194 this.#isRTL = l10n.getDirection() === "rtl";
14195 this.#addEventListeners();
14196 }
14197 reset() {
14198 this.isInitialViewSet = false;
14199 this.isInitialEventDispatched = false;
14200 this.#hideUINotification(true);
14201 this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
14202 this.outlineButton.disabled = false;
14203 this.attachmentsButton.disabled = false;
14204 this.layersButton.disabled = false;
14205 this.outlineButton.hidden = false;
14206 this.attachmentsButton.hidden = false;
14207 this.layersButton.hidden = false;
14208 this._currentOutlineItemButton.disabled = true;
14209 }
14210 get visibleView() {
14211 return this.isOpen ? this.active : _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE;
14212 }
14213 setInitialView(view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE) {
14214 if (this.isInitialViewSet) {
14215 return;
14216 }
14217 this.isInitialViewSet = true;
14218 if (view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE || view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
14219 this.#dispatchEvent();
14220 return;
14221 }
14222 this.switchView(view, true);
14223 if (!this.isInitialEventDispatched) {
14224 this.#dispatchEvent();
14225 }
14226 }
14227 switchView(view, forceOpen = false) {
14228 const isViewChanged = view !== this.active;
14229 let forceRendering = false;
14230 switch (view) {
14231 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE:
14232 if (this.isOpen) {
14233 this.close();
14234 }
14235 return;
14236 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS:
14237 if (this.isOpen && isViewChanged) {
14238 forceRendering = true;
14239 }
14240 break;
14241 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE:
14242 if (this.outlineButton.disabled) {
14243 return;
14244 }
14245 break;
14246 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS:
14247 if (this.attachmentsButton.disabled) {
14248 return;
14249 }
14250 break;
14251 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS:
14252 if (this.layersButton.disabled) {
14253 return;
14254 }
14255 break;
14256 default:
14257 globalThis.ngxConsole.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
14258 return;
14259 }
14260 this.active = view;
14261 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.thumbnailButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS, this.thumbnailView);
14262 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.outlineButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE, this.outlineView);
14263 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.attachmentsButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS, this.attachmentsView);
14264 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.layersButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS, this.layersView);
14265 if (forceOpen && !this.isOpen) {
14266 this.open();
14267 return;
14268 }
14269 if (forceRendering) {
14270 this.onUpdateThumbnails();
14271 this.onToggled();
14272 }
14273 if (isViewChanged) {
14274 this.#dispatchEvent();
14275 }
14276 }
14277 open() {
14278 if (this.isOpen) {
14279 return;
14280 }
14281 this.isOpen = true;
14282 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(this.toggleButton, true);
14283 this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
14284 if (this.active === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
14285 this.onUpdateThumbnails();
14286 }
14287 this.onToggled();
14288 this.#dispatchEvent();
14289 this.#hideUINotification();
14290 }
14291 close(evt = null) {
14292 if (!this.isOpen) {
14293 return;
14294 }
14295 this.isOpen = false;
14296 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(this.toggleButton, false);
14297 this.outerContainer.classList.add("sidebarMoving");
14298 this.outerContainer.classList.remove("sidebarOpen");
14299 this.onToggled();
14300 this.#dispatchEvent();
14301 if (evt?.detail > 0) {
14302 this.toggleButton.blur();
14303 }
14304 }
14305 toggle(evt = null) {
14306 if (this.isOpen) {
14307 this.close(evt);
14308 } else {
14309 this.open();
14310 }
14311 }
14312 #dispatchEvent() {
14313 if (this.isInitialViewSet) {
14314 this.isInitialEventDispatched ||= true;
14315 }
14316 this.eventBus.dispatch("sidebarviewchanged", {
14317 source: this,
14318 view: this.visibleView
14319 });
14320 }
14321 #showUINotification() {
14322 this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-notification-button");
14323 if (!this.isOpen) {
14324 this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
14325 }
14326 }
14327 #hideUINotification(reset = false) {
14328 if (this.isOpen || reset) {
14329 this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
14330 }
14331 if (reset) {
14332 this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-button");
14333 }
14334 }
14335 #addEventListeners() {
14336 this.sidebarContainer.addEventListener("transitionend", evt => {
14337 if (evt.target === this.sidebarContainer) {
14338 this.outerContainer.classList.remove("sidebarMoving");
14339 this.eventBus.dispatch("resize", {
14340 source: this
14341 });
14342 }
14343 });
14344 this.toggleButton.addEventListener("click", evt => {
14345 this.toggle(evt);
14346 });
14347 this.thumbnailButton.addEventListener("click", () => {
14348 this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
14349 });
14350 this.outlineButton.addEventListener("click", () => {
14351 this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE);
14352 });
14353 this.outlineButton.addEventListener("dblclick", () => {
14354 this.eventBus.dispatch("toggleoutlinetree", {
14355 source: this
14356 });
14357 });
14358 this.attachmentsButton.addEventListener("click", () => {
14359 this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS);
14360 });
14361 this.layersButton.addEventListener("click", () => {
14362 this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS);
14363 });
14364 this.layersButton.addEventListener("dblclick", () => {
14365 this.eventBus.dispatch("resetlayers", {
14366 source: this
14367 });
14368 });
14369 this._currentOutlineItemButton.addEventListener("click", () => {
14370 this.eventBus.dispatch("currentoutlineitem", {
14371 source: this
14372 });
14373 });
14374 const onTreeLoaded = (count, button, view) => {
14375 button.disabled = !count;
14376 button.hidden = !count;
14377 if (count) {
14378 this.#showUINotification();
14379 } else if (this.active === view) {
14380 this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
14381 }
14382 };
14383 this.eventBus._on("outlineloaded", evt => {
14384 onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE);
14385 if (evt.enableCurrentOutlineItemButton) {
14386 if (evt.currentOutlineItemPromise) {
14387 evt.currentOutlineItemPromise.then(enabled => {
14388 if (!this.isInitialViewSet) {
14389 return;
14390 }
14391 this._currentOutlineItemButton.disabled = !enabled;
14392 });
14393 }
14394 }
14395 });
14396 this.eventBus._on("attachmentsloaded", evt => {
14397 onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS);
14398 });
14399 this.eventBus._on("layersloaded", evt => {
14400 onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS);
14401 });
14402 this.eventBus._on("presentationmodechanged", evt => {
14403 if (evt.state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL && this.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
14404 this.onUpdateThumbnails();
14405 }
14406 });
14407 this.resizer.addEventListener("mousedown", evt => {
14408 if (evt.button !== 0) {
14409 return;
14410 }
14411 this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
14412 window.addEventListener("mousemove", this.#mouseMoveBound);
14413 window.addEventListener("mouseup", this.#mouseUpBound);
14414 });
14415 this.eventBus._on("resize", evt => {
14416 if (evt.source !== window) {
14417 return;
14418 }
14419 this.#outerContainerWidth = null;
14420 if (!this.#width) {
14421 return;
14422 }
14423 if (!this.isOpen) {
14424 this.#updateWidth(this.#width);
14425 return;
14426 }
14427 this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
14428 const updated = this.#updateWidth(this.#width);
14429 Promise.resolve().then(() => {
14430 this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
14431 if (updated) {
14432 this.eventBus.dispatch("resize", {
14433 source: this
14434 });
14435 }
14436 });
14437 });
14438 }
14439 get outerContainerWidth() {
14440 return this.#outerContainerWidth ||= this.outerContainer.clientWidth;
14441 }
14442 #updateWidth(width = 0) {
14443 const maxWidth = Math.floor(this.outerContainerWidth / 2);
14444 if (width > maxWidth) {
14445 width = maxWidth;
14446 }
14447 if (width < SIDEBAR_MIN_WIDTH) {
14448 width = SIDEBAR_MIN_WIDTH;
14449 }
14450 if (width === this.#width) {
14451 return false;
14452 }
14453 this.#width = width;
14454 _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
14455 return true;
14456 }
14457 #mouseMove(evt) {
14458 let width = evt.clientX;
14459 if (this.#isRTL) {
14460 width = this.outerContainerWidth - width;
14461 }
14462 this.#updateWidth(width);
14463 }
14464 #mouseUp(evt) {
14465 this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
14466 this.eventBus.dispatch("resize", {
14467 source: this
14468 });
14469 window.removeEventListener("mousemove", this.#mouseMoveBound);
14470 window.removeEventListener("mouseup", this.#mouseUpBound);
14471 }
14472}
14473
14474
14475/***/ }),
14476
14477/***/ 1123:
14478/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
14479
14480__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
14481/* harmony export */ __webpack_require__.d(__webpack_exports__, {
14482/* harmony export */ PDFThumbnailView: () => (/* binding */ PDFThumbnailView),
14483/* harmony export */ TempImageFactory: () => (/* binding */ TempImageFactory)
14484/* harmony export */ });
14485/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
14486/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
14487var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
14488pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
14489
14490
14491const DRAW_UPSCALE_FACTOR = 2;
14492const MAX_NUM_SCALING_STEPS = 3;
14493const THUMBNAIL_WIDTH = 98;
14494class TempImageFactory {
14495 static #tempCanvas = null;
14496 static getCanvas(width, height) {
14497 const tempCanvas = this.#tempCanvas ||= document.createElement("canvas");
14498 tempCanvas.width = width;
14499 tempCanvas.height = height;
14500 const options1 = window.pdfDefaultOptions.activateWillReadFrequentlyFlag ? {
14501 willReadFrequently: true,
14502 alpha: false
14503 } : {
14504 alpha: false
14505 };
14506 const options2 = window.pdfDefaultOptions.activateWillReadFrequentlyFlag ? {
14507 willReadFrequently: true
14508 } : undefined;
14509 const ctx = tempCanvas.getContext("2d", options1);
14510 ctx.save();
14511 ctx.fillStyle = "rgb(255, 255, 255)";
14512 ctx.fillRect(0, 0, width, height);
14513 ctx.restore();
14514 return [tempCanvas, tempCanvas.getContext("2d", options2)];
14515 }
14516 static destroyCanvas() {
14517 const tempCanvas = this.#tempCanvas;
14518 if (tempCanvas) {
14519 tempCanvas.width = 0;
14520 tempCanvas.height = 0;
14521 }
14522 this.#tempCanvas = null;
14523 }
14524}
14525class PDFThumbnailView {
14526 constructor({
14527 container,
14528 eventBus,
14529 id,
14530 defaultViewport,
14531 optionalContentConfigPromise,
14532 linkService,
14533 renderingQueue,
14534 pageColors
14535 }) {
14536 this.id = id;
14537 this.renderingId = "thumbnail" + id;
14538 this.pageLabel = null;
14539 this.pdfPage = null;
14540 this.rotation = 0;
14541 this.viewport = defaultViewport;
14542 this.pdfPageRotate = defaultViewport.rotation;
14543 this._optionalContentConfigPromise = optionalContentConfigPromise || null;
14544 this.pageColors = pageColors || null;
14545 this.eventBus = eventBus;
14546 this.linkService = linkService;
14547 this.renderingQueue = renderingQueue;
14548 this.eventBus = eventBus;
14549 this.renderTask = null;
14550 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL;
14551 this.resume = null;
14552 if (window.pdfThumbnailGenerator) {
14553 this._placeholderImg = window.pdfThumbnailGenerator(this, linkService, id, container, this.#pageL10nArgs);
14554 } else {
14555 this.createThumbnail(this, linkService, id, container, this.#pageL10nArgs);
14556 }
14557 }
14558 createThumbnail(pdfThumbnailView, linkService, id, container, pageL10nArgs) {
14559 const anchor = document.createElement("a");
14560 anchor.href = linkService.getAnchorUrl("#page=" + id);
14561 anchor.setAttribute("data-l10n-id", "pdfjs-thumb-page-title");
14562 anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
14563 anchor.onclick = function () {
14564 linkService.goToPage(id);
14565 return false;
14566 };
14567 this.anchor = anchor;
14568 const div = document.createElement("div");
14569 div.className = "thumbnail";
14570 div.setAttribute("data-page-number", this.id);
14571 this.div = div;
14572 this.#updateDims();
14573 const img = document.createElement("div");
14574 img.className = "thumbnailImage";
14575 this._placeholderImg = img;
14576 div.append(img);
14577 anchor.append(div);
14578 container.append(anchor);
14579 }
14580 #updateDims() {
14581 const {
14582 width,
14583 height
14584 } = this.viewport;
14585 const ratio = width / height;
14586 this.canvasWidth = THUMBNAIL_WIDTH;
14587 this.canvasHeight = this.canvasWidth / ratio | 0;
14588 this.scale = this.canvasWidth / width;
14589 const {
14590 style
14591 } = this.div;
14592 style.setProperty("--thumbnail-width", `${this.canvasWidth}px`);
14593 style.setProperty("--thumbnail-height", `${this.canvasHeight}px`);
14594 }
14595 setPdfPage(pdfPage) {
14596 this.pdfPage = pdfPage;
14597 this.pdfPageRotate = pdfPage.rotate;
14598 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
14599 this.viewport = pdfPage.getViewport({
14600 scale: 1,
14601 rotation: totalRotation
14602 });
14603 this.reset();
14604 }
14605 reset() {
14606 this.cancelRendering();
14607 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL;
14608 this.div.removeAttribute("data-loaded");
14609 this.image?.replaceWith(this._placeholderImg);
14610 this.#updateDims();
14611 if (this.image) {
14612 this.image.removeAttribute("src");
14613 delete this.image;
14614 }
14615 }
14616 update({
14617 rotation = null
14618 }) {
14619 if (typeof rotation === "number") {
14620 this.rotation = rotation;
14621 }
14622 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
14623 this.viewport = this.viewport.clone({
14624 scale: 1,
14625 rotation: totalRotation
14626 });
14627 this.reset();
14628 }
14629 cancelRendering() {
14630 if (this.renderTask) {
14631 this.renderTask.cancel();
14632 this.renderTask = null;
14633 }
14634 this.resume = null;
14635 }
14636 #getPageDrawContext(upscaleFactor = 1) {
14637 const canvas = document.createElement("canvas");
14638 const options = window.pdfDefaultOptions.activateWillReadFrequentlyFlag ? {
14639 willReadFrequently: true,
14640 alpha: false
14641 } : {
14642 alpha: false
14643 };
14644 const ctx = canvas.getContext("2d", options);
14645 const outputScale = new _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.OutputScale();
14646 canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
14647 canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
14648 const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
14649 return {
14650 ctx,
14651 canvas,
14652 transform
14653 };
14654 }
14655 #convertCanvasToImage(canvas) {
14656 if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
14657 throw new Error("#convertCanvasToImage: Rendering has not finished.");
14658 }
14659 const reducedCanvas = this.#reduceImage(canvas);
14660 const image = document.createElement("img");
14661 image.className = "thumbnailImage";
14662 image.setAttribute("data-l10n-id", "pdfjs-thumb-page-canvas");
14663 image.setAttribute("data-l10n-args", this.#pageL10nArgs);
14664 image.src = reducedCanvas.toDataURL();
14665 this.image = image;
14666 this.div.setAttribute("data-loaded", true);
14667 this._placeholderImg.replaceWith(image);
14668 reducedCanvas.width = 0;
14669 reducedCanvas.height = 0;
14670 }
14671 async #finishRenderTask(renderTask, canvas, error = null) {
14672 if (renderTask === this.renderTask) {
14673 this.renderTask = null;
14674 }
14675 if (error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.RenderingCancelledException) {
14676 return;
14677 }
14678 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
14679 this.#convertCanvasToImage(canvas);
14680 if (error) {
14681 throw error;
14682 }
14683 this.eventBus.dispatch("thumbnailRendered", this.id);
14684 }
14685 async draw() {
14686 if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL) {
14687 globalThis.ngxConsole.error("Must be in new state before drawing");
14688 return undefined;
14689 }
14690 const {
14691 pdfPage
14692 } = this;
14693 if (!pdfPage) {
14694 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
14695 throw new Error("pdfPage is not loaded");
14696 }
14697 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING;
14698 const {
14699 ctx,
14700 canvas,
14701 transform
14702 } = this.#getPageDrawContext(DRAW_UPSCALE_FACTOR);
14703 const drawViewport = this.viewport.clone({
14704 scale: DRAW_UPSCALE_FACTOR * this.scale
14705 });
14706 const renderContinueCallback = cont => {
14707 if (!this.renderingQueue.isHighestPriority(this)) {
14708 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.PAUSED;
14709 this.resume = () => {
14710 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING;
14711 cont();
14712 };
14713 return;
14714 }
14715 cont();
14716 };
14717 const renderContext = {
14718 canvasContext: ctx,
14719 transform,
14720 viewport: drawViewport,
14721 optionalContentConfigPromise: this._optionalContentConfigPromise,
14722 pageColors: this.pageColors
14723 };
14724 const renderTask = this.renderTask = pdfPage.render(renderContext);
14725 renderTask.onContinue = renderContinueCallback;
14726 const resultPromise = renderTask.promise.then(() => this.#finishRenderTask(renderTask, canvas), error => this.#finishRenderTask(renderTask, canvas, error));
14727 resultPromise.finally(() => {
14728 canvas.width = 0;
14729 canvas.height = 0;
14730 this.eventBus.dispatch("thumbnailrendered", {
14731 source: this,
14732 pageNumber: this.id,
14733 pdfPage: this.pdfPage
14734 });
14735 });
14736 return resultPromise;
14737 }
14738 setImage(pageView) {
14739 if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL) {
14740 return;
14741 }
14742 const {
14743 thumbnailCanvas: canvas,
14744 pdfPage,
14745 scale
14746 } = pageView;
14747 if (!canvas) {
14748 return;
14749 }
14750 if (!this.pdfPage) {
14751 this.setPdfPage(pdfPage);
14752 }
14753 if (scale < this.scale) {
14754 return;
14755 }
14756 this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
14757 this.#convertCanvasToImage(canvas);
14758 }
14759 #reduceImage(img) {
14760 const {
14761 ctx,
14762 canvas
14763 } = this.#getPageDrawContext();
14764 if (img.width <= 2 * canvas.width) {
14765 ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
14766 return canvas;
14767 }
14768 let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
14769 let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
14770 const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
14771 while (reducedWidth > img.width || reducedHeight > img.height) {
14772 reducedWidth >>= 1;
14773 reducedHeight >>= 1;
14774 }
14775 reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
14776 while (reducedWidth > 2 * canvas.width) {
14777 reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
14778 reducedWidth >>= 1;
14779 reducedHeight >>= 1;
14780 }
14781 ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
14782 return canvas;
14783 }
14784 get #pageL10nArgs() {
14785 return JSON.stringify({
14786 page: this.pageLabel ?? this.id
14787 });
14788 }
14789 setPageLabel(label) {
14790 this.pageLabel = typeof label === "string" ? label : null;
14791 this.anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
14792 if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
14793 return;
14794 }
14795 this.image?.setAttribute("data-l10n-args", this.#pageL10nArgs);
14796 }
14797}
14798
14799__webpack_async_result__();
14800} catch(e) { __webpack_async_result__(e); } });
14801
14802/***/ }),
14803
14804/***/ 8280:
14805/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
14806
14807__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
14808/* harmony export */ __webpack_require__.d(__webpack_exports__, {
14809/* harmony export */ PDFThumbnailViewer: () => (/* binding */ PDFThumbnailViewer)
14810/* harmony export */ });
14811/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
14812/* harmony import */ var _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1123);
14813var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__]);
14814_pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
14815
14816
14817const THUMBNAIL_SCROLL_MARGIN = -19;
14818const THUMBNAIL_SELECTED_CLASS = "selected";
14819class PDFThumbnailViewer {
14820 constructor({
14821 container,
14822 eventBus,
14823 linkService,
14824 renderingQueue,
14825 pageColors
14826 }) {
14827 this.container = container;
14828 this.eventBus = eventBus;
14829 this.linkService = linkService;
14830 this.renderingQueue = renderingQueue;
14831 this.pageColors = pageColors || null;
14832 this.scroll = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.watchScroll)(this.container, this.#scrollUpdated.bind(this));
14833 this.#resetView();
14834 }
14835 #scrollUpdated() {
14836 this.renderingQueue.renderHighestPriority();
14837 }
14838 getThumbnail(index) {
14839 return this._thumbnails[index];
14840 }
14841 #getVisibleThumbs() {
14842 return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getVisibleElements)({
14843 scrollEl: this.container,
14844 views: this._thumbnails
14845 });
14846 }
14847 scrollThumbnailIntoView(pageNumber) {
14848 if (!this.pdfDocument) {
14849 return;
14850 }
14851 const thumbnailView = this._thumbnails[pageNumber - 1];
14852 if (!thumbnailView) {
14853 globalThis.ngxConsole.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
14854 return;
14855 }
14856 if (pageNumber !== this._currentPageNumber) {
14857 const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
14858 prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
14859 thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
14860 }
14861 const {
14862 first,
14863 last,
14864 views
14865 } = this.#getVisibleThumbs();
14866 if (views.length > 0) {
14867 let shouldScroll = false;
14868 if (pageNumber <= first.id || pageNumber >= last.id) {
14869 shouldScroll = true;
14870 } else {
14871 for (const {
14872 id,
14873 percent
14874 } of views) {
14875 if (id !== pageNumber) {
14876 continue;
14877 }
14878 shouldScroll = percent < 100;
14879 break;
14880 }
14881 }
14882 if (shouldScroll) {
14883 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.scrollIntoView)(thumbnailView.div, {
14884 top: THUMBNAIL_SCROLL_MARGIN
14885 });
14886 }
14887 }
14888 this._currentPageNumber = pageNumber;
14889 }
14890 get pagesRotation() {
14891 return this._pagesRotation;
14892 }
14893 set pagesRotation(rotation) {
14894 if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(rotation)) {
14895 throw new Error("Invalid thumbnails rotation angle.");
14896 }
14897 if (!this.pdfDocument) {
14898 return;
14899 }
14900 if (this._pagesRotation === rotation) {
14901 return;
14902 }
14903 this._pagesRotation = rotation;
14904 const updateArgs = {
14905 rotation
14906 };
14907 for (const thumbnail of this._thumbnails) {
14908 thumbnail.update(updateArgs);
14909 }
14910 }
14911 cleanup() {
14912 for (const thumbnail of this._thumbnails) {
14913 if (thumbnail.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
14914 thumbnail.reset();
14915 }
14916 }
14917 _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__.TempImageFactory.destroyCanvas();
14918 }
14919 #resetView() {
14920 this._thumbnails = [];
14921 this._currentPageNumber = 1;
14922 this._pageLabels = null;
14923 this._pagesRotation = 0;
14924 this.container.textContent = "";
14925 }
14926 setDocument(pdfDocument) {
14927 this.initialized = false;
14928 if (this.pdfDocument) {
14929 this.#cancelRendering();
14930 this.#resetView();
14931 }
14932 this.pdfDocument = pdfDocument;
14933 if (!pdfDocument) {
14934 return;
14935 }
14936 if (this.initialized) {
14937 return;
14938 }
14939 this.initialized = true;
14940 const firstPagePromise = pdfDocument.getPage(1);
14941 const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
14942 intent: "display"
14943 });
14944 firstPagePromise.then(firstPdfPage => {
14945 const pagesCount = pdfDocument.numPages;
14946 const viewport = firstPdfPage.getViewport({
14947 scale: 1
14948 });
14949 for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
14950 const thumbnail = new _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__.PDFThumbnailView({
14951 container: this.container,
14952 eventBus: this.eventBus,
14953 id: pageNum,
14954 defaultViewport: viewport.clone(),
14955 optionalContentConfigPromise,
14956 linkService: this.linkService,
14957 renderingQueue: this.renderingQueue,
14958 pageColors: this.pageColors,
14959 eventBus: this.eventBus
14960 });
14961 this._thumbnails.push(thumbnail);
14962 }
14963 this._thumbnails[0]?.setPdfPage(firstPdfPage);
14964 const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
14965 thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
14966 }).catch(reason => {
14967 globalThis.ngxConsole.error("Unable to initialize thumbnail viewer", reason);
14968 });
14969 }
14970 #cancelRendering() {
14971 for (const thumbnail of this._thumbnails) {
14972 thumbnail.cancelRendering();
14973 }
14974 }
14975 setPageLabels(labels) {
14976 if (!this.pdfDocument) {
14977 return;
14978 }
14979 if (!labels) {
14980 this._pageLabels = null;
14981 } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
14982 this._pageLabels = null;
14983 globalThis.ngxConsole.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
14984 } else {
14985 this._pageLabels = labels;
14986 }
14987 for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
14988 this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
14989 }
14990 }
14991 async #ensurePdfPageLoaded(thumbView) {
14992 if (thumbView.pdfPage) {
14993 return thumbView.pdfPage;
14994 }
14995 try {
14996 const pdfPage = await this.pdfDocument.getPage(thumbView.id);
14997 if (!thumbView.pdfPage) {
14998 thumbView.setPdfPage(pdfPage);
14999 }
15000 return pdfPage;
15001 } catch (reason) {
15002 globalThis.ngxConsole.error("Unable to get page for thumb view", reason);
15003 return null;
15004 }
15005 }
15006 #getScrollAhead(visible) {
15007 if (visible.first?.id === 1) {
15008 return true;
15009 } else if (visible.last?.id === this._thumbnails.length) {
15010 return false;
15011 }
15012 return this.scroll.down;
15013 }
15014 forceRendering() {
15015 const visibleThumbs = this.#getVisibleThumbs();
15016 const scrollAhead = this.#getScrollAhead(visibleThumbs);
15017 const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
15018 if (thumbView) {
15019 this.#ensurePdfPageLoaded(thumbView).then(() => {
15020 this.renderingQueue.renderView(thumbView);
15021 });
15022 return true;
15023 }
15024 return false;
15025 }
15026 stopRendering() {
15027 this.#cancelRendering();
15028 }
15029}
15030
15031__webpack_async_result__();
15032} catch(e) { __webpack_async_result__(e); } });
15033
15034/***/ }),
15035
15036/***/ 6285:
15037/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
15038
15039__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
15040/* harmony export */ __webpack_require__.d(__webpack_exports__, {
15041/* harmony export */ PDFViewer: () => (/* binding */ PDFViewer),
15042/* harmony export */ PagesCountLimit: () => (/* binding */ PagesCountLimit)
15043/* harmony export */ });
15044/* unused harmony export PDFPageViewBuffer */
15045/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
15046/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
15047/* harmony import */ var web_null_l10n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(410);
15048/* harmony import */ var _page_flip_module_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(553);
15049/* harmony import */ var _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9966);
15050/* harmony import */ var _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6615);
15051/* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(787);
15052var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_null_l10n__WEBPACK_IMPORTED_MODULE_2__, _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_4__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_5__]);
15053([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_null_l10n__WEBPACK_IMPORTED_MODULE_2__, _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_4__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_5__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
15054
15055
15056
15057
15058
15059
15060
15061const DEFAULT_CACHE_SIZE = 10;
15062const PagesCountLimit = {
15063 FORCE_SCROLL_MODE_PAGE: 15000,
15064 FORCE_LAZY_PAGE_INIT: 7500,
15065 PAUSE_EAGER_PAGE_INIT: 250
15066};
15067function isValidAnnotationEditorMode(mode) {
15068 return Object.values(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType).includes(mode) && mode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
15069}
15070class PDFPageViewBuffer {
15071 #buf = new Set();
15072 #size = 0;
15073 constructor(size) {
15074 this.#size = size;
15075 }
15076 push(view) {
15077 const buf = this.#buf;
15078 if (buf.has(view)) {
15079 buf.delete(view);
15080 }
15081 buf.add(view);
15082 if (buf.size > this.#size) {
15083 this.#destroyFirstView();
15084 }
15085 }
15086 resize(newSize, idsToKeep = null) {
15087 this.#size = newSize;
15088 const buf = this.#buf;
15089 if (idsToKeep) {
15090 const ii = buf.size;
15091 let i = 1;
15092 for (const view of buf) {
15093 if (idsToKeep.has(view.id)) {
15094 buf.delete(view);
15095 buf.add(view);
15096 }
15097 if (++i > ii) {
15098 break;
15099 }
15100 }
15101 }
15102 while (buf.size > this.#size) {
15103 this.#destroyFirstView();
15104 }
15105 }
15106 has(view) {
15107 return this.#buf.has(view);
15108 }
15109 [Symbol.iterator]() {
15110 return this.#buf.keys();
15111 }
15112 #destroyFirstView() {
15113 const firstView = this.#buf.keys().next().value;
15114 firstView?.destroy();
15115 this.#buf.delete(firstView);
15116 }
15117}
15118class PDFViewer {
15119 #buffer = null;
15120 #altTextManager = null;
15121 #annotationEditorHighlightColors = null;
15122 #annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
15123 #annotationEditorUIManager = null;
15124 #annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
15125 #containerTopLeft = null;
15126 #copyCallbackBound = null;
15127 #enableHighlightFloatingButton = false;
15128 #enablePermissions = false;
15129 #mlManager = null;
15130 #getAllTextInProgress = false;
15131 #hiddenCopyElement = null;
15132 #interruptCopyCondition = false;
15133 #previousContainerHeight = 0;
15134 #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
15135 #scrollModePageState = null;
15136 #onVisibilityChange = null;
15137 #scaleTimeoutId = null;
15138 #textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
15139 #outerScrollContainer = undefined;
15140 #pageViewMode = "multiple";
15141 constructor(options) {
15142 const viewerVersion = "4.2.552";
15143 if (pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version !== viewerVersion) {
15144 throw new Error(`The API version "${pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version}" does not match the Viewer version "${viewerVersion}".`);
15145 }
15146 this.container = options.container;
15147 this.viewer = options.viewer || options.container.firstElementChild;
15148 this.pageViewMode = options.pageViewMode || "multiple";
15149 if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
15150 throw new Error("Invalid `container` and/or `viewer` option.");
15151 }
15152 if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
15153 throw new Error("The `container` must be absolutely positioned.");
15154 }
15155 this.#resizeObserver.observe(this.container);
15156 this.eventBus = options.eventBus;
15157 this.linkService = options.linkService || new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_6__.SimpleLinkService();
15158 this.downloadManager = options.downloadManager || null;
15159 this.findController = options.findController || null;
15160 this.#altTextManager = options.altTextManager || null;
15161 if (this.findController) {
15162 this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber);
15163 }
15164 this._scriptingManager = options.scriptingManager || null;
15165 this.#textLayerMode = options.textLayerMode ?? _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
15166 this.#annotationMode = options.annotationMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
15167 this.#annotationEditorMode = options.annotationEditorMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
15168 this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
15169 this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
15170 this.imageResourcesPath = options.imageResourcesPath || "";
15171 this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
15172 this.removePageBorders = options.removePageBorders || false;
15173 this.maxCanvasPixels = options.maxCanvasPixels;
15174 this.l10n = options.l10n;
15175 this.l10n ||= new web_null_l10n__WEBPACK_IMPORTED_MODULE_2__.GenericL10n();
15176 this.#enablePermissions = options.enablePermissions || false;
15177 this.pageColors = options.pageColors || null;
15178 this.#mlManager = options.mlManager || null;
15179 this.defaultRenderingQueue = !options.renderingQueue;
15180 if (this.defaultRenderingQueue) {
15181 this.renderingQueue = new _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_5__.PDFRenderingQueue();
15182 this.renderingQueue.setViewer(this);
15183 } else {
15184 this.renderingQueue = options.renderingQueue;
15185 }
15186 this.scroll = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.watchScroll)(this.container, this._scrollUpdate.bind(this));
15187 this.presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.UNKNOWN;
15188 this._onBeforeDraw = this._onAfterDraw = null;
15189 this._resetView();
15190 if (this.removePageBorders) {
15191 this.viewer.classList.add("removePageBorders");
15192 }
15193 this.#updateContainerHeightCss();
15194 this.eventBus._on("thumbnailrendered", ({
15195 pageNumber,
15196 pdfPage
15197 }) => {
15198 const pageView = this._pages[pageNumber - 1];
15199 if (!this.#buffer.has(pageView)) {
15200 pdfPage?.cleanup();
15201 }
15202 });
15203 if (!options.l10n) {
15204 this.l10n.translate(this.container);
15205 }
15206 }
15207 get pageViewMode() {
15208 return this.#pageViewMode;
15209 }
15210 set pageViewMode(viewMode) {
15211 if (this.#pageViewMode !== viewMode) {
15212 this.#pageViewMode = viewMode;
15213 if (!this.#outerScrollContainer && viewMode === "infinite-scroll") {
15214 this.#outerScrollContainer = this.#findParentWithScrollbar(this.container.offsetParent);
15215 if (this.#outerScrollContainer) {
15216 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.watchScroll)(this.#outerScrollContainer, this._scrollUpdate.bind(this));
15217 }
15218 }
15219 }
15220 }
15221 #findParentWithScrollbar(element) {
15222 while (element) {
15223 if (element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth) {
15224 return element;
15225 }
15226 element = element.parentElement;
15227 }
15228 return null;
15229 }
15230 get pagesCount() {
15231 return this._pages.length;
15232 }
15233 getPageView(index) {
15234 return this._pages[index];
15235 }
15236 getCachedPageViews() {
15237 return new Set(this.#buffer);
15238 }
15239 get pageViewsReady() {
15240 return this._pages.every(pageView => pageView?.pdfPage);
15241 }
15242 get renderForms() {
15243 return this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
15244 }
15245 get enableScripting() {
15246 return !!this._scriptingManager;
15247 }
15248 get currentPageNumber() {
15249 return this._currentPageNumber;
15250 }
15251 set currentPageNumber(val) {
15252 if (!Number.isInteger(val)) {
15253 throw new Error("Invalid page number.");
15254 }
15255 if (!this.pdfDocument) {
15256 return;
15257 }
15258 const flip = Math.abs(this._currentPageNumber - val) <= 2;
15259 if (!this._setCurrentPageNumber(val, true)) {
15260 globalThis.ngxConsole.error(`currentPageNumber: "${val}" is not a valid page.`);
15261 }
15262 if (this.pageFlip) {
15263 if (flip) {
15264 this.pageFlip.flip(val - 1);
15265 } else {
15266 this.pageFlip.turnToPage(val - 1);
15267 }
15268 this.ensureAdjacentPagesAreLoaded();
15269 }
15270 }
15271 hidePagesDependingOnpageViewMode() {
15272 if (this.pageViewMode === "book") {
15273 if (!this.pageFlip) {
15274 setTimeout(() => {
15275 if (!this.pageFlip) {
15276 const page1 = this._pages[0].div;
15277 const htmlParentElement = page1.parentElement;
15278 const viewer = htmlParentElement.parentElement;
15279 viewer.style.width = 2 * page1.clientWidth + "px";
15280 viewer.style.overflow = "hidden";
15281 viewer.style.marginLeft = "auto";
15282 viewer.style.marginRight = "auto";
15283 this.pageFlip = new _page_flip_module_js__WEBPACK_IMPORTED_MODULE_3__.PageFlip(htmlParentElement, {
15284 width: page1.clientWidth,
15285 height: page1.clientHeight,
15286 showCover: true,
15287 size: "fixed"
15288 });
15289 this.pageFlip.loadFromHTML(document.querySelectorAll(".page"));
15290 this.pageFlip.on("flip", e => {
15291 if (this._currentPageNumber !== e.data + 1) {
15292 this._setCurrentPageNumber(e.data + 1, false);
15293 }
15294 });
15295 }
15296 }, 100);
15297 }
15298 }
15299 }
15300 async _setCurrentPageNumber(val, resetCurrentPageView = false) {
15301 if (this._currentPageNumber === val) {
15302 if (resetCurrentPageView) {
15303 this.#resetCurrentPageView();
15304 }
15305 return true;
15306 }
15307 if (!(0 < val && val <= this.pagesCount)) {
15308 return false;
15309 }
15310 const previous = this._currentPageNumber;
15311 this._currentPageNumber = val;
15312 this.hidePagesDependingOnpageViewMode();
15313 if (this.pageViewMode === "book" || this.pageViewMode === "infinite-scroll") {
15314 const pageView = this._pages[this.currentPageNumber - 1];
15315 if (pageView.div.parentElement.classList.contains("spread")) {
15316 pageView.div.parentElement.childNodes.forEach(async div => {
15317 const pageNumber = Number(div.getAttribute("data-page-number"));
15318 const pv = this._pages[pageNumber - 1];
15319 await this.#ensurePdfPageLoaded(pv);
15320 this.renderingQueue.renderView(pv);
15321 div.style.display = "inline-block";
15322 });
15323 } else {
15324 await this.#ensurePdfPageLoaded(pageView);
15325 this.renderingQueue.renderView(pageView);
15326 if (this.#pageViewMode === "book") {
15327 this.ensureAdjacentPagesAreLoaded();
15328 }
15329 }
15330 }
15331 this.eventBus.dispatch("pagechanging", {
15332 source: this,
15333 pageNumber: val,
15334 pageLabel: this._pageLabels?.[val - 1] ?? null,
15335 previous
15336 });
15337 if (resetCurrentPageView) {
15338 this.#resetCurrentPageView();
15339 }
15340 return true;
15341 }
15342 addPageToRenderQueue(pageIndex = 0) {
15343 if (pageIndex >= 0 && pageIndex <= this._pages.length - 1) {
15344 const pageView = this._pages[pageIndex];
15345 const isLoading = pageView.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL;
15346 if (isLoading) {
15347 this.#ensurePdfPageLoaded(pageView).then(() => {
15348 this.renderingQueue.renderView(pageView);
15349 });
15350 return true;
15351 }
15352 }
15353 return false;
15354 }
15355 async ensureAdjacentPagesAreLoaded() {
15356 const advances = [0, 1, -1, 2, -2, -3];
15357 let offset = 0;
15358 if (this.currentPageNumber % 2 === 1) {
15359 offset = -1;
15360 }
15361 let renderAsynchronously = false;
15362 for (const advance of advances) {
15363 const pageIndex = this.currentPageNumber + advance + offset;
15364 if (pageIndex >= 0 && pageIndex < this._pages.length) {
15365 try {
15366 const pageView = this._pages[pageIndex];
15367 await this.#ensurePdfPageLoaded(pageView);
15368 const isAlreadyRendering = this._pages.some(pv => pv.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING || pv.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED);
15369 if (isAlreadyRendering || renderAsynchronously) {
15370 const loader = () => this.adjacentPagesRenderer(loader, pageIndex);
15371 this.eventBus._on("pagerendered", loader);
15372 this.eventBus._on("thumbnailRendered", loader);
15373 } else {
15374 renderAsynchronously = this.adjacentPagesRenderer(null, pageIndex);
15375 }
15376 } catch (exception) {
15377 console.log("Exception during pre-rendering page " + pageIndex, exception);
15378 }
15379 }
15380 }
15381 }
15382 adjacentPagesRenderer(self, pageIndex) {
15383 const isAlreadyRendering = this._pages.find(pageView => pageView.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING);
15384 if (isAlreadyRendering) {
15385 return true;
15386 }
15387 const pausedRendering = this._pages.find(pageView => pageView.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED);
15388 if (pausedRendering) {
15389 this.renderingQueue.renderView(pausedRendering);
15390 return true;
15391 }
15392 if (self) {
15393 this.eventBus._off("pagerendered", self);
15394 this.eventBus._off("thumbnailRendered", self);
15395 }
15396 if (pageIndex >= 0 && pageIndex < this._pages.length) {
15397 const pageView = this._pages[pageIndex];
15398 const needsToBeRendered = pageView.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL;
15399 if (needsToBeRendered) {
15400 this.renderingQueue.renderView(pageView);
15401 return true;
15402 }
15403 }
15404 return false;
15405 }
15406 get currentPageLabel() {
15407 return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
15408 }
15409 set currentPageLabel(val) {
15410 if (!this.pdfDocument) {
15411 return;
15412 }
15413 let page = val | 0;
15414 if (this._pageLabels) {
15415 const i = this._pageLabels.indexOf(val);
15416 if (i >= 0) {
15417 page = i + 1;
15418 }
15419 }
15420 if (!this._setCurrentPageNumber(page, true)) {
15421 globalThis.ngxConsole.error(`currentPageLabel: "${val}" is not a valid page.`);
15422 }
15423 }
15424 get currentScale() {
15425 return this._currentScale !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE ? this._currentScale : _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
15426 }
15427 set currentScale(val) {
15428 if (isNaN(val)) {
15429 throw new Error("Invalid numeric scale.");
15430 }
15431 if (!this.pdfDocument) {
15432 return;
15433 }
15434 this.#setScale(val, {
15435 noScroll: false
15436 });
15437 }
15438 get currentScaleValue() {
15439 return this._currentScaleValue;
15440 }
15441 set currentScaleValue(val) {
15442 if (!this.pdfDocument) {
15443 return;
15444 }
15445 this.#setScale(val, {
15446 noScroll: false
15447 });
15448 }
15449 get pagesRotation() {
15450 return this._pagesRotation;
15451 }
15452 set pagesRotation(rotation) {
15453 if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidRotation)(rotation)) {
15454 throw new Error("Invalid pages rotation angle.");
15455 }
15456 if (!this.pdfDocument) {
15457 return;
15458 }
15459 rotation %= 360;
15460 if (rotation < 0) {
15461 rotation += 360;
15462 }
15463 if (this._pagesRotation === rotation) {
15464 return;
15465 }
15466 this._pagesRotation = rotation;
15467 const pageNumber = this._currentPageNumber;
15468 this.refresh(true, {
15469 rotation
15470 });
15471 if (this._currentScaleValue) {
15472 this.#setScale(this._currentScaleValue, {
15473 noScroll: true
15474 });
15475 }
15476 this.eventBus.dispatch("rotationchanging", {
15477 source: this,
15478 pagesRotation: rotation,
15479 pageNumber
15480 });
15481 if (this.defaultRenderingQueue) {
15482 this.update();
15483 }
15484 }
15485 get firstPagePromise() {
15486 return this.pdfDocument ? this._firstPageCapability.promise : null;
15487 }
15488 get onePageRendered() {
15489 return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
15490 }
15491 get pagesPromise() {
15492 return this.pdfDocument ? this._pagesCapability.promise : null;
15493 }
15494 get _layerProperties() {
15495 const self = this;
15496 return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_layerProperties", {
15497 get annotationEditorUIManager() {
15498 return self.#annotationEditorUIManager;
15499 },
15500 get annotationStorage() {
15501 return self.pdfDocument?.annotationStorage;
15502 },
15503 get downloadManager() {
15504 return self.downloadManager;
15505 },
15506 get enableScripting() {
15507 return !!self._scriptingManager;
15508 },
15509 get fieldObjectsPromise() {
15510 return self.pdfDocument?.getFieldObjects();
15511 },
15512 get findController() {
15513 return self.findController;
15514 },
15515 get hasJSActionsPromise() {
15516 return self.pdfDocument?.hasJSActions();
15517 },
15518 get linkService() {
15519 return self.linkService;
15520 }
15521 });
15522 }
15523 #initializePermissions(permissions) {
15524 const params = {
15525 annotationEditorMode: this.#annotationEditorMode,
15526 annotationMode: this.#annotationMode,
15527 textLayerMode: this.#textLayerMode
15528 };
15529 if (!permissions) {
15530 return params;
15531 }
15532 if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.COPY) && this.#textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE) {
15533 params.textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS;
15534 }
15535 if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.MODIFY_CONTENTS)) {
15536 params.annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
15537 }
15538 if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS) {
15539 params.annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE;
15540 }
15541 return params;
15542 }
15543 async #onePageRenderedOrForceFetch() {
15544 if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
15545 return;
15546 }
15547 const visibilityChangePromise = new Promise(resolve => {
15548 this.#onVisibilityChange = () => {
15549 if (document.visibilityState !== "hidden") {
15550 return;
15551 }
15552 resolve();
15553 };
15554 document.addEventListener("visibilitychange", this.#onVisibilityChange);
15555 });
15556 await Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
15557 document.removeEventListener("visibilitychange", this.#onVisibilityChange);
15558 this.#onVisibilityChange = null;
15559 }
15560 async getAllText() {
15561 const texts = [];
15562 const buffer = [];
15563 for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
15564 if (this.#interruptCopyCondition) {
15565 return null;
15566 }
15567 buffer.length = 0;
15568 const page = await this.pdfDocument.getPage(pageNum);
15569 const {
15570 items
15571 } = await page.getTextContent();
15572 for (const item of items) {
15573 if (item.str) {
15574 buffer.push(item.str);
15575 }
15576 if (item.hasEOL) {
15577 buffer.push("\n");
15578 }
15579 }
15580 texts.push((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.removeNullCharacters)(buffer.join("")));
15581 }
15582 return texts.join("\n");
15583 }
15584 #copyCallback(textLayerMode, event) {
15585 const selection = document.getSelection();
15586 const {
15587 focusNode,
15588 anchorNode
15589 } = selection;
15590 if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) {
15591 if (this.#getAllTextInProgress || textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS) {
15592 event.preventDefault();
15593 event.stopPropagation();
15594 return;
15595 }
15596 this.#getAllTextInProgress = true;
15597 const savedCursor = this.container.style.cursor;
15598 this.container.style.cursor = "wait";
15599 const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape";
15600 window.addEventListener("keydown", interruptCopy);
15601 this.getAllText().then(async text => {
15602 if (text !== null) {
15603 await navigator.clipboard.writeText(text);
15604 }
15605 }).catch(reason => {
15606 console.warn(`Something goes wrong when extracting the text: ${reason.message}`);
15607 }).finally(() => {
15608 this.#getAllTextInProgress = false;
15609 this.#interruptCopyCondition = false;
15610 window.removeEventListener("keydown", interruptCopy);
15611 this.container.style.cursor = savedCursor;
15612 });
15613 event.preventDefault();
15614 event.stopPropagation();
15615 }
15616 }
15617 setDocument(pdfDocument) {
15618 if (this.pdfDocument) {
15619 this.eventBus.dispatch("pagesdestroy", {
15620 source: this
15621 });
15622 this._cancelRendering();
15623 this._resetView();
15624 this.findController?.setDocument(null);
15625 this._scriptingManager?.setDocument(null);
15626 if (this.#annotationEditorUIManager) {
15627 this.#annotationEditorUIManager.destroy();
15628 this.#annotationEditorUIManager = null;
15629 }
15630 }
15631 this.pdfDocument = pdfDocument;
15632 if (!pdfDocument) {
15633 return;
15634 }
15635 const pagesCount = pdfDocument.numPages;
15636 const firstPagePromise = pdfDocument.getPage(1);
15637 const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
15638 intent: "display"
15639 });
15640 const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
15641 if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
15642 console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
15643 const mode = this._scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE;
15644 this.eventBus.dispatch("scrollmodechanged", {
15645 source: this,
15646 mode
15647 });
15648 }
15649 this._pagesCapability.promise.then(() => {
15650 this.eventBus.dispatch("pagesloaded", {
15651 source: this,
15652 pagesCount
15653 });
15654 }, () => {});
15655 this._onBeforeDraw = evt => {
15656 const pageView = this._pages[evt.pageNumber - 1];
15657 if (!pageView) {
15658 return;
15659 }
15660 this.#buffer.push(pageView);
15661 };
15662 this.eventBus._on("pagerender", this._onBeforeDraw);
15663 this._onAfterDraw = evt => {
15664 if (evt.cssTransform) {
15665 return;
15666 }
15667 this._onePageRenderedCapability.resolve({
15668 timestamp: evt.timestamp
15669 });
15670 this.eventBus._off("pagerendered", this._onAfterDraw);
15671 this._onAfterDraw = null;
15672 };
15673 this.eventBus._on("pagerendered", this._onAfterDraw);
15674 Promise.all([firstPagePromise, permissionsPromise]).then(([firstPdfPage, permissions]) => {
15675 if (pdfDocument !== this.pdfDocument) {
15676 return;
15677 }
15678 this._firstPageCapability.resolve(firstPdfPage);
15679 this._optionalContentConfigPromise = optionalContentConfigPromise;
15680 const {
15681 annotationEditorMode,
15682 annotationMode,
15683 textLayerMode
15684 } = this.#initializePermissions(permissions);
15685 if (textLayerMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.DISABLE) {
15686 const element = this.#hiddenCopyElement = document.createElement("div");
15687 element.id = "hiddenCopyElement";
15688 this.viewer.before(element);
15689 }
15690 if (annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE) {
15691 const mode = annotationEditorMode;
15692 if (pdfDocument.isPureXfa) {
15693 console.warn("Warning: XFA-editing is not implemented.");
15694 } else if (isValidAnnotationEditorMode(mode)) {
15695 this.#annotationEditorUIManager = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorUIManager(this.container, this.viewer, this.#altTextManager, this.eventBus, pdfDocument, this.pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#mlManager);
15696 this.eventBus.dispatch("annotationeditoruimanager", {
15697 source: this,
15698 uiManager: this.#annotationEditorUIManager
15699 });
15700 if (mode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE) {
15701 this.#annotationEditorUIManager.updateMode(mode);
15702 }
15703 } else {
15704 console.error(`Invalid AnnotationEditor mode: ${mode}`);
15705 }
15706 }
15707 const viewerElement = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE ? null : this.viewer;
15708 const scale = this.currentScale;
15709 const viewport = firstPdfPage.getViewport({
15710 scale: scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS
15711 });
15712 this.viewer.style.setProperty("--scale-factor", viewport.scale);
15713 if (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas") {
15714 this.viewer.style.setProperty("--hcm-highlight-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight"));
15715 this.viewer.style.setProperty("--hcm-highlight-selected-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "ButtonText"));
15716 }
15717 for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
15718 const pageView = new _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_4__.PDFPageView({
15719 container: viewerElement,
15720 eventBus: this.eventBus,
15721 id: pageNum,
15722 scale,
15723 defaultViewport: viewport.clone(),
15724 optionalContentConfigPromise,
15725 renderingQueue: this.renderingQueue,
15726 textLayerMode,
15727 annotationMode,
15728 imageResourcesPath: this.imageResourcesPath,
15729 maxCanvasPixels: this.maxCanvasPixels,
15730 pageColors: this.pageColors,
15731 l10n: this.l10n,
15732 layerProperties: this._layerProperties
15733 });
15734 this._pages.push(pageView);
15735 }
15736 const firstPageView = this._pages[0];
15737 if (firstPageView) {
15738 firstPageView.setPdfPage(firstPdfPage);
15739 this.linkService.cachePageRef(1, firstPdfPage.ref);
15740 }
15741 if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
15742 this.#ensurePageViewVisible();
15743 } else if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
15744 this._updateSpreadMode();
15745 }
15746 this.#onePageRenderedOrForceFetch().then(async () => {
15747 this.findController?.setDocument(pdfDocument);
15748 this._scriptingManager?.setDocument(pdfDocument);
15749 if (this.#hiddenCopyElement) {
15750 this.#copyCallbackBound = this.#copyCallback.bind(this, textLayerMode);
15751 document.addEventListener("copy", this.#copyCallbackBound);
15752 }
15753 if (this.#annotationEditorUIManager) {
15754 this.eventBus.dispatch("annotationeditormodechanged", {
15755 source: this,
15756 mode: this.#annotationEditorMode
15757 });
15758 }
15759 if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
15760 this._pagesCapability.resolve();
15761 return;
15762 }
15763 let getPagesLeft = pagesCount - 1;
15764 if (getPagesLeft <= 0) {
15765 this._pagesCapability.resolve();
15766 return;
15767 }
15768 if (this.#pageViewMode === "book") {
15769 await this.ensureAdjacentPagesAreLoaded();
15770 }
15771 for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
15772 const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
15773 const pageView = this._pages[pageNum - 1];
15774 if (!pageView.pdfPage) {
15775 pageView.setPdfPage(pdfPage);
15776 }
15777 this.linkService.cachePageRef(pageNum, pdfPage.ref);
15778 if (--getPagesLeft === 0) {
15779 this._pagesCapability.resolve();
15780 }
15781 }, reason => {
15782 console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
15783 if (--getPagesLeft === 0) {
15784 this._pagesCapability.resolve();
15785 }
15786 });
15787 if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
15788 await promise;
15789 }
15790 }
15791 });
15792 this.hidePagesDependingOnpageViewMode();
15793 this.eventBus.dispatch("pagesinit", {
15794 source: this
15795 });
15796 pdfDocument.getMetadata().then(({
15797 info
15798 }) => {
15799 if (pdfDocument !== this.pdfDocument) {
15800 return;
15801 }
15802 if (info.Language) {
15803 this.viewer.lang = info.Language;
15804 }
15805 });
15806 if (this.defaultRenderingQueue) {
15807 this.update();
15808 }
15809 }).catch(reason => {
15810 globalThis.ngxConsole.error("Unable to initialize viewer", reason);
15811 this._pagesCapability.reject(reason);
15812 });
15813 }
15814 setPageLabels(labels) {
15815 if (!this.pdfDocument) {
15816 return;
15817 }
15818 if (!labels) {
15819 this._pageLabels = null;
15820 } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
15821 this._pageLabels = null;
15822 globalThis.ngxConsole.error(`setPageLabels: Invalid page labels.`);
15823 } else {
15824 this._pageLabels = labels;
15825 }
15826 for (let i = 0, ii = this._pages.length; i < ii; i++) {
15827 this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
15828 }
15829 }
15830 _resetView() {
15831 this._pages = [];
15832 this._currentPageNumber = 1;
15833 this._currentScale = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE;
15834 this._currentScaleValue = null;
15835 this._pageLabels = null;
15836 const bufferSize = Number(PDFViewerApplicationOptions.get("defaultCacheSize")) || DEFAULT_CACHE_SIZE;
15837 this.#buffer = new PDFPageViewBuffer(bufferSize);
15838 this._location = null;
15839 this._pagesRotation = 0;
15840 this._optionalContentConfigPromise = null;
15841 this._firstPageCapability = Promise.withResolvers();
15842 this._onePageRenderedCapability = Promise.withResolvers();
15843 this._pagesCapability = Promise.withResolvers();
15844 this._scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL;
15845 this._previousScrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.UNKNOWN;
15846 this._spreadMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE;
15847 this.#scrollModePageState = {
15848 previousPageNumber: 1,
15849 scrollDown: true,
15850 pages: []
15851 };
15852 if (this._onBeforeDraw) {
15853 this.eventBus._off("pagerender", this._onBeforeDraw);
15854 this._onBeforeDraw = null;
15855 }
15856 if (this._onAfterDraw) {
15857 this.eventBus._off("pagerendered", this._onAfterDraw);
15858 this._onAfterDraw = null;
15859 }
15860 if (this.#onVisibilityChange) {
15861 document.removeEventListener("visibilitychange", this.#onVisibilityChange);
15862 this.#onVisibilityChange = null;
15863 }
15864 this.viewer.textContent = "";
15865 this._updateScrollMode();
15866 this.viewer.removeAttribute("lang");
15867 if (this.#hiddenCopyElement) {
15868 document.removeEventListener("copy", this.#copyCallbackBound);
15869 this.#copyCallbackBound = null;
15870 this.#hiddenCopyElement.remove();
15871 this.#hiddenCopyElement = null;
15872 }
15873 }
15874 #ensurePageViewVisible() {
15875 if (this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
15876 throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
15877 }
15878 const pageNumber = this._currentPageNumber,
15879 state = this.#scrollModePageState,
15880 viewer = this.viewer;
15881 viewer.textContent = "";
15882 state.pages.length = 0;
15883 if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && !this.isInPresentationMode) {
15884 const pageView = this._pages[pageNumber - 1];
15885 viewer.append(pageView.div);
15886 state.pages.push(pageView);
15887 } else {
15888 const pageIndexSet = new Set(),
15889 parity = this._spreadMode - 1;
15890 if (parity === -1) {
15891 pageIndexSet.add(pageNumber - 1);
15892 } else if (pageNumber % 2 !== parity) {
15893 pageIndexSet.add(pageNumber - 1);
15894 pageIndexSet.add(pageNumber);
15895 } else {
15896 pageIndexSet.add(pageNumber - 2);
15897 pageIndexSet.add(pageNumber - 1);
15898 }
15899 const spread = document.createElement("div");
15900 spread.className = "spread";
15901 if (this.isInPresentationMode) {
15902 const dummyPage = document.createElement("div");
15903 dummyPage.className = "dummyPage";
15904 spread.append(dummyPage);
15905 }
15906 for (const i of pageIndexSet) {
15907 const pageView = this._pages[i];
15908 if (!pageView) {
15909 continue;
15910 }
15911 spread.append(pageView.div);
15912 state.pages.push(pageView);
15913 }
15914 viewer.append(spread);
15915 }
15916 state.scrollDown = pageNumber >= state.previousPageNumber;
15917 state.previousPageNumber = pageNumber;
15918 }
15919 _scrollUpdate() {
15920 if (this.pagesCount === 0) {
15921 return;
15922 }
15923 this.update();
15924 }
15925 scrollPagePosIntoView(pageNumber, pageSpot) {
15926 const pageDiv = this._pages[pageNumber - 1].div;
15927 if (pageSpot) {
15928 const targetPageSpot = {
15929 ...pageSpot
15930 };
15931 if (typeof targetPageSpot.top === "string") {
15932 if (targetPageSpot.top.endsWith("%")) {
15933 const percent = Number(targetPageSpot.top.replace("%", ""));
15934 const viewerHeight = this.viewer.querySelector(".page")?.clientHeight;
15935 let height = pageDiv.clientHeight ?? viewerHeight;
15936 const visibleWindowHeight = this.viewer.parentElement.clientHeight;
15937 height = Math.max(0, height - visibleWindowHeight);
15938 targetPageSpot.top = percent * height / 100;
15939 }
15940 }
15941 if (typeof targetPageSpot.left === "string") {
15942 if (targetPageSpot.left.endsWith("%")) {
15943 const percent = Number(targetPageSpot.left.replace("%", ""));
15944 const viewerWidth = this.viewer.querySelector(".page")?.clientWidth;
15945 const width = pageDiv.clientWidth ?? viewerWidth;
15946 targetPageSpot.left = percent * width / 100;
15947 }
15948 }
15949 this.#scrollIntoView({
15950 div: pageDiv,
15951 id: pageNumber
15952 }, targetPageSpot);
15953 } else {
15954 this.#scrollIntoView({
15955 div: pageDiv,
15956 id: pageNumber
15957 });
15958 }
15959 }
15960 #scrollIntoView(pageView, pageSpot = null) {
15961 if (!pageView) {
15962 return;
15963 }
15964 const {
15965 div,
15966 id
15967 } = pageView;
15968 if (this._currentPageNumber !== id) {
15969 this._setCurrentPageNumber(id);
15970 }
15971 if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
15972 this.#ensurePageViewVisible();
15973 this.update();
15974 }
15975 if (!pageSpot && !this.isInPresentationMode) {
15976 const left = div.offsetLeft + div.clientLeft,
15977 right = left + div.clientWidth;
15978 const {
15979 scrollLeft,
15980 clientWidth
15981 } = this.container;
15982 if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
15983 pageSpot = {
15984 left: 0,
15985 top: 0
15986 };
15987 }
15988 }
15989 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.scrollIntoView)(div, pageSpot, false, this.pageViewMode === "infinite-scroll");
15990 if (!this._currentScaleValue && this._location) {
15991 this._location = null;
15992 }
15993 }
15994 #isSameScale(newScale) {
15995 return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
15996 }
15997 #setScaleUpdatePages(newScale, newValue, {
15998 noScroll = false,
15999 preset = false,
16000 drawingDelay = -1
16001 }) {
16002 const previousScale = isNaN(Number(this.currentScale)) ? undefined : Number(this.currentScale);
16003 const previousScaleValue = this.currentScaleValue;
16004 this._currentScaleValue = newValue.toString();
16005 if (this.#isSameScale(newScale)) {
16006 if (preset) {
16007 this.eventBus.dispatch("scalechanging", {
16008 source: this,
16009 scale: newScale,
16010 presetValue: newValue,
16011 previousScale,
16012 previousPresetValue: previousScaleValue,
16013 noScroll
16014 });
16015 }
16016 return;
16017 }
16018 this.viewer.style.setProperty("--scale-factor", newScale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS);
16019 const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
16020 this.refresh(true, {
16021 scale: newScale,
16022 drawingDelay: postponeDrawing ? drawingDelay : -1
16023 });
16024 if (postponeDrawing) {
16025 this.#scaleTimeoutId = setTimeout(() => {
16026 this.#scaleTimeoutId = null;
16027 this.refresh();
16028 }, drawingDelay);
16029 }
16030 this._currentScale = newScale;
16031 if (!noScroll) {
16032 let page = this._currentPageNumber,
16033 dest;
16034 if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
16035 page = this._location.pageNumber;
16036 dest = [null, {
16037 name: "XYZ"
16038 }, this._location.left, this._location.top, null];
16039 }
16040 this.scrollPageIntoView({
16041 pageNumber: page,
16042 destArray: dest,
16043 allowNegativeOffset: true
16044 });
16045 }
16046 this.eventBus.dispatch("scalechanging", {
16047 source: this,
16048 scale: newScale,
16049 presetValue: preset ? newValue : undefined,
16050 previousScale,
16051 previousPresetValue: previousScaleValue,
16052 noScroll
16053 });
16054 if (this.defaultRenderingQueue) {
16055 this.update();
16056 }
16057 }
16058 get #pageWidthScaleFactor() {
16059 if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL) {
16060 return 2;
16061 }
16062 return 1;
16063 }
16064 #setScale(value, options) {
16065 if (!value) {
16066 value = "auto";
16067 }
16068 let scale = parseFloat(value);
16069 if (this._currentScale === scale) {
16070 return;
16071 }
16072 if (scale > 0) {
16073 options.preset = false;
16074 this.#setScaleUpdatePages(scale, value, options);
16075 } else {
16076 const currentPage = this._pages[this._currentPageNumber - 1];
16077 if (!currentPage) {
16078 return;
16079 }
16080 let hPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SCROLLBAR_PADDING,
16081 vPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.VERTICAL_PADDING;
16082 if (this.isInPresentationMode) {
16083 hPadding = vPadding = 4;
16084 if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
16085 hPadding *= 2;
16086 }
16087 } else if (this.removePageBorders) {
16088 hPadding = vPadding = 0;
16089 } else if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL) {
16090 [hPadding, vPadding] = [vPadding, hPadding];
16091 }
16092 const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor;
16093 const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
16094 switch (value) {
16095 case "page-actual":
16096 scale = 1;
16097 break;
16098 case "page-width":
16099 scale = pageWidthScale;
16100 break;
16101 case "page-height":
16102 scale = pageHeightScale;
16103 break;
16104 case "page-fit":
16105 scale = Math.min(pageWidthScale, pageHeightScale);
16106 break;
16107 case "auto":
16108 const horizontalScale = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
16109 scale = Math.min(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_AUTO_SCALE, horizontalScale);
16110 break;
16111 default:
16112 globalThis.ngxConsole.error(`#setScale: "${value}" is an unknown zoom value.`);
16113 return;
16114 }
16115 options.preset = true;
16116 this.#setScaleUpdatePages(scale, value, options);
16117 }
16118 }
16119 #resetCurrentPageView() {
16120 const pageView = this._pages[this._currentPageNumber - 1];
16121 if (this.isInPresentationMode) {
16122 this.#setScale(this._currentScaleValue, {
16123 noScroll: true
16124 });
16125 }
16126 this.#scrollIntoView(pageView);
16127 }
16128 pageLabelToPageNumber(label) {
16129 if (!this._pageLabels) {
16130 return null;
16131 }
16132 const i = this._pageLabels.indexOf(label);
16133 if (i < 0) {
16134 return null;
16135 }
16136 return i + 1;
16137 }
16138 scrollPageIntoView({
16139 pageNumber,
16140 destArray = null,
16141 allowNegativeOffset = false,
16142 ignoreDestinationZoom = false
16143 }) {
16144 if (!this.pdfDocument) {
16145 return;
16146 }
16147 const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
16148 if (!pageView) {
16149 console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
16150 return;
16151 }
16152 if (this.isInPresentationMode || !destArray) {
16153 this._setCurrentPageNumber(pageNumber, true);
16154 return;
16155 }
16156 let x = 0,
16157 y = 0;
16158 let width = 0,
16159 height = 0,
16160 widthScale,
16161 heightScale;
16162 const changeOrientation = pageView.rotation % 180 !== 0;
16163 const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
16164 const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
16165 let scale = 0;
16166 switch (destArray[1].name) {
16167 case "XYZ":
16168 x = destArray[2];
16169 y = destArray[3];
16170 scale = destArray[4];
16171 x = x !== null ? x : 0;
16172 y = y !== null ? y : pageHeight;
16173 break;
16174 case "Fit":
16175 case "FitB":
16176 scale = "page-fit";
16177 break;
16178 case "FitH":
16179 case "FitBH":
16180 y = destArray[2];
16181 scale = "page-width";
16182 if (y === null && this._location) {
16183 x = this._location.left;
16184 y = this._location.top;
16185 } else if (typeof y !== "number" || y < 0) {
16186 y = pageHeight;
16187 }
16188 break;
16189 case "FitV":
16190 case "FitBV":
16191 x = destArray[2];
16192 width = pageWidth;
16193 height = pageHeight;
16194 scale = "page-height";
16195 break;
16196 case "FitR":
16197 x = destArray[2];
16198 y = destArray[3];
16199 width = destArray[4] - x;
16200 height = destArray[5] - y;
16201 let hPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SCROLLBAR_PADDING,
16202 vPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.VERTICAL_PADDING;
16203 if (this.removePageBorders) {
16204 hPadding = vPadding = 0;
16205 }
16206 widthScale = (this.container.clientWidth - hPadding) / width / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
16207 heightScale = (this.container.clientHeight - vPadding) / height / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
16208 scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
16209 break;
16210 default:
16211 console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
16212 return;
16213 }
16214 if (!ignoreDestinationZoom) {
16215 if (scale && scale !== this._currentScale) {
16216 this.currentScaleValue = scale;
16217 } else if (this._currentScale === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE) {
16218 this.currentScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_VALUE;
16219 }
16220 }
16221 this.#ensurePdfPageLoaded(pageView).then(() => {
16222 this.renderingQueue.renderView(pageView);
16223 if (this.pageViewMode === "single") {
16224 if (this.currentPageNumber !== pageNumber) {
16225 this.currentPageNumber = pageNumber;
16226 }
16227 }
16228 });
16229 if (scale === "page-fit" && !destArray[4]) {
16230 this.#scrollIntoView(pageView);
16231 return;
16232 }
16233 const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
16234 let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
16235 let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
16236 if (!allowNegativeOffset) {
16237 left = Math.max(left, 0);
16238 top = Math.max(top, 0);
16239 }
16240 this.#scrollIntoView(pageView, {
16241 left,
16242 top
16243 });
16244 }
16245 _updateLocation(firstPage) {
16246 const currentScale = this._currentScale;
16247 const currentScaleValue = this._currentScaleValue;
16248 const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
16249 const pageNumber = firstPage.id;
16250 const currentPageView = this._pages[pageNumber - 1];
16251 const container = this.container;
16252 const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
16253 const intLeft = Math.round(topLeft[0]);
16254 const intTop = Math.round(topLeft[1]);
16255 let pdfOpenParams = `#page=${pageNumber}`;
16256 if (!this.isInPresentationMode) {
16257 pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
16258 }
16259 this._location = {
16260 pageNumber,
16261 scale: normalizedScaleValue,
16262 top: intTop,
16263 left: intLeft,
16264 rotation: this._pagesRotation,
16265 pdfOpenParams
16266 };
16267 }
16268 update(noScroll = false) {
16269 if (this.scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
16270 this.viewer.classList.add("singlePageView");
16271 } else {
16272 this.viewer.classList.remove("singlePageView");
16273 }
16274 const visible = this._getVisiblePages();
16275 const visiblePages = visible.views,
16276 numVisiblePages = visiblePages.length;
16277 if (numVisiblePages === 0) {
16278 return;
16279 }
16280 const bufferSize = Number(PDFViewerApplicationOptions.get("defaultCacheSize")) || DEFAULT_CACHE_SIZE;
16281 const newCacheSize = Math.max(bufferSize, 2 * numVisiblePages + 1);
16282 this.#buffer.resize(newCacheSize, visible.ids);
16283 this.renderingQueue.renderHighestPriority(visible);
16284 const isSimpleLayout = this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE || this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL);
16285 const currentId = this._currentPageNumber;
16286 let stillFullyVisible = false;
16287 for (const page of visiblePages) {
16288 if (page.percent < 100) {
16289 break;
16290 }
16291 if (page.id === currentId && isSimpleLayout) {
16292 stillFullyVisible = true;
16293 break;
16294 }
16295 }
16296 if (this.scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE && !noScroll) {
16297 this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
16298 this._updateLocation(visible.first);
16299 this.eventBus.dispatch("updateviewarea", {
16300 source: this,
16301 location: this._location
16302 });
16303 }
16304 this.hidePagesDependingOnpageViewMode();
16305 }
16306 containsElement(element) {
16307 return this.container.contains(element);
16308 }
16309 focus() {
16310 this.container.focus();
16311 }
16312 get _isContainerRtl() {
16313 return getComputedStyle(this.container).direction === "rtl";
16314 }
16315 get isInPresentationMode() {
16316 return this.presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN;
16317 }
16318 get isChangingPresentationMode() {
16319 return this.presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.CHANGING;
16320 }
16321 get isHorizontalScrollbarEnabled() {
16322 return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
16323 }
16324 get isVerticalScrollbarEnabled() {
16325 return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
16326 }
16327 _getVisiblePages() {
16328 const views = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages,
16329 horizontal = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL,
16330 rtl = horizontal && this._isContainerRtl;
16331 return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.getVisibleElements)({
16332 scrollEl: this.container,
16333 views,
16334 sortByVisibility: true,
16335 horizontal,
16336 rtl
16337 });
16338 }
16339 cleanup() {
16340 for (const pageView of this._pages) {
16341 if (pageView.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED) {
16342 pageView.reset();
16343 }
16344 }
16345 }
16346 _cancelRendering() {
16347 for (const pageView of this._pages) {
16348 pageView.cancelRendering();
16349 }
16350 }
16351 async #ensurePdfPageLoaded(pageView) {
16352 if (pageView.pdfPage) {
16353 return pageView.pdfPage;
16354 }
16355 try {
16356 const pdfPage = await this.pdfDocument.getPage(pageView.id);
16357 if (!pageView.pdfPage) {
16358 pageView.setPdfPage(pdfPage);
16359 }
16360 if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
16361 this.linkService.cachePageRef(pageView.id, pdfPage.ref);
16362 }
16363 return pdfPage;
16364 } catch (reason) {
16365 console.error("Unable to get page for page view", reason);
16366 return null;
16367 }
16368 }
16369 #getScrollAhead(visible) {
16370 if (visible.first?.id === 1) {
16371 return true;
16372 } else if (visible.last?.id === this.pagesCount) {
16373 return false;
16374 }
16375 switch (this._scrollMode) {
16376 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE:
16377 return this.#scrollModePageState.scrollDown;
16378 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL:
16379 return this.scroll.right;
16380 }
16381 return this.scroll.down;
16382 }
16383 forceRendering(currentlyVisiblePages) {
16384 const visiblePages = currentlyVisiblePages || this._getVisiblePages();
16385 const scrollAhead = this.#getScrollAhead(visiblePages);
16386 const preRenderExtra = this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL;
16387 const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
16388 if (pageView) {
16389 this.#ensurePdfPageLoaded(pageView).then(() => {
16390 this.renderingQueue.renderView(pageView);
16391 });
16392 return true;
16393 }
16394 return false;
16395 }
16396 get hasEqualPageSizes() {
16397 const firstPageView = this._pages[0];
16398 for (let i = 1, ii = this._pages.length; i < ii; ++i) {
16399 const pageView = this._pages[i];
16400 if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
16401 return false;
16402 }
16403 }
16404 return true;
16405 }
16406 getPagesOverview() {
16407 let initialOrientation;
16408 return this._pages.map(pageView => {
16409 const viewport = pageView.pdfPage.getViewport({
16410 scale: 1
16411 });
16412 const orientation = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isPortraitOrientation)(viewport);
16413 if (initialOrientation === undefined) {
16414 initialOrientation = orientation;
16415 } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
16416 return {
16417 width: viewport.height,
16418 height: viewport.width,
16419 rotation: (viewport.rotation - 90) % 360
16420 };
16421 }
16422 return {
16423 width: viewport.width,
16424 height: viewport.height,
16425 rotation: viewport.rotation
16426 };
16427 });
16428 }
16429 get optionalContentConfigPromise() {
16430 if (!this.pdfDocument) {
16431 return Promise.resolve(null);
16432 }
16433 if (!this._optionalContentConfigPromise) {
16434 console.error("optionalContentConfigPromise: Not initialized yet.");
16435 return this.pdfDocument.getOptionalContentConfig({
16436 intent: "display"
16437 });
16438 }
16439 return this._optionalContentConfigPromise;
16440 }
16441 set optionalContentConfigPromise(promise) {
16442 if (!(promise instanceof Promise)) {
16443 throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
16444 }
16445 if (!this.pdfDocument) {
16446 return;
16447 }
16448 if (!this._optionalContentConfigPromise) {
16449 return;
16450 }
16451 this._optionalContentConfigPromise = promise;
16452 this.refresh(false, {
16453 optionalContentConfigPromise: promise
16454 });
16455 this.eventBus.dispatch("optionalcontentconfigchanged", {
16456 source: this,
16457 promise
16458 });
16459 }
16460 get scrollMode() {
16461 return this._scrollMode;
16462 }
16463 set scrollMode(mode) {
16464 if (this._scrollMode === mode) {
16465 return;
16466 }
16467 if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidScrollMode)(mode)) {
16468 throw new Error(`Invalid scroll mode: ${mode}`);
16469 }
16470 if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
16471 return;
16472 }
16473 this._previousScrollMode = this._scrollMode;
16474 this._scrollMode = mode;
16475 this.eventBus.dispatch("scrollmodechanged", {
16476 source: this,
16477 mode
16478 });
16479 this._updateScrollMode(this._currentPageNumber);
16480 }
16481 _updateScrollMode(pageNumber = null) {
16482 const scrollMode = this._scrollMode,
16483 viewer = this.viewer;
16484 viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL);
16485 viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.WRAPPED);
16486 if (!this.pdfDocument || !pageNumber) {
16487 return;
16488 }
16489 if (scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
16490 this.#ensurePageViewVisible();
16491 } else if (this._previousScrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
16492 this._updateSpreadMode();
16493 }
16494 if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
16495 this.#setScale(this._currentScaleValue, {
16496 noScroll: true
16497 });
16498 }
16499 this._setCurrentPageNumber(pageNumber, true);
16500 this.update();
16501 }
16502 get spreadMode() {
16503 return this._spreadMode;
16504 }
16505 set spreadMode(mode) {
16506 if (this._spreadMode === mode) {
16507 return;
16508 }
16509 if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidSpreadMode)(mode)) {
16510 throw new Error(`Invalid spread mode: ${mode}`);
16511 }
16512 this._spreadMode = mode;
16513 this.eventBus.dispatch("spreadmodechanged", {
16514 source: this,
16515 mode
16516 });
16517 this._updateSpreadMode(this._currentPageNumber);
16518 }
16519 _updateSpreadMode(pageNumber = null) {
16520 if (!this.pdfDocument) {
16521 return;
16522 }
16523 const viewer = this.viewer,
16524 pages = this._pages;
16525 if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
16526 this.#ensurePageViewVisible();
16527 } else {
16528 viewer.textContent = "";
16529 if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
16530 for (const pageView of this._pages) {
16531 viewer.append(pageView.div);
16532 }
16533 } else {
16534 const parity = this._spreadMode - 1;
16535 let spread = null;
16536 for (let i = 0, ii = pages.length; i < ii; ++i) {
16537 if (spread === null) {
16538 spread = document.createElement("div");
16539 spread.className = "spread";
16540 viewer.append(spread);
16541 } else if (i % 2 === parity) {
16542 spread = spread.cloneNode(false);
16543 viewer.append(spread);
16544 }
16545 spread.append(pages[i].div);
16546 }
16547 }
16548 }
16549 this.hidePagesDependingOnpageViewMode();
16550 if (!pageNumber) {
16551 return;
16552 }
16553 if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
16554 this.#setScale(this._currentScaleValue, {
16555 noScroll: true
16556 });
16557 }
16558 this._setCurrentPageNumber(pageNumber, true);
16559 this.update();
16560 }
16561 _getPageAdvance(currentPageNumber, previous = false) {
16562 if (this.pageViewMode === "book") {
16563 return 2;
16564 }
16565 switch (this._scrollMode) {
16566 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.WRAPPED:
16567 {
16568 const {
16569 views
16570 } = this._getVisiblePages(),
16571 pageLayout = new Map();
16572 for (const {
16573 id,
16574 y,
16575 percent,
16576 widthPercent
16577 } of views) {
16578 if (percent === 0 || widthPercent < 100) {
16579 continue;
16580 }
16581 let yArray = pageLayout.get(y);
16582 if (!yArray) {
16583 pageLayout.set(y, yArray ||= []);
16584 }
16585 yArray.push(id);
16586 }
16587 for (const yArray of pageLayout.values()) {
16588 const currentIndex = yArray.indexOf(currentPageNumber);
16589 if (currentIndex === -1) {
16590 continue;
16591 }
16592 const numPages = yArray.length;
16593 if (numPages === 1) {
16594 break;
16595 }
16596 if (previous) {
16597 for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
16598 const currentId = yArray[i],
16599 expectedId = yArray[i + 1] - 1;
16600 if (currentId < expectedId) {
16601 return currentPageNumber - expectedId;
16602 }
16603 }
16604 } else {
16605 for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
16606 const currentId = yArray[i],
16607 expectedId = yArray[i - 1] + 1;
16608 if (currentId > expectedId) {
16609 return expectedId - currentPageNumber;
16610 }
16611 }
16612 }
16613 if (previous) {
16614 const firstId = yArray[0];
16615 if (firstId < currentPageNumber) {
16616 return currentPageNumber - firstId + 1;
16617 }
16618 } else {
16619 const lastId = yArray[numPages - 1];
16620 if (lastId > currentPageNumber) {
16621 return lastId - currentPageNumber + 1;
16622 }
16623 }
16624 break;
16625 }
16626 break;
16627 }
16628 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL:
16629 {
16630 break;
16631 }
16632 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE:
16633 case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL:
16634 {
16635 if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
16636 break;
16637 }
16638 const parity = this._spreadMode - 1;
16639 if (previous && currentPageNumber % 2 !== parity) {
16640 break;
16641 } else if (!previous && currentPageNumber % 2 === parity) {
16642 break;
16643 }
16644 const {
16645 views
16646 } = this._getVisiblePages(),
16647 expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
16648 for (const {
16649 id,
16650 percent,
16651 widthPercent
16652 } of views) {
16653 if (id !== expectedId) {
16654 continue;
16655 }
16656 if (percent > 0 && widthPercent === 100) {
16657 return 2;
16658 }
16659 break;
16660 }
16661 break;
16662 }
16663 }
16664 return 1;
16665 }
16666 nextPage() {
16667 const currentPageNumber = this._currentPageNumber,
16668 pagesCount = this.pagesCount;
16669 if (currentPageNumber >= pagesCount) {
16670 return false;
16671 }
16672 const advance = this._getPageAdvance(currentPageNumber, false) || 1;
16673 this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
16674 return true;
16675 }
16676 previousPage() {
16677 const currentPageNumber = this._currentPageNumber;
16678 if (currentPageNumber <= 1) {
16679 return false;
16680 }
16681 const advance = this._getPageAdvance(currentPageNumber, true) || 1;
16682 this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
16683 return true;
16684 }
16685 increaseScale({
16686 drawingDelay,
16687 scaleFactor,
16688 steps
16689 } = {}) {
16690 if (!this.pdfDocument) {
16691 return;
16692 }
16693 let newScale = this._currentScale;
16694 if (scaleFactor > 1) {
16695 newScale = Math.round(newScale * scaleFactor * 100) / 100;
16696 } else {
16697 steps ??= 1;
16698 do {
16699 newScale = Math.ceil((newScale * _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
16700 } while (--steps > 0 && newScale < _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE);
16701 }
16702 let maxScale = Number(PDFViewerApplicationOptions.get("maxZoom"));
16703 if (!maxScale) {
16704 maxScale = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE;
16705 }
16706 this.#setScale(Math.min(maxScale, newScale), {
16707 noScroll: false,
16708 drawingDelay
16709 });
16710 }
16711 decreaseScale({
16712 drawingDelay,
16713 scaleFactor,
16714 steps
16715 } = {}) {
16716 if (!this.pdfDocument) {
16717 return;
16718 }
16719 let newScale = this._currentScale;
16720 if (scaleFactor > 0 && scaleFactor < 1) {
16721 newScale = Math.round(newScale * scaleFactor * 100) / 100;
16722 } else {
16723 steps ??= 1;
16724 do {
16725 newScale = Math.floor((newScale / _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
16726 } while (--steps > 0 && newScale > _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE);
16727 }
16728 let minScale = Number(PDFViewerApplicationOptions.get("minZoom"));
16729 if (!minScale) {
16730 minScale = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE;
16731 }
16732 this.#setScale(Math.max(minScale, newScale), {
16733 noScroll: false,
16734 drawingDelay
16735 });
16736 }
16737 #updateContainerHeightCss(height = this.container.clientHeight) {
16738 if (height !== this.#previousContainerHeight) {
16739 this.#previousContainerHeight = height;
16740 _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.docStyle.setProperty("--viewer-container-height", `${height}px`);
16741 }
16742 }
16743 #resizeObserverCallback(entries) {
16744 for (const entry of entries) {
16745 if (entry.target === this.container) {
16746 this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize));
16747 this.#containerTopLeft = null;
16748 break;
16749 }
16750 }
16751 }
16752 get containerTopLeft() {
16753 return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
16754 }
16755 get annotationEditorMode() {
16756 return this.#annotationEditorUIManager ? this.#annotationEditorMode : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
16757 }
16758 set annotationEditorMode({
16759 mode,
16760 editId = null,
16761 isFromKeyboard = false
16762 }) {
16763 if (!this.#annotationEditorUIManager) {
16764 throw new Error(`The AnnotationEditor is not enabled.`);
16765 }
16766 if (this.#annotationEditorMode === mode) {
16767 return;
16768 }
16769 if (!isValidAnnotationEditorMode(mode)) {
16770 throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
16771 }
16772 if (!this.pdfDocument) {
16773 return;
16774 }
16775 this.#annotationEditorMode = mode;
16776 this.eventBus.dispatch("annotationeditormodechanged", {
16777 source: this,
16778 mode
16779 });
16780 this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
16781 }
16782 set annotationEditorParams({
16783 type,
16784 value
16785 }) {
16786 if (!this.#annotationEditorUIManager) {
16787 throw new Error(`The AnnotationEditor is not enabled.`);
16788 }
16789 this.#annotationEditorUIManager.updateParams(type, value);
16790 }
16791 refresh(noUpdate = false, updateArgs = Object.create(null)) {
16792 if (!this.pdfDocument) {
16793 return;
16794 }
16795 for (const pageView of this._pages) {
16796 pageView.update(updateArgs);
16797 }
16798 if (this.#scaleTimeoutId !== null) {
16799 clearTimeout(this.#scaleTimeoutId);
16800 this.#scaleTimeoutId = null;
16801 }
16802 if (!noUpdate) {
16803 this.update();
16804 }
16805 }
16806 getSerializedAnnotations() {
16807 const rawAnnotations = this.pdfDocument.annotationStorage.getAll();
16808 if (rawAnnotations) {
16809 const annotations = Object.values(rawAnnotations);
16810 return annotations.filter(a => a.serialize).map(a => a.serialize()).filter(a => a?.annotationType !== undefined);
16811 }
16812 return null;
16813 }
16814 addEditorAnnotation(data) {
16815 if (!Array.isArray(data)) {
16816 data = [data];
16817 }
16818 this.#annotationEditorUIManager.addSerializedEditor(data, true, true, false);
16819 }
16820 removeEditorAnnotations(filter = () => true) {
16821 this.#annotationEditorUIManager.removeEditors(filter);
16822 }
16823 destroyBookMode() {
16824 if (this.pageFlip) {
16825 this.pageFlip.destroy();
16826 this.pageFlip = null;
16827 }
16828 }
16829 stopRendering() {
16830 this._cancelRendering();
16831 }
16832}
16833
16834__webpack_async_result__();
16835} catch(e) { __webpack_async_result__(e); } });
16836
16837/***/ }),
16838
16839/***/ 2603:
16840/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
16841
16842__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
16843/* harmony export */ __webpack_require__.d(__webpack_exports__, {
16844/* harmony export */ AbortException: () => (/* binding */ AbortException),
16845/* harmony export */ AnnotationEditorLayer: () => (/* binding */ AnnotationEditorLayer),
16846/* harmony export */ AnnotationEditorParamsType: () => (/* binding */ AnnotationEditorParamsType),
16847/* harmony export */ AnnotationEditorType: () => (/* binding */ AnnotationEditorType),
16848/* harmony export */ AnnotationEditorUIManager: () => (/* binding */ AnnotationEditorUIManager),
16849/* harmony export */ AnnotationLayer: () => (/* binding */ AnnotationLayer),
16850/* harmony export */ AnnotationMode: () => (/* binding */ AnnotationMode),
16851/* harmony export */ ColorPicker: () => (/* binding */ ColorPicker),
16852/* harmony export */ DOMSVGFactory: () => (/* binding */ DOMSVGFactory),
16853/* harmony export */ DrawLayer: () => (/* binding */ DrawLayer),
16854/* harmony export */ GlobalWorkerOptions: () => (/* binding */ GlobalWorkerOptions),
16855/* harmony export */ InvalidPDFException: () => (/* binding */ InvalidPDFException),
16856/* harmony export */ MissingPDFException: () => (/* binding */ MissingPDFException),
16857/* harmony export */ PDFDateString: () => (/* binding */ PDFDateString),
16858/* harmony export */ PasswordResponses: () => (/* binding */ PasswordResponses),
16859/* harmony export */ PermissionFlag: () => (/* binding */ PermissionFlag),
16860/* harmony export */ PixelsPerInch: () => (/* binding */ PixelsPerInch),
16861/* harmony export */ RenderingCancelledException: () => (/* binding */ RenderingCancelledException),
16862/* harmony export */ UnexpectedResponseException: () => (/* binding */ UnexpectedResponseException),
16863/* harmony export */ XfaLayer: () => (/* binding */ XfaLayer),
16864/* harmony export */ build: () => (/* binding */ build),
16865/* harmony export */ createValidAbsoluteUrl: () => (/* binding */ createValidAbsoluteUrl),
16866/* harmony export */ fetchData: () => (/* binding */ fetchData),
16867/* harmony export */ getDocument: () => (/* binding */ getDocument),
16868/* harmony export */ getFilenameFromUrl: () => (/* binding */ getFilenameFromUrl),
16869/* harmony export */ getPdfFilenameFromUrl: () => (/* binding */ getPdfFilenameFromUrl),
16870/* harmony export */ getXfaPageViewport: () => (/* binding */ getXfaPageViewport),
16871/* harmony export */ isPdfFile: () => (/* binding */ isPdfFile),
16872/* harmony export */ noContextMenu: () => (/* binding */ noContextMenu),
16873/* harmony export */ normalizeUnicode: () => (/* binding */ normalizeUnicode),
16874/* harmony export */ renderTextLayer: () => (/* binding */ renderTextLayer),
16875/* harmony export */ setLayerDimensions: () => (/* binding */ setLayerDimensions),
16876/* harmony export */ shadow: () => (/* binding */ shadow),
16877/* harmony export */ updateTextLayer: () => (/* binding */ updateTextLayer),
16878/* harmony export */ version: () => (/* binding */ version)
16879/* harmony export */ });
16880/* unused harmony exports CMapCompressionType, FeatureTest, ImageKind, isDataScheme, OPS, Outliner, PDFDataRangeTransport, PDFWorker, Util, VerbosityLevel */
16881if (!globalThis.pdfjsLib) {
16882 await globalThis.pdfjsLibPromise;
16883}
16884const {
16885 AbortException,
16886 AnnotationEditorLayer,
16887 AnnotationEditorParamsType,
16888 AnnotationEditorType,
16889 AnnotationEditorUIManager,
16890 AnnotationLayer,
16891 AnnotationMode,
16892 build,
16893 CMapCompressionType,
16894 ColorPicker,
16895 createValidAbsoluteUrl,
16896 DOMSVGFactory,
16897 DrawLayer,
16898 FeatureTest,
16899 fetchData,
16900 getDocument,
16901 getFilenameFromUrl,
16902 getPdfFilenameFromUrl,
16903 getXfaPageViewport,
16904 GlobalWorkerOptions,
16905 ImageKind,
16906 InvalidPDFException,
16907 isDataScheme,
16908 isPdfFile,
16909 MissingPDFException,
16910 noContextMenu,
16911 normalizeUnicode,
16912 OPS,
16913 Outliner,
16914 PasswordResponses,
16915 PDFDataRangeTransport,
16916 PDFDateString,
16917 PDFWorker,
16918 PermissionFlag,
16919 PixelsPerInch,
16920 RenderingCancelledException,
16921 renderTextLayer,
16922 setLayerDimensions,
16923 shadow,
16924 UnexpectedResponseException,
16925 updateTextLayer,
16926 Util,
16927 VerbosityLevel,
16928 version,
16929 XfaLayer
16930} = globalThis.pdfjsLib;
16931
16932__webpack_async_result__();
16933} catch(e) { __webpack_async_result__(e); } }, 1);
16934
16935/***/ }),
16936
16937/***/ 8224:
16938/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
16939
16940/* harmony export */ __webpack_require__.d(__webpack_exports__, {
16941/* harmony export */ BasePreferences: () => (/* binding */ BasePreferences)
16942/* harmony export */ });
16943/* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9840);
16944
16945class BasePreferences {
16946 #browserDefaults = Object.freeze({
16947 canvasMaxAreaInBytes: -1,
16948 isInAutomation: false,
16949 supportsCaretBrowsingMode: false,
16950 supportsDocumentFonts: true,
16951 supportsIntegratedFind: false,
16952 supportsMouseWheelZoomCtrlKey: true,
16953 supportsMouseWheelZoomMetaKey: true,
16954 supportsPinchToZoom: true
16955 });
16956 #defaults = Object.freeze({
16957 annotationEditorMode: 0,
16958 annotationMode: 2,
16959 cursorToolOnLoad: 0,
16960 defaultZoomDelay: 400,
16961 defaultZoomValue: "",
16962 disablePageLabels: false,
16963 enableHighlightEditor: false,
16964 enableHighlightFloatingButton: false,
16965 enableML: false,
16966 enablePermissions: false,
16967 enablePrintAutoRotate: true,
16968 enableScripting: true,
16969 enableStampEditor: true,
16970 externalLinkTarget: 0,
16971 highlightEditorColors: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
16972 historyUpdateUrl: false,
16973 ignoreDestinationZoom: false,
16974 forcePageColors: false,
16975 pageColorsBackground: "Canvas",
16976 pageColorsForeground: "CanvasText",
16977 pdfBugEnabled: false,
16978 removePageBorders: false,
16979 sidebarViewOnLoad: -1,
16980 scrollModeOnLoad: -1,
16981 spreadModeOnLoad: -1,
16982 textLayerMode: 1,
16983 viewOnLoad: 0,
16984 disableAutoFetch: false,
16985 disableFontFace: false,
16986 disableRange: false,
16987 disableStream: false,
16988 enableXfa: true,
16989 viewerCssTheme: 0
16990 });
16991 #prefs = Object.create(null);
16992 #initializedPromise = null;
16993 constructor() {
16994 if (this.constructor === BasePreferences) {
16995 throw new Error("Cannot initialize BasePreferences.");
16996 }
16997 this.#initializedPromise = this._readFromStorage(this.#defaults).then(({
16998 browserPrefs,
16999 prefs
17000 }) => {
17001 const options = Object.create(null);
17002 for (const [name, val] of Object.entries(this.#browserDefaults)) {
17003 const prefVal = browserPrefs?.[name];
17004 options[name] = typeof prefVal === typeof val ? prefVal : val;
17005 }
17006 for (const [name, val] of Object.entries(this.#defaults)) {
17007 const prefVal = prefs?.[name];
17008 options[name] = this.#prefs[name] = typeof prefVal === typeof val ? prefVal : val;
17009 }
17010 _app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.setAll(options, true);
17011 });
17012 }
17013 async _writeToStorage(prefObj) {
17014 throw new Error("Not implemented: _writeToStorage");
17015 }
17016 async _readFromStorage(prefObj) {
17017 throw new Error("Not implemented: _readFromStorage");
17018 }
17019 #updatePref({
17020 name,
17021 value
17022 }) {
17023 throw new Error("Not implemented: #updatePref");
17024 }
17025 async reset() {
17026 await this.#initializedPromise;
17027 const oldPrefs = structuredClone(this.#prefs);
17028 this.#prefs = Object.create(null);
17029 try {
17030 await this._writeToStorage(this.#defaults);
17031 } catch (reason) {
17032 this.#prefs = oldPrefs;
17033 throw reason;
17034 }
17035 }
17036 async set(name, value) {
17037 await this.#initializedPromise;
17038 const defaultValue = this.#defaults[name],
17039 oldPrefs = structuredClone(this.#prefs);
17040 if (defaultValue === undefined) {
17041 throw new Error(`Set preference: "${name}" is undefined.`);
17042 } else if (value === undefined) {
17043 throw new Error("Set preference: no value is specified.");
17044 }
17045 const valueType = typeof value,
17046 defaultType = typeof defaultValue;
17047 if (valueType !== defaultType) {
17048 if (valueType === "number" && defaultType === "string") {
17049 value = value.toString();
17050 } else {
17051 throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
17052 }
17053 } else if (valueType === "number" && !Number.isInteger(value)) {
17054 throw new Error(`Set preference: "${value}" must be an integer.`);
17055 }
17056 this.#prefs[name] = value;
17057 try {
17058 await this._writeToStorage(this.#prefs);
17059 } catch (reason) {
17060 this.#prefs = oldPrefs;
17061 throw reason;
17062 }
17063 }
17064 async get(name) {
17065 await this.#initializedPromise;
17066 const defaultValue = this.#defaults[name];
17067 if (defaultValue === undefined) {
17068 throw new Error(`Get preference: "${name}" is undefined.`);
17069 }
17070 return this.#prefs[name] ?? defaultValue;
17071 }
17072 get initializedPromise() {
17073 return this.#initializedPromise;
17074 }
17075}
17076
17077
17078/***/ }),
17079
17080/***/ 659:
17081/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
17082
17083__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
17084/* harmony export */ __webpack_require__.d(__webpack_exports__, {
17085/* harmony export */ getXfaHtmlForPrinting: () => (/* binding */ getXfaHtmlForPrinting)
17086/* harmony export */ });
17087/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
17088/* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(787);
17089/* harmony import */ var _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2973);
17090var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__]);
17091([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
17092
17093
17094
17095function getXfaHtmlForPrinting(printContainer, pdfDocument) {
17096 const xfaHtml = pdfDocument.allXfaHtml;
17097 const linkService = new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_1__.SimpleLinkService();
17098 const scale = Math.round(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
17099 for (const xfaPage of xfaHtml.children) {
17100 const page = document.createElement("div");
17101 page.className = "xfaPrintedPage";
17102 printContainer.append(page);
17103 const builder = new _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__.XfaLayerBuilder({
17104 pdfPage: null,
17105 annotationStorage: pdfDocument.annotationStorage,
17106 linkService,
17107 xfaHtml: xfaPage
17108 });
17109 const viewport = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.getXfaPageViewport)(xfaPage, {
17110 scale
17111 });
17112 builder.render(viewport, "print");
17113 page.append(builder.div);
17114 }
17115}
17116
17117__webpack_async_result__();
17118} catch(e) { __webpack_async_result__(e); } });
17119
17120/***/ }),
17121
17122/***/ 1900:
17123/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
17124
17125__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
17126/* harmony export */ __webpack_require__.d(__webpack_exports__, {
17127/* harmony export */ SecondaryToolbar: () => (/* binding */ SecondaryToolbar)
17128/* harmony export */ });
17129/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
17130/* harmony import */ var _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6285);
17131var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__]);
17132_pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
17133
17134
17135class SecondaryToolbar {
17136 #opts;
17137 constructor(options, eventBus) {
17138 this.#opts = options;
17139 const buttons = [{
17140 element: options.presentationModeButton,
17141 eventName: "presentationmode",
17142 close: true
17143 }, {
17144 element: options.printButton,
17145 eventName: "print",
17146 close: true
17147 }, {
17148 element: options.downloadButton,
17149 eventName: "download",
17150 close: true
17151 }, {
17152 element: options.viewBookmarkButton,
17153 eventName: null,
17154 close: true
17155 }, {
17156 element: options.firstPageButton,
17157 eventName: "firstpage",
17158 close: true
17159 }, {
17160 element: options.lastPageButton,
17161 eventName: "lastpage",
17162 close: true
17163 }, {
17164 element: options.pageRotateCwButton,
17165 eventName: "rotatecw",
17166 close: false
17167 }, {
17168 element: options.pageRotateCcwButton,
17169 eventName: "rotateccw",
17170 close: false
17171 }, {
17172 element: options.cursorSelectToolButton,
17173 eventName: "switchcursortool",
17174 eventDetails: {
17175 tool: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT
17176 },
17177 close: true
17178 }, {
17179 element: options.cursorHandToolButton,
17180 eventName: "switchcursortool",
17181 eventDetails: {
17182 tool: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND
17183 },
17184 close: true
17185 }, {
17186 element: options.scrollPageButton,
17187 eventName: "switchscrollmode",
17188 eventDetails: {
17189 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE
17190 },
17191 close: true
17192 }, {
17193 element: options.scrollVerticalButton,
17194 eventName: "switchscrollmode",
17195 eventDetails: {
17196 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL
17197 },
17198 close: true
17199 }, {
17200 element: options.scrollHorizontalButton,
17201 eventName: "switchscrollmode",
17202 eventDetails: {
17203 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL
17204 },
17205 close: true
17206 }, {
17207 element: options.scrollWrappedButton,
17208 eventName: "switchscrollmode",
17209 eventDetails: {
17210 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.WRAPPED
17211 },
17212 close: true
17213 }, {
17214 element: options.spreadNoneButton,
17215 eventName: "switchspreadmode",
17216 eventDetails: {
17217 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE
17218 },
17219 close: true
17220 }, {
17221 element: options.spreadOddButton,
17222 eventName: "switchspreadmode",
17223 eventDetails: {
17224 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.ODD
17225 },
17226 close: true
17227 }, {
17228 element: options.spreadEvenButton,
17229 eventName: "switchspreadmode",
17230 eventDetails: {
17231 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.EVEN
17232 },
17233 close: true
17234 }, {
17235 element: options.documentPropertiesButton,
17236 eventName: "documentproperties",
17237 close: true
17238 }];
17239 buttons.push({
17240 element: options.openFileButton,
17241 eventName: "openfile",
17242 close: true
17243 });
17244 this.eventBus = eventBus;
17245 this.opened = false;
17246 this.#bindListeners(buttons);
17247 this.reset();
17248 }
17249 get isOpen() {
17250 return this.opened;
17251 }
17252 setPageNumber(pageNumber) {
17253 this.pageNumber = pageNumber;
17254 this.#updateUIState();
17255 }
17256 setPagesCount(pagesCount) {
17257 this.pagesCount = pagesCount;
17258 this.#updateUIState();
17259 }
17260 reset() {
17261 this.pageNumber = 0;
17262 this.pagesCount = 0;
17263 this.#updateUIState();
17264 this.eventBus.dispatch("switchcursortool", {
17265 source: this,
17266 reset: true
17267 });
17268 this.#scrollModeChanged({
17269 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL
17270 });
17271 this.#spreadModeChanged({
17272 mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE
17273 });
17274 }
17275 #updateUIState() {
17276 const {
17277 firstPageButton,
17278 lastPageButton,
17279 pageRotateCwButton,
17280 pageRotateCcwButton
17281 } = this.#opts;
17282 firstPageButton.disabled = this.pageNumber <= 1;
17283 lastPageButton.disabled = this.pageNumber >= this.pagesCount;
17284 pageRotateCwButton.disabled = this.pagesCount === 0;
17285 pageRotateCcwButton.disabled = this.pagesCount === 0;
17286 }
17287 #bindListeners(buttons) {
17288 const {
17289 eventBus
17290 } = this;
17291 const {
17292 toggleButton
17293 } = this.#opts;
17294 toggleButton.addEventListener("click", this.toggle.bind(this));
17295 for (const {
17296 element,
17297 eventName,
17298 close,
17299 eventDetails
17300 } of buttons) {
17301 element.addEventListener("click", evt => {
17302 if (eventName !== null) {
17303 eventBus.dispatch(eventName, {
17304 source: this,
17305 ...eventDetails
17306 });
17307 }
17308 if (close) {
17309 this.close();
17310 }
17311 eventBus.dispatch("reporttelemetry", {
17312 source: this,
17313 details: {
17314 type: "buttons",
17315 data: {
17316 id: element.id
17317 }
17318 }
17319 });
17320 });
17321 }
17322 eventBus._on("cursortoolchanged", this.#cursorToolChanged.bind(this));
17323 eventBus._on("scrollmodechanged", this.#scrollModeChanged.bind(this));
17324 eventBus._on("spreadmodechanged", this.#spreadModeChanged.bind(this));
17325 }
17326 #cursorToolChanged({
17327 tool
17328 }) {
17329 const {
17330 cursorSelectToolButton,
17331 cursorHandToolButton
17332 } = this.#opts;
17333 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(cursorSelectToolButton, tool === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT);
17334 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(cursorHandToolButton, tool === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND);
17335 }
17336 #scrollModeChanged({
17337 mode
17338 }) {
17339 const {
17340 scrollPageButton,
17341 scrollVerticalButton,
17342 scrollHorizontalButton,
17343 scrollWrappedButton,
17344 spreadNoneButton,
17345 spreadOddButton,
17346 spreadEvenButton
17347 } = this.#opts;
17348 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollPageButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE);
17349 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollVerticalButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL);
17350 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollHorizontalButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL);
17351 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollWrappedButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.WRAPPED);
17352 const forceScrollModePage = this.pagesCount > _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
17353 scrollPageButton.disabled = forceScrollModePage;
17354 scrollVerticalButton.disabled = forceScrollModePage;
17355 scrollHorizontalButton.disabled = forceScrollModePage;
17356 scrollWrappedButton.disabled = forceScrollModePage;
17357 const isHorizontal = mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL;
17358 spreadNoneButton.disabled = isHorizontal;
17359 spreadOddButton.disabled = isHorizontal;
17360 spreadEvenButton.disabled = isHorizontal;
17361 }
17362 #spreadModeChanged({
17363 mode
17364 }) {
17365 const {
17366 spreadNoneButton,
17367 spreadOddButton,
17368 spreadEvenButton
17369 } = this.#opts;
17370 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadNoneButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE);
17371 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadOddButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.ODD);
17372 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadEvenButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.EVEN);
17373 }
17374 open() {
17375 if (this.opened) {
17376 return;
17377 }
17378 this.opened = true;
17379 const {
17380 toggleButton,
17381 toolbar
17382 } = this.#opts;
17383 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(toggleButton, true, toolbar);
17384 }
17385 close() {
17386 if (!this.opened) {
17387 return;
17388 }
17389 this.opened = false;
17390 const {
17391 toggleButton,
17392 toolbar
17393 } = this.#opts;
17394 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(toggleButton, false, toolbar);
17395 }
17396 toggle() {
17397 if (this.opened) {
17398 this.close();
17399 } else {
17400 this.open();
17401 }
17402 }
17403}
17404
17405__webpack_async_result__();
17406} catch(e) { __webpack_async_result__(e); } });
17407
17408/***/ }),
17409
17410/***/ 6698:
17411/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
17412
17413/* harmony export */ __webpack_require__.d(__webpack_exports__, {
17414/* harmony export */ StructTreeLayerBuilder: () => (/* binding */ StructTreeLayerBuilder)
17415/* harmony export */ });
17416/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
17417
17418const PDF_ROLE_TO_HTML_ROLE = {
17419 Document: null,
17420 DocumentFragment: null,
17421 Part: "group",
17422 Sect: "group",
17423 Div: "group",
17424 Aside: "note",
17425 NonStruct: "none",
17426 P: null,
17427 H: "heading",
17428 Title: null,
17429 FENote: "note",
17430 Sub: "group",
17431 Lbl: null,
17432 Span: null,
17433 Em: null,
17434 Strong: null,
17435 Link: "link",
17436 Annot: "note",
17437 Form: "form",
17438 Ruby: null,
17439 RB: null,
17440 RT: null,
17441 RP: null,
17442 Warichu: null,
17443 WT: null,
17444 WP: null,
17445 L: "list",
17446 LI: "listitem",
17447 LBody: null,
17448 Table: "table",
17449 TR: "row",
17450 TH: "columnheader",
17451 TD: "cell",
17452 THead: "columnheader",
17453 TBody: null,
17454 TFoot: null,
17455 Caption: null,
17456 Figure: "figure",
17457 Formula: null,
17458 Artifact: null
17459};
17460const HEADING_PATTERN = /^H(\d+)$/;
17461class StructTreeLayerBuilder {
17462 #treeDom = undefined;
17463 get renderingDone() {
17464 return this.#treeDom !== undefined;
17465 }
17466 render(structTree) {
17467 if (this.#treeDom !== undefined) {
17468 return this.#treeDom;
17469 }
17470 const treeDom = this.#walk(structTree);
17471 treeDom?.classList.add("structTree");
17472 return this.#treeDom = treeDom;
17473 }
17474 hide() {
17475 if (this.#treeDom && !this.#treeDom.hidden) {
17476 this.#treeDom.hidden = true;
17477 }
17478 }
17479 show() {
17480 if (this.#treeDom?.hidden) {
17481 this.#treeDom.hidden = false;
17482 }
17483 }
17484 #setAttributes(structElement, htmlElement) {
17485 const {
17486 alt,
17487 id,
17488 lang
17489 } = structElement;
17490 if (alt !== undefined) {
17491 htmlElement.setAttribute("aria-label", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(alt));
17492 }
17493 if (id !== undefined) {
17494 htmlElement.setAttribute("aria-owns", id);
17495 }
17496 if (lang !== undefined) {
17497 htmlElement.setAttribute("lang", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(lang, true));
17498 }
17499 }
17500 #walk(node) {
17501 if (!node) {
17502 return null;
17503 }
17504 const element = document.createElement("span");
17505 if ("role" in node) {
17506 const {
17507 role
17508 } = node;
17509 const match = role.match(HEADING_PATTERN);
17510 if (match) {
17511 element.setAttribute("role", "heading");
17512 element.setAttribute("aria-level", match[1]);
17513 } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
17514 element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
17515 }
17516 }
17517 this.#setAttributes(node, element);
17518 if (node.children) {
17519 if (node.children.length === 1 && "id" in node.children[0]) {
17520 this.#setAttributes(node.children[0], element);
17521 } else {
17522 for (const kid of node.children) {
17523 element.append(this.#walk(kid));
17524 }
17525 }
17526 }
17527 return element;
17528 }
17529}
17530
17531
17532/***/ }),
17533
17534/***/ 5860:
17535/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
17536
17537/* harmony export */ __webpack_require__.d(__webpack_exports__, {
17538/* harmony export */ TextAccessibilityManager: () => (/* binding */ TextAccessibilityManager)
17539/* harmony export */ });
17540/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
17541
17542class TextAccessibilityManager {
17543 #enabled = false;
17544 #textChildren = null;
17545 #textNodes = new Map();
17546 #waitingElements = new Map();
17547 setTextMapping(textDivs) {
17548 this.#textChildren = textDivs;
17549 }
17550 static #compareElementPositions(e1, e2) {
17551 const rect1 = e1.getBoundingClientRect();
17552 const rect2 = e2.getBoundingClientRect();
17553 if (rect1.width === 0 && rect1.height === 0) {
17554 return +1;
17555 }
17556 if (rect2.width === 0 && rect2.height === 0) {
17557 return -1;
17558 }
17559 const top1 = rect1.y;
17560 const bot1 = rect1.y + rect1.height;
17561 const mid1 = rect1.y + rect1.height / 2;
17562 const top2 = rect2.y;
17563 const bot2 = rect2.y + rect2.height;
17564 const mid2 = rect2.y + rect2.height / 2;
17565 if (mid1 <= top2 && mid2 >= bot1) {
17566 return -1;
17567 }
17568 if (mid2 <= top1 && mid1 >= bot2) {
17569 return +1;
17570 }
17571 const centerX1 = rect1.x + rect1.width / 2;
17572 const centerX2 = rect2.x + rect2.width / 2;
17573 return centerX1 - centerX2;
17574 }
17575 enable() {
17576 if (this.#enabled) {
17577 throw new Error("TextAccessibilityManager is already enabled.");
17578 }
17579 if (!this.#textChildren) {
17580 throw new Error("Text divs and strings have not been set.");
17581 }
17582 this.#enabled = true;
17583 this.#textChildren = this.#textChildren.slice();
17584 this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions);
17585 if (this.#textNodes.size > 0) {
17586 const textChildren = this.#textChildren;
17587 for (const [id, nodeIndex] of this.#textNodes) {
17588 const element = document.getElementById(id);
17589 if (!element) {
17590 this.#textNodes.delete(id);
17591 continue;
17592 }
17593 this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
17594 }
17595 }
17596 for (const [element, isRemovable] of this.#waitingElements) {
17597 this.addPointerInTextLayer(element, isRemovable);
17598 }
17599 this.#waitingElements.clear();
17600 }
17601 disable() {
17602 if (!this.#enabled) {
17603 return;
17604 }
17605 this.#waitingElements.clear();
17606 this.#textChildren = null;
17607 this.#enabled = false;
17608 }
17609 removePointerInTextLayer(element) {
17610 if (!this.#enabled) {
17611 this.#waitingElements.delete(element);
17612 return;
17613 }
17614 const children = this.#textChildren;
17615 if (!children || children.length === 0) {
17616 return;
17617 }
17618 const {
17619 id
17620 } = element;
17621 const nodeIndex = this.#textNodes.get(id);
17622 if (nodeIndex === undefined) {
17623 return;
17624 }
17625 const node = children[nodeIndex];
17626 this.#textNodes.delete(id);
17627 let owns = node.getAttribute("aria-owns");
17628 if (owns?.includes(id)) {
17629 owns = owns.split(" ").filter(x => x !== id).join(" ");
17630 if (owns) {
17631 node.setAttribute("aria-owns", owns);
17632 } else {
17633 node.removeAttribute("aria-owns");
17634 node.setAttribute("role", "presentation");
17635 }
17636 }
17637 }
17638 #addIdToAriaOwns(id, node) {
17639 const owns = node.getAttribute("aria-owns");
17640 if (!owns?.includes(id)) {
17641 node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
17642 }
17643 node.removeAttribute("role");
17644 }
17645 addPointerInTextLayer(element, isRemovable) {
17646 const {
17647 id
17648 } = element;
17649 if (!id) {
17650 return null;
17651 }
17652 if (!this.#enabled) {
17653 this.#waitingElements.set(element, isRemovable);
17654 return null;
17655 }
17656 if (isRemovable) {
17657 this.removePointerInTextLayer(element);
17658 }
17659 const children = this.#textChildren;
17660 if (!children || children.length === 0) {
17661 return null;
17662 }
17663 const index = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
17664 const nodeIndex = Math.max(0, index - 1);
17665 const child = children[nodeIndex];
17666 this.#addIdToAriaOwns(id, child);
17667 this.#textNodes.set(id, nodeIndex);
17668 const parent = child.parentNode;
17669 return parent?.classList.contains("markedContent") ? parent.id : null;
17670 }
17671 moveElementInDOM(container, element, contentElement, isRemovable) {
17672 const id = this.addPointerInTextLayer(contentElement, isRemovable);
17673 if (!container.hasChildNodes()) {
17674 container.append(element);
17675 return id;
17676 }
17677 const children = Array.from(container.childNodes).filter(node => node !== element);
17678 if (children.length === 0) {
17679 return id;
17680 }
17681 const elementToCompare = contentElement || element;
17682 const index = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
17683 if (index === 0) {
17684 children[0].before(element);
17685 } else {
17686 children[index - 1].after(element);
17687 }
17688 return id;
17689 }
17690}
17691
17692
17693/***/ }),
17694
17695/***/ 2027:
17696/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
17697
17698/* harmony export */ __webpack_require__.d(__webpack_exports__, {
17699/* harmony export */ TextHighlighter: () => (/* binding */ TextHighlighter)
17700/* harmony export */ });
17701class TextHighlighter {
17702 #eventAbortController = null;
17703 constructor({
17704 findController,
17705 eventBus,
17706 pageIndex
17707 }) {
17708 this.findController = findController;
17709 this.matches = [];
17710 this.eventBus = eventBus;
17711 this.pageIdx = pageIndex;
17712 this.textDivs = null;
17713 this.textContentItemsStr = null;
17714 this.enabled = false;
17715 }
17716 setTextMapping(divs, texts) {
17717 this.textDivs = divs;
17718 this.textContentItemsStr = texts;
17719 }
17720 enable() {
17721 if (!this.textDivs || !this.textContentItemsStr) {
17722 throw new Error("Text divs and strings have not been set.");
17723 }
17724 if (this.enabled) {
17725 return;
17726 }
17727 this.enabled = true;
17728 if (!this.#eventAbortController) {
17729 this.#eventAbortController = new AbortController();
17730 this.eventBus._on("updatetextlayermatches", evt => {
17731 if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
17732 this._updateMatches();
17733 }
17734 }, {
17735 signal: this.#eventAbortController.signal
17736 });
17737 }
17738 this._updateMatches();
17739 }
17740 disable() {
17741 if (!this.enabled) {
17742 return;
17743 }
17744 this.enabled = false;
17745 this.#eventAbortController?.abort();
17746 this.#eventAbortController = null;
17747 this._updateMatches(true);
17748 }
17749 _convertMatches(matches, matchesLength) {
17750 if (!matches) {
17751 return [];
17752 }
17753 const {
17754 textContentItemsStr
17755 } = this;
17756 let i = 0,
17757 iIndex = 0;
17758 const end = textContentItemsStr.length - 1;
17759 const result = [];
17760 for (let m = 0, mm = matches.length; m < mm; m++) {
17761 let matchIdx = matches[m];
17762 while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
17763 iIndex += textContentItemsStr[i].length;
17764 i++;
17765 }
17766 if (i === textContentItemsStr.length) {
17767 globalThis.ngxConsole.error("Could not find a matching mapping");
17768 }
17769 const match = {
17770 begin: {
17771 divIdx: i,
17772 offset: matchIdx - iIndex
17773 }
17774 };
17775 matchIdx += matchesLength[m];
17776 while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
17777 iIndex += textContentItemsStr[i].length;
17778 i++;
17779 }
17780 match.end = {
17781 divIdx: i,
17782 offset: matchIdx - iIndex
17783 };
17784 result.push(match);
17785 }
17786 return result;
17787 }
17788 _renderMatches(matches) {
17789 if (matches.length === 0) {
17790 return;
17791 }
17792 const {
17793 findController,
17794 pageIdx
17795 } = this;
17796 const {
17797 textContentItemsStr,
17798 textDivs
17799 } = this;
17800 const isSelectedPage = pageIdx === findController.selected.pageIdx;
17801 const selectedMatchIdx = findController.selected.matchIdx;
17802 const highlightAll = findController.state.highlightAll;
17803 let prevEnd = null;
17804 const infinity = {
17805 divIdx: -1,
17806 offset: undefined
17807 };
17808 function beginText(begin, className) {
17809 const divIdx = begin.divIdx;
17810 textDivs[divIdx].textContent = "";
17811 return appendTextToDiv(divIdx, 0, begin.offset, className);
17812 }
17813 function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
17814 let div = textDivs[divIdx];
17815 if (div.nodeType === Node.TEXT_NODE) {
17816 const span = document.createElement("span");
17817 div.before(span);
17818 span.append(div);
17819 textDivs[divIdx] = span;
17820 div = span;
17821 }
17822 const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
17823 const node = document.createTextNode(content);
17824 if (className) {
17825 const span = document.createElement("span");
17826 span.className = `${className} appended`;
17827 span.append(node);
17828 div.append(span);
17829 return className.includes("selected") ? span.offsetLeft : 0;
17830 }
17831 div.append(node);
17832 return 0;
17833 }
17834 let i0 = selectedMatchIdx,
17835 i1 = i0 + 1;
17836 if (highlightAll) {
17837 i0 = 0;
17838 i1 = matches.length;
17839 } else if (!isSelectedPage) {
17840 return;
17841 }
17842 let lastDivIdx = -1;
17843 let lastOffset = -1;
17844 for (let i = i0; i < i1; i++) {
17845 const match = matches[i];
17846 const begin = match.begin;
17847 if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) {
17848 continue;
17849 }
17850 lastDivIdx = begin.divIdx;
17851 lastOffset = begin.offset;
17852 const end = match.end;
17853 const isSelected = isSelectedPage && i === selectedMatchIdx;
17854 const highlightSuffix = isSelected ? " selected" : "";
17855 let selectedLeft = 0;
17856 if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
17857 if (prevEnd !== null) {
17858 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
17859 }
17860 beginText(begin);
17861 } else {
17862 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
17863 }
17864 if (begin.divIdx === end.divIdx) {
17865 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
17866 } else {
17867 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
17868 for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
17869 textDivs[n0].className = "highlight middle" + highlightSuffix;
17870 }
17871 beginText(end, "highlight end" + highlightSuffix);
17872 }
17873 prevEnd = end;
17874 if (isSelected) {
17875 findController.scrollMatchIntoView({
17876 element: textDivs[begin.divIdx],
17877 selectedLeft,
17878 pageIndex: pageIdx,
17879 matchIndex: selectedMatchIdx
17880 });
17881 }
17882 }
17883 if (prevEnd) {
17884 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
17885 }
17886 }
17887 _updateMatches(reset = false) {
17888 if (!this.enabled && !reset) {
17889 return;
17890 }
17891 const {
17892 findController,
17893 matches,
17894 pageIdx
17895 } = this;
17896 const {
17897 textContentItemsStr,
17898 textDivs
17899 } = this;
17900 let clearedUntilDivIdx = -1;
17901 for (const match of matches) {
17902 const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
17903 for (let n = begin, end = match.end.divIdx; n <= end; n++) {
17904 const div = textDivs[n];
17905 div.textContent = textContentItemsStr[n];
17906 div.className = "";
17907 }
17908 clearedUntilDivIdx = match.end.divIdx + 1;
17909 }
17910 if (!findController?.highlightMatches || reset) {
17911 return;
17912 }
17913 const pageMatches = findController.pageMatches[pageIdx] || null;
17914 const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
17915 this.matches = this._convertMatches(pageMatches, pageMatchesLength);
17916 this._renderMatches(this.matches);
17917 }
17918}
17919
17920
17921/***/ }),
17922
17923/***/ 7765:
17924/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
17925
17926__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
17927/* harmony export */ __webpack_require__.d(__webpack_exports__, {
17928/* harmony export */ TextLayerBuilder: () => (/* binding */ TextLayerBuilder)
17929/* harmony export */ });
17930/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
17931/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
17932var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
17933pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
17934
17935
17936class TextLayerBuilder {
17937 #enablePermissions = false;
17938 #onAppend = null;
17939 #rotation = 0;
17940 #scale = 0;
17941 #textContentSource = null;
17942 constructor({
17943 highlighter = null,
17944 accessibilityManager = null,
17945 enablePermissions = false,
17946 onAppend = null
17947 }) {
17948 this.textContentItemsStr = [];
17949 this.renderingDone = false;
17950 this.textDivs = [];
17951 this.textDivProperties = new WeakMap();
17952 this.textLayerRenderTask = null;
17953 this.highlighter = highlighter;
17954 this.accessibilityManager = accessibilityManager;
17955 this.#enablePermissions = enablePermissions === true;
17956 this.#onAppend = onAppend;
17957 this.div = document.createElement("div");
17958 this.div.tabIndex = 0;
17959 this.div.className = "textLayer";
17960 }
17961 #finishRendering() {
17962 this.renderingDone = true;
17963 const endOfContent = document.createElement("div");
17964 endOfContent.className = "endOfContent";
17965 this.div.append(endOfContent);
17966 this.#bindMouse();
17967 }
17968 get numTextDivs() {
17969 return this.textDivs.length;
17970 }
17971 async render(viewport) {
17972 if (!this.#textContentSource) {
17973 throw new Error('No "textContentSource" parameter specified.');
17974 }
17975 const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
17976 const {
17977 rotation
17978 } = viewport;
17979 if (this.renderingDone) {
17980 const mustRotate = rotation !== this.#rotation;
17981 const mustRescale = scale !== this.#scale;
17982 if (mustRotate || mustRescale) {
17983 this.hide();
17984 (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.updateTextLayer)({
17985 container: this.div,
17986 viewport,
17987 textDivs: this.textDivs,
17988 textDivProperties: this.textDivProperties,
17989 mustRescale,
17990 mustRotate
17991 });
17992 this.#scale = scale;
17993 this.#rotation = rotation;
17994 }
17995 this.show();
17996 return;
17997 }
17998 this.cancel();
17999 this.highlighter?.setTextMapping(this.textDivs, this.textContentItemsStr);
18000 this.accessibilityManager?.setTextMapping(this.textDivs);
18001 this.textLayerRenderTask = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.renderTextLayer)({
18002 textContentSource: this.#textContentSource,
18003 container: this.div,
18004 viewport,
18005 textDivs: this.textDivs,
18006 textDivProperties: this.textDivProperties,
18007 textContentItemsStr: this.textContentItemsStr
18008 });
18009 await this.textLayerRenderTask.promise;
18010 this.#finishRendering();
18011 this.#scale = scale;
18012 this.#rotation = rotation;
18013 this.#onAppend?.(this.div);
18014 this.highlighter?.enable();
18015 this.accessibilityManager?.enable();
18016 }
18017 hide() {
18018 if (!this.div.hidden && this.renderingDone) {
18019 this.highlighter?.disable();
18020 this.div.hidden = true;
18021 }
18022 }
18023 show() {
18024 if (this.div.hidden && this.renderingDone) {
18025 this.div.hidden = false;
18026 this.highlighter?.enable();
18027 }
18028 }
18029 cancel() {
18030 if (this.textLayerRenderTask) {
18031 this.textLayerRenderTask.cancel();
18032 this.textLayerRenderTask = null;
18033 }
18034 this.highlighter?.disable();
18035 this.accessibilityManager?.disable();
18036 this.textContentItemsStr.length = 0;
18037 this.textDivs.length = 0;
18038 this.textDivProperties = new WeakMap();
18039 }
18040 setTextContentSource(source) {
18041 this.cancel();
18042 this.#textContentSource = source;
18043 }
18044 #bindMouse() {
18045 const {
18046 div
18047 } = this;
18048 div.addEventListener("mousedown", evt => {
18049 const end = div.querySelector(".endOfContent");
18050 if (!end) {
18051 return;
18052 }
18053 let adjustTop = evt.target !== div;
18054 adjustTop &&= getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
18055 if (adjustTop) {
18056 const divBounds = div.getBoundingClientRect();
18057 const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
18058 end.style.top = (r * 100).toFixed(2) + "%";
18059 }
18060 end.classList.add("active");
18061 });
18062 div.addEventListener("mouseup", () => {
18063 const end = div.querySelector(".endOfContent");
18064 if (!end) {
18065 return;
18066 }
18067 end.style.top = "";
18068 end.classList.remove("active");
18069 });
18070 div.addEventListener("copy", event => {
18071 if (!this.#enablePermissions) {
18072 const selection = document.getSelection();
18073 event.clipboardData.setData("text/plain", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.removeNullCharacters)((0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.normalizeUnicode)(selection.toString())));
18074 }
18075 event.preventDefault();
18076 event.stopPropagation();
18077 });
18078 }
18079}
18080
18081__webpack_async_result__();
18082} catch(e) { __webpack_async_result__(e); } });
18083
18084/***/ }),
18085
18086/***/ 6297:
18087/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
18088
18089__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
18090/* harmony export */ __webpack_require__.d(__webpack_exports__, {
18091/* harmony export */ Toolbar: () => (/* binding */ Toolbar)
18092/* harmony export */ });
18093/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
18094/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
18095var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
18096pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
18097
18098
18099class Toolbar {
18100 #opts;
18101 constructor(options, eventBus) {
18102 this.#opts = options;
18103 this.eventBus = eventBus;
18104 const buttons = [{
18105 element: options.previous,
18106 eventName: "previouspage"
18107 }, {
18108 element: options.next,
18109 eventName: "nextpage"
18110 }, {
18111 element: options.zoomIn,
18112 eventName: "zoomin"
18113 }, {
18114 element: options.zoomOut,
18115 eventName: "zoomout"
18116 }, {
18117 element: options.print,
18118 eventName: "print"
18119 }, {
18120 element: options.presentationModeButton,
18121 eventName: "presentationmode"
18122 }, {
18123 element: options.download,
18124 eventName: "download"
18125 }, {
18126 element: options.editorFreeTextButton,
18127 eventName: "switchannotationeditormode",
18128 eventDetails: {
18129 get mode() {
18130 const {
18131 classList
18132 } = options.editorFreeTextButton;
18133 return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.FREETEXT;
18134 }
18135 }
18136 }, {
18137 element: options.editorHighlightButton,
18138 eventName: "switchannotationeditormode",
18139 eventDetails: {
18140 get mode() {
18141 const {
18142 classList
18143 } = options.editorHighlightButton;
18144 return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT;
18145 }
18146 }
18147 }, {
18148 element: options.editorInkButton,
18149 eventName: "switchannotationeditormode",
18150 eventDetails: {
18151 get mode() {
18152 const {
18153 classList
18154 } = options.editorInkButton;
18155 return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.INK;
18156 }
18157 }
18158 }, {
18159 element: options.editorStampButton,
18160 eventName: "switchannotationeditormode",
18161 eventDetails: {
18162 get mode() {
18163 const {
18164 classList
18165 } = options.editorStampButton;
18166 return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.STAMP;
18167 }
18168 }
18169 }];
18170 this.#bindListeners(buttons);
18171 if (options.editorHighlightColorPicker) {
18172 eventBus._on("annotationeditoruimanager", ({
18173 uiManager
18174 }) => {
18175 this.#setAnnotationEditorUIManager(uiManager, options.editorHighlightColorPicker);
18176 }, {
18177 once: true
18178 });
18179 }
18180 eventBus._on("showannotationeditorui", ({
18181 mode
18182 }) => {
18183 switch (mode) {
18184 case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT:
18185 options.editorHighlightButton.click();
18186 break;
18187 }
18188 });
18189 this.reset();
18190 }
18191 #setAnnotationEditorUIManager(uiManager, parentContainer) {
18192 const colorPicker = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.ColorPicker({
18193 uiManager
18194 });
18195 uiManager.setMainHighlightColorPicker(colorPicker);
18196 parentContainer.append(colorPicker.renderMainDropdown());
18197 }
18198 setPageNumber(pageNumber, pageLabel) {
18199 this.pageNumber = pageNumber;
18200 this.pageLabel = pageLabel;
18201 this.#updateUIState(false);
18202 }
18203 setPagesCount(pagesCount, hasPageLabels) {
18204 this.pagesCount = pagesCount;
18205 this.hasPageLabels = hasPageLabels;
18206 this.#updateUIState(true);
18207 }
18208 setPageScale(pageScaleValue, pageScale) {
18209 this.pageScaleValue = (pageScaleValue || pageScale).toString();
18210 this.pageScale = pageScale;
18211 this.#updateUIState(false);
18212 }
18213 reset() {
18214 this.pageNumber = 0;
18215 this.pageLabel = null;
18216 this.hasPageLabels = false;
18217 this.pagesCount = 0;
18218 const defaultZoomOption = PDFViewerApplicationOptions.get('defaultZoomValue');
18219 if (defaultZoomOption) {
18220 this.pageScaleValue = defaultZoomOption;
18221 if (!!Number(defaultZoomOption)) {
18222 this.pageScale = Number(defaultZoomOption);
18223 }
18224 } else {
18225 this.pageScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_VALUE;
18226 this.pageScale = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
18227 }
18228 this.#updateUIState(true);
18229 this.updateLoadingIndicatorState();
18230 this.#editorModeChanged({
18231 mode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE
18232 });
18233 }
18234 #bindListeners(buttons) {
18235 const {
18236 eventBus
18237 } = this;
18238 const {
18239 pageNumber,
18240 scaleSelect
18241 } = this.#opts;
18242 const self = this;
18243 for (const {
18244 element,
18245 eventName,
18246 eventDetails
18247 } of buttons) {
18248 element.addEventListener("click", evt => {
18249 if (eventName !== null) {
18250 eventBus.dispatch(eventName, {
18251 source: this,
18252 ...eventDetails,
18253 isFromKeyboard: evt.detail === 0
18254 });
18255 }
18256 });
18257 }
18258 pageNumber.addEventListener("click", function () {
18259 this.select();
18260 });
18261 pageNumber.addEventListener("change", function () {
18262 eventBus.dispatch("pagenumberchanged", {
18263 source: self,
18264 value: this.value
18265 });
18266 });
18267 scaleSelect.addEventListener("change", function () {
18268 if (this.value === "custom") {
18269 return;
18270 }
18271 eventBus.dispatch("scalechanged", {
18272 source: self,
18273 value: this.value
18274 });
18275 });
18276 scaleSelect.addEventListener("click", function ({
18277 target
18278 }) {
18279 if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
18280 this.blur();
18281 }
18282 });
18283 scaleSelect.oncontextmenu = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.noContextMenu;
18284 eventBus._on("annotationeditormodechanged", this.#editorModeChanged.bind(this));
18285 }
18286 #editorModeChanged({
18287 mode
18288 }) {
18289 const {
18290 editorFreeTextButton,
18291 editorFreeTextParamsToolbar,
18292 editorHighlightButton,
18293 editorHighlightParamsToolbar,
18294 editorInkButton,
18295 editorInkParamsToolbar,
18296 editorStampButton,
18297 editorStampParamsToolbar
18298 } = this.#opts;
18299 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorFreeTextButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar);
18300 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorHighlightButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT, editorHighlightParamsToolbar);
18301 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorInkButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.INK, editorInkParamsToolbar);
18302 (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorStampButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.STAMP, editorStampParamsToolbar);
18303 const isDisable = mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
18304 editorFreeTextButton.disabled = isDisable;
18305 editorHighlightButton.disabled = isDisable;
18306 editorInkButton.disabled = isDisable;
18307 editorStampButton.disabled = isDisable;
18308 }
18309 #updateUIState(resetNumPages = false) {
18310 const {
18311 pageNumber,
18312 pagesCount,
18313 pageScaleValue,
18314 pageScale
18315 } = this;
18316 const opts = this.#opts;
18317 if (resetNumPages) {
18318 if (this.hasPageLabels) {
18319 opts.pageNumber.type = "text";
18320 opts.numPages.setAttribute("data-l10n-id", "pdfjs-page-of-pages");
18321 } else {
18322 opts.pageNumber.type = "number";
18323 opts.numPages.setAttribute("data-l10n-id", "pdfjs-of-pages");
18324 opts.numPages.setAttribute("data-l10n-args", JSON.stringify({
18325 pagesCount
18326 }));
18327 }
18328 opts.pageNumber.max = pagesCount;
18329 }
18330 if (this.hasPageLabels) {
18331 opts.pageNumber.value = this.pageLabel;
18332 opts.numPages.setAttribute("data-l10n-args", JSON.stringify({
18333 pageNumber,
18334 pagesCount
18335 }));
18336 } else {
18337 opts.pageNumber.value = pageNumber;
18338 }
18339 opts.previous.disabled = pageNumber <= 1;
18340 opts.next.disabled = pageNumber >= pagesCount;
18341 opts.zoomOut.disabled = pageScale <= _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE;
18342 opts.zoomIn.disabled = pageScale >= _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE;
18343 let predefinedValueFound = false;
18344 if (opts.scaleSelect.options) {
18345 for (const option of opts.scaleSelect.options) {
18346 if (option.value !== pageScaleValue) {
18347 option.selected = false;
18348 continue;
18349 }
18350 option.selected = true;
18351 predefinedValueFound = true;
18352 }
18353 }
18354 if (!predefinedValueFound) {
18355 opts.customScaleOption.selected = true;
18356 opts.customScaleOption.setAttribute("data-l10n-args", JSON.stringify({
18357 scale: Math.round(pageScale * 10000) / 100
18358 }));
18359 }
18360 this.eventBus.dispatch("updateuistate", {
18361 source: this,
18362 widget: "Toolbar",
18363 pageNumber,
18364 pagesCount,
18365 pageScaleValue,
18366 pageScale
18367 });
18368 }
18369 updateLoadingIndicatorState(loading = false) {
18370 const {
18371 pageNumber
18372 } = this.#opts;
18373 pageNumber.classList.toggle("loading", loading);
18374 }
18375}
18376
18377__webpack_async_result__();
18378} catch(e) { __webpack_async_result__(e); } });
18379
18380/***/ }),
18381
18382/***/ 7256:
18383/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
18384
18385/* harmony export */ __webpack_require__.d(__webpack_exports__, {
18386/* harmony export */ AutoPrintRegExp: () => (/* binding */ AutoPrintRegExp),
18387/* harmony export */ CursorTool: () => (/* binding */ CursorTool),
18388/* harmony export */ DEFAULT_SCALE: () => (/* binding */ DEFAULT_SCALE),
18389/* harmony export */ DEFAULT_SCALE_DELTA: () => (/* binding */ DEFAULT_SCALE_DELTA),
18390/* harmony export */ DEFAULT_SCALE_VALUE: () => (/* binding */ DEFAULT_SCALE_VALUE),
18391/* harmony export */ MAX_AUTO_SCALE: () => (/* binding */ MAX_AUTO_SCALE),
18392/* harmony export */ MAX_SCALE: () => (/* binding */ MAX_SCALE),
18393/* harmony export */ MIN_SCALE: () => (/* binding */ MIN_SCALE),
18394/* harmony export */ OutputScale: () => (/* binding */ OutputScale),
18395/* harmony export */ PresentationModeState: () => (/* binding */ PresentationModeState),
18396/* harmony export */ ProgressBar: () => (/* binding */ ProgressBar),
18397/* harmony export */ RenderingStates: () => (/* binding */ RenderingStates),
18398/* harmony export */ SCROLLBAR_PADDING: () => (/* binding */ SCROLLBAR_PADDING),
18399/* harmony export */ ScrollMode: () => (/* binding */ ScrollMode),
18400/* harmony export */ SidebarView: () => (/* binding */ SidebarView),
18401/* harmony export */ SpreadMode: () => (/* binding */ SpreadMode),
18402/* harmony export */ TextLayerMode: () => (/* binding */ TextLayerMode),
18403/* harmony export */ UNKNOWN_SCALE: () => (/* binding */ UNKNOWN_SCALE),
18404/* harmony export */ VERTICAL_PADDING: () => (/* binding */ VERTICAL_PADDING),
18405/* harmony export */ animationStarted: () => (/* binding */ animationStarted),
18406/* harmony export */ apiPageLayoutToViewerModes: () => (/* binding */ apiPageLayoutToViewerModes),
18407/* harmony export */ apiPageModeToSidebarView: () => (/* binding */ apiPageModeToSidebarView),
18408/* harmony export */ approximateFraction: () => (/* binding */ approximateFraction),
18409/* harmony export */ binarySearchFirstItem: () => (/* binding */ binarySearchFirstItem),
18410/* harmony export */ docStyle: () => (/* binding */ docStyle),
18411/* harmony export */ getActiveOrFocusedElement: () => (/* binding */ getActiveOrFocusedElement),
18412/* harmony export */ getPageSizeInches: () => (/* binding */ getPageSizeInches),
18413/* harmony export */ getVisibleElements: () => (/* binding */ getVisibleElements),
18414/* harmony export */ isPortraitOrientation: () => (/* binding */ isPortraitOrientation),
18415/* harmony export */ isValidRotation: () => (/* binding */ isValidRotation),
18416/* harmony export */ isValidScrollMode: () => (/* binding */ isValidScrollMode),
18417/* harmony export */ isValidSpreadMode: () => (/* binding */ isValidSpreadMode),
18418/* harmony export */ normalizeWheelEventDelta: () => (/* binding */ normalizeWheelEventDelta),
18419/* harmony export */ normalizeWheelEventDirection: () => (/* binding */ normalizeWheelEventDirection),
18420/* harmony export */ parseQueryString: () => (/* binding */ parseQueryString),
18421/* harmony export */ removeNullCharacters: () => (/* binding */ removeNullCharacters),
18422/* harmony export */ roundToDivide: () => (/* binding */ roundToDivide),
18423/* harmony export */ scrollIntoView: () => (/* binding */ scrollIntoView),
18424/* harmony export */ toggleCheckedBtn: () => (/* binding */ toggleCheckedBtn),
18425/* harmony export */ toggleExpandedBtn: () => (/* binding */ toggleExpandedBtn),
18426/* harmony export */ watchScroll: () => (/* binding */ watchScroll)
18427/* harmony export */ });
18428/* unused harmony export backtrackBeforeAllVisibleElements */
18429const DEFAULT_SCALE_VALUE = "auto";
18430const DEFAULT_SCALE = 1.0;
18431const DEFAULT_SCALE_DELTA = 1.1;
18432const MIN_SCALE = 0.1;
18433const MAX_SCALE = 10.0;
18434const UNKNOWN_SCALE = 0;
18435const MAX_AUTO_SCALE = 1.25;
18436const SCROLLBAR_PADDING = 40;
18437const VERTICAL_PADDING = 5;
18438const RenderingStates = {
18439 INITIAL: 0,
18440 RUNNING: 1,
18441 PAUSED: 2,
18442 FINISHED: 3
18443};
18444const PresentationModeState = {
18445 UNKNOWN: 0,
18446 NORMAL: 1,
18447 CHANGING: 2,
18448 FULLSCREEN: 3
18449};
18450const SidebarView = {
18451 UNKNOWN: -1,
18452 NONE: 0,
18453 THUMBS: 1,
18454 OUTLINE: 2,
18455 ATTACHMENTS: 3,
18456 LAYERS: 4
18457};
18458const TextLayerMode = {
18459 DISABLE: 0,
18460 ENABLE: 1,
18461 ENABLE_PERMISSIONS: 2
18462};
18463const ScrollMode = {
18464 UNKNOWN: -1,
18465 VERTICAL: 0,
18466 HORIZONTAL: 1,
18467 WRAPPED: 2,
18468 PAGE: 3
18469};
18470const SpreadMode = {
18471 UNKNOWN: -1,
18472 NONE: 0,
18473 ODD: 1,
18474 EVEN: 2
18475};
18476const CursorTool = {
18477 SELECT: 0,
18478 HAND: 1,
18479 ZOOM: 2
18480};
18481const AutoPrintRegExp = /\bprint\s*\(/;
18482class OutputScale {
18483 constructor() {
18484 const pixelRatio = window.devicePixelRatio || 1;
18485 this.sx = pixelRatio;
18486 this.sy = pixelRatio;
18487 }
18488 get scaled() {
18489 return this.sx !== 1 || this.sy !== 1;
18490 }
18491}
18492function scrollIntoView(element, spot, scrollMatches = false, infiniteScroll = false) {
18493 if (element.classList.contains("stf__item") || element.parentElement?.classList.contains("stf__item") || element.parentElement?.parentElement?.classList.contains("stf__item")) {
18494 return;
18495 }
18496 let parent = element.offsetParent;
18497 if (!parent) {
18498 globalThis.ngxConsole.error("offsetParent is not set -- cannot scroll");
18499 return;
18500 }
18501 let offsetY = element.offsetTop + element.clientTop;
18502 let offsetX = element.offsetLeft + element.clientLeft;
18503 while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
18504 offsetY += parent.offsetTop;
18505 offsetX += parent.offsetLeft;
18506 parent = parent.offsetParent;
18507 if (!parent) {
18508 if (infiniteScroll) {
18509 if (document.body.clientHeight > offsetY) {
18510 offsetY -= 32;
18511 window.scrollTo(window.scrollX, offsetY);
18512 }
18513 }
18514 return;
18515 }
18516 }
18517 if (spot) {
18518 if (spot.top !== undefined) {
18519 offsetY += spot.top;
18520 }
18521 if (spot.left !== undefined) {
18522 offsetX += spot.left;
18523 parent.scrollLeft = offsetX;
18524 }
18525 } else if (isDivInViewport(element)) {
18526 return;
18527 }
18528 parent.scrollTop = offsetY;
18529}
18530function isDivInViewport(element) {
18531 const rect = element.getBoundingClientRect();
18532 return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
18533}
18534function watchScroll(viewAreaElement, callback) {
18535 const debounceScroll = function (evt) {
18536 if (rAF) {
18537 return;
18538 }
18539 rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
18540 rAF = null;
18541 const currentX = viewAreaElement.scrollLeft;
18542 const lastX = state.lastX;
18543 if (currentX !== lastX) {
18544 state.right = currentX > lastX;
18545 }
18546 state.lastX = currentX;
18547 const currentY = viewAreaElement.scrollTop;
18548 const lastY = state.lastY;
18549 if (currentY !== lastY) {
18550 state.down = currentY > lastY;
18551 }
18552 state.lastY = currentY;
18553 callback(state);
18554 });
18555 };
18556 const state = {
18557 right: true,
18558 down: true,
18559 lastX: viewAreaElement.scrollLeft,
18560 lastY: viewAreaElement.scrollTop,
18561 _eventHandler: debounceScroll
18562 };
18563 let rAF = null;
18564 viewAreaElement.addEventListener("scroll", debounceScroll, true);
18565 return state;
18566}
18567function parseQueryString(query) {
18568 const params = new Map();
18569 for (const [key, value] of new URLSearchParams(query)) {
18570 params.set(key.toLowerCase(), value);
18571 }
18572 return params;
18573}
18574const InvisibleCharsRegExp = /[\x00-\x1F]/g;
18575function removeNullCharacters(str, replaceInvisible = false) {
18576 if (!InvisibleCharsRegExp.test(str)) {
18577 return str;
18578 }
18579 if (replaceInvisible) {
18580 return str.replaceAll(InvisibleCharsRegExp, m => m === "\x00" ? "" : " ");
18581 }
18582 return str.replaceAll("\x00", "");
18583}
18584function binarySearchFirstItem(items, condition, start = 0) {
18585 let minIndex = start;
18586 let maxIndex = items.length - 1;
18587 if (maxIndex < 0 || !condition(items[maxIndex])) {
18588 return items.length;
18589 }
18590 if (condition(items[minIndex])) {
18591 return minIndex;
18592 }
18593 while (minIndex < maxIndex) {
18594 const currentIndex = minIndex + maxIndex >> 1;
18595 const currentItem = items[currentIndex];
18596 if (condition(currentItem)) {
18597 maxIndex = currentIndex;
18598 } else {
18599 minIndex = currentIndex + 1;
18600 }
18601 }
18602 return minIndex;
18603}
18604function approximateFraction(x) {
18605 if (Math.floor(x) === x) {
18606 return [x, 1];
18607 }
18608 const xinv = 1 / x;
18609 const limit = 8;
18610 if (xinv > limit) {
18611 return [1, limit];
18612 } else if (Math.floor(xinv) === xinv) {
18613 return [1, xinv];
18614 }
18615 const x_ = x > 1 ? xinv : x;
18616 let a = 0,
18617 b = 1,
18618 c = 1,
18619 d = 1;
18620 while (true) {
18621 const p = a + c,
18622 q = b + d;
18623 if (q > limit) {
18624 break;
18625 }
18626 if (x_ <= p / q) {
18627 c = p;
18628 d = q;
18629 } else {
18630 a = p;
18631 b = q;
18632 }
18633 }
18634 let result;
18635 if (x_ - a / b < c / d - x_) {
18636 result = x_ === x ? [a, b] : [b, a];
18637 } else {
18638 result = x_ === x ? [c, d] : [d, c];
18639 }
18640 return result;
18641}
18642function roundToDivide(x, div) {
18643 const r = x % div;
18644 return r === 0 ? x : Math.round(x - r + div);
18645}
18646function getPageSizeInches({
18647 view,
18648 userUnit,
18649 rotate
18650}) {
18651 const [x1, y1, x2, y2] = view;
18652 const changeOrientation = rotate % 180 !== 0;
18653 const width = (x2 - x1) / 72 * userUnit;
18654 const height = (y2 - y1) / 72 * userUnit;
18655 return {
18656 width: changeOrientation ? height : width,
18657 height: changeOrientation ? width : height
18658 };
18659}
18660function backtrackBeforeAllVisibleElements(index, views, top) {
18661 if (index < 2) {
18662 return index;
18663 }
18664 let elt = views[index].div;
18665 let pageTop = elt.offsetTop + elt.clientTop;
18666 if (pageTop >= top) {
18667 elt = views[index - 1].div;
18668 pageTop = elt.offsetTop + elt.clientTop;
18669 }
18670 for (let i = index - 2; i >= 0; --i) {
18671 elt = views[i].div;
18672 if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
18673 break;
18674 }
18675 index = i;
18676 }
18677 return index;
18678}
18679function getVisibleElements({
18680 scrollEl,
18681 views,
18682 sortByVisibility = false,
18683 horizontal = false,
18684 rtl = false
18685}) {
18686 const top = scrollEl.scrollTop,
18687 bottom = top + scrollEl.clientHeight;
18688 const left = scrollEl.scrollLeft,
18689 right = left + scrollEl.clientWidth;
18690 function isElementBottomAfterViewTop(view) {
18691 const element = view.div;
18692 const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
18693 return elementBottom > top;
18694 }
18695 function isElementNextAfterViewHorizontally(view) {
18696 const element = view.div;
18697 const elementLeft = element.offsetLeft + element.clientLeft;
18698 const elementRight = elementLeft + element.clientWidth;
18699 return rtl ? elementLeft < right : elementRight > left;
18700 }
18701 const visible = [],
18702 ids = new Set(),
18703 numViews = views.length;
18704 let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
18705 if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
18706 firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
18707 }
18708 let lastEdge = horizontal ? right : -1;
18709 for (let i = firstVisibleElementInd; i < numViews; i++) {
18710 const view = views[i],
18711 element = view.div;
18712 const currentWidth = element.offsetLeft + element.clientLeft;
18713 const currentHeight = element.offsetTop + element.clientTop;
18714 const viewWidth = element.clientWidth,
18715 viewHeight = element.clientHeight;
18716 const viewRight = currentWidth + viewWidth;
18717 const viewBottom = currentHeight + viewHeight;
18718 if (lastEdge === -1) {
18719 if (viewBottom >= bottom) {
18720 lastEdge = viewBottom;
18721 }
18722 } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
18723 break;
18724 }
18725 if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
18726 continue;
18727 }
18728 const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
18729 const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
18730 const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
18731 fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
18732 const percent = fractionHeight * fractionWidth * 100 | 0;
18733 visible.push({
18734 id: view.id,
18735 x: currentWidth,
18736 y: currentHeight,
18737 view,
18738 percent,
18739 widthPercent: fractionWidth * 100 | 0
18740 });
18741 ids.add(view.id);
18742 }
18743 const first = visible[0],
18744 last = visible.at(-1);
18745 if (sortByVisibility) {
18746 visible.sort(function (a, b) {
18747 const pc = a.percent - b.percent;
18748 if (Math.abs(pc) > 0.001) {
18749 return -pc;
18750 }
18751 return a.id - b.id;
18752 });
18753 }
18754 return {
18755 first,
18756 last,
18757 views: visible,
18758 ids
18759 };
18760}
18761function normalizeWheelEventDirection(evt) {
18762 let delta = Math.hypot(evt.deltaX, evt.deltaY);
18763 const angle = Math.atan2(evt.deltaY, evt.deltaX);
18764 if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
18765 delta = -delta;
18766 }
18767 return delta;
18768}
18769function normalizeWheelEventDelta(evt) {
18770 const deltaMode = evt.deltaMode;
18771 let delta = normalizeWheelEventDirection(evt);
18772 const MOUSE_PIXELS_PER_LINE = 30;
18773 const MOUSE_LINES_PER_PAGE = 30;
18774 if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
18775 delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
18776 } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
18777 delta /= MOUSE_LINES_PER_PAGE;
18778 }
18779 return delta;
18780}
18781function isValidRotation(angle) {
18782 return Number.isInteger(angle) && angle % 90 === 0;
18783}
18784function isValidScrollMode(mode) {
18785 return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
18786}
18787function isValidSpreadMode(mode) {
18788 return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
18789}
18790function isPortraitOrientation(size) {
18791 return size.width <= size.height;
18792}
18793const animationStarted = new Promise(function (resolve) {
18794 window.ngxZone.runOutsideAngular(() => {
18795 window.requestAnimationFrame(resolve);
18796 });
18797});
18798const docStyle = document.documentElement.style;
18799function clamp(v, min, max) {
18800 return Math.min(Math.max(v, min), max);
18801}
18802class ProgressBar {
18803 #classList = null;
18804 #disableAutoFetchTimeout = null;
18805 #percent = 0;
18806 #style = null;
18807 #visible = true;
18808 constructor(bar) {
18809 this.#classList = bar.classList;
18810 this.#style = bar.style;
18811 }
18812 get percent() {
18813 return this.#percent;
18814 }
18815 set percent(val) {
18816 this.#percent = clamp(val, 0, 100);
18817 if (isNaN(val)) {
18818 this.#classList.add("indeterminate");
18819 return;
18820 }
18821 this.#classList.remove("indeterminate");
18822 this.#style.setProperty("--progressBar-percent", `${this.#percent}%`);
18823 }
18824 setWidth(viewer) {
18825 if (!viewer) {
18826 return;
18827 }
18828 const container = viewer.parentNode;
18829 const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
18830 if (scrollbarWidth > 0) {
18831 this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
18832 }
18833 }
18834 setDisableAutoFetch(delay = 5000) {
18835 if (isNaN(this.#percent)) {
18836 return;
18837 }
18838 if (this.#disableAutoFetchTimeout) {
18839 clearTimeout(this.#disableAutoFetchTimeout);
18840 }
18841 this.show();
18842 this.#disableAutoFetchTimeout = setTimeout(() => {
18843 this.#disableAutoFetchTimeout = null;
18844 this.hide();
18845 }, delay);
18846 }
18847 hide() {
18848 if (!this.#visible) {
18849 return;
18850 }
18851 this.#visible = false;
18852 this.#classList.add("hidden");
18853 }
18854 show() {
18855 if (this.#visible) {
18856 return;
18857 }
18858 this.#visible = true;
18859 this.#classList.remove("hidden");
18860 }
18861}
18862function getActiveOrFocusedElement() {
18863 let curRoot = document;
18864 let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
18865 while (curActiveOrFocused?.shadowRoot) {
18866 curRoot = curActiveOrFocused.shadowRoot;
18867 curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
18868 }
18869 return curActiveOrFocused;
18870}
18871function apiPageLayoutToViewerModes(layout) {
18872 let scrollMode = ScrollMode.VERTICAL,
18873 spreadMode = SpreadMode.NONE;
18874 switch (layout) {
18875 case "SinglePage":
18876 scrollMode = ScrollMode.PAGE;
18877 break;
18878 case "OneColumn":
18879 break;
18880 case "TwoPageLeft":
18881 scrollMode = ScrollMode.PAGE;
18882 case "TwoColumnLeft":
18883 spreadMode = SpreadMode.ODD;
18884 break;
18885 case "TwoPageRight":
18886 scrollMode = ScrollMode.PAGE;
18887 case "TwoColumnRight":
18888 spreadMode = SpreadMode.EVEN;
18889 break;
18890 }
18891 return {
18892 scrollMode,
18893 spreadMode
18894 };
18895}
18896function apiPageModeToSidebarView(mode) {
18897 switch (mode) {
18898 case "UseNone":
18899 return SidebarView.NONE;
18900 case "UseThumbs":
18901 return SidebarView.THUMBS;
18902 case "UseOutlines":
18903 return SidebarView.OUTLINE;
18904 case "UseAttachments":
18905 return SidebarView.ATTACHMENTS;
18906 case "UseOC":
18907 return SidebarView.LAYERS;
18908 }
18909 return SidebarView.NONE;
18910}
18911function toggleCheckedBtn(button, toggle, view = null) {
18912 button.classList.toggle("toggled", toggle);
18913 button.setAttribute("aria-checked", toggle);
18914 view?.classList.toggle("hidden", !toggle);
18915}
18916function toggleExpandedBtn(button, toggle, view = null) {
18917 button.classList.toggle("toggled", toggle);
18918 button.setAttribute("aria-expanded", toggle);
18919 view?.classList.toggle("hidden", !toggle);
18920}
18921
18922
18923/***/ }),
18924
18925/***/ 9226:
18926/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
18927
18928/* harmony export */ __webpack_require__.d(__webpack_exports__, {
18929/* harmony export */ ViewHistory: () => (/* binding */ ViewHistory)
18930/* harmony export */ });
18931/* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9840);
18932
18933const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
18934class ViewHistory {
18935 constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) {
18936 this.fingerprint = fingerprint;
18937 this.cacheSize = cacheSize;
18938 this._initializedPromise = this._readFromStorage().then(databaseStr => {
18939 const database = JSON.parse(databaseStr || "{}");
18940 let index = -1;
18941 if (!Array.isArray(database.files)) {
18942 database.files = [];
18943 } else {
18944 while (database.files.length >= this.cacheSize) {
18945 database.files.shift();
18946 }
18947 for (let i = 0, ii = database.files.length; i < ii; i++) {
18948 const branch = database.files[i];
18949 if (branch.fingerprint === this.fingerprint) {
18950 index = i;
18951 break;
18952 }
18953 }
18954 }
18955 if (index === -1) {
18956 index = database.files.push({
18957 fingerprint: this.fingerprint
18958 }) - 1;
18959 }
18960 this.file = database.files[index];
18961 this.database = database;
18962 });
18963 }
18964 async _writeToStorage() {
18965 if (_app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.get("disableHistory")) {
18966 return;
18967 }
18968 const databaseStr = JSON.stringify(this.database);
18969 try {
18970 localStorage.setItem("pdfjs.history", databaseStr);
18971 } catch (safariSecurityException) {}
18972 }
18973 async _readFromStorage() {
18974 if (_app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.get("disableHistory")) {
18975 return undefined;
18976 }
18977 try {
18978 return localStorage.getItem("pdfjs.history");
18979 } catch (safariSecurityException) {
18980 return undefined;
18981 }
18982 }
18983 async set(name, val) {
18984 await this._initializedPromise;
18985 this.file[name] = val;
18986 return this._writeToStorage();
18987 }
18988 async setMultiple(properties) {
18989 await this._initializedPromise;
18990 for (const name in properties) {
18991 this.file[name] = properties[name];
18992 }
18993 return this._writeToStorage();
18994 }
18995 async get(name, defaultValue) {
18996 await this._initializedPromise;
18997 const val = this.file[name];
18998 return val !== undefined ? val : defaultValue;
18999 }
19000 async getMultiple(properties) {
19001 await this._initializedPromise;
19002 const values = Object.create(null);
19003 for (const name in properties) {
19004 const val = this.file[name];
19005 values[name] = val !== undefined ? val : properties[name];
19006 }
19007 return values;
19008 }
19009}
19010
19011
19012/***/ }),
19013
19014/***/ 2030:
19015/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
19016
19017__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
19018/* harmony export */ __webpack_require__.d(__webpack_exports__, {
19019/* harmony export */ PDFViewerApplication: () => (/* reexport safe */ _app_js__WEBPACK_IMPORTED_MODULE_3__.PDFViewerApplication),
19020/* harmony export */ PDFViewerApplicationConstants: () => (/* binding */ AppConstants),
19021/* harmony export */ PDFViewerApplicationOptions: () => (/* reexport safe */ _app_options_js__WEBPACK_IMPORTED_MODULE_1__.AppOptions)
19022/* harmony export */ });
19023/* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
19024/* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9840);
19025/* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(787);
19026/* harmony import */ var _app_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1621);
19027var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_app_js__WEBPACK_IMPORTED_MODULE_3__]);
19028_app_js__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
19029
19030
19031
19032
19033const pdfjsVersion = "4.2.552";
19034const pdfjsBuild = "65a73db5b";
19035const AppConstants = {
19036 LinkTarget: _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_2__.LinkTarget,
19037 RenderingStates: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates,
19038 ScrollMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode,
19039 SpreadMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode
19040};
19041window.PDFViewerApplication = _app_js__WEBPACK_IMPORTED_MODULE_3__.PDFViewerApplication;
19042window.PDFViewerApplicationConstants = AppConstants;
19043window.PDFViewerApplicationOptions = _app_options_js__WEBPACK_IMPORTED_MODULE_1__.AppOptions;
19044if (!HTMLCollection.prototype[Symbol.iterator]) {
19045 HTMLCollection.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
19046}
19047(function () {
19048 if (typeof window.CustomEvent === "function") {
19049 return;
19050 }
19051 function CustomEvent(event, params) {
19052 params = params || {
19053 bubbles: false,
19054 cancelable: false,
19055 detail: null
19056 };
19057 const evt = document.createEvent("CustomEvent");
19058 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
19059 return evt;
19060 }
19061 window.CustomEvent = CustomEvent;
19062})();
19063function getViewerConfiguration() {
19064 return {
19065 appContainer: document.body,
19066 mainContainer: document.getElementById("viewerContainer"),
19067 viewerContainer: document.getElementById("viewer"),
19068 toolbar: {
19069 container: document.getElementById("toolbarViewer"),
19070 numPages: document.getElementById("numPages"),
19071 pageNumber: document.getElementById("pageNumber"),
19072 scaleSelect: document.getElementById("scaleSelect"),
19073 customScaleOption: document.getElementById("customScaleOption"),
19074 previous: document.getElementById("previous"),
19075 next: document.getElementById("next"),
19076 zoomIn: document.getElementById("zoomIn"),
19077 zoomOut: document.getElementById("zoomOut"),
19078 viewFind: document.getElementById("viewFind"),
19079 print: document.getElementById("print"),
19080 editorFreeTextButton: document.getElementById("editorFreeText"),
19081 editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
19082 editorHighlightButton: document.getElementById("editorHighlight"),
19083 editorHighlightParamsToolbar: document.getElementById("editorHighlightParamsToolbar"),
19084 editorHighlightColorPicker: document.getElementById("editorHighlightColorPicker"),
19085 editorInkButton: document.getElementById("editorInk"),
19086 editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
19087 editorStampButton: document.getElementById("editorStamp"),
19088 presentationModeButton: document.getElementById("presentationMode"),
19089 editorStampParamsToolbar: document.getElementById("editorStampParamsToolbar"),
19090 download: document.getElementById("download")
19091 },
19092 secondaryToolbar: {
19093 toolbar: document.getElementById("secondaryToolbar"),
19094 toggleButton: document.getElementById("secondaryToolbarToggle"),
19095 presentationModeButton: document.getElementById("secondaryPresentationMode"),
19096 openFileButton: document.getElementById("secondaryOpenFile"),
19097 printButton: document.getElementById("secondaryPrint"),
19098 downloadButton: document.getElementById("secondaryDownload"),
19099 viewBookmarkButton: document.getElementById("viewBookmark"),
19100 firstPageButton: document.getElementById("firstPage"),
19101 lastPageButton: document.getElementById("lastPage"),
19102 pageRotateCwButton: document.getElementById("pageRotateCw"),
19103 pageRotateCcwButton: document.getElementById("pageRotateCcw"),
19104 cursorSelectToolButton: document.getElementById("cursorSelectTool"),
19105 cursorHandToolButton: document.getElementById("cursorHandTool"),
19106 scrollPageButton: document.getElementById("scrollPage"),
19107 scrollVerticalButton: document.getElementById("scrollVertical"),
19108 scrollHorizontalButton: document.getElementById("scrollHorizontal"),
19109 scrollWrappedButton: document.getElementById("scrollWrapped"),
19110 spreadNoneButton: document.getElementById("spreadNone"),
19111 spreadOddButton: document.getElementById("spreadOdd"),
19112 spreadEvenButton: document.getElementById("spreadEven"),
19113 documentPropertiesButton: document.getElementById("documentProperties")
19114 },
19115 sidebar: {
19116 outerContainer: document.getElementById("outerContainer"),
19117 sidebarContainer: document.getElementById("sidebarContainer"),
19118 toggleButton: document.getElementById("sidebarToggle"),
19119 resizer: document.getElementById("sidebarResizer"),
19120 thumbnailButton: document.getElementById("viewThumbnail"),
19121 outlineButton: document.getElementById("viewOutline"),
19122 attachmentsButton: document.getElementById("viewAttachments"),
19123 layersButton: document.getElementById("viewLayers"),
19124 thumbnailView: document.getElementById("thumbnailView"),
19125 outlineView: document.getElementById("outlineView"),
19126 attachmentsView: document.getElementById("attachmentsView"),
19127 layersView: document.getElementById("layersView"),
19128 currentOutlineItemButton: document.getElementById("currentOutlineItem")
19129 },
19130 findBar: {
19131 bar: document.getElementById("findbar"),
19132 toggleButton: document.getElementById("viewFind"),
19133 findField: document.getElementById("findInput"),
19134 highlightAllCheckbox: document.getElementById("findHighlightAll"),
19135 caseSensitiveCheckbox: document.getElementById("findMatchCase"),
19136 matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
19137 entireWordCheckbox: document.getElementById("findEntireWord"),
19138 findMsg: document.getElementById("findMsg"),
19139 findResultsCount: document.getElementById("findResultsCount"),
19140 findPreviousButton: document.getElementById("findPrevious"),
19141 findNextButton: document.getElementById("findNext")
19142 },
19143 passwordOverlay: {
19144 dialog: document.getElementById("passwordDialog"),
19145 label: document.getElementById("passwordText"),
19146 input: document.getElementById("password"),
19147 submitButton: document.getElementById("passwordSubmit"),
19148 cancelButton: document.getElementById("passwordCancel")
19149 },
19150 documentProperties: {
19151 dialog: document.getElementById("documentPropertiesDialog"),
19152 closeButton: document.getElementById("documentPropertiesClose"),
19153 fields: {
19154 fileName: document.getElementById("fileNameField"),
19155 fileSize: document.getElementById("fileSizeField"),
19156 title: document.getElementById("titleField"),
19157 author: document.getElementById("authorField"),
19158 subject: document.getElementById("subjectField"),
19159 keywords: document.getElementById("keywordsField"),
19160 creationDate: document.getElementById("creationDateField"),
19161 modificationDate: document.getElementById("modificationDateField"),
19162 creator: document.getElementById("creatorField"),
19163 producer: document.getElementById("producerField"),
19164 version: document.getElementById("versionField"),
19165 pageCount: document.getElementById("pageCountField"),
19166 pageSize: document.getElementById("pageSizeField"),
19167 linearized: document.getElementById("linearizedField")
19168 }
19169 },
19170 altTextDialog: {
19171 dialog: document.getElementById("altTextDialog"),
19172 optionDescription: document.getElementById("descriptionButton"),
19173 optionDecorative: document.getElementById("decorativeButton"),
19174 textarea: document.getElementById("descriptionTextarea"),
19175 cancelButton: document.getElementById("altTextCancel"),
19176 saveButton: document.getElementById("altTextSave")
19177 },
19178 annotationEditorParams: {
19179 editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
19180 editorFreeTextColor: document.getElementById("editorFreeTextColor"),
19181 editorInkColor: document.getElementById("editorInkColor"),
19182 editorInkThickness: document.getElementById("editorInkThickness"),
19183 editorInkOpacity: document.getElementById("editorInkOpacity"),
19184 editorStampAddImage: document.getElementById("editorStampAddImage"),
19185 editorFreeHighlightThickness: document.getElementById("editorFreeHighlightThickness"),
19186 editorHighlightShowAll: document.getElementById("editorHighlightShowAll")
19187 },
19188 printContainer: document.getElementById("printContainer")
19189 };
19190}
19191function webViewerLoad() {
19192 const config = getViewerConfiguration();
19193 const event = new CustomEvent("webviewerloaded", {
19194 bubbles: true,
19195 cancelable: true,
19196 detail: {
19197 source: window
19198 }
19199 });
19200 try {
19201 document.dispatchEvent(event);
19202 } catch (ex) {
19203 console.error(`webviewerloaded: ${ex}`);
19204 parent.document.dispatchEvent(event);
19205 }
19206 _app_js__WEBPACK_IMPORTED_MODULE_3__.PDFViewerApplication.run(config);
19207}
19208document.blockUnblockOnload?.(true);
19209window.webViewerLoad = webViewerLoad;
19210
19211__webpack_async_result__();
19212} catch(e) { __webpack_async_result__(e); } });
19213
19214/***/ }),
19215
19216/***/ 2973:
19217/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
19218
19219__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
19220/* harmony export */ __webpack_require__.d(__webpack_exports__, {
19221/* harmony export */ XfaLayerBuilder: () => (/* binding */ XfaLayerBuilder)
19222/* harmony export */ });
19223/* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
19224var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
19225pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
19226
19227class XfaLayerBuilder {
19228 constructor({
19229 pdfPage,
19230 annotationStorage = null,
19231 linkService,
19232 xfaHtml = null
19233 }) {
19234 this.pdfPage = pdfPage;
19235 this.annotationStorage = annotationStorage;
19236 this.linkService = linkService;
19237 this.xfaHtml = xfaHtml;
19238 this.div = null;
19239 this._cancelled = false;
19240 }
19241 async render(viewport, intent = "display") {
19242 if (intent === "print") {
19243 const parameters = {
19244 viewport: viewport.clone({
19245 dontFlip: true
19246 }),
19247 div: this.div,
19248 xfaHtml: this.xfaHtml,
19249 annotationStorage: this.annotationStorage,
19250 linkService: this.linkService,
19251 intent
19252 };
19253 this.div = document.createElement("div");
19254 parameters.div = this.div;
19255 return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.render(parameters);
19256 }
19257 const xfaHtml = await this.pdfPage.getXfa();
19258 if (this._cancelled || !xfaHtml) {
19259 return {
19260 textDivs: []
19261 };
19262 }
19263 const parameters = {
19264 viewport: viewport.clone({
19265 dontFlip: true
19266 }),
19267 div: this.div,
19268 xfaHtml,
19269 annotationStorage: this.annotationStorage,
19270 linkService: this.linkService,
19271 intent
19272 };
19273 if (this.div) {
19274 return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.update(parameters);
19275 }
19276 this.div = document.createElement("div");
19277 parameters.div = this.div;
19278 return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.render(parameters);
19279 }
19280 cancel() {
19281 this._cancelled = true;
19282 }
19283 hide() {
19284 if (!this.div) {
19285 return;
19286 }
19287 this.div.hidden = true;
19288 }
19289}
19290
19291__webpack_async_result__();
19292} catch(e) { __webpack_async_result__(e); } });
19293
19294/***/ })
19295
19296/******/ });
19297/************************************************************************/
19298/******/ // The module cache
19299/******/ var __webpack_module_cache__ = {};
19300/******/
19301/******/ // The require function
19302/******/ function __webpack_require__(moduleId) {
19303/******/ // Check if module is in cache
19304/******/ var cachedModule = __webpack_module_cache__[moduleId];
19305/******/ if (cachedModule !== undefined) {
19306/******/ return cachedModule.exports;
19307/******/ }
19308/******/ // Create a new module (and put it into the cache)
19309/******/ var module = __webpack_module_cache__[moduleId] = {
19310/******/ // no module.id needed
19311/******/ // no module.loaded needed
19312/******/ exports: {}
19313/******/ };
19314/******/
19315/******/ // Execute the module function
19316/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
19317/******/
19318/******/ // Return the exports of the module
19319/******/ return module.exports;
19320/******/ }
19321/******/
19322/************************************************************************/
19323/******/ /* webpack/runtime/async module */
19324/******/ (() => {
19325/******/ var webpackQueues = typeof Symbol === "function" ? Symbol("webpack queues") : "__webpack_queues__";
19326/******/ var webpackExports = typeof Symbol === "function" ? Symbol("webpack exports") : "__webpack_exports__";
19327/******/ var webpackError = typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__";
19328/******/ var resolveQueue = (queue) => {
19329/******/ if(queue && queue.d < 1) {
19330/******/ queue.d = 1;
19331/******/ queue.forEach((fn) => (fn.r--));
19332/******/ queue.forEach((fn) => (fn.r-- ? fn.r++ : fn()));
19333/******/ }
19334/******/ }
19335/******/ var wrapDeps = (deps) => (deps.map((dep) => {
19336/******/ if(dep !== null && typeof dep === "object") {
19337/******/ if(dep[webpackQueues]) return dep;
19338/******/ if(dep.then) {
19339/******/ var queue = [];
19340/******/ queue.d = 0;
19341/******/ dep.then((r) => {
19342/******/ obj[webpackExports] = r;
19343/******/ resolveQueue(queue);
19344/******/ }, (e) => {
19345/******/ obj[webpackError] = e;
19346/******/ resolveQueue(queue);
19347/******/ });
19348/******/ var obj = {};
19349/******/ obj[webpackQueues] = (fn) => (fn(queue));
19350/******/ return obj;
19351/******/ }
19352/******/ }
19353/******/ var ret = {};
19354/******/ ret[webpackQueues] = x => {};
19355/******/ ret[webpackExports] = dep;
19356/******/ return ret;
19357/******/ }));
19358/******/ __webpack_require__.a = (module, body, hasAwait) => {
19359/******/ var queue;
19360/******/ hasAwait && ((queue = []).d = -1);
19361/******/ var depQueues = new Set();
19362/******/ var exports = module.exports;
19363/******/ var currentDeps;
19364/******/ var outerResolve;
19365/******/ var reject;
19366/******/ var promise = new Promise((resolve, rej) => {
19367/******/ reject = rej;
19368/******/ outerResolve = resolve;
19369/******/ });
19370/******/ promise[webpackExports] = exports;
19371/******/ promise[webpackQueues] = (fn) => (queue && fn(queue), depQueues.forEach(fn), promise["catch"](x => {}));
19372/******/ module.exports = promise;
19373/******/ body((deps) => {
19374/******/ currentDeps = wrapDeps(deps);
19375/******/ var fn;
19376/******/ var getResult = () => (currentDeps.map((d) => {
19377/******/ if(d[webpackError]) throw d[webpackError];
19378/******/ return d[webpackExports];
19379/******/ }))
19380/******/ var promise = new Promise((resolve) => {
19381/******/ fn = () => (resolve(getResult));
19382/******/ fn.r = 0;
19383/******/ var fnQueue = (q) => (q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))));
19384/******/ currentDeps.map((dep) => (dep[webpackQueues](fnQueue)));
19385/******/ });
19386/******/ return fn.r ? promise : getResult();
19387/******/ }, (err) => ((err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)));
19388/******/ queue && queue.d < 0 && (queue.d = 0);
19389/******/ };
19390/******/ })();
19391/******/
19392/******/ /* webpack/runtime/define property getters */
19393/******/ (() => {
19394/******/ // define getter functions for harmony exports
19395/******/ __webpack_require__.d = (exports, definition) => {
19396/******/ for(var key in definition) {
19397/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
19398/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
19399/******/ }
19400/******/ }
19401/******/ };
19402/******/ })();
19403/******/
19404/******/ /* webpack/runtime/hasOwnProperty shorthand */
19405/******/ (() => {
19406/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
19407/******/ })();
19408/******/
19409/************************************************************************/
19410/******/
19411/******/ // startup
19412/******/ // Load entry module and return exports
19413/******/ // This entry module used 'module' so it can't be inlined
19414/******/ var __webpack_exports__ = __webpack_require__(2030);
19415/******/ __webpack_exports__ = await __webpack_exports__;
19416/******/ var __webpack_exports__PDFViewerApplication = __webpack_exports__.PDFViewerApplication;
19417/******/ var __webpack_exports__PDFViewerApplicationConstants = __webpack_exports__.PDFViewerApplicationConstants;
19418/******/ var __webpack_exports__PDFViewerApplicationOptions = __webpack_exports__.PDFViewerApplicationOptions;
19419/******/ export { __webpack_exports__PDFViewerApplication as PDFViewerApplication, __webpack_exports__PDFViewerApplicationConstants as PDFViewerApplicationConstants, __webpack_exports__PDFViewerApplicationOptions as PDFViewerApplicationOptions };
19420/******/
19421
\No newline at end of file