UNPKG

802 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/***/ 9306:
26/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
27
28
29var isCallable = __webpack_require__(4901);
30var tryToString = __webpack_require__(6823);
31
32var $TypeError = TypeError;
33
34// `Assert: IsCallable(argument) is true`
35module.exports = function (argument) {
36 if (isCallable(argument)) return argument;
37 throw new $TypeError(tryToString(argument) + ' is not a function');
38};
39
40
41/***/ }),
42
43/***/ 3506:
44/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
45
46
47var isPossiblePrototype = __webpack_require__(3925);
48
49var $String = String;
50var $TypeError = TypeError;
51
52module.exports = function (argument) {
53 if (isPossiblePrototype(argument)) return argument;
54 throw new $TypeError("Can't set " + $String(argument) + ' as a prototype');
55};
56
57
58/***/ }),
59
60/***/ 7080:
61/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
62
63
64var has = (__webpack_require__(4402).has);
65
66// Perform ? RequireInternalSlot(M, [[SetData]])
67module.exports = function (it) {
68 has(it);
69 return it;
70};
71
72
73/***/ }),
74
75/***/ 679:
76/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
77
78
79var isPrototypeOf = __webpack_require__(1625);
80
81var $TypeError = TypeError;
82
83module.exports = function (it, Prototype) {
84 if (isPrototypeOf(Prototype, it)) return it;
85 throw new $TypeError('Incorrect invocation');
86};
87
88
89/***/ }),
90
91/***/ 8551:
92/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
93
94
95var isObject = __webpack_require__(34);
96
97var $String = String;
98var $TypeError = TypeError;
99
100// `Assert: Type(argument) is Object`
101module.exports = function (argument) {
102 if (isObject(argument)) return argument;
103 throw new $TypeError($String(argument) + ' is not an object');
104};
105
106
107/***/ }),
108
109/***/ 7811:
110/***/ ((module) => {
111
112
113// eslint-disable-next-line es/no-typed-arrays -- safe
114module.exports = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined';
115
116
117/***/ }),
118
119/***/ 7394:
120/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
121
122
123var uncurryThisAccessor = __webpack_require__(6706);
124var classof = __webpack_require__(4576);
125
126var $TypeError = TypeError;
127
128// Includes
129// - Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
130// - If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
131module.exports = uncurryThisAccessor(ArrayBuffer.prototype, 'byteLength', 'get') || function (O) {
132 if (classof(O) !== 'ArrayBuffer') throw new $TypeError('ArrayBuffer expected');
133 return O.byteLength;
134};
135
136
137/***/ }),
138
139/***/ 3238:
140/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
141
142
143var uncurryThis = __webpack_require__(9504);
144var arrayBufferByteLength = __webpack_require__(7394);
145
146var slice = uncurryThis(ArrayBuffer.prototype.slice);
147
148module.exports = function (O) {
149 if (arrayBufferByteLength(O) !== 0) return false;
150 try {
151 slice(O, 0, 0);
152 return false;
153 } catch (error) {
154 return true;
155 }
156};
157
158
159/***/ }),
160
161/***/ 5636:
162/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
163
164
165var global = __webpack_require__(4475);
166var uncurryThis = __webpack_require__(9504);
167var uncurryThisAccessor = __webpack_require__(6706);
168var toIndex = __webpack_require__(7696);
169var isDetached = __webpack_require__(3238);
170var arrayBufferByteLength = __webpack_require__(7394);
171var detachTransferable = __webpack_require__(4483);
172var PROPER_STRUCTURED_CLONE_TRANSFER = __webpack_require__(1548);
173
174var structuredClone = global.structuredClone;
175var ArrayBuffer = global.ArrayBuffer;
176var DataView = global.DataView;
177var TypeError = global.TypeError;
178var min = Math.min;
179var ArrayBufferPrototype = ArrayBuffer.prototype;
180var DataViewPrototype = DataView.prototype;
181var slice = uncurryThis(ArrayBufferPrototype.slice);
182var isResizable = uncurryThisAccessor(ArrayBufferPrototype, 'resizable', 'get');
183var maxByteLength = uncurryThisAccessor(ArrayBufferPrototype, 'maxByteLength', 'get');
184var getInt8 = uncurryThis(DataViewPrototype.getInt8);
185var setInt8 = uncurryThis(DataViewPrototype.setInt8);
186
187module.exports = (PROPER_STRUCTURED_CLONE_TRANSFER || detachTransferable) && function (arrayBuffer, newLength, preserveResizability) {
188 var byteLength = arrayBufferByteLength(arrayBuffer);
189 var newByteLength = newLength === undefined ? byteLength : toIndex(newLength);
190 var fixedLength = !isResizable || !isResizable(arrayBuffer);
191 var newBuffer;
192 if (isDetached(arrayBuffer)) throw new TypeError('ArrayBuffer is detached');
193 if (PROPER_STRUCTURED_CLONE_TRANSFER) {
194 arrayBuffer = structuredClone(arrayBuffer, { transfer: [arrayBuffer] });
195 if (byteLength === newByteLength && (preserveResizability || fixedLength)) return arrayBuffer;
196 }
197 if (byteLength >= newByteLength && (!preserveResizability || fixedLength)) {
198 newBuffer = slice(arrayBuffer, 0, newByteLength);
199 } else {
200 var options = preserveResizability && !fixedLength && maxByteLength ? { maxByteLength: maxByteLength(arrayBuffer) } : undefined;
201 newBuffer = new ArrayBuffer(newByteLength, options);
202 var a = new DataView(arrayBuffer);
203 var b = new DataView(newBuffer);
204 var copyLength = min(newByteLength, byteLength);
205 for (var i = 0; i < copyLength; i++) setInt8(b, i, getInt8(a, i));
206 }
207 if (!PROPER_STRUCTURED_CLONE_TRANSFER) detachTransferable(arrayBuffer);
208 return newBuffer;
209};
210
211
212/***/ }),
213
214/***/ 4644:
215/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
216
217
218var NATIVE_ARRAY_BUFFER = __webpack_require__(7811);
219var DESCRIPTORS = __webpack_require__(3724);
220var global = __webpack_require__(4475);
221var isCallable = __webpack_require__(4901);
222var isObject = __webpack_require__(34);
223var hasOwn = __webpack_require__(9297);
224var classof = __webpack_require__(6955);
225var tryToString = __webpack_require__(6823);
226var createNonEnumerableProperty = __webpack_require__(6699);
227var defineBuiltIn = __webpack_require__(6840);
228var defineBuiltInAccessor = __webpack_require__(2106);
229var isPrototypeOf = __webpack_require__(1625);
230var getPrototypeOf = __webpack_require__(2787);
231var setPrototypeOf = __webpack_require__(2967);
232var wellKnownSymbol = __webpack_require__(8227);
233var uid = __webpack_require__(3392);
234var InternalStateModule = __webpack_require__(1181);
235
236var enforceInternalState = InternalStateModule.enforce;
237var getInternalState = InternalStateModule.get;
238var Int8Array = global.Int8Array;
239var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
240var Uint8ClampedArray = global.Uint8ClampedArray;
241var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
242var TypedArray = Int8Array && getPrototypeOf(Int8Array);
243var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
244var ObjectPrototype = Object.prototype;
245var TypeError = global.TypeError;
246
247var TO_STRING_TAG = wellKnownSymbol('toStringTag');
248var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
249var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor';
250// Fixing native typed arrays in Opera Presto crashes the browser, see #595
251var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
252var TYPED_ARRAY_TAG_REQUIRED = false;
253var NAME, Constructor, Prototype;
254
255var TypedArrayConstructorsList = {
256 Int8Array: 1,
257 Uint8Array: 1,
258 Uint8ClampedArray: 1,
259 Int16Array: 2,
260 Uint16Array: 2,
261 Int32Array: 4,
262 Uint32Array: 4,
263 Float32Array: 4,
264 Float64Array: 8
265};
266
267var BigIntArrayConstructorsList = {
268 BigInt64Array: 8,
269 BigUint64Array: 8
270};
271
272var isView = function isView(it) {
273 if (!isObject(it)) return false;
274 var klass = classof(it);
275 return klass === 'DataView'
276 || hasOwn(TypedArrayConstructorsList, klass)
277 || hasOwn(BigIntArrayConstructorsList, klass);
278};
279
280var getTypedArrayConstructor = function (it) {
281 var proto = getPrototypeOf(it);
282 if (!isObject(proto)) return;
283 var state = getInternalState(proto);
284 return (state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR)) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto);
285};
286
287var isTypedArray = function (it) {
288 if (!isObject(it)) return false;
289 var klass = classof(it);
290 return hasOwn(TypedArrayConstructorsList, klass)
291 || hasOwn(BigIntArrayConstructorsList, klass);
292};
293
294var aTypedArray = function (it) {
295 if (isTypedArray(it)) return it;
296 throw new TypeError('Target is not a typed array');
297};
298
299var aTypedArrayConstructor = function (C) {
300 if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C))) return C;
301 throw new TypeError(tryToString(C) + ' is not a typed array constructor');
302};
303
304var exportTypedArrayMethod = function (KEY, property, forced, options) {
305 if (!DESCRIPTORS) return;
306 if (forced) for (var ARRAY in TypedArrayConstructorsList) {
307 var TypedArrayConstructor = global[ARRAY];
308 if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY)) try {
309 delete TypedArrayConstructor.prototype[KEY];
310 } catch (error) {
311 // old WebKit bug - some methods are non-configurable
312 try {
313 TypedArrayConstructor.prototype[KEY] = property;
314 } catch (error2) { /* empty */ }
315 }
316 }
317 if (!TypedArrayPrototype[KEY] || forced) {
318 defineBuiltIn(TypedArrayPrototype, KEY, forced ? property
319 : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options);
320 }
321};
322
323var exportTypedArrayStaticMethod = function (KEY, property, forced) {
324 var ARRAY, TypedArrayConstructor;
325 if (!DESCRIPTORS) return;
326 if (setPrototypeOf) {
327 if (forced) for (ARRAY in TypedArrayConstructorsList) {
328 TypedArrayConstructor = global[ARRAY];
329 if (TypedArrayConstructor && hasOwn(TypedArrayConstructor, KEY)) try {
330 delete TypedArrayConstructor[KEY];
331 } catch (error) { /* empty */ }
332 }
333 if (!TypedArray[KEY] || forced) {
334 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable
335 try {
336 return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property);
337 } catch (error) { /* empty */ }
338 } else return;
339 }
340 for (ARRAY in TypedArrayConstructorsList) {
341 TypedArrayConstructor = global[ARRAY];
342 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
343 defineBuiltIn(TypedArrayConstructor, KEY, property);
344 }
345 }
346};
347
348for (NAME in TypedArrayConstructorsList) {
349 Constructor = global[NAME];
350 Prototype = Constructor && Constructor.prototype;
351 if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
352 else NATIVE_ARRAY_BUFFER_VIEWS = false;
353}
354
355for (NAME in BigIntArrayConstructorsList) {
356 Constructor = global[NAME];
357 Prototype = Constructor && Constructor.prototype;
358 if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
359}
360
361// WebKit bug - typed arrays constructors prototype is Object.prototype
362if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) {
363 // eslint-disable-next-line no-shadow -- safe
364 TypedArray = function TypedArray() {
365 throw new TypeError('Incorrect invocation');
366 };
367 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
368 if (global[NAME]) setPrototypeOf(global[NAME], TypedArray);
369 }
370}
371
372if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
373 TypedArrayPrototype = TypedArray.prototype;
374 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
375 if (global[NAME]) setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
376 }
377}
378
379// WebKit bug - one more object in Uint8ClampedArray prototype chain
380if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
381 setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
382}
383
384if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) {
385 TYPED_ARRAY_TAG_REQUIRED = true;
386 defineBuiltInAccessor(TypedArrayPrototype, TO_STRING_TAG, {
387 configurable: true,
388 get: function () {
389 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
390 }
391 });
392 for (NAME in TypedArrayConstructorsList) if (global[NAME]) {
393 createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
394 }
395}
396
397module.exports = {
398 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
399 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG,
400 aTypedArray: aTypedArray,
401 aTypedArrayConstructor: aTypedArrayConstructor,
402 exportTypedArrayMethod: exportTypedArrayMethod,
403 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
404 getTypedArrayConstructor: getTypedArrayConstructor,
405 isView: isView,
406 isTypedArray: isTypedArray,
407 TypedArray: TypedArray,
408 TypedArrayPrototype: TypedArrayPrototype
409};
410
411
412/***/ }),
413
414/***/ 5370:
415/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
416
417
418var lengthOfArrayLike = __webpack_require__(6198);
419
420module.exports = function (Constructor, list, $length) {
421 var index = 0;
422 var length = arguments.length > 2 ? $length : lengthOfArrayLike(list);
423 var result = new Constructor(length);
424 while (length > index) result[index] = list[index++];
425 return result;
426};
427
428
429/***/ }),
430
431/***/ 9617:
432/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
433
434
435var toIndexedObject = __webpack_require__(5397);
436var toAbsoluteIndex = __webpack_require__(5610);
437var lengthOfArrayLike = __webpack_require__(6198);
438
439// `Array.prototype.{ indexOf, includes }` methods implementation
440var createMethod = function (IS_INCLUDES) {
441 return function ($this, el, fromIndex) {
442 var O = toIndexedObject($this);
443 var length = lengthOfArrayLike(O);
444 if (length === 0) return !IS_INCLUDES && -1;
445 var index = toAbsoluteIndex(fromIndex, length);
446 var value;
447 // Array#includes uses SameValueZero equality algorithm
448 // eslint-disable-next-line no-self-compare -- NaN check
449 if (IS_INCLUDES && el !== el) while (length > index) {
450 value = O[index++];
451 // eslint-disable-next-line no-self-compare -- NaN check
452 if (value !== value) return true;
453 // Array#indexOf ignores holes, Array#includes - not
454 } else for (;length > index; index++) {
455 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
456 } return !IS_INCLUDES && -1;
457 };
458};
459
460module.exports = {
461 // `Array.prototype.includes` method
462 // https://tc39.es/ecma262/#sec-array.prototype.includes
463 includes: createMethod(true),
464 // `Array.prototype.indexOf` method
465 // https://tc39.es/ecma262/#sec-array.prototype.indexof
466 indexOf: createMethod(false)
467};
468
469
470/***/ }),
471
472/***/ 4527:
473/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
474
475
476var DESCRIPTORS = __webpack_require__(3724);
477var isArray = __webpack_require__(4376);
478
479var $TypeError = TypeError;
480// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
481var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
482
483// Safari < 13 does not throw an error in this case
484var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
485 // makes no sense without proper strict mode support
486 if (this !== undefined) return true;
487 try {
488 // eslint-disable-next-line es/no-object-defineproperty -- safe
489 Object.defineProperty([], 'length', { writable: false }).length = 1;
490 } catch (error) {
491 return error instanceof TypeError;
492 }
493}();
494
495module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
496 if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
497 throw new $TypeError('Cannot set read only .length');
498 } return O.length = length;
499} : function (O, length) {
500 return O.length = length;
501};
502
503
504/***/ }),
505
506/***/ 7628:
507/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
508
509
510var lengthOfArrayLike = __webpack_require__(6198);
511
512// https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toReversed
513// https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toReversed
514module.exports = function (O, C) {
515 var len = lengthOfArrayLike(O);
516 var A = new C(len);
517 var k = 0;
518 for (; k < len; k++) A[k] = O[len - k - 1];
519 return A;
520};
521
522
523/***/ }),
524
525/***/ 9928:
526/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
527
528
529var lengthOfArrayLike = __webpack_require__(6198);
530var toIntegerOrInfinity = __webpack_require__(1291);
531
532var $RangeError = RangeError;
533
534// https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.with
535// https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.with
536module.exports = function (O, C, index, value) {
537 var len = lengthOfArrayLike(O);
538 var relativeIndex = toIntegerOrInfinity(index);
539 var actualIndex = relativeIndex < 0 ? len + relativeIndex : relativeIndex;
540 if (actualIndex >= len || actualIndex < 0) throw new $RangeError('Incorrect index');
541 var A = new C(len);
542 var k = 0;
543 for (; k < len; k++) A[k] = k === actualIndex ? value : O[k];
544 return A;
545};
546
547
548/***/ }),
549
550/***/ 6319:
551/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
552
553
554var anObject = __webpack_require__(8551);
555var iteratorClose = __webpack_require__(9539);
556
557// call something on iterator step with safe closing on error
558module.exports = function (iterator, fn, value, ENTRIES) {
559 try {
560 return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
561 } catch (error) {
562 iteratorClose(iterator, 'throw', error);
563 }
564};
565
566
567/***/ }),
568
569/***/ 4576:
570/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
571
572
573var uncurryThis = __webpack_require__(9504);
574
575var toString = uncurryThis({}.toString);
576var stringSlice = uncurryThis(''.slice);
577
578module.exports = function (it) {
579 return stringSlice(toString(it), 8, -1);
580};
581
582
583/***/ }),
584
585/***/ 6955:
586/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
587
588
589var TO_STRING_TAG_SUPPORT = __webpack_require__(2140);
590var isCallable = __webpack_require__(4901);
591var classofRaw = __webpack_require__(4576);
592var wellKnownSymbol = __webpack_require__(8227);
593
594var TO_STRING_TAG = wellKnownSymbol('toStringTag');
595var $Object = Object;
596
597// ES3 wrong here
598var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
599
600// fallback for IE11 Script Access Denied error
601var tryGet = function (it, key) {
602 try {
603 return it[key];
604 } catch (error) { /* empty */ }
605};
606
607// getting tag from ES6+ `Object.prototype.toString`
608module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
609 var O, tag, result;
610 return it === undefined ? 'Undefined' : it === null ? 'Null'
611 // @@toStringTag case
612 : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
613 // builtinTag case
614 : CORRECT_ARGUMENTS ? classofRaw(O)
615 // ES3 arguments fallback
616 : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
617};
618
619
620/***/ }),
621
622/***/ 7740:
623/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
624
625
626var hasOwn = __webpack_require__(9297);
627var ownKeys = __webpack_require__(5031);
628var getOwnPropertyDescriptorModule = __webpack_require__(7347);
629var definePropertyModule = __webpack_require__(4913);
630
631module.exports = function (target, source, exceptions) {
632 var keys = ownKeys(source);
633 var defineProperty = definePropertyModule.f;
634 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
635 for (var i = 0; i < keys.length; i++) {
636 var key = keys[i];
637 if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
638 defineProperty(target, key, getOwnPropertyDescriptor(source, key));
639 }
640 }
641};
642
643
644/***/ }),
645
646/***/ 2211:
647/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
648
649
650var fails = __webpack_require__(9039);
651
652module.exports = !fails(function () {
653 function F() { /* empty */ }
654 F.prototype.constructor = null;
655 // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
656 return Object.getPrototypeOf(new F()) !== F.prototype;
657});
658
659
660/***/ }),
661
662/***/ 2529:
663/***/ ((module) => {
664
665
666// `CreateIterResultObject` abstract operation
667// https://tc39.es/ecma262/#sec-createiterresultobject
668module.exports = function (value, done) {
669 return { value: value, done: done };
670};
671
672
673/***/ }),
674
675/***/ 6699:
676/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
677
678
679var DESCRIPTORS = __webpack_require__(3724);
680var definePropertyModule = __webpack_require__(4913);
681var createPropertyDescriptor = __webpack_require__(6980);
682
683module.exports = DESCRIPTORS ? function (object, key, value) {
684 return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
685} : function (object, key, value) {
686 object[key] = value;
687 return object;
688};
689
690
691/***/ }),
692
693/***/ 6980:
694/***/ ((module) => {
695
696
697module.exports = function (bitmap, value) {
698 return {
699 enumerable: !(bitmap & 1),
700 configurable: !(bitmap & 2),
701 writable: !(bitmap & 4),
702 value: value
703 };
704};
705
706
707/***/ }),
708
709/***/ 4659:
710/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
711
712
713var DESCRIPTORS = __webpack_require__(3724);
714var definePropertyModule = __webpack_require__(4913);
715var createPropertyDescriptor = __webpack_require__(6980);
716
717module.exports = function (object, key, value) {
718 if (DESCRIPTORS) definePropertyModule.f(object, key, createPropertyDescriptor(0, value));
719 else object[key] = value;
720};
721
722
723/***/ }),
724
725/***/ 2106:
726/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
727
728
729var makeBuiltIn = __webpack_require__(283);
730var defineProperty = __webpack_require__(4913);
731
732module.exports = function (target, name, descriptor) {
733 if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
734 if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
735 return defineProperty.f(target, name, descriptor);
736};
737
738
739/***/ }),
740
741/***/ 6840:
742/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
743
744
745var isCallable = __webpack_require__(4901);
746var definePropertyModule = __webpack_require__(4913);
747var makeBuiltIn = __webpack_require__(283);
748var defineGlobalProperty = __webpack_require__(9433);
749
750module.exports = function (O, key, value, options) {
751 if (!options) options = {};
752 var simple = options.enumerable;
753 var name = options.name !== undefined ? options.name : key;
754 if (isCallable(value)) makeBuiltIn(value, name, options);
755 if (options.global) {
756 if (simple) O[key] = value;
757 else defineGlobalProperty(key, value);
758 } else {
759 try {
760 if (!options.unsafe) delete O[key];
761 else if (O[key]) simple = true;
762 } catch (error) { /* empty */ }
763 if (simple) O[key] = value;
764 else definePropertyModule.f(O, key, {
765 value: value,
766 enumerable: false,
767 configurable: !options.nonConfigurable,
768 writable: !options.nonWritable
769 });
770 } return O;
771};
772
773
774/***/ }),
775
776/***/ 6279:
777/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
778
779
780var defineBuiltIn = __webpack_require__(6840);
781
782module.exports = function (target, src, options) {
783 for (var key in src) defineBuiltIn(target, key, src[key], options);
784 return target;
785};
786
787
788/***/ }),
789
790/***/ 9433:
791/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
792
793
794var global = __webpack_require__(4475);
795
796// eslint-disable-next-line es/no-object-defineproperty -- safe
797var defineProperty = Object.defineProperty;
798
799module.exports = function (key, value) {
800 try {
801 defineProperty(global, key, { value: value, configurable: true, writable: true });
802 } catch (error) {
803 global[key] = value;
804 } return value;
805};
806
807
808/***/ }),
809
810/***/ 3724:
811/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
812
813
814var fails = __webpack_require__(9039);
815
816// Detect IE8's incomplete defineProperty implementation
817module.exports = !fails(function () {
818 // eslint-disable-next-line es/no-object-defineproperty -- required for testing
819 return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
820});
821
822
823/***/ }),
824
825/***/ 4483:
826/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
827
828
829var global = __webpack_require__(4475);
830var tryNodeRequire = __webpack_require__(9714);
831var PROPER_STRUCTURED_CLONE_TRANSFER = __webpack_require__(1548);
832
833var structuredClone = global.structuredClone;
834var $ArrayBuffer = global.ArrayBuffer;
835var $MessageChannel = global.MessageChannel;
836var detach = false;
837var WorkerThreads, channel, buffer, $detach;
838
839if (PROPER_STRUCTURED_CLONE_TRANSFER) {
840 detach = function (transferable) {
841 structuredClone(transferable, { transfer: [transferable] });
842 };
843} else if ($ArrayBuffer) try {
844 if (!$MessageChannel) {
845 WorkerThreads = tryNodeRequire('worker_threads');
846 if (WorkerThreads) $MessageChannel = WorkerThreads.MessageChannel;
847 }
848
849 if ($MessageChannel) {
850 channel = new $MessageChannel();
851 buffer = new $ArrayBuffer(2);
852
853 $detach = function (transferable) {
854 channel.port1.postMessage(null, [transferable]);
855 };
856
857 if (buffer.byteLength === 2) {
858 $detach(buffer);
859 if (buffer.byteLength === 0) detach = $detach;
860 }
861 }
862} catch (error) { /* empty */ }
863
864module.exports = detach;
865
866
867/***/ }),
868
869/***/ 4055:
870/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
871
872
873var global = __webpack_require__(4475);
874var isObject = __webpack_require__(34);
875
876var document = global.document;
877// typeof document.createElement is 'object' in old IE
878var EXISTS = isObject(document) && isObject(document.createElement);
879
880module.exports = function (it) {
881 return EXISTS ? document.createElement(it) : {};
882};
883
884
885/***/ }),
886
887/***/ 6837:
888/***/ ((module) => {
889
890
891var $TypeError = TypeError;
892var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
893
894module.exports = function (it) {
895 if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded');
896 return it;
897};
898
899
900/***/ }),
901
902/***/ 5002:
903/***/ ((module) => {
904
905
906module.exports = {
907 IndexSizeError: { s: 'INDEX_SIZE_ERR', c: 1, m: 1 },
908 DOMStringSizeError: { s: 'DOMSTRING_SIZE_ERR', c: 2, m: 0 },
909 HierarchyRequestError: { s: 'HIERARCHY_REQUEST_ERR', c: 3, m: 1 },
910 WrongDocumentError: { s: 'WRONG_DOCUMENT_ERR', c: 4, m: 1 },
911 InvalidCharacterError: { s: 'INVALID_CHARACTER_ERR', c: 5, m: 1 },
912 NoDataAllowedError: { s: 'NO_DATA_ALLOWED_ERR', c: 6, m: 0 },
913 NoModificationAllowedError: { s: 'NO_MODIFICATION_ALLOWED_ERR', c: 7, m: 1 },
914 NotFoundError: { s: 'NOT_FOUND_ERR', c: 8, m: 1 },
915 NotSupportedError: { s: 'NOT_SUPPORTED_ERR', c: 9, m: 1 },
916 InUseAttributeError: { s: 'INUSE_ATTRIBUTE_ERR', c: 10, m: 1 },
917 InvalidStateError: { s: 'INVALID_STATE_ERR', c: 11, m: 1 },
918 SyntaxError: { s: 'SYNTAX_ERR', c: 12, m: 1 },
919 InvalidModificationError: { s: 'INVALID_MODIFICATION_ERR', c: 13, m: 1 },
920 NamespaceError: { s: 'NAMESPACE_ERR', c: 14, m: 1 },
921 InvalidAccessError: { s: 'INVALID_ACCESS_ERR', c: 15, m: 1 },
922 ValidationError: { s: 'VALIDATION_ERR', c: 16, m: 0 },
923 TypeMismatchError: { s: 'TYPE_MISMATCH_ERR', c: 17, m: 1 },
924 SecurityError: { s: 'SECURITY_ERR', c: 18, m: 1 },
925 NetworkError: { s: 'NETWORK_ERR', c: 19, m: 1 },
926 AbortError: { s: 'ABORT_ERR', c: 20, m: 1 },
927 URLMismatchError: { s: 'URL_MISMATCH_ERR', c: 21, m: 1 },
928 QuotaExceededError: { s: 'QUOTA_EXCEEDED_ERR', c: 22, m: 1 },
929 TimeoutError: { s: 'TIMEOUT_ERR', c: 23, m: 1 },
930 InvalidNodeTypeError: { s: 'INVALID_NODE_TYPE_ERR', c: 24, m: 1 },
931 DataCloneError: { s: 'DATA_CLONE_ERR', c: 25, m: 1 }
932};
933
934
935/***/ }),
936
937/***/ 7290:
938/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
939
940
941var IS_DENO = __webpack_require__(516);
942var IS_NODE = __webpack_require__(9088);
943
944module.exports = !IS_DENO && !IS_NODE
945 && typeof window == 'object'
946 && typeof document == 'object';
947
948
949/***/ }),
950
951/***/ 516:
952/***/ ((module) => {
953
954
955/* global Deno -- Deno case */
956module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
957
958
959/***/ }),
960
961/***/ 9088:
962/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
963
964
965var global = __webpack_require__(4475);
966var classof = __webpack_require__(4576);
967
968module.exports = classof(global.process) === 'process';
969
970
971/***/ }),
972
973/***/ 9392:
974/***/ ((module) => {
975
976
977module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
978
979
980/***/ }),
981
982/***/ 7388:
983/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
984
985
986var global = __webpack_require__(4475);
987var userAgent = __webpack_require__(9392);
988
989var process = global.process;
990var Deno = global.Deno;
991var versions = process && process.versions || Deno && Deno.version;
992var v8 = versions && versions.v8;
993var match, version;
994
995if (v8) {
996 match = v8.split('.');
997 // in old Chrome, versions of V8 isn't V8 = Chrome / 10
998 // but their correct versions are not interesting for us
999 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
1000}
1001
1002// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
1003// so check `userAgent` even if `.v8` exists, but 0
1004if (!version && userAgent) {
1005 match = userAgent.match(/Edge\/(\d+)/);
1006 if (!match || match[1] >= 74) {
1007 match = userAgent.match(/Chrome\/(\d+)/);
1008 if (match) version = +match[1];
1009 }
1010}
1011
1012module.exports = version;
1013
1014
1015/***/ }),
1016
1017/***/ 8727:
1018/***/ ((module) => {
1019
1020
1021// IE8- don't enum bug keys
1022module.exports = [
1023 'constructor',
1024 'hasOwnProperty',
1025 'isPrototypeOf',
1026 'propertyIsEnumerable',
1027 'toLocaleString',
1028 'toString',
1029 'valueOf'
1030];
1031
1032
1033/***/ }),
1034
1035/***/ 6193:
1036/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1037
1038
1039var uncurryThis = __webpack_require__(9504);
1040
1041var $Error = Error;
1042var replace = uncurryThis(''.replace);
1043
1044var TEST = (function (arg) { return String(new $Error(arg).stack); })('zxcasd');
1045// eslint-disable-next-line redos/no-vulnerable -- safe
1046var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
1047var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
1048
1049module.exports = function (stack, dropEntries) {
1050 if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
1051 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
1052 } return stack;
1053};
1054
1055
1056/***/ }),
1057
1058/***/ 6518:
1059/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1060
1061
1062var global = __webpack_require__(4475);
1063var getOwnPropertyDescriptor = (__webpack_require__(7347).f);
1064var createNonEnumerableProperty = __webpack_require__(6699);
1065var defineBuiltIn = __webpack_require__(6840);
1066var defineGlobalProperty = __webpack_require__(9433);
1067var copyConstructorProperties = __webpack_require__(7740);
1068var isForced = __webpack_require__(2796);
1069
1070/*
1071 options.target - name of the target object
1072 options.global - target is the global object
1073 options.stat - export as static methods of target
1074 options.proto - export as prototype methods of target
1075 options.real - real prototype method for the `pure` version
1076 options.forced - export even if the native feature is available
1077 options.bind - bind methods to the target, required for the `pure` version
1078 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
1079 options.unsafe - use the simple assignment of property instead of delete + defineProperty
1080 options.sham - add a flag to not completely full polyfills
1081 options.enumerable - export as enumerable property
1082 options.dontCallGetSet - prevent calling a getter on target
1083 options.name - the .name of the function if it does not match the key
1084*/
1085module.exports = function (options, source) {
1086 var TARGET = options.target;
1087 var GLOBAL = options.global;
1088 var STATIC = options.stat;
1089 var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1090 if (GLOBAL) {
1091 target = global;
1092 } else if (STATIC) {
1093 target = global[TARGET] || defineGlobalProperty(TARGET, {});
1094 } else {
1095 target = global[TARGET] && global[TARGET].prototype;
1096 }
1097 if (target) for (key in source) {
1098 sourceProperty = source[key];
1099 if (options.dontCallGetSet) {
1100 descriptor = getOwnPropertyDescriptor(target, key);
1101 targetProperty = descriptor && descriptor.value;
1102 } else targetProperty = target[key];
1103 FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
1104 // contained in target
1105 if (!FORCED && targetProperty !== undefined) {
1106 if (typeof sourceProperty == typeof targetProperty) continue;
1107 copyConstructorProperties(sourceProperty, targetProperty);
1108 }
1109 // add a flag to not completely full polyfills
1110 if (options.sham || (targetProperty && targetProperty.sham)) {
1111 createNonEnumerableProperty(sourceProperty, 'sham', true);
1112 }
1113 defineBuiltIn(target, key, sourceProperty, options);
1114 }
1115};
1116
1117
1118/***/ }),
1119
1120/***/ 9039:
1121/***/ ((module) => {
1122
1123
1124module.exports = function (exec) {
1125 try {
1126 return !!exec();
1127 } catch (error) {
1128 return true;
1129 }
1130};
1131
1132
1133/***/ }),
1134
1135/***/ 6080:
1136/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1137
1138
1139var uncurryThis = __webpack_require__(7476);
1140var aCallable = __webpack_require__(9306);
1141var NATIVE_BIND = __webpack_require__(616);
1142
1143var bind = uncurryThis(uncurryThis.bind);
1144
1145// optional / simple context binding
1146module.exports = function (fn, that) {
1147 aCallable(fn);
1148 return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
1149 return fn.apply(that, arguments);
1150 };
1151};
1152
1153
1154/***/ }),
1155
1156/***/ 616:
1157/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1158
1159
1160var fails = __webpack_require__(9039);
1161
1162module.exports = !fails(function () {
1163 // eslint-disable-next-line es/no-function-prototype-bind -- safe
1164 var test = (function () { /* empty */ }).bind();
1165 // eslint-disable-next-line no-prototype-builtins -- safe
1166 return typeof test != 'function' || test.hasOwnProperty('prototype');
1167});
1168
1169
1170/***/ }),
1171
1172/***/ 9565:
1173/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1174
1175
1176var NATIVE_BIND = __webpack_require__(616);
1177
1178var call = Function.prototype.call;
1179
1180module.exports = NATIVE_BIND ? call.bind(call) : function () {
1181 return call.apply(call, arguments);
1182};
1183
1184
1185/***/ }),
1186
1187/***/ 350:
1188/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1189
1190
1191var DESCRIPTORS = __webpack_require__(3724);
1192var hasOwn = __webpack_require__(9297);
1193
1194var FunctionPrototype = Function.prototype;
1195// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1196var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
1197
1198var EXISTS = hasOwn(FunctionPrototype, 'name');
1199// additional protection from minified / mangled / dropped function names
1200var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
1201var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
1202
1203module.exports = {
1204 EXISTS: EXISTS,
1205 PROPER: PROPER,
1206 CONFIGURABLE: CONFIGURABLE
1207};
1208
1209
1210/***/ }),
1211
1212/***/ 6706:
1213/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1214
1215
1216var uncurryThis = __webpack_require__(9504);
1217var aCallable = __webpack_require__(9306);
1218
1219module.exports = function (object, key, method) {
1220 try {
1221 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1222 return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
1223 } catch (error) { /* empty */ }
1224};
1225
1226
1227/***/ }),
1228
1229/***/ 7476:
1230/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1231
1232
1233var classofRaw = __webpack_require__(4576);
1234var uncurryThis = __webpack_require__(9504);
1235
1236module.exports = function (fn) {
1237 // Nashorn bug:
1238 // https://github.com/zloirock/core-js/issues/1128
1239 // https://github.com/zloirock/core-js/issues/1130
1240 if (classofRaw(fn) === 'Function') return uncurryThis(fn);
1241};
1242
1243
1244/***/ }),
1245
1246/***/ 9504:
1247/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1248
1249
1250var NATIVE_BIND = __webpack_require__(616);
1251
1252var FunctionPrototype = Function.prototype;
1253var call = FunctionPrototype.call;
1254var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
1255
1256module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
1257 return function () {
1258 return call.apply(fn, arguments);
1259 };
1260};
1261
1262
1263/***/ }),
1264
1265/***/ 7751:
1266/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1267
1268
1269var global = __webpack_require__(4475);
1270var isCallable = __webpack_require__(4901);
1271
1272var aFunction = function (argument) {
1273 return isCallable(argument) ? argument : undefined;
1274};
1275
1276module.exports = function (namespace, method) {
1277 return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
1278};
1279
1280
1281/***/ }),
1282
1283/***/ 1767:
1284/***/ ((module) => {
1285
1286
1287// `GetIteratorDirect(obj)` abstract operation
1288// https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect
1289module.exports = function (obj) {
1290 return {
1291 iterator: obj,
1292 next: obj.next,
1293 done: false
1294 };
1295};
1296
1297
1298/***/ }),
1299
1300/***/ 8646:
1301/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1302
1303
1304var call = __webpack_require__(9565);
1305var anObject = __webpack_require__(8551);
1306var getIteratorDirect = __webpack_require__(1767);
1307var getIteratorMethod = __webpack_require__(851);
1308
1309module.exports = function (obj, stringHandling) {
1310 if (!stringHandling || typeof obj !== 'string') anObject(obj);
1311 var method = getIteratorMethod(obj);
1312 return getIteratorDirect(anObject(method !== undefined ? call(method, obj) : obj));
1313};
1314
1315
1316/***/ }),
1317
1318/***/ 851:
1319/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1320
1321
1322var classof = __webpack_require__(6955);
1323var getMethod = __webpack_require__(5966);
1324var isNullOrUndefined = __webpack_require__(4117);
1325var Iterators = __webpack_require__(6269);
1326var wellKnownSymbol = __webpack_require__(8227);
1327
1328var ITERATOR = wellKnownSymbol('iterator');
1329
1330module.exports = function (it) {
1331 if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
1332 || getMethod(it, '@@iterator')
1333 || Iterators[classof(it)];
1334};
1335
1336
1337/***/ }),
1338
1339/***/ 81:
1340/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1341
1342
1343var call = __webpack_require__(9565);
1344var aCallable = __webpack_require__(9306);
1345var anObject = __webpack_require__(8551);
1346var tryToString = __webpack_require__(6823);
1347var getIteratorMethod = __webpack_require__(851);
1348
1349var $TypeError = TypeError;
1350
1351module.exports = function (argument, usingIterator) {
1352 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
1353 if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
1354 throw new $TypeError(tryToString(argument) + ' is not iterable');
1355};
1356
1357
1358/***/ }),
1359
1360/***/ 5966:
1361/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1362
1363
1364var aCallable = __webpack_require__(9306);
1365var isNullOrUndefined = __webpack_require__(4117);
1366
1367// `GetMethod` abstract operation
1368// https://tc39.es/ecma262/#sec-getmethod
1369module.exports = function (V, P) {
1370 var func = V[P];
1371 return isNullOrUndefined(func) ? undefined : aCallable(func);
1372};
1373
1374
1375/***/ }),
1376
1377/***/ 3789:
1378/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1379
1380
1381var aCallable = __webpack_require__(9306);
1382var anObject = __webpack_require__(8551);
1383var call = __webpack_require__(9565);
1384var toIntegerOrInfinity = __webpack_require__(1291);
1385var getIteratorDirect = __webpack_require__(1767);
1386
1387var INVALID_SIZE = 'Invalid size';
1388var $RangeError = RangeError;
1389var $TypeError = TypeError;
1390var max = Math.max;
1391
1392var SetRecord = function (set, intSize) {
1393 this.set = set;
1394 this.size = max(intSize, 0);
1395 this.has = aCallable(set.has);
1396 this.keys = aCallable(set.keys);
1397};
1398
1399SetRecord.prototype = {
1400 getIterator: function () {
1401 return getIteratorDirect(anObject(call(this.keys, this.set)));
1402 },
1403 includes: function (it) {
1404 return call(this.has, this.set, it);
1405 }
1406};
1407
1408// `GetSetRecord` abstract operation
1409// https://tc39.es/proposal-set-methods/#sec-getsetrecord
1410module.exports = function (obj) {
1411 anObject(obj);
1412 var numSize = +obj.size;
1413 // NOTE: If size is undefined, then numSize will be NaN
1414 // eslint-disable-next-line no-self-compare -- NaN check
1415 if (numSize !== numSize) throw new $TypeError(INVALID_SIZE);
1416 var intSize = toIntegerOrInfinity(numSize);
1417 if (intSize < 0) throw new $RangeError(INVALID_SIZE);
1418 return new SetRecord(obj, intSize);
1419};
1420
1421
1422/***/ }),
1423
1424/***/ 4475:
1425/***/ (function(module) {
1426
1427
1428var check = function (it) {
1429 return it && it.Math === Math && it;
1430};
1431
1432// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
1433module.exports =
1434 // eslint-disable-next-line es/no-global-this -- safe
1435 check(typeof globalThis == 'object' && globalThis) ||
1436 check(typeof window == 'object' && window) ||
1437 // eslint-disable-next-line no-restricted-globals -- safe
1438 check(typeof self == 'object' && self) ||
1439 check(typeof global == 'object' && global) ||
1440 check(typeof this == 'object' && this) ||
1441 // eslint-disable-next-line no-new-func -- fallback
1442 (function () { return this; })() || Function('return this')();
1443
1444
1445/***/ }),
1446
1447/***/ 9297:
1448/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1449
1450
1451var uncurryThis = __webpack_require__(9504);
1452var toObject = __webpack_require__(8981);
1453
1454var hasOwnProperty = uncurryThis({}.hasOwnProperty);
1455
1456// `HasOwnProperty` abstract operation
1457// https://tc39.es/ecma262/#sec-hasownproperty
1458// eslint-disable-next-line es/no-object-hasown -- safe
1459module.exports = Object.hasOwn || function hasOwn(it, key) {
1460 return hasOwnProperty(toObject(it), key);
1461};
1462
1463
1464/***/ }),
1465
1466/***/ 421:
1467/***/ ((module) => {
1468
1469
1470module.exports = {};
1471
1472
1473/***/ }),
1474
1475/***/ 397:
1476/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1477
1478
1479var getBuiltIn = __webpack_require__(7751);
1480
1481module.exports = getBuiltIn('document', 'documentElement');
1482
1483
1484/***/ }),
1485
1486/***/ 5917:
1487/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1488
1489
1490var DESCRIPTORS = __webpack_require__(3724);
1491var fails = __webpack_require__(9039);
1492var createElement = __webpack_require__(4055);
1493
1494// Thanks to IE8 for its funny defineProperty
1495module.exports = !DESCRIPTORS && !fails(function () {
1496 // eslint-disable-next-line es/no-object-defineproperty -- required for testing
1497 return Object.defineProperty(createElement('div'), 'a', {
1498 get: function () { return 7; }
1499 }).a !== 7;
1500});
1501
1502
1503/***/ }),
1504
1505/***/ 7055:
1506/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1507
1508
1509var uncurryThis = __webpack_require__(9504);
1510var fails = __webpack_require__(9039);
1511var classof = __webpack_require__(4576);
1512
1513var $Object = Object;
1514var split = uncurryThis(''.split);
1515
1516// fallback for non-array-like ES3 and non-enumerable old V8 strings
1517module.exports = fails(function () {
1518 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
1519 // eslint-disable-next-line no-prototype-builtins -- safe
1520 return !$Object('z').propertyIsEnumerable(0);
1521}) ? function (it) {
1522 return classof(it) === 'String' ? split(it, '') : $Object(it);
1523} : $Object;
1524
1525
1526/***/ }),
1527
1528/***/ 3167:
1529/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1530
1531
1532var isCallable = __webpack_require__(4901);
1533var isObject = __webpack_require__(34);
1534var setPrototypeOf = __webpack_require__(2967);
1535
1536// makes subclassing work correct for wrapped built-ins
1537module.exports = function ($this, dummy, Wrapper) {
1538 var NewTarget, NewTargetPrototype;
1539 if (
1540 // it can work only with native `setPrototypeOf`
1541 setPrototypeOf &&
1542 // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
1543 isCallable(NewTarget = dummy.constructor) &&
1544 NewTarget !== Wrapper &&
1545 isObject(NewTargetPrototype = NewTarget.prototype) &&
1546 NewTargetPrototype !== Wrapper.prototype
1547 ) setPrototypeOf($this, NewTargetPrototype);
1548 return $this;
1549};
1550
1551
1552/***/ }),
1553
1554/***/ 3706:
1555/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1556
1557
1558var uncurryThis = __webpack_require__(9504);
1559var isCallable = __webpack_require__(4901);
1560var store = __webpack_require__(7629);
1561
1562var functionToString = uncurryThis(Function.toString);
1563
1564// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
1565if (!isCallable(store.inspectSource)) {
1566 store.inspectSource = function (it) {
1567 return functionToString(it);
1568 };
1569}
1570
1571module.exports = store.inspectSource;
1572
1573
1574/***/ }),
1575
1576/***/ 1181:
1577/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1578
1579
1580var NATIVE_WEAK_MAP = __webpack_require__(8622);
1581var global = __webpack_require__(4475);
1582var isObject = __webpack_require__(34);
1583var createNonEnumerableProperty = __webpack_require__(6699);
1584var hasOwn = __webpack_require__(9297);
1585var shared = __webpack_require__(7629);
1586var sharedKey = __webpack_require__(6119);
1587var hiddenKeys = __webpack_require__(421);
1588
1589var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
1590var TypeError = global.TypeError;
1591var WeakMap = global.WeakMap;
1592var set, get, has;
1593
1594var enforce = function (it) {
1595 return has(it) ? get(it) : set(it, {});
1596};
1597
1598var getterFor = function (TYPE) {
1599 return function (it) {
1600 var state;
1601 if (!isObject(it) || (state = get(it)).type !== TYPE) {
1602 throw new TypeError('Incompatible receiver, ' + TYPE + ' required');
1603 } return state;
1604 };
1605};
1606
1607if (NATIVE_WEAK_MAP || shared.state) {
1608 var store = shared.state || (shared.state = new WeakMap());
1609 /* eslint-disable no-self-assign -- prototype methods protection */
1610 store.get = store.get;
1611 store.has = store.has;
1612 store.set = store.set;
1613 /* eslint-enable no-self-assign -- prototype methods protection */
1614 set = function (it, metadata) {
1615 if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
1616 metadata.facade = it;
1617 store.set(it, metadata);
1618 return metadata;
1619 };
1620 get = function (it) {
1621 return store.get(it) || {};
1622 };
1623 has = function (it) {
1624 return store.has(it);
1625 };
1626} else {
1627 var STATE = sharedKey('state');
1628 hiddenKeys[STATE] = true;
1629 set = function (it, metadata) {
1630 if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
1631 metadata.facade = it;
1632 createNonEnumerableProperty(it, STATE, metadata);
1633 return metadata;
1634 };
1635 get = function (it) {
1636 return hasOwn(it, STATE) ? it[STATE] : {};
1637 };
1638 has = function (it) {
1639 return hasOwn(it, STATE);
1640 };
1641}
1642
1643module.exports = {
1644 set: set,
1645 get: get,
1646 has: has,
1647 enforce: enforce,
1648 getterFor: getterFor
1649};
1650
1651
1652/***/ }),
1653
1654/***/ 4209:
1655/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1656
1657
1658var wellKnownSymbol = __webpack_require__(8227);
1659var Iterators = __webpack_require__(6269);
1660
1661var ITERATOR = wellKnownSymbol('iterator');
1662var ArrayPrototype = Array.prototype;
1663
1664// check on default Array iterator
1665module.exports = function (it) {
1666 return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
1667};
1668
1669
1670/***/ }),
1671
1672/***/ 4376:
1673/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1674
1675
1676var classof = __webpack_require__(4576);
1677
1678// `IsArray` abstract operation
1679// https://tc39.es/ecma262/#sec-isarray
1680// eslint-disable-next-line es/no-array-isarray -- safe
1681module.exports = Array.isArray || function isArray(argument) {
1682 return classof(argument) === 'Array';
1683};
1684
1685
1686/***/ }),
1687
1688/***/ 1108:
1689/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1690
1691
1692var classof = __webpack_require__(6955);
1693
1694module.exports = function (it) {
1695 var klass = classof(it);
1696 return klass === 'BigInt64Array' || klass === 'BigUint64Array';
1697};
1698
1699
1700/***/ }),
1701
1702/***/ 4901:
1703/***/ ((module) => {
1704
1705
1706// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
1707var documentAll = typeof document == 'object' && document.all;
1708
1709// `IsCallable` abstract operation
1710// https://tc39.es/ecma262/#sec-iscallable
1711// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
1712module.exports = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
1713 return typeof argument == 'function' || argument === documentAll;
1714} : function (argument) {
1715 return typeof argument == 'function';
1716};
1717
1718
1719/***/ }),
1720
1721/***/ 2796:
1722/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1723
1724
1725var fails = __webpack_require__(9039);
1726var isCallable = __webpack_require__(4901);
1727
1728var replacement = /#|\.prototype\./;
1729
1730var isForced = function (feature, detection) {
1731 var value = data[normalize(feature)];
1732 return value === POLYFILL ? true
1733 : value === NATIVE ? false
1734 : isCallable(detection) ? fails(detection)
1735 : !!detection;
1736};
1737
1738var normalize = isForced.normalize = function (string) {
1739 return String(string).replace(replacement, '.').toLowerCase();
1740};
1741
1742var data = isForced.data = {};
1743var NATIVE = isForced.NATIVE = 'N';
1744var POLYFILL = isForced.POLYFILL = 'P';
1745
1746module.exports = isForced;
1747
1748
1749/***/ }),
1750
1751/***/ 4117:
1752/***/ ((module) => {
1753
1754
1755// we can't use just `it == null` since of `document.all` special case
1756// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
1757module.exports = function (it) {
1758 return it === null || it === undefined;
1759};
1760
1761
1762/***/ }),
1763
1764/***/ 34:
1765/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1766
1767
1768var isCallable = __webpack_require__(4901);
1769
1770module.exports = function (it) {
1771 return typeof it == 'object' ? it !== null : isCallable(it);
1772};
1773
1774
1775/***/ }),
1776
1777/***/ 3925:
1778/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1779
1780
1781var isObject = __webpack_require__(34);
1782
1783module.exports = function (argument) {
1784 return isObject(argument) || argument === null;
1785};
1786
1787
1788/***/ }),
1789
1790/***/ 6395:
1791/***/ ((module) => {
1792
1793
1794module.exports = false;
1795
1796
1797/***/ }),
1798
1799/***/ 757:
1800/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1801
1802
1803var getBuiltIn = __webpack_require__(7751);
1804var isCallable = __webpack_require__(4901);
1805var isPrototypeOf = __webpack_require__(1625);
1806var USE_SYMBOL_AS_UID = __webpack_require__(7040);
1807
1808var $Object = Object;
1809
1810module.exports = USE_SYMBOL_AS_UID ? function (it) {
1811 return typeof it == 'symbol';
1812} : function (it) {
1813 var $Symbol = getBuiltIn('Symbol');
1814 return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
1815};
1816
1817
1818/***/ }),
1819
1820/***/ 507:
1821/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1822
1823
1824var call = __webpack_require__(9565);
1825
1826module.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) {
1827 var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator;
1828 var next = record.next;
1829 var step, result;
1830 while (!(step = call(next, iterator)).done) {
1831 result = fn(step.value);
1832 if (result !== undefined) return result;
1833 }
1834};
1835
1836
1837/***/ }),
1838
1839/***/ 2652:
1840/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1841
1842
1843var bind = __webpack_require__(6080);
1844var call = __webpack_require__(9565);
1845var anObject = __webpack_require__(8551);
1846var tryToString = __webpack_require__(6823);
1847var isArrayIteratorMethod = __webpack_require__(4209);
1848var lengthOfArrayLike = __webpack_require__(6198);
1849var isPrototypeOf = __webpack_require__(1625);
1850var getIterator = __webpack_require__(81);
1851var getIteratorMethod = __webpack_require__(851);
1852var iteratorClose = __webpack_require__(9539);
1853
1854var $TypeError = TypeError;
1855
1856var Result = function (stopped, result) {
1857 this.stopped = stopped;
1858 this.result = result;
1859};
1860
1861var ResultPrototype = Result.prototype;
1862
1863module.exports = function (iterable, unboundFunction, options) {
1864 var that = options && options.that;
1865 var AS_ENTRIES = !!(options && options.AS_ENTRIES);
1866 var IS_RECORD = !!(options && options.IS_RECORD);
1867 var IS_ITERATOR = !!(options && options.IS_ITERATOR);
1868 var INTERRUPTED = !!(options && options.INTERRUPTED);
1869 var fn = bind(unboundFunction, that);
1870 var iterator, iterFn, index, length, result, next, step;
1871
1872 var stop = function (condition) {
1873 if (iterator) iteratorClose(iterator, 'normal', condition);
1874 return new Result(true, condition);
1875 };
1876
1877 var callFn = function (value) {
1878 if (AS_ENTRIES) {
1879 anObject(value);
1880 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
1881 } return INTERRUPTED ? fn(value, stop) : fn(value);
1882 };
1883
1884 if (IS_RECORD) {
1885 iterator = iterable.iterator;
1886 } else if (IS_ITERATOR) {
1887 iterator = iterable;
1888 } else {
1889 iterFn = getIteratorMethod(iterable);
1890 if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable');
1891 // optimisation for array iterators
1892 if (isArrayIteratorMethod(iterFn)) {
1893 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
1894 result = callFn(iterable[index]);
1895 if (result && isPrototypeOf(ResultPrototype, result)) return result;
1896 } return new Result(false);
1897 }
1898 iterator = getIterator(iterable, iterFn);
1899 }
1900
1901 next = IS_RECORD ? iterable.next : iterator.next;
1902 while (!(step = call(next, iterator)).done) {
1903 try {
1904 result = callFn(step.value);
1905 } catch (error) {
1906 iteratorClose(iterator, 'throw', error);
1907 }
1908 if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
1909 } return new Result(false);
1910};
1911
1912
1913/***/ }),
1914
1915/***/ 9539:
1916/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1917
1918
1919var call = __webpack_require__(9565);
1920var anObject = __webpack_require__(8551);
1921var getMethod = __webpack_require__(5966);
1922
1923module.exports = function (iterator, kind, value) {
1924 var innerResult, innerError;
1925 anObject(iterator);
1926 try {
1927 innerResult = getMethod(iterator, 'return');
1928 if (!innerResult) {
1929 if (kind === 'throw') throw value;
1930 return value;
1931 }
1932 innerResult = call(innerResult, iterator);
1933 } catch (error) {
1934 innerError = true;
1935 innerResult = error;
1936 }
1937 if (kind === 'throw') throw value;
1938 if (innerError) throw innerResult;
1939 anObject(innerResult);
1940 return value;
1941};
1942
1943
1944/***/ }),
1945
1946/***/ 9462:
1947/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1948
1949
1950var call = __webpack_require__(9565);
1951var create = __webpack_require__(2360);
1952var createNonEnumerableProperty = __webpack_require__(6699);
1953var defineBuiltIns = __webpack_require__(6279);
1954var wellKnownSymbol = __webpack_require__(8227);
1955var InternalStateModule = __webpack_require__(1181);
1956var getMethod = __webpack_require__(5966);
1957var IteratorPrototype = (__webpack_require__(7657).IteratorPrototype);
1958var createIterResultObject = __webpack_require__(2529);
1959var iteratorClose = __webpack_require__(9539);
1960
1961var TO_STRING_TAG = wellKnownSymbol('toStringTag');
1962var ITERATOR_HELPER = 'IteratorHelper';
1963var WRAP_FOR_VALID_ITERATOR = 'WrapForValidIterator';
1964var setInternalState = InternalStateModule.set;
1965
1966var createIteratorProxyPrototype = function (IS_ITERATOR) {
1967 var getInternalState = InternalStateModule.getterFor(IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER);
1968
1969 return defineBuiltIns(create(IteratorPrototype), {
1970 next: function next() {
1971 var state = getInternalState(this);
1972 // for simplification:
1973 // for `%WrapForValidIteratorPrototype%.next` our `nextHandler` returns `IterResultObject`
1974 // for `%IteratorHelperPrototype%.next` - just a value
1975 if (IS_ITERATOR) return state.nextHandler();
1976 try {
1977 var result = state.done ? undefined : state.nextHandler();
1978 return createIterResultObject(result, state.done);
1979 } catch (error) {
1980 state.done = true;
1981 throw error;
1982 }
1983 },
1984 'return': function () {
1985 var state = getInternalState(this);
1986 var iterator = state.iterator;
1987 state.done = true;
1988 if (IS_ITERATOR) {
1989 var returnMethod = getMethod(iterator, 'return');
1990 return returnMethod ? call(returnMethod, iterator) : createIterResultObject(undefined, true);
1991 }
1992 if (state.inner) try {
1993 iteratorClose(state.inner.iterator, 'normal');
1994 } catch (error) {
1995 return iteratorClose(iterator, 'throw', error);
1996 }
1997 iteratorClose(iterator, 'normal');
1998 return createIterResultObject(undefined, true);
1999 }
2000 });
2001};
2002
2003var WrapForValidIteratorPrototype = createIteratorProxyPrototype(true);
2004var IteratorHelperPrototype = createIteratorProxyPrototype(false);
2005
2006createNonEnumerableProperty(IteratorHelperPrototype, TO_STRING_TAG, 'Iterator Helper');
2007
2008module.exports = function (nextHandler, IS_ITERATOR) {
2009 var IteratorProxy = function Iterator(record, state) {
2010 if (state) {
2011 state.iterator = record.iterator;
2012 state.next = record.next;
2013 } else state = record;
2014 state.type = IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER;
2015 state.nextHandler = nextHandler;
2016 state.counter = 0;
2017 state.done = false;
2018 setInternalState(this, state);
2019 };
2020
2021 IteratorProxy.prototype = IS_ITERATOR ? WrapForValidIteratorPrototype : IteratorHelperPrototype;
2022
2023 return IteratorProxy;
2024};
2025
2026
2027/***/ }),
2028
2029/***/ 713:
2030/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2031
2032
2033var call = __webpack_require__(9565);
2034var aCallable = __webpack_require__(9306);
2035var anObject = __webpack_require__(8551);
2036var getIteratorDirect = __webpack_require__(1767);
2037var createIteratorProxy = __webpack_require__(9462);
2038var callWithSafeIterationClosing = __webpack_require__(6319);
2039
2040var IteratorProxy = createIteratorProxy(function () {
2041 var iterator = this.iterator;
2042 var result = anObject(call(this.next, iterator));
2043 var done = this.done = !!result.done;
2044 if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true);
2045});
2046
2047// `Iterator.prototype.map` method
2048// https://github.com/tc39/proposal-iterator-helpers
2049module.exports = function map(mapper) {
2050 anObject(this);
2051 aCallable(mapper);
2052 return new IteratorProxy(getIteratorDirect(this), {
2053 mapper: mapper
2054 });
2055};
2056
2057
2058/***/ }),
2059
2060/***/ 7657:
2061/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2062
2063
2064var fails = __webpack_require__(9039);
2065var isCallable = __webpack_require__(4901);
2066var isObject = __webpack_require__(34);
2067var create = __webpack_require__(2360);
2068var getPrototypeOf = __webpack_require__(2787);
2069var defineBuiltIn = __webpack_require__(6840);
2070var wellKnownSymbol = __webpack_require__(8227);
2071var IS_PURE = __webpack_require__(6395);
2072
2073var ITERATOR = wellKnownSymbol('iterator');
2074var BUGGY_SAFARI_ITERATORS = false;
2075
2076// `%IteratorPrototype%` object
2077// https://tc39.es/ecma262/#sec-%iteratorprototype%-object
2078var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
2079
2080/* eslint-disable es/no-array-prototype-keys -- safe */
2081if ([].keys) {
2082 arrayIterator = [].keys();
2083 // Safari 8 has buggy iterators w/o `next`
2084 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
2085 else {
2086 PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
2087 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
2088 }
2089}
2090
2091var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
2092 var test = {};
2093 // FF44- legacy iterators case
2094 return IteratorPrototype[ITERATOR].call(test) !== test;
2095});
2096
2097if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
2098else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
2099
2100// `%IteratorPrototype%[@@iterator]()` method
2101// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
2102if (!isCallable(IteratorPrototype[ITERATOR])) {
2103 defineBuiltIn(IteratorPrototype, ITERATOR, function () {
2104 return this;
2105 });
2106}
2107
2108module.exports = {
2109 IteratorPrototype: IteratorPrototype,
2110 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
2111};
2112
2113
2114/***/ }),
2115
2116/***/ 6269:
2117/***/ ((module) => {
2118
2119
2120module.exports = {};
2121
2122
2123/***/ }),
2124
2125/***/ 6198:
2126/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2127
2128
2129var toLength = __webpack_require__(8014);
2130
2131// `LengthOfArrayLike` abstract operation
2132// https://tc39.es/ecma262/#sec-lengthofarraylike
2133module.exports = function (obj) {
2134 return toLength(obj.length);
2135};
2136
2137
2138/***/ }),
2139
2140/***/ 283:
2141/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2142
2143
2144var uncurryThis = __webpack_require__(9504);
2145var fails = __webpack_require__(9039);
2146var isCallable = __webpack_require__(4901);
2147var hasOwn = __webpack_require__(9297);
2148var DESCRIPTORS = __webpack_require__(3724);
2149var CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(350).CONFIGURABLE);
2150var inspectSource = __webpack_require__(3706);
2151var InternalStateModule = __webpack_require__(1181);
2152
2153var enforceInternalState = InternalStateModule.enforce;
2154var getInternalState = InternalStateModule.get;
2155var $String = String;
2156// eslint-disable-next-line es/no-object-defineproperty -- safe
2157var defineProperty = Object.defineProperty;
2158var stringSlice = uncurryThis(''.slice);
2159var replace = uncurryThis(''.replace);
2160var join = uncurryThis([].join);
2161
2162var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
2163 return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
2164});
2165
2166var TEMPLATE = String(String).split('String');
2167
2168var makeBuiltIn = module.exports = function (value, name, options) {
2169 if (stringSlice($String(name), 0, 7) === 'Symbol(') {
2170 name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
2171 }
2172 if (options && options.getter) name = 'get ' + name;
2173 if (options && options.setter) name = 'set ' + name;
2174 if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
2175 if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true });
2176 else value.name = name;
2177 }
2178 if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
2179 defineProperty(value, 'length', { value: options.arity });
2180 }
2181 try {
2182 if (options && hasOwn(options, 'constructor') && options.constructor) {
2183 if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false });
2184 // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
2185 } else if (value.prototype) value.prototype = undefined;
2186 } catch (error) { /* empty */ }
2187 var state = enforceInternalState(value);
2188 if (!hasOwn(state, 'source')) {
2189 state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
2190 } return value;
2191};
2192
2193// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
2194// eslint-disable-next-line no-extend-native -- required
2195Function.prototype.toString = makeBuiltIn(function toString() {
2196 return isCallable(this) && getInternalState(this).source || inspectSource(this);
2197}, 'toString');
2198
2199
2200/***/ }),
2201
2202/***/ 741:
2203/***/ ((module) => {
2204
2205
2206var ceil = Math.ceil;
2207var floor = Math.floor;
2208
2209// `Math.trunc` method
2210// https://tc39.es/ecma262/#sec-math.trunc
2211// eslint-disable-next-line es/no-math-trunc -- safe
2212module.exports = Math.trunc || function trunc(x) {
2213 var n = +x;
2214 return (n > 0 ? floor : ceil)(n);
2215};
2216
2217
2218/***/ }),
2219
2220/***/ 6043:
2221/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2222
2223
2224var aCallable = __webpack_require__(9306);
2225
2226var $TypeError = TypeError;
2227
2228var PromiseCapability = function (C) {
2229 var resolve, reject;
2230 this.promise = new C(function ($$resolve, $$reject) {
2231 if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor');
2232 resolve = $$resolve;
2233 reject = $$reject;
2234 });
2235 this.resolve = aCallable(resolve);
2236 this.reject = aCallable(reject);
2237};
2238
2239// `NewPromiseCapability` abstract operation
2240// https://tc39.es/ecma262/#sec-newpromisecapability
2241module.exports.f = function (C) {
2242 return new PromiseCapability(C);
2243};
2244
2245
2246/***/ }),
2247
2248/***/ 2603:
2249/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2250
2251
2252var toString = __webpack_require__(655);
2253
2254module.exports = function (argument, $default) {
2255 return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
2256};
2257
2258
2259/***/ }),
2260
2261/***/ 2360:
2262/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2263
2264
2265/* global ActiveXObject -- old IE, WSH */
2266var anObject = __webpack_require__(8551);
2267var definePropertiesModule = __webpack_require__(6801);
2268var enumBugKeys = __webpack_require__(8727);
2269var hiddenKeys = __webpack_require__(421);
2270var html = __webpack_require__(397);
2271var documentCreateElement = __webpack_require__(4055);
2272var sharedKey = __webpack_require__(6119);
2273
2274var GT = '>';
2275var LT = '<';
2276var PROTOTYPE = 'prototype';
2277var SCRIPT = 'script';
2278var IE_PROTO = sharedKey('IE_PROTO');
2279
2280var EmptyConstructor = function () { /* empty */ };
2281
2282var scriptTag = function (content) {
2283 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
2284};
2285
2286// Create object with fake `null` prototype: use ActiveX Object with cleared prototype
2287var NullProtoObjectViaActiveX = function (activeXDocument) {
2288 activeXDocument.write(scriptTag(''));
2289 activeXDocument.close();
2290 var temp = activeXDocument.parentWindow.Object;
2291 activeXDocument = null; // avoid memory leak
2292 return temp;
2293};
2294
2295// Create object with fake `null` prototype: use iframe Object with cleared prototype
2296var NullProtoObjectViaIFrame = function () {
2297 // Thrash, waste and sodomy: IE GC bug
2298 var iframe = documentCreateElement('iframe');
2299 var JS = 'java' + SCRIPT + ':';
2300 var iframeDocument;
2301 iframe.style.display = 'none';
2302 html.appendChild(iframe);
2303 // https://github.com/zloirock/core-js/issues/475
2304 iframe.src = String(JS);
2305 iframeDocument = iframe.contentWindow.document;
2306 iframeDocument.open();
2307 iframeDocument.write(scriptTag('document.F=Object'));
2308 iframeDocument.close();
2309 return iframeDocument.F;
2310};
2311
2312// Check for document.domain and active x support
2313// No need to use active x approach when document.domain is not set
2314// see https://github.com/es-shims/es5-shim/issues/150
2315// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
2316// avoid IE GC bug
2317var activeXDocument;
2318var NullProtoObject = function () {
2319 try {
2320 activeXDocument = new ActiveXObject('htmlfile');
2321 } catch (error) { /* ignore */ }
2322 NullProtoObject = typeof document != 'undefined'
2323 ? document.domain && activeXDocument
2324 ? NullProtoObjectViaActiveX(activeXDocument) // old IE
2325 : NullProtoObjectViaIFrame()
2326 : NullProtoObjectViaActiveX(activeXDocument); // WSH
2327 var length = enumBugKeys.length;
2328 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
2329 return NullProtoObject();
2330};
2331
2332hiddenKeys[IE_PROTO] = true;
2333
2334// `Object.create` method
2335// https://tc39.es/ecma262/#sec-object.create
2336// eslint-disable-next-line es/no-object-create -- safe
2337module.exports = Object.create || function create(O, Properties) {
2338 var result;
2339 if (O !== null) {
2340 EmptyConstructor[PROTOTYPE] = anObject(O);
2341 result = new EmptyConstructor();
2342 EmptyConstructor[PROTOTYPE] = null;
2343 // add "__proto__" for Object.getPrototypeOf polyfill
2344 result[IE_PROTO] = O;
2345 } else result = NullProtoObject();
2346 return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
2347};
2348
2349
2350/***/ }),
2351
2352/***/ 6801:
2353/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2354
2355
2356var DESCRIPTORS = __webpack_require__(3724);
2357var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(8686);
2358var definePropertyModule = __webpack_require__(4913);
2359var anObject = __webpack_require__(8551);
2360var toIndexedObject = __webpack_require__(5397);
2361var objectKeys = __webpack_require__(1072);
2362
2363// `Object.defineProperties` method
2364// https://tc39.es/ecma262/#sec-object.defineproperties
2365// eslint-disable-next-line es/no-object-defineproperties -- safe
2366exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
2367 anObject(O);
2368 var props = toIndexedObject(Properties);
2369 var keys = objectKeys(Properties);
2370 var length = keys.length;
2371 var index = 0;
2372 var key;
2373 while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
2374 return O;
2375};
2376
2377
2378/***/ }),
2379
2380/***/ 4913:
2381/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2382
2383
2384var DESCRIPTORS = __webpack_require__(3724);
2385var IE8_DOM_DEFINE = __webpack_require__(5917);
2386var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(8686);
2387var anObject = __webpack_require__(8551);
2388var toPropertyKey = __webpack_require__(6969);
2389
2390var $TypeError = TypeError;
2391// eslint-disable-next-line es/no-object-defineproperty -- safe
2392var $defineProperty = Object.defineProperty;
2393// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
2394var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2395var ENUMERABLE = 'enumerable';
2396var CONFIGURABLE = 'configurable';
2397var WRITABLE = 'writable';
2398
2399// `Object.defineProperty` method
2400// https://tc39.es/ecma262/#sec-object.defineproperty
2401exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
2402 anObject(O);
2403 P = toPropertyKey(P);
2404 anObject(Attributes);
2405 if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
2406 var current = $getOwnPropertyDescriptor(O, P);
2407 if (current && current[WRITABLE]) {
2408 O[P] = Attributes.value;
2409 Attributes = {
2410 configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
2411 enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
2412 writable: false
2413 };
2414 }
2415 } return $defineProperty(O, P, Attributes);
2416} : $defineProperty : function defineProperty(O, P, Attributes) {
2417 anObject(O);
2418 P = toPropertyKey(P);
2419 anObject(Attributes);
2420 if (IE8_DOM_DEFINE) try {
2421 return $defineProperty(O, P, Attributes);
2422 } catch (error) { /* empty */ }
2423 if ('get' in Attributes || 'set' in Attributes) throw new $TypeError('Accessors not supported');
2424 if ('value' in Attributes) O[P] = Attributes.value;
2425 return O;
2426};
2427
2428
2429/***/ }),
2430
2431/***/ 7347:
2432/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2433
2434
2435var DESCRIPTORS = __webpack_require__(3724);
2436var call = __webpack_require__(9565);
2437var propertyIsEnumerableModule = __webpack_require__(8773);
2438var createPropertyDescriptor = __webpack_require__(6980);
2439var toIndexedObject = __webpack_require__(5397);
2440var toPropertyKey = __webpack_require__(6969);
2441var hasOwn = __webpack_require__(9297);
2442var IE8_DOM_DEFINE = __webpack_require__(5917);
2443
2444// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
2445var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2446
2447// `Object.getOwnPropertyDescriptor` method
2448// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
2449exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
2450 O = toIndexedObject(O);
2451 P = toPropertyKey(P);
2452 if (IE8_DOM_DEFINE) try {
2453 return $getOwnPropertyDescriptor(O, P);
2454 } catch (error) { /* empty */ }
2455 if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
2456};
2457
2458
2459/***/ }),
2460
2461/***/ 8480:
2462/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2463
2464
2465var internalObjectKeys = __webpack_require__(1828);
2466var enumBugKeys = __webpack_require__(8727);
2467
2468var hiddenKeys = enumBugKeys.concat('length', 'prototype');
2469
2470// `Object.getOwnPropertyNames` method
2471// https://tc39.es/ecma262/#sec-object.getownpropertynames
2472// eslint-disable-next-line es/no-object-getownpropertynames -- safe
2473exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
2474 return internalObjectKeys(O, hiddenKeys);
2475};
2476
2477
2478/***/ }),
2479
2480/***/ 3717:
2481/***/ ((__unused_webpack_module, exports) => {
2482
2483
2484// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
2485exports.f = Object.getOwnPropertySymbols;
2486
2487
2488/***/ }),
2489
2490/***/ 2787:
2491/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2492
2493
2494var hasOwn = __webpack_require__(9297);
2495var isCallable = __webpack_require__(4901);
2496var toObject = __webpack_require__(8981);
2497var sharedKey = __webpack_require__(6119);
2498var CORRECT_PROTOTYPE_GETTER = __webpack_require__(2211);
2499
2500var IE_PROTO = sharedKey('IE_PROTO');
2501var $Object = Object;
2502var ObjectPrototype = $Object.prototype;
2503
2504// `Object.getPrototypeOf` method
2505// https://tc39.es/ecma262/#sec-object.getprototypeof
2506// eslint-disable-next-line es/no-object-getprototypeof -- safe
2507module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
2508 var object = toObject(O);
2509 if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
2510 var constructor = object.constructor;
2511 if (isCallable(constructor) && object instanceof constructor) {
2512 return constructor.prototype;
2513 } return object instanceof $Object ? ObjectPrototype : null;
2514};
2515
2516
2517/***/ }),
2518
2519/***/ 1625:
2520/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2521
2522
2523var uncurryThis = __webpack_require__(9504);
2524
2525module.exports = uncurryThis({}.isPrototypeOf);
2526
2527
2528/***/ }),
2529
2530/***/ 1828:
2531/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2532
2533
2534var uncurryThis = __webpack_require__(9504);
2535var hasOwn = __webpack_require__(9297);
2536var toIndexedObject = __webpack_require__(5397);
2537var indexOf = (__webpack_require__(9617).indexOf);
2538var hiddenKeys = __webpack_require__(421);
2539
2540var push = uncurryThis([].push);
2541
2542module.exports = function (object, names) {
2543 var O = toIndexedObject(object);
2544 var i = 0;
2545 var result = [];
2546 var key;
2547 for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
2548 // Don't enum bug & hidden keys
2549 while (names.length > i) if (hasOwn(O, key = names[i++])) {
2550 ~indexOf(result, key) || push(result, key);
2551 }
2552 return result;
2553};
2554
2555
2556/***/ }),
2557
2558/***/ 1072:
2559/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2560
2561
2562var internalObjectKeys = __webpack_require__(1828);
2563var enumBugKeys = __webpack_require__(8727);
2564
2565// `Object.keys` method
2566// https://tc39.es/ecma262/#sec-object.keys
2567// eslint-disable-next-line es/no-object-keys -- safe
2568module.exports = Object.keys || function keys(O) {
2569 return internalObjectKeys(O, enumBugKeys);
2570};
2571
2572
2573/***/ }),
2574
2575/***/ 8773:
2576/***/ ((__unused_webpack_module, exports) => {
2577
2578
2579var $propertyIsEnumerable = {}.propertyIsEnumerable;
2580// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
2581var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2582
2583// Nashorn ~ JDK8 bug
2584var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
2585
2586// `Object.prototype.propertyIsEnumerable` method implementation
2587// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
2588exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
2589 var descriptor = getOwnPropertyDescriptor(this, V);
2590 return !!descriptor && descriptor.enumerable;
2591} : $propertyIsEnumerable;
2592
2593
2594/***/ }),
2595
2596/***/ 2967:
2597/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2598
2599
2600/* eslint-disable no-proto -- safe */
2601var uncurryThisAccessor = __webpack_require__(6706);
2602var isObject = __webpack_require__(34);
2603var requireObjectCoercible = __webpack_require__(7750);
2604var aPossiblePrototype = __webpack_require__(3506);
2605
2606// `Object.setPrototypeOf` method
2607// https://tc39.es/ecma262/#sec-object.setprototypeof
2608// Works with __proto__ only. Old v8 can't work with null proto objects.
2609// eslint-disable-next-line es/no-object-setprototypeof -- safe
2610module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
2611 var CORRECT_SETTER = false;
2612 var test = {};
2613 var setter;
2614 try {
2615 setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
2616 setter(test, []);
2617 CORRECT_SETTER = test instanceof Array;
2618 } catch (error) { /* empty */ }
2619 return function setPrototypeOf(O, proto) {
2620 requireObjectCoercible(O);
2621 aPossiblePrototype(proto);
2622 if (!isObject(O)) return O;
2623 if (CORRECT_SETTER) setter(O, proto);
2624 else O.__proto__ = proto;
2625 return O;
2626 };
2627}() : undefined);
2628
2629
2630/***/ }),
2631
2632/***/ 4270:
2633/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2634
2635
2636var call = __webpack_require__(9565);
2637var isCallable = __webpack_require__(4901);
2638var isObject = __webpack_require__(34);
2639
2640var $TypeError = TypeError;
2641
2642// `OrdinaryToPrimitive` abstract operation
2643// https://tc39.es/ecma262/#sec-ordinarytoprimitive
2644module.exports = function (input, pref) {
2645 var fn, val;
2646 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
2647 if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
2648 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
2649 throw new $TypeError("Can't convert object to primitive value");
2650};
2651
2652
2653/***/ }),
2654
2655/***/ 5031:
2656/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2657
2658
2659var getBuiltIn = __webpack_require__(7751);
2660var uncurryThis = __webpack_require__(9504);
2661var getOwnPropertyNamesModule = __webpack_require__(8480);
2662var getOwnPropertySymbolsModule = __webpack_require__(3717);
2663var anObject = __webpack_require__(8551);
2664
2665var concat = uncurryThis([].concat);
2666
2667// all object keys, includes non-enumerable and symbols
2668module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
2669 var keys = getOwnPropertyNamesModule.f(anObject(it));
2670 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
2671 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
2672};
2673
2674
2675/***/ }),
2676
2677/***/ 8235:
2678/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2679
2680
2681var uncurryThis = __webpack_require__(9504);
2682var hasOwn = __webpack_require__(9297);
2683
2684var $SyntaxError = SyntaxError;
2685var $parseInt = parseInt;
2686var fromCharCode = String.fromCharCode;
2687var at = uncurryThis(''.charAt);
2688var slice = uncurryThis(''.slice);
2689var exec = uncurryThis(/./.exec);
2690
2691var codePoints = {
2692 '\\"': '"',
2693 '\\\\': '\\',
2694 '\\/': '/',
2695 '\\b': '\b',
2696 '\\f': '\f',
2697 '\\n': '\n',
2698 '\\r': '\r',
2699 '\\t': '\t'
2700};
2701
2702var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i;
2703// eslint-disable-next-line regexp/no-control-character -- safe
2704var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/;
2705
2706module.exports = function (source, i) {
2707 var unterminated = true;
2708 var value = '';
2709 while (i < source.length) {
2710 var chr = at(source, i);
2711 if (chr === '\\') {
2712 var twoChars = slice(source, i, i + 2);
2713 if (hasOwn(codePoints, twoChars)) {
2714 value += codePoints[twoChars];
2715 i += 2;
2716 } else if (twoChars === '\\u') {
2717 i += 2;
2718 var fourHexDigits = slice(source, i, i + 4);
2719 if (!exec(IS_4_HEX_DIGITS, fourHexDigits)) throw new $SyntaxError('Bad Unicode escape at: ' + i);
2720 value += fromCharCode($parseInt(fourHexDigits, 16));
2721 i += 4;
2722 } else throw new $SyntaxError('Unknown escape sequence: "' + twoChars + '"');
2723 } else if (chr === '"') {
2724 unterminated = false;
2725 i++;
2726 break;
2727 } else {
2728 if (exec(IS_C0_CONTROL_CODE, chr)) throw new $SyntaxError('Bad control character in string literal at: ' + i);
2729 value += chr;
2730 i++;
2731 }
2732 }
2733 if (unterminated) throw new $SyntaxError('Unterminated string at: ' + i);
2734 return { value: value, end: i };
2735};
2736
2737
2738/***/ }),
2739
2740/***/ 7750:
2741/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2742
2743
2744var isNullOrUndefined = __webpack_require__(4117);
2745
2746var $TypeError = TypeError;
2747
2748// `RequireObjectCoercible` abstract operation
2749// https://tc39.es/ecma262/#sec-requireobjectcoercible
2750module.exports = function (it) {
2751 if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it);
2752 return it;
2753};
2754
2755
2756/***/ }),
2757
2758/***/ 9286:
2759/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2760
2761
2762var SetHelpers = __webpack_require__(4402);
2763var iterate = __webpack_require__(8469);
2764
2765var Set = SetHelpers.Set;
2766var add = SetHelpers.add;
2767
2768module.exports = function (set) {
2769 var result = new Set();
2770 iterate(set, function (it) {
2771 add(result, it);
2772 });
2773 return result;
2774};
2775
2776
2777/***/ }),
2778
2779/***/ 3440:
2780/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2781
2782
2783var aSet = __webpack_require__(7080);
2784var SetHelpers = __webpack_require__(4402);
2785var clone = __webpack_require__(9286);
2786var size = __webpack_require__(5170);
2787var getSetRecord = __webpack_require__(3789);
2788var iterateSet = __webpack_require__(8469);
2789var iterateSimple = __webpack_require__(507);
2790
2791var has = SetHelpers.has;
2792var remove = SetHelpers.remove;
2793
2794// `Set.prototype.difference` method
2795// https://github.com/tc39/proposal-set-methods
2796module.exports = function difference(other) {
2797 var O = aSet(this);
2798 var otherRec = getSetRecord(other);
2799 var result = clone(O);
2800 if (size(O) <= otherRec.size) iterateSet(O, function (e) {
2801 if (otherRec.includes(e)) remove(result, e);
2802 });
2803 else iterateSimple(otherRec.getIterator(), function (e) {
2804 if (has(O, e)) remove(result, e);
2805 });
2806 return result;
2807};
2808
2809
2810/***/ }),
2811
2812/***/ 4402:
2813/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2814
2815
2816var uncurryThis = __webpack_require__(9504);
2817
2818// eslint-disable-next-line es/no-set -- safe
2819var SetPrototype = Set.prototype;
2820
2821module.exports = {
2822 // eslint-disable-next-line es/no-set -- safe
2823 Set: Set,
2824 add: uncurryThis(SetPrototype.add),
2825 has: uncurryThis(SetPrototype.has),
2826 remove: uncurryThis(SetPrototype['delete']),
2827 proto: SetPrototype
2828};
2829
2830
2831/***/ }),
2832
2833/***/ 8750:
2834/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2835
2836
2837var aSet = __webpack_require__(7080);
2838var SetHelpers = __webpack_require__(4402);
2839var size = __webpack_require__(5170);
2840var getSetRecord = __webpack_require__(3789);
2841var iterateSet = __webpack_require__(8469);
2842var iterateSimple = __webpack_require__(507);
2843
2844var Set = SetHelpers.Set;
2845var add = SetHelpers.add;
2846var has = SetHelpers.has;
2847
2848// `Set.prototype.intersection` method
2849// https://github.com/tc39/proposal-set-methods
2850module.exports = function intersection(other) {
2851 var O = aSet(this);
2852 var otherRec = getSetRecord(other);
2853 var result = new Set();
2854
2855 if (size(O) > otherRec.size) {
2856 iterateSimple(otherRec.getIterator(), function (e) {
2857 if (has(O, e)) add(result, e);
2858 });
2859 } else {
2860 iterateSet(O, function (e) {
2861 if (otherRec.includes(e)) add(result, e);
2862 });
2863 }
2864
2865 return result;
2866};
2867
2868
2869/***/ }),
2870
2871/***/ 4449:
2872/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2873
2874
2875var aSet = __webpack_require__(7080);
2876var has = (__webpack_require__(4402).has);
2877var size = __webpack_require__(5170);
2878var getSetRecord = __webpack_require__(3789);
2879var iterateSet = __webpack_require__(8469);
2880var iterateSimple = __webpack_require__(507);
2881var iteratorClose = __webpack_require__(9539);
2882
2883// `Set.prototype.isDisjointFrom` method
2884// https://tc39.github.io/proposal-set-methods/#Set.prototype.isDisjointFrom
2885module.exports = function isDisjointFrom(other) {
2886 var O = aSet(this);
2887 var otherRec = getSetRecord(other);
2888 if (size(O) <= otherRec.size) return iterateSet(O, function (e) {
2889 if (otherRec.includes(e)) return false;
2890 }, true) !== false;
2891 var iterator = otherRec.getIterator();
2892 return iterateSimple(iterator, function (e) {
2893 if (has(O, e)) return iteratorClose(iterator, 'normal', false);
2894 }) !== false;
2895};
2896
2897
2898/***/ }),
2899
2900/***/ 3838:
2901/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2902
2903
2904var aSet = __webpack_require__(7080);
2905var size = __webpack_require__(5170);
2906var iterate = __webpack_require__(8469);
2907var getSetRecord = __webpack_require__(3789);
2908
2909// `Set.prototype.isSubsetOf` method
2910// https://tc39.github.io/proposal-set-methods/#Set.prototype.isSubsetOf
2911module.exports = function isSubsetOf(other) {
2912 var O = aSet(this);
2913 var otherRec = getSetRecord(other);
2914 if (size(O) > otherRec.size) return false;
2915 return iterate(O, function (e) {
2916 if (!otherRec.includes(e)) return false;
2917 }, true) !== false;
2918};
2919
2920
2921/***/ }),
2922
2923/***/ 8527:
2924/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2925
2926
2927var aSet = __webpack_require__(7080);
2928var has = (__webpack_require__(4402).has);
2929var size = __webpack_require__(5170);
2930var getSetRecord = __webpack_require__(3789);
2931var iterateSimple = __webpack_require__(507);
2932var iteratorClose = __webpack_require__(9539);
2933
2934// `Set.prototype.isSupersetOf` method
2935// https://tc39.github.io/proposal-set-methods/#Set.prototype.isSupersetOf
2936module.exports = function isSupersetOf(other) {
2937 var O = aSet(this);
2938 var otherRec = getSetRecord(other);
2939 if (size(O) < otherRec.size) return false;
2940 var iterator = otherRec.getIterator();
2941 return iterateSimple(iterator, function (e) {
2942 if (!has(O, e)) return iteratorClose(iterator, 'normal', false);
2943 }) !== false;
2944};
2945
2946
2947/***/ }),
2948
2949/***/ 8469:
2950/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2951
2952
2953var uncurryThis = __webpack_require__(9504);
2954var iterateSimple = __webpack_require__(507);
2955var SetHelpers = __webpack_require__(4402);
2956
2957var Set = SetHelpers.Set;
2958var SetPrototype = SetHelpers.proto;
2959var forEach = uncurryThis(SetPrototype.forEach);
2960var keys = uncurryThis(SetPrototype.keys);
2961var next = keys(new Set()).next;
2962
2963module.exports = function (set, fn, interruptible) {
2964 return interruptible ? iterateSimple({ iterator: keys(set), next: next }, fn) : forEach(set, fn);
2965};
2966
2967
2968/***/ }),
2969
2970/***/ 4916:
2971/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2972
2973
2974var getBuiltIn = __webpack_require__(7751);
2975
2976var createSetLike = function (size) {
2977 return {
2978 size: size,
2979 has: function () {
2980 return false;
2981 },
2982 keys: function () {
2983 return {
2984 next: function () {
2985 return { done: true };
2986 }
2987 };
2988 }
2989 };
2990};
2991
2992module.exports = function (name) {
2993 var Set = getBuiltIn('Set');
2994 try {
2995 new Set()[name](createSetLike(0));
2996 try {
2997 // late spec change, early WebKit ~ Safari 17.0 beta implementation does not pass it
2998 // https://github.com/tc39/proposal-set-methods/pull/88
2999 new Set()[name](createSetLike(-1));
3000 return false;
3001 } catch (error2) {
3002 return true;
3003 }
3004 } catch (error) {
3005 return false;
3006 }
3007};
3008
3009
3010/***/ }),
3011
3012/***/ 5170:
3013/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3014
3015
3016var uncurryThisAccessor = __webpack_require__(6706);
3017var SetHelpers = __webpack_require__(4402);
3018
3019module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) {
3020 return set.size;
3021};
3022
3023
3024/***/ }),
3025
3026/***/ 3650:
3027/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3028
3029
3030var aSet = __webpack_require__(7080);
3031var SetHelpers = __webpack_require__(4402);
3032var clone = __webpack_require__(9286);
3033var getSetRecord = __webpack_require__(3789);
3034var iterateSimple = __webpack_require__(507);
3035
3036var add = SetHelpers.add;
3037var has = SetHelpers.has;
3038var remove = SetHelpers.remove;
3039
3040// `Set.prototype.symmetricDifference` method
3041// https://github.com/tc39/proposal-set-methods
3042module.exports = function symmetricDifference(other) {
3043 var O = aSet(this);
3044 var keysIter = getSetRecord(other).getIterator();
3045 var result = clone(O);
3046 iterateSimple(keysIter, function (e) {
3047 if (has(O, e)) remove(result, e);
3048 else add(result, e);
3049 });
3050 return result;
3051};
3052
3053
3054/***/ }),
3055
3056/***/ 4204:
3057/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3058
3059
3060var aSet = __webpack_require__(7080);
3061var add = (__webpack_require__(4402).add);
3062var clone = __webpack_require__(9286);
3063var getSetRecord = __webpack_require__(3789);
3064var iterateSimple = __webpack_require__(507);
3065
3066// `Set.prototype.union` method
3067// https://github.com/tc39/proposal-set-methods
3068module.exports = function union(other) {
3069 var O = aSet(this);
3070 var keysIter = getSetRecord(other).getIterator();
3071 var result = clone(O);
3072 iterateSimple(keysIter, function (it) {
3073 add(result, it);
3074 });
3075 return result;
3076};
3077
3078
3079/***/ }),
3080
3081/***/ 6119:
3082/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3083
3084
3085var shared = __webpack_require__(5745);
3086var uid = __webpack_require__(3392);
3087
3088var keys = shared('keys');
3089
3090module.exports = function (key) {
3091 return keys[key] || (keys[key] = uid(key));
3092};
3093
3094
3095/***/ }),
3096
3097/***/ 7629:
3098/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3099
3100
3101var IS_PURE = __webpack_require__(6395);
3102var globalThis = __webpack_require__(4475);
3103var defineGlobalProperty = __webpack_require__(9433);
3104
3105var SHARED = '__core-js_shared__';
3106var store = module.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
3107
3108(store.versions || (store.versions = [])).push({
3109 version: '3.36.1',
3110 mode: IS_PURE ? 'pure' : 'global',
3111 copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
3112 license: 'https://github.com/zloirock/core-js/blob/v3.36.1/LICENSE',
3113 source: 'https://github.com/zloirock/core-js'
3114});
3115
3116
3117/***/ }),
3118
3119/***/ 5745:
3120/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3121
3122
3123var store = __webpack_require__(7629);
3124
3125module.exports = function (key, value) {
3126 return store[key] || (store[key] = value || {});
3127};
3128
3129
3130/***/ }),
3131
3132/***/ 1548:
3133/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3134
3135
3136var global = __webpack_require__(4475);
3137var fails = __webpack_require__(9039);
3138var V8 = __webpack_require__(7388);
3139var IS_BROWSER = __webpack_require__(7290);
3140var IS_DENO = __webpack_require__(516);
3141var IS_NODE = __webpack_require__(9088);
3142
3143var structuredClone = global.structuredClone;
3144
3145module.exports = !!structuredClone && !fails(function () {
3146 // prevent V8 ArrayBufferDetaching protector cell invalidation and performance degradation
3147 // https://github.com/zloirock/core-js/issues/679
3148 if ((IS_DENO && V8 > 92) || (IS_NODE && V8 > 94) || (IS_BROWSER && V8 > 97)) return false;
3149 var buffer = new ArrayBuffer(8);
3150 var clone = structuredClone(buffer, { transfer: [buffer] });
3151 return buffer.byteLength !== 0 || clone.byteLength !== 8;
3152});
3153
3154
3155/***/ }),
3156
3157/***/ 4495:
3158/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3159
3160
3161/* eslint-disable es/no-symbol -- required for testing */
3162var V8_VERSION = __webpack_require__(7388);
3163var fails = __webpack_require__(9039);
3164var global = __webpack_require__(4475);
3165
3166var $String = global.String;
3167
3168// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
3169module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
3170 var symbol = Symbol('symbol detection');
3171 // Chrome 38 Symbol has incorrect toString conversion
3172 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
3173 // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
3174 // of course, fail.
3175 return !$String(symbol) || !(Object(symbol) instanceof Symbol) ||
3176 // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
3177 !Symbol.sham && V8_VERSION && V8_VERSION < 41;
3178});
3179
3180
3181/***/ }),
3182
3183/***/ 5610:
3184/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3185
3186
3187var toIntegerOrInfinity = __webpack_require__(1291);
3188
3189var max = Math.max;
3190var min = Math.min;
3191
3192// Helper for a popular repeating case of the spec:
3193// Let integer be ? ToInteger(index).
3194// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
3195module.exports = function (index, length) {
3196 var integer = toIntegerOrInfinity(index);
3197 return integer < 0 ? max(integer + length, 0) : min(integer, length);
3198};
3199
3200
3201/***/ }),
3202
3203/***/ 5854:
3204/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3205
3206
3207var toPrimitive = __webpack_require__(2777);
3208
3209var $TypeError = TypeError;
3210
3211// `ToBigInt` abstract operation
3212// https://tc39.es/ecma262/#sec-tobigint
3213module.exports = function (argument) {
3214 var prim = toPrimitive(argument, 'number');
3215 if (typeof prim == 'number') throw new $TypeError("Can't convert number to bigint");
3216 // eslint-disable-next-line es/no-bigint -- safe
3217 return BigInt(prim);
3218};
3219
3220
3221/***/ }),
3222
3223/***/ 7696:
3224/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3225
3226
3227var toIntegerOrInfinity = __webpack_require__(1291);
3228var toLength = __webpack_require__(8014);
3229
3230var $RangeError = RangeError;
3231
3232// `ToIndex` abstract operation
3233// https://tc39.es/ecma262/#sec-toindex
3234module.exports = function (it) {
3235 if (it === undefined) return 0;
3236 var number = toIntegerOrInfinity(it);
3237 var length = toLength(number);
3238 if (number !== length) throw new $RangeError('Wrong length or index');
3239 return length;
3240};
3241
3242
3243/***/ }),
3244
3245/***/ 5397:
3246/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3247
3248
3249// toObject with fallback for non-array-like ES3 strings
3250var IndexedObject = __webpack_require__(7055);
3251var requireObjectCoercible = __webpack_require__(7750);
3252
3253module.exports = function (it) {
3254 return IndexedObject(requireObjectCoercible(it));
3255};
3256
3257
3258/***/ }),
3259
3260/***/ 1291:
3261/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3262
3263
3264var trunc = __webpack_require__(741);
3265
3266// `ToIntegerOrInfinity` abstract operation
3267// https://tc39.es/ecma262/#sec-tointegerorinfinity
3268module.exports = function (argument) {
3269 var number = +argument;
3270 // eslint-disable-next-line no-self-compare -- NaN check
3271 return number !== number || number === 0 ? 0 : trunc(number);
3272};
3273
3274
3275/***/ }),
3276
3277/***/ 8014:
3278/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3279
3280
3281var toIntegerOrInfinity = __webpack_require__(1291);
3282
3283var min = Math.min;
3284
3285// `ToLength` abstract operation
3286// https://tc39.es/ecma262/#sec-tolength
3287module.exports = function (argument) {
3288 var len = toIntegerOrInfinity(argument);
3289 return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
3290};
3291
3292
3293/***/ }),
3294
3295/***/ 8981:
3296/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3297
3298
3299var requireObjectCoercible = __webpack_require__(7750);
3300
3301var $Object = Object;
3302
3303// `ToObject` abstract operation
3304// https://tc39.es/ecma262/#sec-toobject
3305module.exports = function (argument) {
3306 return $Object(requireObjectCoercible(argument));
3307};
3308
3309
3310/***/ }),
3311
3312/***/ 2777:
3313/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3314
3315
3316var call = __webpack_require__(9565);
3317var isObject = __webpack_require__(34);
3318var isSymbol = __webpack_require__(757);
3319var getMethod = __webpack_require__(5966);
3320var ordinaryToPrimitive = __webpack_require__(4270);
3321var wellKnownSymbol = __webpack_require__(8227);
3322
3323var $TypeError = TypeError;
3324var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
3325
3326// `ToPrimitive` abstract operation
3327// https://tc39.es/ecma262/#sec-toprimitive
3328module.exports = function (input, pref) {
3329 if (!isObject(input) || isSymbol(input)) return input;
3330 var exoticToPrim = getMethod(input, TO_PRIMITIVE);
3331 var result;
3332 if (exoticToPrim) {
3333 if (pref === undefined) pref = 'default';
3334 result = call(exoticToPrim, input, pref);
3335 if (!isObject(result) || isSymbol(result)) return result;
3336 throw new $TypeError("Can't convert object to primitive value");
3337 }
3338 if (pref === undefined) pref = 'number';
3339 return ordinaryToPrimitive(input, pref);
3340};
3341
3342
3343/***/ }),
3344
3345/***/ 6969:
3346/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3347
3348
3349var toPrimitive = __webpack_require__(2777);
3350var isSymbol = __webpack_require__(757);
3351
3352// `ToPropertyKey` abstract operation
3353// https://tc39.es/ecma262/#sec-topropertykey
3354module.exports = function (argument) {
3355 var key = toPrimitive(argument, 'string');
3356 return isSymbol(key) ? key : key + '';
3357};
3358
3359
3360/***/ }),
3361
3362/***/ 2140:
3363/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3364
3365
3366var wellKnownSymbol = __webpack_require__(8227);
3367
3368var TO_STRING_TAG = wellKnownSymbol('toStringTag');
3369var test = {};
3370
3371test[TO_STRING_TAG] = 'z';
3372
3373module.exports = String(test) === '[object z]';
3374
3375
3376/***/ }),
3377
3378/***/ 655:
3379/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3380
3381
3382var classof = __webpack_require__(6955);
3383
3384var $String = String;
3385
3386module.exports = function (argument) {
3387 if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
3388 return $String(argument);
3389};
3390
3391
3392/***/ }),
3393
3394/***/ 9714:
3395/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3396
3397
3398var IS_NODE = __webpack_require__(9088);
3399
3400module.exports = function (name) {
3401 try {
3402 // eslint-disable-next-line no-new-func -- safe
3403 if (IS_NODE) return Function('return require("' + name + '")')();
3404 } catch (error) { /* empty */ }
3405};
3406
3407
3408/***/ }),
3409
3410/***/ 6823:
3411/***/ ((module) => {
3412
3413
3414var $String = String;
3415
3416module.exports = function (argument) {
3417 try {
3418 return $String(argument);
3419 } catch (error) {
3420 return 'Object';
3421 }
3422};
3423
3424
3425/***/ }),
3426
3427/***/ 3392:
3428/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3429
3430
3431var uncurryThis = __webpack_require__(9504);
3432
3433var id = 0;
3434var postfix = Math.random();
3435var toString = uncurryThis(1.0.toString);
3436
3437module.exports = function (key) {
3438 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
3439};
3440
3441
3442/***/ }),
3443
3444/***/ 7040:
3445/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3446
3447
3448/* eslint-disable es/no-symbol -- required for testing */
3449var NATIVE_SYMBOL = __webpack_require__(4495);
3450
3451module.exports = NATIVE_SYMBOL
3452 && !Symbol.sham
3453 && typeof Symbol.iterator == 'symbol';
3454
3455
3456/***/ }),
3457
3458/***/ 8686:
3459/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3460
3461
3462var DESCRIPTORS = __webpack_require__(3724);
3463var fails = __webpack_require__(9039);
3464
3465// V8 ~ Chrome 36-
3466// https://bugs.chromium.org/p/v8/issues/detail?id=3334
3467module.exports = DESCRIPTORS && fails(function () {
3468 // eslint-disable-next-line es/no-object-defineproperty -- required for testing
3469 return Object.defineProperty(function () { /* empty */ }, 'prototype', {
3470 value: 42,
3471 writable: false
3472 }).prototype !== 42;
3473});
3474
3475
3476/***/ }),
3477
3478/***/ 2812:
3479/***/ ((module) => {
3480
3481
3482var $TypeError = TypeError;
3483
3484module.exports = function (passed, required) {
3485 if (passed < required) throw new $TypeError('Not enough arguments');
3486 return passed;
3487};
3488
3489
3490/***/ }),
3491
3492/***/ 8622:
3493/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3494
3495
3496var global = __webpack_require__(4475);
3497var isCallable = __webpack_require__(4901);
3498
3499var WeakMap = global.WeakMap;
3500
3501module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
3502
3503
3504/***/ }),
3505
3506/***/ 8227:
3507/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3508
3509
3510var global = __webpack_require__(4475);
3511var shared = __webpack_require__(5745);
3512var hasOwn = __webpack_require__(9297);
3513var uid = __webpack_require__(3392);
3514var NATIVE_SYMBOL = __webpack_require__(4495);
3515var USE_SYMBOL_AS_UID = __webpack_require__(7040);
3516
3517var Symbol = global.Symbol;
3518var WellKnownSymbolsStore = shared('wks');
3519var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
3520
3521module.exports = function (name) {
3522 if (!hasOwn(WellKnownSymbolsStore, name)) {
3523 WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name)
3524 ? Symbol[name]
3525 : createWellKnownSymbol('Symbol.' + name);
3526 } return WellKnownSymbolsStore[name];
3527};
3528
3529
3530/***/ }),
3531
3532/***/ 6573:
3533/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3534
3535
3536var DESCRIPTORS = __webpack_require__(3724);
3537var defineBuiltInAccessor = __webpack_require__(2106);
3538var isDetached = __webpack_require__(3238);
3539
3540var ArrayBufferPrototype = ArrayBuffer.prototype;
3541
3542if (DESCRIPTORS && !('detached' in ArrayBufferPrototype)) {
3543 defineBuiltInAccessor(ArrayBufferPrototype, 'detached', {
3544 configurable: true,
3545 get: function detached() {
3546 return isDetached(this);
3547 }
3548 });
3549}
3550
3551
3552/***/ }),
3553
3554/***/ 7936:
3555/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3556
3557
3558var $ = __webpack_require__(6518);
3559var $transfer = __webpack_require__(5636);
3560
3561// `ArrayBuffer.prototype.transferToFixedLength` method
3562// https://tc39.es/proposal-arraybuffer-transfer/#sec-arraybuffer.prototype.transfertofixedlength
3563if ($transfer) $({ target: 'ArrayBuffer', proto: true }, {
3564 transferToFixedLength: function transferToFixedLength() {
3565 return $transfer(this, arguments.length ? arguments[0] : undefined, false);
3566 }
3567});
3568
3569
3570/***/ }),
3571
3572/***/ 8100:
3573/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3574
3575
3576var $ = __webpack_require__(6518);
3577var $transfer = __webpack_require__(5636);
3578
3579// `ArrayBuffer.prototype.transfer` method
3580// https://tc39.es/proposal-arraybuffer-transfer/#sec-arraybuffer.prototype.transfer
3581if ($transfer) $({ target: 'ArrayBuffer', proto: true }, {
3582 transfer: function transfer() {
3583 return $transfer(this, arguments.length ? arguments[0] : undefined, true);
3584 }
3585});
3586
3587
3588/***/ }),
3589
3590/***/ 4114:
3591/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3592
3593
3594var $ = __webpack_require__(6518);
3595var toObject = __webpack_require__(8981);
3596var lengthOfArrayLike = __webpack_require__(6198);
3597var setArrayLength = __webpack_require__(4527);
3598var doesNotExceedSafeInteger = __webpack_require__(6837);
3599var fails = __webpack_require__(9039);
3600
3601var INCORRECT_TO_LENGTH = fails(function () {
3602 return [].push.call({ length: 0x100000000 }, 1) !== 4294967297;
3603});
3604
3605// V8 <= 121 and Safari <= 15.4; FF < 23 throws InternalError
3606// https://bugs.chromium.org/p/v8/issues/detail?id=12681
3607var properErrorOnNonWritableLength = function () {
3608 try {
3609 // eslint-disable-next-line es/no-object-defineproperty -- safe
3610 Object.defineProperty([], 'length', { writable: false }).push();
3611 } catch (error) {
3612 return error instanceof TypeError;
3613 }
3614};
3615
3616var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
3617
3618// `Array.prototype.push` method
3619// https://tc39.es/ecma262/#sec-array.prototype.push
3620$({ target: 'Array', proto: true, arity: 1, forced: FORCED }, {
3621 // eslint-disable-next-line no-unused-vars -- required for `.length`
3622 push: function push(item) {
3623 var O = toObject(this);
3624 var len = lengthOfArrayLike(O);
3625 var argCount = arguments.length;
3626 doesNotExceedSafeInteger(len + argCount);
3627 for (var i = 0; i < argCount; i++) {
3628 O[len] = arguments[i];
3629 len++;
3630 }
3631 setArrayLength(O, len);
3632 return len;
3633 }
3634});
3635
3636
3637/***/ }),
3638
3639/***/ 4628:
3640/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3641
3642
3643var $ = __webpack_require__(6518);
3644var newPromiseCapabilityModule = __webpack_require__(6043);
3645
3646// `Promise.withResolvers` method
3647// https://github.com/tc39/proposal-promise-with-resolvers
3648$({ target: 'Promise', stat: true }, {
3649 withResolvers: function withResolvers() {
3650 var promiseCapability = newPromiseCapabilityModule.f(this);
3651 return {
3652 promise: promiseCapability.promise,
3653 resolve: promiseCapability.resolve,
3654 reject: promiseCapability.reject
3655 };
3656 }
3657});
3658
3659
3660/***/ }),
3661
3662/***/ 7467:
3663/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3664
3665
3666var arrayToReversed = __webpack_require__(7628);
3667var ArrayBufferViewCore = __webpack_require__(4644);
3668
3669var aTypedArray = ArrayBufferViewCore.aTypedArray;
3670var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
3671var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
3672
3673// `%TypedArray%.prototype.toReversed` method
3674// https://tc39.es/ecma262/#sec-%typedarray%.prototype.toreversed
3675exportTypedArrayMethod('toReversed', function toReversed() {
3676 return arrayToReversed(aTypedArray(this), getTypedArrayConstructor(this));
3677});
3678
3679
3680/***/ }),
3681
3682/***/ 4732:
3683/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3684
3685
3686var ArrayBufferViewCore = __webpack_require__(4644);
3687var uncurryThis = __webpack_require__(9504);
3688var aCallable = __webpack_require__(9306);
3689var arrayFromConstructorAndList = __webpack_require__(5370);
3690
3691var aTypedArray = ArrayBufferViewCore.aTypedArray;
3692var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
3693var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
3694var sort = uncurryThis(ArrayBufferViewCore.TypedArrayPrototype.sort);
3695
3696// `%TypedArray%.prototype.toSorted` method
3697// https://tc39.es/ecma262/#sec-%typedarray%.prototype.tosorted
3698exportTypedArrayMethod('toSorted', function toSorted(compareFn) {
3699 if (compareFn !== undefined) aCallable(compareFn);
3700 var O = aTypedArray(this);
3701 var A = arrayFromConstructorAndList(getTypedArrayConstructor(O), O);
3702 return sort(A, compareFn);
3703});
3704
3705
3706/***/ }),
3707
3708/***/ 9577:
3709/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3710
3711
3712var arrayWith = __webpack_require__(9928);
3713var ArrayBufferViewCore = __webpack_require__(4644);
3714var isBigIntArray = __webpack_require__(1108);
3715var toIntegerOrInfinity = __webpack_require__(1291);
3716var toBigInt = __webpack_require__(5854);
3717
3718var aTypedArray = ArrayBufferViewCore.aTypedArray;
3719var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
3720var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
3721
3722var PROPER_ORDER = !!function () {
3723 try {
3724 // eslint-disable-next-line no-throw-literal, es/no-typed-arrays, es/no-array-prototype-with -- required for testing
3725 new Int8Array(1)['with'](2, { valueOf: function () { throw 8; } });
3726 } catch (error) {
3727 // some early implementations, like WebKit, does not follow the final semantic
3728 // https://github.com/tc39/proposal-change-array-by-copy/pull/86
3729 return error === 8;
3730 }
3731}();
3732
3733// `%TypedArray%.prototype.with` method
3734// https://tc39.es/ecma262/#sec-%typedarray%.prototype.with
3735exportTypedArrayMethod('with', { 'with': function (index, value) {
3736 var O = aTypedArray(this);
3737 var relativeIndex = toIntegerOrInfinity(index);
3738 var actualValue = isBigIntArray(O) ? toBigInt(value) : +value;
3739 return arrayWith(O, getTypedArrayConstructor(O), relativeIndex, actualValue);
3740} }['with'], !PROPER_ORDER);
3741
3742
3743/***/ }),
3744
3745/***/ 8992:
3746/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3747
3748
3749var $ = __webpack_require__(6518);
3750var global = __webpack_require__(4475);
3751var anInstance = __webpack_require__(679);
3752var anObject = __webpack_require__(8551);
3753var isCallable = __webpack_require__(4901);
3754var getPrototypeOf = __webpack_require__(2787);
3755var defineBuiltInAccessor = __webpack_require__(2106);
3756var createProperty = __webpack_require__(4659);
3757var fails = __webpack_require__(9039);
3758var hasOwn = __webpack_require__(9297);
3759var wellKnownSymbol = __webpack_require__(8227);
3760var IteratorPrototype = (__webpack_require__(7657).IteratorPrototype);
3761var DESCRIPTORS = __webpack_require__(3724);
3762var IS_PURE = __webpack_require__(6395);
3763
3764var CONSTRUCTOR = 'constructor';
3765var ITERATOR = 'Iterator';
3766var TO_STRING_TAG = wellKnownSymbol('toStringTag');
3767
3768var $TypeError = TypeError;
3769var NativeIterator = global[ITERATOR];
3770
3771// FF56- have non-standard global helper `Iterator`
3772var FORCED = IS_PURE
3773 || !isCallable(NativeIterator)
3774 || NativeIterator.prototype !== IteratorPrototype
3775 // FF44- non-standard `Iterator` passes previous tests
3776 || !fails(function () { NativeIterator({}); });
3777
3778var IteratorConstructor = function Iterator() {
3779 anInstance(this, IteratorPrototype);
3780 if (getPrototypeOf(this) === IteratorPrototype) throw new $TypeError('Abstract class Iterator not directly constructable');
3781};
3782
3783var defineIteratorPrototypeAccessor = function (key, value) {
3784 if (DESCRIPTORS) {
3785 defineBuiltInAccessor(IteratorPrototype, key, {
3786 configurable: true,
3787 get: function () {
3788 return value;
3789 },
3790 set: function (replacement) {
3791 anObject(this);
3792 if (this === IteratorPrototype) throw new $TypeError("You can't redefine this property");
3793 if (hasOwn(this, key)) this[key] = replacement;
3794 else createProperty(this, key, replacement);
3795 }
3796 });
3797 } else IteratorPrototype[key] = value;
3798};
3799
3800if (!hasOwn(IteratorPrototype, TO_STRING_TAG)) defineIteratorPrototypeAccessor(TO_STRING_TAG, ITERATOR);
3801
3802if (FORCED || !hasOwn(IteratorPrototype, CONSTRUCTOR) || IteratorPrototype[CONSTRUCTOR] === Object) {
3803 defineIteratorPrototypeAccessor(CONSTRUCTOR, IteratorConstructor);
3804}
3805
3806IteratorConstructor.prototype = IteratorPrototype;
3807
3808// `Iterator` constructor
3809// https://github.com/tc39/proposal-iterator-helpers
3810$({ global: true, constructor: true, forced: FORCED }, {
3811 Iterator: IteratorConstructor
3812});
3813
3814
3815/***/ }),
3816
3817/***/ 3215:
3818/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3819
3820
3821var $ = __webpack_require__(6518);
3822var iterate = __webpack_require__(2652);
3823var aCallable = __webpack_require__(9306);
3824var anObject = __webpack_require__(8551);
3825var getIteratorDirect = __webpack_require__(1767);
3826
3827// `Iterator.prototype.every` method
3828// https://github.com/tc39/proposal-iterator-helpers
3829$({ target: 'Iterator', proto: true, real: true }, {
3830 every: function every(predicate) {
3831 anObject(this);
3832 aCallable(predicate);
3833 var record = getIteratorDirect(this);
3834 var counter = 0;
3835 return !iterate(record, function (value, stop) {
3836 if (!predicate(value, counter++)) return stop();
3837 }, { IS_RECORD: true, INTERRUPTED: true }).stopped;
3838 }
3839});
3840
3841
3842/***/ }),
3843
3844/***/ 4520:
3845/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3846
3847
3848var $ = __webpack_require__(6518);
3849var call = __webpack_require__(9565);
3850var aCallable = __webpack_require__(9306);
3851var anObject = __webpack_require__(8551);
3852var getIteratorDirect = __webpack_require__(1767);
3853var createIteratorProxy = __webpack_require__(9462);
3854var callWithSafeIterationClosing = __webpack_require__(6319);
3855var IS_PURE = __webpack_require__(6395);
3856
3857var IteratorProxy = createIteratorProxy(function () {
3858 var iterator = this.iterator;
3859 var predicate = this.predicate;
3860 var next = this.next;
3861 var result, done, value;
3862 while (true) {
3863 result = anObject(call(next, iterator));
3864 done = this.done = !!result.done;
3865 if (done) return;
3866 value = result.value;
3867 if (callWithSafeIterationClosing(iterator, predicate, [value, this.counter++], true)) return value;
3868 }
3869});
3870
3871// `Iterator.prototype.filter` method
3872// https://github.com/tc39/proposal-iterator-helpers
3873$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
3874 filter: function filter(predicate) {
3875 anObject(this);
3876 aCallable(predicate);
3877 return new IteratorProxy(getIteratorDirect(this), {
3878 predicate: predicate
3879 });
3880 }
3881});
3882
3883
3884/***/ }),
3885
3886/***/ 670:
3887/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3888
3889
3890var $ = __webpack_require__(6518);
3891var call = __webpack_require__(9565);
3892var aCallable = __webpack_require__(9306);
3893var anObject = __webpack_require__(8551);
3894var getIteratorDirect = __webpack_require__(1767);
3895var getIteratorFlattenable = __webpack_require__(8646);
3896var createIteratorProxy = __webpack_require__(9462);
3897var iteratorClose = __webpack_require__(9539);
3898var IS_PURE = __webpack_require__(6395);
3899
3900var IteratorProxy = createIteratorProxy(function () {
3901 var iterator = this.iterator;
3902 var mapper = this.mapper;
3903 var result, inner;
3904
3905 while (true) {
3906 if (inner = this.inner) try {
3907 result = anObject(call(inner.next, inner.iterator));
3908 if (!result.done) return result.value;
3909 this.inner = null;
3910 } catch (error) { iteratorClose(iterator, 'throw', error); }
3911
3912 result = anObject(call(this.next, iterator));
3913
3914 if (this.done = !!result.done) return;
3915
3916 try {
3917 this.inner = getIteratorFlattenable(mapper(result.value, this.counter++), false);
3918 } catch (error) { iteratorClose(iterator, 'throw', error); }
3919 }
3920});
3921
3922// `Iterator.prototype.flatMap` method
3923// https://github.com/tc39/proposal-iterator-helpers
3924$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
3925 flatMap: function flatMap(mapper) {
3926 anObject(this);
3927 aCallable(mapper);
3928 return new IteratorProxy(getIteratorDirect(this), {
3929 mapper: mapper,
3930 inner: null
3931 });
3932 }
3933});
3934
3935
3936/***/ }),
3937
3938/***/ 1454:
3939/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3940
3941
3942var $ = __webpack_require__(6518);
3943var map = __webpack_require__(713);
3944var IS_PURE = __webpack_require__(6395);
3945
3946// `Iterator.prototype.map` method
3947// https://github.com/tc39/proposal-iterator-helpers
3948$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
3949 map: map
3950});
3951
3952
3953/***/ }),
3954
3955/***/ 7550:
3956/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3957
3958
3959var $ = __webpack_require__(6518);
3960var iterate = __webpack_require__(2652);
3961var aCallable = __webpack_require__(9306);
3962var anObject = __webpack_require__(8551);
3963var getIteratorDirect = __webpack_require__(1767);
3964
3965// `Iterator.prototype.some` method
3966// https://github.com/tc39/proposal-iterator-helpers
3967$({ target: 'Iterator', proto: true, real: true }, {
3968 some: function some(predicate) {
3969 anObject(this);
3970 aCallable(predicate);
3971 var record = getIteratorDirect(this);
3972 var counter = 0;
3973 return iterate(record, function (value, stop) {
3974 if (predicate(value, counter++)) return stop();
3975 }, { IS_RECORD: true, INTERRUPTED: true }).stopped;
3976 }
3977});
3978
3979
3980/***/ }),
3981
3982/***/ 8335:
3983/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3984
3985
3986var $ = __webpack_require__(6518);
3987var DESCRIPTORS = __webpack_require__(3724);
3988var global = __webpack_require__(4475);
3989var getBuiltIn = __webpack_require__(7751);
3990var uncurryThis = __webpack_require__(9504);
3991var call = __webpack_require__(9565);
3992var isCallable = __webpack_require__(4901);
3993var isObject = __webpack_require__(34);
3994var isArray = __webpack_require__(4376);
3995var hasOwn = __webpack_require__(9297);
3996var toString = __webpack_require__(655);
3997var lengthOfArrayLike = __webpack_require__(6198);
3998var createProperty = __webpack_require__(4659);
3999var fails = __webpack_require__(9039);
4000var parseJSONString = __webpack_require__(8235);
4001var NATIVE_SYMBOL = __webpack_require__(4495);
4002
4003var JSON = global.JSON;
4004var Number = global.Number;
4005var SyntaxError = global.SyntaxError;
4006var nativeParse = JSON && JSON.parse;
4007var enumerableOwnProperties = getBuiltIn('Object', 'keys');
4008// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
4009var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
4010var at = uncurryThis(''.charAt);
4011var slice = uncurryThis(''.slice);
4012var exec = uncurryThis(/./.exec);
4013var push = uncurryThis([].push);
4014
4015var IS_DIGIT = /^\d$/;
4016var IS_NON_ZERO_DIGIT = /^[1-9]$/;
4017var IS_NUMBER_START = /^(?:-|\d)$/;
4018var IS_WHITESPACE = /^[\t\n\r ]$/;
4019
4020var PRIMITIVE = 0;
4021var OBJECT = 1;
4022
4023var $parse = function (source, reviver) {
4024 source = toString(source);
4025 var context = new Context(source, 0, '');
4026 var root = context.parse();
4027 var value = root.value;
4028 var endIndex = context.skip(IS_WHITESPACE, root.end);
4029 if (endIndex < source.length) {
4030 throw new SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex);
4031 }
4032 return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value;
4033};
4034
4035var internalize = function (holder, name, reviver, node) {
4036 var val = holder[name];
4037 var unmodified = node && val === node.value;
4038 var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {};
4039 var elementRecordsLen, keys, len, i, P;
4040 if (isObject(val)) {
4041 var nodeIsArray = isArray(val);
4042 var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {};
4043 if (nodeIsArray) {
4044 elementRecordsLen = nodes.length;
4045 len = lengthOfArrayLike(val);
4046 for (i = 0; i < len; i++) {
4047 internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined));
4048 }
4049 } else {
4050 keys = enumerableOwnProperties(val);
4051 len = lengthOfArrayLike(keys);
4052 for (i = 0; i < len; i++) {
4053 P = keys[i];
4054 internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined));
4055 }
4056 }
4057 }
4058 return call(reviver, holder, name, val, context);
4059};
4060
4061var internalizeProperty = function (object, key, value) {
4062 if (DESCRIPTORS) {
4063 var descriptor = getOwnPropertyDescriptor(object, key);
4064 if (descriptor && !descriptor.configurable) return;
4065 }
4066 if (value === undefined) delete object[key];
4067 else createProperty(object, key, value);
4068};
4069
4070var Node = function (value, end, source, nodes) {
4071 this.value = value;
4072 this.end = end;
4073 this.source = source;
4074 this.nodes = nodes;
4075};
4076
4077var Context = function (source, index) {
4078 this.source = source;
4079 this.index = index;
4080};
4081
4082// https://www.json.org/json-en.html
4083Context.prototype = {
4084 fork: function (nextIndex) {
4085 return new Context(this.source, nextIndex);
4086 },
4087 parse: function () {
4088 var source = this.source;
4089 var i = this.skip(IS_WHITESPACE, this.index);
4090 var fork = this.fork(i);
4091 var chr = at(source, i);
4092 if (exec(IS_NUMBER_START, chr)) return fork.number();
4093 switch (chr) {
4094 case '{':
4095 return fork.object();
4096 case '[':
4097 return fork.array();
4098 case '"':
4099 return fork.string();
4100 case 't':
4101 return fork.keyword(true);
4102 case 'f':
4103 return fork.keyword(false);
4104 case 'n':
4105 return fork.keyword(null);
4106 } throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
4107 },
4108 node: function (type, value, start, end, nodes) {
4109 return new Node(value, end, type ? null : slice(this.source, start, end), nodes);
4110 },
4111 object: function () {
4112 var source = this.source;
4113 var i = this.index + 1;
4114 var expectKeypair = false;
4115 var object = {};
4116 var nodes = {};
4117 while (i < source.length) {
4118 i = this.until(['"', '}'], i);
4119 if (at(source, i) === '}' && !expectKeypair) {
4120 i++;
4121 break;
4122 }
4123 // Parsing the key
4124 var result = this.fork(i).string();
4125 var key = result.value;
4126 i = result.end;
4127 i = this.until([':'], i) + 1;
4128 // Parsing value
4129 i = this.skip(IS_WHITESPACE, i);
4130 result = this.fork(i).parse();
4131 createProperty(nodes, key, result);
4132 createProperty(object, key, result.value);
4133 i = this.until([',', '}'], result.end);
4134 var chr = at(source, i);
4135 if (chr === ',') {
4136 expectKeypair = true;
4137 i++;
4138 } else if (chr === '}') {
4139 i++;
4140 break;
4141 }
4142 }
4143 return this.node(OBJECT, object, this.index, i, nodes);
4144 },
4145 array: function () {
4146 var source = this.source;
4147 var i = this.index + 1;
4148 var expectElement = false;
4149 var array = [];
4150 var nodes = [];
4151 while (i < source.length) {
4152 i = this.skip(IS_WHITESPACE, i);
4153 if (at(source, i) === ']' && !expectElement) {
4154 i++;
4155 break;
4156 }
4157 var result = this.fork(i).parse();
4158 push(nodes, result);
4159 push(array, result.value);
4160 i = this.until([',', ']'], result.end);
4161 if (at(source, i) === ',') {
4162 expectElement = true;
4163 i++;
4164 } else if (at(source, i) === ']') {
4165 i++;
4166 break;
4167 }
4168 }
4169 return this.node(OBJECT, array, this.index, i, nodes);
4170 },
4171 string: function () {
4172 var index = this.index;
4173 var parsed = parseJSONString(this.source, this.index + 1);
4174 return this.node(PRIMITIVE, parsed.value, index, parsed.end);
4175 },
4176 number: function () {
4177 var source = this.source;
4178 var startIndex = this.index;
4179 var i = startIndex;
4180 if (at(source, i) === '-') i++;
4181 if (at(source, i) === '0') i++;
4182 else if (exec(IS_NON_ZERO_DIGIT, at(source, i))) i = this.skip(IS_DIGIT, ++i);
4183 else throw new SyntaxError('Failed to parse number at: ' + i);
4184 if (at(source, i) === '.') i = this.skip(IS_DIGIT, ++i);
4185 if (at(source, i) === 'e' || at(source, i) === 'E') {
4186 i++;
4187 if (at(source, i) === '+' || at(source, i) === '-') i++;
4188 var exponentStartIndex = i;
4189 i = this.skip(IS_DIGIT, i);
4190 if (exponentStartIndex === i) throw new SyntaxError("Failed to parse number's exponent value at: " + i);
4191 }
4192 return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i);
4193 },
4194 keyword: function (value) {
4195 var keyword = '' + value;
4196 var index = this.index;
4197 var endIndex = index + keyword.length;
4198 if (slice(this.source, index, endIndex) !== keyword) throw new SyntaxError('Failed to parse value at: ' + index);
4199 return this.node(PRIMITIVE, value, index, endIndex);
4200 },
4201 skip: function (regex, i) {
4202 var source = this.source;
4203 for (; i < source.length; i++) if (!exec(regex, at(source, i))) break;
4204 return i;
4205 },
4206 until: function (array, i) {
4207 i = this.skip(IS_WHITESPACE, i);
4208 var chr = at(this.source, i);
4209 for (var j = 0; j < array.length; j++) if (array[j] === chr) return i;
4210 throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
4211 }
4212};
4213
4214var NO_SOURCE_SUPPORT = fails(function () {
4215 var unsafeInt = '9007199254740993';
4216 var source;
4217 nativeParse(unsafeInt, function (key, value, context) {
4218 source = context.source;
4219 });
4220 return source !== unsafeInt;
4221});
4222
4223var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () {
4224 // Safari 9 bug
4225 return 1 / nativeParse('-0 \t') !== -Infinity;
4226});
4227
4228// `JSON.parse` method
4229// https://tc39.es/ecma262/#sec-json.parse
4230// https://github.com/tc39/proposal-json-parse-with-source
4231$({ target: 'JSON', stat: true, forced: NO_SOURCE_SUPPORT }, {
4232 parse: function parse(text, reviver) {
4233 return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver);
4234 }
4235});
4236
4237
4238/***/ }),
4239
4240/***/ 3375:
4241/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4242
4243
4244var $ = __webpack_require__(6518);
4245var difference = __webpack_require__(3440);
4246var setMethodAcceptSetLike = __webpack_require__(4916);
4247
4248// `Set.prototype.difference` method
4249// https://github.com/tc39/proposal-set-methods
4250$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('difference') }, {
4251 difference: difference
4252});
4253
4254
4255/***/ }),
4256
4257/***/ 9225:
4258/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4259
4260
4261var $ = __webpack_require__(6518);
4262var fails = __webpack_require__(9039);
4263var intersection = __webpack_require__(8750);
4264var setMethodAcceptSetLike = __webpack_require__(4916);
4265
4266var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () {
4267 // eslint-disable-next-line es/no-array-from, es/no-set -- testing
4268 return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) !== '3,2';
4269});
4270
4271// `Set.prototype.intersection` method
4272// https://github.com/tc39/proposal-set-methods
4273$({ target: 'Set', proto: true, real: true, forced: INCORRECT }, {
4274 intersection: intersection
4275});
4276
4277
4278/***/ }),
4279
4280/***/ 3972:
4281/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4282
4283
4284var $ = __webpack_require__(6518);
4285var isDisjointFrom = __webpack_require__(4449);
4286var setMethodAcceptSetLike = __webpack_require__(4916);
4287
4288// `Set.prototype.isDisjointFrom` method
4289// https://github.com/tc39/proposal-set-methods
4290$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isDisjointFrom') }, {
4291 isDisjointFrom: isDisjointFrom
4292});
4293
4294
4295/***/ }),
4296
4297/***/ 9209:
4298/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4299
4300
4301var $ = __webpack_require__(6518);
4302var isSubsetOf = __webpack_require__(3838);
4303var setMethodAcceptSetLike = __webpack_require__(4916);
4304
4305// `Set.prototype.isSubsetOf` method
4306// https://github.com/tc39/proposal-set-methods
4307$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSubsetOf') }, {
4308 isSubsetOf: isSubsetOf
4309});
4310
4311
4312/***/ }),
4313
4314/***/ 5714:
4315/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4316
4317
4318var $ = __webpack_require__(6518);
4319var isSupersetOf = __webpack_require__(8527);
4320var setMethodAcceptSetLike = __webpack_require__(4916);
4321
4322// `Set.prototype.isSupersetOf` method
4323// https://github.com/tc39/proposal-set-methods
4324$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSupersetOf') }, {
4325 isSupersetOf: isSupersetOf
4326});
4327
4328
4329/***/ }),
4330
4331/***/ 7561:
4332/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4333
4334
4335var $ = __webpack_require__(6518);
4336var symmetricDifference = __webpack_require__(3650);
4337var setMethodAcceptSetLike = __webpack_require__(4916);
4338
4339// `Set.prototype.symmetricDifference` method
4340// https://github.com/tc39/proposal-set-methods
4341$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('symmetricDifference') }, {
4342 symmetricDifference: symmetricDifference
4343});
4344
4345
4346/***/ }),
4347
4348/***/ 6197:
4349/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4350
4351
4352var $ = __webpack_require__(6518);
4353var union = __webpack_require__(4204);
4354var setMethodAcceptSetLike = __webpack_require__(4916);
4355
4356// `Set.prototype.union` method
4357// https://github.com/tc39/proposal-set-methods
4358$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('union') }, {
4359 union: union
4360});
4361
4362
4363/***/ }),
4364
4365/***/ 4979:
4366/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4367
4368
4369var $ = __webpack_require__(6518);
4370var global = __webpack_require__(4475);
4371var getBuiltIn = __webpack_require__(7751);
4372var createPropertyDescriptor = __webpack_require__(6980);
4373var defineProperty = (__webpack_require__(4913).f);
4374var hasOwn = __webpack_require__(9297);
4375var anInstance = __webpack_require__(679);
4376var inheritIfRequired = __webpack_require__(3167);
4377var normalizeStringArgument = __webpack_require__(2603);
4378var DOMExceptionConstants = __webpack_require__(5002);
4379var clearErrorStack = __webpack_require__(6193);
4380var DESCRIPTORS = __webpack_require__(3724);
4381var IS_PURE = __webpack_require__(6395);
4382
4383var DOM_EXCEPTION = 'DOMException';
4384var Error = getBuiltIn('Error');
4385var NativeDOMException = getBuiltIn(DOM_EXCEPTION);
4386
4387var $DOMException = function DOMException() {
4388 anInstance(this, DOMExceptionPrototype);
4389 var argumentsLength = arguments.length;
4390 var message = normalizeStringArgument(argumentsLength < 1 ? undefined : arguments[0]);
4391 var name = normalizeStringArgument(argumentsLength < 2 ? undefined : arguments[1], 'Error');
4392 var that = new NativeDOMException(message, name);
4393 var error = new Error(message);
4394 error.name = DOM_EXCEPTION;
4395 defineProperty(that, 'stack', createPropertyDescriptor(1, clearErrorStack(error.stack, 1)));
4396 inheritIfRequired(that, this, $DOMException);
4397 return that;
4398};
4399
4400var DOMExceptionPrototype = $DOMException.prototype = NativeDOMException.prototype;
4401
4402var ERROR_HAS_STACK = 'stack' in new Error(DOM_EXCEPTION);
4403var DOM_EXCEPTION_HAS_STACK = 'stack' in new NativeDOMException(1, 2);
4404
4405// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
4406var descriptor = NativeDOMException && DESCRIPTORS && Object.getOwnPropertyDescriptor(global, DOM_EXCEPTION);
4407
4408// Bun ~ 0.1.1 DOMException have incorrect descriptor and we can't redefine it
4409// https://github.com/Jarred-Sumner/bun/issues/399
4410var BUGGY_DESCRIPTOR = !!descriptor && !(descriptor.writable && descriptor.configurable);
4411
4412var FORCED_CONSTRUCTOR = ERROR_HAS_STACK && !BUGGY_DESCRIPTOR && !DOM_EXCEPTION_HAS_STACK;
4413
4414// `DOMException` constructor patch for `.stack` where it's required
4415// https://webidl.spec.whatwg.org/#es-DOMException-specialness
4416$({ global: true, constructor: true, forced: IS_PURE || FORCED_CONSTRUCTOR }, { // TODO: fix export logic
4417 DOMException: FORCED_CONSTRUCTOR ? $DOMException : NativeDOMException
4418});
4419
4420var PolyfilledDOMException = getBuiltIn(DOM_EXCEPTION);
4421var PolyfilledDOMExceptionPrototype = PolyfilledDOMException.prototype;
4422
4423if (PolyfilledDOMExceptionPrototype.constructor !== PolyfilledDOMException) {
4424 if (!IS_PURE) {
4425 defineProperty(PolyfilledDOMExceptionPrototype, 'constructor', createPropertyDescriptor(1, PolyfilledDOMException));
4426 }
4427
4428 for (var key in DOMExceptionConstants) if (hasOwn(DOMExceptionConstants, key)) {
4429 var constant = DOMExceptionConstants[key];
4430 var constantName = constant.s;
4431 if (!hasOwn(PolyfilledDOMException, constantName)) {
4432 defineProperty(PolyfilledDOMException, constantName, createPropertyDescriptor(6, constant.c));
4433 }
4434 }
4435}
4436
4437
4438/***/ }),
4439
4440/***/ 4603:
4441/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4442
4443
4444var defineBuiltIn = __webpack_require__(6840);
4445var uncurryThis = __webpack_require__(9504);
4446var toString = __webpack_require__(655);
4447var validateArgumentsLength = __webpack_require__(2812);
4448
4449var $URLSearchParams = URLSearchParams;
4450var URLSearchParamsPrototype = $URLSearchParams.prototype;
4451var append = uncurryThis(URLSearchParamsPrototype.append);
4452var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
4453var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
4454var push = uncurryThis([].push);
4455var params = new $URLSearchParams('a=1&a=2&b=3');
4456
4457params['delete']('a', 1);
4458// `undefined` case is a Chromium 117 bug
4459// https://bugs.chromium.org/p/v8/issues/detail?id=14222
4460params['delete']('b', undefined);
4461
4462if (params + '' !== 'a=2') {
4463 defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name /* , value */) {
4464 var length = arguments.length;
4465 var $value = length < 2 ? undefined : arguments[1];
4466 if (length && $value === undefined) return $delete(this, name);
4467 var entries = [];
4468 forEach(this, function (v, k) { // also validates `this`
4469 push(entries, { key: k, value: v });
4470 });
4471 validateArgumentsLength(length, 1);
4472 var key = toString(name);
4473 var value = toString($value);
4474 var index = 0;
4475 var dindex = 0;
4476 var found = false;
4477 var entriesLength = entries.length;
4478 var entry;
4479 while (index < entriesLength) {
4480 entry = entries[index++];
4481 if (found || entry.key === key) {
4482 found = true;
4483 $delete(this, entry.key);
4484 } else dindex++;
4485 }
4486 while (dindex < entriesLength) {
4487 entry = entries[dindex++];
4488 if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value);
4489 }
4490 }, { enumerable: true, unsafe: true });
4491}
4492
4493
4494/***/ }),
4495
4496/***/ 7566:
4497/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4498
4499
4500var defineBuiltIn = __webpack_require__(6840);
4501var uncurryThis = __webpack_require__(9504);
4502var toString = __webpack_require__(655);
4503var validateArgumentsLength = __webpack_require__(2812);
4504
4505var $URLSearchParams = URLSearchParams;
4506var URLSearchParamsPrototype = $URLSearchParams.prototype;
4507var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
4508var $has = uncurryThis(URLSearchParamsPrototype.has);
4509var params = new $URLSearchParams('a=1');
4510
4511// `undefined` case is a Chromium 117 bug
4512// https://bugs.chromium.org/p/v8/issues/detail?id=14222
4513if (params.has('a', 2) || !params.has('a', undefined)) {
4514 defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) {
4515 var length = arguments.length;
4516 var $value = length < 2 ? undefined : arguments[1];
4517 if (length && $value === undefined) return $has(this, name);
4518 var values = getAll(this, name); // also validates `this`
4519 validateArgumentsLength(length, 1);
4520 var value = toString($value);
4521 var index = 0;
4522 while (index < values.length) {
4523 if (values[index++] === value) return true;
4524 } return false;
4525 }, { enumerable: true, unsafe: true });
4526}
4527
4528
4529/***/ }),
4530
4531/***/ 8721:
4532/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4533
4534
4535var DESCRIPTORS = __webpack_require__(3724);
4536var uncurryThis = __webpack_require__(9504);
4537var defineBuiltInAccessor = __webpack_require__(2106);
4538
4539var URLSearchParamsPrototype = URLSearchParams.prototype;
4540var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
4541
4542// `URLSearchParams.prototype.size` getter
4543// https://github.com/whatwg/url/pull/734
4544if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
4545 defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
4546 get: function size() {
4547 var count = 0;
4548 forEach(this, function () { count++; });
4549 return count;
4550 },
4551 configurable: true,
4552 enumerable: true
4553 });
4554}
4555
4556
4557/***/ }),
4558
4559/***/ 6976:
4560/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
4561
4562
4563// EXPORTS
4564__webpack_require__.d(__webpack_exports__, {
4565 AnnotationLayer: () => (/* binding */ AnnotationLayer),
4566 FreeTextAnnotationElement: () => (/* binding */ FreeTextAnnotationElement),
4567 InkAnnotationElement: () => (/* binding */ InkAnnotationElement),
4568 StampAnnotationElement: () => (/* binding */ StampAnnotationElement)
4569});
4570
4571// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
4572var es_array_push = __webpack_require__(4114);
4573// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.constructor.js
4574var esnext_iterator_constructor = __webpack_require__(8992);
4575// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.flat-map.js
4576var esnext_iterator_flat_map = __webpack_require__(670);
4577// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.map.js
4578var esnext_iterator_map = __webpack_require__(1454);
4579// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.difference.v2.js
4580var esnext_set_difference_v2 = __webpack_require__(3375);
4581// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.intersection.v2.js
4582var esnext_set_intersection_v2 = __webpack_require__(9225);
4583// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-disjoint-from.v2.js
4584var esnext_set_is_disjoint_from_v2 = __webpack_require__(3972);
4585// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-subset-of.v2.js
4586var esnext_set_is_subset_of_v2 = __webpack_require__(9209);
4587// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-superset-of.v2.js
4588var esnext_set_is_superset_of_v2 = __webpack_require__(5714);
4589// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.symmetric-difference.v2.js
4590var esnext_set_symmetric_difference_v2 = __webpack_require__(7561);
4591// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.union.v2.js
4592var esnext_set_union_v2 = __webpack_require__(6197);
4593// EXTERNAL MODULE: ./src/shared/util.js
4594var util = __webpack_require__(4292);
4595// EXTERNAL MODULE: ./src/display/display_utils.js
4596var display_utils = __webpack_require__(5419);
4597// EXTERNAL MODULE: ./src/display/annotation_storage.js
4598var annotation_storage = __webpack_require__(9792);
4599;// CONCATENATED MODULE: ./src/shared/scripting_utils.js
4600
4601function makeColorComp(n) {
4602 return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
4603}
4604function scaleAndClamp(x) {
4605 return Math.max(0, Math.min(255, 255 * x));
4606}
4607class ColorConverters {
4608 static CMYK_G(_ref) {
4609 let [c, y, m, k] = _ref;
4610 return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
4611 }
4612 static G_CMYK(_ref2) {
4613 let [g] = _ref2;
4614 return ["CMYK", 0, 0, 0, 1 - g];
4615 }
4616 static G_RGB(_ref3) {
4617 let [g] = _ref3;
4618 return ["RGB", g, g, g];
4619 }
4620 static G_rgb(_ref4) {
4621 let [g] = _ref4;
4622 g = scaleAndClamp(g);
4623 return [g, g, g];
4624 }
4625 static G_HTML(_ref5) {
4626 let [g] = _ref5;
4627 const G = makeColorComp(g);
4628 return `#${G}${G}${G}`;
4629 }
4630 static RGB_G(_ref6) {
4631 let [r, g, b] = _ref6;
4632 return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
4633 }
4634 static RGB_rgb(color) {
4635 return color.map(scaleAndClamp);
4636 }
4637 static RGB_HTML(color) {
4638 return `#${color.map(makeColorComp).join("")}`;
4639 }
4640 static T_HTML() {
4641 return "#00000000";
4642 }
4643 static T_rgb() {
4644 return [null];
4645 }
4646 static CMYK_RGB(_ref7) {
4647 let [c, y, m, k] = _ref7;
4648 return ["RGB", 1 - Math.min(1, c + k), 1 - Math.min(1, m + k), 1 - Math.min(1, y + k)];
4649 }
4650 static CMYK_rgb(_ref8) {
4651 let [c, y, m, k] = _ref8;
4652 return [scaleAndClamp(1 - Math.min(1, c + k)), scaleAndClamp(1 - Math.min(1, m + k)), scaleAndClamp(1 - Math.min(1, y + k))];
4653 }
4654 static CMYK_HTML(components) {
4655 const rgb = this.CMYK_RGB(components).slice(1);
4656 return this.RGB_HTML(rgb);
4657 }
4658 static RGB_CMYK(_ref9) {
4659 let [r, g, b] = _ref9;
4660 const c = 1 - r;
4661 const m = 1 - g;
4662 const y = 1 - b;
4663 const k = Math.min(c, m, y);
4664 return ["CMYK", c, m, y, k];
4665 }
4666}
4667
4668// EXTERNAL MODULE: ./src/display/xfa_layer.js
4669var xfa_layer = __webpack_require__(8284);
4670;// CONCATENATED MODULE: ./src/display/annotation_layer.js
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687const DEFAULT_TAB_INDEX = 1000;
4688const DEFAULT_FONT_SIZE = 9;
4689const GetElementsByNameSet = new WeakSet();
4690function getRectDims(rect) {
4691 return {
4692 width: rect[2] - rect[0],
4693 height: rect[3] - rect[1]
4694 };
4695}
4696class AnnotationElementFactory {
4697 static create(parameters) {
4698 const subtype = parameters.data.annotationType;
4699 switch (subtype) {
4700 case util.AnnotationType.LINK:
4701 return new LinkAnnotationElement(parameters);
4702 case util.AnnotationType.TEXT:
4703 return new TextAnnotationElement(parameters);
4704 case util.AnnotationType.WIDGET:
4705 const fieldType = parameters.data.fieldType;
4706 switch (fieldType) {
4707 case "Tx":
4708 return new TextWidgetAnnotationElement(parameters);
4709 case "Btn":
4710 if (parameters.data.radioButton) {
4711 return new RadioButtonWidgetAnnotationElement(parameters);
4712 } else if (parameters.data.checkBox) {
4713 return new CheckboxWidgetAnnotationElement(parameters);
4714 }
4715 return new PushButtonWidgetAnnotationElement(parameters);
4716 case "Ch":
4717 return new ChoiceWidgetAnnotationElement(parameters);
4718 case "Sig":
4719 return new SignatureWidgetAnnotationElement(parameters);
4720 }
4721 return new WidgetAnnotationElement(parameters);
4722 case util.AnnotationType.POPUP:
4723 return new PopupAnnotationElement(parameters);
4724 case util.AnnotationType.FREETEXT:
4725 return new FreeTextAnnotationElement(parameters);
4726 case util.AnnotationType.LINE:
4727 return new LineAnnotationElement(parameters);
4728 case util.AnnotationType.SQUARE:
4729 return new SquareAnnotationElement(parameters);
4730 case util.AnnotationType.CIRCLE:
4731 return new CircleAnnotationElement(parameters);
4732 case util.AnnotationType.POLYLINE:
4733 return new PolylineAnnotationElement(parameters);
4734 case util.AnnotationType.CARET:
4735 return new CaretAnnotationElement(parameters);
4736 case util.AnnotationType.INK:
4737 return new InkAnnotationElement(parameters);
4738 case util.AnnotationType.POLYGON:
4739 return new PolygonAnnotationElement(parameters);
4740 case util.AnnotationType.HIGHLIGHT:
4741 return new HighlightAnnotationElement(parameters);
4742 case util.AnnotationType.UNDERLINE:
4743 return new UnderlineAnnotationElement(parameters);
4744 case util.AnnotationType.SQUIGGLY:
4745 return new SquigglyAnnotationElement(parameters);
4746 case util.AnnotationType.STRIKEOUT:
4747 return new StrikeOutAnnotationElement(parameters);
4748 case util.AnnotationType.STAMP:
4749 return new StampAnnotationElement(parameters);
4750 case util.AnnotationType.FILEATTACHMENT:
4751 return new FileAttachmentAnnotationElement(parameters);
4752 default:
4753 return new AnnotationElement(parameters);
4754 }
4755 }
4756}
4757class AnnotationElement {
4758 #hasBorder = false;
4759 constructor(parameters) {
4760 let {
4761 isRenderable = false,
4762 ignoreBorder = false,
4763 createQuadrilaterals = false
4764 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4765 this.isRenderable = isRenderable;
4766 this.data = parameters.data;
4767 this.layer = parameters.layer;
4768 this.linkService = parameters.linkService;
4769 this.downloadManager = parameters.downloadManager;
4770 this.imageResourcesPath = parameters.imageResourcesPath;
4771 this.renderForms = parameters.renderForms;
4772 this.svgFactory = parameters.svgFactory;
4773 this.annotationStorage = parameters.annotationStorage;
4774 this.enableScripting = parameters.enableScripting;
4775 this.hasJSActions = parameters.hasJSActions;
4776 this._fieldObjects = parameters.fieldObjects;
4777 this.parent = parameters.parent;
4778 if (isRenderable) {
4779 this.container = this._createContainer(ignoreBorder);
4780 }
4781 if (createQuadrilaterals) {
4782 this._createQuadrilaterals();
4783 }
4784 }
4785 static _hasPopupData(_ref) {
4786 let {
4787 titleObj,
4788 contentsObj,
4789 richText
4790 } = _ref;
4791 return !!(titleObj?.str || contentsObj?.str || richText?.str);
4792 }
4793 get hasPopupData() {
4794 return AnnotationElement._hasPopupData(this.data);
4795 }
4796 _createContainer(ignoreBorder) {
4797 const {
4798 data,
4799 parent: {
4800 page,
4801 viewport
4802 }
4803 } = this;
4804 const container = document.createElement("section");
4805 container.setAttribute("data-annotation-id", data.id);
4806 if (!(this instanceof WidgetAnnotationElement)) {
4807 container.tabIndex = DEFAULT_TAB_INDEX;
4808 }
4809 container.style.zIndex = this.parent.zIndex++;
4810 if (data.popupRef) {
4811 container.setAttribute("aria-haspopup", "dialog");
4812 }
4813 if (data.alternativeText) {
4814 container.title = data.alternativeText;
4815 }
4816 if (data.noRotate) {
4817 container.classList.add("norotate");
4818 }
4819 const {
4820 pageWidth,
4821 pageHeight,
4822 pageX,
4823 pageY
4824 } = viewport.rawDims;
4825 if (!data.rect || this instanceof PopupAnnotationElement) {
4826 const {
4827 rotation
4828 } = data;
4829 if (!data.hasOwnCanvas && rotation !== 0) {
4830 this.setRotation(rotation, container);
4831 }
4832 return container;
4833 }
4834 const {
4835 width,
4836 height
4837 } = getRectDims(data.rect);
4838 const rect = util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
4839 if (!ignoreBorder && data.borderStyle.width > 0) {
4840 container.style.borderWidth = `${data.borderStyle.width}px`;
4841 const horizontalRadius = data.borderStyle.horizontalCornerRadius;
4842 const verticalRadius = data.borderStyle.verticalCornerRadius;
4843 if (horizontalRadius > 0 || verticalRadius > 0) {
4844 const radius = `calc(${horizontalRadius}px * var(--scale-factor)) / calc(${verticalRadius}px * var(--scale-factor))`;
4845 container.style.borderRadius = radius;
4846 } else if (this instanceof RadioButtonWidgetAnnotationElement) {
4847 const radius = `calc(${width}px * var(--scale-factor)) / calc(${height}px * var(--scale-factor))`;
4848 container.style.borderRadius = radius;
4849 }
4850 switch (data.borderStyle.style) {
4851 case util.AnnotationBorderStyleType.SOLID:
4852 container.style.borderStyle = "solid";
4853 break;
4854 case util.AnnotationBorderStyleType.DASHED:
4855 container.style.borderStyle = "dashed";
4856 break;
4857 case util.AnnotationBorderStyleType.BEVELED:
4858 (0,util.warn)("Unimplemented border style: beveled");
4859 break;
4860 case util.AnnotationBorderStyleType.INSET:
4861 (0,util.warn)("Unimplemented border style: inset");
4862 break;
4863 case util.AnnotationBorderStyleType.UNDERLINE:
4864 container.style.borderBottomStyle = "solid";
4865 break;
4866 default:
4867 break;
4868 }
4869 const borderColor = data.borderColor || null;
4870 if (borderColor) {
4871 this.#hasBorder = true;
4872 container.style.borderColor = util.Util.makeHexColor(borderColor[0] | 0, borderColor[1] | 0, borderColor[2] | 0);
4873 } else {
4874 container.style.borderWidth = 0;
4875 }
4876 }
4877 container.style.left = `${100 * (rect[0] - pageX) / pageWidth}%`;
4878 container.style.top = `${100 * (rect[1] - pageY) / pageHeight}%`;
4879 const {
4880 rotation
4881 } = data;
4882 if (data.hasOwnCanvas || rotation === 0) {
4883 container.style.width = `${100 * width / pageWidth}%`;
4884 container.style.height = `${100 * height / pageHeight}%`;
4885 } else {
4886 this.setRotation(rotation, container);
4887 }
4888 return container;
4889 }
4890 setRotation(angle) {
4891 let container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.container;
4892 if (!this.data.rect) {
4893 return;
4894 }
4895 const {
4896 pageWidth,
4897 pageHeight
4898 } = this.parent.viewport.rawDims;
4899 const {
4900 width,
4901 height
4902 } = getRectDims(this.data.rect);
4903 let elementWidth, elementHeight;
4904 if (angle % 180 === 0) {
4905 elementWidth = 100 * width / pageWidth;
4906 elementHeight = 100 * height / pageHeight;
4907 } else {
4908 elementWidth = 100 * height / pageWidth;
4909 elementHeight = 100 * width / pageHeight;
4910 }
4911 container.style.width = `${elementWidth}%`;
4912 container.style.height = `${elementHeight}%`;
4913 container.setAttribute("data-main-rotation", (360 - angle) % 360);
4914 }
4915 get _commonActions() {
4916 const setColor = (jsName, styleName, event) => {
4917 const color = event.detail[jsName];
4918 const colorType = color[0];
4919 const colorArray = color.slice(1);
4920 event.target.style[styleName] = ColorConverters[`${colorType}_HTML`](colorArray);
4921 this.annotationStorage.setValue(this.data.id, {
4922 [styleName]: ColorConverters[`${colorType}_rgb`](colorArray)
4923 });
4924 };
4925 return (0,util.shadow)(this, "_commonActions", {
4926 display: event => {
4927 const {
4928 display
4929 } = event.detail;
4930 const hidden = display % 2 === 1;
4931 this.container.style.visibility = hidden ? "hidden" : "visible";
4932 this.annotationStorage.setValue(this.data.id, {
4933 noView: hidden,
4934 noPrint: display === 1 || display === 2
4935 });
4936 },
4937 print: event => {
4938 this.annotationStorage.setValue(this.data.id, {
4939 noPrint: !event.detail.print
4940 });
4941 },
4942 hidden: event => {
4943 const {
4944 hidden
4945 } = event.detail;
4946 this.container.style.visibility = hidden ? "hidden" : "visible";
4947 this.annotationStorage.setValue(this.data.id, {
4948 noPrint: hidden,
4949 noView: hidden
4950 });
4951 },
4952 focus: event => {
4953 setTimeout(() => event.target.focus({
4954 preventScroll: false
4955 }), 0);
4956 },
4957 userName: event => {
4958 event.target.title = event.detail.userName;
4959 },
4960 readonly: event => {
4961 event.target.disabled = event.detail.readonly;
4962 },
4963 required: event => {
4964 this._setRequired(event.target, event.detail.required);
4965 },
4966 bgColor: event => {
4967 setColor("bgColor", "backgroundColor", event);
4968 },
4969 fillColor: event => {
4970 setColor("fillColor", "backgroundColor", event);
4971 },
4972 fgColor: event => {
4973 setColor("fgColor", "color", event);
4974 },
4975 textColor: event => {
4976 setColor("textColor", "color", event);
4977 },
4978 borderColor: event => {
4979 setColor("borderColor", "borderColor", event);
4980 },
4981 strokeColor: event => {
4982 setColor("strokeColor", "borderColor", event);
4983 },
4984 rotation: event => {
4985 const angle = event.detail.rotation;
4986 this.setRotation(angle);
4987 this.annotationStorage.setValue(this.data.id, {
4988 rotation: angle
4989 });
4990 }
4991 });
4992 }
4993 _dispatchEventFromSandbox(actions, jsEvent) {
4994 const commonActions = this._commonActions;
4995 for (const name of Object.keys(jsEvent.detail)) {
4996 const action = actions[name] || commonActions[name];
4997 action?.(jsEvent);
4998 }
4999 }
5000 _setDefaultPropertiesFromJS(element) {
5001 if (!this.enableScripting) {
5002 return;
5003 }
5004 const storedData = this.annotationStorage.getRawValue(this.data.id);
5005 if (!storedData) {
5006 return;
5007 }
5008 const commonActions = this._commonActions;
5009 for (const [actionName, detail] of Object.entries(storedData)) {
5010 const action = commonActions[actionName];
5011 if (action) {
5012 const eventProxy = {
5013 detail: {
5014 [actionName]: detail
5015 },
5016 target: element
5017 };
5018 action(eventProxy);
5019 delete storedData[actionName];
5020 }
5021 }
5022 }
5023 _createQuadrilaterals() {
5024 if (!this.container) {
5025 return;
5026 }
5027 const {
5028 quadPoints
5029 } = this.data;
5030 if (!quadPoints) {
5031 return;
5032 }
5033 const [rectBlX, rectBlY, rectTrX, rectTrY] = this.data.rect;
5034 if (quadPoints.length === 1) {
5035 const [, {
5036 x: trX,
5037 y: trY
5038 }, {
5039 x: blX,
5040 y: blY
5041 }] = quadPoints[0];
5042 if (rectTrX === trX && rectTrY === trY && rectBlX === blX && rectBlY === blY) {
5043 return;
5044 }
5045 }
5046 const {
5047 style
5048 } = this.container;
5049 let svgBuffer;
5050 if (this.#hasBorder) {
5051 const {
5052 borderColor,
5053 borderWidth
5054 } = style;
5055 style.borderWidth = 0;
5056 svgBuffer = ["url('data:image/svg+xml;utf8,", `<svg xmlns="http://www.w3.org/2000/svg"`, ` preserveAspectRatio="none" viewBox="0 0 1 1">`, `<g fill="transparent" stroke="${borderColor}" stroke-width="${borderWidth}">`];
5057 this.container.classList.add("hasBorder");
5058 }
5059 const width = rectTrX - rectBlX;
5060 const height = rectTrY - rectBlY;
5061 const {
5062 svgFactory
5063 } = this;
5064 const svg = svgFactory.createElement("svg");
5065 svg.classList.add("quadrilateralsContainer");
5066 svg.setAttribute("width", 0);
5067 svg.setAttribute("height", 0);
5068 const defs = svgFactory.createElement("defs");
5069 svg.append(defs);
5070 const clipPath = svgFactory.createElement("clipPath");
5071 const id = `clippath_${this.data.id}`;
5072 clipPath.setAttribute("id", id);
5073 clipPath.setAttribute("clipPathUnits", "objectBoundingBox");
5074 defs.append(clipPath);
5075 for (const [, {
5076 x: trX,
5077 y: trY
5078 }, {
5079 x: blX,
5080 y: blY
5081 }] of quadPoints) {
5082 const rect = svgFactory.createElement("rect");
5083 const x = (blX - rectBlX) / width;
5084 const y = (rectTrY - trY) / height;
5085 const rectWidth = (trX - blX) / width;
5086 const rectHeight = (trY - blY) / height;
5087 rect.setAttribute("x", x);
5088 rect.setAttribute("y", y);
5089 rect.setAttribute("width", rectWidth);
5090 rect.setAttribute("height", rectHeight);
5091 clipPath.append(rect);
5092 svgBuffer?.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${y}" width="${rectWidth}" height="${rectHeight}"/>`);
5093 }
5094 if (this.#hasBorder) {
5095 svgBuffer.push(`</g></svg>')`);
5096 style.backgroundImage = svgBuffer.join("");
5097 }
5098 this.container.append(svg);
5099 this.container.style.clipPath = `url(#${id})`;
5100 }
5101 _createPopup() {
5102 const {
5103 container,
5104 data
5105 } = this;
5106 container.setAttribute("aria-haspopup", "dialog");
5107 const popup = new PopupAnnotationElement({
5108 data: {
5109 color: data.color,
5110 titleObj: data.titleObj,
5111 modificationDate: data.modificationDate,
5112 contentsObj: data.contentsObj,
5113 richText: data.richText,
5114 parentRect: data.rect,
5115 borderStyle: 0,
5116 id: `popup_${data.id}`,
5117 rotation: data.rotation
5118 },
5119 parent: this.parent,
5120 elements: [this]
5121 });
5122 this.parent.div.append(popup.render());
5123 }
5124 render() {
5125 (0,util.unreachable)("Abstract method `AnnotationElement.render` called");
5126 }
5127 _getElementsByName(name) {
5128 let skipId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
5129 const fields = [];
5130 if (this._fieldObjects) {
5131 const fieldObj = this._fieldObjects[name];
5132 if (fieldObj) {
5133 for (const {
5134 page,
5135 id,
5136 exportValues
5137 } of fieldObj) {
5138 if (page === -1) {
5139 continue;
5140 }
5141 if (id === skipId) {
5142 continue;
5143 }
5144 const exportValue = typeof exportValues === "string" ? exportValues : null;
5145 const domElement = document.querySelector(`[data-element-id="${id}"]`);
5146 if (domElement && !GetElementsByNameSet.has(domElement)) {
5147 (0,util.warn)(`_getElementsByName - element not allowed: ${id}`);
5148 continue;
5149 }
5150 fields.push({
5151 id,
5152 exportValue,
5153 domElement
5154 });
5155 }
5156 }
5157 return fields;
5158 }
5159 for (const domElement of document.getElementsByName(name)) {
5160 const {
5161 exportValue
5162 } = domElement;
5163 const id = domElement.getAttribute("data-element-id");
5164 if (id === skipId) {
5165 continue;
5166 }
5167 if (!GetElementsByNameSet.has(domElement)) {
5168 continue;
5169 }
5170 fields.push({
5171 id,
5172 exportValue,
5173 domElement
5174 });
5175 }
5176 return fields;
5177 }
5178 show() {
5179 if (this.container) {
5180 this.container.hidden = false;
5181 }
5182 this.popup?.maybeShow();
5183 }
5184 hide() {
5185 if (this.container) {
5186 this.container.hidden = true;
5187 }
5188 this.popup?.forceHide();
5189 }
5190 getElementsToTriggerPopup() {
5191 return this.container;
5192 }
5193 addHighlightArea() {
5194 const triggers = this.getElementsToTriggerPopup();
5195 if (Array.isArray(triggers)) {
5196 for (const element of triggers) {
5197 element.classList.add("highlightArea");
5198 }
5199 } else {
5200 triggers.classList.add("highlightArea");
5201 }
5202 }
5203 get _isEditable() {
5204 return false;
5205 }
5206 _editOnDoubleClick() {
5207 if (!this._isEditable) {
5208 return;
5209 }
5210 const {
5211 annotationEditorType: mode,
5212 data: {
5213 id: editId
5214 }
5215 } = this;
5216 this.container.addEventListener("dblclick", () => {
5217 this.linkService.eventBus?.dispatch("switchannotationeditormode", {
5218 source: this,
5219 mode,
5220 editId
5221 });
5222 });
5223 }
5224}
5225class LinkAnnotationElement extends AnnotationElement {
5226 constructor(parameters) {
5227 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
5228 super(parameters, {
5229 isRenderable: true,
5230 ignoreBorder: !!options?.ignoreBorder,
5231 createQuadrilaterals: true
5232 });
5233 this.isTooltipOnly = parameters.data.isTooltipOnly;
5234 }
5235 render() {
5236 const {
5237 data,
5238 linkService
5239 } = this;
5240 const link = document.createElement("a");
5241 link.setAttribute("data-element-id", data.id);
5242 let isBound = false;
5243 if (data.url) {
5244 linkService.addLinkAttributes(link, data.url, data.newWindow);
5245 isBound = true;
5246 } else if (data.action) {
5247 this._bindNamedAction(link, data.action);
5248 isBound = true;
5249 } else if (data.attachment) {
5250 this.#bindAttachment(link, data.attachment, data.attachmentDest);
5251 isBound = true;
5252 } else if (data.setOCGState) {
5253 this.#bindSetOCGState(link, data.setOCGState);
5254 isBound = true;
5255 } else if (data.dest) {
5256 this._bindLink(link, data.dest);
5257 isBound = true;
5258 } else {
5259 if (data.actions && (data.actions.Action || data.actions["Mouse Up"] || data.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions) {
5260 this._bindJSAction(link, data);
5261 isBound = true;
5262 }
5263 if (data.resetForm) {
5264 this._bindResetFormAction(link, data.resetForm);
5265 isBound = true;
5266 } else if (this.isTooltipOnly && !isBound) {
5267 this._bindLink(link, "");
5268 isBound = true;
5269 }
5270 }
5271 this.container.classList.add("linkAnnotation");
5272 if (isBound) {
5273 this.container.append(link);
5274 }
5275 return this.container;
5276 }
5277 #setInternalLink() {
5278 this.container.setAttribute("data-internal-link", "");
5279 }
5280 _bindLink(link, destination) {
5281 link.href = this.linkService.getDestinationHash(destination);
5282 link.onclick = () => {
5283 if (destination) {
5284 this.linkService.goToDestination(destination);
5285 }
5286 return false;
5287 };
5288 if (destination || destination === "") {
5289 this.#setInternalLink();
5290 }
5291 }
5292 _bindNamedAction(link, action) {
5293 link.href = this.linkService.getAnchorUrl("");
5294 link.onclick = () => {
5295 this.linkService.executeNamedAction(action);
5296 return false;
5297 };
5298 this.#setInternalLink();
5299 }
5300 #bindAttachment(link, attachment) {
5301 let dest = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
5302 link.href = this.linkService.getAnchorUrl("");
5303 link.onclick = () => {
5304 this.downloadManager?.openOrDownloadData(attachment.content, attachment.filename, dest);
5305 return false;
5306 };
5307 this.#setInternalLink();
5308 }
5309 #bindSetOCGState(link, action) {
5310 link.href = this.linkService.getAnchorUrl("");
5311 link.onclick = () => {
5312 this.linkService.executeSetOCGState(action);
5313 return false;
5314 };
5315 this.#setInternalLink();
5316 }
5317 _bindJSAction(link, data) {
5318 link.href = this.linkService.getAnchorUrl("");
5319 const map = new Map([["Action", "onclick"], ["Mouse Up", "onmouseup"], ["Mouse Down", "onmousedown"]]);
5320 for (const name of Object.keys(data.actions)) {
5321 const jsName = map.get(name);
5322 if (!jsName) {
5323 continue;
5324 }
5325 link[jsName] = () => {
5326 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
5327 source: this,
5328 detail: {
5329 id: data.id,
5330 name
5331 }
5332 });
5333 return false;
5334 };
5335 }
5336 if (!link.onclick) {
5337 link.onclick = () => false;
5338 }
5339 this.#setInternalLink();
5340 }
5341 _bindResetFormAction(link, resetForm) {
5342 const otherClickAction = link.onclick;
5343 if (!otherClickAction) {
5344 link.href = this.linkService.getAnchorUrl("");
5345 }
5346 this.#setInternalLink();
5347 if (!this._fieldObjects) {
5348 (0,util.warn)(`_bindResetFormAction - "resetForm" action not supported, ` + "ensure that the `fieldObjects` parameter is provided.");
5349 if (!otherClickAction) {
5350 link.onclick = () => false;
5351 }
5352 return;
5353 }
5354 link.onclick = () => {
5355 otherClickAction?.();
5356 const {
5357 fields: resetFormFields,
5358 refs: resetFormRefs,
5359 include
5360 } = resetForm;
5361 const allFields = [];
5362 if (resetFormFields.length !== 0 || resetFormRefs.length !== 0) {
5363 const fieldIds = new Set(resetFormRefs);
5364 for (const fieldName of resetFormFields) {
5365 const fields = this._fieldObjects[fieldName] || [];
5366 for (const {
5367 id
5368 } of fields) {
5369 fieldIds.add(id);
5370 }
5371 }
5372 for (const fields of Object.values(this._fieldObjects)) {
5373 for (const field of fields) {
5374 if (fieldIds.has(field.id) === include) {
5375 allFields.push(field);
5376 }
5377 }
5378 }
5379 } else {
5380 for (const fields of Object.values(this._fieldObjects)) {
5381 allFields.push(...fields);
5382 }
5383 }
5384 const storage = this.annotationStorage;
5385 const allIds = [];
5386 for (const field of allFields) {
5387 const {
5388 id
5389 } = field;
5390 allIds.push(id);
5391 switch (field.type) {
5392 case "text":
5393 {
5394 const value = field.defaultValue || "";
5395 storage.setValue(id, {
5396 value
5397 });
5398 break;
5399 }
5400 case "checkbox":
5401 case "radiobutton":
5402 {
5403 const value = field.defaultValue === field.exportValues;
5404 storage.setValue(id, {
5405 value
5406 });
5407 break;
5408 }
5409 case "combobox":
5410 case "listbox":
5411 {
5412 const value = field.defaultValue || "";
5413 storage.setValue(id, {
5414 value
5415 });
5416 break;
5417 }
5418 default:
5419 continue;
5420 }
5421 const domElement = document.querySelector(`[data-element-id="${id}"]`);
5422 if (!domElement) {
5423 continue;
5424 } else if (!GetElementsByNameSet.has(domElement)) {
5425 (0,util.warn)(`_bindResetFormAction - element not allowed: ${id}`);
5426 continue;
5427 }
5428 domElement.dispatchEvent(new Event("resetform"));
5429 }
5430 if (this.enableScripting) {
5431 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
5432 source: this,
5433 detail: {
5434 id: "app",
5435 ids: allIds,
5436 name: "ResetForm"
5437 }
5438 });
5439 }
5440 return false;
5441 };
5442 }
5443}
5444class TextAnnotationElement extends AnnotationElement {
5445 constructor(parameters) {
5446 super(parameters, {
5447 isRenderable: true
5448 });
5449 }
5450 render() {
5451 this.container.classList.add("textAnnotation");
5452 const image = document.createElement("img");
5453 image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
5454 image.setAttribute("data-l10n-id", "pdfjs-text-annotation-type");
5455 image.setAttribute("data-l10n-args", JSON.stringify({
5456 type: this.data.name
5457 }));
5458 if (!this.data.popupRef && this.hasPopupData) {
5459 this._createPopup();
5460 }
5461 this.container.append(image);
5462 return this.container;
5463 }
5464}
5465class WidgetAnnotationElement extends AnnotationElement {
5466 render() {
5467 return this.container;
5468 }
5469 showElementAndHideCanvas(element) {
5470 if (this.data.hasOwnCanvas) {
5471 if (element.previousSibling?.nodeName === "CANVAS") {
5472 element.previousSibling.hidden = true;
5473 }
5474 element.hidden = false;
5475 }
5476 }
5477 _getKeyModifier(event) {
5478 return util.FeatureTest.platform.isMac ? event.metaKey : event.ctrlKey;
5479 }
5480 _setEventListener(element, elementData, baseName, eventName, valueGetter) {
5481 if (baseName.includes("mouse")) {
5482 element.addEventListener(baseName, event => {
5483 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
5484 source: this,
5485 detail: {
5486 id: this.data.id,
5487 name: eventName,
5488 value: valueGetter(event),
5489 shift: event.shiftKey,
5490 modifier: this._getKeyModifier(event)
5491 }
5492 });
5493 });
5494 } else {
5495 element.addEventListener(baseName, event => {
5496 if (baseName === "blur") {
5497 if (!elementData.focused || !event.relatedTarget) {
5498 return;
5499 }
5500 elementData.focused = false;
5501 } else if (baseName === "focus") {
5502 if (elementData.focused) {
5503 return;
5504 }
5505 elementData.focused = true;
5506 }
5507 if (!valueGetter) {
5508 return;
5509 }
5510 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
5511 source: this,
5512 detail: {
5513 id: this.data.id,
5514 name: eventName,
5515 value: valueGetter(event)
5516 }
5517 });
5518 });
5519 }
5520 }
5521 _setEventListeners(element, elementData, names, getter) {
5522 for (const [baseName, eventName] of names) {
5523 if (eventName === "Action" || this.data.actions?.[eventName]) {
5524 if (eventName === "Focus" || eventName === "Blur") {
5525 elementData ||= {
5526 focused: false
5527 };
5528 }
5529 this._setEventListener(element, elementData, baseName, eventName, getter);
5530 if (eventName === "Focus" && !this.data.actions?.Blur) {
5531 this._setEventListener(element, elementData, "blur", "Blur", null);
5532 } else if (eventName === "Blur" && !this.data.actions?.Focus) {
5533 this._setEventListener(element, elementData, "focus", "Focus", null);
5534 }
5535 }
5536 }
5537 }
5538 _setBackgroundColor(element) {
5539 const color = this.data.backgroundColor || null;
5540 element.style.backgroundColor = color === null ? "transparent" : util.Util.makeHexColor(color[0], color[1], color[2]);
5541 }
5542 _setTextStyle(element) {
5543 const TEXT_ALIGNMENT = ["left", "center", "right"];
5544 const {
5545 fontColor
5546 } = this.data.defaultAppearanceData;
5547 const fontSize = this.data.defaultAppearanceData.fontSize || DEFAULT_FONT_SIZE;
5548 const style = element.style;
5549 let computedFontSize;
5550 const BORDER_SIZE = 2;
5551 const roundToOneDecimal = x => Math.round(10 * x) / 10;
5552 if (this.data.multiLine) {
5553 const height = Math.abs(this.data.rect[3] - this.data.rect[1] - BORDER_SIZE);
5554 const numberOfLines = Math.round(height / (util.LINE_FACTOR * fontSize)) || 1;
5555 const lineHeight = height / numberOfLines;
5556 computedFontSize = Math.min(fontSize, roundToOneDecimal(lineHeight / util.LINE_FACTOR));
5557 } else {
5558 const height = Math.abs(this.data.rect[3] - this.data.rect[1] - BORDER_SIZE);
5559 computedFontSize = Math.min(fontSize, roundToOneDecimal(height / util.LINE_FACTOR));
5560 }
5561 style.fontSize = `calc(${computedFontSize}px * var(--scale-factor))`;
5562 style.color = util.Util.makeHexColor(fontColor[0], fontColor[1], fontColor[2]);
5563 if (this.data.textAlignment !== null) {
5564 style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
5565 }
5566 }
5567 _setRequired(element, isRequired) {
5568 if (isRequired) {
5569 element.setAttribute("required", true);
5570 } else {
5571 element.removeAttribute("required");
5572 }
5573 element.setAttribute("aria-required", isRequired);
5574 }
5575}
5576class TextWidgetAnnotationElement extends WidgetAnnotationElement {
5577 constructor(parameters) {
5578 const isRenderable = parameters.renderForms || parameters.data.hasOwnCanvas || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
5579 super(parameters, {
5580 isRenderable
5581 });
5582 }
5583 setPropertyOnSiblings(base, key, value, keyInStorage) {
5584 const storage = this.annotationStorage;
5585 for (const element of this._getElementsByName(base.name, base.id)) {
5586 if (element.domElement) {
5587 element.domElement[key] = value;
5588 }
5589 storage.setValue(element.id, {
5590 [keyInStorage]: value
5591 });
5592 }
5593 }
5594 render() {
5595 const storage = this.annotationStorage;
5596 const id = this.data.id;
5597 this.container.classList.add("textWidgetAnnotation");
5598 let element = null;
5599 if (this.renderForms) {
5600 const storedData = storage.getValue(id, {
5601 value: this.data.fieldValue
5602 });
5603 let textContent = storedData.value || "";
5604 const maxLen = storage.getValue(id, {
5605 charLimit: this.data.maxLen
5606 }).charLimit;
5607 if (maxLen && textContent.length > maxLen) {
5608 textContent = textContent.slice(0, maxLen);
5609 }
5610 let fieldFormattedValues = storedData.formattedValue || this.data.textContent?.join("\n") || null;
5611 if (fieldFormattedValues && this.data.comb) {
5612 fieldFormattedValues = fieldFormattedValues.replaceAll(/\s+/g, "");
5613 }
5614 const elementData = {
5615 userValue: textContent,
5616 formattedValue: fieldFormattedValues,
5617 lastCommittedValue: null,
5618 commitKey: 1,
5619 focused: false
5620 };
5621 if (this.data.multiLine) {
5622 element = document.createElement("textarea");
5623 element.textContent = fieldFormattedValues ?? textContent;
5624 if (this.data.doNotScroll) {
5625 element.style.overflowY = "hidden";
5626 }
5627 } else {
5628 element = document.createElement("input");
5629 element.type = "text";
5630 element.setAttribute("value", fieldFormattedValues ?? textContent);
5631 if (this.data.doNotScroll) {
5632 element.style.overflowX = "hidden";
5633 }
5634 }
5635 if (this.data.hasOwnCanvas) {
5636 element.hidden = true;
5637 }
5638 GetElementsByNameSet.add(element);
5639 element.setAttribute("data-element-id", id);
5640 element.disabled = this.data.readOnly;
5641 element.name = this.data.fieldName;
5642 element.tabIndex = DEFAULT_TAB_INDEX;
5643 this._setRequired(element, this.data.required);
5644 if (maxLen) {
5645 element.maxLength = maxLen;
5646 }
5647 element.addEventListener("input", event => {
5648 storage.setValue(id, {
5649 value: event.target.value
5650 });
5651 this.setPropertyOnSiblings(element, "value", event.target.value, "value");
5652 elementData.formattedValue = null;
5653 });
5654 element.addEventListener("resetform", event => {
5655 const defaultValue = this.data.defaultFieldValue ?? "";
5656 element.value = elementData.userValue = defaultValue;
5657 elementData.formattedValue = null;
5658 });
5659 let blurListener = event => {
5660 const {
5661 formattedValue
5662 } = elementData;
5663 if (formattedValue !== null && formattedValue !== undefined) {
5664 event.target.value = formattedValue;
5665 }
5666 event.target.scrollLeft = 0;
5667 };
5668 if (this.enableScripting && this.hasJSActions) {
5669 element.addEventListener("focus", event => {
5670 if (elementData.focused) {
5671 return;
5672 }
5673 const {
5674 target
5675 } = event;
5676 if (elementData.userValue) {
5677 target.value = elementData.userValue;
5678 }
5679 elementData.lastCommittedValue = target.value;
5680 elementData.commitKey = 1;
5681 if (!this.data.actions?.Focus) {
5682 elementData.focused = true;
5683 }
5684 });
5685 element.addEventListener("updatefromsandbox", jsEvent => {
5686 this.showElementAndHideCanvas(jsEvent.target);
5687 const actions = {
5688 value(event) {
5689 elementData.userValue = event.detail.value ?? "";
5690 storage.setValue(id, {
5691 value: elementData.userValue.toString()
5692 });
5693 event.target.value = elementData.userValue;
5694 },
5695 formattedValue(event) {
5696 const {
5697 formattedValue
5698 } = event.detail;
5699 elementData.formattedValue = formattedValue;
5700 if (formattedValue !== null && formattedValue !== undefined && event.target !== document.activeElement) {
5701 event.target.value = formattedValue;
5702 }
5703 storage.setValue(id, {
5704 formattedValue
5705 });
5706 },
5707 selRange(event) {
5708 event.target.setSelectionRange(...event.detail.selRange);
5709 },
5710 charLimit: event => {
5711 const {
5712 charLimit
5713 } = event.detail;
5714 const {
5715 target
5716 } = event;
5717 if (charLimit === 0) {
5718 target.removeAttribute("maxLength");
5719 return;
5720 }
5721 target.setAttribute("maxLength", charLimit);
5722 let value = elementData.userValue;
5723 if (!value || value.length <= charLimit) {
5724 return;
5725 }
5726 value = value.slice(0, charLimit);
5727 target.value = elementData.userValue = value;
5728 storage.setValue(id, {
5729 value
5730 });
5731 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
5732 source: this,
5733 detail: {
5734 id,
5735 name: "Keystroke",
5736 value,
5737 willCommit: true,
5738 commitKey: 1,
5739 selStart: target.selectionStart,
5740 selEnd: target.selectionEnd
5741 }
5742 });
5743 }
5744 };
5745 this._dispatchEventFromSandbox(actions, jsEvent);
5746 });
5747 element.addEventListener("keydown", event => {
5748 elementData.commitKey = 1;
5749 let commitKey = -1;
5750 if (event.key === "Escape") {
5751 commitKey = 0;
5752 } else if (event.key === "Enter" && !this.data.multiLine) {
5753 commitKey = 2;
5754 } else if (event.key === "Tab") {
5755 elementData.commitKey = 3;
5756 }
5757 if (commitKey === -1) {
5758 return;
5759 }
5760 const {
5761 value
5762 } = event.target;
5763 if (elementData.lastCommittedValue === value) {
5764 return;
5765 }
5766 elementData.lastCommittedValue = value;
5767 elementData.userValue = value;
5768 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
5769 source: this,
5770 detail: {
5771 id,
5772 name: "Keystroke",
5773 value,
5774 willCommit: true,
5775 commitKey,
5776 selStart: event.target.selectionStart,
5777 selEnd: event.target.selectionEnd
5778 }
5779 });
5780 });
5781 const _blurListener = blurListener;
5782 blurListener = null;
5783 element.addEventListener("blur", event => {
5784 if (!elementData.focused || !event.relatedTarget) {
5785 return;
5786 }
5787 if (!this.data.actions?.Blur) {
5788 elementData.focused = false;
5789 }
5790 const {
5791 value
5792 } = event.target;
5793 elementData.userValue = value;
5794 if (elementData.lastCommittedValue !== value) {
5795 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
5796 source: this,
5797 detail: {
5798 id,
5799 name: "Keystroke",
5800 value,
5801 willCommit: true,
5802 commitKey: elementData.commitKey,
5803 selStart: event.target.selectionStart,
5804 selEnd: event.target.selectionEnd
5805 }
5806 });
5807 }
5808 _blurListener(event);
5809 });
5810 if (this.data.actions?.Keystroke) {
5811 element.addEventListener("beforeinput", event => {
5812 elementData.lastCommittedValue = null;
5813 const {
5814 data,
5815 target
5816 } = event;
5817 const {
5818 value,
5819 selectionStart,
5820 selectionEnd
5821 } = target;
5822 let selStart = selectionStart,
5823 selEnd = selectionEnd;
5824 switch (event.inputType) {
5825 case "deleteWordBackward":
5826 {
5827 const match = value.substring(0, selectionStart).match(/\w*[^\w]*$/);
5828 if (match) {
5829 selStart -= match[0].length;
5830 }
5831 break;
5832 }
5833 case "deleteWordForward":
5834 {
5835 const match = value.substring(selectionStart).match(/^[^\w]*\w*/);
5836 if (match) {
5837 selEnd += match[0].length;
5838 }
5839 break;
5840 }
5841 case "deleteContentBackward":
5842 if (selectionStart === selectionEnd) {
5843 selStart -= 1;
5844 }
5845 break;
5846 case "deleteContentForward":
5847 if (selectionStart === selectionEnd) {
5848 selEnd += 1;
5849 }
5850 break;
5851 }
5852 event.preventDefault();
5853 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
5854 source: this,
5855 detail: {
5856 id,
5857 name: "Keystroke",
5858 value,
5859 change: data || "",
5860 willCommit: false,
5861 selStart,
5862 selEnd
5863 }
5864 });
5865 });
5866 }
5867 this._setEventListeners(element, elementData, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.value);
5868 }
5869 if (blurListener) {
5870 element.addEventListener("blur", blurListener);
5871 }
5872 if (this.data.comb) {
5873 const fieldWidth = this.data.rect[2] - this.data.rect[0];
5874 const combWidth = fieldWidth / maxLen;
5875 element.classList.add("comb");
5876 element.style.letterSpacing = `calc(${combWidth}px * var(--scale-factor) - 1ch)`;
5877 }
5878 } else {
5879 element = document.createElement("div");
5880 element.textContent = this.data.fieldValue;
5881 element.style.verticalAlign = "middle";
5882 element.style.display = "table-cell";
5883 if (this.data.hasOwnCanvas) {
5884 element.hidden = true;
5885 }
5886 }
5887 this._setTextStyle(element);
5888 this._setBackgroundColor(element);
5889 this._setDefaultPropertiesFromJS(element);
5890 this.container.append(element);
5891 return this.container;
5892 }
5893}
5894class SignatureWidgetAnnotationElement extends WidgetAnnotationElement {
5895 constructor(parameters) {
5896 super(parameters, {
5897 isRenderable: !!parameters.data.hasOwnCanvas
5898 });
5899 }
5900}
5901class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
5902 constructor(parameters) {
5903 super(parameters, {
5904 isRenderable: parameters.renderForms
5905 });
5906 }
5907 render() {
5908 const storage = this.annotationStorage;
5909 const data = this.data;
5910 const id = data.id;
5911 let value = storage.getValue(id, {
5912 value: data.exportValue === data.fieldValue
5913 }).value;
5914 if (typeof value === "string") {
5915 value = value !== "Off";
5916 storage.setValue(id, {
5917 value
5918 });
5919 }
5920 this.container.classList.add("buttonWidgetAnnotation", "checkBox");
5921 const element = document.createElement("input");
5922 GetElementsByNameSet.add(element);
5923 element.setAttribute("data-element-id", id);
5924 element.disabled = data.readOnly;
5925 this._setRequired(element, this.data.required);
5926 element.type = "checkbox";
5927 element.name = data.fieldName;
5928 if (value) {
5929 element.setAttribute("checked", true);
5930 }
5931 element.setAttribute("exportValue", data.exportValue);
5932 element.tabIndex = DEFAULT_TAB_INDEX;
5933 element.addEventListener("change", event => {
5934 const {
5935 name,
5936 checked
5937 } = event.target;
5938 for (const checkbox of this._getElementsByName(name, id)) {
5939 const curChecked = checked && checkbox.exportValue === data.exportValue;
5940 if (checkbox.domElement) {
5941 checkbox.domElement.checked = curChecked;
5942 }
5943 storage.setValue(checkbox.id, {
5944 value: curChecked
5945 });
5946 }
5947 storage.setValue(id, {
5948 value: checked
5949 });
5950 });
5951 element.addEventListener("resetform", event => {
5952 const defaultValue = data.defaultFieldValue || "Off";
5953 event.target.checked = defaultValue === data.exportValue;
5954 });
5955 if (this.enableScripting && this.hasJSActions) {
5956 element.addEventListener("updatefromsandbox", jsEvent => {
5957 const actions = {
5958 value(event) {
5959 event.target.checked = event.detail.value !== "Off";
5960 storage.setValue(id, {
5961 value: event.target.checked
5962 });
5963 }
5964 };
5965 this._dispatchEventFromSandbox(actions, jsEvent);
5966 });
5967 this._setEventListeners(element, null, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
5968 }
5969 this._setBackgroundColor(element);
5970 this._setDefaultPropertiesFromJS(element);
5971 this.container.append(element);
5972 return this.container;
5973 }
5974}
5975class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
5976 constructor(parameters) {
5977 super(parameters, {
5978 isRenderable: parameters.renderForms
5979 });
5980 }
5981 render() {
5982 this.container.classList.add("buttonWidgetAnnotation", "radioButton");
5983 const storage = this.annotationStorage;
5984 const data = this.data;
5985 const id = data.id;
5986 let value = storage.getValue(id, {
5987 value: data.fieldValue === data.buttonValue
5988 }).value;
5989 if (typeof value === "string") {
5990 value = value !== data.buttonValue;
5991 storage.setValue(id, {
5992 value
5993 });
5994 }
5995 if (value) {
5996 for (const radio of this._getElementsByName(data.fieldName, id)) {
5997 storage.setValue(radio.id, {
5998 value: false
5999 });
6000 }
6001 }
6002 const element = document.createElement("input");
6003 GetElementsByNameSet.add(element);
6004 element.setAttribute("data-element-id", id);
6005 element.disabled = data.readOnly;
6006 this._setRequired(element, this.data.required);
6007 element.type = "radio";
6008 element.name = data.fieldName;
6009 if (value) {
6010 element.setAttribute("checked", true);
6011 }
6012 element.tabIndex = DEFAULT_TAB_INDEX;
6013 element.addEventListener("change", event => {
6014 const {
6015 name,
6016 checked
6017 } = event.target;
6018 for (const radio of this._getElementsByName(name, id)) {
6019 storage.setValue(radio.id, {
6020 value: false
6021 });
6022 }
6023 storage.setValue(id, {
6024 value: checked
6025 });
6026 });
6027 element.addEventListener("resetform", event => {
6028 const defaultValue = data.defaultFieldValue;
6029 event.target.checked = defaultValue !== null && defaultValue !== undefined && defaultValue === data.buttonValue;
6030 });
6031 if (this.enableScripting && this.hasJSActions) {
6032 const pdfButtonValue = data.buttonValue;
6033 element.addEventListener("updatefromsandbox", jsEvent => {
6034 const actions = {
6035 value: event => {
6036 const checked = pdfButtonValue === event.detail.value;
6037 for (const radio of this._getElementsByName(event.target.name)) {
6038 const curChecked = checked && radio.id === id;
6039 if (radio.domElement) {
6040 radio.domElement.checked = curChecked;
6041 }
6042 storage.setValue(radio.id, {
6043 value: curChecked
6044 });
6045 }
6046 }
6047 };
6048 this._dispatchEventFromSandbox(actions, jsEvent);
6049 });
6050 this._setEventListeners(element, null, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
6051 }
6052 this._setBackgroundColor(element);
6053 this._setDefaultPropertiesFromJS(element);
6054 this.container.append(element);
6055 return this.container;
6056 }
6057}
6058class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
6059 constructor(parameters) {
6060 super(parameters, {
6061 ignoreBorder: parameters.data.hasAppearance
6062 });
6063 }
6064 render() {
6065 const container = super.render();
6066 container.classList.add("buttonWidgetAnnotation", "pushButton");
6067 const linkElement = container.lastChild;
6068 if (this.enableScripting && this.hasJSActions && linkElement) {
6069 this._setDefaultPropertiesFromJS(linkElement);
6070 linkElement.addEventListener("updatefromsandbox", jsEvent => {
6071 this._dispatchEventFromSandbox({}, jsEvent);
6072 });
6073 }
6074 return container;
6075 }
6076}
6077class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
6078 constructor(parameters) {
6079 super(parameters, {
6080 isRenderable: parameters.renderForms
6081 });
6082 }
6083 render() {
6084 this.container.classList.add("choiceWidgetAnnotation");
6085 const storage = this.annotationStorage;
6086 const id = this.data.id;
6087 const storedData = storage.getValue(id, {
6088 value: this.data.fieldValue
6089 });
6090 const selectElement = document.createElement("select");
6091 GetElementsByNameSet.add(selectElement);
6092 selectElement.setAttribute("data-element-id", id);
6093 selectElement.disabled = this.data.readOnly;
6094 this._setRequired(selectElement, this.data.required);
6095 selectElement.name = this.data.fieldName;
6096 selectElement.tabIndex = DEFAULT_TAB_INDEX;
6097 let addAnEmptyEntry = this.data.combo && this.data.options.length > 0;
6098 if (!this.data.combo) {
6099 selectElement.size = this.data.options.length;
6100 if (this.data.multiSelect) {
6101 selectElement.multiple = true;
6102 }
6103 }
6104 selectElement.addEventListener("resetform", event => {
6105 const defaultValue = this.data.defaultFieldValue;
6106 for (const option of selectElement.options) {
6107 option.selected = option.value === defaultValue;
6108 }
6109 });
6110 for (const option of this.data.options) {
6111 const optionElement = document.createElement("option");
6112 optionElement.textContent = option.displayValue;
6113 optionElement.value = option.exportValue;
6114 if (storedData.value.includes(option.exportValue)) {
6115 optionElement.setAttribute("selected", true);
6116 addAnEmptyEntry = false;
6117 }
6118 selectElement.append(optionElement);
6119 }
6120 let removeEmptyEntry = null;
6121 if (addAnEmptyEntry) {
6122 const noneOptionElement = document.createElement("option");
6123 noneOptionElement.value = " ";
6124 noneOptionElement.setAttribute("hidden", true);
6125 noneOptionElement.setAttribute("selected", true);
6126 selectElement.prepend(noneOptionElement);
6127 removeEmptyEntry = () => {
6128 noneOptionElement.remove();
6129 selectElement.removeEventListener("input", removeEmptyEntry);
6130 removeEmptyEntry = null;
6131 };
6132 selectElement.addEventListener("input", removeEmptyEntry);
6133 }
6134 const getValue = isExport => {
6135 const name = isExport ? "value" : "textContent";
6136 const {
6137 options,
6138 multiple
6139 } = selectElement;
6140 if (!multiple) {
6141 return options.selectedIndex === -1 ? null : options[options.selectedIndex][name];
6142 }
6143 return Array.prototype.filter.call(options, option => option.selected).map(option => option[name]);
6144 };
6145 let selectedValues = getValue(false);
6146 const getItems = event => {
6147 const options = event.target.options;
6148 return Array.prototype.map.call(options, option => ({
6149 displayValue: option.textContent,
6150 exportValue: option.value
6151 }));
6152 };
6153 if (this.enableScripting && this.hasJSActions) {
6154 selectElement.addEventListener("updatefromsandbox", jsEvent => {
6155 const actions = {
6156 value(event) {
6157 removeEmptyEntry?.();
6158 const value = event.detail.value;
6159 const values = new Set(Array.isArray(value) ? value : [value]);
6160 for (const option of selectElement.options) {
6161 option.selected = values.has(option.value);
6162 }
6163 storage.setValue(id, {
6164 value: getValue(true)
6165 });
6166 selectedValues = getValue(false);
6167 },
6168 multipleSelection(event) {
6169 selectElement.multiple = true;
6170 },
6171 remove(event) {
6172 const options = selectElement.options;
6173 const index = event.detail.remove;
6174 options[index].selected = false;
6175 selectElement.remove(index);
6176 if (options.length > 0) {
6177 const i = Array.prototype.findIndex.call(options, option => option.selected);
6178 if (i === -1) {
6179 options[0].selected = true;
6180 }
6181 }
6182 storage.setValue(id, {
6183 value: getValue(true),
6184 items: getItems(event)
6185 });
6186 selectedValues = getValue(false);
6187 },
6188 clear(event) {
6189 while (selectElement.length !== 0) {
6190 selectElement.remove(0);
6191 }
6192 storage.setValue(id, {
6193 value: null,
6194 items: []
6195 });
6196 selectedValues = getValue(false);
6197 },
6198 insert(event) {
6199 const {
6200 index,
6201 displayValue,
6202 exportValue
6203 } = event.detail.insert;
6204 const selectChild = selectElement.children[index];
6205 const optionElement = document.createElement("option");
6206 optionElement.textContent = displayValue;
6207 optionElement.value = exportValue;
6208 if (selectChild) {
6209 selectChild.before(optionElement);
6210 } else {
6211 selectElement.append(optionElement);
6212 }
6213 storage.setValue(id, {
6214 value: getValue(true),
6215 items: getItems(event)
6216 });
6217 selectedValues = getValue(false);
6218 },
6219 items(event) {
6220 const {
6221 items
6222 } = event.detail;
6223 while (selectElement.length !== 0) {
6224 selectElement.remove(0);
6225 }
6226 for (const item of items) {
6227 const {
6228 displayValue,
6229 exportValue
6230 } = item;
6231 const optionElement = document.createElement("option");
6232 optionElement.textContent = displayValue;
6233 optionElement.value = exportValue;
6234 selectElement.append(optionElement);
6235 }
6236 if (selectElement.options.length > 0) {
6237 selectElement.options[0].selected = true;
6238 }
6239 storage.setValue(id, {
6240 value: getValue(true),
6241 items: getItems(event)
6242 });
6243 selectedValues = getValue(false);
6244 },
6245 indices(event) {
6246 const indices = new Set(event.detail.indices);
6247 for (const option of event.target.options) {
6248 option.selected = indices.has(option.index);
6249 }
6250 storage.setValue(id, {
6251 value: getValue(true)
6252 });
6253 selectedValues = getValue(false);
6254 },
6255 editable(event) {
6256 event.target.disabled = !event.detail.editable;
6257 }
6258 };
6259 this._dispatchEventFromSandbox(actions, jsEvent);
6260 });
6261 selectElement.addEventListener("input", event => {
6262 const exportValue = getValue(true);
6263 storage.setValue(id, {
6264 value: exportValue
6265 });
6266 event.preventDefault();
6267 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
6268 source: this,
6269 detail: {
6270 id,
6271 name: "Keystroke",
6272 value: selectedValues,
6273 changeEx: exportValue,
6274 willCommit: false,
6275 commitKey: 1,
6276 keyDown: false
6277 }
6278 });
6279 });
6280 this._setEventListeners(selectElement, null, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"], ["input", "Action"], ["input", "Validate"]], event => event.target.value);
6281 } else {
6282 selectElement.addEventListener("input", function (event) {
6283 storage.setValue(id, {
6284 value: getValue(true)
6285 });
6286 });
6287 }
6288 if (this.data.combo) {
6289 this._setTextStyle(selectElement);
6290 } else {}
6291 this._setBackgroundColor(selectElement);
6292 this._setDefaultPropertiesFromJS(selectElement);
6293 this.container.append(selectElement);
6294 return this.container;
6295 }
6296}
6297class PopupAnnotationElement extends AnnotationElement {
6298 constructor(parameters) {
6299 const {
6300 data,
6301 elements
6302 } = parameters;
6303 super(parameters, {
6304 isRenderable: AnnotationElement._hasPopupData(data)
6305 });
6306 this.elements = elements;
6307 }
6308 render() {
6309 this.container.classList.add("popupAnnotation");
6310 const popup = new PopupElement({
6311 container: this.container,
6312 color: this.data.color,
6313 titleObj: this.data.titleObj,
6314 modificationDate: this.data.modificationDate,
6315 contentsObj: this.data.contentsObj,
6316 richText: this.data.richText,
6317 rect: this.data.rect,
6318 parentRect: this.data.parentRect || null,
6319 parent: this.parent,
6320 elements: this.elements,
6321 open: this.data.open
6322 });
6323 const elementIds = [];
6324 for (const element of this.elements) {
6325 element.popup = popup;
6326 elementIds.push(element.data.id);
6327 element.addHighlightArea();
6328 }
6329 this.container.setAttribute("aria-controls", elementIds.map(id => `${util.AnnotationPrefix}${id}`).join(","));
6330 return this.container;
6331 }
6332}
6333class PopupElement {
6334 #boundKeyDown = this.#keyDown.bind(this);
6335 #boundHide = this.#hide.bind(this);
6336 #boundShow = this.#show.bind(this);
6337 #boundToggle = this.#toggle.bind(this);
6338 #color = null;
6339 #container = null;
6340 #contentsObj = null;
6341 #dateObj = null;
6342 #elements = null;
6343 #parent = null;
6344 #parentRect = null;
6345 #pinned = false;
6346 #popup = null;
6347 #rect = null;
6348 #richText = null;
6349 #titleObj = null;
6350 #wasVisible = false;
6351 constructor(_ref2) {
6352 let {
6353 container,
6354 color,
6355 elements,
6356 titleObj,
6357 modificationDate,
6358 contentsObj,
6359 richText,
6360 parent,
6361 rect,
6362 parentRect,
6363 open
6364 } = _ref2;
6365 this.#container = container;
6366 this.#titleObj = titleObj;
6367 this.#contentsObj = contentsObj;
6368 this.#richText = richText;
6369 this.#parent = parent;
6370 this.#color = color;
6371 this.#rect = rect;
6372 this.#parentRect = parentRect;
6373 this.#elements = elements;
6374 this.#dateObj = display_utils.PDFDateString.toDateObject(modificationDate);
6375 this.trigger = elements.flatMap(e => e.getElementsToTriggerPopup());
6376 for (const element of this.trigger) {
6377 element.addEventListener("click", this.#boundToggle);
6378 element.addEventListener("mouseenter", this.#boundShow);
6379 element.addEventListener("mouseleave", this.#boundHide);
6380 element.classList.add("popupTriggerArea");
6381 }
6382 for (const element of elements) {
6383 element.container?.addEventListener("keydown", this.#boundKeyDown);
6384 }
6385 this.#container.hidden = true;
6386 if (open) {
6387 this.#toggle();
6388 }
6389 }
6390 render() {
6391 if (this.#popup) {
6392 return;
6393 }
6394 const {
6395 page: {
6396 view
6397 },
6398 viewport: {
6399 rawDims: {
6400 pageWidth,
6401 pageHeight,
6402 pageX,
6403 pageY
6404 }
6405 }
6406 } = this.#parent;
6407 const popup = this.#popup = document.createElement("div");
6408 popup.className = "popup";
6409 if (this.#color) {
6410 const baseColor = popup.style.outlineColor = util.Util.makeHexColor(...this.#color);
6411 if (CSS.supports("background-color", "color-mix(in srgb, red 30%, white)")) {
6412 popup.style.backgroundColor = `color-mix(in srgb, ${baseColor} 30%, white)`;
6413 } else {
6414 const BACKGROUND_ENLIGHT = 0.7;
6415 popup.style.backgroundColor = util.Util.makeHexColor(...this.#color.map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
6416 }
6417 }
6418 const header = document.createElement("span");
6419 header.className = "header";
6420 const title = document.createElement("h1");
6421 header.append(title);
6422 ({
6423 dir: title.dir,
6424 str: title.textContent
6425 } = this.#titleObj);
6426 popup.append(header);
6427 if (this.#dateObj) {
6428 const modificationDate = document.createElement("span");
6429 modificationDate.classList.add("popupDate");
6430 modificationDate.setAttribute("data-l10n-id", "pdfjs-annotation-date-string");
6431 modificationDate.setAttribute("data-l10n-args", JSON.stringify({
6432 date: this.#dateObj.toLocaleDateString(),
6433 time: this.#dateObj.toLocaleTimeString()
6434 }));
6435 header.append(modificationDate);
6436 }
6437 const contentsObj = this.#contentsObj;
6438 const richText = this.#richText;
6439 if (richText?.str && (!contentsObj?.str || contentsObj.str === richText.str)) {
6440 xfa_layer.XfaLayer.render({
6441 xfaHtml: richText.html,
6442 intent: "richText",
6443 div: popup
6444 });
6445 popup.lastChild.classList.add("richText", "popupContent");
6446 } else {
6447 const contents = this._formatContents(contentsObj);
6448 popup.append(contents);
6449 }
6450 let useParentRect = !!this.#parentRect;
6451 let rect = useParentRect ? this.#parentRect : this.#rect;
6452 for (const element of this.#elements) {
6453 if (!rect || util.Util.intersect(element.data.rect, rect) !== null) {
6454 rect = element.data.rect;
6455 useParentRect = true;
6456 break;
6457 }
6458 }
6459 const normalizedRect = util.Util.normalizeRect([rect[0], view[3] - rect[1] + view[1], rect[2], view[3] - rect[3] + view[1]]);
6460 const HORIZONTAL_SPACE_AFTER_ANNOTATION = 5;
6461 const parentWidth = useParentRect ? rect[2] - rect[0] + HORIZONTAL_SPACE_AFTER_ANNOTATION : 0;
6462 const popupLeft = normalizedRect[0] + parentWidth;
6463 const popupTop = normalizedRect[1];
6464 const {
6465 style
6466 } = this.#container;
6467 style.left = `${100 * (popupLeft - pageX) / pageWidth}%`;
6468 style.top = `${100 * (popupTop - pageY) / pageHeight}%`;
6469 this.#container.append(popup);
6470 }
6471 _formatContents(_ref3) {
6472 let {
6473 str,
6474 dir
6475 } = _ref3;
6476 const p = document.createElement("p");
6477 p.classList.add("popupContent");
6478 p.dir = dir;
6479 const lines = str.split(/(?:\r\n?|\n)/);
6480 for (let i = 0, ii = lines.length; i < ii; ++i) {
6481 const line = lines[i];
6482 p.append(document.createTextNode(line));
6483 if (i < ii - 1) {
6484 p.append(document.createElement("br"));
6485 }
6486 }
6487 return p;
6488 }
6489 #keyDown(event) {
6490 if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {
6491 return;
6492 }
6493 if (event.key === "Enter" || event.key === "Escape" && this.#pinned) {
6494 this.#toggle();
6495 }
6496 }
6497 #toggle() {
6498 this.#pinned = !this.#pinned;
6499 if (this.#pinned) {
6500 this.#show();
6501 this.#container.addEventListener("click", this.#boundToggle);
6502 this.#container.addEventListener("keydown", this.#boundKeyDown);
6503 } else {
6504 this.#hide();
6505 this.#container.removeEventListener("click", this.#boundToggle);
6506 this.#container.removeEventListener("keydown", this.#boundKeyDown);
6507 }
6508 }
6509 #show() {
6510 if (!this.#popup) {
6511 this.render();
6512 }
6513 if (!this.isVisible) {
6514 this.#container.hidden = false;
6515 this.#container.style.zIndex = parseInt(this.#container.style.zIndex) + 1000;
6516 } else if (this.#pinned) {
6517 this.#container.classList.add("focused");
6518 }
6519 }
6520 #hide() {
6521 this.#container.classList.remove("focused");
6522 if (this.#pinned || !this.isVisible) {
6523 return;
6524 }
6525 this.#container.hidden = true;
6526 this.#container.style.zIndex = parseInt(this.#container.style.zIndex) - 1000;
6527 }
6528 forceHide() {
6529 this.#wasVisible = this.isVisible;
6530 if (!this.#wasVisible) {
6531 return;
6532 }
6533 this.#container.hidden = true;
6534 }
6535 maybeShow() {
6536 if (!this.#wasVisible) {
6537 return;
6538 }
6539 this.#wasVisible = false;
6540 this.#container.hidden = false;
6541 }
6542 get isVisible() {
6543 return this.#container.hidden === false;
6544 }
6545}
6546class FreeTextAnnotationElement extends AnnotationElement {
6547 constructor(parameters) {
6548 super(parameters, {
6549 isRenderable: true,
6550 ignoreBorder: true
6551 });
6552 this.textContent = parameters.data.textContent;
6553 this.textPosition = parameters.data.textPosition;
6554 this.annotationEditorType = util.AnnotationEditorType.FREETEXT;
6555 }
6556 render() {
6557 this.container.classList.add("freeTextAnnotation");
6558 if (this.textContent) {
6559 const content = document.createElement("div");
6560 content.classList.add("annotationTextContent");
6561 content.setAttribute("role", "comment");
6562 for (const line of this.textContent) {
6563 const lineSpan = document.createElement("span");
6564 lineSpan.textContent = line;
6565 content.append(lineSpan);
6566 }
6567 this.container.append(content);
6568 }
6569 if (!this.data.popupRef && this.hasPopupData) {
6570 this._createPopup();
6571 }
6572 this._editOnDoubleClick();
6573 return this.container;
6574 }
6575 get _isEditable() {
6576 return this.data.hasOwnCanvas;
6577 }
6578}
6579class LineAnnotationElement extends AnnotationElement {
6580 #line = null;
6581 constructor(parameters) {
6582 super(parameters, {
6583 isRenderable: true,
6584 ignoreBorder: true
6585 });
6586 }
6587 render() {
6588 this.container.classList.add("lineAnnotation");
6589 const data = this.data;
6590 const {
6591 width,
6592 height
6593 } = getRectDims(data.rect);
6594 const svg = this.svgFactory.create(width, height, true);
6595 const line = this.#line = this.svgFactory.createElement("svg:line");
6596 line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
6597 line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
6598 line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
6599 line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
6600 line.setAttribute("stroke-width", data.borderStyle.width || 1);
6601 line.setAttribute("stroke", "transparent");
6602 line.setAttribute("fill", "transparent");
6603 svg.append(line);
6604 this.container.append(svg);
6605 if (!data.popupRef && this.hasPopupData) {
6606 this._createPopup();
6607 }
6608 return this.container;
6609 }
6610 getElementsToTriggerPopup() {
6611 return this.#line;
6612 }
6613 addHighlightArea() {
6614 this.container.classList.add("highlightArea");
6615 }
6616}
6617class SquareAnnotationElement extends AnnotationElement {
6618 #square = null;
6619 constructor(parameters) {
6620 super(parameters, {
6621 isRenderable: true,
6622 ignoreBorder: true
6623 });
6624 }
6625 render() {
6626 this.container.classList.add("squareAnnotation");
6627 const data = this.data;
6628 const {
6629 width,
6630 height
6631 } = getRectDims(data.rect);
6632 const svg = this.svgFactory.create(width, height, true);
6633 const borderWidth = data.borderStyle.width;
6634 const square = this.#square = this.svgFactory.createElement("svg:rect");
6635 square.setAttribute("x", borderWidth / 2);
6636 square.setAttribute("y", borderWidth / 2);
6637 square.setAttribute("width", width - borderWidth);
6638 square.setAttribute("height", height - borderWidth);
6639 square.setAttribute("stroke-width", borderWidth || 1);
6640 square.setAttribute("stroke", "transparent");
6641 square.setAttribute("fill", "transparent");
6642 svg.append(square);
6643 this.container.append(svg);
6644 if (!data.popupRef && this.hasPopupData) {
6645 this._createPopup();
6646 }
6647 return this.container;
6648 }
6649 getElementsToTriggerPopup() {
6650 return this.#square;
6651 }
6652 addHighlightArea() {
6653 this.container.classList.add("highlightArea");
6654 }
6655}
6656class CircleAnnotationElement extends AnnotationElement {
6657 #circle = null;
6658 constructor(parameters) {
6659 super(parameters, {
6660 isRenderable: true,
6661 ignoreBorder: true
6662 });
6663 }
6664 render() {
6665 this.container.classList.add("circleAnnotation");
6666 const data = this.data;
6667 const {
6668 width,
6669 height
6670 } = getRectDims(data.rect);
6671 const svg = this.svgFactory.create(width, height, true);
6672 const borderWidth = data.borderStyle.width;
6673 const circle = this.#circle = this.svgFactory.createElement("svg:ellipse");
6674 circle.setAttribute("cx", width / 2);
6675 circle.setAttribute("cy", height / 2);
6676 circle.setAttribute("rx", width / 2 - borderWidth / 2);
6677 circle.setAttribute("ry", height / 2 - borderWidth / 2);
6678 circle.setAttribute("stroke-width", borderWidth || 1);
6679 circle.setAttribute("stroke", "transparent");
6680 circle.setAttribute("fill", "transparent");
6681 svg.append(circle);
6682 this.container.append(svg);
6683 if (!data.popupRef && this.hasPopupData) {
6684 this._createPopup();
6685 }
6686 return this.container;
6687 }
6688 getElementsToTriggerPopup() {
6689 return this.#circle;
6690 }
6691 addHighlightArea() {
6692 this.container.classList.add("highlightArea");
6693 }
6694}
6695class PolylineAnnotationElement extends AnnotationElement {
6696 #polyline = null;
6697 constructor(parameters) {
6698 super(parameters, {
6699 isRenderable: true,
6700 ignoreBorder: true
6701 });
6702 this.containerClassName = "polylineAnnotation";
6703 this.svgElementName = "svg:polyline";
6704 }
6705 render() {
6706 this.container.classList.add(this.containerClassName);
6707 const data = this.data;
6708 const {
6709 width,
6710 height
6711 } = getRectDims(data.rect);
6712 const svg = this.svgFactory.create(width, height, true);
6713 let points = [];
6714 for (const coordinate of data.vertices) {
6715 const x = coordinate.x - data.rect[0];
6716 const y = data.rect[3] - coordinate.y;
6717 points.push(x + "," + y);
6718 }
6719 points = points.join(" ");
6720 const polyline = this.#polyline = this.svgFactory.createElement(this.svgElementName);
6721 polyline.setAttribute("points", points);
6722 polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
6723 polyline.setAttribute("stroke", "transparent");
6724 polyline.setAttribute("fill", "transparent");
6725 svg.append(polyline);
6726 this.container.append(svg);
6727 if (!data.popupRef && this.hasPopupData) {
6728 this._createPopup();
6729 }
6730 return this.container;
6731 }
6732 getElementsToTriggerPopup() {
6733 return this.#polyline;
6734 }
6735 addHighlightArea() {
6736 this.container.classList.add("highlightArea");
6737 }
6738}
6739class PolygonAnnotationElement extends PolylineAnnotationElement {
6740 constructor(parameters) {
6741 super(parameters);
6742 this.containerClassName = "polygonAnnotation";
6743 this.svgElementName = "svg:polygon";
6744 }
6745}
6746class CaretAnnotationElement extends AnnotationElement {
6747 constructor(parameters) {
6748 super(parameters, {
6749 isRenderable: true,
6750 ignoreBorder: true
6751 });
6752 }
6753 render() {
6754 this.container.classList.add("caretAnnotation");
6755 if (!this.data.popupRef && this.hasPopupData) {
6756 this._createPopup();
6757 }
6758 return this.container;
6759 }
6760}
6761class InkAnnotationElement extends AnnotationElement {
6762 #polylines = [];
6763 constructor(parameters) {
6764 super(parameters, {
6765 isRenderable: true,
6766 ignoreBorder: true
6767 });
6768 this.containerClassName = "inkAnnotation";
6769 this.svgElementName = "svg:polyline";
6770 this.annotationEditorType = util.AnnotationEditorType.INK;
6771 }
6772 render() {
6773 this.container.classList.add(this.containerClassName);
6774 const data = this.data;
6775 const {
6776 width,
6777 height
6778 } = getRectDims(data.rect);
6779 const svg = this.svgFactory.create(width, height, true);
6780 for (const inkList of data.inkLists) {
6781 let points = [];
6782 for (const coordinate of inkList) {
6783 const x = coordinate.x - data.rect[0];
6784 const y = data.rect[3] - coordinate.y;
6785 points.push(`${x},${y}`);
6786 }
6787 points = points.join(" ");
6788 const polyline = this.svgFactory.createElement(this.svgElementName);
6789 this.#polylines.push(polyline);
6790 polyline.setAttribute("points", points);
6791 polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
6792 polyline.setAttribute("stroke", "transparent");
6793 polyline.setAttribute("fill", "transparent");
6794 if (!data.popupRef && this.hasPopupData) {
6795 this._createPopup();
6796 }
6797 svg.append(polyline);
6798 }
6799 this.container.append(svg);
6800 return this.container;
6801 }
6802 getElementsToTriggerPopup() {
6803 return this.#polylines;
6804 }
6805 addHighlightArea() {
6806 this.container.classList.add("highlightArea");
6807 }
6808}
6809class HighlightAnnotationElement extends AnnotationElement {
6810 constructor(parameters) {
6811 super(parameters, {
6812 isRenderable: true,
6813 ignoreBorder: true,
6814 createQuadrilaterals: true
6815 });
6816 }
6817 render() {
6818 if (!this.data.popupRef && this.hasPopupData) {
6819 this._createPopup();
6820 }
6821 this.container.classList.add("highlightAnnotation");
6822 return this.container;
6823 }
6824}
6825class UnderlineAnnotationElement extends AnnotationElement {
6826 constructor(parameters) {
6827 super(parameters, {
6828 isRenderable: true,
6829 ignoreBorder: true,
6830 createQuadrilaterals: true
6831 });
6832 }
6833 render() {
6834 if (!this.data.popupRef && this.hasPopupData) {
6835 this._createPopup();
6836 }
6837 this.container.classList.add("underlineAnnotation");
6838 return this.container;
6839 }
6840}
6841class SquigglyAnnotationElement extends AnnotationElement {
6842 constructor(parameters) {
6843 super(parameters, {
6844 isRenderable: true,
6845 ignoreBorder: true,
6846 createQuadrilaterals: true
6847 });
6848 }
6849 render() {
6850 if (!this.data.popupRef && this.hasPopupData) {
6851 this._createPopup();
6852 }
6853 this.container.classList.add("squigglyAnnotation");
6854 return this.container;
6855 }
6856}
6857class StrikeOutAnnotationElement extends AnnotationElement {
6858 constructor(parameters) {
6859 super(parameters, {
6860 isRenderable: true,
6861 ignoreBorder: true,
6862 createQuadrilaterals: true
6863 });
6864 }
6865 render() {
6866 if (!this.data.popupRef && this.hasPopupData) {
6867 this._createPopup();
6868 }
6869 this.container.classList.add("strikeoutAnnotation");
6870 return this.container;
6871 }
6872}
6873class StampAnnotationElement extends AnnotationElement {
6874 constructor(parameters) {
6875 super(parameters, {
6876 isRenderable: true,
6877 ignoreBorder: true
6878 });
6879 }
6880 render() {
6881 this.container.classList.add("stampAnnotation");
6882 if (!this.data.popupRef && this.hasPopupData) {
6883 this._createPopup();
6884 }
6885 return this.container;
6886 }
6887}
6888class FileAttachmentAnnotationElement extends AnnotationElement {
6889 #trigger = null;
6890 constructor(parameters) {
6891 super(parameters, {
6892 isRenderable: true
6893 });
6894 const {
6895 filename,
6896 content
6897 } = this.data.file;
6898 this.filename = (0,display_utils.getFilenameFromUrl)(filename, true);
6899 this.content = content;
6900 this.linkService.eventBus?.dispatch("fileattachmentannotation", {
6901 source: this,
6902 filename,
6903 content
6904 });
6905 }
6906 render() {
6907 this.container.classList.add("fileAttachmentAnnotation");
6908 const {
6909 container,
6910 data
6911 } = this;
6912 let trigger;
6913 if (data.hasAppearance || data.fillAlpha === 0) {
6914 trigger = document.createElement("div");
6915 } else {
6916 trigger = document.createElement("img");
6917 trigger.src = `${this.imageResourcesPath}annotation-${/paperclip/i.test(data.name) ? "paperclip" : "pushpin"}.svg`;
6918 if (data.fillAlpha && data.fillAlpha < 1) {
6919 trigger.style = `filter: opacity(${Math.round(data.fillAlpha * 100)}%);`;
6920 }
6921 }
6922 trigger.addEventListener("dblclick", this.#download.bind(this));
6923 this.#trigger = trigger;
6924 const {
6925 isMac
6926 } = util.FeatureTest.platform;
6927 container.addEventListener("keydown", evt => {
6928 if (evt.key === "Enter" && (isMac ? evt.metaKey : evt.ctrlKey)) {
6929 this.#download();
6930 }
6931 });
6932 if (!data.popupRef && this.hasPopupData) {
6933 this._createPopup();
6934 } else {
6935 trigger.classList.add("popupTriggerArea");
6936 }
6937 container.append(trigger);
6938 return container;
6939 }
6940 getElementsToTriggerPopup() {
6941 return this.#trigger;
6942 }
6943 addHighlightArea() {
6944 this.container.classList.add("highlightArea");
6945 }
6946 #download() {
6947 this.downloadManager?.openOrDownloadData(this.content, this.filename);
6948 }
6949}
6950class AnnotationLayer {
6951 #accessibilityManager = null;
6952 #annotationCanvasMap = null;
6953 #editableAnnotations = new Map();
6954 constructor(_ref4) {
6955 let {
6956 div,
6957 accessibilityManager,
6958 annotationCanvasMap,
6959 page,
6960 viewport
6961 } = _ref4;
6962 this.div = div;
6963 this.#accessibilityManager = accessibilityManager;
6964 this.#annotationCanvasMap = annotationCanvasMap;
6965 this.page = page;
6966 this.viewport = viewport;
6967 this.zIndex = 0;
6968 }
6969 #appendElement(element, id) {
6970 const contentElement = element.firstChild || element;
6971 contentElement.id = `${util.AnnotationPrefix}${id}`;
6972 this.div.append(element);
6973 this.#accessibilityManager?.moveElementInDOM(this.div, element, contentElement, false);
6974 }
6975 async render(params) {
6976 const {
6977 annotations
6978 } = params;
6979 const layer = this.div;
6980 (0,display_utils.setLayerDimensions)(layer, this.viewport);
6981 const popupToElements = new Map();
6982 const elementParams = {
6983 data: null,
6984 layer,
6985 linkService: params.linkService,
6986 downloadManager: params.downloadManager,
6987 imageResourcesPath: params.imageResourcesPath || "",
6988 renderForms: params.renderForms !== false,
6989 svgFactory: new display_utils.DOMSVGFactory(),
6990 annotationStorage: params.annotationStorage || new annotation_storage.AnnotationStorage(),
6991 enableScripting: params.enableScripting === true,
6992 hasJSActions: params.hasJSActions,
6993 fieldObjects: params.fieldObjects,
6994 parent: this,
6995 elements: null
6996 };
6997 for (const data of annotations) {
6998 if (data.noHTML) {
6999 continue;
7000 }
7001 const isPopupAnnotation = data.annotationType === util.AnnotationType.POPUP;
7002 if (!isPopupAnnotation) {
7003 const {
7004 width,
7005 height
7006 } = getRectDims(data.rect);
7007 if (width <= 0 || height <= 0) {
7008 continue;
7009 }
7010 } else {
7011 const elements = popupToElements.get(data.id);
7012 if (!elements) {
7013 continue;
7014 }
7015 elementParams.elements = elements;
7016 }
7017 elementParams.data = data;
7018 const element = AnnotationElementFactory.create(elementParams);
7019 if (!element.isRenderable) {
7020 continue;
7021 }
7022 if (!isPopupAnnotation && data.popupRef) {
7023 const elements = popupToElements.get(data.popupRef);
7024 if (!elements) {
7025 popupToElements.set(data.popupRef, [element]);
7026 } else {
7027 elements.push(element);
7028 }
7029 }
7030 if (element.annotationEditorType > 0) {
7031 this.#editableAnnotations.set(element.data.id, element);
7032 }
7033 const rendered = element.render();
7034 if (data.hidden) {
7035 rendered.style.visibility = "hidden";
7036 }
7037 this.#appendElement(rendered, data.id);
7038 }
7039 this.#setAnnotationCanvasMap();
7040 }
7041 update(_ref5) {
7042 let {
7043 viewport
7044 } = _ref5;
7045 const layer = this.div;
7046 this.viewport = viewport;
7047 (0,display_utils.setLayerDimensions)(layer, {
7048 rotation: viewport.rotation
7049 });
7050 this.#setAnnotationCanvasMap();
7051 layer.hidden = false;
7052 }
7053 #setAnnotationCanvasMap() {
7054 if (!this.#annotationCanvasMap) {
7055 return;
7056 }
7057 const layer = this.div;
7058 for (const [id, canvas] of this.#annotationCanvasMap) {
7059 const element = layer.querySelector(`[data-annotation-id="${id}"]`);
7060 if (!element) {
7061 continue;
7062 }
7063 const {
7064 firstChild
7065 } = element;
7066 if (!firstChild) {
7067 element.append(canvas);
7068 } else if (firstChild.nodeName === "CANVAS") {
7069 firstChild.replaceWith(canvas);
7070 } else {
7071 firstChild.before(canvas);
7072 }
7073 }
7074 this.#annotationCanvasMap.clear();
7075 }
7076 getEditableAnnotations() {
7077 return Array.from(this.#editableAnnotations.values());
7078 }
7079 getEditableAnnotation(id) {
7080 return this.#editableAnnotations.get(id);
7081 }
7082}
7083
7084
7085/***/ }),
7086
7087/***/ 9792:
7088/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7089
7090/* harmony export */ __webpack_require__.d(__webpack_exports__, {
7091/* harmony export */ AnnotationStorage: () => (/* binding */ AnnotationStorage),
7092/* harmony export */ PrintAnnotationStorage: () => (/* binding */ PrintAnnotationStorage),
7093/* harmony export */ SerializableEmpty: () => (/* binding */ SerializableEmpty)
7094/* harmony export */ });
7095/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
7096/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1454);
7097/* harmony import */ var core_js_modules_web_dom_exception_stack_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4979);
7098/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4292);
7099/* harmony import */ var _editor_editor_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(310);
7100/* harmony import */ var _shared_murmurhash3_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7651);
7101
7102
7103
7104
7105
7106
7107const SerializableEmpty = Object.freeze({
7108 map: null,
7109 hash: "",
7110 transfer: undefined
7111});
7112class AnnotationStorage {
7113 #modified = false;
7114 #storage = new Map();
7115 constructor() {
7116 this.onSetModified = null;
7117 this.onResetModified = null;
7118 this.onAnnotationEditor = null;
7119 }
7120 getValue(key, defaultValue) {
7121 const value = this.#storage.get(key);
7122 if (value === undefined) {
7123 return defaultValue;
7124 }
7125 return Object.assign(defaultValue, value);
7126 }
7127 getRawValue(key) {
7128 return this.#storage.get(key);
7129 }
7130 remove(key) {
7131 this.#storage.delete(key);
7132 if (this.#storage.size === 0) {
7133 this.resetModified();
7134 }
7135 if (typeof this.onAnnotationEditor === "function") {
7136 for (const value of this.#storage.values()) {
7137 if (value instanceof _editor_editor_js__WEBPACK_IMPORTED_MODULE_4__.AnnotationEditor) {
7138 return;
7139 }
7140 }
7141 this.onAnnotationEditor(null);
7142 }
7143 }
7144 setValue(key, value) {
7145 const obj = this.#storage.get(key);
7146 let modified = false;
7147 if (obj !== undefined) {
7148 for (const [entry, val] of Object.entries(value)) {
7149 if (obj[entry] !== val) {
7150 modified = true;
7151 obj[entry] = val;
7152 }
7153 }
7154 } else {
7155 modified = true;
7156 this.#storage.set(key, value);
7157 }
7158 if (modified) {
7159 this.#setModified();
7160 }
7161 if (value instanceof _editor_editor_js__WEBPACK_IMPORTED_MODULE_4__.AnnotationEditor && typeof this.onAnnotationEditor === "function") {
7162 this.onAnnotationEditor(value.constructor._type);
7163 }
7164 }
7165 has(key) {
7166 return this.#storage.has(key);
7167 }
7168 getAll() {
7169 return this.#storage.size > 0 ? (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_3__.objectFromMap)(this.#storage) : null;
7170 }
7171 setAll(obj) {
7172 for (const [key, val] of Object.entries(obj)) {
7173 this.setValue(key, val);
7174 }
7175 }
7176 get size() {
7177 return this.#storage.size;
7178 }
7179 #setModified() {
7180 if (!this.#modified) {
7181 this.#modified = true;
7182 if (typeof this.onSetModified === "function") {
7183 this.onSetModified();
7184 }
7185 }
7186 }
7187 resetModified() {
7188 if (this.#modified) {
7189 this.#modified = false;
7190 if (typeof this.onResetModified === "function") {
7191 this.onResetModified();
7192 }
7193 }
7194 }
7195 get print() {
7196 return new PrintAnnotationStorage(this);
7197 }
7198 get serializable() {
7199 if (this.#storage.size === 0) {
7200 return SerializableEmpty;
7201 }
7202 const map = new Map(),
7203 hash = new _shared_murmurhash3_js__WEBPACK_IMPORTED_MODULE_5__.MurmurHash3_64(),
7204 transfer = [];
7205 const context = Object.create(null);
7206 let hasBitmap = false;
7207 for (const [key, val] of this.#storage) {
7208 const serialized = val instanceof _editor_editor_js__WEBPACK_IMPORTED_MODULE_4__.AnnotationEditor ? val.serialize(false, context) : val;
7209 if (serialized) {
7210 map.set(key, serialized);
7211 hash.update(`${key}:${JSON.stringify(serialized)}`);
7212 hasBitmap ||= !!serialized.bitmap;
7213 }
7214 }
7215 if (hasBitmap) {
7216 for (const value of map.values()) {
7217 if (value.bitmap) {
7218 transfer.push(value.bitmap);
7219 }
7220 }
7221 }
7222 return map.size > 0 ? {
7223 map,
7224 hash: hash.hexdigest(),
7225 transfer
7226 } : SerializableEmpty;
7227 }
7228 get editorStats() {
7229 let stats = null;
7230 const typeToEditor = new Map();
7231 for (const value of this.#storage.values()) {
7232 if (!(value instanceof _editor_editor_js__WEBPACK_IMPORTED_MODULE_4__.AnnotationEditor)) {
7233 continue;
7234 }
7235 const editorStats = value.telemetryFinalData;
7236 if (!editorStats) {
7237 continue;
7238 }
7239 const {
7240 type
7241 } = editorStats;
7242 if (!typeToEditor.has(type)) {
7243 typeToEditor.set(type, Object.getPrototypeOf(value).constructor);
7244 }
7245 stats ||= Object.create(null);
7246 const map = stats[type] ||= new Map();
7247 for (const [key, val] of Object.entries(editorStats)) {
7248 if (key === "type") {
7249 continue;
7250 }
7251 let counters = map.get(key);
7252 if (!counters) {
7253 counters = new Map();
7254 map.set(key, counters);
7255 }
7256 const count = counters.get(val) ?? 0;
7257 counters.set(val, count + 1);
7258 }
7259 }
7260 for (const [type, editor] of typeToEditor) {
7261 stats[type] = editor.computeTelemetryFinalData(stats[type]);
7262 }
7263 return stats;
7264 }
7265}
7266class PrintAnnotationStorage extends AnnotationStorage {
7267 #serializable;
7268 constructor(parent) {
7269 super();
7270 const {
7271 map,
7272 hash,
7273 transfer
7274 } = parent.serializable;
7275 const clone = structuredClone(map, transfer ? {
7276 transfer
7277 } : null);
7278 this.#serializable = {
7279 map: clone,
7280 hash,
7281 transfer
7282 };
7283 }
7284 get print() {
7285 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_3__.unreachable)("Should not call PrintAnnotationStorage.print");
7286 }
7287 get serializable() {
7288 return this.#serializable;
7289 }
7290}
7291
7292
7293/***/ }),
7294
7295/***/ 3831:
7296/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
7297
7298__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
7299/* harmony export */ __webpack_require__.d(__webpack_exports__, {
7300/* harmony export */ PDFDataRangeTransport: () => (/* binding */ PDFDataRangeTransport),
7301/* harmony export */ PDFWorker: () => (/* binding */ PDFWorker),
7302/* harmony export */ build: () => (/* binding */ build),
7303/* harmony export */ getDocument: () => (/* binding */ getDocument),
7304/* harmony export */ version: () => (/* binding */ version)
7305/* harmony export */ });
7306/* unused harmony exports DefaultCanvasFactory, DefaultCMapReaderFactory, DefaultFilterFactory, DefaultStandardFontDataFactory, LoopbackPort, PDFDocumentLoadingTask, PDFDocumentProxy, PDFPageProxy, PDFWorkerUtil, RenderTask */
7307/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
7308/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6573);
7309/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8100);
7310/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7936);
7311/* harmony import */ var core_js_modules_es_promise_with_resolvers_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4628);
7312/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7467);
7313/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4732);
7314/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9577);
7315/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1454);
7316/* harmony import */ var core_js_modules_esnext_set_difference_v2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3375);
7317/* harmony import */ var core_js_modules_esnext_set_intersection_v2_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(9225);
7318/* harmony import */ var core_js_modules_esnext_set_is_disjoint_from_v2_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(3972);
7319/* harmony import */ var core_js_modules_esnext_set_is_subset_of_v2_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(9209);
7320/* harmony import */ var core_js_modules_esnext_set_is_superset_of_v2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(5714);
7321/* harmony import */ var core_js_modules_esnext_set_symmetric_difference_v2_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(7561);
7322/* harmony import */ var core_js_modules_esnext_set_union_v2_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(6197);
7323/* harmony import */ var core_js_modules_web_dom_exception_stack_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(4979);
7324/* harmony import */ var core_js_modules_web_url_search_params_delete_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(4603);
7325/* harmony import */ var core_js_modules_web_url_search_params_has_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(7566);
7326/* harmony import */ var core_js_modules_web_url_search_params_size_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(8721);
7327/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(4292);
7328/* harmony import */ var _annotation_storage_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(9792);
7329/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(5419);
7330/* harmony import */ var _font_loader_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(10);
7331/* harmony import */ var display_node_utils__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(1573);
7332/* harmony import */ var _canvas_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(4923);
7333/* harmony import */ var _text_layer_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(6814);
7334/* harmony import */ var _worker_options_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(6164);
7335/* harmony import */ var _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(5178);
7336/* harmony import */ var _metadata_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(6062);
7337/* harmony import */ var _optional_content_config_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(5626);
7338/* harmony import */ var _transport_stream_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(585);
7339/* harmony import */ var display_fetch_stream__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(4094);
7340/* harmony import */ var display_network__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(7457);
7341/* harmony import */ var display_node_stream__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(4786);
7342/* harmony import */ var _xfa_text_js__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(2050);
7343var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([display_node_utils__WEBPACK_IMPORTED_MODULE_24__, display_node_stream__WEBPACK_IMPORTED_MODULE_33__]);
7344([display_node_utils__WEBPACK_IMPORTED_MODULE_24__, display_node_stream__WEBPACK_IMPORTED_MODULE_33__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381const DEFAULT_RANGE_CHUNK_SIZE = 65536;
7382const RENDERING_CANCELLED_TIMEOUT = 100;
7383const DELAYED_CLEANUP_TIMEOUT = 5000;
7384const DefaultCanvasFactory = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS ? display_node_utils__WEBPACK_IMPORTED_MODULE_24__.NodeCanvasFactory : _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.DOMCanvasFactory;
7385const DefaultCMapReaderFactory = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS ? display_node_utils__WEBPACK_IMPORTED_MODULE_24__.NodeCMapReaderFactory : _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.DOMCMapReaderFactory;
7386const DefaultFilterFactory = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS ? display_node_utils__WEBPACK_IMPORTED_MODULE_24__.NodeFilterFactory : _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.DOMFilterFactory;
7387const DefaultStandardFontDataFactory = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS ? display_node_utils__WEBPACK_IMPORTED_MODULE_24__.NodeStandardFontDataFactory : _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.DOMStandardFontDataFactory;
7388function getDocument(src) {
7389 if (typeof src === "string" || src instanceof URL) {
7390 src = {
7391 url: src
7392 };
7393 } else if (src instanceof ArrayBuffer || ArrayBuffer.isView(src)) {
7394 src = {
7395 data: src
7396 };
7397 }
7398 if (typeof src !== "object") {
7399 throw new Error("Invalid parameter in getDocument, need parameter object.");
7400 }
7401 if (!src.url && !src.data && !src.range) {
7402 throw new Error("Invalid parameter object: need either .data, .range or .url");
7403 }
7404 const task = new PDFDocumentLoadingTask();
7405 const {
7406 docId
7407 } = task;
7408 const url = src.url ? getUrlProp(src.url) : null;
7409 const data = src.data ? getDataProp(src.data) : null;
7410 const httpHeaders = src.httpHeaders || null;
7411 const withCredentials = src.withCredentials === true;
7412 const password = src.password ?? null;
7413 const rangeTransport = src.range instanceof PDFDataRangeTransport ? src.range : null;
7414 const rangeChunkSize = Number.isInteger(src.rangeChunkSize) && src.rangeChunkSize > 0 ? src.rangeChunkSize : DEFAULT_RANGE_CHUNK_SIZE;
7415 let worker = src.worker instanceof PDFWorker ? src.worker : null;
7416 const verbosity = src.verbosity;
7417 const docBaseUrl = typeof src.docBaseUrl === "string" && !(0,_display_utils_js__WEBPACK_IMPORTED_MODULE_22__.isDataScheme)(src.docBaseUrl) ? src.docBaseUrl : null;
7418 const cMapUrl = typeof src.cMapUrl === "string" ? src.cMapUrl : null;
7419 const cMapPacked = src.cMapPacked !== false;
7420 const CMapReaderFactory = src.CMapReaderFactory || DefaultCMapReaderFactory;
7421 const standardFontDataUrl = typeof src.standardFontDataUrl === "string" ? src.standardFontDataUrl : null;
7422 const StandardFontDataFactory = src.StandardFontDataFactory || DefaultStandardFontDataFactory;
7423 const ignoreErrors = src.stopAtErrors !== true;
7424 const maxImageSize = Number.isInteger(src.maxImageSize) && src.maxImageSize > -1 ? src.maxImageSize : -1;
7425 const isEvalSupported = src.isEvalSupported !== false;
7426 const isOffscreenCanvasSupported = typeof src.isOffscreenCanvasSupported === "boolean" ? src.isOffscreenCanvasSupported : !_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS;
7427 const canvasMaxAreaInBytes = Number.isInteger(src.canvasMaxAreaInBytes) ? src.canvasMaxAreaInBytes : -1;
7428 const disableFontFace = typeof src.disableFontFace === "boolean" ? src.disableFontFace : _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS;
7429 const fontExtraProperties = src.fontExtraProperties === true;
7430 const enableXfa = src.enableXfa === true;
7431 const ownerDocument = src.ownerDocument || globalThis.document;
7432 const disableRange = src.disableRange === true;
7433 const disableStream = src.disableStream === true;
7434 const disableAutoFetch = src.disableAutoFetch === true;
7435 const pdfBug = src.pdfBug === true;
7436 const length = rangeTransport ? rangeTransport.length : src.length ?? NaN;
7437 const useSystemFonts = typeof src.useSystemFonts === "boolean" ? src.useSystemFonts : !_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS && !disableFontFace;
7438 const useWorkerFetch = typeof src.useWorkerFetch === "boolean" ? src.useWorkerFetch : CMapReaderFactory === _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.DOMCMapReaderFactory && StandardFontDataFactory === _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.DOMStandardFontDataFactory && cMapUrl && standardFontDataUrl && (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_22__.isValidFetchUrl)(cMapUrl, document.baseURI) && (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_22__.isValidFetchUrl)(standardFontDataUrl, document.baseURI);
7439 const canvasFactory = src.canvasFactory || new DefaultCanvasFactory({
7440 ownerDocument
7441 });
7442 const filterFactory = src.filterFactory || new DefaultFilterFactory({
7443 docId,
7444 ownerDocument
7445 });
7446 const styleElement = null;
7447 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.setVerbosityLevel)(verbosity);
7448 const transportFactory = {
7449 canvasFactory,
7450 filterFactory
7451 };
7452 if (!useWorkerFetch) {
7453 transportFactory.cMapReaderFactory = new CMapReaderFactory({
7454 baseUrl: cMapUrl,
7455 isCompressed: cMapPacked
7456 });
7457 transportFactory.standardFontDataFactory = new StandardFontDataFactory({
7458 baseUrl: standardFontDataUrl
7459 });
7460 }
7461 if (!worker) {
7462 const workerParams = {
7463 verbosity,
7464 port: _worker_options_js__WEBPACK_IMPORTED_MODULE_35__.GlobalWorkerOptions.workerPort
7465 };
7466 worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
7467 task._worker = worker;
7468 }
7469 const fetchDocParams = {
7470 docId,
7471 apiVersion: "4.1.392",
7472 data,
7473 password,
7474 disableAutoFetch,
7475 rangeChunkSize,
7476 length,
7477 docBaseUrl,
7478 enableXfa,
7479 evaluatorOptions: {
7480 maxImageSize,
7481 disableFontFace,
7482 ignoreErrors,
7483 isEvalSupported,
7484 isOffscreenCanvasSupported,
7485 canvasMaxAreaInBytes,
7486 fontExtraProperties,
7487 useSystemFonts,
7488 cMapUrl: useWorkerFetch ? cMapUrl : null,
7489 standardFontDataUrl: useWorkerFetch ? standardFontDataUrl : null
7490 }
7491 };
7492 const transportParams = {
7493 ignoreErrors,
7494 isEvalSupported,
7495 disableFontFace,
7496 fontExtraProperties,
7497 enableXfa,
7498 ownerDocument,
7499 disableAutoFetch,
7500 pdfBug,
7501 styleElement
7502 };
7503 worker.promise.then(function () {
7504 if (task.destroyed) {
7505 throw new Error("Loading aborted");
7506 }
7507 const workerIdPromise = _fetchDocument(worker, fetchDocParams);
7508 const networkStreamPromise = new Promise(function (resolve) {
7509 let networkStream;
7510 if (rangeTransport) {
7511 networkStream = new _transport_stream_js__WEBPACK_IMPORTED_MODULE_30__.PDFDataTransportStream(rangeTransport, {
7512 disableRange,
7513 disableStream
7514 });
7515 } else if (!data) {
7516 const createPDFNetworkStream = params => {
7517 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS) {
7518 const isFetchSupported = function () {
7519 return typeof fetch !== "undefined" && typeof Response !== "undefined" && "body" in Response.prototype;
7520 };
7521 return isFetchSupported() && (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_22__.isValidFetchUrl)(params.url) ? new display_fetch_stream__WEBPACK_IMPORTED_MODULE_31__.PDFFetchStream(params) : new display_node_stream__WEBPACK_IMPORTED_MODULE_33__.PDFNodeStream(params);
7522 }
7523 return (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_22__.isValidFetchUrl)(params.url) ? new display_fetch_stream__WEBPACK_IMPORTED_MODULE_31__.PDFFetchStream(params) : new display_network__WEBPACK_IMPORTED_MODULE_32__.PDFNetworkStream(params);
7524 };
7525 networkStream = createPDFNetworkStream({
7526 url,
7527 length,
7528 httpHeaders,
7529 withCredentials,
7530 rangeChunkSize,
7531 disableRange,
7532 disableStream
7533 });
7534 }
7535 resolve(networkStream);
7536 });
7537 return Promise.all([workerIdPromise, networkStreamPromise]).then(function (_ref) {
7538 let [workerId, networkStream] = _ref;
7539 if (task.destroyed) {
7540 throw new Error("Loading aborted");
7541 }
7542 const messageHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_27__.MessageHandler(docId, workerId, worker.port);
7543 const transport = new WorkerTransport(messageHandler, task, networkStream, transportParams, transportFactory);
7544 task._transport = transport;
7545 messageHandler.send("Ready", null);
7546 });
7547 }).catch(task._capability.reject);
7548 return task;
7549}
7550async function _fetchDocument(worker, source) {
7551 if (worker.destroyed) {
7552 throw new Error("Worker was destroyed");
7553 }
7554 const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", source, source.data ? [source.data.buffer] : null);
7555 if (worker.destroyed) {
7556 throw new Error("Worker was destroyed");
7557 }
7558 return workerId;
7559}
7560function getUrlProp(val) {
7561 if (val instanceof URL) {
7562 return val.href;
7563 }
7564 try {
7565 return new URL(val, window.location).href;
7566 } catch {
7567 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS && typeof val === "string") {
7568 return val;
7569 }
7570 }
7571 throw new Error("Invalid PDF url data: " + "either string or URL-object is expected in the url property.");
7572}
7573function getDataProp(val) {
7574 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS && typeof Buffer !== "undefined" && val instanceof Buffer) {
7575 throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");
7576 }
7577 if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) {
7578 return val;
7579 }
7580 if (typeof val === "string") {
7581 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.stringToBytes)(val);
7582 }
7583 if (val instanceof ArrayBuffer || ArrayBuffer.isView(val) || typeof val === "object" && !isNaN(val?.length)) {
7584 return new Uint8Array(val);
7585 }
7586 throw new Error("Invalid PDF binary data: either TypedArray, " + "string, or array-like object is expected in the data property.");
7587}
7588class PDFDocumentLoadingTask {
7589 static #docId = 0;
7590 constructor() {
7591 this._capability = Promise.withResolvers();
7592 this._transport = null;
7593 this._worker = null;
7594 this.docId = `d${PDFDocumentLoadingTask.#docId++}`;
7595 this.destroyed = false;
7596 this.onPassword = null;
7597 this.onProgress = null;
7598 }
7599 get promise() {
7600 return this._capability.promise;
7601 }
7602 async destroy() {
7603 this.destroyed = true;
7604 try {
7605 if (this._worker?.port) {
7606 this._worker._pendingDestroy = true;
7607 }
7608 await this._transport?.destroy();
7609 } catch (ex) {
7610 if (this._worker?.port) {
7611 delete this._worker._pendingDestroy;
7612 }
7613 throw ex;
7614 }
7615 this._transport = null;
7616 if (this._worker) {
7617 this._worker.destroy();
7618 this._worker = null;
7619 }
7620 }
7621}
7622class PDFDataRangeTransport {
7623 constructor(length, initialData) {
7624 let progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
7625 let contentDispositionFilename = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
7626 this.length = length;
7627 this.initialData = initialData;
7628 this.progressiveDone = progressiveDone;
7629 this.contentDispositionFilename = contentDispositionFilename;
7630 this._rangeListeners = [];
7631 this._progressListeners = [];
7632 this._progressiveReadListeners = [];
7633 this._progressiveDoneListeners = [];
7634 this._readyCapability = Promise.withResolvers();
7635 }
7636 addRangeListener(listener) {
7637 this._rangeListeners.push(listener);
7638 }
7639 addProgressListener(listener) {
7640 this._progressListeners.push(listener);
7641 }
7642 addProgressiveReadListener(listener) {
7643 this._progressiveReadListeners.push(listener);
7644 }
7645 addProgressiveDoneListener(listener) {
7646 this._progressiveDoneListeners.push(listener);
7647 }
7648 onDataRange(begin, chunk) {
7649 for (const listener of this._rangeListeners) {
7650 listener(begin, chunk);
7651 }
7652 }
7653 onDataProgress(loaded, total) {
7654 this._readyCapability.promise.then(() => {
7655 for (const listener of this._progressListeners) {
7656 listener(loaded, total);
7657 }
7658 });
7659 }
7660 onDataProgressiveRead(chunk) {
7661 this._readyCapability.promise.then(() => {
7662 for (const listener of this._progressiveReadListeners) {
7663 listener(chunk);
7664 }
7665 });
7666 }
7667 onDataProgressiveDone() {
7668 this._readyCapability.promise.then(() => {
7669 for (const listener of this._progressiveDoneListeners) {
7670 listener();
7671 }
7672 });
7673 }
7674 transportReady() {
7675 this._readyCapability.resolve();
7676 }
7677 requestDataRange(begin, end) {
7678 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange");
7679 }
7680 abort() {}
7681}
7682class PDFDocumentProxy {
7683 constructor(pdfInfo, transport) {
7684 this._pdfInfo = pdfInfo;
7685 this._transport = transport;
7686 }
7687 get annotationStorage() {
7688 return this._transport.annotationStorage;
7689 }
7690 get filterFactory() {
7691 return this._transport.filterFactory;
7692 }
7693 get numPages() {
7694 return this._pdfInfo.numPages;
7695 }
7696 get fingerprints() {
7697 return this._pdfInfo.fingerprints;
7698 }
7699 get isPureXfa() {
7700 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
7701 }
7702 get allXfaHtml() {
7703 return this._transport._htmlForXfa;
7704 }
7705 getPage(pageNumber) {
7706 return this._transport.getPage(pageNumber);
7707 }
7708 getPageIndex(ref) {
7709 return this._transport.getPageIndex(ref);
7710 }
7711 getDestinations() {
7712 return this._transport.getDestinations();
7713 }
7714 getDestination(id) {
7715 return this._transport.getDestination(id);
7716 }
7717 getPageLabels() {
7718 return this._transport.getPageLabels();
7719 }
7720 getPageLayout() {
7721 return this._transport.getPageLayout();
7722 }
7723 getPageMode() {
7724 return this._transport.getPageMode();
7725 }
7726 getViewerPreferences() {
7727 return this._transport.getViewerPreferences();
7728 }
7729 getOpenAction() {
7730 return this._transport.getOpenAction();
7731 }
7732 getAttachments() {
7733 return this._transport.getAttachments();
7734 }
7735 getJSActions() {
7736 return this._transport.getDocJSActions();
7737 }
7738 getOutline() {
7739 return this._transport.getOutline();
7740 }
7741 getOptionalContentConfig() {
7742 let {
7743 intent = "display"
7744 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7745 const {
7746 renderingIntent
7747 } = this._transport.getRenderingIntent(intent);
7748 return this._transport.getOptionalContentConfig(renderingIntent);
7749 }
7750 getPermissions() {
7751 return this._transport.getPermissions();
7752 }
7753 getMetadata() {
7754 return this._transport.getMetadata();
7755 }
7756 getMarkInfo() {
7757 return this._transport.getMarkInfo();
7758 }
7759 getData() {
7760 return this._transport.getData();
7761 }
7762 saveDocument() {
7763 return this._transport.saveDocument();
7764 }
7765 getDownloadInfo() {
7766 return this._transport.downloadInfoCapability.promise;
7767 }
7768 cleanup() {
7769 let keepLoadedFonts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
7770 return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
7771 }
7772 destroy() {
7773 return this.loadingTask.destroy();
7774 }
7775 get loadingParams() {
7776 return this._transport.loadingParams;
7777 }
7778 get loadingTask() {
7779 return this._transport.loadingTask;
7780 }
7781 getFieldObjects() {
7782 return this._transport.getFieldObjects();
7783 }
7784 hasJSActions() {
7785 return this._transport.hasJSActions();
7786 }
7787 getCalculationOrderIds() {
7788 return this._transport.getCalculationOrderIds();
7789 }
7790}
7791class PDFPageProxy {
7792 #delayedCleanupTimeout = null;
7793 #pendingCleanup = false;
7794 constructor(pageIndex, pageInfo, transport) {
7795 let pdfBug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
7796 this._pageIndex = pageIndex;
7797 this._pageInfo = pageInfo;
7798 this._transport = transport;
7799 this._stats = pdfBug ? new _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.StatTimer() : null;
7800 this._pdfBug = pdfBug;
7801 this.commonObjs = transport.commonObjs;
7802 this.objs = new PDFObjects();
7803 this._maybeCleanupAfterRender = false;
7804 this._intentStates = new Map();
7805 this.destroyed = false;
7806 }
7807 get pageNumber() {
7808 return this._pageIndex + 1;
7809 }
7810 get rotate() {
7811 return this._pageInfo.rotate;
7812 }
7813 get ref() {
7814 return this._pageInfo.ref;
7815 }
7816 get userUnit() {
7817 return this._pageInfo.userUnit;
7818 }
7819 get view() {
7820 return this._pageInfo.view;
7821 }
7822 getViewport() {
7823 let {
7824 scale,
7825 rotation = this.rotate,
7826 offsetX = 0,
7827 offsetY = 0,
7828 dontFlip = false
7829 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7830 return new _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.PageViewport({
7831 viewBox: this.view,
7832 scale,
7833 rotation,
7834 offsetX,
7835 offsetY,
7836 dontFlip
7837 });
7838 }
7839 getAnnotations() {
7840 let {
7841 intent = "display"
7842 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7843 const {
7844 renderingIntent
7845 } = this._transport.getRenderingIntent(intent);
7846 return this._transport.getAnnotations(this._pageIndex, renderingIntent);
7847 }
7848 getJSActions() {
7849 return this._transport.getPageJSActions(this._pageIndex);
7850 }
7851 get filterFactory() {
7852 return this._transport.filterFactory;
7853 }
7854 get isPureXfa() {
7855 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
7856 }
7857 async getXfa() {
7858 return this._transport._htmlForXfa?.children[this._pageIndex] || null;
7859 }
7860 render(_ref2) {
7861 let {
7862 canvasContext,
7863 viewport,
7864 intent = "display",
7865 annotationMode = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AnnotationMode.ENABLE,
7866 transform = null,
7867 background = null,
7868 optionalContentConfigPromise = null,
7869 annotationCanvasMap = null,
7870 pageColors = null,
7871 printAnnotationStorage = null
7872 } = _ref2;
7873 this._stats?.time("Overall");
7874 const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage);
7875 const {
7876 renderingIntent,
7877 cacheKey
7878 } = intentArgs;
7879 this.#pendingCleanup = false;
7880 this.#abortDelayedCleanup();
7881 optionalContentConfigPromise ||= this._transport.getOptionalContentConfig(renderingIntent);
7882 let intentState = this._intentStates.get(cacheKey);
7883 if (!intentState) {
7884 intentState = Object.create(null);
7885 this._intentStates.set(cacheKey, intentState);
7886 }
7887 if (intentState.streamReaderCancelTimeout) {
7888 clearTimeout(intentState.streamReaderCancelTimeout);
7889 intentState.streamReaderCancelTimeout = null;
7890 }
7891 const intentPrint = !!(renderingIntent & _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.PRINT);
7892 if (!intentState.displayReadyCapability) {
7893 intentState.displayReadyCapability = Promise.withResolvers();
7894 intentState.operatorList = {
7895 fnArray: [],
7896 argsArray: [],
7897 lastChunk: false,
7898 separateAnnots: null
7899 };
7900 this._stats?.time("Page Request");
7901 this._pumpOperatorList(intentArgs);
7902 }
7903 const complete = error => {
7904 intentState.renderTasks.delete(internalRenderTask);
7905 if (this._maybeCleanupAfterRender || intentPrint) {
7906 this.#pendingCleanup = true;
7907 }
7908 this.#tryCleanup(!intentPrint);
7909 if (error) {
7910 internalRenderTask.capability.reject(error);
7911 this._abortOperatorList({
7912 intentState,
7913 reason: error instanceof Error ? error : new Error(error)
7914 });
7915 } else {
7916 internalRenderTask.capability.resolve();
7917 }
7918 this._stats?.timeEnd("Rendering");
7919 this._stats?.timeEnd("Overall");
7920 };
7921 const internalRenderTask = new InternalRenderTask({
7922 callback: complete,
7923 params: {
7924 canvasContext,
7925 viewport,
7926 transform,
7927 background
7928 },
7929 objs: this.objs,
7930 commonObjs: this.commonObjs,
7931 annotationCanvasMap,
7932 operatorList: intentState.operatorList,
7933 pageIndex: this._pageIndex,
7934 canvasFactory: this._transport.canvasFactory,
7935 filterFactory: this._transport.filterFactory,
7936 useRequestAnimationFrame: !intentPrint,
7937 pdfBug: this._pdfBug,
7938 pageColors
7939 });
7940 (intentState.renderTasks ||= new Set()).add(internalRenderTask);
7941 const renderTask = internalRenderTask.task;
7942 Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(_ref3 => {
7943 let [transparency, optionalContentConfig] = _ref3;
7944 if (this.destroyed) {
7945 complete();
7946 return;
7947 }
7948 this._stats?.time("Rendering");
7949 if (!(optionalContentConfig.renderingIntent & renderingIntent)) {
7950 throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` " + "and `PDFDocumentProxy.getOptionalContentConfig` methods.");
7951 }
7952 internalRenderTask.initializeGraphics({
7953 transparency,
7954 optionalContentConfig
7955 });
7956 internalRenderTask.operatorListChanged();
7957 }).catch(complete);
7958 return renderTask;
7959 }
7960 getOperatorList() {
7961 let {
7962 intent = "display",
7963 annotationMode = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AnnotationMode.ENABLE,
7964 printAnnotationStorage = null
7965 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7966 function operatorListChanged() {
7967 if (intentState.operatorList.lastChunk) {
7968 intentState.opListReadCapability.resolve(intentState.operatorList);
7969 intentState.renderTasks.delete(opListTask);
7970 }
7971 }
7972 const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage, true);
7973 let intentState = this._intentStates.get(intentArgs.cacheKey);
7974 if (!intentState) {
7975 intentState = Object.create(null);
7976 this._intentStates.set(intentArgs.cacheKey, intentState);
7977 }
7978 let opListTask;
7979 if (!intentState.opListReadCapability) {
7980 opListTask = Object.create(null);
7981 opListTask.operatorListChanged = operatorListChanged;
7982 intentState.opListReadCapability = Promise.withResolvers();
7983 (intentState.renderTasks ||= new Set()).add(opListTask);
7984 intentState.operatorList = {
7985 fnArray: [],
7986 argsArray: [],
7987 lastChunk: false,
7988 separateAnnots: null
7989 };
7990 this._stats?.time("Page Request");
7991 this._pumpOperatorList(intentArgs);
7992 }
7993 return intentState.opListReadCapability.promise;
7994 }
7995 streamTextContent() {
7996 let {
7997 includeMarkedContent = false,
7998 disableNormalization = false
7999 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8000 const TEXT_CONTENT_CHUNK_SIZE = 100;
8001 return this._transport.messageHandler.sendWithStream("GetTextContent", {
8002 pageIndex: this._pageIndex,
8003 includeMarkedContent: includeMarkedContent === true,
8004 disableNormalization: disableNormalization === true
8005 }, {
8006 highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
8007 size(textContent) {
8008 return textContent.items.length;
8009 }
8010 });
8011 }
8012 getTextContent() {
8013 let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8014 if (this._transport._htmlForXfa) {
8015 return this.getXfa().then(xfa => _xfa_text_js__WEBPACK_IMPORTED_MODULE_34__.XfaText.textContent(xfa));
8016 }
8017 const readableStream = this.streamTextContent(params);
8018 return new Promise(function (resolve, reject) {
8019 function pump() {
8020 reader.read().then(function (_ref4) {
8021 let {
8022 value,
8023 done
8024 } = _ref4;
8025 if (done) {
8026 resolve(textContent);
8027 return;
8028 }
8029 Object.assign(textContent.styles, value.styles);
8030 textContent.items.push(...value.items);
8031 pump();
8032 }, reject);
8033 }
8034 const reader = readableStream.getReader();
8035 const textContent = {
8036 items: [],
8037 styles: Object.create(null)
8038 };
8039 pump();
8040 });
8041 }
8042 getStructTree() {
8043 return this._transport.getStructTree(this._pageIndex);
8044 }
8045 _destroy() {
8046 this.destroyed = true;
8047 const waitOn = [];
8048 for (const intentState of this._intentStates.values()) {
8049 this._abortOperatorList({
8050 intentState,
8051 reason: new Error("Page was destroyed."),
8052 force: true
8053 });
8054 if (intentState.opListReadCapability) {
8055 continue;
8056 }
8057 for (const internalRenderTask of intentState.renderTasks) {
8058 waitOn.push(internalRenderTask.completed);
8059 internalRenderTask.cancel();
8060 }
8061 }
8062 this.objs.clear();
8063 this.#pendingCleanup = false;
8064 this.#abortDelayedCleanup();
8065 return Promise.all(waitOn);
8066 }
8067 cleanup() {
8068 let resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
8069 this.#pendingCleanup = true;
8070 const success = this.#tryCleanup(false);
8071 if (resetStats && success) {
8072 this._stats &&= new _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.StatTimer();
8073 }
8074 return success;
8075 }
8076 #tryCleanup() {
8077 let delayed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
8078 this.#abortDelayedCleanup();
8079 if (!this.#pendingCleanup || this.destroyed) {
8080 return false;
8081 }
8082 if (delayed) {
8083 this.#delayedCleanupTimeout = setTimeout(() => {
8084 this.#delayedCleanupTimeout = null;
8085 this.#tryCleanup(false);
8086 }, DELAYED_CLEANUP_TIMEOUT);
8087 return false;
8088 }
8089 for (const {
8090 renderTasks,
8091 operatorList
8092 } of this._intentStates.values()) {
8093 if (renderTasks.size > 0 || !operatorList.lastChunk) {
8094 return false;
8095 }
8096 }
8097 this._intentStates.clear();
8098 this.objs.clear();
8099 this.#pendingCleanup = false;
8100 return true;
8101 }
8102 #abortDelayedCleanup() {
8103 if (this.#delayedCleanupTimeout) {
8104 clearTimeout(this.#delayedCleanupTimeout);
8105 this.#delayedCleanupTimeout = null;
8106 }
8107 }
8108 _startRenderPage(transparency, cacheKey) {
8109 const intentState = this._intentStates.get(cacheKey);
8110 if (!intentState) {
8111 return;
8112 }
8113 this._stats?.timeEnd("Page Request");
8114 intentState.displayReadyCapability?.resolve(transparency);
8115 }
8116 _renderPageChunk(operatorListChunk, intentState) {
8117 for (let i = 0, ii = operatorListChunk.length; i < ii; i++) {
8118 intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
8119 intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
8120 }
8121 intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
8122 intentState.operatorList.separateAnnots = operatorListChunk.separateAnnots;
8123 for (const internalRenderTask of intentState.renderTasks) {
8124 internalRenderTask.operatorListChanged();
8125 }
8126 if (operatorListChunk.lastChunk) {
8127 this.#tryCleanup(true);
8128 }
8129 }
8130 _pumpOperatorList(_ref5) {
8131 let {
8132 renderingIntent,
8133 cacheKey,
8134 annotationStorageSerializable
8135 } = _ref5;
8136 const {
8137 map,
8138 transfer
8139 } = annotationStorageSerializable;
8140 const readableStream = this._transport.messageHandler.sendWithStream("GetOperatorList", {
8141 pageIndex: this._pageIndex,
8142 intent: renderingIntent,
8143 cacheKey,
8144 annotationStorage: map
8145 }, transfer);
8146 const reader = readableStream.getReader();
8147 const intentState = this._intentStates.get(cacheKey);
8148 intentState.streamReader = reader;
8149 const pump = () => {
8150 reader.read().then(_ref6 => {
8151 let {
8152 value,
8153 done
8154 } = _ref6;
8155 if (done) {
8156 intentState.streamReader = null;
8157 return;
8158 }
8159 if (this._transport.destroyed) {
8160 return;
8161 }
8162 this._renderPageChunk(value, intentState);
8163 pump();
8164 }, reason => {
8165 intentState.streamReader = null;
8166 if (this._transport.destroyed) {
8167 return;
8168 }
8169 if (intentState.operatorList) {
8170 intentState.operatorList.lastChunk = true;
8171 for (const internalRenderTask of intentState.renderTasks) {
8172 internalRenderTask.operatorListChanged();
8173 }
8174 this.#tryCleanup(true);
8175 }
8176 if (intentState.displayReadyCapability) {
8177 intentState.displayReadyCapability.reject(reason);
8178 } else if (intentState.opListReadCapability) {
8179 intentState.opListReadCapability.reject(reason);
8180 } else {
8181 throw reason;
8182 }
8183 });
8184 };
8185 pump();
8186 }
8187 _abortOperatorList(_ref7) {
8188 let {
8189 intentState,
8190 reason,
8191 force = false
8192 } = _ref7;
8193 if (!intentState.streamReader) {
8194 return;
8195 }
8196 if (intentState.streamReaderCancelTimeout) {
8197 clearTimeout(intentState.streamReaderCancelTimeout);
8198 intentState.streamReaderCancelTimeout = null;
8199 }
8200 if (!force) {
8201 if (intentState.renderTasks.size > 0) {
8202 return;
8203 }
8204 if (reason instanceof _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.RenderingCancelledException) {
8205 let delay = RENDERING_CANCELLED_TIMEOUT;
8206 if (reason.extraDelay > 0 && reason.extraDelay < 1000) {
8207 delay += reason.extraDelay;
8208 }
8209 intentState.streamReaderCancelTimeout = setTimeout(() => {
8210 intentState.streamReaderCancelTimeout = null;
8211 this._abortOperatorList({
8212 intentState,
8213 reason,
8214 force: true
8215 });
8216 }, delay);
8217 return;
8218 }
8219 }
8220 intentState.streamReader.cancel(new _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AbortException(reason.message)).catch(() => {});
8221 intentState.streamReader = null;
8222 if (this._transport.destroyed) {
8223 return;
8224 }
8225 for (const [curCacheKey, curIntentState] of this._intentStates) {
8226 if (curIntentState === intentState) {
8227 this._intentStates.delete(curCacheKey);
8228 break;
8229 }
8230 }
8231 this.cleanup();
8232 }
8233 get stats() {
8234 return this._stats;
8235 }
8236}
8237class LoopbackPort {
8238 #listeners = new Set();
8239 #deferred = Promise.resolve();
8240 postMessage(obj, transfer) {
8241 const event = {
8242 data: structuredClone(obj, transfer ? {
8243 transfer
8244 } : null)
8245 };
8246 this.#deferred.then(() => {
8247 for (const listener of this.#listeners) {
8248 listener.call(this, event);
8249 }
8250 });
8251 }
8252 addEventListener(name, listener) {
8253 this.#listeners.add(listener);
8254 }
8255 removeEventListener(name, listener) {
8256 this.#listeners.delete(listener);
8257 }
8258 terminate() {
8259 this.#listeners.clear();
8260 }
8261}
8262const PDFWorkerUtil = {
8263 isWorkerDisabled: false,
8264 fakeWorkerId: 0
8265};
8266{
8267 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.isNodeJS) {
8268 PDFWorkerUtil.isWorkerDisabled = true;
8269 _worker_options_js__WEBPACK_IMPORTED_MODULE_35__.GlobalWorkerOptions.workerSrc ||= "./pdf.worker.mjs";
8270 }
8271 PDFWorkerUtil.isSameOrigin = function (baseUrl, otherUrl) {
8272 let base;
8273 try {
8274 base = new URL(baseUrl);
8275 if (!base.origin || base.origin === "null") {
8276 return false;
8277 }
8278 } catch {
8279 return false;
8280 }
8281 const other = new URL(otherUrl, base);
8282 return base.origin === other.origin;
8283 };
8284 PDFWorkerUtil.createCDNWrapper = function (url) {
8285 const wrapper = `await import("${url}");`;
8286 return URL.createObjectURL(new Blob([wrapper], {
8287 type: "text/javascript"
8288 }));
8289 };
8290}
8291class PDFWorker {
8292 static #workerPorts;
8293 constructor() {
8294 let {
8295 name = null,
8296 port = null,
8297 verbosity = (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.getVerbosityLevel)()
8298 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8299 this.name = name;
8300 this.destroyed = false;
8301 this.verbosity = verbosity;
8302 this._readyCapability = Promise.withResolvers();
8303 this._port = null;
8304 this._webWorker = null;
8305 this._messageHandler = null;
8306 if (port) {
8307 if (PDFWorker.#workerPorts?.has(port)) {
8308 throw new Error("Cannot use more than one PDFWorker per port.");
8309 }
8310 (PDFWorker.#workerPorts ||= new WeakMap()).set(port, this);
8311 this._initializeFromPort(port);
8312 return;
8313 }
8314 this._initialize();
8315 }
8316 get promise() {
8317 return this._readyCapability.promise;
8318 }
8319 get port() {
8320 return this._port;
8321 }
8322 get messageHandler() {
8323 return this._messageHandler;
8324 }
8325 _initializeFromPort(port) {
8326 this._port = port;
8327 this._messageHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_27__.MessageHandler("main", "worker", port);
8328 this._messageHandler.on("ready", function () {});
8329 this._readyCapability.resolve();
8330 this._messageHandler.send("configure", {
8331 verbosity: this.verbosity
8332 });
8333 }
8334 _initialize() {
8335 if (!PDFWorkerUtil.isWorkerDisabled && !PDFWorker.#mainThreadWorkerMessageHandler) {
8336 let {
8337 workerSrc
8338 } = PDFWorker;
8339 try {
8340 if (!PDFWorkerUtil.isSameOrigin(window.location.href, workerSrc)) {
8341 workerSrc = PDFWorkerUtil.createCDNWrapper(new URL(workerSrc, window.location).href);
8342 }
8343 const worker = new Worker(workerSrc, {
8344 type: "module"
8345 });
8346 const messageHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_27__.MessageHandler("main", "worker", worker);
8347 const terminateEarly = () => {
8348 worker.removeEventListener("error", onWorkerError);
8349 messageHandler.destroy();
8350 worker.terminate();
8351 if (this.destroyed) {
8352 this._readyCapability.reject(new Error("Worker was destroyed"));
8353 } else {
8354 this._setupFakeWorker();
8355 }
8356 };
8357 const onWorkerError = () => {
8358 if (!this._webWorker) {
8359 terminateEarly();
8360 }
8361 };
8362 worker.addEventListener("error", onWorkerError);
8363 messageHandler.on("test", data => {
8364 worker.removeEventListener("error", onWorkerError);
8365 if (this.destroyed) {
8366 terminateEarly();
8367 return;
8368 }
8369 if (data) {
8370 this._messageHandler = messageHandler;
8371 this._port = worker;
8372 this._webWorker = worker;
8373 this._readyCapability.resolve();
8374 messageHandler.send("configure", {
8375 verbosity: this.verbosity
8376 });
8377 } else {
8378 this._setupFakeWorker();
8379 messageHandler.destroy();
8380 worker.terminate();
8381 }
8382 });
8383 messageHandler.on("ready", data => {
8384 worker.removeEventListener("error", onWorkerError);
8385 if (this.destroyed) {
8386 terminateEarly();
8387 return;
8388 }
8389 try {
8390 sendTest();
8391 } catch {
8392 this._setupFakeWorker();
8393 }
8394 });
8395 const sendTest = () => {
8396 const testObj = new Uint8Array();
8397 messageHandler.send("test", testObj, [testObj.buffer]);
8398 };
8399 sendTest();
8400 return;
8401 } catch {
8402 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.info)("The worker has been disabled.");
8403 }
8404 }
8405 this._setupFakeWorker();
8406 }
8407 _setupFakeWorker() {
8408 if (!PDFWorkerUtil.isWorkerDisabled) {
8409 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.warn)("Setting up fake worker.");
8410 PDFWorkerUtil.isWorkerDisabled = true;
8411 }
8412 PDFWorker._setupFakeWorkerGlobal.then(WorkerMessageHandler => {
8413 if (this.destroyed) {
8414 this._readyCapability.reject(new Error("Worker was destroyed"));
8415 return;
8416 }
8417 const port = new LoopbackPort();
8418 this._port = port;
8419 const id = `fake${PDFWorkerUtil.fakeWorkerId++}`;
8420 const workerHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_27__.MessageHandler(id + "_worker", id, port);
8421 WorkerMessageHandler.setup(workerHandler, port);
8422 const messageHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_27__.MessageHandler(id, id + "_worker", port);
8423 this._messageHandler = messageHandler;
8424 this._readyCapability.resolve();
8425 messageHandler.send("configure", {
8426 verbosity: this.verbosity
8427 });
8428 }).catch(reason => {
8429 this._readyCapability.reject(new Error(`Setting up fake worker failed: "${reason.message}".`));
8430 });
8431 }
8432 destroy() {
8433 this.destroyed = true;
8434 if (this._webWorker) {
8435 this._webWorker.terminate();
8436 this._webWorker = null;
8437 }
8438 PDFWorker.#workerPorts?.delete(this._port);
8439 this._port = null;
8440 if (this._messageHandler) {
8441 this._messageHandler.destroy();
8442 this._messageHandler = null;
8443 }
8444 }
8445 static fromPort(params) {
8446 if (!params?.port) {
8447 throw new Error("PDFWorker.fromPort - invalid method signature.");
8448 }
8449 const cachedPort = this.#workerPorts?.get(params.port);
8450 if (cachedPort) {
8451 if (cachedPort._pendingDestroy) {
8452 throw new Error("PDFWorker.fromPort - the worker is being destroyed.\n" + "Please remember to await `PDFDocumentLoadingTask.destroy()`-calls.");
8453 }
8454 return cachedPort;
8455 }
8456 return new PDFWorker(params);
8457 }
8458 static get workerSrc() {
8459 if (_worker_options_js__WEBPACK_IMPORTED_MODULE_35__.GlobalWorkerOptions.workerSrc) {
8460 return _worker_options_js__WEBPACK_IMPORTED_MODULE_35__.GlobalWorkerOptions.workerSrc;
8461 }
8462 throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
8463 }
8464 static get #mainThreadWorkerMessageHandler() {
8465 try {
8466 return globalThis.pdfjsWorker?.WorkerMessageHandler || null;
8467 } catch {
8468 return null;
8469 }
8470 }
8471 static get _setupFakeWorkerGlobal() {
8472 const loader = async () => {
8473 if (this.#mainThreadWorkerMessageHandler) {
8474 return this.#mainThreadWorkerMessageHandler;
8475 }
8476 const worker = await import( /*webpackIgnore: true*/this.workerSrc);
8477 return worker.WorkerMessageHandler;
8478 };
8479 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.shadow)(this, "_setupFakeWorkerGlobal", loader());
8480 }
8481}
8482class WorkerTransport {
8483 #methodPromises = new Map();
8484 #pageCache = new Map();
8485 #pagePromises = new Map();
8486 #passwordCapability = null;
8487 constructor(messageHandler, loadingTask, networkStream, params, factory) {
8488 this.messageHandler = messageHandler;
8489 this.loadingTask = loadingTask;
8490 this.commonObjs = new PDFObjects();
8491 this.fontLoader = new _font_loader_js__WEBPACK_IMPORTED_MODULE_23__.FontLoader({
8492 ownerDocument: params.ownerDocument,
8493 styleElement: params.styleElement
8494 });
8495 this._params = params;
8496 this.canvasFactory = factory.canvasFactory;
8497 this.filterFactory = factory.filterFactory;
8498 this.cMapReaderFactory = factory.cMapReaderFactory;
8499 this.standardFontDataFactory = factory.standardFontDataFactory;
8500 this.destroyed = false;
8501 this.destroyCapability = null;
8502 this._networkStream = networkStream;
8503 this._fullReader = null;
8504 this._lastProgress = null;
8505 this.downloadInfoCapability = Promise.withResolvers();
8506 this.setupMessageHandler();
8507 }
8508 #cacheSimpleMethod(name) {
8509 let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
8510 const cachedPromise = this.#methodPromises.get(name);
8511 if (cachedPromise) {
8512 return cachedPromise;
8513 }
8514 const promise = this.messageHandler.sendWithPromise(name, data);
8515 this.#methodPromises.set(name, promise);
8516 return promise;
8517 }
8518 get annotationStorage() {
8519 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.shadow)(this, "annotationStorage", new _annotation_storage_js__WEBPACK_IMPORTED_MODULE_21__.AnnotationStorage());
8520 }
8521 getRenderingIntent(intent) {
8522 let annotationMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AnnotationMode.ENABLE;
8523 let printAnnotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
8524 let isOpList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
8525 let renderingIntent = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.DISPLAY;
8526 let annotationStorageSerializable = _annotation_storage_js__WEBPACK_IMPORTED_MODULE_21__.SerializableEmpty;
8527 switch (intent) {
8528 case "any":
8529 renderingIntent = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.ANY;
8530 break;
8531 case "display":
8532 break;
8533 case "print":
8534 renderingIntent = _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.PRINT;
8535 break;
8536 default:
8537 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.warn)(`getRenderingIntent - invalid intent: ${intent}`);
8538 }
8539 switch (annotationMode) {
8540 case _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AnnotationMode.DISABLE:
8541 renderingIntent += _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.ANNOTATIONS_DISABLE;
8542 break;
8543 case _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AnnotationMode.ENABLE:
8544 break;
8545 case _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AnnotationMode.ENABLE_FORMS:
8546 renderingIntent += _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.ANNOTATIONS_FORMS;
8547 break;
8548 case _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AnnotationMode.ENABLE_STORAGE:
8549 renderingIntent += _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.ANNOTATIONS_STORAGE;
8550 const annotationStorage = renderingIntent & _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.PRINT && printAnnotationStorage instanceof _annotation_storage_js__WEBPACK_IMPORTED_MODULE_21__.PrintAnnotationStorage ? printAnnotationStorage : this.annotationStorage;
8551 annotationStorageSerializable = annotationStorage.serializable;
8552 break;
8553 default:
8554 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.warn)(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
8555 }
8556 if (isOpList) {
8557 renderingIntent += _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.RenderingIntentFlag.OPLIST;
8558 }
8559 return {
8560 renderingIntent,
8561 cacheKey: `${renderingIntent}_${annotationStorageSerializable.hash}`,
8562 annotationStorageSerializable
8563 };
8564 }
8565 destroy() {
8566 if (this.destroyCapability) {
8567 return this.destroyCapability.promise;
8568 }
8569 this.destroyed = true;
8570 this.destroyCapability = Promise.withResolvers();
8571 this.#passwordCapability?.reject(new Error("Worker was destroyed during onPassword callback"));
8572 const waitOn = [];
8573 for (const page of this.#pageCache.values()) {
8574 waitOn.push(page._destroy());
8575 }
8576 this.#pageCache.clear();
8577 this.#pagePromises.clear();
8578 if (this.hasOwnProperty("annotationStorage")) {
8579 this.annotationStorage.resetModified();
8580 }
8581 const terminated = this.messageHandler.sendWithPromise("Terminate", null);
8582 waitOn.push(terminated);
8583 Promise.all(waitOn).then(() => {
8584 this.commonObjs.clear();
8585 this.fontLoader.clear();
8586 this.#methodPromises.clear();
8587 this.filterFactory.destroy();
8588 (0,_text_layer_js__WEBPACK_IMPORTED_MODULE_26__.cleanupTextLayer)();
8589 this._networkStream?.cancelAllRequests(new _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.AbortException("Worker was terminated."));
8590 if (this.messageHandler) {
8591 this.messageHandler.destroy();
8592 this.messageHandler = null;
8593 }
8594 this.destroyCapability.resolve();
8595 }, this.destroyCapability.reject);
8596 return this.destroyCapability.promise;
8597 }
8598 setupMessageHandler() {
8599 const {
8600 messageHandler,
8601 loadingTask
8602 } = this;
8603 messageHandler.on("GetReader", (data, sink) => {
8604 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.assert)(this._networkStream, "GetReader - no `IPDFStream` instance available.");
8605 this._fullReader = this._networkStream.getFullReader();
8606 this._fullReader.onProgress = evt => {
8607 this._lastProgress = {
8608 loaded: evt.loaded,
8609 total: evt.total
8610 };
8611 };
8612 sink.onPull = () => {
8613 this._fullReader.read().then(function (_ref8) {
8614 let {
8615 value,
8616 done
8617 } = _ref8;
8618 if (done) {
8619 sink.close();
8620 return;
8621 }
8622 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.assert)(value instanceof ArrayBuffer, "GetReader - expected an ArrayBuffer.");
8623 sink.enqueue(new Uint8Array(value), 1, [value]);
8624 }).catch(reason => {
8625 sink.error(reason);
8626 });
8627 };
8628 sink.onCancel = reason => {
8629 this._fullReader.cancel(reason);
8630 sink.ready.catch(readyReason => {
8631 if (this.destroyed) {
8632 return;
8633 }
8634 throw readyReason;
8635 });
8636 };
8637 });
8638 messageHandler.on("ReaderHeadersReady", data => {
8639 const headersCapability = Promise.withResolvers();
8640 const fullReader = this._fullReader;
8641 fullReader.headersReady.then(() => {
8642 if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
8643 if (this._lastProgress) {
8644 loadingTask.onProgress?.(this._lastProgress);
8645 }
8646 fullReader.onProgress = evt => {
8647 loadingTask.onProgress?.({
8648 loaded: evt.loaded,
8649 total: evt.total
8650 });
8651 };
8652 }
8653 headersCapability.resolve({
8654 isStreamingSupported: fullReader.isStreamingSupported,
8655 isRangeSupported: fullReader.isRangeSupported,
8656 contentLength: fullReader.contentLength
8657 });
8658 }, headersCapability.reject);
8659 return headersCapability.promise;
8660 });
8661 messageHandler.on("GetRangeReader", (data, sink) => {
8662 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.assert)(this._networkStream, "GetRangeReader - no `IPDFStream` instance available.");
8663 const rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
8664 if (!rangeReader) {
8665 sink.close();
8666 return;
8667 }
8668 sink.onPull = () => {
8669 rangeReader.read().then(function (_ref9) {
8670 let {
8671 value,
8672 done
8673 } = _ref9;
8674 if (done) {
8675 sink.close();
8676 return;
8677 }
8678 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.assert)(value instanceof ArrayBuffer, "GetRangeReader - expected an ArrayBuffer.");
8679 sink.enqueue(new Uint8Array(value), 1, [value]);
8680 }).catch(reason => {
8681 sink.error(reason);
8682 });
8683 };
8684 sink.onCancel = reason => {
8685 rangeReader.cancel(reason);
8686 sink.ready.catch(readyReason => {
8687 if (this.destroyed) {
8688 return;
8689 }
8690 throw readyReason;
8691 });
8692 };
8693 });
8694 messageHandler.on("GetDoc", _ref10 => {
8695 let {
8696 pdfInfo
8697 } = _ref10;
8698 this._numPages = pdfInfo.numPages;
8699 this._htmlForXfa = pdfInfo.htmlForXfa;
8700 delete pdfInfo.htmlForXfa;
8701 loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
8702 });
8703 messageHandler.on("DocException", function (ex) {
8704 let reason;
8705 switch (ex.name) {
8706 case "PasswordException":
8707 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.PasswordException(ex.message, ex.code);
8708 break;
8709 case "InvalidPDFException":
8710 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.InvalidPDFException(ex.message);
8711 break;
8712 case "MissingPDFException":
8713 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.MissingPDFException(ex.message);
8714 break;
8715 case "UnexpectedResponseException":
8716 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.UnexpectedResponseException(ex.message, ex.status);
8717 break;
8718 case "UnknownErrorException":
8719 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.UnknownErrorException(ex.message, ex.details);
8720 break;
8721 default:
8722 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.unreachable)("DocException - expected a valid Error.");
8723 }
8724 loadingTask._capability.reject(reason);
8725 });
8726 messageHandler.on("PasswordRequest", exception => {
8727 this.#passwordCapability = Promise.withResolvers();
8728 if (loadingTask.onPassword) {
8729 const updatePassword = password => {
8730 if (password instanceof Error) {
8731 this.#passwordCapability.reject(password);
8732 } else {
8733 this.#passwordCapability.resolve({
8734 password
8735 });
8736 }
8737 };
8738 try {
8739 loadingTask.onPassword(updatePassword, exception.code);
8740 } catch (ex) {
8741 this.#passwordCapability.reject(ex);
8742 }
8743 } else {
8744 this.#passwordCapability.reject(new _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.PasswordException(exception.message, exception.code));
8745 }
8746 return this.#passwordCapability.promise;
8747 });
8748 messageHandler.on("DataLoaded", data => {
8749 loadingTask.onProgress?.({
8750 loaded: data.length,
8751 total: data.length
8752 });
8753 this.downloadInfoCapability.resolve(data);
8754 });
8755 messageHandler.on("StartRenderPage", data => {
8756 if (this.destroyed) {
8757 return;
8758 }
8759 const page = this.#pageCache.get(data.pageIndex);
8760 page._startRenderPage(data.transparency, data.cacheKey);
8761 });
8762 messageHandler.on("commonobj", _ref11 => {
8763 let [id, type, exportedData] = _ref11;
8764 if (this.destroyed) {
8765 return null;
8766 }
8767 if (this.commonObjs.has(id)) {
8768 return null;
8769 }
8770 switch (type) {
8771 case "Font":
8772 const params = this._params;
8773 if ("error" in exportedData) {
8774 const exportedError = exportedData.error;
8775 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.warn)(`Error during font loading: ${exportedError}`);
8776 this.commonObjs.resolve(id, exportedError);
8777 break;
8778 }
8779 const inspectFont = params.pdfBug && globalThis.FontInspector?.enabled ? (font, url) => globalThis.FontInspector.fontAdded(font, url) : null;
8780 const font = new _font_loader_js__WEBPACK_IMPORTED_MODULE_23__.FontFaceObject(exportedData, {
8781 isEvalSupported: params.isEvalSupported,
8782 disableFontFace: params.disableFontFace,
8783 ignoreErrors: params.ignoreErrors,
8784 inspectFont
8785 });
8786 this.fontLoader.bind(font).catch(() => messageHandler.sendWithPromise("FontFallback", {
8787 id
8788 })).finally(() => {
8789 if (!params.fontExtraProperties && font.data) {
8790 font.data = null;
8791 }
8792 this.commonObjs.resolve(id, font);
8793 });
8794 break;
8795 case "CopyLocalImage":
8796 const {
8797 imageRef
8798 } = exportedData;
8799 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.assert)(imageRef, "The imageRef must be defined.");
8800 for (const pageProxy of this.#pageCache.values()) {
8801 for (const [, data] of pageProxy.objs) {
8802 if (data.ref !== imageRef) {
8803 continue;
8804 }
8805 if (!data.dataLen) {
8806 return null;
8807 }
8808 this.commonObjs.resolve(id, structuredClone(data));
8809 return data.dataLen;
8810 }
8811 }
8812 break;
8813 case "FontPath":
8814 case "Image":
8815 case "Pattern":
8816 this.commonObjs.resolve(id, exportedData);
8817 break;
8818 default:
8819 throw new Error(`Got unknown common object type ${type}`);
8820 }
8821 return null;
8822 });
8823 messageHandler.on("obj", _ref12 => {
8824 let [id, pageIndex, type, imageData] = _ref12;
8825 if (this.destroyed) {
8826 return;
8827 }
8828 const pageProxy = this.#pageCache.get(pageIndex);
8829 if (pageProxy.objs.has(id)) {
8830 return;
8831 }
8832 if (pageProxy._intentStates.size === 0) {
8833 imageData?.bitmap?.close();
8834 return;
8835 }
8836 switch (type) {
8837 case "Image":
8838 pageProxy.objs.resolve(id, imageData);
8839 if (imageData?.dataLen > _shared_util_js__WEBPACK_IMPORTED_MODULE_20__.MAX_IMAGE_SIZE_TO_CACHE) {
8840 pageProxy._maybeCleanupAfterRender = true;
8841 }
8842 break;
8843 case "Pattern":
8844 pageProxy.objs.resolve(id, imageData);
8845 break;
8846 default:
8847 throw new Error(`Got unknown object type ${type}`);
8848 }
8849 });
8850 messageHandler.on("DocProgress", data => {
8851 if (this.destroyed) {
8852 return;
8853 }
8854 loadingTask.onProgress?.({
8855 loaded: data.loaded,
8856 total: data.total
8857 });
8858 });
8859 messageHandler.on("FetchBuiltInCMap", data => {
8860 if (this.destroyed) {
8861 return Promise.reject(new Error("Worker was destroyed."));
8862 }
8863 if (!this.cMapReaderFactory) {
8864 return Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."));
8865 }
8866 return this.cMapReaderFactory.fetch(data);
8867 });
8868 messageHandler.on("FetchStandardFontData", data => {
8869 if (this.destroyed) {
8870 return Promise.reject(new Error("Worker was destroyed."));
8871 }
8872 if (!this.standardFontDataFactory) {
8873 return Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."));
8874 }
8875 return this.standardFontDataFactory.fetch(data);
8876 });
8877 }
8878 getData() {
8879 return this.messageHandler.sendWithPromise("GetData", null);
8880 }
8881 saveDocument() {
8882 if (this.annotationStorage.size <= 0) {
8883 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.warn)("saveDocument called while `annotationStorage` is empty, " + "please use the getData-method instead.");
8884 }
8885 const {
8886 map,
8887 transfer
8888 } = this.annotationStorage.serializable;
8889 return this.messageHandler.sendWithPromise("SaveDocument", {
8890 isPureXfa: !!this._htmlForXfa,
8891 numPages: this._numPages,
8892 annotationStorage: map,
8893 filename: this._fullReader?.filename ?? null
8894 }, transfer).finally(() => {
8895 this.annotationStorage.resetModified();
8896 });
8897 }
8898 getPage(pageNumber) {
8899 if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
8900 return Promise.reject(new Error("Invalid page request."));
8901 }
8902 const pageIndex = pageNumber - 1,
8903 cachedPromise = this.#pagePromises.get(pageIndex);
8904 if (cachedPromise) {
8905 return cachedPromise;
8906 }
8907 const promise = this.messageHandler.sendWithPromise("GetPage", {
8908 pageIndex
8909 }).then(pageInfo => {
8910 if (this.destroyed) {
8911 throw new Error("Transport destroyed");
8912 }
8913 const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.pdfBug);
8914 this.#pageCache.set(pageIndex, page);
8915 return page;
8916 });
8917 this.#pagePromises.set(pageIndex, promise);
8918 return promise;
8919 }
8920 getPageIndex(ref) {
8921 if (typeof ref !== "object" || ref === null || !Number.isInteger(ref.num) || ref.num < 0 || !Number.isInteger(ref.gen) || ref.gen < 0) {
8922 return Promise.reject(new Error("Invalid pageIndex request."));
8923 }
8924 return this.messageHandler.sendWithPromise("GetPageIndex", {
8925 num: ref.num,
8926 gen: ref.gen
8927 });
8928 }
8929 getAnnotations(pageIndex, intent) {
8930 return this.messageHandler.sendWithPromise("GetAnnotations", {
8931 pageIndex,
8932 intent
8933 });
8934 }
8935 getFieldObjects() {
8936 return this.#cacheSimpleMethod("GetFieldObjects");
8937 }
8938 hasJSActions() {
8939 return this.#cacheSimpleMethod("HasJSActions");
8940 }
8941 getCalculationOrderIds() {
8942 return this.messageHandler.sendWithPromise("GetCalculationOrderIds", null);
8943 }
8944 getDestinations() {
8945 return this.messageHandler.sendWithPromise("GetDestinations", null);
8946 }
8947 getDestination(id) {
8948 if (typeof id !== "string") {
8949 return Promise.reject(new Error("Invalid destination request."));
8950 }
8951 return this.messageHandler.sendWithPromise("GetDestination", {
8952 id
8953 });
8954 }
8955 getPageLabels() {
8956 return this.messageHandler.sendWithPromise("GetPageLabels", null);
8957 }
8958 getPageLayout() {
8959 return this.messageHandler.sendWithPromise("GetPageLayout", null);
8960 }
8961 getPageMode() {
8962 return this.messageHandler.sendWithPromise("GetPageMode", null);
8963 }
8964 getViewerPreferences() {
8965 return this.messageHandler.sendWithPromise("GetViewerPreferences", null);
8966 }
8967 getOpenAction() {
8968 return this.messageHandler.sendWithPromise("GetOpenAction", null);
8969 }
8970 getAttachments() {
8971 return this.messageHandler.sendWithPromise("GetAttachments", null);
8972 }
8973 getDocJSActions() {
8974 return this.#cacheSimpleMethod("GetDocJSActions");
8975 }
8976 getPageJSActions(pageIndex) {
8977 return this.messageHandler.sendWithPromise("GetPageJSActions", {
8978 pageIndex
8979 });
8980 }
8981 getStructTree(pageIndex) {
8982 return this.messageHandler.sendWithPromise("GetStructTree", {
8983 pageIndex
8984 });
8985 }
8986 getOutline() {
8987 return this.messageHandler.sendWithPromise("GetOutline", null);
8988 }
8989 getOptionalContentConfig(renderingIntent) {
8990 return this.#cacheSimpleMethod("GetOptionalContentConfig").then(data => new _optional_content_config_js__WEBPACK_IMPORTED_MODULE_29__.OptionalContentConfig(data, renderingIntent));
8991 }
8992 getPermissions() {
8993 return this.messageHandler.sendWithPromise("GetPermissions", null);
8994 }
8995 getMetadata() {
8996 const name = "GetMetadata",
8997 cachedPromise = this.#methodPromises.get(name);
8998 if (cachedPromise) {
8999 return cachedPromise;
9000 }
9001 const promise = this.messageHandler.sendWithPromise(name, null).then(results => ({
9002 info: results[0],
9003 metadata: results[1] ? new _metadata_js__WEBPACK_IMPORTED_MODULE_28__.Metadata(results[1]) : null,
9004 contentDispositionFilename: this._fullReader?.filename ?? null,
9005 contentLength: this._fullReader?.contentLength ?? null
9006 }));
9007 this.#methodPromises.set(name, promise);
9008 return promise;
9009 }
9010 getMarkInfo() {
9011 return this.messageHandler.sendWithPromise("GetMarkInfo", null);
9012 }
9013 async startCleanup() {
9014 let keepLoadedFonts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
9015 if (this.destroyed) {
9016 return;
9017 }
9018 await this.messageHandler.sendWithPromise("Cleanup", null);
9019 for (const page of this.#pageCache.values()) {
9020 const cleanupSuccessful = page.cleanup();
9021 if (!cleanupSuccessful) {
9022 throw new Error(`startCleanup: Page ${page.pageNumber} is currently rendering.`);
9023 }
9024 }
9025 this.commonObjs.clear();
9026 if (!keepLoadedFonts) {
9027 this.fontLoader.clear();
9028 }
9029 this.#methodPromises.clear();
9030 this.filterFactory.destroy(true);
9031 (0,_text_layer_js__WEBPACK_IMPORTED_MODULE_26__.cleanupTextLayer)();
9032 }
9033 get loadingParams() {
9034 const {
9035 disableAutoFetch,
9036 enableXfa
9037 } = this._params;
9038 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_20__.shadow)(this, "loadingParams", {
9039 disableAutoFetch,
9040 enableXfa
9041 });
9042 }
9043}
9044const INITIAL_DATA = Symbol("INITIAL_DATA");
9045class PDFObjects {
9046 #objs = Object.create(null);
9047 #ensureObj(objId) {
9048 return this.#objs[objId] ||= {
9049 ...Promise.withResolvers(),
9050 data: INITIAL_DATA
9051 };
9052 }
9053 get(objId) {
9054 let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
9055 if (callback) {
9056 const obj = this.#ensureObj(objId);
9057 obj.promise.then(() => callback(obj.data));
9058 return null;
9059 }
9060 const obj = this.#objs[objId];
9061 if (!obj || obj.data === INITIAL_DATA) {
9062 throw new Error(`Requesting object that isn't resolved yet ${objId}.`);
9063 }
9064 return obj.data;
9065 }
9066 has(objId) {
9067 const obj = this.#objs[objId];
9068 return !!obj && obj.data !== INITIAL_DATA;
9069 }
9070 resolve(objId) {
9071 let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
9072 const obj = this.#ensureObj(objId);
9073 obj.data = data;
9074 obj.resolve();
9075 }
9076 clear() {
9077 for (const objId in this.#objs) {
9078 const {
9079 data
9080 } = this.#objs[objId];
9081 data?.bitmap?.close();
9082 }
9083 this.#objs = Object.create(null);
9084 }
9085 *[Symbol.iterator]() {
9086 for (const objId in this.#objs) {
9087 const {
9088 data
9089 } = this.#objs[objId];
9090 if (data === INITIAL_DATA) {
9091 continue;
9092 }
9093 yield [objId, data];
9094 }
9095 }
9096}
9097class RenderTask {
9098 #internalRenderTask = null;
9099 constructor(internalRenderTask) {
9100 this.#internalRenderTask = internalRenderTask;
9101 this.onContinue = null;
9102 }
9103 get promise() {
9104 return this.#internalRenderTask.capability.promise;
9105 }
9106 cancel() {
9107 let extraDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
9108 this.#internalRenderTask.cancel(null, extraDelay);
9109 }
9110 get separateAnnots() {
9111 const {
9112 separateAnnots
9113 } = this.#internalRenderTask.operatorList;
9114 if (!separateAnnots) {
9115 return false;
9116 }
9117 const {
9118 annotationCanvasMap
9119 } = this.#internalRenderTask;
9120 return separateAnnots.form || separateAnnots.canvas && annotationCanvasMap?.size > 0;
9121 }
9122}
9123class InternalRenderTask {
9124 static #canvasInUse = new WeakSet();
9125 constructor(_ref13) {
9126 let {
9127 callback,
9128 params,
9129 objs,
9130 commonObjs,
9131 annotationCanvasMap,
9132 operatorList,
9133 pageIndex,
9134 canvasFactory,
9135 filterFactory,
9136 useRequestAnimationFrame = false,
9137 pdfBug = false,
9138 pageColors = null
9139 } = _ref13;
9140 this.callback = callback;
9141 this.params = params;
9142 this.objs = objs;
9143 this.commonObjs = commonObjs;
9144 this.annotationCanvasMap = annotationCanvasMap;
9145 this.operatorListIdx = null;
9146 this.operatorList = operatorList;
9147 this._pageIndex = pageIndex;
9148 this.canvasFactory = canvasFactory;
9149 this.filterFactory = filterFactory;
9150 this._pdfBug = pdfBug;
9151 this.pageColors = pageColors;
9152 this.running = false;
9153 this.graphicsReadyCallback = null;
9154 this.graphicsReady = false;
9155 this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== "undefined";
9156 this.cancelled = false;
9157 this.capability = Promise.withResolvers();
9158 this.task = new RenderTask(this);
9159 this._cancelBound = this.cancel.bind(this);
9160 this._continueBound = this._continue.bind(this);
9161 this._scheduleNextBound = this._scheduleNext.bind(this);
9162 this._nextBound = this._next.bind(this);
9163 this._canvas = params.canvasContext.canvas;
9164 }
9165 get completed() {
9166 return this.capability.promise.catch(function () {});
9167 }
9168 initializeGraphics(_ref14) {
9169 let {
9170 transparency = false,
9171 optionalContentConfig
9172 } = _ref14;
9173 if (this.cancelled) {
9174 return;
9175 }
9176 if (this._canvas) {
9177 if (InternalRenderTask.#canvasInUse.has(this._canvas)) {
9178 throw new Error("Cannot use the same canvas during multiple render() operations. " + "Use different canvas or ensure previous operations were " + "cancelled or completed.");
9179 }
9180 InternalRenderTask.#canvasInUse.add(this._canvas);
9181 }
9182 if (this._pdfBug && globalThis.StepperManager?.enabled) {
9183 this.stepper = globalThis.StepperManager.create(this._pageIndex);
9184 this.stepper.init(this.operatorList);
9185 this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
9186 }
9187 const {
9188 canvasContext,
9189 viewport,
9190 transform,
9191 background
9192 } = this.params;
9193 this.gfx = new _canvas_js__WEBPACK_IMPORTED_MODULE_25__.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
9194 optionalContentConfig
9195 }, this.annotationCanvasMap, this.pageColors);
9196 this.gfx.beginDrawing({
9197 transform,
9198 viewport,
9199 transparency,
9200 background
9201 });
9202 this.operatorListIdx = 0;
9203 this.graphicsReady = true;
9204 this.graphicsReadyCallback?.();
9205 }
9206 cancel() {
9207 let error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
9208 let extraDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
9209 this.running = false;
9210 this.cancelled = true;
9211 this.gfx?.endDrawing();
9212 InternalRenderTask.#canvasInUse.delete(this._canvas);
9213 this.callback(error || new _display_utils_js__WEBPACK_IMPORTED_MODULE_22__.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex + 1}`, extraDelay));
9214 }
9215 operatorListChanged() {
9216 if (!this.graphicsReady) {
9217 this.graphicsReadyCallback ||= this._continueBound;
9218 return;
9219 }
9220 this.stepper?.updateOperatorList(this.operatorList);
9221 if (this.running) {
9222 return;
9223 }
9224 this._continue();
9225 }
9226 _continue() {
9227 this.running = true;
9228 if (this.cancelled) {
9229 return;
9230 }
9231 if (this.task.onContinue) {
9232 this.task.onContinue(this._scheduleNextBound);
9233 } else {
9234 this._scheduleNext();
9235 }
9236 }
9237 _scheduleNext() {
9238 if (this._useRequestAnimationFrame) {
9239 window.requestAnimationFrame(() => {
9240 this._nextBound().catch(this._cancelBound);
9241 });
9242 } else {
9243 Promise.resolve().then(this._nextBound).catch(this._cancelBound);
9244 }
9245 }
9246 async _next() {
9247 if (this.cancelled) {
9248 return;
9249 }
9250 this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
9251 if (this.operatorListIdx === this.operatorList.argsArray.length) {
9252 this.running = false;
9253 if (this.operatorList.lastChunk) {
9254 this.gfx.endDrawing();
9255 InternalRenderTask.#canvasInUse.delete(this._canvas);
9256 this.callback();
9257 }
9258 }
9259 }
9260}
9261const version = "4.1.392";
9262const build = "fcb76a78d";
9263
9264__webpack_async_result__();
9265} catch(e) { __webpack_async_result__(e); } });
9266
9267/***/ }),
9268
9269/***/ 2583:
9270/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9271
9272/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9273/* harmony export */ BaseCMapReaderFactory: () => (/* binding */ BaseCMapReaderFactory),
9274/* harmony export */ BaseCanvasFactory: () => (/* binding */ BaseCanvasFactory),
9275/* harmony export */ BaseFilterFactory: () => (/* binding */ BaseFilterFactory),
9276/* harmony export */ BaseSVGFactory: () => (/* binding */ BaseSVGFactory),
9277/* harmony export */ BaseStandardFontDataFactory: () => (/* binding */ BaseStandardFontDataFactory)
9278/* harmony export */ });
9279/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4292);
9280
9281class BaseFilterFactory {
9282 constructor() {
9283 if (this.constructor === BaseFilterFactory) {
9284 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseFilterFactory.");
9285 }
9286 }
9287 addFilter(maps) {
9288 return "none";
9289 }
9290 addHCMFilter(fgColor, bgColor) {
9291 return "none";
9292 }
9293 addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
9294 return "none";
9295 }
9296 destroy() {
9297 let keepHCM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
9298 }
9299}
9300class BaseCanvasFactory {
9301 constructor() {
9302 if (this.constructor === BaseCanvasFactory) {
9303 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseCanvasFactory.");
9304 }
9305 }
9306 create(width, height) {
9307 if (width <= 0 || height <= 0) {
9308 throw new Error("Invalid canvas size");
9309 }
9310 const canvas = this._createCanvas(width, height);
9311 return {
9312 canvas,
9313 context: canvas.getContext("2d")
9314 };
9315 }
9316 reset(canvasAndContext, width, height) {
9317 if (!canvasAndContext.canvas) {
9318 throw new Error("Canvas is not specified");
9319 }
9320 if (width <= 0 || height <= 0) {
9321 throw new Error("Invalid canvas size");
9322 }
9323 canvasAndContext.canvas.width = width;
9324 canvasAndContext.canvas.height = height;
9325 }
9326 destroy(canvasAndContext) {
9327 if (!canvasAndContext.canvas) {
9328 throw new Error("Canvas is not specified");
9329 }
9330 canvasAndContext.canvas.width = 0;
9331 canvasAndContext.canvas.height = 0;
9332 canvasAndContext.canvas = null;
9333 canvasAndContext.context = null;
9334 }
9335 _createCanvas(width, height) {
9336 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method `_createCanvas` called.");
9337 }
9338}
9339class BaseCMapReaderFactory {
9340 constructor(_ref) {
9341 let {
9342 baseUrl = null,
9343 isCompressed = true
9344 } = _ref;
9345 if (this.constructor === BaseCMapReaderFactory) {
9346 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseCMapReaderFactory.");
9347 }
9348 this.baseUrl = baseUrl;
9349 this.isCompressed = isCompressed;
9350 }
9351 async fetch(_ref2) {
9352 let {
9353 name
9354 } = _ref2;
9355 if (!this.baseUrl) {
9356 throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
9357 }
9358 if (!name) {
9359 throw new Error("CMap name must be specified.");
9360 }
9361 const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
9362 const compressionType = this.isCompressed ? _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.CMapCompressionType.BINARY : _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.CMapCompressionType.NONE;
9363 return this._fetchData(url, compressionType).catch(reason => {
9364 throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`);
9365 });
9366 }
9367 _fetchData(url, compressionType) {
9368 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method `_fetchData` called.");
9369 }
9370}
9371class BaseStandardFontDataFactory {
9372 constructor(_ref3) {
9373 let {
9374 baseUrl = null
9375 } = _ref3;
9376 if (this.constructor === BaseStandardFontDataFactory) {
9377 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseStandardFontDataFactory.");
9378 }
9379 this.baseUrl = baseUrl;
9380 }
9381 async fetch(_ref4) {
9382 let {
9383 filename
9384 } = _ref4;
9385 if (!this.baseUrl) {
9386 throw new Error('The standard font "baseUrl" parameter must be specified, ensure that ' + 'the "standardFontDataUrl" API parameter is provided.');
9387 }
9388 if (!filename) {
9389 throw new Error("Font filename must be specified.");
9390 }
9391 const url = `${this.baseUrl}${filename}`;
9392 return this._fetchData(url).catch(reason => {
9393 throw new Error(`Unable to load font data at: ${url}`);
9394 });
9395 }
9396 _fetchData(url) {
9397 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method `_fetchData` called.");
9398 }
9399}
9400class BaseSVGFactory {
9401 constructor() {
9402 if (this.constructor === BaseSVGFactory) {
9403 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseSVGFactory.");
9404 }
9405 }
9406 create(width, height) {
9407 let skipDimensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
9408 if (width <= 0 || height <= 0) {
9409 throw new Error("Invalid SVG dimensions");
9410 }
9411 const svg = this._createSVG("svg:svg");
9412 svg.setAttribute("version", "1.1");
9413 if (!skipDimensions) {
9414 svg.setAttribute("width", `${width}px`);
9415 svg.setAttribute("height", `${height}px`);
9416 }
9417 svg.setAttribute("preserveAspectRatio", "none");
9418 svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
9419 return svg;
9420 }
9421 createElement(type) {
9422 if (typeof type !== "string") {
9423 throw new Error("Invalid SVG element type");
9424 }
9425 return this._createSVG(type);
9426 }
9427 _createSVG(type) {
9428 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method `_createSVG` called.");
9429 }
9430}
9431
9432
9433/***/ }),
9434
9435/***/ 4923:
9436/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9437
9438
9439// EXPORTS
9440__webpack_require__.d(__webpack_exports__, {
9441 CanvasGraphics: () => (/* binding */ CanvasGraphics)
9442});
9443
9444// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
9445var es_array_push = __webpack_require__(4114);
9446// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array-buffer.detached.js
9447var es_array_buffer_detached = __webpack_require__(6573);
9448// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array-buffer.transfer.js
9449var es_array_buffer_transfer = __webpack_require__(8100);
9450// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array-buffer.transfer-to-fixed-length.js
9451var es_array_buffer_transfer_to_fixed_length = __webpack_require__(7936);
9452// EXTERNAL MODULE: ./node_modules/core-js/modules/es.typed-array.to-reversed.js
9453var es_typed_array_to_reversed = __webpack_require__(7467);
9454// EXTERNAL MODULE: ./node_modules/core-js/modules/es.typed-array.to-sorted.js
9455var es_typed_array_to_sorted = __webpack_require__(4732);
9456// EXTERNAL MODULE: ./node_modules/core-js/modules/es.typed-array.with.js
9457var es_typed_array_with = __webpack_require__(9577);
9458// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.constructor.js
9459var esnext_iterator_constructor = __webpack_require__(8992);
9460// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.filter.js
9461var esnext_iterator_filter = __webpack_require__(4520);
9462// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.map.js
9463var esnext_iterator_map = __webpack_require__(1454);
9464// EXTERNAL MODULE: ./src/shared/util.js
9465var util = __webpack_require__(4292);
9466// EXTERNAL MODULE: ./src/display/display_utils.js
9467var display_utils = __webpack_require__(5419);
9468;// CONCATENATED MODULE: ./src/display/pattern_helper.js
9469
9470
9471const PathType = {
9472 FILL: "Fill",
9473 STROKE: "Stroke",
9474 SHADING: "Shading"
9475};
9476function applyBoundingBox(ctx, bbox) {
9477 if (!bbox) {
9478 return;
9479 }
9480 const width = bbox[2] - bbox[0];
9481 const height = bbox[3] - bbox[1];
9482 const region = new Path2D();
9483 region.rect(bbox[0], bbox[1], width, height);
9484 ctx.clip(region);
9485}
9486class BaseShadingPattern {
9487 constructor() {
9488 if (this.constructor === BaseShadingPattern) {
9489 (0,util.unreachable)("Cannot initialize BaseShadingPattern.");
9490 }
9491 }
9492 getPattern() {
9493 (0,util.unreachable)("Abstract method `getPattern` called.");
9494 }
9495}
9496class RadialAxialShadingPattern extends BaseShadingPattern {
9497 constructor(IR) {
9498 super();
9499 this._type = IR[1];
9500 this._bbox = IR[2];
9501 this._colorStops = IR[3];
9502 this._p0 = IR[4];
9503 this._p1 = IR[5];
9504 this._r0 = IR[6];
9505 this._r1 = IR[7];
9506 this.matrix = null;
9507 }
9508 _createGradient(ctx) {
9509 let grad;
9510 if (this._type === "axial") {
9511 grad = ctx.createLinearGradient(this._p0[0], this._p0[1], this._p1[0], this._p1[1]);
9512 } else if (this._type === "radial") {
9513 grad = ctx.createRadialGradient(this._p0[0], this._p0[1], this._r0, this._p1[0], this._p1[1], this._r1);
9514 }
9515 for (const colorStop of this._colorStops) {
9516 grad.addColorStop(colorStop[0], colorStop[1]);
9517 }
9518 return grad;
9519 }
9520 getPattern(ctx, owner, inverse, pathType) {
9521 let pattern;
9522 if (pathType === PathType.STROKE || pathType === PathType.FILL) {
9523 const ownerBBox = owner.current.getClippedPathBoundingBox(pathType, (0,display_utils.getCurrentTransform)(ctx)) || [0, 0, 0, 0];
9524 const width = Math.ceil(ownerBBox[2] - ownerBBox[0]) || 1;
9525 const height = Math.ceil(ownerBBox[3] - ownerBBox[1]) || 1;
9526 const tmpCanvas = owner.cachedCanvases.getCanvas("pattern", width, height, true);
9527 const tmpCtx = tmpCanvas.context;
9528 tmpCtx.clearRect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
9529 tmpCtx.beginPath();
9530 tmpCtx.rect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
9531 tmpCtx.translate(-ownerBBox[0], -ownerBBox[1]);
9532 inverse = util.Util.transform(inverse, [1, 0, 0, 1, ownerBBox[0], ownerBBox[1]]);
9533 tmpCtx.transform(...owner.baseTransform);
9534 if (this.matrix) {
9535 tmpCtx.transform(...this.matrix);
9536 }
9537 applyBoundingBox(tmpCtx, this._bbox);
9538 tmpCtx.fillStyle = this._createGradient(tmpCtx);
9539 tmpCtx.fill();
9540 pattern = ctx.createPattern(tmpCanvas.canvas, "no-repeat");
9541 const domMatrix = new DOMMatrix(inverse);
9542 pattern.setTransform(domMatrix);
9543 } else {
9544 applyBoundingBox(ctx, this._bbox);
9545 pattern = this._createGradient(ctx);
9546 }
9547 return pattern;
9548 }
9549}
9550function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
9551 const coords = context.coords,
9552 colors = context.colors;
9553 const bytes = data.data,
9554 rowSize = data.width * 4;
9555 let tmp;
9556 if (coords[p1 + 1] > coords[p2 + 1]) {
9557 tmp = p1;
9558 p1 = p2;
9559 p2 = tmp;
9560 tmp = c1;
9561 c1 = c2;
9562 c2 = tmp;
9563 }
9564 if (coords[p2 + 1] > coords[p3 + 1]) {
9565 tmp = p2;
9566 p2 = p3;
9567 p3 = tmp;
9568 tmp = c2;
9569 c2 = c3;
9570 c3 = tmp;
9571 }
9572 if (coords[p1 + 1] > coords[p2 + 1]) {
9573 tmp = p1;
9574 p1 = p2;
9575 p2 = tmp;
9576 tmp = c1;
9577 c1 = c2;
9578 c2 = tmp;
9579 }
9580 const x1 = (coords[p1] + context.offsetX) * context.scaleX;
9581 const y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
9582 const x2 = (coords[p2] + context.offsetX) * context.scaleX;
9583 const y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
9584 const x3 = (coords[p3] + context.offsetX) * context.scaleX;
9585 const y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
9586 if (y1 >= y3) {
9587 return;
9588 }
9589 const c1r = colors[c1],
9590 c1g = colors[c1 + 1],
9591 c1b = colors[c1 + 2];
9592 const c2r = colors[c2],
9593 c2g = colors[c2 + 1],
9594 c2b = colors[c2 + 2];
9595 const c3r = colors[c3],
9596 c3g = colors[c3 + 1],
9597 c3b = colors[c3 + 2];
9598 const minY = Math.round(y1),
9599 maxY = Math.round(y3);
9600 let xa, car, cag, cab;
9601 let xb, cbr, cbg, cbb;
9602 for (let y = minY; y <= maxY; y++) {
9603 if (y < y2) {
9604 const k = y < y1 ? 0 : (y1 - y) / (y1 - y2);
9605 xa = x1 - (x1 - x2) * k;
9606 car = c1r - (c1r - c2r) * k;
9607 cag = c1g - (c1g - c2g) * k;
9608 cab = c1b - (c1b - c2b) * k;
9609 } else {
9610 let k;
9611 if (y > y3) {
9612 k = 1;
9613 } else if (y2 === y3) {
9614 k = 0;
9615 } else {
9616 k = (y2 - y) / (y2 - y3);
9617 }
9618 xa = x2 - (x2 - x3) * k;
9619 car = c2r - (c2r - c3r) * k;
9620 cag = c2g - (c2g - c3g) * k;
9621 cab = c2b - (c2b - c3b) * k;
9622 }
9623 let k;
9624 if (y < y1) {
9625 k = 0;
9626 } else if (y > y3) {
9627 k = 1;
9628 } else {
9629 k = (y1 - y) / (y1 - y3);
9630 }
9631 xb = x1 - (x1 - x3) * k;
9632 cbr = c1r - (c1r - c3r) * k;
9633 cbg = c1g - (c1g - c3g) * k;
9634 cbb = c1b - (c1b - c3b) * k;
9635 const x1_ = Math.round(Math.min(xa, xb));
9636 const x2_ = Math.round(Math.max(xa, xb));
9637 let j = rowSize * y + x1_ * 4;
9638 for (let x = x1_; x <= x2_; x++) {
9639 k = (xa - x) / (xa - xb);
9640 if (k < 0) {
9641 k = 0;
9642 } else if (k > 1) {
9643 k = 1;
9644 }
9645 bytes[j++] = car - (car - cbr) * k | 0;
9646 bytes[j++] = cag - (cag - cbg) * k | 0;
9647 bytes[j++] = cab - (cab - cbb) * k | 0;
9648 bytes[j++] = 255;
9649 }
9650 }
9651}
9652function drawFigure(data, figure, context) {
9653 const ps = figure.coords;
9654 const cs = figure.colors;
9655 let i, ii;
9656 switch (figure.type) {
9657 case "lattice":
9658 const verticesPerRow = figure.verticesPerRow;
9659 const rows = Math.floor(ps.length / verticesPerRow) - 1;
9660 const cols = verticesPerRow - 1;
9661 for (i = 0; i < rows; i++) {
9662 let q = i * verticesPerRow;
9663 for (let j = 0; j < cols; j++, q++) {
9664 drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
9665 drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
9666 }
9667 }
9668 break;
9669 case "triangles":
9670 for (i = 0, ii = ps.length; i < ii; i += 3) {
9671 drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
9672 }
9673 break;
9674 default:
9675 throw new Error("illegal figure");
9676 }
9677}
9678class MeshShadingPattern extends BaseShadingPattern {
9679 constructor(IR) {
9680 super();
9681 this._coords = IR[2];
9682 this._colors = IR[3];
9683 this._figures = IR[4];
9684 this._bounds = IR[5];
9685 this._bbox = IR[7];
9686 this._background = IR[8];
9687 this.matrix = null;
9688 }
9689 _createMeshCanvas(combinedScale, backgroundColor, cachedCanvases) {
9690 const EXPECTED_SCALE = 1.1;
9691 const MAX_PATTERN_SIZE = 3000;
9692 const BORDER_SIZE = 2;
9693 const offsetX = Math.floor(this._bounds[0]);
9694 const offsetY = Math.floor(this._bounds[1]);
9695 const boundsWidth = Math.ceil(this._bounds[2]) - offsetX;
9696 const boundsHeight = Math.ceil(this._bounds[3]) - offsetY;
9697 const width = Math.min(Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
9698 const height = Math.min(Math.ceil(Math.abs(boundsHeight * combinedScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
9699 const scaleX = boundsWidth / width;
9700 const scaleY = boundsHeight / height;
9701 const context = {
9702 coords: this._coords,
9703 colors: this._colors,
9704 offsetX: -offsetX,
9705 offsetY: -offsetY,
9706 scaleX: 1 / scaleX,
9707 scaleY: 1 / scaleY
9708 };
9709 const paddedWidth = width + BORDER_SIZE * 2;
9710 const paddedHeight = height + BORDER_SIZE * 2;
9711 const tmpCanvas = cachedCanvases.getCanvas("mesh", paddedWidth, paddedHeight, false);
9712 const tmpCtx = tmpCanvas.context;
9713 const data = tmpCtx.createImageData(width, height);
9714 if (backgroundColor) {
9715 const bytes = data.data;
9716 for (let i = 0, ii = bytes.length; i < ii; i += 4) {
9717 bytes[i] = backgroundColor[0];
9718 bytes[i + 1] = backgroundColor[1];
9719 bytes[i + 2] = backgroundColor[2];
9720 bytes[i + 3] = 255;
9721 }
9722 }
9723 for (const figure of this._figures) {
9724 drawFigure(data, figure, context);
9725 }
9726 tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
9727 const canvas = tmpCanvas.canvas;
9728 return {
9729 canvas,
9730 offsetX: offsetX - BORDER_SIZE * scaleX,
9731 offsetY: offsetY - BORDER_SIZE * scaleY,
9732 scaleX,
9733 scaleY
9734 };
9735 }
9736 getPattern(ctx, owner, inverse, pathType) {
9737 applyBoundingBox(ctx, this._bbox);
9738 let scale;
9739 if (pathType === PathType.SHADING) {
9740 scale = util.Util.singularValueDecompose2dScale((0,display_utils.getCurrentTransform)(ctx));
9741 } else {
9742 scale = util.Util.singularValueDecompose2dScale(owner.baseTransform);
9743 if (this.matrix) {
9744 const matrixScale = util.Util.singularValueDecompose2dScale(this.matrix);
9745 scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
9746 }
9747 }
9748 const temporaryPatternCanvas = this._createMeshCanvas(scale, pathType === PathType.SHADING ? null : this._background, owner.cachedCanvases);
9749 if (pathType !== PathType.SHADING) {
9750 ctx.setTransform(...owner.baseTransform);
9751 if (this.matrix) {
9752 ctx.transform(...this.matrix);
9753 }
9754 }
9755 ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
9756 ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
9757 return ctx.createPattern(temporaryPatternCanvas.canvas, "no-repeat");
9758 }
9759}
9760class DummyShadingPattern extends BaseShadingPattern {
9761 getPattern() {
9762 return "hotpink";
9763 }
9764}
9765function getShadingPattern(IR) {
9766 switch (IR[0]) {
9767 case "RadialAxial":
9768 return new RadialAxialShadingPattern(IR);
9769 case "Mesh":
9770 return new MeshShadingPattern(IR);
9771 case "Dummy":
9772 return new DummyShadingPattern();
9773 }
9774 throw new Error(`Unknown IR type: ${IR[0]}`);
9775}
9776const PaintType = {
9777 COLORED: 1,
9778 UNCOLORED: 2
9779};
9780class TilingPattern {
9781 static MAX_PATTERN_SIZE = 3000;
9782 constructor(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
9783 this.operatorList = IR[2];
9784 this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
9785 this.bbox = IR[4];
9786 this.xstep = IR[5];
9787 this.ystep = IR[6];
9788 this.paintType = IR[7];
9789 this.tilingType = IR[8];
9790 this.color = color;
9791 this.ctx = ctx;
9792 this.canvasGraphicsFactory = canvasGraphicsFactory;
9793 this.baseTransform = baseTransform;
9794 }
9795 createPatternCanvas(owner) {
9796 const operatorList = this.operatorList;
9797 const bbox = this.bbox;
9798 const xstep = this.xstep;
9799 const ystep = this.ystep;
9800 const paintType = this.paintType;
9801 const tilingType = this.tilingType;
9802 const color = this.color;
9803 const canvasGraphicsFactory = this.canvasGraphicsFactory;
9804 (0,util.info)("TilingType: " + tilingType);
9805 const x0 = bbox[0],
9806 y0 = bbox[1],
9807 x1 = bbox[2],
9808 y1 = bbox[3];
9809 const matrixScale = util.Util.singularValueDecompose2dScale(this.matrix);
9810 const curMatrixScale = util.Util.singularValueDecompose2dScale(this.baseTransform);
9811 const combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
9812 const dimx = this.getSizeAndScale(xstep, this.ctx.canvas.width, combinedScale[0]);
9813 const dimy = this.getSizeAndScale(ystep, this.ctx.canvas.height, combinedScale[1]);
9814 const tmpCanvas = owner.cachedCanvases.getCanvas("pattern", dimx.size, dimy.size, true);
9815 const tmpCtx = tmpCanvas.context;
9816 const graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
9817 graphics.groupLevel = owner.groupLevel;
9818 this.setFillAndStrokeStyleToContext(graphics, paintType, color);
9819 let adjustedX0 = x0;
9820 let adjustedY0 = y0;
9821 let adjustedX1 = x1;
9822 let adjustedY1 = y1;
9823 if (x0 < 0) {
9824 adjustedX0 = 0;
9825 adjustedX1 += Math.abs(x0);
9826 }
9827 if (y0 < 0) {
9828 adjustedY0 = 0;
9829 adjustedY1 += Math.abs(y0);
9830 }
9831 tmpCtx.translate(-(dimx.scale * adjustedX0), -(dimy.scale * adjustedY0));
9832 graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
9833 tmpCtx.save();
9834 this.clipBbox(graphics, adjustedX0, adjustedY0, adjustedX1, adjustedY1);
9835 graphics.baseTransform = (0,display_utils.getCurrentTransform)(graphics.ctx);
9836 graphics.executeOperatorList(operatorList);
9837 graphics.endDrawing();
9838 return {
9839 canvas: tmpCanvas.canvas,
9840 scaleX: dimx.scale,
9841 scaleY: dimy.scale,
9842 offsetX: adjustedX0,
9843 offsetY: adjustedY0
9844 };
9845 }
9846 getSizeAndScale(step, realOutputSize, scale) {
9847 step = Math.abs(step);
9848 const maxSize = Math.max(TilingPattern.MAX_PATTERN_SIZE, realOutputSize);
9849 let size = Math.ceil(step * scale);
9850 if (size >= maxSize) {
9851 size = maxSize;
9852 } else {
9853 scale = size / step;
9854 }
9855 return {
9856 scale,
9857 size
9858 };
9859 }
9860 clipBbox(graphics, x0, y0, x1, y1) {
9861 const bboxWidth = x1 - x0;
9862 const bboxHeight = y1 - y0;
9863 graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
9864 graphics.current.updateRectMinMax((0,display_utils.getCurrentTransform)(graphics.ctx), [x0, y0, x1, y1]);
9865 graphics.clip();
9866 graphics.endPath();
9867 }
9868 setFillAndStrokeStyleToContext(graphics, paintType, color) {
9869 const context = graphics.ctx,
9870 current = graphics.current;
9871 switch (paintType) {
9872 case PaintType.COLORED:
9873 const ctx = this.ctx;
9874 context.fillStyle = ctx.fillStyle;
9875 context.strokeStyle = ctx.strokeStyle;
9876 current.fillColor = ctx.fillStyle;
9877 current.strokeColor = ctx.strokeStyle;
9878 break;
9879 case PaintType.UNCOLORED:
9880 const cssColor = util.Util.makeHexColor(color[0], color[1], color[2]);
9881 context.fillStyle = cssColor;
9882 context.strokeStyle = cssColor;
9883 current.fillColor = cssColor;
9884 current.strokeColor = cssColor;
9885 break;
9886 default:
9887 throw new util.FormatError(`Unsupported paint type: ${paintType}`);
9888 }
9889 }
9890 getPattern(ctx, owner, inverse, pathType) {
9891 let matrix = inverse;
9892 if (pathType !== PathType.SHADING) {
9893 matrix = util.Util.transform(matrix, owner.baseTransform);
9894 if (this.matrix) {
9895 matrix = util.Util.transform(matrix, this.matrix);
9896 }
9897 }
9898 const temporaryPatternCanvas = this.createPatternCanvas(owner);
9899 let domMatrix = new DOMMatrix(matrix);
9900 domMatrix = domMatrix.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
9901 domMatrix = domMatrix.scale(1 / temporaryPatternCanvas.scaleX, 1 / temporaryPatternCanvas.scaleY);
9902 const pattern = ctx.createPattern(temporaryPatternCanvas.canvas, "repeat");
9903 pattern.setTransform(domMatrix);
9904 return pattern;
9905 }
9906}
9907
9908;// CONCATENATED MODULE: ./src/shared/image_utils.js
9909
9910
9911
9912
9913
9914
9915
9916function convertToRGBA(params) {
9917 switch (params.kind) {
9918 case ImageKind.GRAYSCALE_1BPP:
9919 return convertBlackAndWhiteToRGBA(params);
9920 case ImageKind.RGB_24BPP:
9921 return convertRGBToRGBA(params);
9922 }
9923 return null;
9924}
9925function convertBlackAndWhiteToRGBA(_ref) {
9926 let {
9927 src,
9928 srcPos = 0,
9929 dest,
9930 width,
9931 height,
9932 nonBlackColor = 0xffffffff,
9933 inverseDecode = false
9934 } = _ref;
9935 const black = util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
9936 const [zeroMapping, oneMapping] = inverseDecode ? [nonBlackColor, black] : [black, nonBlackColor];
9937 const widthInSource = width >> 3;
9938 const widthRemainder = width & 7;
9939 const srcLength = src.length;
9940 dest = new Uint32Array(dest.buffer);
9941 let destPos = 0;
9942 for (let i = 0; i < height; i++) {
9943 for (const max = srcPos + widthInSource; srcPos < max; srcPos++) {
9944 const elem = srcPos < srcLength ? src[srcPos] : 255;
9945 dest[destPos++] = elem & 0b10000000 ? oneMapping : zeroMapping;
9946 dest[destPos++] = elem & 0b1000000 ? oneMapping : zeroMapping;
9947 dest[destPos++] = elem & 0b100000 ? oneMapping : zeroMapping;
9948 dest[destPos++] = elem & 0b10000 ? oneMapping : zeroMapping;
9949 dest[destPos++] = elem & 0b1000 ? oneMapping : zeroMapping;
9950 dest[destPos++] = elem & 0b100 ? oneMapping : zeroMapping;
9951 dest[destPos++] = elem & 0b10 ? oneMapping : zeroMapping;
9952 dest[destPos++] = elem & 0b1 ? oneMapping : zeroMapping;
9953 }
9954 if (widthRemainder === 0) {
9955 continue;
9956 }
9957 const elem = srcPos < srcLength ? src[srcPos++] : 255;
9958 for (let j = 0; j < widthRemainder; j++) {
9959 dest[destPos++] = elem & 1 << 7 - j ? oneMapping : zeroMapping;
9960 }
9961 }
9962 return {
9963 srcPos,
9964 destPos
9965 };
9966}
9967function convertRGBToRGBA(_ref2) {
9968 let {
9969 src,
9970 srcPos = 0,
9971 dest,
9972 destPos = 0,
9973 width,
9974 height
9975 } = _ref2;
9976 let i = 0;
9977 const len32 = src.length >> 2;
9978 const src32 = new Uint32Array(src.buffer, srcPos, len32);
9979 if (FeatureTest.isLittleEndian) {
9980 for (; i < len32 - 2; i += 3, destPos += 4) {
9981 const s1 = src32[i];
9982 const s2 = src32[i + 1];
9983 const s3 = src32[i + 2];
9984 dest[destPos] = s1 | 0xff000000;
9985 dest[destPos + 1] = s1 >>> 24 | s2 << 8 | 0xff000000;
9986 dest[destPos + 2] = s2 >>> 16 | s3 << 16 | 0xff000000;
9987 dest[destPos + 3] = s3 >>> 8 | 0xff000000;
9988 }
9989 for (let j = i * 4, jj = src.length; j < jj; j += 3) {
9990 dest[destPos++] = src[j] | src[j + 1] << 8 | src[j + 2] << 16 | 0xff000000;
9991 }
9992 } else {
9993 for (; i < len32 - 2; i += 3, destPos += 4) {
9994 const s1 = src32[i];
9995 const s2 = src32[i + 1];
9996 const s3 = src32[i + 2];
9997 dest[destPos] = s1 | 0xff;
9998 dest[destPos + 1] = s1 << 24 | s2 >>> 8 | 0xff;
9999 dest[destPos + 2] = s2 << 16 | s3 >>> 16 | 0xff;
10000 dest[destPos + 3] = s3 << 8 | 0xff;
10001 }
10002 for (let j = i * 4, jj = src.length; j < jj; j += 3) {
10003 dest[destPos++] = src[j] << 24 | src[j + 1] << 16 | src[j + 2] << 8 | 0xff;
10004 }
10005 }
10006 return {
10007 srcPos,
10008 destPos
10009 };
10010}
10011function grayToRGBA(src, dest) {
10012 if (FeatureTest.isLittleEndian) {
10013 for (let i = 0, ii = src.length; i < ii; i++) {
10014 dest[i] = src[i] * 0x10101 | 0xff000000;
10015 }
10016 } else {
10017 for (let i = 0, ii = src.length; i < ii; i++) {
10018 dest[i] = src[i] * 0x1010100 | 0x000000ff;
10019 }
10020 }
10021}
10022
10023;// CONCATENATED MODULE: ./src/display/canvas.js
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038const MIN_FONT_SIZE = 16;
10039const MAX_FONT_SIZE = 100;
10040const MAX_GROUP_SIZE = 4096;
10041const EXECUTION_TIME = 15;
10042const EXECUTION_STEPS = 10;
10043const MAX_SIZE_TO_COMPILE = 1000;
10044const FULL_CHUNK_HEIGHT = 16;
10045function mirrorContextOperations(ctx, destCtx) {
10046 if (ctx._removeMirroring) {
10047 throw new Error("Context is already forwarding operations.");
10048 }
10049 ctx.__originalSave = ctx.save;
10050 ctx.__originalRestore = ctx.restore;
10051 ctx.__originalRotate = ctx.rotate;
10052 ctx.__originalScale = ctx.scale;
10053 ctx.__originalTranslate = ctx.translate;
10054 ctx.__originalTransform = ctx.transform;
10055 ctx.__originalSetTransform = ctx.setTransform;
10056 ctx.__originalResetTransform = ctx.resetTransform;
10057 ctx.__originalClip = ctx.clip;
10058 ctx.__originalMoveTo = ctx.moveTo;
10059 ctx.__originalLineTo = ctx.lineTo;
10060 ctx.__originalBezierCurveTo = ctx.bezierCurveTo;
10061 ctx.__originalRect = ctx.rect;
10062 ctx.__originalClosePath = ctx.closePath;
10063 ctx.__originalBeginPath = ctx.beginPath;
10064 ctx._removeMirroring = () => {
10065 ctx.save = ctx.__originalSave;
10066 ctx.restore = ctx.__originalRestore;
10067 ctx.rotate = ctx.__originalRotate;
10068 ctx.scale = ctx.__originalScale;
10069 ctx.translate = ctx.__originalTranslate;
10070 ctx.transform = ctx.__originalTransform;
10071 ctx.setTransform = ctx.__originalSetTransform;
10072 ctx.resetTransform = ctx.__originalResetTransform;
10073 ctx.clip = ctx.__originalClip;
10074 ctx.moveTo = ctx.__originalMoveTo;
10075 ctx.lineTo = ctx.__originalLineTo;
10076 ctx.bezierCurveTo = ctx.__originalBezierCurveTo;
10077 ctx.rect = ctx.__originalRect;
10078 ctx.closePath = ctx.__originalClosePath;
10079 ctx.beginPath = ctx.__originalBeginPath;
10080 delete ctx._removeMirroring;
10081 };
10082 ctx.save = function ctxSave() {
10083 destCtx.save();
10084 this.__originalSave();
10085 };
10086 ctx.restore = function ctxRestore() {
10087 destCtx.restore();
10088 this.__originalRestore();
10089 };
10090 ctx.translate = function ctxTranslate(x, y) {
10091 destCtx.translate(x, y);
10092 this.__originalTranslate(x, y);
10093 };
10094 ctx.scale = function ctxScale(x, y) {
10095 destCtx.scale(x, y);
10096 this.__originalScale(x, y);
10097 };
10098 ctx.transform = function ctxTransform(a, b, c, d, e, f) {
10099 destCtx.transform(a, b, c, d, e, f);
10100 this.__originalTransform(a, b, c, d, e, f);
10101 };
10102 ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
10103 destCtx.setTransform(a, b, c, d, e, f);
10104 this.__originalSetTransform(a, b, c, d, e, f);
10105 };
10106 ctx.resetTransform = function ctxResetTransform() {
10107 destCtx.resetTransform();
10108 this.__originalResetTransform();
10109 };
10110 ctx.rotate = function ctxRotate(angle) {
10111 destCtx.rotate(angle);
10112 this.__originalRotate(angle);
10113 };
10114 ctx.clip = function ctxRotate(rule) {
10115 destCtx.clip(rule);
10116 this.__originalClip(rule);
10117 };
10118 ctx.moveTo = function (x, y) {
10119 destCtx.moveTo(x, y);
10120 this.__originalMoveTo(x, y);
10121 };
10122 ctx.lineTo = function (x, y) {
10123 destCtx.lineTo(x, y);
10124 this.__originalLineTo(x, y);
10125 };
10126 ctx.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
10127 destCtx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
10128 this.__originalBezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
10129 };
10130 ctx.rect = function (x, y, width, height) {
10131 destCtx.rect(x, y, width, height);
10132 this.__originalRect(x, y, width, height);
10133 };
10134 ctx.closePath = function () {
10135 destCtx.closePath();
10136 this.__originalClosePath();
10137 };
10138 ctx.beginPath = function () {
10139 destCtx.beginPath();
10140 this.__originalBeginPath();
10141 };
10142}
10143class CachedCanvases {
10144 constructor(canvasFactory) {
10145 this.canvasFactory = canvasFactory;
10146 this.cache = Object.create(null);
10147 }
10148 getCanvas(id, width, height) {
10149 let canvasEntry;
10150 if (this.cache[id] !== undefined) {
10151 canvasEntry = this.cache[id];
10152 this.canvasFactory.reset(canvasEntry, width, height);
10153 } else {
10154 canvasEntry = this.canvasFactory.create(width, height);
10155 this.cache[id] = canvasEntry;
10156 }
10157 return canvasEntry;
10158 }
10159 delete(id) {
10160 delete this.cache[id];
10161 }
10162 clear() {
10163 for (const id in this.cache) {
10164 const canvasEntry = this.cache[id];
10165 this.canvasFactory.destroy(canvasEntry);
10166 delete this.cache[id];
10167 }
10168 }
10169}
10170function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
10171 const [a, b, c, d, tx, ty] = (0,display_utils.getCurrentTransform)(ctx);
10172 if (b === 0 && c === 0) {
10173 const tlX = destX * a + tx;
10174 const rTlX = Math.round(tlX);
10175 const tlY = destY * d + ty;
10176 const rTlY = Math.round(tlY);
10177 const brX = (destX + destW) * a + tx;
10178 const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
10179 const brY = (destY + destH) * d + ty;
10180 const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
10181 ctx.setTransform(Math.sign(a), 0, 0, Math.sign(d), rTlX, rTlY);
10182 ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rWidth, rHeight);
10183 ctx.setTransform(a, b, c, d, tx, ty);
10184 return [rWidth, rHeight];
10185 }
10186 if (a === 0 && d === 0) {
10187 const tlX = destY * c + tx;
10188 const rTlX = Math.round(tlX);
10189 const tlY = destX * b + ty;
10190 const rTlY = Math.round(tlY);
10191 const brX = (destY + destH) * c + tx;
10192 const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
10193 const brY = (destX + destW) * b + ty;
10194 const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
10195 ctx.setTransform(0, Math.sign(b), Math.sign(c), 0, rTlX, rTlY);
10196 ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rHeight, rWidth);
10197 ctx.setTransform(a, b, c, d, tx, ty);
10198 return [rHeight, rWidth];
10199 }
10200 ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH);
10201 const scaleX = Math.hypot(a, b);
10202 const scaleY = Math.hypot(c, d);
10203 return [scaleX * destW, scaleY * destH];
10204}
10205function compileType3Glyph(imgData) {
10206 const {
10207 width,
10208 height
10209 } = imgData;
10210 if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
10211 return null;
10212 }
10213 const POINT_TO_PROCESS_LIMIT = 1000;
10214 const POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
10215 const width1 = width + 1;
10216 let points = new Uint8Array(width1 * (height + 1));
10217 let i, j, j0;
10218 const lineSize = width + 7 & ~7;
10219 let data = new Uint8Array(lineSize * height),
10220 pos = 0;
10221 for (const elem of imgData.data) {
10222 let mask = 128;
10223 while (mask > 0) {
10224 data[pos++] = elem & mask ? 0 : 255;
10225 mask >>= 1;
10226 }
10227 }
10228 let count = 0;
10229 pos = 0;
10230 if (data[pos] !== 0) {
10231 points[0] = 1;
10232 ++count;
10233 }
10234 for (j = 1; j < width; j++) {
10235 if (data[pos] !== data[pos + 1]) {
10236 points[j] = data[pos] ? 2 : 1;
10237 ++count;
10238 }
10239 pos++;
10240 }
10241 if (data[pos] !== 0) {
10242 points[j] = 2;
10243 ++count;
10244 }
10245 for (i = 1; i < height; i++) {
10246 pos = i * lineSize;
10247 j0 = i * width1;
10248 if (data[pos - lineSize] !== data[pos]) {
10249 points[j0] = data[pos] ? 1 : 8;
10250 ++count;
10251 }
10252 let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
10253 for (j = 1; j < width; j++) {
10254 sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
10255 if (POINT_TYPES[sum]) {
10256 points[j0 + j] = POINT_TYPES[sum];
10257 ++count;
10258 }
10259 pos++;
10260 }
10261 if (data[pos - lineSize] !== data[pos]) {
10262 points[j0 + j] = data[pos] ? 2 : 4;
10263 ++count;
10264 }
10265 if (count > POINT_TO_PROCESS_LIMIT) {
10266 return null;
10267 }
10268 }
10269 pos = lineSize * (height - 1);
10270 j0 = i * width1;
10271 if (data[pos] !== 0) {
10272 points[j0] = 8;
10273 ++count;
10274 }
10275 for (j = 1; j < width; j++) {
10276 if (data[pos] !== data[pos + 1]) {
10277 points[j0 + j] = data[pos] ? 4 : 8;
10278 ++count;
10279 }
10280 pos++;
10281 }
10282 if (data[pos] !== 0) {
10283 points[j0 + j] = 4;
10284 ++count;
10285 }
10286 if (count > POINT_TO_PROCESS_LIMIT) {
10287 return null;
10288 }
10289 const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
10290 const path = new Path2D();
10291 for (i = 0; count && i <= height; i++) {
10292 let p = i * width1;
10293 const end = p + width;
10294 while (p < end && !points[p]) {
10295 p++;
10296 }
10297 if (p === end) {
10298 continue;
10299 }
10300 path.moveTo(p % width1, i);
10301 const p0 = p;
10302 let type = points[p];
10303 do {
10304 const step = steps[type];
10305 do {
10306 p += step;
10307 } while (!points[p]);
10308 const pp = points[p];
10309 if (pp !== 5 && pp !== 10) {
10310 type = pp;
10311 points[p] = 0;
10312 } else {
10313 type = pp & 0x33 * type >> 4;
10314 points[p] &= type >> 2 | type << 2;
10315 }
10316 path.lineTo(p % width1, p / width1 | 0);
10317 if (!points[p]) {
10318 --count;
10319 }
10320 } while (p0 !== p);
10321 --i;
10322 }
10323 data = null;
10324 points = null;
10325 const drawOutline = function (c) {
10326 c.save();
10327 c.scale(1 / width, -1 / height);
10328 c.translate(0, -height);
10329 c.fill(path);
10330 c.beginPath();
10331 c.restore();
10332 };
10333 return drawOutline;
10334}
10335class CanvasExtraState {
10336 constructor(width, height) {
10337 this.alphaIsShape = false;
10338 this.fontSize = 0;
10339 this.fontSizeScale = 1;
10340 this.textMatrix = util.IDENTITY_MATRIX;
10341 this.textMatrixScale = 1;
10342 this.fontMatrix = util.FONT_IDENTITY_MATRIX;
10343 this.leading = 0;
10344 this.x = 0;
10345 this.y = 0;
10346 this.lineX = 0;
10347 this.lineY = 0;
10348 this.charSpacing = 0;
10349 this.wordSpacing = 0;
10350 this.textHScale = 1;
10351 this.textRenderingMode = util.TextRenderingMode.FILL;
10352 this.textRise = 0;
10353 this.fillColor = "#000000";
10354 this.strokeColor = "#000000";
10355 this.patternFill = false;
10356 this.fillAlpha = 1;
10357 this.strokeAlpha = 1;
10358 this.lineWidth = 1;
10359 this.activeSMask = null;
10360 this.transferMaps = "none";
10361 this.startNewPathAndClipBox([0, 0, width, height]);
10362 }
10363 clone() {
10364 const clone = Object.create(this);
10365 clone.clipBox = this.clipBox.slice();
10366 return clone;
10367 }
10368 setCurrentPoint(x, y) {
10369 this.x = x;
10370 this.y = y;
10371 }
10372 updatePathMinMax(transform, x, y) {
10373 [x, y] = util.Util.applyTransform([x, y], transform);
10374 this.minX = Math.min(this.minX, x);
10375 this.minY = Math.min(this.minY, y);
10376 this.maxX = Math.max(this.maxX, x);
10377 this.maxY = Math.max(this.maxY, y);
10378 }
10379 updateRectMinMax(transform, rect) {
10380 const p1 = util.Util.applyTransform(rect, transform);
10381 const p2 = util.Util.applyTransform(rect.slice(2), transform);
10382 const p3 = util.Util.applyTransform([rect[0], rect[3]], transform);
10383 const p4 = util.Util.applyTransform([rect[2], rect[1]], transform);
10384 this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]);
10385 this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]);
10386 this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]);
10387 this.maxY = Math.max(this.maxY, p1[1], p2[1], p3[1], p4[1]);
10388 }
10389 updateScalingPathMinMax(transform, minMax) {
10390 util.Util.scaleMinMax(transform, minMax);
10391 this.minX = Math.min(this.minX, minMax[0]);
10392 this.minY = Math.min(this.minY, minMax[1]);
10393 this.maxX = Math.max(this.maxX, minMax[2]);
10394 this.maxY = Math.max(this.maxY, minMax[3]);
10395 }
10396 updateCurvePathMinMax(transform, x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
10397 const box = util.Util.bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax);
10398 if (minMax) {
10399 return;
10400 }
10401 this.updateRectMinMax(transform, box);
10402 }
10403 getPathBoundingBox() {
10404 let pathType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PathType.FILL;
10405 let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
10406 const box = [this.minX, this.minY, this.maxX, this.maxY];
10407 if (pathType === PathType.STROKE) {
10408 if (!transform) {
10409 (0,util.unreachable)("Stroke bounding box must include transform.");
10410 }
10411 const scale = util.Util.singularValueDecompose2dScale(transform);
10412 const xStrokePad = scale[0] * this.lineWidth / 2;
10413 const yStrokePad = scale[1] * this.lineWidth / 2;
10414 box[0] -= xStrokePad;
10415 box[1] -= yStrokePad;
10416 box[2] += xStrokePad;
10417 box[3] += yStrokePad;
10418 }
10419 return box;
10420 }
10421 updateClipFromPath() {
10422 const intersect = util.Util.intersect(this.clipBox, this.getPathBoundingBox());
10423 this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
10424 }
10425 isEmptyClip() {
10426 return this.minX === Infinity;
10427 }
10428 startNewPathAndClipBox(box) {
10429 this.clipBox = box;
10430 this.minX = Infinity;
10431 this.minY = Infinity;
10432 this.maxX = 0;
10433 this.maxY = 0;
10434 }
10435 getClippedPathBoundingBox() {
10436 let pathType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PathType.FILL;
10437 let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
10438 return util.Util.intersect(this.clipBox, this.getPathBoundingBox(pathType, transform));
10439 }
10440}
10441function putBinaryImageData(ctx, imgData) {
10442 if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
10443 ctx.putImageData(imgData, 0, 0);
10444 return;
10445 }
10446 const height = imgData.height,
10447 width = imgData.width;
10448 const partialChunkHeight = height % FULL_CHUNK_HEIGHT;
10449 const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
10450 const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
10451 const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
10452 let srcPos = 0,
10453 destPos;
10454 const src = imgData.data;
10455 const dest = chunkImgData.data;
10456 let i, j, thisChunkHeight, elemsInThisChunk;
10457 if (imgData.kind === util.ImageKind.GRAYSCALE_1BPP) {
10458 const srcLength = src.byteLength;
10459 const dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
10460 const dest32DataLength = dest32.length;
10461 const fullSrcDiff = width + 7 >> 3;
10462 const white = 0xffffffff;
10463 const black = util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
10464 for (i = 0; i < totalChunks; i++) {
10465 thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
10466 destPos = 0;
10467 for (j = 0; j < thisChunkHeight; j++) {
10468 const srcDiff = srcLength - srcPos;
10469 let k = 0;
10470 const kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
10471 const kEndUnrolled = kEnd & ~7;
10472 let mask = 0;
10473 let srcByte = 0;
10474 for (; k < kEndUnrolled; k += 8) {
10475 srcByte = src[srcPos++];
10476 dest32[destPos++] = srcByte & 128 ? white : black;
10477 dest32[destPos++] = srcByte & 64 ? white : black;
10478 dest32[destPos++] = srcByte & 32 ? white : black;
10479 dest32[destPos++] = srcByte & 16 ? white : black;
10480 dest32[destPos++] = srcByte & 8 ? white : black;
10481 dest32[destPos++] = srcByte & 4 ? white : black;
10482 dest32[destPos++] = srcByte & 2 ? white : black;
10483 dest32[destPos++] = srcByte & 1 ? white : black;
10484 }
10485 for (; k < kEnd; k++) {
10486 if (mask === 0) {
10487 srcByte = src[srcPos++];
10488 mask = 128;
10489 }
10490 dest32[destPos++] = srcByte & mask ? white : black;
10491 mask >>= 1;
10492 }
10493 }
10494 while (destPos < dest32DataLength) {
10495 dest32[destPos++] = 0;
10496 }
10497 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
10498 }
10499 } else if (imgData.kind === util.ImageKind.RGBA_32BPP) {
10500 j = 0;
10501 elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
10502 for (i = 0; i < fullChunks; i++) {
10503 dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
10504 srcPos += elemsInThisChunk;
10505 ctx.putImageData(chunkImgData, 0, j);
10506 j += FULL_CHUNK_HEIGHT;
10507 }
10508 if (i < totalChunks) {
10509 elemsInThisChunk = width * partialChunkHeight * 4;
10510 dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
10511 ctx.putImageData(chunkImgData, 0, j);
10512 }
10513 } else if (imgData.kind === util.ImageKind.RGB_24BPP) {
10514 thisChunkHeight = FULL_CHUNK_HEIGHT;
10515 elemsInThisChunk = width * thisChunkHeight;
10516 for (i = 0; i < totalChunks; i++) {
10517 if (i >= fullChunks) {
10518 thisChunkHeight = partialChunkHeight;
10519 elemsInThisChunk = width * thisChunkHeight;
10520 }
10521 destPos = 0;
10522 for (j = elemsInThisChunk; j--;) {
10523 dest[destPos++] = src[srcPos++];
10524 dest[destPos++] = src[srcPos++];
10525 dest[destPos++] = src[srcPos++];
10526 dest[destPos++] = 255;
10527 }
10528 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
10529 }
10530 } else {
10531 throw new Error(`bad image kind: ${imgData.kind}`);
10532 }
10533}
10534function putBinaryImageMask(ctx, imgData) {
10535 if (imgData.bitmap) {
10536 ctx.drawImage(imgData.bitmap, 0, 0);
10537 return;
10538 }
10539 const height = imgData.height,
10540 width = imgData.width;
10541 const partialChunkHeight = height % FULL_CHUNK_HEIGHT;
10542 const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
10543 const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
10544 const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
10545 let srcPos = 0;
10546 const src = imgData.data;
10547 const dest = chunkImgData.data;
10548 for (let i = 0; i < totalChunks; i++) {
10549 const thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
10550 ({
10551 srcPos
10552 } = convertBlackAndWhiteToRGBA({
10553 src,
10554 srcPos,
10555 dest,
10556 width,
10557 height: thisChunkHeight,
10558 nonBlackColor: 0
10559 }));
10560 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
10561 }
10562}
10563function copyCtxState(sourceCtx, destCtx) {
10564 const properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font", "filter"];
10565 for (const property of properties) {
10566 if (sourceCtx[property] !== undefined) {
10567 destCtx[property] = sourceCtx[property];
10568 }
10569 }
10570 if (sourceCtx.setLineDash !== undefined) {
10571 destCtx.setLineDash(sourceCtx.getLineDash());
10572 destCtx.lineDashOffset = sourceCtx.lineDashOffset;
10573 }
10574}
10575function resetCtxToDefault(ctx) {
10576 ctx.strokeStyle = ctx.fillStyle = "#000000";
10577 ctx.fillRule = "nonzero";
10578 ctx.globalAlpha = 1;
10579 ctx.lineWidth = 1;
10580 ctx.lineCap = "butt";
10581 ctx.lineJoin = "miter";
10582 ctx.miterLimit = 10;
10583 ctx.globalCompositeOperation = "source-over";
10584 ctx.font = "10px sans-serif";
10585 if (ctx.setLineDash !== undefined) {
10586 ctx.setLineDash([]);
10587 ctx.lineDashOffset = 0;
10588 }
10589 if (!util.isNodeJS) {
10590 const {
10591 filter
10592 } = ctx;
10593 if (filter !== "none" && filter !== "") {
10594 ctx.filter = "none";
10595 }
10596 }
10597}
10598function composeSMaskBackdrop(bytes, r0, g0, b0) {
10599 const length = bytes.length;
10600 for (let i = 3; i < length; i += 4) {
10601 const alpha = bytes[i];
10602 if (alpha === 0) {
10603 bytes[i - 3] = r0;
10604 bytes[i - 2] = g0;
10605 bytes[i - 1] = b0;
10606 } else if (alpha < 255) {
10607 const alpha_ = 255 - alpha;
10608 bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
10609 bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
10610 bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
10611 }
10612 }
10613}
10614function composeSMaskAlpha(maskData, layerData, transferMap) {
10615 const length = maskData.length;
10616 const scale = 1 / 255;
10617 for (let i = 3; i < length; i += 4) {
10618 const alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
10619 layerData[i] = layerData[i] * alpha * scale | 0;
10620 }
10621}
10622function composeSMaskLuminosity(maskData, layerData, transferMap) {
10623 const length = maskData.length;
10624 for (let i = 3; i < length; i += 4) {
10625 const y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
10626 layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
10627 }
10628}
10629function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap, layerOffsetX, layerOffsetY, maskOffsetX, maskOffsetY) {
10630 const hasBackdrop = !!backdrop;
10631 const r0 = hasBackdrop ? backdrop[0] : 0;
10632 const g0 = hasBackdrop ? backdrop[1] : 0;
10633 const b0 = hasBackdrop ? backdrop[2] : 0;
10634 const composeFn = subtype === "Luminosity" ? composeSMaskLuminosity : composeSMaskAlpha;
10635 const PIXELS_TO_PROCESS = 1048576;
10636 const chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
10637 for (let row = 0; row < height; row += chunkSize) {
10638 const chunkHeight = Math.min(chunkSize, height - row);
10639 const maskData = maskCtx.getImageData(layerOffsetX - maskOffsetX, row + (layerOffsetY - maskOffsetY), width, chunkHeight);
10640 const layerData = layerCtx.getImageData(layerOffsetX, row + layerOffsetY, width, chunkHeight);
10641 if (hasBackdrop) {
10642 composeSMaskBackdrop(maskData.data, r0, g0, b0);
10643 }
10644 composeFn(maskData.data, layerData.data, transferMap);
10645 layerCtx.putImageData(layerData, layerOffsetX, row + layerOffsetY);
10646 }
10647}
10648function composeSMask(ctx, smask, layerCtx, layerBox) {
10649 const layerOffsetX = layerBox[0];
10650 const layerOffsetY = layerBox[1];
10651 const layerWidth = layerBox[2] - layerOffsetX;
10652 const layerHeight = layerBox[3] - layerOffsetY;
10653 if (layerWidth === 0 || layerHeight === 0) {
10654 return;
10655 }
10656 genericComposeSMask(smask.context, layerCtx, layerWidth, layerHeight, smask.subtype, smask.backdrop, smask.transferMap, layerOffsetX, layerOffsetY, smask.offsetX, smask.offsetY);
10657 ctx.save();
10658 ctx.globalAlpha = 1;
10659 ctx.globalCompositeOperation = "source-over";
10660 ctx.setTransform(1, 0, 0, 1, 0, 0);
10661 ctx.drawImage(layerCtx.canvas, 0, 0);
10662 ctx.restore();
10663}
10664function getImageSmoothingEnabled(transform, interpolate) {
10665 const scale = util.Util.singularValueDecompose2dScale(transform);
10666 scale[0] = Math.fround(scale[0]);
10667 scale[1] = Math.fround(scale[1]);
10668 const actualScale = Math.fround((globalThis.devicePixelRatio || 1) * display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
10669 if (interpolate !== undefined) {
10670 return interpolate;
10671 } else if (scale[0] <= actualScale || scale[1] <= actualScale) {
10672 return true;
10673 }
10674 return false;
10675}
10676const LINE_CAP_STYLES = ["butt", "round", "square"];
10677const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
10678const NORMAL_CLIP = {};
10679const EO_CLIP = {};
10680class CanvasGraphics {
10681 constructor(canvasCtx, commonObjs, objs, canvasFactory, filterFactory, _ref, annotationCanvasMap, pageColors) {
10682 let {
10683 optionalContentConfig,
10684 markedContentStack = null
10685 } = _ref;
10686 this.ctx = canvasCtx;
10687 this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
10688 this.stateStack = [];
10689 this.pendingClip = null;
10690 this.pendingEOFill = false;
10691 this.res = null;
10692 this.xobjs = null;
10693 this.commonObjs = commonObjs;
10694 this.objs = objs;
10695 this.canvasFactory = canvasFactory;
10696 this.filterFactory = filterFactory;
10697 this.groupStack = [];
10698 this.processingType3 = null;
10699 this.baseTransform = null;
10700 this.baseTransformStack = [];
10701 this.groupLevel = 0;
10702 this.smaskStack = [];
10703 this.smaskCounter = 0;
10704 this.tempSMask = null;
10705 this.suspendedCtx = null;
10706 this.contentVisible = true;
10707 this.markedContentStack = markedContentStack || [];
10708 this.optionalContentConfig = optionalContentConfig;
10709 this.cachedCanvases = new CachedCanvases(this.canvasFactory);
10710 this.cachedPatterns = new Map();
10711 this.annotationCanvasMap = annotationCanvasMap;
10712 this.viewportScale = 1;
10713 this.outputScaleX = 1;
10714 this.outputScaleY = 1;
10715 this.pageColors = pageColors;
10716 this._cachedScaleForStroking = [-1, 0];
10717 this._cachedGetSinglePixelWidth = null;
10718 this._cachedBitmapsMap = new Map();
10719 }
10720 getObject(data) {
10721 let fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
10722 if (typeof data === "string") {
10723 return data.startsWith("g_") ? this.commonObjs.get(data) : this.objs.get(data);
10724 }
10725 return fallback;
10726 }
10727 beginDrawing(_ref2) {
10728 let {
10729 transform,
10730 viewport,
10731 transparency = false,
10732 background = null
10733 } = _ref2;
10734 const width = this.ctx.canvas.width;
10735 const height = this.ctx.canvas.height;
10736 const savedFillStyle = this.ctx.fillStyle;
10737 this.ctx.fillStyle = background || "#ffffff";
10738 this.ctx.fillRect(0, 0, width, height);
10739 this.ctx.fillStyle = savedFillStyle;
10740 if (transparency) {
10741 const transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height);
10742 this.compositeCtx = this.ctx;
10743 this.transparentCanvas = transparentCanvas.canvas;
10744 this.ctx = transparentCanvas.context;
10745 this.ctx.save();
10746 this.ctx.transform(...(0,display_utils.getCurrentTransform)(this.compositeCtx));
10747 }
10748 this.ctx.save();
10749 resetCtxToDefault(this.ctx);
10750 if (transform) {
10751 this.ctx.transform(...transform);
10752 this.outputScaleX = transform[0];
10753 this.outputScaleY = transform[0];
10754 }
10755 this.ctx.transform(...viewport.transform);
10756 this.viewportScale = viewport.scale;
10757 this.baseTransform = (0,display_utils.getCurrentTransform)(this.ctx);
10758 }
10759 executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
10760 const argsArray = operatorList.argsArray;
10761 const fnArray = operatorList.fnArray;
10762 let i = executionStartIdx || 0;
10763 const argsArrayLen = argsArray.length;
10764 if (argsArrayLen === i) {
10765 return i;
10766 }
10767 const chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
10768 const endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
10769 let steps = 0;
10770 const commonObjs = this.commonObjs;
10771 const objs = this.objs;
10772 let fnId;
10773 while (true) {
10774 if (stepper !== undefined && i === stepper.nextBreakPoint) {
10775 stepper.breakIt(i, continueCallback);
10776 return i;
10777 }
10778 fnId = fnArray[i];
10779 if (fnId !== util.OPS.dependency) {
10780 this[fnId].apply(this, argsArray[i]);
10781 } else {
10782 for (const depObjId of argsArray[i]) {
10783 const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
10784 if (!objsPool.has(depObjId)) {
10785 objsPool.get(depObjId, continueCallback);
10786 return i;
10787 }
10788 }
10789 }
10790 i++;
10791 if (i === argsArrayLen) {
10792 return i;
10793 }
10794 if (chunkOperations && ++steps > EXECUTION_STEPS) {
10795 if (Date.now() > endTime) {
10796 continueCallback();
10797 return i;
10798 }
10799 steps = 0;
10800 }
10801 }
10802 }
10803 #restoreInitialState() {
10804 while (this.stateStack.length || this.inSMaskMode) {
10805 this.restore();
10806 }
10807 this.ctx.restore();
10808 if (this.transparentCanvas) {
10809 this.ctx = this.compositeCtx;
10810 this.ctx.save();
10811 this.ctx.setTransform(1, 0, 0, 1, 0, 0);
10812 this.ctx.drawImage(this.transparentCanvas, 0, 0);
10813 this.ctx.restore();
10814 this.transparentCanvas = null;
10815 }
10816 }
10817 endDrawing() {
10818 this.#restoreInitialState();
10819 this.cachedCanvases.clear();
10820 this.cachedPatterns.clear();
10821 for (const cache of this._cachedBitmapsMap.values()) {
10822 for (const canvas of cache.values()) {
10823 if (typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement) {
10824 canvas.width = canvas.height = 0;
10825 }
10826 }
10827 cache.clear();
10828 }
10829 this._cachedBitmapsMap.clear();
10830 this.#drawFilter();
10831 }
10832 #drawFilter() {
10833 if (this.pageColors) {
10834 const hcmFilterId = this.filterFactory.addHCMFilter(this.pageColors.foreground, this.pageColors.background);
10835 if (hcmFilterId !== "none") {
10836 const savedFilter = this.ctx.filter;
10837 this.ctx.filter = hcmFilterId;
10838 this.ctx.drawImage(this.ctx.canvas, 0, 0);
10839 this.ctx.filter = savedFilter;
10840 }
10841 }
10842 }
10843 _scaleImage(img, inverseTransform) {
10844 const width = img.width;
10845 const height = img.height;
10846 let widthScale = Math.max(Math.hypot(inverseTransform[0], inverseTransform[1]), 1);
10847 let heightScale = Math.max(Math.hypot(inverseTransform[2], inverseTransform[3]), 1);
10848 let paintWidth = width,
10849 paintHeight = height;
10850 let tmpCanvasId = "prescale1";
10851 let tmpCanvas, tmpCtx;
10852 while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
10853 let newWidth = paintWidth,
10854 newHeight = paintHeight;
10855 if (widthScale > 2 && paintWidth > 1) {
10856 newWidth = paintWidth >= 16384 ? Math.floor(paintWidth / 2) - 1 || 1 : Math.ceil(paintWidth / 2);
10857 widthScale /= paintWidth / newWidth;
10858 }
10859 if (heightScale > 2 && paintHeight > 1) {
10860 newHeight = paintHeight >= 16384 ? Math.floor(paintHeight / 2) - 1 || 1 : Math.ceil(paintHeight) / 2;
10861 heightScale /= paintHeight / newHeight;
10862 }
10863 tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
10864 tmpCtx = tmpCanvas.context;
10865 tmpCtx.clearRect(0, 0, newWidth, newHeight);
10866 tmpCtx.drawImage(img, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
10867 img = tmpCanvas.canvas;
10868 paintWidth = newWidth;
10869 paintHeight = newHeight;
10870 tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
10871 }
10872 return {
10873 img,
10874 paintWidth,
10875 paintHeight
10876 };
10877 }
10878 _createMaskCanvas(img) {
10879 const ctx = this.ctx;
10880 const {
10881 width,
10882 height
10883 } = img;
10884 const fillColor = this.current.fillColor;
10885 const isPatternFill = this.current.patternFill;
10886 const currentTransform = (0,display_utils.getCurrentTransform)(ctx);
10887 let cache, cacheKey, scaled, maskCanvas;
10888 if ((img.bitmap || img.data) && img.count > 1) {
10889 const mainKey = img.bitmap || img.data.buffer;
10890 cacheKey = JSON.stringify(isPatternFill ? currentTransform : [currentTransform.slice(0, 4), fillColor]);
10891 cache = this._cachedBitmapsMap.get(mainKey);
10892 if (!cache) {
10893 cache = new Map();
10894 this._cachedBitmapsMap.set(mainKey, cache);
10895 }
10896 const cachedImage = cache.get(cacheKey);
10897 if (cachedImage && !isPatternFill) {
10898 const offsetX = Math.round(Math.min(currentTransform[0], currentTransform[2]) + currentTransform[4]);
10899 const offsetY = Math.round(Math.min(currentTransform[1], currentTransform[3]) + currentTransform[5]);
10900 return {
10901 canvas: cachedImage,
10902 offsetX,
10903 offsetY
10904 };
10905 }
10906 scaled = cachedImage;
10907 }
10908 if (!scaled) {
10909 maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
10910 putBinaryImageMask(maskCanvas.context, img);
10911 }
10912 let maskToCanvas = util.Util.transform(currentTransform, [1 / width, 0, 0, -1 / height, 0, 0]);
10913 maskToCanvas = util.Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);
10914 const [minX, minY, maxX, maxY] = util.Util.getAxialAlignedBoundingBox([0, 0, width, height], maskToCanvas);
10915 const drawnWidth = Math.round(maxX - minX) || 1;
10916 const drawnHeight = Math.round(maxY - minY) || 1;
10917 const fillCanvas = this.cachedCanvases.getCanvas("fillCanvas", drawnWidth, drawnHeight);
10918 const fillCtx = fillCanvas.context;
10919 const offsetX = minX;
10920 const offsetY = minY;
10921 fillCtx.translate(-offsetX, -offsetY);
10922 fillCtx.transform(...maskToCanvas);
10923 if (!scaled) {
10924 scaled = this._scaleImage(maskCanvas.canvas, (0,display_utils.getCurrentTransformInverse)(fillCtx));
10925 scaled = scaled.img;
10926 if (cache && isPatternFill) {
10927 cache.set(cacheKey, scaled);
10928 }
10929 }
10930 fillCtx.imageSmoothingEnabled = getImageSmoothingEnabled((0,display_utils.getCurrentTransform)(fillCtx), img.interpolate);
10931 drawImageAtIntegerCoords(fillCtx, scaled, 0, 0, scaled.width, scaled.height, 0, 0, width, height);
10932 fillCtx.globalCompositeOperation = "source-in";
10933 const inverse = util.Util.transform((0,display_utils.getCurrentTransformInverse)(fillCtx), [1, 0, 0, 1, -offsetX, -offsetY]);
10934 fillCtx.fillStyle = isPatternFill ? fillColor.getPattern(ctx, this, inverse, PathType.FILL) : fillColor;
10935 fillCtx.fillRect(0, 0, width, height);
10936 if (cache && !isPatternFill) {
10937 this.cachedCanvases.delete("fillCanvas");
10938 cache.set(cacheKey, fillCanvas.canvas);
10939 }
10940 return {
10941 canvas: fillCanvas.canvas,
10942 offsetX: Math.round(offsetX),
10943 offsetY: Math.round(offsetY)
10944 };
10945 }
10946 setLineWidth(width) {
10947 if (width !== this.current.lineWidth) {
10948 this._cachedScaleForStroking[0] = -1;
10949 }
10950 this.current.lineWidth = width;
10951 this.ctx.lineWidth = width;
10952 }
10953 setLineCap(style) {
10954 this.ctx.lineCap = LINE_CAP_STYLES[style];
10955 }
10956 setLineJoin(style) {
10957 this.ctx.lineJoin = LINE_JOIN_STYLES[style];
10958 }
10959 setMiterLimit(limit) {
10960 this.ctx.miterLimit = limit;
10961 }
10962 setDash(dashArray, dashPhase) {
10963 const ctx = this.ctx;
10964 if (ctx.setLineDash !== undefined) {
10965 ctx.setLineDash(dashArray);
10966 ctx.lineDashOffset = dashPhase;
10967 }
10968 }
10969 setRenderingIntent(intent) {}
10970 setFlatness(flatness) {}
10971 setGState(states) {
10972 for (const [key, value] of states) {
10973 switch (key) {
10974 case "LW":
10975 this.setLineWidth(value);
10976 break;
10977 case "LC":
10978 this.setLineCap(value);
10979 break;
10980 case "LJ":
10981 this.setLineJoin(value);
10982 break;
10983 case "ML":
10984 this.setMiterLimit(value);
10985 break;
10986 case "D":
10987 this.setDash(value[0], value[1]);
10988 break;
10989 case "RI":
10990 this.setRenderingIntent(value);
10991 break;
10992 case "FL":
10993 this.setFlatness(value);
10994 break;
10995 case "Font":
10996 this.setFont(value[0], value[1]);
10997 break;
10998 case "CA":
10999 this.current.strokeAlpha = value;
11000 break;
11001 case "ca":
11002 this.current.fillAlpha = value;
11003 this.ctx.globalAlpha = value;
11004 break;
11005 case "BM":
11006 this.ctx.globalCompositeOperation = value;
11007 break;
11008 case "SMask":
11009 this.current.activeSMask = value ? this.tempSMask : null;
11010 this.tempSMask = null;
11011 this.checkSMaskState();
11012 break;
11013 case "TR":
11014 this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(value);
11015 break;
11016 }
11017 }
11018 }
11019 get inSMaskMode() {
11020 return !!this.suspendedCtx;
11021 }
11022 checkSMaskState() {
11023 const inSMaskMode = this.inSMaskMode;
11024 if (this.current.activeSMask && !inSMaskMode) {
11025 this.beginSMaskMode();
11026 } else if (!this.current.activeSMask && inSMaskMode) {
11027 this.endSMaskMode();
11028 }
11029 }
11030 beginSMaskMode() {
11031 if (this.inSMaskMode) {
11032 throw new Error("beginSMaskMode called while already in smask mode");
11033 }
11034 const drawnWidth = this.ctx.canvas.width;
11035 const drawnHeight = this.ctx.canvas.height;
11036 const cacheId = "smaskGroupAt" + this.groupLevel;
11037 const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
11038 this.suspendedCtx = this.ctx;
11039 this.ctx = scratchCanvas.context;
11040 const ctx = this.ctx;
11041 ctx.setTransform(...(0,display_utils.getCurrentTransform)(this.suspendedCtx));
11042 copyCtxState(this.suspendedCtx, ctx);
11043 mirrorContextOperations(ctx, this.suspendedCtx);
11044 this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
11045 }
11046 endSMaskMode() {
11047 if (!this.inSMaskMode) {
11048 throw new Error("endSMaskMode called while not in smask mode");
11049 }
11050 this.ctx._removeMirroring();
11051 copyCtxState(this.ctx, this.suspendedCtx);
11052 this.ctx = this.suspendedCtx;
11053 this.suspendedCtx = null;
11054 }
11055 compose(dirtyBox) {
11056 if (!this.current.activeSMask) {
11057 return;
11058 }
11059 if (!dirtyBox) {
11060 dirtyBox = [0, 0, this.ctx.canvas.width, this.ctx.canvas.height];
11061 } else {
11062 dirtyBox[0] = Math.floor(dirtyBox[0]);
11063 dirtyBox[1] = Math.floor(dirtyBox[1]);
11064 dirtyBox[2] = Math.ceil(dirtyBox[2]);
11065 dirtyBox[3] = Math.ceil(dirtyBox[3]);
11066 }
11067 const smask = this.current.activeSMask;
11068 const suspendedCtx = this.suspendedCtx;
11069 composeSMask(suspendedCtx, smask, this.ctx, dirtyBox);
11070 this.ctx.save();
11071 this.ctx.setTransform(1, 0, 0, 1, 0, 0);
11072 this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
11073 this.ctx.restore();
11074 }
11075 save() {
11076 if (this.inSMaskMode) {
11077 copyCtxState(this.ctx, this.suspendedCtx);
11078 this.suspendedCtx.save();
11079 } else {
11080 this.ctx.save();
11081 }
11082 const old = this.current;
11083 this.stateStack.push(old);
11084 this.current = old.clone();
11085 }
11086 restore() {
11087 if (this.stateStack.length === 0 && this.inSMaskMode) {
11088 this.endSMaskMode();
11089 }
11090 if (this.stateStack.length !== 0) {
11091 this.current = this.stateStack.pop();
11092 if (this.inSMaskMode) {
11093 this.suspendedCtx.restore();
11094 copyCtxState(this.suspendedCtx, this.ctx);
11095 } else {
11096 this.ctx.restore();
11097 }
11098 this.checkSMaskState();
11099 this.pendingClip = null;
11100 this._cachedScaleForStroking[0] = -1;
11101 this._cachedGetSinglePixelWidth = null;
11102 }
11103 }
11104 transform(a, b, c, d, e, f) {
11105 this.ctx.transform(a, b, c, d, e, f);
11106 this._cachedScaleForStroking[0] = -1;
11107 this._cachedGetSinglePixelWidth = null;
11108 }
11109 constructPath(ops, args, minMax) {
11110 const ctx = this.ctx;
11111 const current = this.current;
11112 let x = current.x,
11113 y = current.y;
11114 let startX, startY;
11115 const currentTransform = (0,display_utils.getCurrentTransform)(ctx);
11116 const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
11117 const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
11118 for (let i = 0, j = 0, ii = ops.length; i < ii; i++) {
11119 switch (ops[i] | 0) {
11120 case util.OPS.rectangle:
11121 x = args[j++];
11122 y = args[j++];
11123 const width = args[j++];
11124 const height = args[j++];
11125 const xw = x + width;
11126 const yh = y + height;
11127 ctx.moveTo(x, y);
11128 if (width === 0 || height === 0) {
11129 ctx.lineTo(xw, yh);
11130 } else {
11131 ctx.lineTo(xw, y);
11132 ctx.lineTo(xw, yh);
11133 ctx.lineTo(x, yh);
11134 }
11135 if (!isScalingMatrix) {
11136 current.updateRectMinMax(currentTransform, [x, y, xw, yh]);
11137 }
11138 ctx.closePath();
11139 break;
11140 case util.OPS.moveTo:
11141 x = args[j++];
11142 y = args[j++];
11143 ctx.moveTo(x, y);
11144 if (!isScalingMatrix) {
11145 current.updatePathMinMax(currentTransform, x, y);
11146 }
11147 break;
11148 case util.OPS.lineTo:
11149 x = args[j++];
11150 y = args[j++];
11151 ctx.lineTo(x, y);
11152 if (!isScalingMatrix) {
11153 current.updatePathMinMax(currentTransform, x, y);
11154 }
11155 break;
11156 case util.OPS.curveTo:
11157 startX = x;
11158 startY = y;
11159 x = args[j + 4];
11160 y = args[j + 5];
11161 ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
11162 current.updateCurvePathMinMax(currentTransform, startX, startY, args[j], args[j + 1], args[j + 2], args[j + 3], x, y, minMaxForBezier);
11163 j += 6;
11164 break;
11165 case util.OPS.curveTo2:
11166 startX = x;
11167 startY = y;
11168 ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
11169 current.updateCurvePathMinMax(currentTransform, startX, startY, x, y, args[j], args[j + 1], args[j + 2], args[j + 3], minMaxForBezier);
11170 x = args[j + 2];
11171 y = args[j + 3];
11172 j += 4;
11173 break;
11174 case util.OPS.curveTo3:
11175 startX = x;
11176 startY = y;
11177 x = args[j + 2];
11178 y = args[j + 3];
11179 ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
11180 current.updateCurvePathMinMax(currentTransform, startX, startY, args[j], args[j + 1], x, y, x, y, minMaxForBezier);
11181 j += 4;
11182 break;
11183 case util.OPS.closePath:
11184 ctx.closePath();
11185 break;
11186 }
11187 }
11188 if (isScalingMatrix) {
11189 current.updateScalingPathMinMax(currentTransform, minMaxForBezier);
11190 }
11191 current.setCurrentPoint(x, y);
11192 }
11193 closePath() {
11194 this.ctx.closePath();
11195 }
11196 stroke() {
11197 let consumePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
11198 const ctx = this.ctx;
11199 const strokeColor = this.current.strokeColor;
11200 ctx.globalAlpha = this.current.strokeAlpha;
11201 if (this.contentVisible) {
11202 if (typeof strokeColor === "object" && strokeColor?.getPattern) {
11203 ctx.save();
11204 ctx.strokeStyle = strokeColor.getPattern(ctx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.STROKE);
11205 this.rescaleAndStroke(false);
11206 ctx.restore();
11207 } else {
11208 this.rescaleAndStroke(true);
11209 }
11210 }
11211 if (consumePath) {
11212 this.consumePath(this.current.getClippedPathBoundingBox());
11213 }
11214 ctx.globalAlpha = this.current.fillAlpha;
11215 }
11216 closeStroke() {
11217 this.closePath();
11218 this.stroke();
11219 }
11220 fill() {
11221 let consumePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
11222 const ctx = this.ctx;
11223 const fillColor = this.current.fillColor;
11224 const isPatternFill = this.current.patternFill;
11225 let needRestore = false;
11226 if (isPatternFill) {
11227 ctx.save();
11228 ctx.fillStyle = fillColor.getPattern(ctx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.FILL);
11229 needRestore = true;
11230 }
11231 const intersect = this.current.getClippedPathBoundingBox();
11232 if (this.contentVisible && intersect !== null) {
11233 if (this.pendingEOFill) {
11234 ctx.fill("evenodd");
11235 this.pendingEOFill = false;
11236 } else {
11237 ctx.fill();
11238 }
11239 }
11240 if (needRestore) {
11241 ctx.restore();
11242 }
11243 if (consumePath) {
11244 this.consumePath(intersect);
11245 }
11246 }
11247 eoFill() {
11248 this.pendingEOFill = true;
11249 this.fill();
11250 }
11251 fillStroke() {
11252 this.fill(false);
11253 this.stroke(false);
11254 this.consumePath();
11255 }
11256 eoFillStroke() {
11257 this.pendingEOFill = true;
11258 this.fillStroke();
11259 }
11260 closeFillStroke() {
11261 this.closePath();
11262 this.fillStroke();
11263 }
11264 closeEOFillStroke() {
11265 this.pendingEOFill = true;
11266 this.closePath();
11267 this.fillStroke();
11268 }
11269 endPath() {
11270 this.consumePath();
11271 }
11272 clip() {
11273 this.pendingClip = NORMAL_CLIP;
11274 }
11275 eoClip() {
11276 this.pendingClip = EO_CLIP;
11277 }
11278 beginText() {
11279 this.current.textMatrix = util.IDENTITY_MATRIX;
11280 this.current.textMatrixScale = 1;
11281 this.current.x = this.current.lineX = 0;
11282 this.current.y = this.current.lineY = 0;
11283 }
11284 endText() {
11285 const paths = this.pendingTextPaths;
11286 const ctx = this.ctx;
11287 if (paths === undefined) {
11288 ctx.beginPath();
11289 return;
11290 }
11291 ctx.save();
11292 ctx.beginPath();
11293 for (const path of paths) {
11294 ctx.setTransform(...path.transform);
11295 ctx.translate(path.x, path.y);
11296 path.addToPath(ctx, path.fontSize);
11297 }
11298 ctx.restore();
11299 ctx.clip();
11300 ctx.beginPath();
11301 delete this.pendingTextPaths;
11302 }
11303 setCharSpacing(spacing) {
11304 this.current.charSpacing = spacing;
11305 }
11306 setWordSpacing(spacing) {
11307 this.current.wordSpacing = spacing;
11308 }
11309 setHScale(scale) {
11310 this.current.textHScale = scale / 100;
11311 }
11312 setLeading(leading) {
11313 this.current.leading = -leading;
11314 }
11315 setFont(fontRefName, size) {
11316 const fontObj = this.commonObjs.get(fontRefName);
11317 const current = this.current;
11318 if (!fontObj) {
11319 throw new Error(`Can't find font for ${fontRefName}`);
11320 }
11321 current.fontMatrix = fontObj.fontMatrix || util.FONT_IDENTITY_MATRIX;
11322 if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
11323 (0,util.warn)("Invalid font matrix for font " + fontRefName);
11324 }
11325 if (size < 0) {
11326 size = -size;
11327 current.fontDirection = -1;
11328 } else {
11329 current.fontDirection = 1;
11330 }
11331 this.current.font = fontObj;
11332 this.current.fontSize = size;
11333 if (fontObj.isType3Font) {
11334 return;
11335 }
11336 const name = fontObj.loadedName || "sans-serif";
11337 const typeface = fontObj.systemFontInfo?.css || `"${name}", ${fontObj.fallbackName}`;
11338 let bold = "normal";
11339 if (fontObj.black) {
11340 bold = "900";
11341 } else if (fontObj.bold) {
11342 bold = "bold";
11343 }
11344 const italic = fontObj.italic ? "italic" : "normal";
11345 let browserFontSize = size;
11346 if (size < MIN_FONT_SIZE) {
11347 browserFontSize = MIN_FONT_SIZE;
11348 } else if (size > MAX_FONT_SIZE) {
11349 browserFontSize = MAX_FONT_SIZE;
11350 }
11351 this.current.fontSizeScale = size / browserFontSize;
11352 this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
11353 }
11354 setTextRenderingMode(mode) {
11355 this.current.textRenderingMode = mode;
11356 }
11357 setTextRise(rise) {
11358 this.current.textRise = rise;
11359 }
11360 moveText(x, y) {
11361 this.current.x = this.current.lineX += x;
11362 this.current.y = this.current.lineY += y;
11363 }
11364 setLeadingMoveText(x, y) {
11365 this.setLeading(-y);
11366 this.moveText(x, y);
11367 }
11368 setTextMatrix(a, b, c, d, e, f) {
11369 this.current.textMatrix = [a, b, c, d, e, f];
11370 this.current.textMatrixScale = Math.hypot(a, b);
11371 this.current.x = this.current.lineX = 0;
11372 this.current.y = this.current.lineY = 0;
11373 }
11374 nextLine() {
11375 this.moveText(0, this.current.leading);
11376 }
11377 paintChar(character, x, y, patternTransform) {
11378 const ctx = this.ctx;
11379 const current = this.current;
11380 const font = current.font;
11381 const textRenderingMode = current.textRenderingMode;
11382 const fontSize = current.fontSize / current.fontSizeScale;
11383 const fillStrokeMode = textRenderingMode & util.TextRenderingMode.FILL_STROKE_MASK;
11384 const isAddToPathSet = !!(textRenderingMode & util.TextRenderingMode.ADD_TO_PATH_FLAG);
11385 const patternFill = current.patternFill && !font.missingFile;
11386 let addToPath;
11387 if (font.disableFontFace || isAddToPathSet || patternFill) {
11388 addToPath = font.getPathGenerator(this.commonObjs, character);
11389 }
11390 if (font.disableFontFace || patternFill) {
11391 ctx.save();
11392 ctx.translate(x, y);
11393 ctx.beginPath();
11394 addToPath(ctx, fontSize);
11395 if (patternTransform) {
11396 ctx.setTransform(...patternTransform);
11397 }
11398 if (fillStrokeMode === util.TextRenderingMode.FILL || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
11399 ctx.fill();
11400 }
11401 if (fillStrokeMode === util.TextRenderingMode.STROKE || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
11402 ctx.stroke();
11403 }
11404 ctx.restore();
11405 } else {
11406 if (fillStrokeMode === util.TextRenderingMode.FILL || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
11407 ctx.fillText(character, x, y);
11408 }
11409 if (fillStrokeMode === util.TextRenderingMode.STROKE || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
11410 ctx.strokeText(character, x, y);
11411 }
11412 }
11413 if (isAddToPathSet) {
11414 const paths = this.pendingTextPaths ||= [];
11415 paths.push({
11416 transform: (0,display_utils.getCurrentTransform)(ctx),
11417 x,
11418 y,
11419 fontSize,
11420 addToPath
11421 });
11422 }
11423 }
11424 get isFontSubpixelAAEnabled() {
11425 const {
11426 context: ctx
11427 } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
11428 ctx.scale(1.5, 1);
11429 ctx.fillText("I", 0, 10);
11430 const data = ctx.getImageData(0, 0, 10, 10).data;
11431 let enabled = false;
11432 for (let i = 3; i < data.length; i += 4) {
11433 if (data[i] > 0 && data[i] < 255) {
11434 enabled = true;
11435 break;
11436 }
11437 }
11438 return (0,util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
11439 }
11440 showText(glyphs) {
11441 const current = this.current;
11442 const font = current.font;
11443 if (font.isType3Font) {
11444 return this.showType3Text(glyphs);
11445 }
11446 const fontSize = current.fontSize;
11447 if (fontSize === 0) {
11448 return undefined;
11449 }
11450 const ctx = this.ctx;
11451 const fontSizeScale = current.fontSizeScale;
11452 const charSpacing = current.charSpacing;
11453 const wordSpacing = current.wordSpacing;
11454 const fontDirection = current.fontDirection;
11455 const textHScale = current.textHScale * fontDirection;
11456 const glyphsLength = glyphs.length;
11457 const vertical = font.vertical;
11458 const spacingDir = vertical ? 1 : -1;
11459 const defaultVMetrics = font.defaultVMetrics;
11460 const widthAdvanceScale = fontSize * current.fontMatrix[0];
11461 const simpleFillText = current.textRenderingMode === util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
11462 ctx.save();
11463 ctx.transform(...current.textMatrix);
11464 ctx.translate(current.x, current.y + current.textRise);
11465 if (fontDirection > 0) {
11466 ctx.scale(textHScale, -1);
11467 } else {
11468 ctx.scale(textHScale, 1);
11469 }
11470 let patternTransform;
11471 if (current.patternFill) {
11472 ctx.save();
11473 const pattern = current.fillColor.getPattern(ctx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.FILL);
11474 patternTransform = (0,display_utils.getCurrentTransform)(ctx);
11475 ctx.restore();
11476 ctx.fillStyle = pattern;
11477 }
11478 let lineWidth = current.lineWidth;
11479 const scale = current.textMatrixScale;
11480 if (scale === 0 || lineWidth === 0) {
11481 const fillStrokeMode = current.textRenderingMode & util.TextRenderingMode.FILL_STROKE_MASK;
11482 if (fillStrokeMode === util.TextRenderingMode.STROKE || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
11483 lineWidth = this.getSinglePixelWidth();
11484 }
11485 } else {
11486 lineWidth /= scale;
11487 }
11488 if (fontSizeScale !== 1.0) {
11489 ctx.scale(fontSizeScale, fontSizeScale);
11490 lineWidth /= fontSizeScale;
11491 }
11492 ctx.lineWidth = lineWidth;
11493 if (font.isInvalidPDFjsFont) {
11494 const chars = [];
11495 let width = 0;
11496 for (const glyph of glyphs) {
11497 chars.push(glyph.unicode);
11498 width += glyph.width;
11499 }
11500 ctx.fillText(chars.join(""), 0, 0);
11501 current.x += width * widthAdvanceScale * textHScale;
11502 ctx.restore();
11503 this.compose();
11504 return undefined;
11505 }
11506 let x = 0,
11507 i;
11508 for (i = 0; i < glyphsLength; ++i) {
11509 const glyph = glyphs[i];
11510 if (typeof glyph === "number") {
11511 x += spacingDir * glyph * fontSize / 1000;
11512 continue;
11513 }
11514 let restoreNeeded = false;
11515 const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
11516 const character = glyph.fontChar;
11517 const accent = glyph.accent;
11518 let scaledX, scaledY;
11519 let width = glyph.width;
11520 if (vertical) {
11521 const vmetric = glyph.vmetric || defaultVMetrics;
11522 const vx = -(glyph.vmetric ? vmetric[1] : width * 0.5) * widthAdvanceScale;
11523 const vy = vmetric[2] * widthAdvanceScale;
11524 width = vmetric ? -vmetric[0] : width;
11525 scaledX = vx / fontSizeScale;
11526 scaledY = (x + vy) / fontSizeScale;
11527 } else {
11528 scaledX = x / fontSizeScale;
11529 scaledY = 0;
11530 }
11531 if (font.remeasure && width > 0) {
11532 const measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
11533 if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
11534 const characterScaleX = width / measuredWidth;
11535 restoreNeeded = true;
11536 ctx.save();
11537 ctx.scale(characterScaleX, 1);
11538 scaledX /= characterScaleX;
11539 } else if (width !== measuredWidth) {
11540 scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
11541 }
11542 }
11543 if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
11544 if (simpleFillText && !accent) {
11545 ctx.fillText(character, scaledX, scaledY);
11546 } else {
11547 this.paintChar(character, scaledX, scaledY, patternTransform);
11548 if (accent) {
11549 const scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
11550 const scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
11551 this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
11552 }
11553 }
11554 }
11555 const charWidth = vertical ? width * widthAdvanceScale - spacing * fontDirection : width * widthAdvanceScale + spacing * fontDirection;
11556 x += charWidth;
11557 if (restoreNeeded) {
11558 ctx.restore();
11559 }
11560 }
11561 if (vertical) {
11562 current.y -= x;
11563 } else {
11564 current.x += x * textHScale;
11565 }
11566 ctx.restore();
11567 this.compose();
11568 return undefined;
11569 }
11570 showType3Text(glyphs) {
11571 const ctx = this.ctx;
11572 const current = this.current;
11573 const font = current.font;
11574 const fontSize = current.fontSize;
11575 const fontDirection = current.fontDirection;
11576 const spacingDir = font.vertical ? 1 : -1;
11577 const charSpacing = current.charSpacing;
11578 const wordSpacing = current.wordSpacing;
11579 const textHScale = current.textHScale * fontDirection;
11580 const fontMatrix = current.fontMatrix || util.FONT_IDENTITY_MATRIX;
11581 const glyphsLength = glyphs.length;
11582 const isTextInvisible = current.textRenderingMode === util.TextRenderingMode.INVISIBLE;
11583 let i, glyph, width, spacingLength;
11584 if (isTextInvisible || fontSize === 0) {
11585 return;
11586 }
11587 this._cachedScaleForStroking[0] = -1;
11588 this._cachedGetSinglePixelWidth = null;
11589 ctx.save();
11590 ctx.transform(...current.textMatrix);
11591 ctx.translate(current.x, current.y);
11592 ctx.scale(textHScale, fontDirection);
11593 for (i = 0; i < glyphsLength; ++i) {
11594 glyph = glyphs[i];
11595 if (typeof glyph === "number") {
11596 spacingLength = spacingDir * glyph * fontSize / 1000;
11597 this.ctx.translate(spacingLength, 0);
11598 current.x += spacingLength * textHScale;
11599 continue;
11600 }
11601 const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
11602 const operatorList = font.charProcOperatorList[glyph.operatorListId];
11603 if (!operatorList) {
11604 (0,util.warn)(`Type3 character "${glyph.operatorListId}" is not available.`);
11605 continue;
11606 }
11607 if (this.contentVisible) {
11608 this.processingType3 = glyph;
11609 this.save();
11610 ctx.scale(fontSize, fontSize);
11611 ctx.transform(...fontMatrix);
11612 this.executeOperatorList(operatorList);
11613 this.restore();
11614 }
11615 const transformed = util.Util.applyTransform([glyph.width, 0], fontMatrix);
11616 width = transformed[0] * fontSize + spacing;
11617 ctx.translate(width, 0);
11618 current.x += width * textHScale;
11619 }
11620 ctx.restore();
11621 this.processingType3 = null;
11622 }
11623 setCharWidth(xWidth, yWidth) {}
11624 setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
11625 this.ctx.rect(llx, lly, urx - llx, ury - lly);
11626 this.ctx.clip();
11627 this.endPath();
11628 }
11629 getColorN_Pattern(IR) {
11630 let pattern;
11631 if (IR[0] === "TilingPattern") {
11632 const color = IR[1];
11633 const baseTransform = this.baseTransform || (0,display_utils.getCurrentTransform)(this.ctx);
11634 const canvasGraphicsFactory = {
11635 createCanvasGraphics: ctx => new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
11636 optionalContentConfig: this.optionalContentConfig,
11637 markedContentStack: this.markedContentStack
11638 })
11639 };
11640 pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
11641 } else {
11642 pattern = this._getPattern(IR[1], IR[2]);
11643 }
11644 return pattern;
11645 }
11646 setStrokeColorN() {
11647 this.current.strokeColor = this.getColorN_Pattern(arguments);
11648 }
11649 setFillColorN() {
11650 this.current.fillColor = this.getColorN_Pattern(arguments);
11651 this.current.patternFill = true;
11652 }
11653 setStrokeRGBColor(r, g, b) {
11654 const color = util.Util.makeHexColor(r, g, b);
11655 this.ctx.strokeStyle = color;
11656 this.current.strokeColor = color;
11657 }
11658 setFillRGBColor(r, g, b) {
11659 const color = util.Util.makeHexColor(r, g, b);
11660 this.ctx.fillStyle = color;
11661 this.current.fillColor = color;
11662 this.current.patternFill = false;
11663 }
11664 _getPattern(objId) {
11665 let matrix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
11666 let pattern;
11667 if (this.cachedPatterns.has(objId)) {
11668 pattern = this.cachedPatterns.get(objId);
11669 } else {
11670 pattern = getShadingPattern(this.getObject(objId));
11671 this.cachedPatterns.set(objId, pattern);
11672 }
11673 if (matrix) {
11674 pattern.matrix = matrix;
11675 }
11676 return pattern;
11677 }
11678 shadingFill(objId) {
11679 if (!this.contentVisible) {
11680 return;
11681 }
11682 const ctx = this.ctx;
11683 this.save();
11684 const pattern = this._getPattern(objId);
11685 ctx.fillStyle = pattern.getPattern(ctx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.SHADING);
11686 const inv = (0,display_utils.getCurrentTransformInverse)(ctx);
11687 if (inv) {
11688 const {
11689 width,
11690 height
11691 } = ctx.canvas;
11692 const [x0, y0, x1, y1] = util.Util.getAxialAlignedBoundingBox([0, 0, width, height], inv);
11693 this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
11694 } else {
11695 this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
11696 }
11697 this.compose(this.current.getClippedPathBoundingBox());
11698 this.restore();
11699 }
11700 beginInlineImage() {
11701 (0,util.unreachable)("Should not call beginInlineImage");
11702 }
11703 beginImageData() {
11704 (0,util.unreachable)("Should not call beginImageData");
11705 }
11706 paintFormXObjectBegin(matrix, bbox) {
11707 if (!this.contentVisible) {
11708 return;
11709 }
11710 this.save();
11711 this.baseTransformStack.push(this.baseTransform);
11712 if (Array.isArray(matrix) && matrix.length === 6) {
11713 this.transform(...matrix);
11714 }
11715 this.baseTransform = (0,display_utils.getCurrentTransform)(this.ctx);
11716 if (bbox) {
11717 const width = bbox[2] - bbox[0];
11718 const height = bbox[3] - bbox[1];
11719 this.ctx.rect(bbox[0], bbox[1], width, height);
11720 this.current.updateRectMinMax((0,display_utils.getCurrentTransform)(this.ctx), bbox);
11721 this.clip();
11722 this.endPath();
11723 }
11724 }
11725 paintFormXObjectEnd() {
11726 if (!this.contentVisible) {
11727 return;
11728 }
11729 this.restore();
11730 this.baseTransform = this.baseTransformStack.pop();
11731 }
11732 beginGroup(group) {
11733 if (!this.contentVisible) {
11734 return;
11735 }
11736 this.save();
11737 if (this.inSMaskMode) {
11738 this.endSMaskMode();
11739 this.current.activeSMask = null;
11740 }
11741 const currentCtx = this.ctx;
11742 if (!group.isolated) {
11743 (0,util.info)("TODO: Support non-isolated groups.");
11744 }
11745 if (group.knockout) {
11746 (0,util.warn)("Knockout groups not supported.");
11747 }
11748 const currentTransform = (0,display_utils.getCurrentTransform)(currentCtx);
11749 if (group.matrix) {
11750 currentCtx.transform(...group.matrix);
11751 }
11752 if (!group.bbox) {
11753 throw new Error("Bounding box is required.");
11754 }
11755 let bounds = util.Util.getAxialAlignedBoundingBox(group.bbox, (0,display_utils.getCurrentTransform)(currentCtx));
11756 const canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
11757 bounds = util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
11758 const offsetX = Math.floor(bounds[0]);
11759 const offsetY = Math.floor(bounds[1]);
11760 let drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
11761 let drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
11762 let scaleX = 1,
11763 scaleY = 1;
11764 if (drawnWidth > MAX_GROUP_SIZE) {
11765 scaleX = drawnWidth / MAX_GROUP_SIZE;
11766 drawnWidth = MAX_GROUP_SIZE;
11767 }
11768 if (drawnHeight > MAX_GROUP_SIZE) {
11769 scaleY = drawnHeight / MAX_GROUP_SIZE;
11770 drawnHeight = MAX_GROUP_SIZE;
11771 }
11772 this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);
11773 let cacheId = "groupAt" + this.groupLevel;
11774 if (group.smask) {
11775 cacheId += "_smask_" + this.smaskCounter++ % 2;
11776 }
11777 const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
11778 const groupCtx = scratchCanvas.context;
11779 groupCtx.scale(1 / scaleX, 1 / scaleY);
11780 groupCtx.translate(-offsetX, -offsetY);
11781 groupCtx.transform(...currentTransform);
11782 if (group.smask) {
11783 this.smaskStack.push({
11784 canvas: scratchCanvas.canvas,
11785 context: groupCtx,
11786 offsetX,
11787 offsetY,
11788 scaleX,
11789 scaleY,
11790 subtype: group.smask.subtype,
11791 backdrop: group.smask.backdrop,
11792 transferMap: group.smask.transferMap || null,
11793 startTransformInverse: null
11794 });
11795 } else {
11796 currentCtx.setTransform(1, 0, 0, 1, 0, 0);
11797 currentCtx.translate(offsetX, offsetY);
11798 currentCtx.scale(scaleX, scaleY);
11799 currentCtx.save();
11800 }
11801 copyCtxState(currentCtx, groupCtx);
11802 this.ctx = groupCtx;
11803 this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
11804 this.groupStack.push(currentCtx);
11805 this.groupLevel++;
11806 }
11807 endGroup(group) {
11808 if (!this.contentVisible) {
11809 return;
11810 }
11811 this.groupLevel--;
11812 const groupCtx = this.ctx;
11813 const ctx = this.groupStack.pop();
11814 this.ctx = ctx;
11815 this.ctx.imageSmoothingEnabled = false;
11816 if (group.smask) {
11817 this.tempSMask = this.smaskStack.pop();
11818 this.restore();
11819 } else {
11820 this.ctx.restore();
11821 const currentMtx = (0,display_utils.getCurrentTransform)(this.ctx);
11822 this.restore();
11823 this.ctx.save();
11824 this.ctx.setTransform(...currentMtx);
11825 const dirtyBox = util.Util.getAxialAlignedBoundingBox([0, 0, groupCtx.canvas.width, groupCtx.canvas.height], currentMtx);
11826 this.ctx.drawImage(groupCtx.canvas, 0, 0);
11827 this.ctx.restore();
11828 this.compose(dirtyBox);
11829 }
11830 }
11831 beginAnnotation(id, rect, transform, matrix, hasOwnCanvas) {
11832 this.#restoreInitialState();
11833 resetCtxToDefault(this.ctx);
11834 this.ctx.save();
11835 this.save();
11836 if (this.baseTransform) {
11837 this.ctx.setTransform(...this.baseTransform);
11838 }
11839 if (Array.isArray(rect) && rect.length === 4) {
11840 const width = rect[2] - rect[0];
11841 const height = rect[3] - rect[1];
11842 if (hasOwnCanvas && this.annotationCanvasMap) {
11843 transform = transform.slice();
11844 transform[4] -= rect[0];
11845 transform[5] -= rect[1];
11846 rect = rect.slice();
11847 rect[0] = rect[1] = 0;
11848 rect[2] = width;
11849 rect[3] = height;
11850 const [scaleX, scaleY] = util.Util.singularValueDecompose2dScale((0,display_utils.getCurrentTransform)(this.ctx));
11851 const {
11852 viewportScale
11853 } = this;
11854 const canvasWidth = Math.ceil(width * this.outputScaleX * viewportScale);
11855 const canvasHeight = Math.ceil(height * this.outputScaleY * viewportScale);
11856 this.annotationCanvas = this.canvasFactory.create(canvasWidth, canvasHeight);
11857 const {
11858 canvas,
11859 context
11860 } = this.annotationCanvas;
11861 this.annotationCanvasMap.set(id, canvas);
11862 this.annotationCanvas.savedCtx = this.ctx;
11863 this.ctx = context;
11864 this.ctx.save();
11865 this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
11866 resetCtxToDefault(this.ctx);
11867 } else {
11868 resetCtxToDefault(this.ctx);
11869 this.ctx.rect(rect[0], rect[1], width, height);
11870 this.ctx.clip();
11871 this.endPath();
11872 }
11873 }
11874 this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
11875 this.transform(...transform);
11876 this.transform(...matrix);
11877 }
11878 endAnnotation() {
11879 if (this.annotationCanvas) {
11880 this.ctx.restore();
11881 this.#drawFilter();
11882 this.ctx = this.annotationCanvas.savedCtx;
11883 delete this.annotationCanvas.savedCtx;
11884 delete this.annotationCanvas;
11885 }
11886 }
11887 paintImageMaskXObject(img) {
11888 if (!this.contentVisible) {
11889 return;
11890 }
11891 const count = img.count;
11892 img = this.getObject(img.data, img);
11893 img.count = count;
11894 const ctx = this.ctx;
11895 const glyph = this.processingType3;
11896 if (glyph) {
11897 if (glyph.compiled === undefined) {
11898 glyph.compiled = compileType3Glyph(img);
11899 }
11900 if (glyph.compiled) {
11901 glyph.compiled(ctx);
11902 return;
11903 }
11904 }
11905 const mask = this._createMaskCanvas(img);
11906 const maskCanvas = mask.canvas;
11907 ctx.save();
11908 ctx.setTransform(1, 0, 0, 1, 0, 0);
11909 ctx.drawImage(maskCanvas, mask.offsetX, mask.offsetY);
11910 ctx.restore();
11911 this.compose();
11912 }
11913 paintImageMaskXObjectRepeat(img, scaleX) {
11914 let skewX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
11915 let skewY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
11916 let scaleY = arguments.length > 4 ? arguments[4] : undefined;
11917 let positions = arguments.length > 5 ? arguments[5] : undefined;
11918 if (!this.contentVisible) {
11919 return;
11920 }
11921 img = this.getObject(img.data, img);
11922 const ctx = this.ctx;
11923 ctx.save();
11924 const currentTransform = (0,display_utils.getCurrentTransform)(ctx);
11925 ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);
11926 const mask = this._createMaskCanvas(img);
11927 ctx.setTransform(1, 0, 0, 1, mask.offsetX - currentTransform[4], mask.offsetY - currentTransform[5]);
11928 for (let i = 0, ii = positions.length; i < ii; i += 2) {
11929 const trans = util.Util.transform(currentTransform, [scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]]);
11930 const [x, y] = util.Util.applyTransform([0, 0], trans);
11931 ctx.drawImage(mask.canvas, x, y);
11932 }
11933 ctx.restore();
11934 this.compose();
11935 }
11936 paintImageMaskXObjectGroup(images) {
11937 if (!this.contentVisible) {
11938 return;
11939 }
11940 const ctx = this.ctx;
11941 const fillColor = this.current.fillColor;
11942 const isPatternFill = this.current.patternFill;
11943 for (const image of images) {
11944 const {
11945 data,
11946 width,
11947 height,
11948 transform
11949 } = image;
11950 const maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
11951 const maskCtx = maskCanvas.context;
11952 maskCtx.save();
11953 const img = this.getObject(data, image);
11954 putBinaryImageMask(maskCtx, img);
11955 maskCtx.globalCompositeOperation = "source-in";
11956 maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.FILL) : fillColor;
11957 maskCtx.fillRect(0, 0, width, height);
11958 maskCtx.restore();
11959 ctx.save();
11960 ctx.transform(...transform);
11961 ctx.scale(1, -1);
11962 drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
11963 ctx.restore();
11964 }
11965 this.compose();
11966 }
11967 paintImageXObject(objId) {
11968 if (!this.contentVisible) {
11969 return;
11970 }
11971 const imgData = this.getObject(objId);
11972 if (!imgData) {
11973 (0,util.warn)("Dependent image isn't ready yet");
11974 return;
11975 }
11976 this.paintInlineImageXObject(imgData);
11977 }
11978 paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
11979 if (!this.contentVisible) {
11980 return;
11981 }
11982 const imgData = this.getObject(objId);
11983 if (!imgData) {
11984 (0,util.warn)("Dependent image isn't ready yet");
11985 return;
11986 }
11987 const width = imgData.width;
11988 const height = imgData.height;
11989 const map = [];
11990 for (let i = 0, ii = positions.length; i < ii; i += 2) {
11991 map.push({
11992 transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
11993 x: 0,
11994 y: 0,
11995 w: width,
11996 h: height
11997 });
11998 }
11999 this.paintInlineImageXObjectGroup(imgData, map);
12000 }
12001 applyTransferMapsToCanvas(ctx) {
12002 if (this.current.transferMaps !== "none") {
12003 ctx.filter = this.current.transferMaps;
12004 ctx.drawImage(ctx.canvas, 0, 0);
12005 ctx.filter = "none";
12006 }
12007 return ctx.canvas;
12008 }
12009 applyTransferMapsToBitmap(imgData) {
12010 if (this.current.transferMaps === "none") {
12011 return imgData.bitmap;
12012 }
12013 const {
12014 bitmap,
12015 width,
12016 height
12017 } = imgData;
12018 const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
12019 const tmpCtx = tmpCanvas.context;
12020 tmpCtx.filter = this.current.transferMaps;
12021 tmpCtx.drawImage(bitmap, 0, 0);
12022 tmpCtx.filter = "none";
12023 return tmpCanvas.canvas;
12024 }
12025 paintInlineImageXObject(imgData) {
12026 if (!this.contentVisible) {
12027 return;
12028 }
12029 const width = imgData.width;
12030 const height = imgData.height;
12031 const ctx = this.ctx;
12032 this.save();
12033 if (!util.isNodeJS) {
12034 const {
12035 filter
12036 } = ctx;
12037 if (filter !== "none" && filter !== "") {
12038 ctx.filter = "none";
12039 }
12040 }
12041 ctx.scale(1 / width, -1 / height);
12042 let imgToPaint;
12043 if (imgData.bitmap) {
12044 imgToPaint = this.applyTransferMapsToBitmap(imgData);
12045 } else if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
12046 imgToPaint = imgData;
12047 } else {
12048 const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
12049 const tmpCtx = tmpCanvas.context;
12050 putBinaryImageData(tmpCtx, imgData);
12051 imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
12052 }
12053 const scaled = this._scaleImage(imgToPaint, (0,display_utils.getCurrentTransformInverse)(ctx));
12054 ctx.imageSmoothingEnabled = getImageSmoothingEnabled((0,display_utils.getCurrentTransform)(ctx), imgData.interpolate);
12055 drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
12056 this.compose();
12057 this.restore();
12058 }
12059 paintInlineImageXObjectGroup(imgData, map) {
12060 if (!this.contentVisible) {
12061 return;
12062 }
12063 const ctx = this.ctx;
12064 let imgToPaint;
12065 if (imgData.bitmap) {
12066 imgToPaint = imgData.bitmap;
12067 } else {
12068 const w = imgData.width;
12069 const h = imgData.height;
12070 const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
12071 const tmpCtx = tmpCanvas.context;
12072 putBinaryImageData(tmpCtx, imgData);
12073 imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
12074 }
12075 for (const entry of map) {
12076 ctx.save();
12077 ctx.transform(...entry.transform);
12078 ctx.scale(1, -1);
12079 drawImageAtIntegerCoords(ctx, imgToPaint, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
12080 ctx.restore();
12081 }
12082 this.compose();
12083 }
12084 paintSolidColorImageMask() {
12085 if (!this.contentVisible) {
12086 return;
12087 }
12088 this.ctx.fillRect(0, 0, 1, 1);
12089 this.compose();
12090 }
12091 markPoint(tag) {}
12092 markPointProps(tag, properties) {}
12093 beginMarkedContent(tag) {
12094 this.markedContentStack.push({
12095 visible: true
12096 });
12097 }
12098 beginMarkedContentProps(tag, properties) {
12099 if (tag === "OC") {
12100 this.markedContentStack.push({
12101 visible: this.optionalContentConfig.isVisible(properties)
12102 });
12103 } else {
12104 this.markedContentStack.push({
12105 visible: true
12106 });
12107 }
12108 this.contentVisible = this.isContentVisible();
12109 }
12110 endMarkedContent() {
12111 this.markedContentStack.pop();
12112 this.contentVisible = this.isContentVisible();
12113 }
12114 beginCompat() {}
12115 endCompat() {}
12116 consumePath(clipBox) {
12117 const isEmpty = this.current.isEmptyClip();
12118 if (this.pendingClip) {
12119 this.current.updateClipFromPath();
12120 }
12121 if (!this.pendingClip) {
12122 this.compose(clipBox);
12123 }
12124 const ctx = this.ctx;
12125 if (this.pendingClip) {
12126 if (!isEmpty) {
12127 if (this.pendingClip === EO_CLIP) {
12128 ctx.clip("evenodd");
12129 } else {
12130 ctx.clip();
12131 }
12132 }
12133 this.pendingClip = null;
12134 }
12135 this.current.startNewPathAndClipBox(this.current.clipBox);
12136 ctx.beginPath();
12137 }
12138 getSinglePixelWidth() {
12139 if (!this._cachedGetSinglePixelWidth) {
12140 const m = (0,display_utils.getCurrentTransform)(this.ctx);
12141 if (m[1] === 0 && m[2] === 0) {
12142 this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(m[0]), Math.abs(m[3]));
12143 } else {
12144 const absDet = Math.abs(m[0] * m[3] - m[2] * m[1]);
12145 const normX = Math.hypot(m[0], m[2]);
12146 const normY = Math.hypot(m[1], m[3]);
12147 this._cachedGetSinglePixelWidth = Math.max(normX, normY) / absDet;
12148 }
12149 }
12150 return this._cachedGetSinglePixelWidth;
12151 }
12152 getScaleForStroking() {
12153 if (this._cachedScaleForStroking[0] === -1) {
12154 const {
12155 lineWidth
12156 } = this.current;
12157 const {
12158 a,
12159 b,
12160 c,
12161 d
12162 } = this.ctx.getTransform();
12163 let scaleX, scaleY;
12164 if (b === 0 && c === 0) {
12165 const normX = Math.abs(a);
12166 const normY = Math.abs(d);
12167 if (normX === normY) {
12168 if (lineWidth === 0) {
12169 scaleX = scaleY = 1 / normX;
12170 } else {
12171 const scaledLineWidth = normX * lineWidth;
12172 scaleX = scaleY = scaledLineWidth < 1 ? 1 / scaledLineWidth : 1;
12173 }
12174 } else if (lineWidth === 0) {
12175 scaleX = 1 / normX;
12176 scaleY = 1 / normY;
12177 } else {
12178 const scaledXLineWidth = normX * lineWidth;
12179 const scaledYLineWidth = normY * lineWidth;
12180 scaleX = scaledXLineWidth < 1 ? 1 / scaledXLineWidth : 1;
12181 scaleY = scaledYLineWidth < 1 ? 1 / scaledYLineWidth : 1;
12182 }
12183 } else {
12184 const absDet = Math.abs(a * d - b * c);
12185 const normX = Math.hypot(a, b);
12186 const normY = Math.hypot(c, d);
12187 if (lineWidth === 0) {
12188 scaleX = normY / absDet;
12189 scaleY = normX / absDet;
12190 } else {
12191 const baseArea = lineWidth * absDet;
12192 scaleX = normY > baseArea ? normY / baseArea : 1;
12193 scaleY = normX > baseArea ? normX / baseArea : 1;
12194 }
12195 }
12196 this._cachedScaleForStroking[0] = scaleX;
12197 this._cachedScaleForStroking[1] = scaleY;
12198 }
12199 return this._cachedScaleForStroking;
12200 }
12201 rescaleAndStroke(saveRestore) {
12202 const {
12203 ctx
12204 } = this;
12205 const {
12206 lineWidth
12207 } = this.current;
12208 const [scaleX, scaleY] = this.getScaleForStroking();
12209 ctx.lineWidth = lineWidth || 1;
12210 if (scaleX === 1 && scaleY === 1) {
12211 ctx.stroke();
12212 return;
12213 }
12214 const dashes = ctx.getLineDash();
12215 if (saveRestore) {
12216 ctx.save();
12217 }
12218 ctx.scale(scaleX, scaleY);
12219 if (dashes.length > 0) {
12220 const scale = Math.max(scaleX, scaleY);
12221 ctx.setLineDash(dashes.map(x => x / scale));
12222 ctx.lineDashOffset /= scale;
12223 }
12224 ctx.stroke();
12225 if (saveRestore) {
12226 ctx.restore();
12227 }
12228 }
12229 isContentVisible() {
12230 for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
12231 if (!this.markedContentStack[i].visible) {
12232 return false;
12233 }
12234 }
12235 return true;
12236 }
12237}
12238for (const op in util.OPS) {
12239 if (CanvasGraphics.prototype[op] !== undefined) {
12240 CanvasGraphics.prototype[util.OPS[op]] = CanvasGraphics.prototype[op];
12241 }
12242}
12243
12244
12245/***/ }),
12246
12247/***/ 5419:
12248/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12249
12250/* harmony export */ __webpack_require__.d(__webpack_exports__, {
12251/* harmony export */ DOMCMapReaderFactory: () => (/* binding */ DOMCMapReaderFactory),
12252/* harmony export */ DOMCanvasFactory: () => (/* binding */ DOMCanvasFactory),
12253/* harmony export */ DOMFilterFactory: () => (/* binding */ DOMFilterFactory),
12254/* harmony export */ DOMSVGFactory: () => (/* binding */ DOMSVGFactory),
12255/* harmony export */ DOMStandardFontDataFactory: () => (/* binding */ DOMStandardFontDataFactory),
12256/* harmony export */ PDFDateString: () => (/* binding */ PDFDateString),
12257/* harmony export */ PageViewport: () => (/* binding */ PageViewport),
12258/* harmony export */ PixelsPerInch: () => (/* binding */ PixelsPerInch),
12259/* harmony export */ RenderingCancelledException: () => (/* binding */ RenderingCancelledException),
12260/* harmony export */ StatTimer: () => (/* binding */ StatTimer),
12261/* harmony export */ fetchData: () => (/* binding */ fetchData),
12262/* harmony export */ getColorValues: () => (/* binding */ getColorValues),
12263/* harmony export */ getCurrentTransform: () => (/* binding */ getCurrentTransform),
12264/* harmony export */ getCurrentTransformInverse: () => (/* binding */ getCurrentTransformInverse),
12265/* harmony export */ getFilenameFromUrl: () => (/* binding */ getFilenameFromUrl),
12266/* harmony export */ getPdfFilenameFromUrl: () => (/* binding */ getPdfFilenameFromUrl),
12267/* harmony export */ getRGB: () => (/* binding */ getRGB),
12268/* harmony export */ getXfaPageViewport: () => (/* binding */ getXfaPageViewport),
12269/* harmony export */ isDataScheme: () => (/* binding */ isDataScheme),
12270/* harmony export */ isPdfFile: () => (/* binding */ isPdfFile),
12271/* harmony export */ isValidFetchUrl: () => (/* binding */ isValidFetchUrl),
12272/* harmony export */ noContextMenu: () => (/* binding */ noContextMenu),
12273/* harmony export */ setLayerDimensions: () => (/* binding */ setLayerDimensions)
12274/* harmony export */ });
12275/* unused harmony export deprecated */
12276/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
12277/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6573);
12278/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8100);
12279/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7936);
12280/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7467);
12281/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4732);
12282/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9577);
12283/* harmony import */ var core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(8992);
12284/* harmony import */ var core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4520);
12285/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1454);
12286/* harmony import */ var core_js_modules_web_url_search_params_delete_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(4603);
12287/* harmony import */ var core_js_modules_web_url_search_params_has_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(7566);
12288/* harmony import */ var core_js_modules_web_url_search_params_size_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(8721);
12289/* harmony import */ var _base_factory_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(2583);
12290/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(4292);
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306const SVG_NS = "http://www.w3.org/2000/svg";
12307class PixelsPerInch {
12308 static CSS = 96.0;
12309 static PDF = 72.0;
12310 static PDF_TO_CSS_UNITS = this.CSS / this.PDF;
12311}
12312class DOMFilterFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_13__.BaseFilterFactory {
12313 #_cache;
12314 #_defs;
12315 #docId;
12316 #document;
12317 #_hcmCache;
12318 #id = 0;
12319 constructor() {
12320 let {
12321 docId,
12322 ownerDocument = globalThis.document
12323 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12324 super();
12325 this.#docId = docId;
12326 this.#document = ownerDocument;
12327 }
12328 get #cache() {
12329 return this.#_cache ||= new Map();
12330 }
12331 get #hcmCache() {
12332 return this.#_hcmCache ||= new Map();
12333 }
12334 get #defs() {
12335 if (!this.#_defs) {
12336 const div = this.#document.createElement("div");
12337 const {
12338 style
12339 } = div;
12340 style.visibility = "hidden";
12341 style.contain = "strict";
12342 style.width = style.height = 0;
12343 style.position = "absolute";
12344 style.top = style.left = 0;
12345 style.zIndex = -1;
12346 const svg = this.#document.createElementNS(SVG_NS, "svg");
12347 svg.setAttribute("width", 0);
12348 svg.setAttribute("height", 0);
12349 this.#_defs = this.#document.createElementNS(SVG_NS, "defs");
12350 div.append(svg);
12351 svg.append(this.#_defs);
12352 this.#document.body.append(div);
12353 }
12354 return this.#_defs;
12355 }
12356 addFilter(maps) {
12357 if (!maps) {
12358 return "none";
12359 }
12360 let value = this.#cache.get(maps);
12361 if (value) {
12362 return value;
12363 }
12364 let tableR, tableG, tableB, key;
12365 if (maps.length === 1) {
12366 const mapR = maps[0];
12367 const buffer = new Array(256);
12368 for (let i = 0; i < 256; i++) {
12369 buffer[i] = mapR[i] / 255;
12370 }
12371 key = tableR = tableG = tableB = buffer.join(",");
12372 } else {
12373 const [mapR, mapG, mapB] = maps;
12374 const bufferR = new Array(256);
12375 const bufferG = new Array(256);
12376 const bufferB = new Array(256);
12377 for (let i = 0; i < 256; i++) {
12378 bufferR[i] = mapR[i] / 255;
12379 bufferG[i] = mapG[i] / 255;
12380 bufferB[i] = mapB[i] / 255;
12381 }
12382 tableR = bufferR.join(",");
12383 tableG = bufferG.join(",");
12384 tableB = bufferB.join(",");
12385 key = `${tableR}${tableG}${tableB}`;
12386 }
12387 value = this.#cache.get(key);
12388 if (value) {
12389 this.#cache.set(maps, value);
12390 return value;
12391 }
12392 const id = `g_${this.#docId}_transfer_map_${this.#id++}`;
12393 const url = `url(#${id})`;
12394 this.#cache.set(maps, url);
12395 this.#cache.set(key, url);
12396 const filter = this.#createFilter(id);
12397 this.#addTransferMapConversion(tableR, tableG, tableB, filter);
12398 return url;
12399 }
12400 addHCMFilter(fgColor, bgColor) {
12401 const key = `${fgColor}-${bgColor}`;
12402 const filterName = "base";
12403 let info = this.#hcmCache.get(filterName);
12404 if (info?.key === key) {
12405 return info.url;
12406 }
12407 if (info) {
12408 info.filter?.remove();
12409 info.key = key;
12410 info.url = "none";
12411 info.filter = null;
12412 } else {
12413 info = {
12414 key,
12415 url: "none",
12416 filter: null
12417 };
12418 this.#hcmCache.set(filterName, info);
12419 }
12420 if (!fgColor || !bgColor) {
12421 return info.url;
12422 }
12423 const fgRGB = this.#getRGB(fgColor);
12424 fgColor = _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.Util.makeHexColor(...fgRGB);
12425 const bgRGB = this.#getRGB(bgColor);
12426 bgColor = _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.Util.makeHexColor(...bgRGB);
12427 this.#defs.style.color = "";
12428 if (fgColor === "#000000" && bgColor === "#ffffff" || fgColor === bgColor) {
12429 return info.url;
12430 }
12431 const map = new Array(256);
12432 for (let i = 0; i <= 255; i++) {
12433 const x = i / 255;
12434 map[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
12435 }
12436 const table = map.join(",");
12437 const id = `g_${this.#docId}_hcm_filter`;
12438 const filter = info.filter = this.#createFilter(id);
12439 this.#addTransferMapConversion(table, table, table, filter);
12440 this.#addGrayConversion(filter);
12441 const getSteps = (c, n) => {
12442 const start = fgRGB[c] / 255;
12443 const end = bgRGB[c] / 255;
12444 const arr = new Array(n + 1);
12445 for (let i = 0; i <= n; i++) {
12446 arr[i] = start + i / n * (end - start);
12447 }
12448 return arr.join(",");
12449 };
12450 this.#addTransferMapConversion(getSteps(0, 5), getSteps(1, 5), getSteps(2, 5), filter);
12451 info.url = `url(#${id})`;
12452 return info.url;
12453 }
12454 addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
12455 const key = `${fgColor}-${bgColor}-${newFgColor}-${newBgColor}`;
12456 let info = this.#hcmCache.get(filterName);
12457 if (info?.key === key) {
12458 return info.url;
12459 }
12460 if (info) {
12461 info.filter?.remove();
12462 info.key = key;
12463 info.url = "none";
12464 info.filter = null;
12465 } else {
12466 info = {
12467 key,
12468 url: "none",
12469 filter: null
12470 };
12471 this.#hcmCache.set(filterName, info);
12472 }
12473 if (!fgColor || !bgColor) {
12474 return info.url;
12475 }
12476 const [fgRGB, bgRGB] = [fgColor, bgColor].map(this.#getRGB.bind(this));
12477 let fgGray = Math.round(0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]);
12478 let bgGray = Math.round(0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]);
12479 let [newFgRGB, newBgRGB] = [newFgColor, newBgColor].map(this.#getRGB.bind(this));
12480 if (bgGray < fgGray) {
12481 [fgGray, bgGray, newFgRGB, newBgRGB] = [bgGray, fgGray, newBgRGB, newFgRGB];
12482 }
12483 this.#defs.style.color = "";
12484 const getSteps = (fg, bg, n) => {
12485 const arr = new Array(256);
12486 const step = (bgGray - fgGray) / n;
12487 const newStart = fg / 255;
12488 const newStep = (bg - fg) / (255 * n);
12489 let prev = 0;
12490 for (let i = 0; i <= n; i++) {
12491 const k = Math.round(fgGray + i * step);
12492 const value = newStart + i * newStep;
12493 for (let j = prev; j <= k; j++) {
12494 arr[j] = value;
12495 }
12496 prev = k + 1;
12497 }
12498 for (let i = prev; i < 256; i++) {
12499 arr[i] = arr[prev - 1];
12500 }
12501 return arr.join(",");
12502 };
12503 const id = `g_${this.#docId}_hcm_${filterName}_filter`;
12504 const filter = info.filter = this.#createFilter(id);
12505 this.#addGrayConversion(filter);
12506 this.#addTransferMapConversion(getSteps(newFgRGB[0], newBgRGB[0], 5), getSteps(newFgRGB[1], newBgRGB[1], 5), getSteps(newFgRGB[2], newBgRGB[2], 5), filter);
12507 info.url = `url(#${id})`;
12508 return info.url;
12509 }
12510 destroy() {
12511 let keepHCM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
12512 if (keepHCM && this.#hcmCache.size !== 0) {
12513 return;
12514 }
12515 if (this.#_defs) {
12516 this.#_defs.parentNode.parentNode.remove();
12517 this.#_defs = null;
12518 }
12519 if (this.#_cache) {
12520 this.#_cache.clear();
12521 this.#_cache = null;
12522 }
12523 this.#id = 0;
12524 }
12525 #addGrayConversion(filter) {
12526 const feColorMatrix = this.#document.createElementNS(SVG_NS, "feColorMatrix");
12527 feColorMatrix.setAttribute("type", "matrix");
12528 feColorMatrix.setAttribute("values", "0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0");
12529 filter.append(feColorMatrix);
12530 }
12531 #createFilter(id) {
12532 const filter = this.#document.createElementNS(SVG_NS, "filter");
12533 filter.setAttribute("color-interpolation-filters", "sRGB");
12534 filter.setAttribute("id", id);
12535 this.#defs.append(filter);
12536 return filter;
12537 }
12538 #appendFeFunc(feComponentTransfer, func, table) {
12539 const feFunc = this.#document.createElementNS(SVG_NS, func);
12540 feFunc.setAttribute("type", "discrete");
12541 feFunc.setAttribute("tableValues", table);
12542 feComponentTransfer.append(feFunc);
12543 }
12544 #addTransferMapConversion(rTable, gTable, bTable, filter) {
12545 const feComponentTransfer = this.#document.createElementNS(SVG_NS, "feComponentTransfer");
12546 filter.append(feComponentTransfer);
12547 this.#appendFeFunc(feComponentTransfer, "feFuncR", rTable);
12548 this.#appendFeFunc(feComponentTransfer, "feFuncG", gTable);
12549 this.#appendFeFunc(feComponentTransfer, "feFuncB", bTable);
12550 }
12551 #getRGB(color) {
12552 this.#defs.style.color = color;
12553 return getRGB(getComputedStyle(this.#defs).getPropertyValue("color"));
12554 }
12555}
12556class DOMCanvasFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_13__.BaseCanvasFactory {
12557 constructor() {
12558 let {
12559 ownerDocument = globalThis.document
12560 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12561 super();
12562 this._document = ownerDocument;
12563 }
12564 _createCanvas(width, height) {
12565 const canvas = this._document.createElement("canvas");
12566 canvas.width = width;
12567 canvas.height = height;
12568 return canvas;
12569 }
12570}
12571async function fetchData(url) {
12572 let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "text";
12573 if (isValidFetchUrl(url, document.baseURI)) {
12574 const response = await fetch(url);
12575 if (!response.ok) {
12576 throw new Error(response.statusText);
12577 }
12578 switch (type) {
12579 case "arraybuffer":
12580 return response.arrayBuffer();
12581 case "blob":
12582 return response.blob();
12583 case "json":
12584 return response.json();
12585 }
12586 return response.text();
12587 }
12588 return new Promise((resolve, reject) => {
12589 const request = new XMLHttpRequest();
12590 request.open("GET", url, true);
12591 request.responseType = type;
12592 request.onreadystatechange = () => {
12593 if (request.readyState !== XMLHttpRequest.DONE) {
12594 return;
12595 }
12596 if (request.status === 200 || request.status === 0) {
12597 switch (type) {
12598 case "arraybuffer":
12599 case "blob":
12600 case "json":
12601 resolve(request.response);
12602 return;
12603 }
12604 resolve(request.responseText);
12605 return;
12606 }
12607 reject(new Error(request.statusText));
12608 };
12609 request.send(null);
12610 });
12611}
12612class DOMCMapReaderFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_13__.BaseCMapReaderFactory {
12613 _fetchData(url, compressionType) {
12614 return fetchData(url, this.isCompressed ? "arraybuffer" : "text").then(data => ({
12615 cMapData: data instanceof ArrayBuffer ? new Uint8Array(data) : (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_14__.stringToBytes)(data),
12616 compressionType
12617 }));
12618 }
12619}
12620class DOMStandardFontDataFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_13__.BaseStandardFontDataFactory {
12621 _fetchData(url) {
12622 return fetchData(url, "arraybuffer").then(data => new Uint8Array(data));
12623 }
12624}
12625class DOMSVGFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_13__.BaseSVGFactory {
12626 _createSVG(type) {
12627 return document.createElementNS(SVG_NS, type);
12628 }
12629}
12630class PageViewport {
12631 constructor(_ref) {
12632 let {
12633 viewBox,
12634 scale,
12635 rotation,
12636 offsetX = 0,
12637 offsetY = 0,
12638 dontFlip = false
12639 } = _ref;
12640 this.viewBox = viewBox;
12641 this.scale = scale;
12642 this.rotation = rotation;
12643 this.offsetX = offsetX;
12644 this.offsetY = offsetY;
12645 const centerX = (viewBox[2] + viewBox[0]) / 2;
12646 const centerY = (viewBox[3] + viewBox[1]) / 2;
12647 let rotateA, rotateB, rotateC, rotateD;
12648 rotation %= 360;
12649 if (rotation < 0) {
12650 rotation += 360;
12651 }
12652 switch (rotation) {
12653 case 180:
12654 rotateA = -1;
12655 rotateB = 0;
12656 rotateC = 0;
12657 rotateD = 1;
12658 break;
12659 case 90:
12660 rotateA = 0;
12661 rotateB = 1;
12662 rotateC = 1;
12663 rotateD = 0;
12664 break;
12665 case 270:
12666 rotateA = 0;
12667 rotateB = -1;
12668 rotateC = -1;
12669 rotateD = 0;
12670 break;
12671 case 0:
12672 rotateA = 1;
12673 rotateB = 0;
12674 rotateC = 0;
12675 rotateD = -1;
12676 break;
12677 default:
12678 throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
12679 }
12680 if (dontFlip) {
12681 rotateC = -rotateC;
12682 rotateD = -rotateD;
12683 }
12684 let offsetCanvasX, offsetCanvasY;
12685 let width, height;
12686 if (rotateA === 0) {
12687 offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
12688 offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
12689 width = (viewBox[3] - viewBox[1]) * scale;
12690 height = (viewBox[2] - viewBox[0]) * scale;
12691 } else {
12692 offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
12693 offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
12694 width = (viewBox[2] - viewBox[0]) * scale;
12695 height = (viewBox[3] - viewBox[1]) * scale;
12696 }
12697 this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
12698 this.width = width;
12699 this.height = height;
12700 }
12701 get rawDims() {
12702 const {
12703 viewBox
12704 } = this;
12705 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_14__.shadow)(this, "rawDims", {
12706 pageWidth: viewBox[2] - viewBox[0],
12707 pageHeight: viewBox[3] - viewBox[1],
12708 pageX: viewBox[0],
12709 pageY: viewBox[1]
12710 });
12711 }
12712 clone() {
12713 let {
12714 scale = this.scale,
12715 rotation = this.rotation,
12716 offsetX = this.offsetX,
12717 offsetY = this.offsetY,
12718 dontFlip = false
12719 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12720 return new PageViewport({
12721 viewBox: this.viewBox.slice(),
12722 scale,
12723 rotation,
12724 offsetX,
12725 offsetY,
12726 dontFlip
12727 });
12728 }
12729 convertToViewportPoint(x, y) {
12730 return _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.Util.applyTransform([x, y], this.transform);
12731 }
12732 convertToViewportRectangle(rect) {
12733 const topLeft = _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.Util.applyTransform([rect[0], rect[1]], this.transform);
12734 const bottomRight = _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.Util.applyTransform([rect[2], rect[3]], this.transform);
12735 return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
12736 }
12737 convertToPdfPoint(x, y) {
12738 return _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.Util.applyInverseTransform([x, y], this.transform);
12739 }
12740}
12741class RenderingCancelledException extends _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.BaseException {
12742 constructor(msg) {
12743 let extraDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
12744 super(msg, "RenderingCancelledException");
12745 this.extraDelay = extraDelay;
12746 }
12747}
12748function isDataScheme(url) {
12749 const ii = url.length;
12750 let i = 0;
12751 while (i < ii && url[i].trim() === "") {
12752 i++;
12753 }
12754 return url.substring(i, i + 5).toLowerCase() === "data:";
12755}
12756function isPdfFile(filename) {
12757 return typeof filename === "string" && /\.pdf$/i.test(filename);
12758}
12759function getFilenameFromUrl(url) {
12760 let onlyStripPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
12761 if (!onlyStripPath) {
12762 [url] = url.split(/[#?]/, 1);
12763 }
12764 return url.substring(url.lastIndexOf("/") + 1);
12765}
12766function getPdfFilenameFromUrl(url) {
12767 let defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
12768 if (typeof url !== "string") {
12769 return defaultFilename;
12770 }
12771 if (isDataScheme(url)) {
12772 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_14__.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
12773 return defaultFilename;
12774 }
12775 const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
12776 const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
12777 const splitURI = reURI.exec(url);
12778 let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
12779 if (suggestedFilename) {
12780 suggestedFilename = suggestedFilename[0];
12781 if (suggestedFilename.includes("%")) {
12782 try {
12783 suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
12784 } catch {}
12785 }
12786 }
12787 return suggestedFilename || defaultFilename;
12788}
12789class StatTimer {
12790 started = Object.create(null);
12791 times = [];
12792 time(name) {
12793 if (name in this.started) {
12794 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_14__.warn)(`Timer is already running for ${name}`);
12795 }
12796 this.started[name] = Date.now();
12797 }
12798 timeEnd(name) {
12799 if (!(name in this.started)) {
12800 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_14__.warn)(`Timer has not been started for ${name}`);
12801 }
12802 this.times.push({
12803 name,
12804 start: this.started[name],
12805 end: Date.now()
12806 });
12807 delete this.started[name];
12808 }
12809 toString() {
12810 const outBuf = [];
12811 let longest = 0;
12812 for (const {
12813 name
12814 } of this.times) {
12815 longest = Math.max(name.length, longest);
12816 }
12817 for (const {
12818 name,
12819 start,
12820 end
12821 } of this.times) {
12822 outBuf.push(`${name.padEnd(longest)} ${end - start}ms\n`);
12823 }
12824 return outBuf.join("");
12825 }
12826}
12827function isValidFetchUrl(url, baseUrl) {
12828 try {
12829 const {
12830 protocol
12831 } = baseUrl ? new URL(url, baseUrl) : new URL(url);
12832 return protocol === "http:" || protocol === "https:";
12833 } catch {
12834 return false;
12835 }
12836}
12837function noContextMenu(e) {
12838 e.preventDefault();
12839}
12840function deprecated(details) {
12841 console.log("Deprecated API usage: " + details);
12842}
12843let pdfDateStringRegex;
12844class PDFDateString {
12845 static toDateObject(input) {
12846 if (!input || typeof input !== "string") {
12847 return null;
12848 }
12849 pdfDateStringRegex ||= new RegExp("^D:" + "(\\d{4})" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "([Z|+|-])?" + "(\\d{2})?" + "'?" + "(\\d{2})?" + "'?");
12850 const matches = pdfDateStringRegex.exec(input);
12851 if (!matches) {
12852 return null;
12853 }
12854 const year = parseInt(matches[1], 10);
12855 let month = parseInt(matches[2], 10);
12856 month = month >= 1 && month <= 12 ? month - 1 : 0;
12857 let day = parseInt(matches[3], 10);
12858 day = day >= 1 && day <= 31 ? day : 1;
12859 let hour = parseInt(matches[4], 10);
12860 hour = hour >= 0 && hour <= 23 ? hour : 0;
12861 let minute = parseInt(matches[5], 10);
12862 minute = minute >= 0 && minute <= 59 ? minute : 0;
12863 let second = parseInt(matches[6], 10);
12864 second = second >= 0 && second <= 59 ? second : 0;
12865 const universalTimeRelation = matches[7] || "Z";
12866 let offsetHour = parseInt(matches[8], 10);
12867 offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
12868 let offsetMinute = parseInt(matches[9], 10) || 0;
12869 offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
12870 if (universalTimeRelation === "-") {
12871 hour += offsetHour;
12872 minute += offsetMinute;
12873 } else if (universalTimeRelation === "+") {
12874 hour -= offsetHour;
12875 minute -= offsetMinute;
12876 }
12877 return new Date(Date.UTC(year, month, day, hour, minute, second));
12878 }
12879}
12880function getXfaPageViewport(xfaPage, _ref2) {
12881 let {
12882 scale = 1,
12883 rotation = 0
12884 } = _ref2;
12885 const {
12886 width,
12887 height
12888 } = xfaPage.attributes.style;
12889 const viewBox = [0, 0, parseInt(width), parseInt(height)];
12890 return new PageViewport({
12891 viewBox,
12892 scale,
12893 rotation
12894 });
12895}
12896function getRGB(color) {
12897 if (color.startsWith("#")) {
12898 const colorRGB = parseInt(color.slice(1), 16);
12899 return [(colorRGB & 0xff0000) >> 16, (colorRGB & 0x00ff00) >> 8, colorRGB & 0x0000ff];
12900 }
12901 if (color.startsWith("rgb(")) {
12902 return color.slice(4, -1).split(",").map(x => parseInt(x));
12903 }
12904 if (color.startsWith("rgba(")) {
12905 return color.slice(5, -1).split(",").map(x => parseInt(x)).slice(0, 3);
12906 }
12907 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_14__.warn)(`Not a valid color format: "${color}"`);
12908 return [0, 0, 0];
12909}
12910function getColorValues(colors) {
12911 const span = document.createElement("span");
12912 span.style.visibility = "hidden";
12913 document.body.append(span);
12914 for (const name of colors.keys()) {
12915 span.style.color = name;
12916 const computedColor = window.getComputedStyle(span).color;
12917 colors.set(name, getRGB(computedColor));
12918 }
12919 span.remove();
12920}
12921function getCurrentTransform(ctx) {
12922 const {
12923 a,
12924 b,
12925 c,
12926 d,
12927 e,
12928 f
12929 } = ctx.getTransform();
12930 return [a, b, c, d, e, f];
12931}
12932function getCurrentTransformInverse(ctx) {
12933 const {
12934 a,
12935 b,
12936 c,
12937 d,
12938 e,
12939 f
12940 } = ctx.getTransform().invertSelf();
12941 return [a, b, c, d, e, f];
12942}
12943function setLayerDimensions(div, viewport) {
12944 let mustFlip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
12945 let mustRotate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
12946 if (viewport instanceof PageViewport) {
12947 const {
12948 pageWidth,
12949 pageHeight
12950 } = viewport.rawDims;
12951 const {
12952 style
12953 } = div;
12954 const useRound = _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.FeatureTest.isCSSRoundSupported;
12955 const w = `var(--scale-factor) * ${pageWidth}px`,
12956 h = `var(--scale-factor) * ${pageHeight}px`;
12957 const widthStr = useRound ? `round(${w}, 1px)` : `calc(${w})`,
12958 heightStr = useRound ? `round(${h}, 1px)` : `calc(${h})`;
12959 if (!mustFlip || viewport.rotation % 180 === 0) {
12960 style.width = widthStr;
12961 style.height = heightStr;
12962 } else {
12963 style.width = heightStr;
12964 style.height = widthStr;
12965 }
12966 }
12967 if (mustRotate) {
12968 div.setAttribute("data-main-rotation", viewport.rotation);
12969 }
12970}
12971
12972
12973/***/ }),
12974
12975/***/ 4047:
12976/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12977
12978/* harmony export */ __webpack_require__.d(__webpack_exports__, {
12979/* harmony export */ DrawLayer: () => (/* binding */ DrawLayer)
12980/* harmony export */ });
12981/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5419);
12982/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4292);
12983
12984
12985class DrawLayer {
12986 #parent = null;
12987 #id = 0;
12988 #mapping = new Map();
12989 #toUpdate = new Map();
12990 constructor(_ref) {
12991 let {
12992 pageIndex
12993 } = _ref;
12994 this.pageIndex = pageIndex;
12995 }
12996 setParent(parent) {
12997 if (!this.#parent) {
12998 this.#parent = parent;
12999 return;
13000 }
13001 if (this.#parent !== parent) {
13002 if (this.#mapping.size > 0) {
13003 for (const root of this.#mapping.values()) {
13004 root.remove();
13005 parent.append(root);
13006 }
13007 }
13008 this.#parent = parent;
13009 }
13010 }
13011 static get _svgFactory() {
13012 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_svgFactory", new _display_utils_js__WEBPACK_IMPORTED_MODULE_0__.DOMSVGFactory());
13013 }
13014 static #setBox(element) {
13015 let {
13016 x = 0,
13017 y = 0,
13018 width = 1,
13019 height = 1
13020 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13021 const {
13022 style
13023 } = element;
13024 style.top = `${100 * y}%`;
13025 style.left = `${100 * x}%`;
13026 style.width = `${100 * width}%`;
13027 style.height = `${100 * height}%`;
13028 }
13029 #createSVG(box) {
13030 const svg = DrawLayer._svgFactory.create(1, 1, true);
13031 this.#parent.append(svg);
13032 svg.setAttribute("aria-hidden", true);
13033 DrawLayer.#setBox(svg, box);
13034 return svg;
13035 }
13036 #createClipPath(defs, pathId) {
13037 const clipPath = DrawLayer._svgFactory.createElement("clipPath");
13038 defs.append(clipPath);
13039 const clipPathId = `clip_${pathId}`;
13040 clipPath.setAttribute("id", clipPathId);
13041 clipPath.setAttribute("clipPathUnits", "objectBoundingBox");
13042 const clipPathUse = DrawLayer._svgFactory.createElement("use");
13043 clipPath.append(clipPathUse);
13044 clipPathUse.setAttribute("href", `#${pathId}`);
13045 clipPathUse.classList.add("clip");
13046 return clipPathId;
13047 }
13048 highlight(outlines, color, opacity) {
13049 let isPathUpdatable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
13050 const id = this.#id++;
13051 const root = this.#createSVG(outlines.box);
13052 root.classList.add("highlight");
13053 if (outlines.free) {
13054 root.classList.add("free");
13055 }
13056 const defs = DrawLayer._svgFactory.createElement("defs");
13057 root.append(defs);
13058 const path = DrawLayer._svgFactory.createElement("path");
13059 defs.append(path);
13060 const pathId = `path_p${this.pageIndex}_${id}`;
13061 path.setAttribute("id", pathId);
13062 path.setAttribute("d", outlines.toSVGPath());
13063 if (isPathUpdatable) {
13064 this.#toUpdate.set(id, path);
13065 }
13066 const clipPathId = this.#createClipPath(defs, pathId);
13067 const use = DrawLayer._svgFactory.createElement("use");
13068 root.append(use);
13069 root.setAttribute("fill", color);
13070 root.setAttribute("fill-opacity", opacity);
13071 use.setAttribute("href", `#${pathId}`);
13072 this.#mapping.set(id, root);
13073 return {
13074 id,
13075 clipPathId: `url(#${clipPathId})`
13076 };
13077 }
13078 highlightOutline(outlines) {
13079 const id = this.#id++;
13080 const root = this.#createSVG(outlines.box);
13081 root.classList.add("highlightOutline");
13082 const defs = DrawLayer._svgFactory.createElement("defs");
13083 root.append(defs);
13084 const path = DrawLayer._svgFactory.createElement("path");
13085 defs.append(path);
13086 const pathId = `path_p${this.pageIndex}_${id}`;
13087 path.setAttribute("id", pathId);
13088 path.setAttribute("d", outlines.toSVGPath());
13089 path.setAttribute("vector-effect", "non-scaling-stroke");
13090 let maskId;
13091 if (outlines.free) {
13092 root.classList.add("free");
13093 const mask = DrawLayer._svgFactory.createElement("mask");
13094 defs.append(mask);
13095 maskId = `mask_p${this.pageIndex}_${id}`;
13096 mask.setAttribute("id", maskId);
13097 mask.setAttribute("maskUnits", "objectBoundingBox");
13098 const rect = DrawLayer._svgFactory.createElement("rect");
13099 mask.append(rect);
13100 rect.setAttribute("width", "1");
13101 rect.setAttribute("height", "1");
13102 rect.setAttribute("fill", "white");
13103 const use = DrawLayer._svgFactory.createElement("use");
13104 mask.append(use);
13105 use.setAttribute("href", `#${pathId}`);
13106 use.setAttribute("stroke", "none");
13107 use.setAttribute("fill", "black");
13108 use.setAttribute("fill-rule", "nonzero");
13109 use.classList.add("mask");
13110 }
13111 const use1 = DrawLayer._svgFactory.createElement("use");
13112 root.append(use1);
13113 use1.setAttribute("href", `#${pathId}`);
13114 if (maskId) {
13115 use1.setAttribute("mask", `url(#${maskId})`);
13116 }
13117 const use2 = use1.cloneNode();
13118 root.append(use2);
13119 use1.classList.add("mainOutline");
13120 use2.classList.add("secondaryOutline");
13121 this.#mapping.set(id, root);
13122 return id;
13123 }
13124 finalizeLine(id, line) {
13125 const path = this.#toUpdate.get(id);
13126 this.#toUpdate.delete(id);
13127 this.updateBox(id, line.box);
13128 path.setAttribute("d", line.toSVGPath());
13129 }
13130 updateLine(id, line) {
13131 const root = this.#mapping.get(id);
13132 const defs = root.firstChild;
13133 const path = defs.firstChild;
13134 path.setAttribute("d", line.toSVGPath());
13135 }
13136 removeFreeHighlight(id) {
13137 this.remove(id);
13138 this.#toUpdate.delete(id);
13139 }
13140 updatePath(id, line) {
13141 this.#toUpdate.get(id).setAttribute("d", line.toSVGPath());
13142 }
13143 updateBox(id, box) {
13144 DrawLayer.#setBox(this.#mapping.get(id), box);
13145 }
13146 show(id, visible) {
13147 this.#mapping.get(id).classList.toggle("hidden", !visible);
13148 }
13149 rotate(id, angle) {
13150 this.#mapping.get(id).setAttribute("data-main-rotation", angle);
13151 }
13152 changeColor(id, color) {
13153 this.#mapping.get(id).setAttribute("fill", color);
13154 }
13155 changeOpacity(id, opacity) {
13156 this.#mapping.get(id).setAttribute("fill-opacity", opacity);
13157 }
13158 addClass(id, className) {
13159 this.#mapping.get(id).classList.add(className);
13160 }
13161 removeClass(id, className) {
13162 this.#mapping.get(id).classList.remove(className);
13163 }
13164 remove(id) {
13165 if (this.#parent === null) {
13166 return;
13167 }
13168 this.#mapping.get(id).remove();
13169 this.#mapping.delete(id);
13170 }
13171 destroy() {
13172 this.#parent = null;
13173 for (const root of this.#mapping.values()) {
13174 root.remove();
13175 }
13176 this.#mapping.clear();
13177 }
13178}
13179
13180
13181/***/ }),
13182
13183/***/ 9731:
13184/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13185
13186
13187// EXPORTS
13188__webpack_require__.d(__webpack_exports__, {
13189 AnnotationEditorLayer: () => (/* binding */ AnnotationEditorLayer)
13190});
13191
13192// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.map.js
13193var esnext_iterator_map = __webpack_require__(1454);
13194// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.difference.v2.js
13195var esnext_set_difference_v2 = __webpack_require__(3375);
13196// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.intersection.v2.js
13197var esnext_set_intersection_v2 = __webpack_require__(9225);
13198// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-disjoint-from.v2.js
13199var esnext_set_is_disjoint_from_v2 = __webpack_require__(3972);
13200// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-subset-of.v2.js
13201var esnext_set_is_subset_of_v2 = __webpack_require__(9209);
13202// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-superset-of.v2.js
13203var esnext_set_is_superset_of_v2 = __webpack_require__(5714);
13204// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.symmetric-difference.v2.js
13205var esnext_set_symmetric_difference_v2 = __webpack_require__(7561);
13206// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.union.v2.js
13207var esnext_set_union_v2 = __webpack_require__(6197);
13208// EXTERNAL MODULE: ./src/shared/util.js
13209var util = __webpack_require__(4292);
13210// EXTERNAL MODULE: ./src/display/editor/editor.js + 1 modules
13211var editor_editor = __webpack_require__(310);
13212// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
13213var es_array_push = __webpack_require__(4114);
13214// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.constructor.js
13215var esnext_iterator_constructor = __webpack_require__(8992);
13216// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.some.js
13217var esnext_iterator_some = __webpack_require__(7550);
13218// EXTERNAL MODULE: ./src/display/editor/tools.js
13219var tools = __webpack_require__(7830);
13220// EXTERNAL MODULE: ./src/display/annotation_layer.js + 1 modules
13221var annotation_layer = __webpack_require__(6976);
13222;// CONCATENATED MODULE: ./src/display/editor/freetext.js
13223
13224
13225
13226
13227
13228
13229
13230const EOL_PATTERN = /\r\n?|\n/g;
13231class FreeTextEditor extends editor_editor.AnnotationEditor {
13232 #boundEditorDivBlur = this.editorDivBlur.bind(this);
13233 #boundEditorDivFocus = this.editorDivFocus.bind(this);
13234 #boundEditorDivInput = this.editorDivInput.bind(this);
13235 #boundEditorDivKeydown = this.editorDivKeydown.bind(this);
13236 #boundEditorDivPaste = this.editorDivPaste.bind(this);
13237 #color;
13238 #content = "";
13239 #editorDivId = `${this.id}-editor`;
13240 #fontSize;
13241 #initialData = null;
13242 static _freeTextDefaultContent = "";
13243 static _internalPadding = 0;
13244 static _defaultColor = null;
13245 static _defaultFontSize = 10;
13246 static get _keyboardManager() {
13247 const proto = FreeTextEditor.prototype;
13248 const arrowChecker = self => self.isEmpty();
13249 const small = tools.AnnotationEditorUIManager.TRANSLATE_SMALL;
13250 const big = tools.AnnotationEditorUIManager.TRANSLATE_BIG;
13251 return (0,util.shadow)(this, "_keyboardManager", new tools.KeyboardManager([[["ctrl+s", "mac+meta+s", "ctrl+p", "mac+meta+p"], proto.commitOrRemove, {
13252 bubbles: true
13253 }], [["ctrl+Enter", "mac+meta+Enter", "Escape", "mac+Escape"], proto.commitOrRemove], [["ArrowLeft", "mac+ArrowLeft"], proto._translateEmpty, {
13254 args: [-small, 0],
13255 checker: arrowChecker
13256 }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], proto._translateEmpty, {
13257 args: [-big, 0],
13258 checker: arrowChecker
13259 }], [["ArrowRight", "mac+ArrowRight"], proto._translateEmpty, {
13260 args: [small, 0],
13261 checker: arrowChecker
13262 }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], proto._translateEmpty, {
13263 args: [big, 0],
13264 checker: arrowChecker
13265 }], [["ArrowUp", "mac+ArrowUp"], proto._translateEmpty, {
13266 args: [0, -small],
13267 checker: arrowChecker
13268 }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], proto._translateEmpty, {
13269 args: [0, -big],
13270 checker: arrowChecker
13271 }], [["ArrowDown", "mac+ArrowDown"], proto._translateEmpty, {
13272 args: [0, small],
13273 checker: arrowChecker
13274 }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], proto._translateEmpty, {
13275 args: [0, big],
13276 checker: arrowChecker
13277 }]]));
13278 }
13279 static _type = "freetext";
13280 static _editorType = util.AnnotationEditorType.FREETEXT;
13281 constructor(params) {
13282 super({
13283 ...params,
13284 name: "freeTextEditor"
13285 });
13286 this.#color = params.color || FreeTextEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor;
13287 this.#fontSize = params.fontSize || FreeTextEditor._defaultFontSize;
13288 }
13289 static initialize(l10n, uiManager) {
13290 editor_editor.AnnotationEditor.initialize(l10n, uiManager, {
13291 strings: ["pdfjs-free-text-default-content"]
13292 });
13293 const style = getComputedStyle(document.documentElement);
13294 this._internalPadding = parseFloat(style.getPropertyValue("--freetext-padding"));
13295 }
13296 static updateDefaultParams(type, value) {
13297 switch (type) {
13298 case util.AnnotationEditorParamsType.FREETEXT_SIZE:
13299 FreeTextEditor._defaultFontSize = value;
13300 break;
13301 case util.AnnotationEditorParamsType.FREETEXT_COLOR:
13302 FreeTextEditor._defaultColor = value;
13303 break;
13304 }
13305 }
13306 updateParams(type, value) {
13307 switch (type) {
13308 case util.AnnotationEditorParamsType.FREETEXT_SIZE:
13309 this.#updateFontSize(value);
13310 break;
13311 case util.AnnotationEditorParamsType.FREETEXT_COLOR:
13312 this.#updateColor(value);
13313 break;
13314 }
13315 }
13316 static get defaultPropertiesToUpdate() {
13317 return [[util.AnnotationEditorParamsType.FREETEXT_SIZE, FreeTextEditor._defaultFontSize], [util.AnnotationEditorParamsType.FREETEXT_COLOR, FreeTextEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor]];
13318 }
13319 get propertiesToUpdate() {
13320 return [[util.AnnotationEditorParamsType.FREETEXT_SIZE, this.#fontSize], [util.AnnotationEditorParamsType.FREETEXT_COLOR, this.#color]];
13321 }
13322 #updateFontSize(fontSize) {
13323 const setFontsize = size => {
13324 this.editorDiv.style.fontSize = `calc(${size}px * var(--scale-factor))`;
13325 this.translate(0, -(size - this.#fontSize) * this.parentScale);
13326 this.#fontSize = size;
13327 this.#setEditorDimensions();
13328 };
13329 const savedFontsize = this.#fontSize;
13330 this.addCommands({
13331 cmd: setFontsize.bind(this, fontSize),
13332 undo: setFontsize.bind(this, savedFontsize),
13333 post: this._uiManager.updateUI.bind(this._uiManager, this),
13334 mustExec: true,
13335 type: util.AnnotationEditorParamsType.FREETEXT_SIZE,
13336 overwriteIfSameType: true,
13337 keepUndo: true
13338 });
13339 }
13340 #updateColor(color) {
13341 const setColor = col => {
13342 this.#color = this.editorDiv.style.color = col;
13343 };
13344 const savedColor = this.#color;
13345 this.addCommands({
13346 cmd: setColor.bind(this, color),
13347 undo: setColor.bind(this, savedColor),
13348 post: this._uiManager.updateUI.bind(this._uiManager, this),
13349 mustExec: true,
13350 type: util.AnnotationEditorParamsType.FREETEXT_COLOR,
13351 overwriteIfSameType: true,
13352 keepUndo: true
13353 });
13354 }
13355 _translateEmpty(x, y) {
13356 this._uiManager.translateSelectedEditors(x, y, true);
13357 }
13358 getInitialTranslation() {
13359 const scale = this.parentScale;
13360 return [-FreeTextEditor._internalPadding * scale, -(FreeTextEditor._internalPadding + this.#fontSize) * scale];
13361 }
13362 rebuild() {
13363 if (!this.parent) {
13364 return;
13365 }
13366 super.rebuild();
13367 if (this.div === null) {
13368 return;
13369 }
13370 if (!this.isAttachedToDOM) {
13371 this.parent.add(this);
13372 }
13373 }
13374 enableEditMode() {
13375 if (this.isInEditMode()) {
13376 return;
13377 }
13378 this.parent.setEditingState(false);
13379 this.parent.updateToolbar(util.AnnotationEditorType.FREETEXT);
13380 super.enableEditMode();
13381 this.overlayDiv.classList.remove("enabled");
13382 this.editorDiv.contentEditable = true;
13383 this._isDraggable = false;
13384 this.div.removeAttribute("aria-activedescendant");
13385 this.editorDiv.addEventListener("keydown", this.#boundEditorDivKeydown);
13386 this.editorDiv.addEventListener("focus", this.#boundEditorDivFocus);
13387 this.editorDiv.addEventListener("blur", this.#boundEditorDivBlur);
13388 this.editorDiv.addEventListener("input", this.#boundEditorDivInput);
13389 this.editorDiv.addEventListener("paste", this.#boundEditorDivPaste);
13390 }
13391 disableEditMode() {
13392 if (!this.isInEditMode()) {
13393 return;
13394 }
13395 this.parent.setEditingState(true);
13396 super.disableEditMode();
13397 this.overlayDiv.classList.add("enabled");
13398 this.editorDiv.contentEditable = false;
13399 this.div.setAttribute("aria-activedescendant", this.#editorDivId);
13400 this._isDraggable = true;
13401 this.editorDiv.removeEventListener("keydown", this.#boundEditorDivKeydown);
13402 this.editorDiv.removeEventListener("focus", this.#boundEditorDivFocus);
13403 this.editorDiv.removeEventListener("blur", this.#boundEditorDivBlur);
13404 this.editorDiv.removeEventListener("input", this.#boundEditorDivInput);
13405 this.editorDiv.removeEventListener("paste", this.#boundEditorDivPaste);
13406 this.div.focus({
13407 preventScroll: true
13408 });
13409 this.isEditing = false;
13410 this.parent.div.classList.add("freetextEditing");
13411 }
13412 focusin(event) {
13413 if (!this._focusEventsAllowed) {
13414 return;
13415 }
13416 super.focusin(event);
13417 if (event.target !== this.editorDiv) {
13418 this.editorDiv.focus();
13419 }
13420 }
13421 onceAdded() {
13422 if (this.width) {
13423 return;
13424 }
13425 this.enableEditMode();
13426 this.editorDiv.focus();
13427 if (this._initialOptions?.isCentered) {
13428 this.center();
13429 }
13430 this._initialOptions = null;
13431 }
13432 isEmpty() {
13433 return !this.editorDiv || this.editorDiv.innerText.trim() === "";
13434 }
13435 remove() {
13436 this.isEditing = false;
13437 if (this.parent) {
13438 this.parent.setEditingState(true);
13439 this.parent.div.classList.add("freetextEditing");
13440 }
13441 super.remove();
13442 }
13443 #extractText() {
13444 const buffer = [];
13445 this.editorDiv.normalize();
13446 for (const child of this.editorDiv.childNodes) {
13447 buffer.push(FreeTextEditor.#getNodeContent(child));
13448 }
13449 return buffer.join("\n");
13450 }
13451 #setEditorDimensions() {
13452 const [parentWidth, parentHeight] = this.parentDimensions;
13453 let rect;
13454 if (this.isAttachedToDOM) {
13455 rect = this.div.getBoundingClientRect();
13456 } else {
13457 const {
13458 currentLayer,
13459 div
13460 } = this;
13461 const savedDisplay = div.style.display;
13462 div.style.display = "hidden";
13463 currentLayer.div.append(this.div);
13464 rect = div.getBoundingClientRect();
13465 div.remove();
13466 div.style.display = savedDisplay;
13467 }
13468 if (this.rotation % 180 === this.parentRotation % 180) {
13469 this.width = rect.width / parentWidth;
13470 this.height = rect.height / parentHeight;
13471 } else {
13472 this.width = rect.height / parentWidth;
13473 this.height = rect.width / parentHeight;
13474 }
13475 this.fixAndSetPosition();
13476 }
13477 commit() {
13478 if (!this.isInEditMode()) {
13479 return;
13480 }
13481 super.commit();
13482 this.disableEditMode();
13483 const savedText = this.#content;
13484 const newText = this.#content = this.#extractText().trimEnd();
13485 if (savedText === newText) {
13486 return;
13487 }
13488 const setText = text => {
13489 this.#content = text;
13490 if (!text) {
13491 this.remove();
13492 return;
13493 }
13494 this.#setContent();
13495 this._uiManager.rebuild(this);
13496 this.#setEditorDimensions();
13497 };
13498 this.addCommands({
13499 cmd: () => {
13500 setText(newText);
13501 },
13502 undo: () => {
13503 setText(savedText);
13504 },
13505 mustExec: false
13506 });
13507 this.#setEditorDimensions();
13508 }
13509 shouldGetKeyboardEvents() {
13510 return this.isInEditMode();
13511 }
13512 enterInEditMode() {
13513 this.enableEditMode();
13514 this.editorDiv.focus();
13515 }
13516 dblclick(event) {
13517 this.enterInEditMode();
13518 }
13519 keydown(event) {
13520 if (event.target === this.div && event.key === "Enter") {
13521 this.enterInEditMode();
13522 event.preventDefault();
13523 }
13524 }
13525 editorDivKeydown(event) {
13526 FreeTextEditor._keyboardManager.exec(this, event);
13527 }
13528 editorDivFocus(event) {
13529 this.isEditing = true;
13530 }
13531 editorDivBlur(event) {
13532 this.isEditing = false;
13533 }
13534 editorDivInput(event) {
13535 this.parent.div.classList.toggle("freetextEditing", this.isEmpty());
13536 }
13537 disableEditing() {
13538 this.editorDiv.setAttribute("role", "comment");
13539 this.editorDiv.removeAttribute("aria-multiline");
13540 }
13541 enableEditing() {
13542 this.editorDiv.setAttribute("role", "textbox");
13543 this.editorDiv.setAttribute("aria-multiline", true);
13544 }
13545 render() {
13546 if (this.div) {
13547 return this.div;
13548 }
13549 let baseX, baseY;
13550 if (this.width) {
13551 baseX = this.x;
13552 baseY = this.y;
13553 }
13554 super.render();
13555 this.editorDiv = document.createElement("div");
13556 this.editorDiv.className = "internal";
13557 this.editorDiv.setAttribute("id", this.#editorDivId);
13558 this.editorDiv.setAttribute("data-l10n-id", "pdfjs-free-text");
13559 this.enableEditing();
13560 editor_editor.AnnotationEditor._l10nPromise.get("pdfjs-free-text-default-content").then(msg => this.editorDiv?.setAttribute("default-content", msg));
13561 this.editorDiv.contentEditable = true;
13562 const {
13563 style
13564 } = this.editorDiv;
13565 style.fontSize = `calc(${this.#fontSize}px * var(--scale-factor))`;
13566 style.color = this.#color;
13567 this.div.append(this.editorDiv);
13568 this.overlayDiv = document.createElement("div");
13569 this.overlayDiv.classList.add("overlay", "enabled");
13570 this.div.append(this.overlayDiv);
13571 (0,tools.bindEvents)(this, this.div, ["dblclick", "keydown"]);
13572 if (this.width) {
13573 const [parentWidth, parentHeight] = this.parentDimensions;
13574 if (this.annotationElementId) {
13575 const {
13576 position
13577 } = this.#initialData;
13578 let [tx, ty] = this.getInitialTranslation();
13579 [tx, ty] = this.pageTranslationToScreen(tx, ty);
13580 const [pageWidth, pageHeight] = this.pageDimensions;
13581 const [pageX, pageY] = this.pageTranslation;
13582 let posX, posY;
13583 switch (this.rotation) {
13584 case 0:
13585 posX = baseX + (position[0] - pageX) / pageWidth;
13586 posY = baseY + this.height - (position[1] - pageY) / pageHeight;
13587 break;
13588 case 90:
13589 posX = baseX + (position[0] - pageX) / pageWidth;
13590 posY = baseY - (position[1] - pageY) / pageHeight;
13591 [tx, ty] = [ty, -tx];
13592 break;
13593 case 180:
13594 posX = baseX - this.width + (position[0] - pageX) / pageWidth;
13595 posY = baseY - (position[1] - pageY) / pageHeight;
13596 [tx, ty] = [-tx, -ty];
13597 break;
13598 case 270:
13599 posX = baseX + (position[0] - pageX - this.height * pageHeight) / pageWidth;
13600 posY = baseY + (position[1] - pageY - this.width * pageWidth) / pageHeight;
13601 [tx, ty] = [-ty, tx];
13602 break;
13603 }
13604 this.setAt(posX * parentWidth, posY * parentHeight, tx, ty);
13605 } else {
13606 this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
13607 }
13608 this.#setContent();
13609 this._isDraggable = true;
13610 this.editorDiv.contentEditable = false;
13611 } else {
13612 this._isDraggable = false;
13613 this.editorDiv.contentEditable = true;
13614 }
13615 return this.div;
13616 }
13617 static #getNodeContent(node) {
13618 return (node.nodeType === Node.TEXT_NODE ? node.nodeValue : node.innerText).replaceAll(EOL_PATTERN, "");
13619 }
13620 editorDivPaste(event) {
13621 const clipboardData = event.clipboardData || window.clipboardData;
13622 const {
13623 types
13624 } = clipboardData;
13625 if (types.length === 1 && types[0] === "text/plain") {
13626 return;
13627 }
13628 event.preventDefault();
13629 const paste = FreeTextEditor.#deserializeContent(clipboardData.getData("text") || "").replaceAll(EOL_PATTERN, "\n");
13630 if (!paste) {
13631 return;
13632 }
13633 const selection = window.getSelection();
13634 if (!selection.rangeCount) {
13635 return;
13636 }
13637 this.editorDiv.normalize();
13638 selection.deleteFromDocument();
13639 const range = selection.getRangeAt(0);
13640 if (!paste.includes("\n")) {
13641 range.insertNode(document.createTextNode(paste));
13642 this.editorDiv.normalize();
13643 selection.collapseToStart();
13644 return;
13645 }
13646 const {
13647 startContainer,
13648 startOffset
13649 } = range;
13650 const bufferBefore = [];
13651 const bufferAfter = [];
13652 if (startContainer.nodeType === Node.TEXT_NODE) {
13653 const parent = startContainer.parentElement;
13654 bufferAfter.push(startContainer.nodeValue.slice(startOffset).replaceAll(EOL_PATTERN, ""));
13655 if (parent !== this.editorDiv) {
13656 let buffer = bufferBefore;
13657 for (const child of this.editorDiv.childNodes) {
13658 if (child === parent) {
13659 buffer = bufferAfter;
13660 continue;
13661 }
13662 buffer.push(FreeTextEditor.#getNodeContent(child));
13663 }
13664 }
13665 bufferBefore.push(startContainer.nodeValue.slice(0, startOffset).replaceAll(EOL_PATTERN, ""));
13666 } else if (startContainer === this.editorDiv) {
13667 let buffer = bufferBefore;
13668 let i = 0;
13669 for (const child of this.editorDiv.childNodes) {
13670 if (i++ === startOffset) {
13671 buffer = bufferAfter;
13672 }
13673 buffer.push(FreeTextEditor.#getNodeContent(child));
13674 }
13675 }
13676 this.#content = `${bufferBefore.join("\n")}${paste}${bufferAfter.join("\n")}`;
13677 this.#setContent();
13678 const newRange = new Range();
13679 let beforeLength = bufferBefore.reduce((acc, line) => acc + line.length, 0);
13680 for (const {
13681 firstChild
13682 } of this.editorDiv.childNodes) {
13683 if (firstChild.nodeType === Node.TEXT_NODE) {
13684 const length = firstChild.nodeValue.length;
13685 if (beforeLength <= length) {
13686 newRange.setStart(firstChild, beforeLength);
13687 newRange.setEnd(firstChild, beforeLength);
13688 break;
13689 }
13690 beforeLength -= length;
13691 }
13692 }
13693 selection.removeAllRanges();
13694 selection.addRange(newRange);
13695 }
13696 #setContent() {
13697 this.editorDiv.replaceChildren();
13698 if (!this.#content) {
13699 return;
13700 }
13701 for (const line of this.#content.split("\n")) {
13702 const div = document.createElement("div");
13703 div.append(line ? document.createTextNode(line) : document.createElement("br"));
13704 this.editorDiv.append(div);
13705 }
13706 }
13707 #serializeContent() {
13708 return this.#content.replaceAll("\xa0", " ");
13709 }
13710 static #deserializeContent(content) {
13711 return content.replaceAll(" ", "\xa0");
13712 }
13713 get contentDiv() {
13714 return this.editorDiv;
13715 }
13716 static deserialize(data, parent, uiManager) {
13717 let initialData = null;
13718 if (data instanceof annotation_layer.FreeTextAnnotationElement) {
13719 const {
13720 data: {
13721 defaultAppearanceData: {
13722 fontSize,
13723 fontColor
13724 },
13725 rect,
13726 rotation,
13727 id
13728 },
13729 textContent,
13730 textPosition,
13731 parent: {
13732 page: {
13733 pageNumber
13734 }
13735 }
13736 } = data;
13737 if (!textContent || textContent.length === 0) {
13738 return null;
13739 }
13740 initialData = data = {
13741 annotationType: util.AnnotationEditorType.FREETEXT,
13742 color: Array.from(fontColor),
13743 fontSize,
13744 value: textContent.join("\n"),
13745 position: textPosition,
13746 pageIndex: pageNumber - 1,
13747 rect,
13748 rotation,
13749 id,
13750 deleted: false
13751 };
13752 }
13753 const editor = super.deserialize(data, parent, uiManager);
13754 editor.#fontSize = data.fontSize;
13755 editor.#color = util.Util.makeHexColor(...data.color);
13756 editor.#content = FreeTextEditor.#deserializeContent(data.value);
13757 editor.annotationElementId = data.id || null;
13758 editor.#initialData = initialData;
13759 return editor;
13760 }
13761 serialize() {
13762 let isForCopying = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
13763 if (this.isEmpty()) {
13764 return null;
13765 }
13766 if (this.deleted) {
13767 return {
13768 pageIndex: this.pageIndex,
13769 id: this.annotationElementId,
13770 deleted: true
13771 };
13772 }
13773 const padding = FreeTextEditor._internalPadding * this.parentScale;
13774 const rect = this.getRect(padding, padding);
13775 const color = editor_editor.AnnotationEditor._colorManager.convert(this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : this.#color);
13776 const serialized = {
13777 annotationType: util.AnnotationEditorType.FREETEXT,
13778 color,
13779 fontSize: this.#fontSize,
13780 value: this.#serializeContent(),
13781 pageIndex: this.pageIndex,
13782 rect,
13783 rotation: this.rotation,
13784 structTreeParentId: this._structTreeParentId
13785 };
13786 if (isForCopying) {
13787 return serialized;
13788 }
13789 if (this.annotationElementId && !this.#hasElementChanged(serialized)) {
13790 return null;
13791 }
13792 serialized.id = this.annotationElementId;
13793 return serialized;
13794 }
13795 #hasElementChanged(serialized) {
13796 const {
13797 value,
13798 fontSize,
13799 color,
13800 pageIndex
13801 } = this.#initialData;
13802 return this._hasBeenMoved || serialized.value !== value || serialized.fontSize !== fontSize || serialized.color.some((c, i) => c !== color[i]) || serialized.pageIndex !== pageIndex;
13803 }
13804}
13805
13806// EXTERNAL MODULE: ./src/display/editor/outliner.js
13807var editor_outliner = __webpack_require__(4061);
13808// EXTERNAL MODULE: ./src/display/editor/color_picker.js
13809var color_picker = __webpack_require__(2259);
13810// EXTERNAL MODULE: ./src/display/display_utils.js
13811var display_utils = __webpack_require__(5419);
13812;// CONCATENATED MODULE: ./src/display/editor/highlight.js
13813
13814
13815
13816
13817
13818
13819
13820class HighlightEditor extends editor_editor.AnnotationEditor {
13821 #anchorNode = null;
13822 #anchorOffset = 0;
13823 #boxes;
13824 #clipPathId = null;
13825 #colorPicker = null;
13826 #focusOutlines = null;
13827 #focusNode = null;
13828 #focusOffset = 0;
13829 #highlightDiv = null;
13830 #highlightOutlines = null;
13831 #id = null;
13832 #isFreeHighlight = false;
13833 #boundKeydown = this.#keydown.bind(this);
13834 #lastPoint = null;
13835 #opacity;
13836 #outlineId = null;
13837 #text = "";
13838 #thickness;
13839 #methodOfCreation = "";
13840 static _defaultColor = null;
13841 static _defaultOpacity = 1;
13842 static _defaultThickness = 12;
13843 static _l10nPromise;
13844 static _type = "highlight";
13845 static _editorType = util.AnnotationEditorType.HIGHLIGHT;
13846 static _freeHighlightId = -1;
13847 static _freeHighlight = null;
13848 static _freeHighlightClipId = "";
13849 static get _keyboardManager() {
13850 const proto = HighlightEditor.prototype;
13851 return (0,util.shadow)(this, "_keyboardManager", new tools.KeyboardManager([[["ArrowLeft", "mac+ArrowLeft"], proto._moveCaret, {
13852 args: [0]
13853 }], [["ArrowRight", "mac+ArrowRight"], proto._moveCaret, {
13854 args: [1]
13855 }], [["ArrowUp", "mac+ArrowUp"], proto._moveCaret, {
13856 args: [2]
13857 }], [["ArrowDown", "mac+ArrowDown"], proto._moveCaret, {
13858 args: [3]
13859 }]]));
13860 }
13861 constructor(params) {
13862 super({
13863 ...params,
13864 name: "highlightEditor"
13865 });
13866 this.color = params.color || HighlightEditor._defaultColor;
13867 this.#thickness = params.thickness || HighlightEditor._defaultThickness;
13868 this.#opacity = params.opacity || HighlightEditor._defaultOpacity;
13869 this.#boxes = params.boxes || null;
13870 this.#methodOfCreation = params.methodOfCreation || "";
13871 this.#text = params.text || "";
13872 this._isDraggable = false;
13873 if (params.highlightId > -1) {
13874 this.#isFreeHighlight = true;
13875 this.#createFreeOutlines(params);
13876 this.#addToDrawLayer();
13877 } else {
13878 this.#anchorNode = params.anchorNode;
13879 this.#anchorOffset = params.anchorOffset;
13880 this.#focusNode = params.focusNode;
13881 this.#focusOffset = params.focusOffset;
13882 this.#createOutlines();
13883 this.#addToDrawLayer();
13884 this.rotate(this.rotation);
13885 }
13886 }
13887 get telemetryInitialData() {
13888 return {
13889 action: "added",
13890 type: this.#isFreeHighlight ? "free_highlight" : "highlight",
13891 color: this._uiManager.highlightColorNames.get(this.color),
13892 thickness: this.#thickness,
13893 methodOfCreation: this.#methodOfCreation
13894 };
13895 }
13896 get telemetryFinalData() {
13897 return {
13898 type: "highlight",
13899 color: this._uiManager.highlightColorNames.get(this.color)
13900 };
13901 }
13902 static computeTelemetryFinalData(data) {
13903 return {
13904 numberOfColors: data.get("color").size
13905 };
13906 }
13907 #createOutlines() {
13908 const outliner = new editor_outliner.Outliner(this.#boxes, 0.001);
13909 this.#highlightOutlines = outliner.getOutlines();
13910 ({
13911 x: this.x,
13912 y: this.y,
13913 width: this.width,
13914 height: this.height
13915 } = this.#highlightOutlines.box);
13916 const outlinerForOutline = new editor_outliner.Outliner(this.#boxes, 0.0025, 0.001, this._uiManager.direction === "ltr");
13917 this.#focusOutlines = outlinerForOutline.getOutlines();
13918 const {
13919 lastPoint
13920 } = this.#focusOutlines.box;
13921 this.#lastPoint = [(lastPoint[0] - this.x) / this.width, (lastPoint[1] - this.y) / this.height];
13922 }
13923 #createFreeOutlines(_ref) {
13924 let {
13925 highlightOutlines,
13926 highlightId,
13927 clipPathId
13928 } = _ref;
13929 this.#highlightOutlines = highlightOutlines;
13930 const extraThickness = 1.5;
13931 this.#focusOutlines = highlightOutlines.getNewOutline(this.#thickness / 2 + extraThickness, 0.0025);
13932 if (highlightId >= 0) {
13933 this.#id = highlightId;
13934 this.#clipPathId = clipPathId;
13935 this.parent.drawLayer.finalizeLine(highlightId, highlightOutlines);
13936 this.#outlineId = this.parent.drawLayer.highlightOutline(this.#focusOutlines);
13937 } else if (this.parent) {
13938 const angle = this.parent.viewport.rotation;
13939 this.parent.drawLayer.updateLine(this.#id, highlightOutlines);
13940 this.parent.drawLayer.updateBox(this.#id, HighlightEditor.#rotateBbox(this.#highlightOutlines.box, (angle - this.rotation + 360) % 360));
13941 this.parent.drawLayer.updateLine(this.#outlineId, this.#focusOutlines);
13942 this.parent.drawLayer.updateBox(this.#outlineId, HighlightEditor.#rotateBbox(this.#focusOutlines.box, angle));
13943 }
13944 const {
13945 x,
13946 y,
13947 width,
13948 height
13949 } = highlightOutlines.box;
13950 switch (this.rotation) {
13951 case 0:
13952 this.x = x;
13953 this.y = y;
13954 this.width = width;
13955 this.height = height;
13956 break;
13957 case 90:
13958 {
13959 const [pageWidth, pageHeight] = this.parentDimensions;
13960 this.x = y;
13961 this.y = 1 - x;
13962 this.width = width * pageHeight / pageWidth;
13963 this.height = height * pageWidth / pageHeight;
13964 break;
13965 }
13966 case 180:
13967 this.x = 1 - x;
13968 this.y = 1 - y;
13969 this.width = width;
13970 this.height = height;
13971 break;
13972 case 270:
13973 {
13974 const [pageWidth, pageHeight] = this.parentDimensions;
13975 this.x = 1 - y;
13976 this.y = x;
13977 this.width = width * pageHeight / pageWidth;
13978 this.height = height * pageWidth / pageHeight;
13979 break;
13980 }
13981 }
13982 const {
13983 lastPoint
13984 } = this.#focusOutlines.box;
13985 this.#lastPoint = [(lastPoint[0] - x) / width, (lastPoint[1] - y) / height];
13986 }
13987 static initialize(l10n, uiManager) {
13988 editor_editor.AnnotationEditor.initialize(l10n, uiManager);
13989 HighlightEditor._defaultColor ||= uiManager.highlightColors?.values().next().value || "#fff066";
13990 }
13991 static updateDefaultParams(type, value) {
13992 switch (type) {
13993 case util.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
13994 HighlightEditor._defaultColor = value;
13995 break;
13996 case util.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
13997 HighlightEditor._defaultThickness = value;
13998 break;
13999 }
14000 }
14001 translateInPage(x, y) {}
14002 get toolbarPosition() {
14003 return this.#lastPoint;
14004 }
14005 updateParams(type, value) {
14006 switch (type) {
14007 case util.AnnotationEditorParamsType.HIGHLIGHT_COLOR:
14008 this.#updateColor(value);
14009 break;
14010 case util.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
14011 this.#updateThickness(value);
14012 break;
14013 }
14014 }
14015 static get defaultPropertiesToUpdate() {
14016 return [[util.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR, HighlightEditor._defaultColor], [util.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS, HighlightEditor._defaultThickness]];
14017 }
14018 get propertiesToUpdate() {
14019 return [[util.AnnotationEditorParamsType.HIGHLIGHT_COLOR, this.color || HighlightEditor._defaultColor], [util.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS, this.#thickness || HighlightEditor._defaultThickness], [util.AnnotationEditorParamsType.HIGHLIGHT_FREE, this.#isFreeHighlight]];
14020 }
14021 #updateColor(color) {
14022 const setColor = col => {
14023 this.color = col;
14024 this.parent?.drawLayer.changeColor(this.#id, col);
14025 this.#colorPicker?.updateColor(col);
14026 };
14027 const savedColor = this.color;
14028 this.addCommands({
14029 cmd: setColor.bind(this, color),
14030 undo: setColor.bind(this, savedColor),
14031 post: this._uiManager.updateUI.bind(this._uiManager, this),
14032 mustExec: true,
14033 type: util.AnnotationEditorParamsType.HIGHLIGHT_COLOR,
14034 overwriteIfSameType: true,
14035 keepUndo: true
14036 });
14037 this._reportTelemetry({
14038 action: "color_changed",
14039 color: this._uiManager.highlightColorNames.get(color)
14040 }, true);
14041 }
14042 #updateThickness(thickness) {
14043 const savedThickness = this.#thickness;
14044 const setThickness = th => {
14045 this.#thickness = th;
14046 this.#changeThickness(th);
14047 };
14048 this.addCommands({
14049 cmd: setThickness.bind(this, thickness),
14050 undo: setThickness.bind(this, savedThickness),
14051 post: this._uiManager.updateUI.bind(this._uiManager, this),
14052 mustExec: true,
14053 type: util.AnnotationEditorParamsType.INK_THICKNESS,
14054 overwriteIfSameType: true,
14055 keepUndo: true
14056 });
14057 this._reportTelemetry({
14058 action: "thickness_changed",
14059 thickness
14060 }, true);
14061 }
14062 async addEditToolbar() {
14063 const toolbar = await super.addEditToolbar();
14064 if (!toolbar) {
14065 return null;
14066 }
14067 if (this._uiManager.highlightColors) {
14068 this.#colorPicker = new color_picker.ColorPicker({
14069 editor: this
14070 });
14071 toolbar.addColorPicker(this.#colorPicker);
14072 }
14073 return toolbar;
14074 }
14075 disableEditing() {
14076 super.disableEditing();
14077 this.div.classList.toggle("disabled", true);
14078 }
14079 enableEditing() {
14080 super.enableEditing();
14081 this.div.classList.toggle("disabled", false);
14082 }
14083 fixAndSetPosition() {
14084 return super.fixAndSetPosition(this.#getRotation());
14085 }
14086 getBaseTranslation() {
14087 return [0, 0];
14088 }
14089 getRect(tx, ty) {
14090 return super.getRect(tx, ty, this.#getRotation());
14091 }
14092 onceAdded() {
14093 this.parent.addUndoableEditor(this);
14094 this.div.focus();
14095 }
14096 remove() {
14097 this.#cleanDrawLayer();
14098 this._reportTelemetry({
14099 action: "deleted"
14100 });
14101 super.remove();
14102 }
14103 rebuild() {
14104 if (!this.parent) {
14105 return;
14106 }
14107 super.rebuild();
14108 if (this.div === null) {
14109 return;
14110 }
14111 this.#addToDrawLayer();
14112 if (!this.isAttachedToDOM) {
14113 this.parent.add(this);
14114 }
14115 }
14116 setParent(parent) {
14117 let mustBeSelected = false;
14118 if (this.parent && !parent) {
14119 this.#cleanDrawLayer();
14120 } else if (parent) {
14121 this.#addToDrawLayer(parent);
14122 mustBeSelected = !this.parent && this.div?.classList.contains("selectedEditor");
14123 }
14124 super.setParent(parent);
14125 this.show(this._isVisible);
14126 if (mustBeSelected) {
14127 this.select();
14128 }
14129 }
14130 #changeThickness(thickness) {
14131 if (!this.#isFreeHighlight) {
14132 return;
14133 }
14134 this.#createFreeOutlines({
14135 highlightOutlines: this.#highlightOutlines.getNewOutline(thickness / 2)
14136 });
14137 this.fixAndSetPosition();
14138 const [parentWidth, parentHeight] = this.parentDimensions;
14139 this.setDims(this.width * parentWidth, this.height * parentHeight);
14140 }
14141 #cleanDrawLayer() {
14142 if (this.#id === null || !this.parent) {
14143 return;
14144 }
14145 this.parent.drawLayer.remove(this.#id);
14146 this.#id = null;
14147 this.parent.drawLayer.remove(this.#outlineId);
14148 this.#outlineId = null;
14149 }
14150 #addToDrawLayer() {
14151 let parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.parent;
14152 if (this.#id !== null) {
14153 return;
14154 }
14155 ({
14156 id: this.#id,
14157 clipPathId: this.#clipPathId
14158 } = parent.drawLayer.highlight(this.#highlightOutlines, this.color, this.#opacity));
14159 this.#outlineId = parent.drawLayer.highlightOutline(this.#focusOutlines);
14160 if (this.#highlightDiv) {
14161 this.#highlightDiv.style.clipPath = this.#clipPathId;
14162 }
14163 }
14164 static #rotateBbox(_ref2, angle) {
14165 let {
14166 x,
14167 y,
14168 width,
14169 height
14170 } = _ref2;
14171 switch (angle) {
14172 case 90:
14173 return {
14174 x: 1 - y - height,
14175 y: x,
14176 width: height,
14177 height: width
14178 };
14179 case 180:
14180 return {
14181 x: 1 - x - width,
14182 y: 1 - y - height,
14183 width,
14184 height
14185 };
14186 case 270:
14187 return {
14188 x: y,
14189 y: 1 - x - width,
14190 width: height,
14191 height: width
14192 };
14193 }
14194 return {
14195 x,
14196 y,
14197 width,
14198 height
14199 };
14200 }
14201 rotate(angle) {
14202 const {
14203 drawLayer
14204 } = this.parent;
14205 let box;
14206 if (this.#isFreeHighlight) {
14207 angle = (angle - this.rotation + 360) % 360;
14208 box = HighlightEditor.#rotateBbox(this.#highlightOutlines.box, angle);
14209 } else {
14210 box = HighlightEditor.#rotateBbox(this, angle);
14211 }
14212 drawLayer.rotate(this.#id, angle);
14213 drawLayer.rotate(this.#outlineId, angle);
14214 drawLayer.updateBox(this.#id, box);
14215 drawLayer.updateBox(this.#outlineId, HighlightEditor.#rotateBbox(this.#focusOutlines.box, angle));
14216 }
14217 render() {
14218 if (this.div) {
14219 return this.div;
14220 }
14221 const div = super.render();
14222 if (this.#text) {
14223 div.setAttribute("aria-label", this.#text);
14224 div.setAttribute("role", "mark");
14225 }
14226 if (this.#isFreeHighlight) {
14227 div.classList.add("free");
14228 } else {
14229 this.div.addEventListener("keydown", this.#boundKeydown);
14230 }
14231 const highlightDiv = this.#highlightDiv = document.createElement("div");
14232 div.append(highlightDiv);
14233 highlightDiv.setAttribute("aria-hidden", "true");
14234 highlightDiv.className = "internal";
14235 highlightDiv.style.clipPath = this.#clipPathId;
14236 const [parentWidth, parentHeight] = this.parentDimensions;
14237 this.setDims(this.width * parentWidth, this.height * parentHeight);
14238 (0,tools.bindEvents)(this, this.#highlightDiv, ["pointerover", "pointerleave"]);
14239 this.enableEditing();
14240 return div;
14241 }
14242 pointerover() {
14243 this.parent.drawLayer.addClass(this.#outlineId, "hovered");
14244 }
14245 pointerleave() {
14246 this.parent.drawLayer.removeClass(this.#outlineId, "hovered");
14247 }
14248 #keydown(event) {
14249 HighlightEditor._keyboardManager.exec(this, event);
14250 }
14251 _moveCaret(direction) {
14252 this.parent.unselect(this);
14253 switch (direction) {
14254 case 0:
14255 case 2:
14256 this.#setCaret(true);
14257 break;
14258 case 1:
14259 case 3:
14260 this.#setCaret(false);
14261 break;
14262 }
14263 }
14264 #setCaret(start) {
14265 if (!this.#anchorNode) {
14266 return;
14267 }
14268 const selection = window.getSelection();
14269 if (start) {
14270 selection.setPosition(this.#anchorNode, this.#anchorOffset);
14271 } else {
14272 selection.setPosition(this.#focusNode, this.#focusOffset);
14273 }
14274 }
14275 select() {
14276 super.select();
14277 if (!this.#outlineId) {
14278 return;
14279 }
14280 this.parent?.drawLayer.removeClass(this.#outlineId, "hovered");
14281 this.parent?.drawLayer.addClass(this.#outlineId, "selected");
14282 }
14283 unselect() {
14284 super.unselect();
14285 if (!this.#outlineId) {
14286 return;
14287 }
14288 this.parent?.drawLayer.removeClass(this.#outlineId, "selected");
14289 if (!this.#isFreeHighlight) {
14290 this.#setCaret(false);
14291 }
14292 }
14293 get _mustFixPosition() {
14294 return !this.#isFreeHighlight;
14295 }
14296 show() {
14297 let visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._isVisible;
14298 super.show(visible);
14299 if (this.parent) {
14300 this.parent.drawLayer.show(this.#id, visible);
14301 this.parent.drawLayer.show(this.#outlineId, visible);
14302 }
14303 }
14304 #getRotation() {
14305 return this.#isFreeHighlight ? this.rotation : 0;
14306 }
14307 #serializeBoxes() {
14308 if (this.#isFreeHighlight) {
14309 return null;
14310 }
14311 const [pageWidth, pageHeight] = this.pageDimensions;
14312 const boxes = this.#boxes;
14313 const quadPoints = new Array(boxes.length * 8);
14314 let i = 0;
14315 for (const {
14316 x,
14317 y,
14318 width,
14319 height
14320 } of boxes) {
14321 const sx = x * pageWidth;
14322 const sy = (1 - y - height) * pageHeight;
14323 quadPoints[i] = quadPoints[i + 4] = sx;
14324 quadPoints[i + 1] = quadPoints[i + 3] = sy;
14325 quadPoints[i + 2] = quadPoints[i + 6] = sx + width * pageWidth;
14326 quadPoints[i + 5] = quadPoints[i + 7] = sy + height * pageHeight;
14327 i += 8;
14328 }
14329 return quadPoints;
14330 }
14331 #serializeOutlines(rect) {
14332 return this.#highlightOutlines.serialize(rect, this.#getRotation());
14333 }
14334 static startHighlighting(parent, isLTR, _ref3) {
14335 let {
14336 target: textLayer,
14337 x,
14338 y
14339 } = _ref3;
14340 const {
14341 x: layerX,
14342 y: layerY,
14343 width: parentWidth,
14344 height: parentHeight
14345 } = textLayer.getBoundingClientRect();
14346 const pointerMove = e => {
14347 this.#highlightMove(parent, e);
14348 };
14349 const pointerDownOptions = {
14350 capture: true,
14351 passive: false
14352 };
14353 const pointerDown = e => {
14354 e.preventDefault();
14355 e.stopPropagation();
14356 };
14357 const pointerUpCallback = e => {
14358 textLayer.removeEventListener("pointermove", pointerMove);
14359 window.removeEventListener("blur", pointerUpCallback);
14360 window.removeEventListener("pointerup", pointerUpCallback);
14361 window.removeEventListener("pointerdown", pointerDown, pointerDownOptions);
14362 window.removeEventListener("contextmenu", display_utils.noContextMenu);
14363 this.#endHighlight(parent, e);
14364 };
14365 window.addEventListener("blur", pointerUpCallback);
14366 window.addEventListener("pointerup", pointerUpCallback);
14367 window.addEventListener("pointerdown", pointerDown, pointerDownOptions);
14368 window.addEventListener("contextmenu", display_utils.noContextMenu);
14369 textLayer.addEventListener("pointermove", pointerMove);
14370 this._freeHighlight = new editor_outliner.FreeOutliner({
14371 x,
14372 y
14373 }, [layerX, layerY, parentWidth, parentHeight], parent.scale, this._defaultThickness / 2, isLTR, 0.001);
14374 ({
14375 id: this._freeHighlightId,
14376 clipPathId: this._freeHighlightClipId
14377 } = parent.drawLayer.highlight(this._freeHighlight, this._defaultColor, this._defaultOpacity, true));
14378 }
14379 static #highlightMove(parent, event) {
14380 if (this._freeHighlight.add(event)) {
14381 parent.drawLayer.updatePath(this._freeHighlightId, this._freeHighlight);
14382 }
14383 }
14384 static #endHighlight(parent, event) {
14385 if (!this._freeHighlight.isEmpty()) {
14386 parent.createAndAddNewEditor(event, false, {
14387 highlightId: this._freeHighlightId,
14388 highlightOutlines: this._freeHighlight.getOutlines(),
14389 clipPathId: this._freeHighlightClipId,
14390 methodOfCreation: "main_toolbar"
14391 });
14392 } else {
14393 parent.drawLayer.removeFreeHighlight(this._freeHighlightId);
14394 }
14395 this._freeHighlightId = -1;
14396 this._freeHighlight = null;
14397 this._freeHighlightClipId = "";
14398 }
14399 static deserialize(data, parent, uiManager) {
14400 const editor = super.deserialize(data, parent, uiManager);
14401 const {
14402 rect: [blX, blY, trX, trY],
14403 color,
14404 quadPoints
14405 } = data;
14406 editor.color = util.Util.makeHexColor(...color);
14407 editor.#opacity = data.opacity;
14408 const [pageWidth, pageHeight] = editor.pageDimensions;
14409 editor.width = (trX - blX) / pageWidth;
14410 editor.height = (trY - blY) / pageHeight;
14411 const boxes = editor.#boxes = [];
14412 for (let i = 0; i < quadPoints.length; i += 8) {
14413 boxes.push({
14414 x: (quadPoints[4] - trX) / pageWidth,
14415 y: (trY - (1 - quadPoints[i + 5])) / pageHeight,
14416 width: (quadPoints[i + 2] - quadPoints[i]) / pageWidth,
14417 height: (quadPoints[i + 5] - quadPoints[i + 1]) / pageHeight
14418 });
14419 }
14420 editor.#createOutlines();
14421 return editor;
14422 }
14423 serialize() {
14424 let isForCopying = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
14425 if (this.isEmpty() || isForCopying) {
14426 return null;
14427 }
14428 const rect = this.getRect(0, 0);
14429 const color = editor_editor.AnnotationEditor._colorManager.convert(this.color);
14430 return {
14431 annotationType: util.AnnotationEditorType.HIGHLIGHT,
14432 color,
14433 opacity: this.#opacity,
14434 thickness: this.#thickness,
14435 quadPoints: this.#serializeBoxes(),
14436 outlines: this.#serializeOutlines(rect),
14437 pageIndex: this.pageIndex,
14438 rect,
14439 rotation: this.#getRotation(),
14440 structTreeParentId: this._structTreeParentId
14441 };
14442 }
14443 static canCreateNewEmptyEditor() {
14444 return false;
14445 }
14446}
14447
14448;// CONCATENATED MODULE: ./src/display/editor/ink.js
14449
14450
14451
14452
14453
14454
14455
14456class InkEditor extends editor_editor.AnnotationEditor {
14457 #baseHeight = 0;
14458 #baseWidth = 0;
14459 #boundCanvasPointermove = this.canvasPointermove.bind(this);
14460 #boundCanvasPointerleave = this.canvasPointerleave.bind(this);
14461 #boundCanvasPointerup = this.canvasPointerup.bind(this);
14462 #boundCanvasPointerdown = this.canvasPointerdown.bind(this);
14463 #canvasContextMenuTimeoutId = null;
14464 #currentPath2D = new Path2D();
14465 #disableEditing = false;
14466 #hasSomethingToDraw = false;
14467 #isCanvasInitialized = false;
14468 #observer = null;
14469 #realWidth = 0;
14470 #realHeight = 0;
14471 #requestFrameCallback = null;
14472 static _defaultColor = null;
14473 static _defaultOpacity = 1;
14474 static _defaultThickness = 1;
14475 static _type = "ink";
14476 static _editorType = util.AnnotationEditorType.INK;
14477 constructor(params) {
14478 super({
14479 ...params,
14480 name: "inkEditor"
14481 });
14482 this.color = params.color || null;
14483 this.thickness = params.thickness || null;
14484 this.opacity = params.opacity || null;
14485 this.paths = [];
14486 this.bezierPath2D = [];
14487 this.allRawPaths = [];
14488 this.currentPath = [];
14489 this.scaleFactor = 1;
14490 this.translationX = this.translationY = 0;
14491 this.x = 0;
14492 this.y = 0;
14493 this._willKeepAspectRatio = true;
14494 }
14495 static initialize(l10n, uiManager) {
14496 editor_editor.AnnotationEditor.initialize(l10n, uiManager);
14497 }
14498 static updateDefaultParams(type, value) {
14499 switch (type) {
14500 case util.AnnotationEditorParamsType.INK_THICKNESS:
14501 InkEditor._defaultThickness = value;
14502 break;
14503 case util.AnnotationEditorParamsType.INK_COLOR:
14504 InkEditor._defaultColor = value;
14505 break;
14506 case util.AnnotationEditorParamsType.INK_OPACITY:
14507 InkEditor._defaultOpacity = value / 100;
14508 break;
14509 }
14510 }
14511 updateParams(type, value) {
14512 switch (type) {
14513 case util.AnnotationEditorParamsType.INK_THICKNESS:
14514 this.#updateThickness(value);
14515 break;
14516 case util.AnnotationEditorParamsType.INK_COLOR:
14517 this.#updateColor(value);
14518 break;
14519 case util.AnnotationEditorParamsType.INK_OPACITY:
14520 this.#updateOpacity(value);
14521 break;
14522 }
14523 }
14524 static get defaultPropertiesToUpdate() {
14525 return [[util.AnnotationEditorParamsType.INK_THICKNESS, InkEditor._defaultThickness], [util.AnnotationEditorParamsType.INK_COLOR, InkEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor], [util.AnnotationEditorParamsType.INK_OPACITY, Math.round(InkEditor._defaultOpacity * 100)]];
14526 }
14527 get propertiesToUpdate() {
14528 return [[util.AnnotationEditorParamsType.INK_THICKNESS, this.thickness || InkEditor._defaultThickness], [util.AnnotationEditorParamsType.INK_COLOR, this.color || InkEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor], [util.AnnotationEditorParamsType.INK_OPACITY, Math.round(100 * (this.opacity ?? InkEditor._defaultOpacity))]];
14529 }
14530 #updateThickness(thickness) {
14531 const setThickness = th => {
14532 this.thickness = th;
14533 this.#fitToContent();
14534 };
14535 const savedThickness = this.thickness;
14536 this.addCommands({
14537 cmd: setThickness.bind(this, thickness),
14538 undo: setThickness.bind(this, savedThickness),
14539 post: this._uiManager.updateUI.bind(this._uiManager, this),
14540 mustExec: true,
14541 type: util.AnnotationEditorParamsType.INK_THICKNESS,
14542 overwriteIfSameType: true,
14543 keepUndo: true
14544 });
14545 }
14546 #updateColor(color) {
14547 const setColor = col => {
14548 this.color = col;
14549 this.#redraw();
14550 };
14551 const savedColor = this.color;
14552 this.addCommands({
14553 cmd: setColor.bind(this, color),
14554 undo: setColor.bind(this, savedColor),
14555 post: this._uiManager.updateUI.bind(this._uiManager, this),
14556 mustExec: true,
14557 type: util.AnnotationEditorParamsType.INK_COLOR,
14558 overwriteIfSameType: true,
14559 keepUndo: true
14560 });
14561 }
14562 #updateOpacity(opacity) {
14563 const setOpacity = op => {
14564 this.opacity = op;
14565 this.#redraw();
14566 };
14567 opacity /= 100;
14568 const savedOpacity = this.opacity;
14569 this.addCommands({
14570 cmd: setOpacity.bind(this, opacity),
14571 undo: setOpacity.bind(this, savedOpacity),
14572 post: this._uiManager.updateUI.bind(this._uiManager, this),
14573 mustExec: true,
14574 type: util.AnnotationEditorParamsType.INK_OPACITY,
14575 overwriteIfSameType: true,
14576 keepUndo: true
14577 });
14578 }
14579 rebuild() {
14580 if (!this.parent) {
14581 return;
14582 }
14583 super.rebuild();
14584 if (this.div === null) {
14585 return;
14586 }
14587 if (!this.canvas) {
14588 this.#createCanvas();
14589 this.#createObserver();
14590 }
14591 if (!this.isAttachedToDOM) {
14592 this.parent.add(this);
14593 this.#setCanvasDims();
14594 }
14595 this.#fitToContent();
14596 }
14597 remove() {
14598 if (this.canvas === null) {
14599 return;
14600 }
14601 if (!this.isEmpty()) {
14602 this.commit();
14603 }
14604 this.canvas.width = this.canvas.height = 0;
14605 this.canvas.remove();
14606 this.canvas = null;
14607 if (this.#canvasContextMenuTimeoutId) {
14608 clearTimeout(this.#canvasContextMenuTimeoutId);
14609 this.#canvasContextMenuTimeoutId = null;
14610 }
14611 this.#observer.disconnect();
14612 this.#observer = null;
14613 super.remove();
14614 }
14615 setParent(parent) {
14616 if (!this.parent && parent) {
14617 this._uiManager.removeShouldRescale(this);
14618 } else if (this.parent && parent === null) {
14619 this._uiManager.addShouldRescale(this);
14620 }
14621 super.setParent(parent);
14622 }
14623 onScaleChanging() {
14624 const [parentWidth, parentHeight] = this.parentDimensions;
14625 const width = this.width * parentWidth;
14626 const height = this.height * parentHeight;
14627 this.setDimensions(width, height);
14628 }
14629 enableEditMode() {
14630 if (this.#disableEditing || this.canvas === null) {
14631 return;
14632 }
14633 super.enableEditMode();
14634 this._isDraggable = false;
14635 this.canvas.addEventListener("pointerdown", this.#boundCanvasPointerdown);
14636 }
14637 disableEditMode() {
14638 if (!this.isInEditMode() || this.canvas === null) {
14639 return;
14640 }
14641 super.disableEditMode();
14642 this._isDraggable = !this.isEmpty();
14643 this.div.classList.remove("editing");
14644 this.canvas.removeEventListener("pointerdown", this.#boundCanvasPointerdown);
14645 }
14646 onceAdded() {
14647 this._isDraggable = !this.isEmpty();
14648 }
14649 isEmpty() {
14650 return this.paths.length === 0 || this.paths.length === 1 && this.paths[0].length === 0;
14651 }
14652 #getInitialBBox() {
14653 const {
14654 parentRotation,
14655 parentDimensions: [width, height]
14656 } = this;
14657 switch (parentRotation) {
14658 case 90:
14659 return [0, height, height, width];
14660 case 180:
14661 return [width, height, width, height];
14662 case 270:
14663 return [width, 0, height, width];
14664 default:
14665 return [0, 0, width, height];
14666 }
14667 }
14668 #setStroke() {
14669 const {
14670 ctx,
14671 color,
14672 opacity,
14673 thickness,
14674 parentScale,
14675 scaleFactor
14676 } = this;
14677 ctx.lineWidth = thickness * parentScale / scaleFactor;
14678 ctx.lineCap = "round";
14679 ctx.lineJoin = "round";
14680 ctx.miterLimit = 10;
14681 ctx.strokeStyle = `${color}${(0,tools.opacityToHex)(opacity)}`;
14682 }
14683 #startDrawing(x, y) {
14684 this.canvas.addEventListener("contextmenu", display_utils.noContextMenu);
14685 this.canvas.addEventListener("pointerleave", this.#boundCanvasPointerleave);
14686 this.canvas.addEventListener("pointermove", this.#boundCanvasPointermove);
14687 this.canvas.addEventListener("pointerup", this.#boundCanvasPointerup);
14688 this.canvas.removeEventListener("pointerdown", this.#boundCanvasPointerdown);
14689 this.isEditing = true;
14690 if (!this.#isCanvasInitialized) {
14691 this.#isCanvasInitialized = true;
14692 this.#setCanvasDims();
14693 this.thickness ||= InkEditor._defaultThickness;
14694 this.color ||= InkEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor;
14695 this.opacity ??= InkEditor._defaultOpacity;
14696 }
14697 this.currentPath.push([x, y]);
14698 this.#hasSomethingToDraw = false;
14699 this.#setStroke();
14700 this.#requestFrameCallback = () => {
14701 this.#drawPoints();
14702 if (this.#requestFrameCallback) {
14703 window.requestAnimationFrame(this.#requestFrameCallback);
14704 }
14705 };
14706 window.requestAnimationFrame(this.#requestFrameCallback);
14707 }
14708 #draw(x, y) {
14709 const [lastX, lastY] = this.currentPath.at(-1);
14710 if (this.currentPath.length > 1 && x === lastX && y === lastY) {
14711 return;
14712 }
14713 const currentPath = this.currentPath;
14714 let path2D = this.#currentPath2D;
14715 currentPath.push([x, y]);
14716 this.#hasSomethingToDraw = true;
14717 if (currentPath.length <= 2) {
14718 path2D.moveTo(...currentPath[0]);
14719 path2D.lineTo(x, y);
14720 return;
14721 }
14722 if (currentPath.length === 3) {
14723 this.#currentPath2D = path2D = new Path2D();
14724 path2D.moveTo(...currentPath[0]);
14725 }
14726 this.#makeBezierCurve(path2D, ...currentPath.at(-3), ...currentPath.at(-2), x, y);
14727 }
14728 #endPath() {
14729 if (this.currentPath.length === 0) {
14730 return;
14731 }
14732 const lastPoint = this.currentPath.at(-1);
14733 this.#currentPath2D.lineTo(...lastPoint);
14734 }
14735 #stopDrawing(x, y) {
14736 this.#requestFrameCallback = null;
14737 x = Math.min(Math.max(x, 0), this.canvas.width);
14738 y = Math.min(Math.max(y, 0), this.canvas.height);
14739 this.#draw(x, y);
14740 this.#endPath();
14741 let bezier;
14742 if (this.currentPath.length !== 1) {
14743 bezier = this.#generateBezierPoints();
14744 } else {
14745 const xy = [x, y];
14746 bezier = [[xy, xy.slice(), xy.slice(), xy]];
14747 }
14748 const path2D = this.#currentPath2D;
14749 const currentPath = this.currentPath;
14750 this.currentPath = [];
14751 this.#currentPath2D = new Path2D();
14752 const cmd = () => {
14753 this.allRawPaths.push(currentPath);
14754 this.paths.push(bezier);
14755 this.bezierPath2D.push(path2D);
14756 this._uiManager.rebuild(this);
14757 };
14758 const undo = () => {
14759 this.allRawPaths.pop();
14760 this.paths.pop();
14761 this.bezierPath2D.pop();
14762 if (this.paths.length === 0) {
14763 this.remove();
14764 } else {
14765 if (!this.canvas) {
14766 this.#createCanvas();
14767 this.#createObserver();
14768 }
14769 this.#fitToContent();
14770 }
14771 };
14772 this.addCommands({
14773 cmd,
14774 undo,
14775 mustExec: true
14776 });
14777 }
14778 #drawPoints() {
14779 if (!this.#hasSomethingToDraw) {
14780 return;
14781 }
14782 this.#hasSomethingToDraw = false;
14783 const thickness = Math.ceil(this.thickness * this.parentScale);
14784 const lastPoints = this.currentPath.slice(-3);
14785 const x = lastPoints.map(xy => xy[0]);
14786 const y = lastPoints.map(xy => xy[1]);
14787 const xMin = Math.min(...x) - thickness;
14788 const xMax = Math.max(...x) + thickness;
14789 const yMin = Math.min(...y) - thickness;
14790 const yMax = Math.max(...y) + thickness;
14791 const {
14792 ctx
14793 } = this;
14794 ctx.save();
14795 ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
14796 for (const path of this.bezierPath2D) {
14797 ctx.stroke(path);
14798 }
14799 ctx.stroke(this.#currentPath2D);
14800 ctx.restore();
14801 }
14802 #makeBezierCurve(path2D, x0, y0, x1, y1, x2, y2) {
14803 const prevX = (x0 + x1) / 2;
14804 const prevY = (y0 + y1) / 2;
14805 const x3 = (x1 + x2) / 2;
14806 const y3 = (y1 + y2) / 2;
14807 path2D.bezierCurveTo(prevX + 2 * (x1 - prevX) / 3, prevY + 2 * (y1 - prevY) / 3, x3 + 2 * (x1 - x3) / 3, y3 + 2 * (y1 - y3) / 3, x3, y3);
14808 }
14809 #generateBezierPoints() {
14810 const path = this.currentPath;
14811 if (path.length <= 2) {
14812 return [[path[0], path[0], path.at(-1), path.at(-1)]];
14813 }
14814 const bezierPoints = [];
14815 let i;
14816 let [x0, y0] = path[0];
14817 for (i = 1; i < path.length - 2; i++) {
14818 const [x1, y1] = path[i];
14819 const [x2, y2] = path[i + 1];
14820 const x3 = (x1 + x2) / 2;
14821 const y3 = (y1 + y2) / 2;
14822 const control1 = [x0 + 2 * (x1 - x0) / 3, y0 + 2 * (y1 - y0) / 3];
14823 const control2 = [x3 + 2 * (x1 - x3) / 3, y3 + 2 * (y1 - y3) / 3];
14824 bezierPoints.push([[x0, y0], control1, control2, [x3, y3]]);
14825 [x0, y0] = [x3, y3];
14826 }
14827 const [x1, y1] = path[i];
14828 const [x2, y2] = path[i + 1];
14829 const control1 = [x0 + 2 * (x1 - x0) / 3, y0 + 2 * (y1 - y0) / 3];
14830 const control2 = [x2 + 2 * (x1 - x2) / 3, y2 + 2 * (y1 - y2) / 3];
14831 bezierPoints.push([[x0, y0], control1, control2, [x2, y2]]);
14832 return bezierPoints;
14833 }
14834 #redraw() {
14835 if (this.isEmpty()) {
14836 this.#updateTransform();
14837 return;
14838 }
14839 this.#setStroke();
14840 const {
14841 canvas,
14842 ctx
14843 } = this;
14844 ctx.setTransform(1, 0, 0, 1, 0, 0);
14845 ctx.clearRect(0, 0, canvas.width, canvas.height);
14846 this.#updateTransform();
14847 for (const path of this.bezierPath2D) {
14848 ctx.stroke(path);
14849 }
14850 }
14851 commit() {
14852 if (this.#disableEditing) {
14853 return;
14854 }
14855 super.commit();
14856 this.isEditing = false;
14857 this.disableEditMode();
14858 this.setInForeground();
14859 this.#disableEditing = true;
14860 this.div.classList.add("disabled");
14861 this.#fitToContent(true);
14862 this.select();
14863 this.parent.addInkEditorIfNeeded(true);
14864 this.moveInDOM();
14865 this.div.focus({
14866 preventScroll: true
14867 });
14868 }
14869 focusin(event) {
14870 if (!this._focusEventsAllowed) {
14871 return;
14872 }
14873 super.focusin(event);
14874 this.enableEditMode();
14875 }
14876 canvasPointerdown(event) {
14877 if (event.button !== 0 || !this.isInEditMode() || this.#disableEditing) {
14878 return;
14879 }
14880 this.setInForeground();
14881 event.preventDefault();
14882 if (!this.div.contains(document.activeElement)) {
14883 this.div.focus({
14884 preventScroll: true
14885 });
14886 }
14887 this.#startDrawing(event.offsetX, event.offsetY);
14888 }
14889 canvasPointermove(event) {
14890 event.preventDefault();
14891 this.#draw(event.offsetX, event.offsetY);
14892 }
14893 canvasPointerup(event) {
14894 event.preventDefault();
14895 this.#endDrawing(event);
14896 }
14897 canvasPointerleave(event) {
14898 this.#endDrawing(event);
14899 }
14900 #endDrawing(event) {
14901 this.canvas.removeEventListener("pointerleave", this.#boundCanvasPointerleave);
14902 this.canvas.removeEventListener("pointermove", this.#boundCanvasPointermove);
14903 this.canvas.removeEventListener("pointerup", this.#boundCanvasPointerup);
14904 this.canvas.addEventListener("pointerdown", this.#boundCanvasPointerdown);
14905 if (this.#canvasContextMenuTimeoutId) {
14906 clearTimeout(this.#canvasContextMenuTimeoutId);
14907 }
14908 this.#canvasContextMenuTimeoutId = setTimeout(() => {
14909 this.#canvasContextMenuTimeoutId = null;
14910 this.canvas.removeEventListener("contextmenu", display_utils.noContextMenu);
14911 }, 10);
14912 this.#stopDrawing(event.offsetX, event.offsetY);
14913 this.addToAnnotationStorage();
14914 this.setInBackground();
14915 }
14916 #createCanvas() {
14917 this.canvas = document.createElement("canvas");
14918 this.canvas.width = this.canvas.height = 0;
14919 this.canvas.className = "inkEditorCanvas";
14920 this.canvas.setAttribute("data-l10n-id", "pdfjs-ink-canvas");
14921 this.div.append(this.canvas);
14922 this.ctx = this.canvas.getContext("2d");
14923 }
14924 #createObserver() {
14925 this.#observer = new ResizeObserver(entries => {
14926 const rect = entries[0].contentRect;
14927 if (rect.width && rect.height) {
14928 this.setDimensions(rect.width, rect.height);
14929 }
14930 });
14931 this.#observer.observe(this.div);
14932 }
14933 get isResizable() {
14934 return !this.isEmpty() && this.#disableEditing;
14935 }
14936 render() {
14937 if (this.div) {
14938 return this.div;
14939 }
14940 let baseX, baseY;
14941 if (this.width) {
14942 baseX = this.x;
14943 baseY = this.y;
14944 }
14945 super.render();
14946 this.div.setAttribute("data-l10n-id", "pdfjs-ink");
14947 const [x, y, w, h] = this.#getInitialBBox();
14948 this.setAt(x, y, 0, 0);
14949 this.setDims(w, h);
14950 this.#createCanvas();
14951 if (this.width) {
14952 const [parentWidth, parentHeight] = this.parentDimensions;
14953 this.setAspectRatio(this.width * parentWidth, this.height * parentHeight);
14954 this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
14955 this.#isCanvasInitialized = true;
14956 this.#setCanvasDims();
14957 this.setDims(this.width * parentWidth, this.height * parentHeight);
14958 this.#redraw();
14959 this.div.classList.add("disabled");
14960 } else {
14961 this.div.classList.add("editing");
14962 this.enableEditMode();
14963 }
14964 this.#createObserver();
14965 return this.div;
14966 }
14967 #setCanvasDims() {
14968 if (!this.#isCanvasInitialized) {
14969 return;
14970 }
14971 const [parentWidth, parentHeight] = this.parentDimensions;
14972 this.canvas.width = Math.ceil(this.width * parentWidth);
14973 this.canvas.height = Math.ceil(this.height * parentHeight);
14974 this.#updateTransform();
14975 }
14976 setDimensions(width, height) {
14977 const roundedWidth = Math.round(width);
14978 const roundedHeight = Math.round(height);
14979 if (this.#realWidth === roundedWidth && this.#realHeight === roundedHeight) {
14980 return;
14981 }
14982 this.#realWidth = roundedWidth;
14983 this.#realHeight = roundedHeight;
14984 this.canvas.style.visibility = "hidden";
14985 const [parentWidth, parentHeight] = this.parentDimensions;
14986 this.width = width / parentWidth;
14987 this.height = height / parentHeight;
14988 this.fixAndSetPosition();
14989 if (this.#disableEditing) {
14990 this.#setScaleFactor(width, height);
14991 }
14992 this.#setCanvasDims();
14993 this.#redraw();
14994 this.canvas.style.visibility = "visible";
14995 this.fixDims();
14996 }
14997 #setScaleFactor(width, height) {
14998 const padding = this.#getPadding();
14999 const scaleFactorW = (width - padding) / this.#baseWidth;
15000 const scaleFactorH = (height - padding) / this.#baseHeight;
15001 this.scaleFactor = Math.min(scaleFactorW, scaleFactorH);
15002 }
15003 #updateTransform() {
15004 const padding = this.#getPadding() / 2;
15005 this.ctx.setTransform(this.scaleFactor, 0, 0, this.scaleFactor, this.translationX * this.scaleFactor + padding, this.translationY * this.scaleFactor + padding);
15006 }
15007 static #buildPath2D(bezier) {
15008 const path2D = new Path2D();
15009 for (let i = 0, ii = bezier.length; i < ii; i++) {
15010 const [first, control1, control2, second] = bezier[i];
15011 if (i === 0) {
15012 path2D.moveTo(...first);
15013 }
15014 path2D.bezierCurveTo(control1[0], control1[1], control2[0], control2[1], second[0], second[1]);
15015 }
15016 return path2D;
15017 }
15018 static #toPDFCoordinates(points, rect, rotation) {
15019 const [blX, blY, trX, trY] = rect;
15020 switch (rotation) {
15021 case 0:
15022 for (let i = 0, ii = points.length; i < ii; i += 2) {
15023 points[i] += blX;
15024 points[i + 1] = trY - points[i + 1];
15025 }
15026 break;
15027 case 90:
15028 for (let i = 0, ii = points.length; i < ii; i += 2) {
15029 const x = points[i];
15030 points[i] = points[i + 1] + blX;
15031 points[i + 1] = x + blY;
15032 }
15033 break;
15034 case 180:
15035 for (let i = 0, ii = points.length; i < ii; i += 2) {
15036 points[i] = trX - points[i];
15037 points[i + 1] += blY;
15038 }
15039 break;
15040 case 270:
15041 for (let i = 0, ii = points.length; i < ii; i += 2) {
15042 const x = points[i];
15043 points[i] = trX - points[i + 1];
15044 points[i + 1] = trY - x;
15045 }
15046 break;
15047 default:
15048 throw new Error("Invalid rotation");
15049 }
15050 return points;
15051 }
15052 static #fromPDFCoordinates(points, rect, rotation) {
15053 const [blX, blY, trX, trY] = rect;
15054 switch (rotation) {
15055 case 0:
15056 for (let i = 0, ii = points.length; i < ii; i += 2) {
15057 points[i] -= blX;
15058 points[i + 1] = trY - points[i + 1];
15059 }
15060 break;
15061 case 90:
15062 for (let i = 0, ii = points.length; i < ii; i += 2) {
15063 const x = points[i];
15064 points[i] = points[i + 1] - blY;
15065 points[i + 1] = x - blX;
15066 }
15067 break;
15068 case 180:
15069 for (let i = 0, ii = points.length; i < ii; i += 2) {
15070 points[i] = trX - points[i];
15071 points[i + 1] -= blY;
15072 }
15073 break;
15074 case 270:
15075 for (let i = 0, ii = points.length; i < ii; i += 2) {
15076 const x = points[i];
15077 points[i] = trY - points[i + 1];
15078 points[i + 1] = trX - x;
15079 }
15080 break;
15081 default:
15082 throw new Error("Invalid rotation");
15083 }
15084 return points;
15085 }
15086 #serializePaths(s, tx, ty, rect) {
15087 const paths = [];
15088 const padding = this.thickness / 2;
15089 const shiftX = s * tx + padding;
15090 const shiftY = s * ty + padding;
15091 for (const bezier of this.paths) {
15092 const buffer = [];
15093 const points = [];
15094 for (let j = 0, jj = bezier.length; j < jj; j++) {
15095 const [first, control1, control2, second] = bezier[j];
15096 if (first[0] === second[0] && first[1] === second[1] && jj === 1) {
15097 const p0 = s * first[0] + shiftX;
15098 const p1 = s * first[1] + shiftY;
15099 buffer.push(p0, p1);
15100 points.push(p0, p1);
15101 break;
15102 }
15103 const p10 = s * first[0] + shiftX;
15104 const p11 = s * first[1] + shiftY;
15105 const p20 = s * control1[0] + shiftX;
15106 const p21 = s * control1[1] + shiftY;
15107 const p30 = s * control2[0] + shiftX;
15108 const p31 = s * control2[1] + shiftY;
15109 const p40 = s * second[0] + shiftX;
15110 const p41 = s * second[1] + shiftY;
15111 if (j === 0) {
15112 buffer.push(p10, p11);
15113 points.push(p10, p11);
15114 }
15115 buffer.push(p20, p21, p30, p31, p40, p41);
15116 points.push(p20, p21);
15117 if (j === jj - 1) {
15118 points.push(p40, p41);
15119 }
15120 }
15121 paths.push({
15122 bezier: InkEditor.#toPDFCoordinates(buffer, rect, this.rotation),
15123 points: InkEditor.#toPDFCoordinates(points, rect, this.rotation)
15124 });
15125 }
15126 return paths;
15127 }
15128 #getBbox() {
15129 let xMin = Infinity;
15130 let xMax = -Infinity;
15131 let yMin = Infinity;
15132 let yMax = -Infinity;
15133 for (const path of this.paths) {
15134 for (const [first, control1, control2, second] of path) {
15135 const bbox = util.Util.bezierBoundingBox(...first, ...control1, ...control2, ...second);
15136 xMin = Math.min(xMin, bbox[0]);
15137 yMin = Math.min(yMin, bbox[1]);
15138 xMax = Math.max(xMax, bbox[2]);
15139 yMax = Math.max(yMax, bbox[3]);
15140 }
15141 }
15142 return [xMin, yMin, xMax, yMax];
15143 }
15144 #getPadding() {
15145 return this.#disableEditing ? Math.ceil(this.thickness * this.parentScale) : 0;
15146 }
15147 #fitToContent() {
15148 let firstTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
15149 if (this.isEmpty()) {
15150 return;
15151 }
15152 if (!this.#disableEditing) {
15153 this.#redraw();
15154 return;
15155 }
15156 const bbox = this.#getBbox();
15157 const padding = this.#getPadding();
15158 this.#baseWidth = Math.max(editor_editor.AnnotationEditor.MIN_SIZE, bbox[2] - bbox[0]);
15159 this.#baseHeight = Math.max(editor_editor.AnnotationEditor.MIN_SIZE, bbox[3] - bbox[1]);
15160 const width = Math.ceil(padding + this.#baseWidth * this.scaleFactor);
15161 const height = Math.ceil(padding + this.#baseHeight * this.scaleFactor);
15162 const [parentWidth, parentHeight] = this.parentDimensions;
15163 this.width = width / parentWidth;
15164 this.height = height / parentHeight;
15165 this.setAspectRatio(width, height);
15166 const prevTranslationX = this.translationX;
15167 const prevTranslationY = this.translationY;
15168 this.translationX = -bbox[0];
15169 this.translationY = -bbox[1];
15170 this.#setCanvasDims();
15171 this.#redraw();
15172 this.#realWidth = width;
15173 this.#realHeight = height;
15174 this.setDims(width, height);
15175 const unscaledPadding = firstTime ? padding / this.scaleFactor / 2 : 0;
15176 this.translate(prevTranslationX - this.translationX - unscaledPadding, prevTranslationY - this.translationY - unscaledPadding);
15177 }
15178 static deserialize(data, parent, uiManager) {
15179 if (data instanceof annotation_layer.InkAnnotationElement) {
15180 return null;
15181 }
15182 const editor = super.deserialize(data, parent, uiManager);
15183 editor.thickness = data.thickness;
15184 editor.color = util.Util.makeHexColor(...data.color);
15185 editor.opacity = data.opacity;
15186 const [pageWidth, pageHeight] = editor.pageDimensions;
15187 const width = editor.width * pageWidth;
15188 const height = editor.height * pageHeight;
15189 const scaleFactor = editor.parentScale;
15190 const padding = data.thickness / 2;
15191 editor.#disableEditing = true;
15192 editor.#realWidth = Math.round(width);
15193 editor.#realHeight = Math.round(height);
15194 const {
15195 paths,
15196 rect,
15197 rotation
15198 } = data;
15199 for (let {
15200 bezier
15201 } of paths) {
15202 bezier = InkEditor.#fromPDFCoordinates(bezier, rect, rotation);
15203 const path = [];
15204 editor.paths.push(path);
15205 let p0 = scaleFactor * (bezier[0] - padding);
15206 let p1 = scaleFactor * (bezier[1] - padding);
15207 for (let i = 2, ii = bezier.length; i < ii; i += 6) {
15208 const p10 = scaleFactor * (bezier[i] - padding);
15209 const p11 = scaleFactor * (bezier[i + 1] - padding);
15210 const p20 = scaleFactor * (bezier[i + 2] - padding);
15211 const p21 = scaleFactor * (bezier[i + 3] - padding);
15212 const p30 = scaleFactor * (bezier[i + 4] - padding);
15213 const p31 = scaleFactor * (bezier[i + 5] - padding);
15214 path.push([[p0, p1], [p10, p11], [p20, p21], [p30, p31]]);
15215 p0 = p30;
15216 p1 = p31;
15217 }
15218 const path2D = this.#buildPath2D(path);
15219 editor.bezierPath2D.push(path2D);
15220 }
15221 const bbox = editor.#getBbox();
15222 editor.#baseWidth = Math.max(editor_editor.AnnotationEditor.MIN_SIZE, bbox[2] - bbox[0]);
15223 editor.#baseHeight = Math.max(editor_editor.AnnotationEditor.MIN_SIZE, bbox[3] - bbox[1]);
15224 editor.#setScaleFactor(width, height);
15225 return editor;
15226 }
15227 serialize() {
15228 if (this.isEmpty()) {
15229 return null;
15230 }
15231 const rect = this.getRect(0, 0);
15232 const color = editor_editor.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);
15233 return {
15234 annotationType: util.AnnotationEditorType.INK,
15235 color,
15236 thickness: this.thickness,
15237 opacity: this.opacity,
15238 paths: this.#serializePaths(this.scaleFactor / this.parentScale, this.translationX, this.translationY, rect),
15239 pageIndex: this.pageIndex,
15240 rect,
15241 rotation: this.rotation,
15242 structTreeParentId: this._structTreeParentId
15243 };
15244 }
15245}
15246
15247// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.filter.js
15248var esnext_iterator_filter = __webpack_require__(4520);
15249// EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-exception.stack.js
15250var web_dom_exception_stack = __webpack_require__(4979);
15251;// CONCATENATED MODULE: ./src/display/editor/stamp.js
15252
15253
15254
15255
15256
15257
15258
15259class StampEditor extends editor_editor.AnnotationEditor {
15260 #bitmap = null;
15261 #bitmapId = null;
15262 #bitmapPromise = null;
15263 #bitmapUrl = null;
15264 #bitmapFile = null;
15265 #bitmapFileName = "";
15266 #canvas = null;
15267 #observer = null;
15268 #resizeTimeoutId = null;
15269 #isSvg = false;
15270 #hasBeenAddedInUndoStack = false;
15271 static _type = "stamp";
15272 static _editorType = util.AnnotationEditorType.STAMP;
15273 constructor(params) {
15274 super({
15275 ...params,
15276 name: "stampEditor"
15277 });
15278 this.#bitmapUrl = params.bitmapUrl;
15279 this.#bitmapFile = params.bitmapFile;
15280 }
15281 static initialize(l10n, uiManager) {
15282 editor_editor.AnnotationEditor.initialize(l10n, uiManager);
15283 }
15284 static get supportedTypes() {
15285 const types = ["apng", "avif", "bmp", "gif", "jpeg", "png", "svg+xml", "webp", "x-icon"];
15286 return (0,util.shadow)(this, "supportedTypes", types.map(type => `image/${type}`));
15287 }
15288 static get supportedTypesStr() {
15289 return (0,util.shadow)(this, "supportedTypesStr", this.supportedTypes.join(","));
15290 }
15291 static isHandlingMimeForPasting(mime) {
15292 return this.supportedTypes.includes(mime);
15293 }
15294 static paste(item, parent) {
15295 parent.pasteEditor(util.AnnotationEditorType.STAMP, {
15296 bitmapFile: item.getAsFile()
15297 });
15298 }
15299 #getBitmapFetched(data) {
15300 let fromId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
15301 if (!data) {
15302 this.remove();
15303 return;
15304 }
15305 this.#bitmap = data.bitmap;
15306 if (!fromId) {
15307 this.#bitmapId = data.id;
15308 this.#isSvg = data.isSvg;
15309 }
15310 if (data.file) {
15311 this.#bitmapFileName = data.file.name;
15312 }
15313 this.#createCanvas();
15314 }
15315 #getBitmapDone() {
15316 this.#bitmapPromise = null;
15317 this._uiManager.enableWaiting(false);
15318 if (this.#canvas) {
15319 this.div.focus();
15320 }
15321 }
15322 #getBitmap() {
15323 if (this.#bitmapId) {
15324 this._uiManager.enableWaiting(true);
15325 this._uiManager.imageManager.getFromId(this.#bitmapId).then(data => this.#getBitmapFetched(data, true)).finally(() => this.#getBitmapDone());
15326 return;
15327 }
15328 if (this.#bitmapUrl) {
15329 const url = this.#bitmapUrl;
15330 this.#bitmapUrl = null;
15331 this._uiManager.enableWaiting(true);
15332 this.#bitmapPromise = this._uiManager.imageManager.getFromUrl(url).then(data => this.#getBitmapFetched(data)).finally(() => this.#getBitmapDone());
15333 return;
15334 }
15335 if (this.#bitmapFile) {
15336 const file = this.#bitmapFile;
15337 this.#bitmapFile = null;
15338 this._uiManager.enableWaiting(true);
15339 this.#bitmapPromise = this._uiManager.imageManager.getFromFile(file).then(data => this.#getBitmapFetched(data)).finally(() => this.#getBitmapDone());
15340 return;
15341 }
15342 const input = document.createElement("input");
15343 input.type = "file";
15344 input.accept = StampEditor.supportedTypesStr;
15345 this.#bitmapPromise = new Promise(resolve => {
15346 input.addEventListener("change", async () => {
15347 if (!input.files || input.files.length === 0) {
15348 this.remove();
15349 } else {
15350 this._uiManager.enableWaiting(true);
15351 const data = await this._uiManager.imageManager.getFromFile(input.files[0]);
15352 this.#getBitmapFetched(data);
15353 }
15354 resolve();
15355 });
15356 input.addEventListener("cancel", () => {
15357 this.remove();
15358 resolve();
15359 });
15360 }).finally(() => this.#getBitmapDone());
15361 input.click();
15362 }
15363 remove() {
15364 if (this.#bitmapId) {
15365 this.#bitmap = null;
15366 this._uiManager.imageManager.deleteId(this.#bitmapId);
15367 this.#canvas?.remove();
15368 this.#canvas = null;
15369 this.#observer?.disconnect();
15370 this.#observer = null;
15371 if (this.#resizeTimeoutId) {
15372 clearTimeout(this.#resizeTimeoutId);
15373 this.#resizeTimeoutId = null;
15374 }
15375 }
15376 super.remove();
15377 }
15378 rebuild() {
15379 if (!this.parent) {
15380 if (this.#bitmapId) {
15381 this.#getBitmap();
15382 }
15383 return;
15384 }
15385 super.rebuild();
15386 if (this.div === null) {
15387 return;
15388 }
15389 if (this.#bitmapId && this.#canvas === null) {
15390 this.#getBitmap();
15391 }
15392 if (!this.isAttachedToDOM) {
15393 this.parent.add(this);
15394 }
15395 }
15396 onceAdded() {
15397 this._isDraggable = true;
15398 this.div.focus();
15399 }
15400 isEmpty() {
15401 return !(this.#bitmapPromise || this.#bitmap || this.#bitmapUrl || this.#bitmapFile || this.#bitmapId);
15402 }
15403 get isResizable() {
15404 return true;
15405 }
15406 render() {
15407 if (this.div) {
15408 return this.div;
15409 }
15410 let baseX, baseY;
15411 if (this.width) {
15412 baseX = this.x;
15413 baseY = this.y;
15414 }
15415 super.render();
15416 this.div.hidden = true;
15417 this.addAltTextButton();
15418 if (this.#bitmap) {
15419 this.#createCanvas();
15420 } else {
15421 this.#getBitmap();
15422 }
15423 if (this.width) {
15424 const [parentWidth, parentHeight] = this.parentDimensions;
15425 this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
15426 }
15427 return this.div;
15428 }
15429 #createCanvas() {
15430 const {
15431 div
15432 } = this;
15433 let {
15434 width,
15435 height
15436 } = this.#bitmap;
15437 const [pageWidth, pageHeight] = this.pageDimensions;
15438 const MAX_RATIO = 0.75;
15439 if (this.width) {
15440 width = this.width * pageWidth;
15441 height = this.height * pageHeight;
15442 } else if (width > MAX_RATIO * pageWidth || height > MAX_RATIO * pageHeight) {
15443 const factor = Math.min(MAX_RATIO * pageWidth / width, MAX_RATIO * pageHeight / height);
15444 width *= factor;
15445 height *= factor;
15446 }
15447 const [parentWidth, parentHeight] = this.parentDimensions;
15448 this.setDims(width * parentWidth / pageWidth, height * parentHeight / pageHeight);
15449 this._uiManager.enableWaiting(false);
15450 const canvas = this.#canvas = document.createElement("canvas");
15451 div.append(canvas);
15452 div.hidden = false;
15453 this.#drawBitmap(width, height);
15454 this.#createObserver();
15455 if (!this.#hasBeenAddedInUndoStack) {
15456 this.parent.addUndoableEditor(this);
15457 this.#hasBeenAddedInUndoStack = true;
15458 }
15459 this._reportTelemetry({
15460 action: "inserted_image"
15461 });
15462 if (this.#bitmapFileName) {
15463 canvas.setAttribute("aria-label", this.#bitmapFileName);
15464 }
15465 }
15466 #setDimensions(width, height) {
15467 const [parentWidth, parentHeight] = this.parentDimensions;
15468 this.width = width / parentWidth;
15469 this.height = height / parentHeight;
15470 this.setDims(width, height);
15471 if (this._initialOptions?.isCentered) {
15472 this.center();
15473 } else {
15474 this.fixAndSetPosition();
15475 }
15476 this._initialOptions = null;
15477 if (this.#resizeTimeoutId !== null) {
15478 clearTimeout(this.#resizeTimeoutId);
15479 }
15480 const TIME_TO_WAIT = 200;
15481 this.#resizeTimeoutId = setTimeout(() => {
15482 this.#resizeTimeoutId = null;
15483 this.#drawBitmap(width, height);
15484 }, TIME_TO_WAIT);
15485 }
15486 #scaleBitmap(width, height) {
15487 const {
15488 width: bitmapWidth,
15489 height: bitmapHeight
15490 } = this.#bitmap;
15491 let newWidth = bitmapWidth;
15492 let newHeight = bitmapHeight;
15493 let bitmap = this.#bitmap;
15494 while (newWidth > 2 * width || newHeight > 2 * height) {
15495 const prevWidth = newWidth;
15496 const prevHeight = newHeight;
15497 if (newWidth > 2 * width) {
15498 newWidth = newWidth >= 16384 ? Math.floor(newWidth / 2) - 1 : Math.ceil(newWidth / 2);
15499 }
15500 if (newHeight > 2 * height) {
15501 newHeight = newHeight >= 16384 ? Math.floor(newHeight / 2) - 1 : Math.ceil(newHeight / 2);
15502 }
15503 const offscreen = new OffscreenCanvas(newWidth, newHeight);
15504 const ctx = offscreen.getContext("2d");
15505 ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight);
15506 bitmap = offscreen.transferToImageBitmap();
15507 }
15508 return bitmap;
15509 }
15510 #drawBitmap(width, height) {
15511 width = Math.ceil(width);
15512 height = Math.ceil(height);
15513 const canvas = this.#canvas;
15514 if (!canvas || canvas.width === width && canvas.height === height) {
15515 return;
15516 }
15517 canvas.width = width;
15518 canvas.height = height;
15519 const bitmap = this.#isSvg ? this.#bitmap : this.#scaleBitmap(width, height);
15520 if (this._uiManager.hasMLManager && !this.hasAltText()) {
15521 const offscreen = new OffscreenCanvas(width, height);
15522 const ctx = offscreen.getContext("2d");
15523 ctx.drawImage(bitmap, 0, 0, bitmap.width, bitmap.height, 0, 0, width, height);
15524 offscreen.convertToBlob().then(blob => {
15525 const fileReader = new FileReader();
15526 fileReader.onload = () => {
15527 const url = fileReader.result;
15528 this._uiManager.mlGuess({
15529 service: "image-to-text",
15530 request: {
15531 imageData: url
15532 }
15533 }).then(response => {
15534 const altText = response?.output || "";
15535 if (this.parent && altText && !this.hasAltText()) {
15536 this.altTextData = {
15537 altText,
15538 decorative: false
15539 };
15540 }
15541 });
15542 };
15543 fileReader.readAsDataURL(blob);
15544 });
15545 }
15546 const ctx = canvas.getContext("2d");
15547 ctx.filter = this._uiManager.hcmFilter;
15548 ctx.drawImage(bitmap, 0, 0, bitmap.width, bitmap.height, 0, 0, width, height);
15549 }
15550 getImageForAltText() {
15551 return this.#canvas;
15552 }
15553 #serializeBitmap(toUrl) {
15554 if (toUrl) {
15555 if (this.#isSvg) {
15556 const url = this._uiManager.imageManager.getSvgUrl(this.#bitmapId);
15557 if (url) {
15558 return url;
15559 }
15560 }
15561 const canvas = document.createElement("canvas");
15562 ({
15563 width: canvas.width,
15564 height: canvas.height
15565 } = this.#bitmap);
15566 const ctx = canvas.getContext("2d");
15567 ctx.drawImage(this.#bitmap, 0, 0);
15568 return canvas.toDataURL();
15569 }
15570 if (this.#isSvg) {
15571 const [pageWidth, pageHeight] = this.pageDimensions;
15572 const width = Math.round(this.width * pageWidth * display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
15573 const height = Math.round(this.height * pageHeight * display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
15574 const offscreen = new OffscreenCanvas(width, height);
15575 const ctx = offscreen.getContext("2d");
15576 ctx.drawImage(this.#bitmap, 0, 0, this.#bitmap.width, this.#bitmap.height, 0, 0, width, height);
15577 return offscreen.transferToImageBitmap();
15578 }
15579 return structuredClone(this.#bitmap);
15580 }
15581 #createObserver() {
15582 this.#observer = new ResizeObserver(entries => {
15583 const rect = entries[0].contentRect;
15584 if (rect.width && rect.height) {
15585 this.#setDimensions(rect.width, rect.height);
15586 }
15587 });
15588 this.#observer.observe(this.div);
15589 }
15590 static deserialize(data, parent, uiManager) {
15591 if (data instanceof annotation_layer.StampAnnotationElement) {
15592 return null;
15593 }
15594 const editor = super.deserialize(data, parent, uiManager);
15595 const {
15596 rect,
15597 bitmapUrl,
15598 bitmapId,
15599 isSvg,
15600 accessibilityData
15601 } = data;
15602 if (bitmapId && uiManager.imageManager.isValidId(bitmapId)) {
15603 editor.#bitmapId = bitmapId;
15604 } else {
15605 editor.#bitmapUrl = bitmapUrl;
15606 }
15607 editor.#isSvg = isSvg;
15608 const [parentWidth, parentHeight] = editor.pageDimensions;
15609 editor.width = (rect[2] - rect[0]) / parentWidth;
15610 editor.height = (rect[3] - rect[1]) / parentHeight;
15611 if (accessibilityData) {
15612 editor.altTextData = accessibilityData;
15613 }
15614 return editor;
15615 }
15616 serialize() {
15617 let isForCopying = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
15618 let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
15619 if (this.isEmpty()) {
15620 return null;
15621 }
15622 const serialized = {
15623 annotationType: util.AnnotationEditorType.STAMP,
15624 bitmapId: this.#bitmapId,
15625 pageIndex: this.pageIndex,
15626 rect: this.getRect(0, 0),
15627 rotation: this.rotation,
15628 isSvg: this.#isSvg,
15629 structTreeParentId: this._structTreeParentId
15630 };
15631 if (isForCopying) {
15632 serialized.bitmapUrl = this.#serializeBitmap(true);
15633 serialized.accessibilityData = this.altTextData;
15634 return serialized;
15635 }
15636 const {
15637 decorative,
15638 altText
15639 } = this.altTextData;
15640 if (!decorative && altText) {
15641 serialized.accessibilityData = {
15642 type: "Figure",
15643 alt: altText
15644 };
15645 }
15646 if (context === null) {
15647 return serialized;
15648 }
15649 context.stamps ||= new Map();
15650 const area = this.#isSvg ? (serialized.rect[2] - serialized.rect[0]) * (serialized.rect[3] - serialized.rect[1]) : null;
15651 if (!context.stamps.has(this.#bitmapId)) {
15652 context.stamps.set(this.#bitmapId, {
15653 area,
15654 serialized
15655 });
15656 serialized.bitmap = this.#serializeBitmap(false);
15657 } else if (this.#isSvg) {
15658 const prevData = context.stamps.get(this.#bitmapId);
15659 if (area > prevData.area) {
15660 prevData.area = area;
15661 prevData.serialized.bitmap.close();
15662 prevData.serialized.bitmap = this.#serializeBitmap(false);
15663 }
15664 }
15665 return serialized;
15666 }
15667}
15668
15669;// CONCATENATED MODULE: ./src/display/editor/annotation_editor_layer.js
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685class AnnotationEditorLayer {
15686 #accessibilityManager;
15687 #allowClick = false;
15688 #annotationLayer = null;
15689 #boundPointerup = null;
15690 #boundPointerdown = null;
15691 #boundTextLayerPointerDown = null;
15692 #editorFocusTimeoutId = null;
15693 #editors = new Map();
15694 #hadPointerDown = false;
15695 #isCleaningUp = false;
15696 #isDisabling = false;
15697 #textLayer = null;
15698 #uiManager;
15699 static _initialized = false;
15700 static #editorTypes = new Map([FreeTextEditor, InkEditor, StampEditor, HighlightEditor].map(type => [type._editorType, type]));
15701 constructor(_ref) {
15702 let {
15703 uiManager,
15704 pageIndex,
15705 div,
15706 accessibilityManager,
15707 annotationLayer,
15708 drawLayer,
15709 textLayer,
15710 viewport,
15711 l10n
15712 } = _ref;
15713 const editorTypes = [...AnnotationEditorLayer.#editorTypes.values()];
15714 if (!AnnotationEditorLayer._initialized) {
15715 AnnotationEditorLayer._initialized = true;
15716 for (const editorType of editorTypes) {
15717 editorType.initialize(l10n, uiManager);
15718 }
15719 }
15720 uiManager.registerEditorTypes(editorTypes);
15721 this.#uiManager = uiManager;
15722 this.pageIndex = pageIndex;
15723 this.div = div;
15724 this.#accessibilityManager = accessibilityManager;
15725 this.#annotationLayer = annotationLayer;
15726 this.viewport = viewport;
15727 this.#textLayer = textLayer;
15728 this.drawLayer = drawLayer;
15729 this.#uiManager.addLayer(this);
15730 }
15731 get isEmpty() {
15732 return this.#editors.size === 0;
15733 }
15734 get isInvisible() {
15735 return this.isEmpty && this.#uiManager.getMode() === util.AnnotationEditorType.NONE;
15736 }
15737 updateToolbar(mode) {
15738 this.#uiManager.updateToolbar(mode);
15739 }
15740 updateMode() {
15741 let mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.#uiManager.getMode();
15742 this.#cleanup();
15743 switch (mode) {
15744 case util.AnnotationEditorType.NONE:
15745 this.disableTextSelection();
15746 this.togglePointerEvents(false);
15747 this.toggleAnnotationLayerPointerEvents(true);
15748 this.disableClick();
15749 return;
15750 case util.AnnotationEditorType.INK:
15751 this.addInkEditorIfNeeded(false);
15752 this.disableTextSelection();
15753 this.togglePointerEvents(true);
15754 this.disableClick();
15755 break;
15756 case util.AnnotationEditorType.HIGHLIGHT:
15757 this.enableTextSelection();
15758 this.togglePointerEvents(false);
15759 this.disableClick();
15760 break;
15761 default:
15762 this.disableTextSelection();
15763 this.togglePointerEvents(true);
15764 this.enableClick();
15765 }
15766 this.toggleAnnotationLayerPointerEvents(false);
15767 const {
15768 classList
15769 } = this.div;
15770 for (const editorType of AnnotationEditorLayer.#editorTypes.values()) {
15771 classList.toggle(`${editorType._type}Editing`, mode === editorType._editorType);
15772 }
15773 this.div.hidden = false;
15774 }
15775 hasTextLayer(textLayer) {
15776 return textLayer === this.#textLayer?.div;
15777 }
15778 addInkEditorIfNeeded(isCommitting) {
15779 if (this.#uiManager.getMode() !== util.AnnotationEditorType.INK) {
15780 return;
15781 }
15782 if (!isCommitting) {
15783 for (const editor of this.#editors.values()) {
15784 if (editor.isEmpty()) {
15785 editor.setInBackground();
15786 return;
15787 }
15788 }
15789 }
15790 const editor = this.createAndAddNewEditor({
15791 offsetX: 0,
15792 offsetY: 0
15793 }, false);
15794 editor.setInBackground();
15795 }
15796 setEditingState(isEditing) {
15797 this.#uiManager.setEditingState(isEditing);
15798 }
15799 addCommands(params) {
15800 this.#uiManager.addCommands(params);
15801 }
15802 togglePointerEvents() {
15803 let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
15804 this.div.classList.toggle("disabled", !enabled);
15805 }
15806 toggleAnnotationLayerPointerEvents() {
15807 let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
15808 this.#annotationLayer?.div.classList.toggle("disabled", !enabled);
15809 }
15810 enable() {
15811 this.div.tabIndex = 0;
15812 this.togglePointerEvents(true);
15813 const annotationElementIds = new Set();
15814 for (const editor of this.#editors.values()) {
15815 editor.enableEditing();
15816 if (editor.annotationElementId) {
15817 annotationElementIds.add(editor.annotationElementId);
15818 }
15819 }
15820 if (!this.#annotationLayer) {
15821 return;
15822 }
15823 const editables = this.#annotationLayer.getEditableAnnotations();
15824 for (const editable of editables) {
15825 editable.hide();
15826 if (this.#uiManager.isDeletedAnnotationElement(editable.data.id)) {
15827 continue;
15828 }
15829 if (annotationElementIds.has(editable.data.id)) {
15830 continue;
15831 }
15832 const editor = this.deserialize(editable);
15833 if (!editor) {
15834 continue;
15835 }
15836 this.addOrRebuild(editor);
15837 editor.enableEditing();
15838 }
15839 }
15840 disable() {
15841 this.#isDisabling = true;
15842 this.div.tabIndex = -1;
15843 this.togglePointerEvents(false);
15844 const hiddenAnnotationIds = new Set();
15845 for (const editor of this.#editors.values()) {
15846 editor.disableEditing();
15847 if (!editor.annotationElementId || editor.serialize() !== null) {
15848 hiddenAnnotationIds.add(editor.annotationElementId);
15849 continue;
15850 }
15851 this.getEditableAnnotation(editor.annotationElementId)?.show();
15852 editor.remove();
15853 }
15854 if (this.#annotationLayer) {
15855 const editables = this.#annotationLayer.getEditableAnnotations();
15856 for (const editable of editables) {
15857 const {
15858 id
15859 } = editable.data;
15860 if (hiddenAnnotationIds.has(id) || this.#uiManager.isDeletedAnnotationElement(id)) {
15861 continue;
15862 }
15863 editable.show();
15864 }
15865 }
15866 this.#cleanup();
15867 if (this.isEmpty) {
15868 this.div.hidden = true;
15869 }
15870 const {
15871 classList
15872 } = this.div;
15873 for (const editorType of AnnotationEditorLayer.#editorTypes.values()) {
15874 classList.remove(`${editorType._type}Editing`);
15875 }
15876 this.disableTextSelection();
15877 this.toggleAnnotationLayerPointerEvents(true);
15878 this.#isDisabling = false;
15879 }
15880 getEditableAnnotation(id) {
15881 return this.#annotationLayer?.getEditableAnnotation(id) || null;
15882 }
15883 setActiveEditor(editor) {
15884 const currentActive = this.#uiManager.getActive();
15885 if (currentActive === editor) {
15886 return;
15887 }
15888 this.#uiManager.setActiveEditor(editor);
15889 }
15890 enableTextSelection() {
15891 this.div.tabIndex = -1;
15892 if (this.#textLayer?.div && !this.#boundTextLayerPointerDown) {
15893 this.#boundTextLayerPointerDown = this.#textLayerPointerDown.bind(this);
15894 this.#textLayer.div.addEventListener("pointerdown", this.#boundTextLayerPointerDown);
15895 this.#textLayer.div.classList.add("highlighting");
15896 }
15897 }
15898 disableTextSelection() {
15899 this.div.tabIndex = 0;
15900 if (this.#textLayer?.div && this.#boundTextLayerPointerDown) {
15901 this.#textLayer.div.removeEventListener("pointerdown", this.#boundTextLayerPointerDown);
15902 this.#boundTextLayerPointerDown = null;
15903 this.#textLayer.div.classList.remove("highlighting");
15904 }
15905 }
15906 #textLayerPointerDown(event) {
15907 this.#uiManager.unselectAll();
15908 if (event.target === this.#textLayer.div) {
15909 const {
15910 isMac
15911 } = util.FeatureTest.platform;
15912 if (event.button !== 0 || event.ctrlKey && isMac) {
15913 return;
15914 }
15915 this.#uiManager.showAllEditors("highlight", true, true);
15916 this.#textLayer.div.classList.add("free");
15917 HighlightEditor.startHighlighting(this, this.#uiManager.direction === "ltr", event);
15918 this.#textLayer.div.addEventListener("pointerup", () => {
15919 this.#textLayer.div.classList.remove("free");
15920 }, {
15921 once: true
15922 });
15923 event.preventDefault();
15924 }
15925 }
15926 enableClick() {
15927 if (this.#boundPointerdown) {
15928 return;
15929 }
15930 this.#boundPointerdown = this.pointerdown.bind(this);
15931 this.#boundPointerup = this.pointerup.bind(this);
15932 this.div.addEventListener("pointerdown", this.#boundPointerdown);
15933 this.div.addEventListener("pointerup", this.#boundPointerup);
15934 }
15935 disableClick() {
15936 if (!this.#boundPointerdown) {
15937 return;
15938 }
15939 this.div.removeEventListener("pointerdown", this.#boundPointerdown);
15940 this.div.removeEventListener("pointerup", this.#boundPointerup);
15941 this.#boundPointerdown = null;
15942 this.#boundPointerup = null;
15943 }
15944 attach(editor) {
15945 this.#editors.set(editor.id, editor);
15946 const {
15947 annotationElementId
15948 } = editor;
15949 if (annotationElementId && this.#uiManager.isDeletedAnnotationElement(annotationElementId)) {
15950 this.#uiManager.removeDeletedAnnotationElement(editor);
15951 }
15952 }
15953 detach(editor) {
15954 this.#editors.delete(editor.id);
15955 this.#accessibilityManager?.removePointerInTextLayer(editor.contentDiv);
15956 if (!this.#isDisabling && editor.annotationElementId) {
15957 this.#uiManager.addDeletedAnnotationElement(editor);
15958 }
15959 }
15960 remove(editor) {
15961 this.detach(editor);
15962 this.#uiManager.removeEditor(editor);
15963 editor.div.remove();
15964 editor.isAttachedToDOM = false;
15965 if (!this.#isCleaningUp) {
15966 this.addInkEditorIfNeeded(false);
15967 }
15968 }
15969 changeParent(editor) {
15970 if (editor.parent === this) {
15971 return;
15972 }
15973 if (editor.annotationElementId) {
15974 this.#uiManager.addDeletedAnnotationElement(editor.annotationElementId);
15975 editor_editor.AnnotationEditor.deleteAnnotationElement(editor);
15976 editor.annotationElementId = null;
15977 }
15978 this.attach(editor);
15979 editor.parent?.detach(editor);
15980 editor.setParent(this);
15981 if (editor.div && editor.isAttachedToDOM) {
15982 editor.div.remove();
15983 this.div.append(editor.div);
15984 }
15985 }
15986 add(editor) {
15987 if (editor.parent === this && editor.isAttachedToDOM) {
15988 return;
15989 }
15990 this.changeParent(editor);
15991 this.#uiManager.addEditor(editor);
15992 this.attach(editor);
15993 if (!editor.isAttachedToDOM) {
15994 const div = editor.render();
15995 this.div.append(div);
15996 editor.isAttachedToDOM = true;
15997 }
15998 editor.fixAndSetPosition();
15999 editor.onceAdded();
16000 this.#uiManager.addToAnnotationStorage(editor);
16001 editor._reportTelemetry(editor.telemetryInitialData);
16002 }
16003 moveEditorInDOM(editor) {
16004 if (!editor.isAttachedToDOM) {
16005 return;
16006 }
16007 const {
16008 activeElement
16009 } = document;
16010 if (editor.div.contains(activeElement) && !this.#editorFocusTimeoutId) {
16011 editor._focusEventsAllowed = false;
16012 this.#editorFocusTimeoutId = setTimeout(() => {
16013 this.#editorFocusTimeoutId = null;
16014 if (!editor.div.contains(document.activeElement)) {
16015 editor.div.addEventListener("focusin", () => {
16016 editor._focusEventsAllowed = true;
16017 }, {
16018 once: true
16019 });
16020 activeElement.focus();
16021 } else {
16022 editor._focusEventsAllowed = true;
16023 }
16024 }, 0);
16025 }
16026 editor._structTreeParentId = this.#accessibilityManager?.moveElementInDOM(this.div, editor.div, editor.contentDiv, true);
16027 }
16028 addOrRebuild(editor) {
16029 if (editor.needsToBeRebuilt()) {
16030 editor.parent ||= this;
16031 editor.rebuild();
16032 editor.show();
16033 } else {
16034 this.add(editor);
16035 }
16036 }
16037 addUndoableEditor(editor) {
16038 const cmd = () => editor._uiManager.rebuild(editor);
16039 const undo = () => {
16040 editor.remove();
16041 };
16042 this.addCommands({
16043 cmd,
16044 undo,
16045 mustExec: false
16046 });
16047 }
16048 getNextId() {
16049 return this.#uiManager.getId();
16050 }
16051 get #currentEditorType() {
16052 return AnnotationEditorLayer.#editorTypes.get(this.#uiManager.getMode());
16053 }
16054 #createNewEditor(params) {
16055 const editorType = this.#currentEditorType;
16056 return editorType ? new editorType.prototype.constructor(params) : null;
16057 }
16058 canCreateNewEmptyEditor() {
16059 return this.#currentEditorType?.canCreateNewEmptyEditor();
16060 }
16061 pasteEditor(mode, params) {
16062 this.#uiManager.updateToolbar(mode);
16063 this.#uiManager.updateMode(mode);
16064 const {
16065 offsetX,
16066 offsetY
16067 } = this.#getCenterPoint();
16068 const id = this.getNextId();
16069 const editor = this.#createNewEditor({
16070 parent: this,
16071 id,
16072 x: offsetX,
16073 y: offsetY,
16074 uiManager: this.#uiManager,
16075 isCentered: true,
16076 ...params
16077 });
16078 if (editor) {
16079 this.add(editor);
16080 }
16081 }
16082 deserialize(data) {
16083 return AnnotationEditorLayer.#editorTypes.get(data.annotationType ?? data.annotationEditorType)?.deserialize(data, this, this.#uiManager) || null;
16084 }
16085 createAndAddNewEditor(event, isCentered) {
16086 let data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
16087 const id = this.getNextId();
16088 const editor = this.#createNewEditor({
16089 parent: this,
16090 id,
16091 x: event.offsetX,
16092 y: event.offsetY,
16093 uiManager: this.#uiManager,
16094 isCentered,
16095 ...data
16096 });
16097 if (editor) {
16098 this.add(editor);
16099 }
16100 return editor;
16101 }
16102 #getCenterPoint() {
16103 const {
16104 x,
16105 y,
16106 width,
16107 height
16108 } = this.div.getBoundingClientRect();
16109 const tlX = Math.max(0, x);
16110 const tlY = Math.max(0, y);
16111 const brX = Math.min(window.innerWidth, x + width);
16112 const brY = Math.min(window.innerHeight, y + height);
16113 const centerX = (tlX + brX) / 2 - x;
16114 const centerY = (tlY + brY) / 2 - y;
16115 const [offsetX, offsetY] = this.viewport.rotation % 180 === 0 ? [centerX, centerY] : [centerY, centerX];
16116 return {
16117 offsetX,
16118 offsetY
16119 };
16120 }
16121 addNewEditor() {
16122 this.createAndAddNewEditor(this.#getCenterPoint(), true);
16123 }
16124 setSelected(editor) {
16125 this.#uiManager.setSelected(editor);
16126 }
16127 toggleSelected(editor) {
16128 this.#uiManager.toggleSelected(editor);
16129 }
16130 isSelected(editor) {
16131 return this.#uiManager.isSelected(editor);
16132 }
16133 unselect(editor) {
16134 this.#uiManager.unselect(editor);
16135 }
16136 pointerup(event) {
16137 const {
16138 isMac
16139 } = util.FeatureTest.platform;
16140 if (event.button !== 0 || event.ctrlKey && isMac) {
16141 return;
16142 }
16143 if (event.target !== this.div) {
16144 return;
16145 }
16146 if (!this.#hadPointerDown) {
16147 return;
16148 }
16149 this.#hadPointerDown = false;
16150 if (!this.#allowClick) {
16151 this.#allowClick = true;
16152 return;
16153 }
16154 if (this.#uiManager.getMode() === util.AnnotationEditorType.STAMP) {
16155 this.#uiManager.unselectAll();
16156 return;
16157 }
16158 this.createAndAddNewEditor(event, false);
16159 }
16160 pointerdown(event) {
16161 if (this.#uiManager.getMode() === util.AnnotationEditorType.HIGHLIGHT) {
16162 this.enableTextSelection();
16163 }
16164 if (this.#hadPointerDown) {
16165 this.#hadPointerDown = false;
16166 return;
16167 }
16168 const {
16169 isMac
16170 } = util.FeatureTest.platform;
16171 if (event.button !== 0 || event.ctrlKey && isMac) {
16172 return;
16173 }
16174 if (event.target !== this.div) {
16175 return;
16176 }
16177 this.#hadPointerDown = true;
16178 const editor = this.#uiManager.getActive();
16179 this.#allowClick = !editor || editor.isEmpty();
16180 }
16181 findNewParent(editor, x, y) {
16182 const layer = this.#uiManager.findParent(x, y);
16183 if (layer === null || layer === this) {
16184 return false;
16185 }
16186 layer.changeParent(editor);
16187 return true;
16188 }
16189 destroy() {
16190 if (this.#uiManager.getActive()?.parent === this) {
16191 this.#uiManager.commitOrRemove();
16192 this.#uiManager.setActiveEditor(null);
16193 }
16194 if (this.#editorFocusTimeoutId) {
16195 clearTimeout(this.#editorFocusTimeoutId);
16196 this.#editorFocusTimeoutId = null;
16197 }
16198 for (const editor of this.#editors.values()) {
16199 this.#accessibilityManager?.removePointerInTextLayer(editor.contentDiv);
16200 editor.setParent(null);
16201 editor.isAttachedToDOM = false;
16202 editor.div.remove();
16203 }
16204 this.div = null;
16205 this.#editors.clear();
16206 this.#uiManager.removeLayer(this);
16207 }
16208 #cleanup() {
16209 this.#isCleaningUp = true;
16210 for (const editor of this.#editors.values()) {
16211 if (editor.isEmpty()) {
16212 editor.remove();
16213 }
16214 }
16215 this.#isCleaningUp = false;
16216 }
16217 render(_ref2) {
16218 let {
16219 viewport
16220 } = _ref2;
16221 this.viewport = viewport;
16222 (0,display_utils.setLayerDimensions)(this.div, viewport);
16223 for (const editor of this.#uiManager.getEditors(this.pageIndex)) {
16224 this.add(editor);
16225 editor.rebuild();
16226 }
16227 this.updateMode();
16228 }
16229 update(_ref3) {
16230 let {
16231 viewport
16232 } = _ref3;
16233 this.#uiManager.commitOrRemove();
16234 this.#cleanup();
16235 const oldRotation = this.viewport.rotation;
16236 const rotation = viewport.rotation;
16237 this.viewport = viewport;
16238 (0,display_utils.setLayerDimensions)(this.div, {
16239 rotation
16240 });
16241 if (oldRotation !== rotation) {
16242 for (const editor of this.#editors.values()) {
16243 editor.rotate(rotation);
16244 }
16245 }
16246 this.addInkEditorIfNeeded(false);
16247 }
16248 get pageDimensions() {
16249 const {
16250 pageWidth,
16251 pageHeight
16252 } = this.viewport.rawDims;
16253 return [pageWidth, pageHeight];
16254 }
16255 get scale() {
16256 return this.#uiManager.viewParameters.realScale;
16257 }
16258}
16259
16260
16261/***/ }),
16262
16263/***/ 2259:
16264/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
16265
16266/* harmony export */ __webpack_require__.d(__webpack_exports__, {
16267/* harmony export */ ColorPicker: () => (/* binding */ ColorPicker)
16268/* harmony export */ });
16269/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4292);
16270/* harmony import */ var _tools_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7830);
16271/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5419);
16272
16273
16274
16275class ColorPicker {
16276 #boundKeyDown = this.#keyDown.bind(this);
16277 #boundPointerDown = this.#pointerDown.bind(this);
16278 #button = null;
16279 #buttonSwatch = null;
16280 #defaultColor;
16281 #dropdown = null;
16282 #dropdownWasFromKeyboard = false;
16283 #isMainColorPicker = false;
16284 #editor = null;
16285 #eventBus;
16286 #uiManager = null;
16287 #type;
16288 static get _keyboardManager() {
16289 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_keyboardManager", new _tools_js__WEBPACK_IMPORTED_MODULE_1__.KeyboardManager([[["Escape", "mac+Escape"], ColorPicker.prototype._hideDropdownFromKeyboard], [[" ", "mac+ "], ColorPicker.prototype._colorSelectFromKeyboard], [["ArrowDown", "ArrowRight", "mac+ArrowDown", "mac+ArrowRight"], ColorPicker.prototype._moveToNext], [["ArrowUp", "ArrowLeft", "mac+ArrowUp", "mac+ArrowLeft"], ColorPicker.prototype._moveToPrevious], [["Home", "mac+Home"], ColorPicker.prototype._moveToBeginning], [["End", "mac+End"], ColorPicker.prototype._moveToEnd]]));
16290 }
16291 constructor(_ref) {
16292 let {
16293 editor = null,
16294 uiManager = null
16295 } = _ref;
16296 if (editor) {
16297 this.#isMainColorPicker = false;
16298 this.#type = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.HIGHLIGHT_COLOR;
16299 this.#editor = editor;
16300 } else {
16301 this.#isMainColorPicker = true;
16302 this.#type = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR;
16303 }
16304 this.#uiManager = editor?._uiManager || uiManager;
16305 this.#eventBus = this.#uiManager._eventBus;
16306 this.#defaultColor = editor?.color || this.#uiManager?.highlightColors.values().next().value || "#FFFF98";
16307 }
16308 renderButton() {
16309 const button = this.#button = document.createElement("button");
16310 button.className = "colorPicker";
16311 button.tabIndex = "0";
16312 button.setAttribute("data-l10n-id", "pdfjs-editor-colorpicker-button");
16313 button.setAttribute("aria-haspopup", true);
16314 button.addEventListener("click", this.#openDropdown.bind(this));
16315 button.addEventListener("keydown", this.#boundKeyDown);
16316 const swatch = this.#buttonSwatch = document.createElement("span");
16317 swatch.className = "swatch";
16318 swatch.setAttribute("aria-hidden", true);
16319 swatch.style.backgroundColor = this.#defaultColor;
16320 button.append(swatch);
16321 return button;
16322 }
16323 renderMainDropdown() {
16324 const dropdown = this.#dropdown = this.#getDropdownRoot();
16325 dropdown.setAttribute("aria-orientation", "horizontal");
16326 dropdown.setAttribute("aria-labelledby", "highlightColorPickerLabel");
16327 return dropdown;
16328 }
16329 #getDropdownRoot() {
16330 const div = document.createElement("div");
16331 div.addEventListener("contextmenu", _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.noContextMenu);
16332 div.className = "dropdown";
16333 div.role = "listbox";
16334 div.setAttribute("aria-multiselectable", false);
16335 div.setAttribute("aria-orientation", "vertical");
16336 div.setAttribute("data-l10n-id", "pdfjs-editor-colorpicker-dropdown");
16337 for (const [name, color] of this.#uiManager.highlightColors) {
16338 const button = document.createElement("button");
16339 button.tabIndex = "0";
16340 button.role = "option";
16341 button.setAttribute("data-color", color);
16342 button.title = name;
16343 button.setAttribute("data-l10n-id", `pdfjs-editor-colorpicker-${name}`);
16344 const swatch = document.createElement("span");
16345 button.append(swatch);
16346 swatch.className = "swatch";
16347 swatch.style.backgroundColor = color;
16348 button.setAttribute("aria-selected", color === this.#defaultColor);
16349 button.addEventListener("click", this.#colorSelect.bind(this, color));
16350 div.append(button);
16351 }
16352 div.addEventListener("keydown", this.#boundKeyDown);
16353 return div;
16354 }
16355 #colorSelect(color, event) {
16356 event.stopPropagation();
16357 this.#eventBus.dispatch("switchannotationeditorparams", {
16358 source: this,
16359 type: this.#type,
16360 value: color
16361 });
16362 }
16363 _colorSelectFromKeyboard(event) {
16364 if (event.target === this.#button) {
16365 this.#openDropdown(event);
16366 return;
16367 }
16368 const color = event.target.getAttribute("data-color");
16369 if (!color) {
16370 return;
16371 }
16372 this.#colorSelect(color, event);
16373 }
16374 _moveToNext(event) {
16375 if (!this.#isDropdownVisible) {
16376 this.#openDropdown(event);
16377 return;
16378 }
16379 if (event.target === this.#button) {
16380 this.#dropdown.firstChild?.focus();
16381 return;
16382 }
16383 event.target.nextSibling?.focus();
16384 }
16385 _moveToPrevious(event) {
16386 if (event.target === this.#dropdown?.firstChild || event.target === this.#button) {
16387 if (this.#isDropdownVisible) {
16388 this._hideDropdownFromKeyboard();
16389 }
16390 return;
16391 }
16392 if (!this.#isDropdownVisible) {
16393 this.#openDropdown(event);
16394 }
16395 event.target.previousSibling?.focus();
16396 }
16397 _moveToBeginning(event) {
16398 if (!this.#isDropdownVisible) {
16399 this.#openDropdown(event);
16400 return;
16401 }
16402 this.#dropdown.firstChild?.focus();
16403 }
16404 _moveToEnd(event) {
16405 if (!this.#isDropdownVisible) {
16406 this.#openDropdown(event);
16407 return;
16408 }
16409 this.#dropdown.lastChild?.focus();
16410 }
16411 #keyDown(event) {
16412 ColorPicker._keyboardManager.exec(this, event);
16413 }
16414 #openDropdown(event) {
16415 if (this.#isDropdownVisible) {
16416 this.hideDropdown();
16417 return;
16418 }
16419 this.#dropdownWasFromKeyboard = event.detail === 0;
16420 window.addEventListener("pointerdown", this.#boundPointerDown);
16421 if (this.#dropdown) {
16422 this.#dropdown.classList.remove("hidden");
16423 return;
16424 }
16425 const root = this.#dropdown = this.#getDropdownRoot();
16426 this.#button.append(root);
16427 }
16428 #pointerDown(event) {
16429 if (this.#dropdown?.contains(event.target)) {
16430 return;
16431 }
16432 this.hideDropdown();
16433 }
16434 hideDropdown() {
16435 this.#dropdown?.classList.add("hidden");
16436 window.removeEventListener("pointerdown", this.#boundPointerDown);
16437 }
16438 get #isDropdownVisible() {
16439 return this.#dropdown && !this.#dropdown.classList.contains("hidden");
16440 }
16441 _hideDropdownFromKeyboard() {
16442 if (this.#isMainColorPicker) {
16443 return;
16444 }
16445 if (!this.#isDropdownVisible) {
16446 this.#editor?.unselect();
16447 return;
16448 }
16449 this.hideDropdown();
16450 this.#button.focus({
16451 preventScroll: true,
16452 focusVisible: this.#dropdownWasFromKeyboard
16453 });
16454 }
16455 updateColor(color) {
16456 if (this.#buttonSwatch) {
16457 this.#buttonSwatch.style.backgroundColor = color;
16458 }
16459 if (!this.#dropdown) {
16460 return;
16461 }
16462 const i = this.#uiManager.highlightColors.values();
16463 for (const child of this.#dropdown.children) {
16464 child.setAttribute("aria-selected", i.next().value === color);
16465 }
16466 }
16467 destroy() {
16468 this.#button?.remove();
16469 this.#button = null;
16470 this.#buttonSwatch = null;
16471 this.#dropdown?.remove();
16472 this.#dropdown = null;
16473 }
16474}
16475
16476
16477/***/ }),
16478
16479/***/ 310:
16480/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
16481
16482
16483// EXPORTS
16484__webpack_require__.d(__webpack_exports__, {
16485 AnnotationEditor: () => (/* binding */ AnnotationEditor)
16486});
16487
16488// EXTERNAL MODULE: ./src/display/editor/tools.js
16489var tools = __webpack_require__(7830);
16490// EXTERNAL MODULE: ./src/shared/util.js
16491var util = __webpack_require__(4292);
16492// EXTERNAL MODULE: ./src/display/display_utils.js
16493var display_utils = __webpack_require__(5419);
16494;// CONCATENATED MODULE: ./src/display/editor/alt_text.js
16495
16496class AltText {
16497 #altText = "";
16498 #altTextDecorative = false;
16499 #altTextButton = null;
16500 #altTextTooltip = null;
16501 #altTextTooltipTimeout = null;
16502 #altTextWasFromKeyBoard = false;
16503 #editor = null;
16504 static _l10nPromise = null;
16505 constructor(editor) {
16506 this.#editor = editor;
16507 }
16508 static initialize(l10nPromise) {
16509 AltText._l10nPromise ||= l10nPromise;
16510 }
16511 async render() {
16512 const altText = this.#altTextButton = document.createElement("button");
16513 altText.className = "altText";
16514 const msg = await AltText._l10nPromise.get("pdfjs-editor-alt-text-button-label");
16515 altText.textContent = msg;
16516 altText.setAttribute("aria-label", msg);
16517 altText.tabIndex = "0";
16518 altText.addEventListener("contextmenu", display_utils.noContextMenu);
16519 altText.addEventListener("pointerdown", event => event.stopPropagation());
16520 const onClick = event => {
16521 event.preventDefault();
16522 this.#editor._uiManager.editAltText(this.#editor);
16523 };
16524 altText.addEventListener("click", onClick, {
16525 capture: true
16526 });
16527 altText.addEventListener("keydown", event => {
16528 if (event.target === altText && event.key === "Enter") {
16529 this.#altTextWasFromKeyBoard = true;
16530 onClick(event);
16531 }
16532 });
16533 await this.#setState();
16534 return altText;
16535 }
16536 finish() {
16537 if (!this.#altTextButton) {
16538 return;
16539 }
16540 this.#altTextButton.focus({
16541 focusVisible: this.#altTextWasFromKeyBoard
16542 });
16543 this.#altTextWasFromKeyBoard = false;
16544 }
16545 isEmpty() {
16546 return !this.#altText && !this.#altTextDecorative;
16547 }
16548 get data() {
16549 return {
16550 altText: this.#altText,
16551 decorative: this.#altTextDecorative
16552 };
16553 }
16554 set data(_ref) {
16555 let {
16556 altText,
16557 decorative
16558 } = _ref;
16559 if (this.#altText === altText && this.#altTextDecorative === decorative) {
16560 return;
16561 }
16562 this.#altText = altText;
16563 this.#altTextDecorative = decorative;
16564 this.#setState();
16565 }
16566 toggle() {
16567 let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
16568 if (!this.#altTextButton) {
16569 return;
16570 }
16571 if (!enabled && this.#altTextTooltipTimeout) {
16572 clearTimeout(this.#altTextTooltipTimeout);
16573 this.#altTextTooltipTimeout = null;
16574 }
16575 this.#altTextButton.disabled = !enabled;
16576 }
16577 destroy() {
16578 this.#altTextButton?.remove();
16579 this.#altTextButton = null;
16580 this.#altTextTooltip = null;
16581 }
16582 async #setState() {
16583 const button = this.#altTextButton;
16584 if (!button) {
16585 return;
16586 }
16587 if (!this.#altText && !this.#altTextDecorative) {
16588 button.classList.remove("done");
16589 this.#altTextTooltip?.remove();
16590 return;
16591 }
16592 button.classList.add("done");
16593 AltText._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(msg => {
16594 button.setAttribute("aria-label", msg);
16595 });
16596 let tooltip = this.#altTextTooltip;
16597 if (!tooltip) {
16598 this.#altTextTooltip = tooltip = document.createElement("span");
16599 tooltip.className = "tooltip";
16600 tooltip.setAttribute("role", "tooltip");
16601 const id = tooltip.id = `alt-text-tooltip-${this.#editor.id}`;
16602 button.setAttribute("aria-describedby", id);
16603 const DELAY_TO_SHOW_TOOLTIP = 100;
16604 button.addEventListener("mouseenter", () => {
16605 this.#altTextTooltipTimeout = setTimeout(() => {
16606 this.#altTextTooltipTimeout = null;
16607 this.#altTextTooltip.classList.add("show");
16608 this.#editor._reportTelemetry({
16609 action: "alt_text_tooltip"
16610 });
16611 }, DELAY_TO_SHOW_TOOLTIP);
16612 });
16613 button.addEventListener("mouseleave", () => {
16614 if (this.#altTextTooltipTimeout) {
16615 clearTimeout(this.#altTextTooltipTimeout);
16616 this.#altTextTooltipTimeout = null;
16617 }
16618 this.#altTextTooltip?.classList.remove("show");
16619 });
16620 }
16621 tooltip.innerText = this.#altTextDecorative ? await AltText._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip") : this.#altText;
16622 if (!tooltip.parentNode) {
16623 button.append(tooltip);
16624 }
16625 const element = this.#editor.getImageForAltText();
16626 element?.setAttribute("aria-describedby", tooltip.id);
16627 }
16628}
16629
16630// EXTERNAL MODULE: ./src/display/editor/toolbar.js
16631var toolbar = __webpack_require__(4362);
16632;// CONCATENATED MODULE: ./src/display/editor/editor.js
16633
16634
16635
16636
16637
16638class AnnotationEditor {
16639 #allResizerDivs = null;
16640 #altText = null;
16641 #disabled = false;
16642 #keepAspectRatio = false;
16643 #resizersDiv = null;
16644 #savedDimensions = null;
16645 #boundFocusin = this.focusin.bind(this);
16646 #boundFocusout = this.focusout.bind(this);
16647 #editToolbar = null;
16648 #focusedResizerName = "";
16649 #hasBeenClicked = false;
16650 #initialPosition = null;
16651 #isEditing = false;
16652 #isInEditMode = false;
16653 #isResizerEnabledForKeyboard = false;
16654 #moveInDOMTimeout = null;
16655 #prevDragX = 0;
16656 #prevDragY = 0;
16657 #telemetryTimeouts = null;
16658 _initialOptions = Object.create(null);
16659 _isVisible = true;
16660 _uiManager = null;
16661 _focusEventsAllowed = true;
16662 _l10nPromise = null;
16663 #isDraggable = false;
16664 #zIndex = AnnotationEditor._zIndex++;
16665 static _borderLineWidth = -1;
16666 static _colorManager = new tools.ColorManager();
16667 static _zIndex = 1;
16668 static _telemetryTimeout = 1000;
16669 static get _resizerKeyboardManager() {
16670 const resize = AnnotationEditor.prototype._resizeWithKeyboard;
16671 const small = tools.AnnotationEditorUIManager.TRANSLATE_SMALL;
16672 const big = tools.AnnotationEditorUIManager.TRANSLATE_BIG;
16673 return (0,util.shadow)(this, "_resizerKeyboardManager", new tools.KeyboardManager([[["ArrowLeft", "mac+ArrowLeft"], resize, {
16674 args: [-small, 0]
16675 }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], resize, {
16676 args: [-big, 0]
16677 }], [["ArrowRight", "mac+ArrowRight"], resize, {
16678 args: [small, 0]
16679 }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], resize, {
16680 args: [big, 0]
16681 }], [["ArrowUp", "mac+ArrowUp"], resize, {
16682 args: [0, -small]
16683 }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], resize, {
16684 args: [0, -big]
16685 }], [["ArrowDown", "mac+ArrowDown"], resize, {
16686 args: [0, small]
16687 }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], resize, {
16688 args: [0, big]
16689 }], [["Escape", "mac+Escape"], AnnotationEditor.prototype._stopResizingWithKeyboard]]));
16690 }
16691 constructor(parameters) {
16692 if (this.constructor === AnnotationEditor) {
16693 (0,util.unreachable)("Cannot initialize AnnotationEditor.");
16694 }
16695 this.parent = parameters.parent;
16696 this.id = parameters.id;
16697 this.width = this.height = null;
16698 this.pageIndex = parameters.parent.pageIndex;
16699 this.name = parameters.name;
16700 this.div = null;
16701 this._uiManager = parameters.uiManager;
16702 this.annotationElementId = null;
16703 this._willKeepAspectRatio = false;
16704 this._initialOptions.isCentered = parameters.isCentered;
16705 this._structTreeParentId = null;
16706 const {
16707 rotation,
16708 rawDims: {
16709 pageWidth,
16710 pageHeight,
16711 pageX,
16712 pageY
16713 }
16714 } = this.parent.viewport;
16715 this.rotation = rotation;
16716 this.pageRotation = (360 + rotation - this._uiManager.viewParameters.rotation) % 360;
16717 this.pageDimensions = [pageWidth, pageHeight];
16718 this.pageTranslation = [pageX, pageY];
16719 const [width, height] = this.parentDimensions;
16720 this.x = parameters.x / width;
16721 this.y = parameters.y / height;
16722 this.isAttachedToDOM = false;
16723 this.deleted = false;
16724 }
16725 get editorType() {
16726 return Object.getPrototypeOf(this).constructor._type;
16727 }
16728 static get _defaultLineColor() {
16729 return (0,util.shadow)(this, "_defaultLineColor", this._colorManager.getHexCode("CanvasText"));
16730 }
16731 static deleteAnnotationElement(editor) {
16732 const fakeEditor = new FakeEditor({
16733 id: editor.parent.getNextId(),
16734 parent: editor.parent,
16735 uiManager: editor._uiManager
16736 });
16737 fakeEditor.annotationElementId = editor.annotationElementId;
16738 fakeEditor.deleted = true;
16739 fakeEditor._uiManager.addToAnnotationStorage(fakeEditor);
16740 }
16741 static initialize(l10n, _uiManager, options) {
16742 AnnotationEditor._l10nPromise ||= new Map(["pdfjs-editor-alt-text-button-label", "pdfjs-editor-alt-text-edit-button-label", "pdfjs-editor-alt-text-decorative-tooltip", "pdfjs-editor-resizer-label-topLeft", "pdfjs-editor-resizer-label-topMiddle", "pdfjs-editor-resizer-label-topRight", "pdfjs-editor-resizer-label-middleRight", "pdfjs-editor-resizer-label-bottomRight", "pdfjs-editor-resizer-label-bottomMiddle", "pdfjs-editor-resizer-label-bottomLeft", "pdfjs-editor-resizer-label-middleLeft"].map(str => [str, l10n.get(str.replaceAll(/([A-Z])/g, c => `-${c.toLowerCase()}`))]));
16743 if (options?.strings) {
16744 for (const str of options.strings) {
16745 AnnotationEditor._l10nPromise.set(str, l10n.get(str));
16746 }
16747 }
16748 if (AnnotationEditor._borderLineWidth !== -1) {
16749 return;
16750 }
16751 const style = getComputedStyle(document.documentElement);
16752 AnnotationEditor._borderLineWidth = parseFloat(style.getPropertyValue("--outline-width")) || 0;
16753 }
16754 static updateDefaultParams(_type, _value) {}
16755 static get defaultPropertiesToUpdate() {
16756 return [];
16757 }
16758 static isHandlingMimeForPasting(mime) {
16759 return false;
16760 }
16761 static paste(item, parent) {
16762 (0,util.unreachable)("Not implemented");
16763 }
16764 get propertiesToUpdate() {
16765 return [];
16766 }
16767 get _isDraggable() {
16768 return this.#isDraggable;
16769 }
16770 set _isDraggable(value) {
16771 this.#isDraggable = value;
16772 this.div?.classList.toggle("draggable", value);
16773 }
16774 get isEnterHandled() {
16775 return true;
16776 }
16777 center() {
16778 const [pageWidth, pageHeight] = this.pageDimensions;
16779 switch (this.parentRotation) {
16780 case 90:
16781 this.x -= this.height * pageHeight / (pageWidth * 2);
16782 this.y += this.width * pageWidth / (pageHeight * 2);
16783 break;
16784 case 180:
16785 this.x += this.width / 2;
16786 this.y += this.height / 2;
16787 break;
16788 case 270:
16789 this.x += this.height * pageHeight / (pageWidth * 2);
16790 this.y -= this.width * pageWidth / (pageHeight * 2);
16791 break;
16792 default:
16793 this.x -= this.width / 2;
16794 this.y -= this.height / 2;
16795 break;
16796 }
16797 this.fixAndSetPosition();
16798 }
16799 addCommands(params) {
16800 this._uiManager.addCommands(params);
16801 }
16802 get currentLayer() {
16803 return this._uiManager.currentLayer;
16804 }
16805 setInBackground() {
16806 this.div.style.zIndex = 0;
16807 }
16808 setInForeground() {
16809 this.div.style.zIndex = this.#zIndex;
16810 }
16811 setParent(parent) {
16812 if (parent !== null) {
16813 this.pageIndex = parent.pageIndex;
16814 this.pageDimensions = parent.pageDimensions;
16815 } else {
16816 this.#stopResizing();
16817 }
16818 this.parent = parent;
16819 }
16820 focusin(event) {
16821 if (!this._focusEventsAllowed) {
16822 return;
16823 }
16824 if (!this.#hasBeenClicked) {
16825 this.parent.setSelected(this);
16826 } else {
16827 this.#hasBeenClicked = false;
16828 }
16829 }
16830 focusout(event) {
16831 if (!this._focusEventsAllowed) {
16832 return;
16833 }
16834 if (!this.isAttachedToDOM) {
16835 return;
16836 }
16837 const target = event.relatedTarget;
16838 if (target?.closest(`#${this.id}`)) {
16839 return;
16840 }
16841 event.preventDefault();
16842 if (!this.parent?.isMultipleSelection) {
16843 this.commitOrRemove();
16844 }
16845 }
16846 commitOrRemove() {
16847 if (this.isEmpty()) {
16848 this.remove();
16849 } else {
16850 this.commit();
16851 }
16852 }
16853 commit() {
16854 this.addToAnnotationStorage();
16855 }
16856 addToAnnotationStorage() {
16857 this._uiManager.addToAnnotationStorage(this);
16858 }
16859 setAt(x, y, tx, ty) {
16860 const [width, height] = this.parentDimensions;
16861 [tx, ty] = this.screenToPageTranslation(tx, ty);
16862 this.x = (x + tx) / width;
16863 this.y = (y + ty) / height;
16864 this.fixAndSetPosition();
16865 }
16866 #translate(_ref, x, y) {
16867 let [width, height] = _ref;
16868 [x, y] = this.screenToPageTranslation(x, y);
16869 this.x += x / width;
16870 this.y += y / height;
16871 this.fixAndSetPosition();
16872 }
16873 translate(x, y) {
16874 this.#translate(this.parentDimensions, x, y);
16875 }
16876 translateInPage(x, y) {
16877 this.#initialPosition ||= [this.x, this.y];
16878 this.#translate(this.pageDimensions, x, y);
16879 this.div.scrollIntoView({
16880 block: "nearest"
16881 });
16882 }
16883 drag(tx, ty) {
16884 this.#initialPosition ||= [this.x, this.y];
16885 const [parentWidth, parentHeight] = this.parentDimensions;
16886 this.x += tx / parentWidth;
16887 this.y += ty / parentHeight;
16888 if (this.parent && (this.x < 0 || this.x > 1 || this.y < 0 || this.y > 1)) {
16889 const {
16890 x,
16891 y
16892 } = this.div.getBoundingClientRect();
16893 if (this.parent.findNewParent(this, x, y)) {
16894 this.x -= Math.floor(this.x);
16895 this.y -= Math.floor(this.y);
16896 }
16897 }
16898 let {
16899 x,
16900 y
16901 } = this;
16902 const [bx, by] = this.getBaseTranslation();
16903 x += bx;
16904 y += by;
16905 this.div.style.left = `${(100 * x).toFixed(2)}%`;
16906 this.div.style.top = `${(100 * y).toFixed(2)}%`;
16907 this.div.scrollIntoView({
16908 block: "nearest"
16909 });
16910 }
16911 get _hasBeenMoved() {
16912 return !!this.#initialPosition && (this.#initialPosition[0] !== this.x || this.#initialPosition[1] !== this.y);
16913 }
16914 getBaseTranslation() {
16915 const [parentWidth, parentHeight] = this.parentDimensions;
16916 const {
16917 _borderLineWidth
16918 } = AnnotationEditor;
16919 const x = _borderLineWidth / parentWidth;
16920 const y = _borderLineWidth / parentHeight;
16921 switch (this.rotation) {
16922 case 90:
16923 return [-x, y];
16924 case 180:
16925 return [x, y];
16926 case 270:
16927 return [x, -y];
16928 default:
16929 return [-x, -y];
16930 }
16931 }
16932 get _mustFixPosition() {
16933 return true;
16934 }
16935 fixAndSetPosition() {
16936 let rotation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.rotation;
16937 const [pageWidth, pageHeight] = this.pageDimensions;
16938 let {
16939 x,
16940 y,
16941 width,
16942 height
16943 } = this;
16944 width *= pageWidth;
16945 height *= pageHeight;
16946 x *= pageWidth;
16947 y *= pageHeight;
16948 if (this._mustFixPosition) {
16949 switch (rotation) {
16950 case 0:
16951 x = Math.max(0, Math.min(pageWidth - width, x));
16952 y = Math.max(0, Math.min(pageHeight - height, y));
16953 break;
16954 case 90:
16955 x = Math.max(0, Math.min(pageWidth - height, x));
16956 y = Math.min(pageHeight, Math.max(width, y));
16957 break;
16958 case 180:
16959 x = Math.min(pageWidth, Math.max(width, x));
16960 y = Math.min(pageHeight, Math.max(height, y));
16961 break;
16962 case 270:
16963 x = Math.min(pageWidth, Math.max(height, x));
16964 y = Math.max(0, Math.min(pageHeight - width, y));
16965 break;
16966 }
16967 }
16968 this.x = x /= pageWidth;
16969 this.y = y /= pageHeight;
16970 const [bx, by] = this.getBaseTranslation();
16971 x += bx;
16972 y += by;
16973 const {
16974 style
16975 } = this.div;
16976 style.left = `${(100 * x).toFixed(2)}%`;
16977 style.top = `${(100 * y).toFixed(2)}%`;
16978 this.moveInDOM();
16979 }
16980 static #rotatePoint(x, y, angle) {
16981 switch (angle) {
16982 case 90:
16983 return [y, -x];
16984 case 180:
16985 return [-x, -y];
16986 case 270:
16987 return [-y, x];
16988 default:
16989 return [x, y];
16990 }
16991 }
16992 screenToPageTranslation(x, y) {
16993 return AnnotationEditor.#rotatePoint(x, y, this.parentRotation);
16994 }
16995 pageTranslationToScreen(x, y) {
16996 return AnnotationEditor.#rotatePoint(x, y, 360 - this.parentRotation);
16997 }
16998 #getRotationMatrix(rotation) {
16999 switch (rotation) {
17000 case 90:
17001 {
17002 const [pageWidth, pageHeight] = this.pageDimensions;
17003 return [0, -pageWidth / pageHeight, pageHeight / pageWidth, 0];
17004 }
17005 case 180:
17006 return [-1, 0, 0, -1];
17007 case 270:
17008 {
17009 const [pageWidth, pageHeight] = this.pageDimensions;
17010 return [0, pageWidth / pageHeight, -pageHeight / pageWidth, 0];
17011 }
17012 default:
17013 return [1, 0, 0, 1];
17014 }
17015 }
17016 get parentScale() {
17017 return this._uiManager.viewParameters.realScale;
17018 }
17019 get parentRotation() {
17020 return (this._uiManager.viewParameters.rotation + this.pageRotation) % 360;
17021 }
17022 get parentDimensions() {
17023 const {
17024 parentScale,
17025 pageDimensions: [pageWidth, pageHeight]
17026 } = this;
17027 const scaledWidth = pageWidth * parentScale;
17028 const scaledHeight = pageHeight * parentScale;
17029 return util.FeatureTest.isCSSRoundSupported ? [Math.round(scaledWidth), Math.round(scaledHeight)] : [scaledWidth, scaledHeight];
17030 }
17031 setDims(width, height) {
17032 const [parentWidth, parentHeight] = this.parentDimensions;
17033 this.div.style.width = `${(100 * width / parentWidth).toFixed(2)}%`;
17034 if (!this.#keepAspectRatio) {
17035 this.div.style.height = `${(100 * height / parentHeight).toFixed(2)}%`;
17036 }
17037 }
17038 fixDims() {
17039 const {
17040 style
17041 } = this.div;
17042 const {
17043 height,
17044 width
17045 } = style;
17046 const widthPercent = width.endsWith("%");
17047 const heightPercent = !this.#keepAspectRatio && height.endsWith("%");
17048 if (widthPercent && heightPercent) {
17049 return;
17050 }
17051 const [parentWidth, parentHeight] = this.parentDimensions;
17052 if (!widthPercent) {
17053 style.width = `${(100 * parseFloat(width) / parentWidth).toFixed(2)}%`;
17054 }
17055 if (!this.#keepAspectRatio && !heightPercent) {
17056 style.height = `${(100 * parseFloat(height) / parentHeight).toFixed(2)}%`;
17057 }
17058 }
17059 getInitialTranslation() {
17060 return [0, 0];
17061 }
17062 #createResizers() {
17063 if (this.#resizersDiv) {
17064 return;
17065 }
17066 this.#resizersDiv = document.createElement("div");
17067 this.#resizersDiv.classList.add("resizers");
17068 const classes = this._willKeepAspectRatio ? ["topLeft", "topRight", "bottomRight", "bottomLeft"] : ["topLeft", "topMiddle", "topRight", "middleRight", "bottomRight", "bottomMiddle", "bottomLeft", "middleLeft"];
17069 for (const name of classes) {
17070 const div = document.createElement("div");
17071 this.#resizersDiv.append(div);
17072 div.classList.add("resizer", name);
17073 div.setAttribute("data-resizer-name", name);
17074 div.addEventListener("pointerdown", this.#resizerPointerdown.bind(this, name));
17075 div.addEventListener("contextmenu", display_utils.noContextMenu);
17076 div.tabIndex = -1;
17077 }
17078 this.div.prepend(this.#resizersDiv);
17079 }
17080 #resizerPointerdown(name, event) {
17081 event.preventDefault();
17082 const {
17083 isMac
17084 } = util.FeatureTest.platform;
17085 if (event.button !== 0 || event.ctrlKey && isMac) {
17086 return;
17087 }
17088 this.#altText?.toggle(false);
17089 const boundResizerPointermove = this.#resizerPointermove.bind(this, name);
17090 const savedDraggable = this._isDraggable;
17091 this._isDraggable = false;
17092 const pointerMoveOptions = {
17093 passive: true,
17094 capture: true
17095 };
17096 this.parent.togglePointerEvents(false);
17097 window.addEventListener("pointermove", boundResizerPointermove, pointerMoveOptions);
17098 const savedX = this.x;
17099 const savedY = this.y;
17100 const savedWidth = this.width;
17101 const savedHeight = this.height;
17102 const savedParentCursor = this.parent.div.style.cursor;
17103 const savedCursor = this.div.style.cursor;
17104 this.div.style.cursor = this.parent.div.style.cursor = window.getComputedStyle(event.target).cursor;
17105 const pointerUpCallback = () => {
17106 this.parent.togglePointerEvents(true);
17107 this.#altText?.toggle(true);
17108 this._isDraggable = savedDraggable;
17109 window.removeEventListener("pointerup", pointerUpCallback);
17110 window.removeEventListener("blur", pointerUpCallback);
17111 window.removeEventListener("pointermove", boundResizerPointermove, pointerMoveOptions);
17112 this.parent.div.style.cursor = savedParentCursor;
17113 this.div.style.cursor = savedCursor;
17114 this.#addResizeToUndoStack(savedX, savedY, savedWidth, savedHeight);
17115 };
17116 window.addEventListener("pointerup", pointerUpCallback);
17117 window.addEventListener("blur", pointerUpCallback);
17118 }
17119 #addResizeToUndoStack(savedX, savedY, savedWidth, savedHeight) {
17120 const newX = this.x;
17121 const newY = this.y;
17122 const newWidth = this.width;
17123 const newHeight = this.height;
17124 if (newX === savedX && newY === savedY && newWidth === savedWidth && newHeight === savedHeight) {
17125 return;
17126 }
17127 this.addCommands({
17128 cmd: () => {
17129 this.width = newWidth;
17130 this.height = newHeight;
17131 this.x = newX;
17132 this.y = newY;
17133 const [parentWidth, parentHeight] = this.parentDimensions;
17134 this.setDims(parentWidth * newWidth, parentHeight * newHeight);
17135 this.fixAndSetPosition();
17136 },
17137 undo: () => {
17138 this.width = savedWidth;
17139 this.height = savedHeight;
17140 this.x = savedX;
17141 this.y = savedY;
17142 const [parentWidth, parentHeight] = this.parentDimensions;
17143 this.setDims(parentWidth * savedWidth, parentHeight * savedHeight);
17144 this.fixAndSetPosition();
17145 },
17146 mustExec: true
17147 });
17148 }
17149 #resizerPointermove(name, event) {
17150 const [parentWidth, parentHeight] = this.parentDimensions;
17151 const savedX = this.x;
17152 const savedY = this.y;
17153 const savedWidth = this.width;
17154 const savedHeight = this.height;
17155 const minWidth = AnnotationEditor.MIN_SIZE / parentWidth;
17156 const minHeight = AnnotationEditor.MIN_SIZE / parentHeight;
17157 const round = x => Math.round(x * 10000) / 10000;
17158 const rotationMatrix = this.#getRotationMatrix(this.rotation);
17159 const transf = (x, y) => [rotationMatrix[0] * x + rotationMatrix[2] * y, rotationMatrix[1] * x + rotationMatrix[3] * y];
17160 const invRotationMatrix = this.#getRotationMatrix(360 - this.rotation);
17161 const invTransf = (x, y) => [invRotationMatrix[0] * x + invRotationMatrix[2] * y, invRotationMatrix[1] * x + invRotationMatrix[3] * y];
17162 let getPoint;
17163 let getOpposite;
17164 let isDiagonal = false;
17165 let isHorizontal = false;
17166 switch (name) {
17167 case "topLeft":
17168 isDiagonal = true;
17169 getPoint = (w, h) => [0, 0];
17170 getOpposite = (w, h) => [w, h];
17171 break;
17172 case "topMiddle":
17173 getPoint = (w, h) => [w / 2, 0];
17174 getOpposite = (w, h) => [w / 2, h];
17175 break;
17176 case "topRight":
17177 isDiagonal = true;
17178 getPoint = (w, h) => [w, 0];
17179 getOpposite = (w, h) => [0, h];
17180 break;
17181 case "middleRight":
17182 isHorizontal = true;
17183 getPoint = (w, h) => [w, h / 2];
17184 getOpposite = (w, h) => [0, h / 2];
17185 break;
17186 case "bottomRight":
17187 isDiagonal = true;
17188 getPoint = (w, h) => [w, h];
17189 getOpposite = (w, h) => [0, 0];
17190 break;
17191 case "bottomMiddle":
17192 getPoint = (w, h) => [w / 2, h];
17193 getOpposite = (w, h) => [w / 2, 0];
17194 break;
17195 case "bottomLeft":
17196 isDiagonal = true;
17197 getPoint = (w, h) => [0, h];
17198 getOpposite = (w, h) => [w, 0];
17199 break;
17200 case "middleLeft":
17201 isHorizontal = true;
17202 getPoint = (w, h) => [0, h / 2];
17203 getOpposite = (w, h) => [w, h / 2];
17204 break;
17205 }
17206 const point = getPoint(savedWidth, savedHeight);
17207 const oppositePoint = getOpposite(savedWidth, savedHeight);
17208 let transfOppositePoint = transf(...oppositePoint);
17209 const oppositeX = round(savedX + transfOppositePoint[0]);
17210 const oppositeY = round(savedY + transfOppositePoint[1]);
17211 let ratioX = 1;
17212 let ratioY = 1;
17213 let [deltaX, deltaY] = this.screenToPageTranslation(event.movementX, event.movementY);
17214 [deltaX, deltaY] = invTransf(deltaX / parentWidth, deltaY / parentHeight);
17215 if (isDiagonal) {
17216 const oldDiag = Math.hypot(savedWidth, savedHeight);
17217 ratioX = ratioY = Math.max(Math.min(Math.hypot(oppositePoint[0] - point[0] - deltaX, oppositePoint[1] - point[1] - deltaY) / oldDiag, 1 / savedWidth, 1 / savedHeight), minWidth / savedWidth, minHeight / savedHeight);
17218 } else if (isHorizontal) {
17219 ratioX = Math.max(minWidth, Math.min(1, Math.abs(oppositePoint[0] - point[0] - deltaX))) / savedWidth;
17220 } else {
17221 ratioY = Math.max(minHeight, Math.min(1, Math.abs(oppositePoint[1] - point[1] - deltaY))) / savedHeight;
17222 }
17223 const newWidth = round(savedWidth * ratioX);
17224 const newHeight = round(savedHeight * ratioY);
17225 transfOppositePoint = transf(...getOpposite(newWidth, newHeight));
17226 const newX = oppositeX - transfOppositePoint[0];
17227 const newY = oppositeY - transfOppositePoint[1];
17228 this.width = newWidth;
17229 this.height = newHeight;
17230 this.x = newX;
17231 this.y = newY;
17232 this.setDims(parentWidth * newWidth, parentHeight * newHeight);
17233 this.fixAndSetPosition();
17234 }
17235 altTextFinish() {
17236 this.#altText?.finish();
17237 }
17238 async addEditToolbar() {
17239 if (this.#editToolbar || this.#isInEditMode) {
17240 return this.#editToolbar;
17241 }
17242 this.#editToolbar = new toolbar.EditorToolbar(this);
17243 this.div.append(this.#editToolbar.render());
17244 if (this.#altText) {
17245 this.#editToolbar.addAltTextButton(await this.#altText.render());
17246 }
17247 return this.#editToolbar;
17248 }
17249 removeEditToolbar() {
17250 if (!this.#editToolbar) {
17251 return;
17252 }
17253 this.#editToolbar.remove();
17254 this.#editToolbar = null;
17255 this.#altText?.destroy();
17256 }
17257 getClientDimensions() {
17258 return this.div.getBoundingClientRect();
17259 }
17260 async addAltTextButton() {
17261 if (this.#altText) {
17262 return;
17263 }
17264 AltText.initialize(AnnotationEditor._l10nPromise);
17265 this.#altText = new AltText(this);
17266 await this.addEditToolbar();
17267 }
17268 get altTextData() {
17269 return this.#altText?.data;
17270 }
17271 set altTextData(data) {
17272 if (!this.#altText) {
17273 return;
17274 }
17275 this.#altText.data = data;
17276 }
17277 hasAltText() {
17278 return !this.#altText?.isEmpty();
17279 }
17280 render() {
17281 this.div = document.createElement("div");
17282 this.div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360);
17283 this.div.className = this.name;
17284 this.div.setAttribute("id", this.id);
17285 this.div.tabIndex = this.#disabled ? -1 : 0;
17286 if (!this._isVisible) {
17287 this.div.classList.add("hidden");
17288 }
17289 this.setInForeground();
17290 this.div.addEventListener("focusin", this.#boundFocusin);
17291 this.div.addEventListener("focusout", this.#boundFocusout);
17292 const [parentWidth, parentHeight] = this.parentDimensions;
17293 if (this.parentRotation % 180 !== 0) {
17294 this.div.style.maxWidth = `${(100 * parentHeight / parentWidth).toFixed(2)}%`;
17295 this.div.style.maxHeight = `${(100 * parentWidth / parentHeight).toFixed(2)}%`;
17296 }
17297 const [tx, ty] = this.getInitialTranslation();
17298 this.translate(tx, ty);
17299 (0,tools.bindEvents)(this, this.div, ["pointerdown"]);
17300 return this.div;
17301 }
17302 pointerdown(event) {
17303 const {
17304 isMac
17305 } = util.FeatureTest.platform;
17306 if (event.button !== 0 || event.ctrlKey && isMac) {
17307 event.preventDefault();
17308 return;
17309 }
17310 this.#hasBeenClicked = true;
17311 if (this._isDraggable) {
17312 this.#setUpDragSession(event);
17313 return;
17314 }
17315 this.#selectOnPointerEvent(event);
17316 }
17317 #selectOnPointerEvent(event) {
17318 const {
17319 isMac
17320 } = util.FeatureTest.platform;
17321 if (event.ctrlKey && !isMac || event.shiftKey || event.metaKey && isMac) {
17322 this.parent.toggleSelected(this);
17323 } else {
17324 this.parent.setSelected(this);
17325 }
17326 }
17327 #setUpDragSession(event) {
17328 const isSelected = this._uiManager.isSelected(this);
17329 this._uiManager.setUpDragSession();
17330 let pointerMoveOptions, pointerMoveCallback;
17331 if (isSelected) {
17332 this.div.classList.add("moving");
17333 pointerMoveOptions = {
17334 passive: true,
17335 capture: true
17336 };
17337 this.#prevDragX = event.clientX;
17338 this.#prevDragY = event.clientY;
17339 pointerMoveCallback = e => {
17340 const {
17341 clientX: x,
17342 clientY: y
17343 } = e;
17344 const [tx, ty] = this.screenToPageTranslation(x - this.#prevDragX, y - this.#prevDragY);
17345 this.#prevDragX = x;
17346 this.#prevDragY = y;
17347 this._uiManager.dragSelectedEditors(tx, ty);
17348 };
17349 window.addEventListener("pointermove", pointerMoveCallback, pointerMoveOptions);
17350 }
17351 const pointerUpCallback = () => {
17352 window.removeEventListener("pointerup", pointerUpCallback);
17353 window.removeEventListener("blur", pointerUpCallback);
17354 if (isSelected) {
17355 this.div.classList.remove("moving");
17356 window.removeEventListener("pointermove", pointerMoveCallback, pointerMoveOptions);
17357 }
17358 this.#hasBeenClicked = false;
17359 if (!this._uiManager.endDragSession()) {
17360 this.#selectOnPointerEvent(event);
17361 }
17362 };
17363 window.addEventListener("pointerup", pointerUpCallback);
17364 window.addEventListener("blur", pointerUpCallback);
17365 }
17366 moveInDOM() {
17367 if (this.#moveInDOMTimeout) {
17368 clearTimeout(this.#moveInDOMTimeout);
17369 }
17370 this.#moveInDOMTimeout = setTimeout(() => {
17371 this.#moveInDOMTimeout = null;
17372 this.parent?.moveEditorInDOM(this);
17373 }, 0);
17374 }
17375 _setParentAndPosition(parent, x, y) {
17376 parent.changeParent(this);
17377 this.x = x;
17378 this.y = y;
17379 this.fixAndSetPosition();
17380 }
17381 getRect(tx, ty) {
17382 let rotation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.rotation;
17383 const scale = this.parentScale;
17384 const [pageWidth, pageHeight] = this.pageDimensions;
17385 const [pageX, pageY] = this.pageTranslation;
17386 const shiftX = tx / scale;
17387 const shiftY = ty / scale;
17388 const x = this.x * pageWidth;
17389 const y = this.y * pageHeight;
17390 const width = this.width * pageWidth;
17391 const height = this.height * pageHeight;
17392 switch (rotation) {
17393 case 0:
17394 return [x + shiftX + pageX, pageHeight - y - shiftY - height + pageY, x + shiftX + width + pageX, pageHeight - y - shiftY + pageY];
17395 case 90:
17396 return [x + shiftY + pageX, pageHeight - y + shiftX + pageY, x + shiftY + height + pageX, pageHeight - y + shiftX + width + pageY];
17397 case 180:
17398 return [x - shiftX - width + pageX, pageHeight - y + shiftY + pageY, x - shiftX + pageX, pageHeight - y + shiftY + height + pageY];
17399 case 270:
17400 return [x - shiftY - height + pageX, pageHeight - y - shiftX - width + pageY, x - shiftY + pageX, pageHeight - y - shiftX + pageY];
17401 default:
17402 throw new Error("Invalid rotation");
17403 }
17404 }
17405 getRectInCurrentCoords(rect, pageHeight) {
17406 const [x1, y1, x2, y2] = rect;
17407 const width = x2 - x1;
17408 const height = y2 - y1;
17409 switch (this.rotation) {
17410 case 0:
17411 return [x1, pageHeight - y2, width, height];
17412 case 90:
17413 return [x1, pageHeight - y1, height, width];
17414 case 180:
17415 return [x2, pageHeight - y1, width, height];
17416 case 270:
17417 return [x2, pageHeight - y2, height, width];
17418 default:
17419 throw new Error("Invalid rotation");
17420 }
17421 }
17422 onceAdded() {}
17423 isEmpty() {
17424 return false;
17425 }
17426 enableEditMode() {
17427 this.#isInEditMode = true;
17428 }
17429 disableEditMode() {
17430 this.#isInEditMode = false;
17431 }
17432 isInEditMode() {
17433 return this.#isInEditMode;
17434 }
17435 shouldGetKeyboardEvents() {
17436 return this.#isResizerEnabledForKeyboard;
17437 }
17438 needsToBeRebuilt() {
17439 return this.div && !this.isAttachedToDOM;
17440 }
17441 rebuild() {
17442 this.div?.addEventListener("focusin", this.#boundFocusin);
17443 this.div?.addEventListener("focusout", this.#boundFocusout);
17444 }
17445 rotate(_angle) {}
17446 serialize() {
17447 let isForCopying = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
17448 let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
17449 (0,util.unreachable)("An editor must be serializable");
17450 }
17451 static deserialize(data, parent, uiManager) {
17452 const editor = new this.prototype.constructor({
17453 parent,
17454 id: parent.getNextId(),
17455 uiManager
17456 });
17457 editor.rotation = data.rotation;
17458 const [pageWidth, pageHeight] = editor.pageDimensions;
17459 const [x, y, width, height] = editor.getRectInCurrentCoords(data.rect, pageHeight);
17460 editor.x = x / pageWidth;
17461 editor.y = y / pageHeight;
17462 editor.width = width / pageWidth;
17463 editor.height = height / pageHeight;
17464 return editor;
17465 }
17466 remove() {
17467 this.div.removeEventListener("focusin", this.#boundFocusin);
17468 this.div.removeEventListener("focusout", this.#boundFocusout);
17469 if (!this.isEmpty()) {
17470 this.commit();
17471 }
17472 if (this.parent) {
17473 this.parent.remove(this);
17474 } else {
17475 this._uiManager.removeEditor(this);
17476 }
17477 if (this.#moveInDOMTimeout) {
17478 clearTimeout(this.#moveInDOMTimeout);
17479 this.#moveInDOMTimeout = null;
17480 }
17481 this.#stopResizing();
17482 this.removeEditToolbar();
17483 if (this.#telemetryTimeouts) {
17484 for (const timeout of this.#telemetryTimeouts.values()) {
17485 clearTimeout(timeout);
17486 }
17487 this.#telemetryTimeouts = null;
17488 }
17489 this.parent = null;
17490 }
17491 get isResizable() {
17492 return false;
17493 }
17494 makeResizable() {
17495 if (this.isResizable) {
17496 this.#createResizers();
17497 this.#resizersDiv.classList.remove("hidden");
17498 (0,tools.bindEvents)(this, this.div, ["keydown"]);
17499 }
17500 }
17501 get toolbarPosition() {
17502 return null;
17503 }
17504 keydown(event) {
17505 if (!this.isResizable || event.target !== this.div || event.key !== "Enter") {
17506 return;
17507 }
17508 this._uiManager.setSelected(this);
17509 this.#savedDimensions = {
17510 savedX: this.x,
17511 savedY: this.y,
17512 savedWidth: this.width,
17513 savedHeight: this.height
17514 };
17515 const children = this.#resizersDiv.children;
17516 if (!this.#allResizerDivs) {
17517 this.#allResizerDivs = Array.from(children);
17518 const boundResizerKeydown = this.#resizerKeydown.bind(this);
17519 const boundResizerBlur = this.#resizerBlur.bind(this);
17520 for (const div of this.#allResizerDivs) {
17521 const name = div.getAttribute("data-resizer-name");
17522 div.setAttribute("role", "spinbutton");
17523 div.addEventListener("keydown", boundResizerKeydown);
17524 div.addEventListener("blur", boundResizerBlur);
17525 div.addEventListener("focus", this.#resizerFocus.bind(this, name));
17526 AnnotationEditor._l10nPromise.get(`pdfjs-editor-resizer-label-${name}`).then(msg => div.setAttribute("aria-label", msg));
17527 }
17528 }
17529 const first = this.#allResizerDivs[0];
17530 let firstPosition = 0;
17531 for (const div of children) {
17532 if (div === first) {
17533 break;
17534 }
17535 firstPosition++;
17536 }
17537 const nextFirstPosition = (360 - this.rotation + this.parentRotation) % 360 / 90 * (this.#allResizerDivs.length / 4);
17538 if (nextFirstPosition !== firstPosition) {
17539 if (nextFirstPosition < firstPosition) {
17540 for (let i = 0; i < firstPosition - nextFirstPosition; i++) {
17541 this.#resizersDiv.append(this.#resizersDiv.firstChild);
17542 }
17543 } else if (nextFirstPosition > firstPosition) {
17544 for (let i = 0; i < nextFirstPosition - firstPosition; i++) {
17545 this.#resizersDiv.firstChild.before(this.#resizersDiv.lastChild);
17546 }
17547 }
17548 let i = 0;
17549 for (const child of children) {
17550 const div = this.#allResizerDivs[i++];
17551 const name = div.getAttribute("data-resizer-name");
17552 AnnotationEditor._l10nPromise.get(`pdfjs-editor-resizer-label-${name}`).then(msg => child.setAttribute("aria-label", msg));
17553 }
17554 }
17555 this.#setResizerTabIndex(0);
17556 this.#isResizerEnabledForKeyboard = true;
17557 this.#resizersDiv.firstChild.focus({
17558 focusVisible: true
17559 });
17560 event.preventDefault();
17561 event.stopImmediatePropagation();
17562 }
17563 #resizerKeydown(event) {
17564 AnnotationEditor._resizerKeyboardManager.exec(this, event);
17565 }
17566 #resizerBlur(event) {
17567 if (this.#isResizerEnabledForKeyboard && event.relatedTarget?.parentNode !== this.#resizersDiv) {
17568 this.#stopResizing();
17569 }
17570 }
17571 #resizerFocus(name) {
17572 this.#focusedResizerName = this.#isResizerEnabledForKeyboard ? name : "";
17573 }
17574 #setResizerTabIndex(value) {
17575 if (!this.#allResizerDivs) {
17576 return;
17577 }
17578 for (const div of this.#allResizerDivs) {
17579 div.tabIndex = value;
17580 }
17581 }
17582 _resizeWithKeyboard(x, y) {
17583 if (!this.#isResizerEnabledForKeyboard) {
17584 return;
17585 }
17586 this.#resizerPointermove(this.#focusedResizerName, {
17587 movementX: x,
17588 movementY: y
17589 });
17590 }
17591 #stopResizing() {
17592 this.#isResizerEnabledForKeyboard = false;
17593 this.#setResizerTabIndex(-1);
17594 if (this.#savedDimensions) {
17595 const {
17596 savedX,
17597 savedY,
17598 savedWidth,
17599 savedHeight
17600 } = this.#savedDimensions;
17601 this.#addResizeToUndoStack(savedX, savedY, savedWidth, savedHeight);
17602 this.#savedDimensions = null;
17603 }
17604 }
17605 _stopResizingWithKeyboard() {
17606 this.#stopResizing();
17607 this.div.focus();
17608 }
17609 select() {
17610 this.makeResizable();
17611 this.div?.classList.add("selectedEditor");
17612 if (!this.#editToolbar) {
17613 this.addEditToolbar().then(() => {
17614 if (this.div?.classList.contains("selectedEditor")) {
17615 this.#editToolbar?.show();
17616 }
17617 });
17618 return;
17619 }
17620 this.#editToolbar?.show();
17621 }
17622 unselect() {
17623 this.#resizersDiv?.classList.add("hidden");
17624 this.div?.classList.remove("selectedEditor");
17625 if (this.div?.contains(document.activeElement)) {
17626 this._uiManager.currentLayer.div.focus({
17627 preventScroll: true
17628 });
17629 }
17630 this.#editToolbar?.hide();
17631 }
17632 updateParams(type, value) {}
17633 disableEditing() {}
17634 enableEditing() {}
17635 enterInEditMode() {}
17636 getImageForAltText() {
17637 return null;
17638 }
17639 get contentDiv() {
17640 return this.div;
17641 }
17642 get isEditing() {
17643 return this.#isEditing;
17644 }
17645 set isEditing(value) {
17646 this.#isEditing = value;
17647 if (!this.parent) {
17648 return;
17649 }
17650 if (value) {
17651 this.parent.setSelected(this);
17652 this.parent.setActiveEditor(this);
17653 } else {
17654 this.parent.setActiveEditor(null);
17655 }
17656 }
17657 setAspectRatio(width, height) {
17658 this.#keepAspectRatio = true;
17659 const aspectRatio = width / height;
17660 const {
17661 style
17662 } = this.div;
17663 style.aspectRatio = aspectRatio;
17664 style.height = "auto";
17665 }
17666 static get MIN_SIZE() {
17667 return 16;
17668 }
17669 static canCreateNewEmptyEditor() {
17670 return true;
17671 }
17672 get telemetryInitialData() {
17673 return {
17674 action: "added"
17675 };
17676 }
17677 get telemetryFinalData() {
17678 return null;
17679 }
17680 _reportTelemetry(data) {
17681 let mustWait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
17682 if (mustWait) {
17683 this.#telemetryTimeouts ||= new Map();
17684 const {
17685 action
17686 } = data;
17687 let timeout = this.#telemetryTimeouts.get(action);
17688 if (timeout) {
17689 clearTimeout(timeout);
17690 }
17691 timeout = setTimeout(() => {
17692 this._reportTelemetry(data);
17693 this.#telemetryTimeouts.delete(action);
17694 if (this.#telemetryTimeouts.size === 0) {
17695 this.#telemetryTimeouts = null;
17696 }
17697 }, AnnotationEditor._telemetryTimeout);
17698 this.#telemetryTimeouts.set(action, timeout);
17699 return;
17700 }
17701 data.type ||= this.editorType;
17702 this._uiManager._eventBus.dispatch("reporttelemetry", {
17703 source: this,
17704 details: {
17705 type: "editing",
17706 data
17707 }
17708 });
17709 }
17710 show() {
17711 let visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._isVisible;
17712 this.div.classList.toggle("hidden", !visible);
17713 this._isVisible = visible;
17714 }
17715 enable() {
17716 if (this.div) {
17717 this.div.tabIndex = 0;
17718 }
17719 this.#disabled = false;
17720 }
17721 disable() {
17722 if (this.div) {
17723 this.div.tabIndex = -1;
17724 }
17725 this.#disabled = true;
17726 }
17727}
17728class FakeEditor extends AnnotationEditor {
17729 constructor(params) {
17730 super(params);
17731 this.annotationElementId = params.annotationElementId;
17732 this.deleted = true;
17733 }
17734 serialize() {
17735 return {
17736 id: this.annotationElementId,
17737 deleted: true,
17738 pageIndex: this.pageIndex
17739 };
17740 }
17741}
17742
17743
17744/***/ }),
17745
17746/***/ 4061:
17747/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
17748
17749/* harmony export */ __webpack_require__.d(__webpack_exports__, {
17750/* harmony export */ FreeOutliner: () => (/* binding */ FreeOutliner),
17751/* harmony export */ Outliner: () => (/* binding */ Outliner)
17752/* harmony export */ });
17753/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
17754/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6573);
17755/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8100);
17756/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7936);
17757/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7467);
17758/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4732);
17759/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9577);
17760/* harmony import */ var core_js_modules_esnext_set_difference_v2_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3375);
17761/* harmony import */ var core_js_modules_esnext_set_intersection_v2_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(9225);
17762/* harmony import */ var core_js_modules_esnext_set_is_disjoint_from_v2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3972);
17763/* harmony import */ var core_js_modules_esnext_set_is_subset_of_v2_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(9209);
17764/* harmony import */ var core_js_modules_esnext_set_is_superset_of_v2_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(5714);
17765/* harmony import */ var core_js_modules_esnext_set_symmetric_difference_v2_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(7561);
17766/* harmony import */ var core_js_modules_esnext_set_union_v2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(6197);
17767/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(4292);
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783class Outliner {
17784 #box;
17785 #verticalEdges = [];
17786 #intervals = [];
17787 constructor(boxes) {
17788 let borderWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
17789 let innerMargin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
17790 let isLTR = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
17791 let minX = Infinity;
17792 let maxX = -Infinity;
17793 let minY = Infinity;
17794 let maxY = -Infinity;
17795 const NUMBER_OF_DIGITS = 4;
17796 const EPSILON = 10 ** -NUMBER_OF_DIGITS;
17797 for (const {
17798 x,
17799 y,
17800 width,
17801 height
17802 } of boxes) {
17803 const x1 = Math.floor((x - borderWidth) / EPSILON) * EPSILON;
17804 const x2 = Math.ceil((x + width + borderWidth) / EPSILON) * EPSILON;
17805 const y1 = Math.floor((y - borderWidth) / EPSILON) * EPSILON;
17806 const y2 = Math.ceil((y + height + borderWidth) / EPSILON) * EPSILON;
17807 const left = [x1, y1, y2, true];
17808 const right = [x2, y1, y2, false];
17809 this.#verticalEdges.push(left, right);
17810 minX = Math.min(minX, x1);
17811 maxX = Math.max(maxX, x2);
17812 minY = Math.min(minY, y1);
17813 maxY = Math.max(maxY, y2);
17814 }
17815 const bboxWidth = maxX - minX + 2 * innerMargin;
17816 const bboxHeight = maxY - minY + 2 * innerMargin;
17817 const shiftedMinX = minX - innerMargin;
17818 const shiftedMinY = minY - innerMargin;
17819 const lastEdge = this.#verticalEdges.at(isLTR ? -1 : -2);
17820 const lastPoint = [lastEdge[0], lastEdge[2]];
17821 for (const edge of this.#verticalEdges) {
17822 const [x, y1, y2] = edge;
17823 edge[0] = (x - shiftedMinX) / bboxWidth;
17824 edge[1] = (y1 - shiftedMinY) / bboxHeight;
17825 edge[2] = (y2 - shiftedMinY) / bboxHeight;
17826 }
17827 this.#box = {
17828 x: shiftedMinX,
17829 y: shiftedMinY,
17830 width: bboxWidth,
17831 height: bboxHeight,
17832 lastPoint
17833 };
17834 }
17835 getOutlines() {
17836 this.#verticalEdges.sort((a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2]);
17837 const outlineVerticalEdges = [];
17838 for (const edge of this.#verticalEdges) {
17839 if (edge[3]) {
17840 outlineVerticalEdges.push(...this.#breakEdge(edge));
17841 this.#insert(edge);
17842 } else {
17843 this.#remove(edge);
17844 outlineVerticalEdges.push(...this.#breakEdge(edge));
17845 }
17846 }
17847 return this.#getOutlines(outlineVerticalEdges);
17848 }
17849 #getOutlines(outlineVerticalEdges) {
17850 const edges = [];
17851 const allEdges = new Set();
17852 for (const edge of outlineVerticalEdges) {
17853 const [x, y1, y2] = edge;
17854 edges.push([x, y1, edge], [x, y2, edge]);
17855 }
17856 edges.sort((a, b) => a[1] - b[1] || a[0] - b[0]);
17857 for (let i = 0, ii = edges.length; i < ii; i += 2) {
17858 const edge1 = edges[i][2];
17859 const edge2 = edges[i + 1][2];
17860 edge1.push(edge2);
17861 edge2.push(edge1);
17862 allEdges.add(edge1);
17863 allEdges.add(edge2);
17864 }
17865 const outlines = [];
17866 let outline;
17867 while (allEdges.size > 0) {
17868 const edge = allEdges.values().next().value;
17869 let [x, y1, y2, edge1, edge2] = edge;
17870 allEdges.delete(edge);
17871 let lastPointX = x;
17872 let lastPointY = y1;
17873 outline = [x, y2];
17874 outlines.push(outline);
17875 while (true) {
17876 let e;
17877 if (allEdges.has(edge1)) {
17878 e = edge1;
17879 } else if (allEdges.has(edge2)) {
17880 e = edge2;
17881 } else {
17882 break;
17883 }
17884 allEdges.delete(e);
17885 [x, y1, y2, edge1, edge2] = e;
17886 if (lastPointX !== x) {
17887 outline.push(lastPointX, lastPointY, x, lastPointY === y1 ? y1 : y2);
17888 lastPointX = x;
17889 }
17890 lastPointY = lastPointY === y1 ? y2 : y1;
17891 }
17892 outline.push(lastPointX, lastPointY);
17893 }
17894 return new HighlightOutline(outlines, this.#box);
17895 }
17896 #binarySearch(y) {
17897 const array = this.#intervals;
17898 let start = 0;
17899 let end = array.length - 1;
17900 while (start <= end) {
17901 const middle = start + end >> 1;
17902 const y1 = array[middle][0];
17903 if (y1 === y) {
17904 return middle;
17905 }
17906 if (y1 < y) {
17907 start = middle + 1;
17908 } else {
17909 end = middle - 1;
17910 }
17911 }
17912 return end + 1;
17913 }
17914 #insert(_ref) {
17915 let [, y1, y2] = _ref;
17916 const index = this.#binarySearch(y1);
17917 this.#intervals.splice(index, 0, [y1, y2]);
17918 }
17919 #remove(_ref2) {
17920 let [, y1, y2] = _ref2;
17921 const index = this.#binarySearch(y1);
17922 for (let i = index; i < this.#intervals.length; i++) {
17923 const [start, end] = this.#intervals[i];
17924 if (start !== y1) {
17925 break;
17926 }
17927 if (start === y1 && end === y2) {
17928 this.#intervals.splice(i, 1);
17929 return;
17930 }
17931 }
17932 for (let i = index - 1; i >= 0; i--) {
17933 const [start, end] = this.#intervals[i];
17934 if (start !== y1) {
17935 break;
17936 }
17937 if (start === y1 && end === y2) {
17938 this.#intervals.splice(i, 1);
17939 return;
17940 }
17941 }
17942 }
17943 #breakEdge(edge) {
17944 const [x, y1, y2] = edge;
17945 const results = [[x, y1, y2]];
17946 const index = this.#binarySearch(y2);
17947 for (let i = 0; i < index; i++) {
17948 const [start, end] = this.#intervals[i];
17949 for (let j = 0, jj = results.length; j < jj; j++) {
17950 const [, y3, y4] = results[j];
17951 if (end <= y3 || y4 <= start) {
17952 continue;
17953 }
17954 if (y3 >= start) {
17955 if (y4 > end) {
17956 results[j][1] = end;
17957 } else {
17958 if (jj === 1) {
17959 return [];
17960 }
17961 results.splice(j, 1);
17962 j--;
17963 jj--;
17964 }
17965 continue;
17966 }
17967 results[j][2] = start;
17968 if (y4 > end) {
17969 results.push([x, end, y4]);
17970 }
17971 }
17972 }
17973 return results;
17974 }
17975}
17976class Outline {
17977 toSVGPath() {
17978 throw new Error("Abstract method `toSVGPath` must be implemented.");
17979 }
17980 get box() {
17981 throw new Error("Abstract getter `box` must be implemented.");
17982 }
17983 serialize(_bbox, _rotation) {
17984 throw new Error("Abstract method `serialize` must be implemented.");
17985 }
17986 get free() {
17987 return this instanceof FreeHighlightOutline;
17988 }
17989}
17990class HighlightOutline extends Outline {
17991 #box;
17992 #outlines;
17993 constructor(outlines, box) {
17994 super();
17995 this.#outlines = outlines;
17996 this.#box = box;
17997 }
17998 toSVGPath() {
17999 const buffer = [];
18000 for (const polygon of this.#outlines) {
18001 let [prevX, prevY] = polygon;
18002 buffer.push(`M${prevX} ${prevY}`);
18003 for (let i = 2; i < polygon.length; i += 2) {
18004 const x = polygon[i];
18005 const y = polygon[i + 1];
18006 if (x === prevX) {
18007 buffer.push(`V${y}`);
18008 prevY = y;
18009 } else if (y === prevY) {
18010 buffer.push(`H${x}`);
18011 prevX = x;
18012 }
18013 }
18014 buffer.push("Z");
18015 }
18016 return buffer.join(" ");
18017 }
18018 serialize(_ref3, _rotation) {
18019 let [blX, blY, trX, trY] = _ref3;
18020 const outlines = [];
18021 const width = trX - blX;
18022 const height = trY - blY;
18023 for (const outline of this.#outlines) {
18024 const points = new Array(outline.length);
18025 for (let i = 0; i < outline.length; i += 2) {
18026 points[i] = blX + outline[i] * width;
18027 points[i + 1] = trY - outline[i + 1] * height;
18028 }
18029 outlines.push(points);
18030 }
18031 return outlines;
18032 }
18033 get box() {
18034 return this.#box;
18035 }
18036}
18037class FreeOutliner {
18038 #box;
18039 #bottom = [];
18040 #innerMargin;
18041 #isLTR;
18042 #top = [];
18043 #last = new Float64Array(18);
18044 #lastX;
18045 #lastY;
18046 #min;
18047 #min_dist;
18048 #scaleFactor;
18049 #thickness;
18050 #points = [];
18051 static #MIN_DIST = 8;
18052 static #MIN_DIFF = 2;
18053 static #MIN = FreeOutliner.#MIN_DIST + FreeOutliner.#MIN_DIFF;
18054 constructor(_ref4, box, scaleFactor, thickness, isLTR) {
18055 let {
18056 x,
18057 y
18058 } = _ref4;
18059 let innerMargin = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
18060 this.#box = box;
18061 this.#thickness = thickness * scaleFactor;
18062 this.#isLTR = isLTR;
18063 this.#last.set([NaN, NaN, NaN, NaN, x, y], 6);
18064 this.#innerMargin = innerMargin;
18065 this.#min_dist = FreeOutliner.#MIN_DIST * scaleFactor;
18066 this.#min = FreeOutliner.#MIN * scaleFactor;
18067 this.#scaleFactor = scaleFactor;
18068 this.#points.push(x, y);
18069 }
18070 get free() {
18071 return true;
18072 }
18073 isEmpty() {
18074 return isNaN(this.#last[8]);
18075 }
18076 #getLastCoords() {
18077 const lastTop = this.#last.subarray(4, 6);
18078 const lastBottom = this.#last.subarray(16, 18);
18079 const [x, y, width, height] = this.#box;
18080 return [(this.#lastX + (lastTop[0] - lastBottom[0]) / 2 - x) / width, (this.#lastY + (lastTop[1] - lastBottom[1]) / 2 - y) / height, (this.#lastX + (lastBottom[0] - lastTop[0]) / 2 - x) / width, (this.#lastY + (lastBottom[1] - lastTop[1]) / 2 - y) / height];
18081 }
18082 add(_ref5) {
18083 let {
18084 x,
18085 y
18086 } = _ref5;
18087 this.#lastX = x;
18088 this.#lastY = y;
18089 const [layerX, layerY, layerWidth, layerHeight] = this.#box;
18090 let [x1, y1, x2, y2] = this.#last.subarray(8, 12);
18091 const diffX = x - x2;
18092 const diffY = y - y2;
18093 const d = Math.hypot(diffX, diffY);
18094 if (d < this.#min) {
18095 return false;
18096 }
18097 const diffD = d - this.#min_dist;
18098 const K = diffD / d;
18099 const shiftX = K * diffX;
18100 const shiftY = K * diffY;
18101 let x0 = x1;
18102 let y0 = y1;
18103 x1 = x2;
18104 y1 = y2;
18105 x2 += shiftX;
18106 y2 += shiftY;
18107 this.#points?.push(x, y);
18108 const nX = -shiftY / diffD;
18109 const nY = shiftX / diffD;
18110 const thX = nX * this.#thickness;
18111 const thY = nY * this.#thickness;
18112 this.#last.set(this.#last.subarray(2, 8), 0);
18113 this.#last.set([x2 + thX, y2 + thY], 4);
18114 this.#last.set(this.#last.subarray(14, 18), 12);
18115 this.#last.set([x2 - thX, y2 - thY], 16);
18116 if (isNaN(this.#last[6])) {
18117 if (this.#top.length === 0) {
18118 this.#last.set([x1 + thX, y1 + thY], 2);
18119 this.#top.push(NaN, NaN, NaN, NaN, (x1 + thX - layerX) / layerWidth, (y1 + thY - layerY) / layerHeight);
18120 this.#last.set([x1 - thX, y1 - thY], 14);
18121 this.#bottom.push(NaN, NaN, NaN, NaN, (x1 - thX - layerX) / layerWidth, (y1 - thY - layerY) / layerHeight);
18122 }
18123 this.#last.set([x0, y0, x1, y1, x2, y2], 6);
18124 return !this.isEmpty();
18125 }
18126 this.#last.set([x0, y0, x1, y1, x2, y2], 6);
18127 const angle = Math.abs(Math.atan2(y0 - y1, x0 - x1) - Math.atan2(shiftY, shiftX));
18128 if (angle < Math.PI / 2) {
18129 [x1, y1, x2, y2] = this.#last.subarray(2, 6);
18130 this.#top.push(NaN, NaN, NaN, NaN, ((x1 + x2) / 2 - layerX) / layerWidth, ((y1 + y2) / 2 - layerY) / layerHeight);
18131 [x1, y1, x0, y0] = this.#last.subarray(14, 18);
18132 this.#bottom.push(NaN, NaN, NaN, NaN, ((x0 + x1) / 2 - layerX) / layerWidth, ((y0 + y1) / 2 - layerY) / layerHeight);
18133 return true;
18134 }
18135 [x0, y0, x1, y1, x2, y2] = this.#last.subarray(0, 6);
18136 this.#top.push(((x0 + 5 * x1) / 6 - layerX) / layerWidth, ((y0 + 5 * y1) / 6 - layerY) / layerHeight, ((5 * x1 + x2) / 6 - layerX) / layerWidth, ((5 * y1 + y2) / 6 - layerY) / layerHeight, ((x1 + x2) / 2 - layerX) / layerWidth, ((y1 + y2) / 2 - layerY) / layerHeight);
18137 [x2, y2, x1, y1, x0, y0] = this.#last.subarray(12, 18);
18138 this.#bottom.push(((x0 + 5 * x1) / 6 - layerX) / layerWidth, ((y0 + 5 * y1) / 6 - layerY) / layerHeight, ((5 * x1 + x2) / 6 - layerX) / layerWidth, ((5 * y1 + y2) / 6 - layerY) / layerHeight, ((x1 + x2) / 2 - layerX) / layerWidth, ((y1 + y2) / 2 - layerY) / layerHeight);
18139 return true;
18140 }
18141 toSVGPath() {
18142 if (this.isEmpty()) {
18143 return "";
18144 }
18145 const top = this.#top;
18146 const bottom = this.#bottom;
18147 const lastTop = this.#last.subarray(4, 6);
18148 const lastBottom = this.#last.subarray(16, 18);
18149 const [x, y, width, height] = this.#box;
18150 const [lastTopX, lastTopY, lastBottomX, lastBottomY] = this.#getLastCoords();
18151 if (isNaN(this.#last[6]) && !this.isEmpty()) {
18152 return `M${(this.#last[2] - x) / width} ${(this.#last[3] - y) / height} L${(this.#last[4] - x) / width} ${(this.#last[5] - y) / height} L${lastTopX} ${lastTopY} L${lastBottomX} ${lastBottomY} L${(this.#last[16] - x) / width} ${(this.#last[17] - y) / height} L${(this.#last[14] - x) / width} ${(this.#last[15] - y) / height} Z`;
18153 }
18154 const buffer = [];
18155 buffer.push(`M${top[4]} ${top[5]}`);
18156 for (let i = 6; i < top.length; i += 6) {
18157 if (isNaN(top[i])) {
18158 buffer.push(`L${top[i + 4]} ${top[i + 5]}`);
18159 } else {
18160 buffer.push(`C${top[i]} ${top[i + 1]} ${top[i + 2]} ${top[i + 3]} ${top[i + 4]} ${top[i + 5]}`);
18161 }
18162 }
18163 buffer.push(`L${(lastTop[0] - x) / width} ${(lastTop[1] - y) / height} L${lastTopX} ${lastTopY} L${lastBottomX} ${lastBottomY} L${(lastBottom[0] - x) / width} ${(lastBottom[1] - y) / height}`);
18164 for (let i = bottom.length - 6; i >= 6; i -= 6) {
18165 if (isNaN(bottom[i])) {
18166 buffer.push(`L${bottom[i + 4]} ${bottom[i + 5]}`);
18167 } else {
18168 buffer.push(`C${bottom[i]} ${bottom[i + 1]} ${bottom[i + 2]} ${bottom[i + 3]} ${bottom[i + 4]} ${bottom[i + 5]}`);
18169 }
18170 }
18171 buffer.push(`L${bottom[4]} ${bottom[5]} Z`);
18172 return buffer.join(" ");
18173 }
18174 getOutlines() {
18175 const top = this.#top;
18176 const bottom = this.#bottom;
18177 const last = this.#last;
18178 const lastTop = last.subarray(4, 6);
18179 const lastBottom = last.subarray(16, 18);
18180 const [layerX, layerY, layerWidth, layerHeight] = this.#box;
18181 const points = new Float64Array((this.#points?.length ?? 0) + 2);
18182 for (let i = 0, ii = points.length - 2; i < ii; i += 2) {
18183 points[i] = (this.#points[i] - layerX) / layerWidth;
18184 points[i + 1] = (this.#points[i + 1] - layerY) / layerHeight;
18185 }
18186 points[points.length - 2] = (this.#lastX - layerX) / layerWidth;
18187 points[points.length - 1] = (this.#lastY - layerY) / layerHeight;
18188 const [lastTopX, lastTopY, lastBottomX, lastBottomY] = this.#getLastCoords();
18189 if (isNaN(last[6]) && !this.isEmpty()) {
18190 const outline = new Float64Array(36);
18191 outline.set([NaN, NaN, NaN, NaN, (last[2] - layerX) / layerWidth, (last[3] - layerY) / layerHeight, NaN, NaN, NaN, NaN, (last[4] - layerX) / layerWidth, (last[5] - layerY) / layerHeight, NaN, NaN, NaN, NaN, lastTopX, lastTopY, NaN, NaN, NaN, NaN, lastBottomX, lastBottomY, NaN, NaN, NaN, NaN, (last[16] - layerX) / layerWidth, (last[17] - layerY) / layerHeight, NaN, NaN, NaN, NaN, (last[14] - layerX) / layerWidth, (last[15] - layerY) / layerHeight], 0);
18192 return new FreeHighlightOutline(outline, points, this.#box, this.#scaleFactor, this.#innerMargin, this.#isLTR);
18193 }
18194 const outline = new Float64Array(this.#top.length + 24 + this.#bottom.length);
18195 let N = top.length;
18196 for (let i = 0; i < N; i += 2) {
18197 if (isNaN(top[i])) {
18198 outline[i] = outline[i + 1] = NaN;
18199 continue;
18200 }
18201 outline[i] = top[i];
18202 outline[i + 1] = top[i + 1];
18203 }
18204 outline.set([NaN, NaN, NaN, NaN, (lastTop[0] - layerX) / layerWidth, (lastTop[1] - layerY) / layerHeight, NaN, NaN, NaN, NaN, lastTopX, lastTopY, NaN, NaN, NaN, NaN, lastBottomX, lastBottomY, NaN, NaN, NaN, NaN, (lastBottom[0] - layerX) / layerWidth, (lastBottom[1] - layerY) / layerHeight], N);
18205 N += 24;
18206 for (let i = bottom.length - 6; i >= 6; i -= 6) {
18207 for (let j = 0; j < 6; j += 2) {
18208 if (isNaN(bottom[i + j])) {
18209 outline[N] = outline[N + 1] = NaN;
18210 N += 2;
18211 continue;
18212 }
18213 outline[N] = bottom[i + j];
18214 outline[N + 1] = bottom[i + j + 1];
18215 N += 2;
18216 }
18217 }
18218 outline.set([NaN, NaN, NaN, NaN, bottom[4], bottom[5]], N);
18219 return new FreeHighlightOutline(outline, points, this.#box, this.#scaleFactor, this.#innerMargin, this.#isLTR);
18220 }
18221}
18222class FreeHighlightOutline extends Outline {
18223 #box;
18224 #bbox = null;
18225 #innerMargin;
18226 #isLTR;
18227 #points;
18228 #scaleFactor;
18229 #outline;
18230 constructor(outline, points, box, scaleFactor, innerMargin, isLTR) {
18231 super();
18232 this.#outline = outline;
18233 this.#points = points;
18234 this.#box = box;
18235 this.#scaleFactor = scaleFactor;
18236 this.#innerMargin = innerMargin;
18237 this.#isLTR = isLTR;
18238 this.#computeMinMax(isLTR);
18239 const {
18240 x,
18241 y,
18242 width,
18243 height
18244 } = this.#bbox;
18245 for (let i = 0, ii = outline.length; i < ii; i += 2) {
18246 outline[i] = (outline[i] - x) / width;
18247 outline[i + 1] = (outline[i + 1] - y) / height;
18248 }
18249 for (let i = 0, ii = points.length; i < ii; i += 2) {
18250 points[i] = (points[i] - x) / width;
18251 points[i + 1] = (points[i + 1] - y) / height;
18252 }
18253 }
18254 toSVGPath() {
18255 const buffer = [`M${this.#outline[4]} ${this.#outline[5]}`];
18256 for (let i = 6, ii = this.#outline.length; i < ii; i += 6) {
18257 if (isNaN(this.#outline[i])) {
18258 buffer.push(`L${this.#outline[i + 4]} ${this.#outline[i + 5]}`);
18259 continue;
18260 }
18261 buffer.push(`C${this.#outline[i]} ${this.#outline[i + 1]} ${this.#outline[i + 2]} ${this.#outline[i + 3]} ${this.#outline[i + 4]} ${this.#outline[i + 5]}`);
18262 }
18263 buffer.push("Z");
18264 return buffer.join(" ");
18265 }
18266 serialize(_ref6, rotation) {
18267 let [blX, blY, trX, trY] = _ref6;
18268 const width = trX - blX;
18269 const height = trY - blY;
18270 let outline;
18271 let points;
18272 switch (rotation) {
18273 case 0:
18274 outline = this.#rescale(this.#outline, blX, trY, width, -height);
18275 points = this.#rescale(this.#points, blX, trY, width, -height);
18276 break;
18277 case 90:
18278 outline = this.#rescaleAndSwap(this.#outline, blX, blY, width, height);
18279 points = this.#rescaleAndSwap(this.#points, blX, blY, width, height);
18280 break;
18281 case 180:
18282 outline = this.#rescale(this.#outline, trX, blY, -width, height);
18283 points = this.#rescale(this.#points, trX, blY, -width, height);
18284 break;
18285 case 270:
18286 outline = this.#rescaleAndSwap(this.#outline, trX, trY, -width, -height);
18287 points = this.#rescaleAndSwap(this.#points, trX, trY, -width, -height);
18288 break;
18289 }
18290 return {
18291 outline: Array.from(outline),
18292 points: [Array.from(points)]
18293 };
18294 }
18295 #rescale(src, tx, ty, sx, sy) {
18296 const dest = new Float64Array(src.length);
18297 for (let i = 0, ii = src.length; i < ii; i += 2) {
18298 dest[i] = tx + src[i] * sx;
18299 dest[i + 1] = ty + src[i + 1] * sy;
18300 }
18301 return dest;
18302 }
18303 #rescaleAndSwap(src, tx, ty, sx, sy) {
18304 const dest = new Float64Array(src.length);
18305 for (let i = 0, ii = src.length; i < ii; i += 2) {
18306 dest[i] = tx + src[i + 1] * sx;
18307 dest[i + 1] = ty + src[i] * sy;
18308 }
18309 return dest;
18310 }
18311 #computeMinMax(isLTR) {
18312 const outline = this.#outline;
18313 let lastX = outline[4];
18314 let lastY = outline[5];
18315 let minX = lastX;
18316 let minY = lastY;
18317 let maxX = lastX;
18318 let maxY = lastY;
18319 let lastPointX = lastX;
18320 let lastPointY = lastY;
18321 const ltrCallback = isLTR ? Math.max : Math.min;
18322 for (let i = 6, ii = outline.length; i < ii; i += 6) {
18323 if (isNaN(outline[i])) {
18324 minX = Math.min(minX, outline[i + 4]);
18325 minY = Math.min(minY, outline[i + 5]);
18326 maxX = Math.max(maxX, outline[i + 4]);
18327 maxY = Math.max(maxY, outline[i + 5]);
18328 if (lastPointY < outline[i + 5]) {
18329 lastPointX = outline[i + 4];
18330 lastPointY = outline[i + 5];
18331 } else if (lastPointY === outline[i + 5]) {
18332 lastPointX = ltrCallback(lastPointX, outline[i + 4]);
18333 }
18334 } else {
18335 const bbox = _shared_util_js__WEBPACK_IMPORTED_MODULE_14__.Util.bezierBoundingBox(lastX, lastY, ...outline.slice(i, i + 6));
18336 minX = Math.min(minX, bbox[0]);
18337 minY = Math.min(minY, bbox[1]);
18338 maxX = Math.max(maxX, bbox[2]);
18339 maxY = Math.max(maxY, bbox[3]);
18340 if (lastPointY < bbox[3]) {
18341 lastPointX = bbox[2];
18342 lastPointY = bbox[3];
18343 } else if (lastPointY === bbox[3]) {
18344 lastPointX = ltrCallback(lastPointX, bbox[2]);
18345 }
18346 }
18347 lastX = outline[i + 4];
18348 lastY = outline[i + 5];
18349 }
18350 const x = minX - this.#innerMargin,
18351 y = minY - this.#innerMargin,
18352 width = maxX - minX + 2 * this.#innerMargin,
18353 height = maxY - minY + 2 * this.#innerMargin;
18354 this.#bbox = {
18355 x,
18356 y,
18357 width,
18358 height,
18359 lastPoint: [lastPointX, lastPointY]
18360 };
18361 }
18362 get box() {
18363 return this.#bbox;
18364 }
18365 getNewOutline(thickness, innerMargin) {
18366 const {
18367 x,
18368 y,
18369 width,
18370 height
18371 } = this.#bbox;
18372 const [layerX, layerY, layerWidth, layerHeight] = this.#box;
18373 const sx = width * layerWidth;
18374 const sy = height * layerHeight;
18375 const tx = x * layerWidth + layerX;
18376 const ty = y * layerHeight + layerY;
18377 const outliner = new FreeOutliner({
18378 x: this.#points[0] * sx + tx,
18379 y: this.#points[1] * sy + ty
18380 }, this.#box, this.#scaleFactor, thickness, this.#isLTR, innerMargin ?? this.#innerMargin);
18381 for (let i = 2; i < this.#points.length; i += 2) {
18382 outliner.add({
18383 x: this.#points[i] * sx + tx,
18384 y: this.#points[i + 1] * sy + ty
18385 });
18386 }
18387 return outliner.getOutlines();
18388 }
18389}
18390
18391
18392/***/ }),
18393
18394/***/ 4362:
18395/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
18396
18397/* harmony export */ __webpack_require__.d(__webpack_exports__, {
18398/* harmony export */ EditorToolbar: () => (/* binding */ EditorToolbar),
18399/* harmony export */ HighlightToolbar: () => (/* binding */ HighlightToolbar)
18400/* harmony export */ });
18401/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5419);
18402
18403class EditorToolbar {
18404 #toolbar = null;
18405 #colorPicker = null;
18406 #editor;
18407 #buttons = null;
18408 constructor(editor) {
18409 this.#editor = editor;
18410 }
18411 render() {
18412 const editToolbar = this.#toolbar = document.createElement("div");
18413 editToolbar.className = "editToolbar";
18414 editToolbar.setAttribute("role", "toolbar");
18415 editToolbar.addEventListener("contextmenu", _display_utils_js__WEBPACK_IMPORTED_MODULE_0__.noContextMenu);
18416 editToolbar.addEventListener("pointerdown", EditorToolbar.#pointerDown);
18417 const buttons = this.#buttons = document.createElement("div");
18418 buttons.className = "buttons";
18419 editToolbar.append(buttons);
18420 const position = this.#editor.toolbarPosition;
18421 if (position) {
18422 const {
18423 style
18424 } = editToolbar;
18425 const x = this.#editor._uiManager.direction === "ltr" ? 1 - position[0] : position[0];
18426 style.insetInlineEnd = `${100 * x}%`;
18427 style.top = `calc(${100 * position[1]}% + var(--editor-toolbar-vert-offset))`;
18428 }
18429 this.#addDeleteButton();
18430 return editToolbar;
18431 }
18432 static #pointerDown(e) {
18433 e.stopPropagation();
18434 }
18435 #focusIn(e) {
18436 this.#editor._focusEventsAllowed = false;
18437 e.preventDefault();
18438 e.stopPropagation();
18439 }
18440 #focusOut(e) {
18441 this.#editor._focusEventsAllowed = true;
18442 e.preventDefault();
18443 e.stopPropagation();
18444 }
18445 #addListenersToElement(element) {
18446 element.addEventListener("focusin", this.#focusIn.bind(this), {
18447 capture: true
18448 });
18449 element.addEventListener("focusout", this.#focusOut.bind(this), {
18450 capture: true
18451 });
18452 element.addEventListener("contextmenu", _display_utils_js__WEBPACK_IMPORTED_MODULE_0__.noContextMenu);
18453 }
18454 hide() {
18455 this.#toolbar.classList.add("hidden");
18456 this.#colorPicker?.hideDropdown();
18457 }
18458 show() {
18459 this.#toolbar.classList.remove("hidden");
18460 }
18461 #addDeleteButton() {
18462 const button = document.createElement("button");
18463 button.className = "delete";
18464 button.tabIndex = 0;
18465 button.setAttribute("data-l10n-id", `pdfjs-editor-remove-${this.#editor.editorType}-button`);
18466 this.#addListenersToElement(button);
18467 button.addEventListener("click", e => {
18468 this.#editor._uiManager.delete();
18469 });
18470 this.#buttons.append(button);
18471 }
18472 get #divider() {
18473 const divider = document.createElement("div");
18474 divider.className = "divider";
18475 return divider;
18476 }
18477 addAltTextButton(button) {
18478 this.#addListenersToElement(button);
18479 this.#buttons.prepend(button, this.#divider);
18480 }
18481 addColorPicker(colorPicker) {
18482 this.#colorPicker = colorPicker;
18483 const button = colorPicker.renderButton();
18484 this.#addListenersToElement(button);
18485 this.#buttons.prepend(button, this.#divider);
18486 }
18487 remove() {
18488 this.#toolbar.remove();
18489 this.#colorPicker?.destroy();
18490 this.#colorPicker = null;
18491 }
18492}
18493class HighlightToolbar {
18494 #buttons = null;
18495 #toolbar = null;
18496 #uiManager;
18497 constructor(uiManager) {
18498 this.#uiManager = uiManager;
18499 }
18500 #render() {
18501 const editToolbar = this.#toolbar = document.createElement("div");
18502 editToolbar.className = "editToolbar";
18503 editToolbar.setAttribute("role", "toolbar");
18504 editToolbar.addEventListener("contextmenu", _display_utils_js__WEBPACK_IMPORTED_MODULE_0__.noContextMenu);
18505 const buttons = this.#buttons = document.createElement("div");
18506 buttons.className = "buttons";
18507 editToolbar.append(buttons);
18508 this.#addHighlightButton();
18509 return editToolbar;
18510 }
18511 #getLastPoint(boxes, isLTR) {
18512 let lastY = 0;
18513 let lastX = 0;
18514 for (const box of boxes) {
18515 const y = box.y + box.height;
18516 if (y < lastY) {
18517 continue;
18518 }
18519 const x = box.x + (isLTR ? box.width : 0);
18520 if (y > lastY) {
18521 lastX = x;
18522 lastY = y;
18523 continue;
18524 }
18525 if (isLTR) {
18526 if (x > lastX) {
18527 lastX = x;
18528 }
18529 } else if (x < lastX) {
18530 lastX = x;
18531 }
18532 }
18533 return [isLTR ? 1 - lastX : lastX, lastY];
18534 }
18535 show(parent, boxes, isLTR) {
18536 const [x, y] = this.#getLastPoint(boxes, isLTR);
18537 const {
18538 style
18539 } = this.#toolbar ||= this.#render();
18540 parent.append(this.#toolbar);
18541 style.insetInlineEnd = `${100 * x}%`;
18542 style.top = `calc(${100 * y}% + var(--editor-toolbar-vert-offset))`;
18543 }
18544 hide() {
18545 this.#toolbar.remove();
18546 }
18547 #addHighlightButton() {
18548 const button = document.createElement("button");
18549 button.className = "highlightButton";
18550 button.tabIndex = 0;
18551 button.setAttribute("data-l10n-id", `pdfjs-highlight-floating-button1`);
18552 const span = document.createElement("span");
18553 button.append(span);
18554 span.className = "visuallyHidden";
18555 span.setAttribute("data-l10n-id", "pdfjs-highlight-floating-button-label");
18556 button.addEventListener("contextmenu", _display_utils_js__WEBPACK_IMPORTED_MODULE_0__.noContextMenu);
18557 button.addEventListener("click", () => {
18558 this.#uiManager.highlightSelection("floating_button");
18559 });
18560 this.#buttons.append(button);
18561 }
18562}
18563
18564
18565/***/ }),
18566
18567/***/ 7830:
18568/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
18569
18570/* harmony export */ __webpack_require__.d(__webpack_exports__, {
18571/* harmony export */ AnnotationEditorUIManager: () => (/* binding */ AnnotationEditorUIManager),
18572/* harmony export */ ColorManager: () => (/* binding */ ColorManager),
18573/* harmony export */ KeyboardManager: () => (/* binding */ KeyboardManager),
18574/* harmony export */ bindEvents: () => (/* binding */ bindEvents),
18575/* harmony export */ opacityToHex: () => (/* binding */ opacityToHex)
18576/* harmony export */ });
18577/* unused harmony export CommandManager */
18578/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
18579/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6573);
18580/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8100);
18581/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7936);
18582/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7467);
18583/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4732);
18584/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9577);
18585/* harmony import */ var core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(8992);
18586/* harmony import */ var core_js_modules_esnext_iterator_every_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(3215);
18587/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1454);
18588/* harmony import */ var core_js_modules_esnext_iterator_some_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(7550);
18589/* harmony import */ var core_js_modules_esnext_json_parse_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(8335);
18590/* harmony import */ var core_js_modules_esnext_set_difference_v2_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(3375);
18591/* harmony import */ var core_js_modules_esnext_set_intersection_v2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(9225);
18592/* harmony import */ var core_js_modules_esnext_set_is_disjoint_from_v2_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(3972);
18593/* harmony import */ var core_js_modules_esnext_set_is_subset_of_v2_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(9209);
18594/* harmony import */ var core_js_modules_esnext_set_is_superset_of_v2_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(5714);
18595/* harmony import */ var core_js_modules_esnext_set_symmetric_difference_v2_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(7561);
18596/* harmony import */ var core_js_modules_esnext_set_union_v2_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(6197);
18597/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(4292);
18598/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(5419);
18599/* harmony import */ var _toolbar_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(4362);
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622function bindEvents(obj, element, names) {
18623 for (const name of names) {
18624 element.addEventListener(name, obj[name].bind(obj));
18625 }
18626}
18627function opacityToHex(opacity) {
18628 return Math.round(Math.min(255, Math.max(1, 255 * opacity))).toString(16).padStart(2, "0");
18629}
18630class IdManager {
18631 #id = 0;
18632 constructor() {}
18633 get id() {
18634 return `${_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorPrefix}${this.#id++}`;
18635 }
18636}
18637class ImageManager {
18638 #baseId = (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.getUuid)();
18639 #id = 0;
18640 #cache = null;
18641 static get _isSVGFittingCanvas() {
18642 const svg = `data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>`;
18643 const canvas = new OffscreenCanvas(1, 3);
18644 const ctx = canvas.getContext("2d");
18645 const image = new Image();
18646 image.src = svg;
18647 const promise = image.decode().then(() => {
18648 ctx.drawImage(image, 0, 0, 1, 1, 0, 0, 1, 3);
18649 return new Uint32Array(ctx.getImageData(0, 0, 1, 1).data.buffer)[0] === 0;
18650 });
18651 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.shadow)(this, "_isSVGFittingCanvas", promise);
18652 }
18653 async #get(key, rawData) {
18654 this.#cache ||= new Map();
18655 let data = this.#cache.get(key);
18656 if (data === null) {
18657 return null;
18658 }
18659 if (data?.bitmap) {
18660 data.refCounter += 1;
18661 return data;
18662 }
18663 try {
18664 data ||= {
18665 bitmap: null,
18666 id: `image_${this.#baseId}_${this.#id++}`,
18667 refCounter: 0,
18668 isSvg: false
18669 };
18670 let image;
18671 if (typeof rawData === "string") {
18672 data.url = rawData;
18673 image = await (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_20__.fetchData)(rawData, "blob");
18674 } else {
18675 image = data.file = rawData;
18676 }
18677 if (image.type === "image/svg+xml") {
18678 const mustRemoveAspectRatioPromise = ImageManager._isSVGFittingCanvas;
18679 const fileReader = new FileReader();
18680 const imageElement = new Image();
18681 const imagePromise = new Promise((resolve, reject) => {
18682 imageElement.onload = () => {
18683 data.bitmap = imageElement;
18684 data.isSvg = true;
18685 resolve();
18686 };
18687 fileReader.onload = async () => {
18688 const url = data.svgUrl = fileReader.result;
18689 imageElement.src = (await mustRemoveAspectRatioPromise) ? `${url}#svgView(preserveAspectRatio(none))` : url;
18690 };
18691 imageElement.onerror = fileReader.onerror = reject;
18692 });
18693 fileReader.readAsDataURL(image);
18694 await imagePromise;
18695 } else {
18696 data.bitmap = await createImageBitmap(image);
18697 }
18698 data.refCounter = 1;
18699 } catch (e) {
18700 console.error(e);
18701 data = null;
18702 }
18703 this.#cache.set(key, data);
18704 if (data) {
18705 this.#cache.set(data.id, data);
18706 }
18707 return data;
18708 }
18709 async getFromFile(file) {
18710 const {
18711 lastModified,
18712 name,
18713 size,
18714 type
18715 } = file;
18716 return this.#get(`${lastModified}_${name}_${size}_${type}`, file);
18717 }
18718 async getFromUrl(url) {
18719 return this.#get(url, url);
18720 }
18721 async getFromId(id) {
18722 this.#cache ||= new Map();
18723 const data = this.#cache.get(id);
18724 if (!data) {
18725 return null;
18726 }
18727 if (data.bitmap) {
18728 data.refCounter += 1;
18729 return data;
18730 }
18731 if (data.file) {
18732 return this.getFromFile(data.file);
18733 }
18734 return this.getFromUrl(data.url);
18735 }
18736 getSvgUrl(id) {
18737 const data = this.#cache.get(id);
18738 if (!data?.isSvg) {
18739 return null;
18740 }
18741 return data.svgUrl;
18742 }
18743 deleteId(id) {
18744 this.#cache ||= new Map();
18745 const data = this.#cache.get(id);
18746 if (!data) {
18747 return;
18748 }
18749 data.refCounter -= 1;
18750 if (data.refCounter !== 0) {
18751 return;
18752 }
18753 data.bitmap = null;
18754 }
18755 isValidId(id) {
18756 return id.startsWith(`image_${this.#baseId}_`);
18757 }
18758}
18759class CommandManager {
18760 #commands = [];
18761 #locked = false;
18762 #maxSize;
18763 #position = -1;
18764 constructor() {
18765 let maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 128;
18766 this.#maxSize = maxSize;
18767 }
18768 add(_ref) {
18769 let {
18770 cmd,
18771 undo,
18772 post,
18773 mustExec,
18774 type = NaN,
18775 overwriteIfSameType = false,
18776 keepUndo = false
18777 } = _ref;
18778 if (mustExec) {
18779 cmd();
18780 }
18781 if (this.#locked) {
18782 return;
18783 }
18784 const save = {
18785 cmd,
18786 undo,
18787 post,
18788 type
18789 };
18790 if (this.#position === -1) {
18791 if (this.#commands.length > 0) {
18792 this.#commands.length = 0;
18793 }
18794 this.#position = 0;
18795 this.#commands.push(save);
18796 return;
18797 }
18798 if (overwriteIfSameType && this.#commands[this.#position].type === type) {
18799 if (keepUndo) {
18800 save.undo = this.#commands[this.#position].undo;
18801 }
18802 this.#commands[this.#position] = save;
18803 return;
18804 }
18805 const next = this.#position + 1;
18806 if (next === this.#maxSize) {
18807 this.#commands.splice(0, 1);
18808 } else {
18809 this.#position = next;
18810 if (next < this.#commands.length) {
18811 this.#commands.splice(next);
18812 }
18813 }
18814 this.#commands.push(save);
18815 }
18816 undo() {
18817 if (this.#position === -1) {
18818 return;
18819 }
18820 this.#locked = true;
18821 const {
18822 undo,
18823 post
18824 } = this.#commands[this.#position];
18825 undo();
18826 post?.();
18827 this.#locked = false;
18828 this.#position -= 1;
18829 }
18830 redo() {
18831 if (this.#position < this.#commands.length - 1) {
18832 this.#position += 1;
18833 this.#locked = true;
18834 const {
18835 cmd,
18836 post
18837 } = this.#commands[this.#position];
18838 cmd();
18839 post?.();
18840 this.#locked = false;
18841 }
18842 }
18843 hasSomethingToUndo() {
18844 return this.#position !== -1;
18845 }
18846 hasSomethingToRedo() {
18847 return this.#position < this.#commands.length - 1;
18848 }
18849 destroy() {
18850 this.#commands = null;
18851 }
18852}
18853class KeyboardManager {
18854 constructor(callbacks) {
18855 this.buffer = [];
18856 this.callbacks = new Map();
18857 this.allKeys = new Set();
18858 const {
18859 isMac
18860 } = _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.FeatureTest.platform;
18861 for (const [keys, callback, options = {}] of callbacks) {
18862 for (const key of keys) {
18863 const isMacKey = key.startsWith("mac+");
18864 if (isMac && isMacKey) {
18865 this.callbacks.set(key.slice(4), {
18866 callback,
18867 options
18868 });
18869 this.allKeys.add(key.split("+").at(-1));
18870 } else if (!isMac && !isMacKey) {
18871 this.callbacks.set(key, {
18872 callback,
18873 options
18874 });
18875 this.allKeys.add(key.split("+").at(-1));
18876 }
18877 }
18878 }
18879 }
18880 #serialize(event) {
18881 if (event.altKey) {
18882 this.buffer.push("alt");
18883 }
18884 if (event.ctrlKey) {
18885 this.buffer.push("ctrl");
18886 }
18887 if (event.metaKey) {
18888 this.buffer.push("meta");
18889 }
18890 if (event.shiftKey) {
18891 this.buffer.push("shift");
18892 }
18893 this.buffer.push(event.key);
18894 const str = this.buffer.join("+");
18895 this.buffer.length = 0;
18896 return str;
18897 }
18898 exec(self, event) {
18899 if (!this.allKeys.has(event.key)) {
18900 return;
18901 }
18902 const info = this.callbacks.get(this.#serialize(event));
18903 if (!info) {
18904 return;
18905 }
18906 const {
18907 callback,
18908 options: {
18909 bubbles = false,
18910 args = [],
18911 checker = null
18912 }
18913 } = info;
18914 if (checker && !checker(self, event)) {
18915 return;
18916 }
18917 callback.bind(self, ...args, event)();
18918 if (!bubbles) {
18919 event.stopPropagation();
18920 event.preventDefault();
18921 }
18922 }
18923}
18924class ColorManager {
18925 static _colorsMapping = new Map([["CanvasText", [0, 0, 0]], ["Canvas", [255, 255, 255]]]);
18926 get _colors() {
18927 const colors = new Map([["CanvasText", null], ["Canvas", null]]);
18928 (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_20__.getColorValues)(colors);
18929 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.shadow)(this, "_colors", colors);
18930 }
18931 convert(color) {
18932 const rgb = (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_20__.getRGB)(color);
18933 if (!window.matchMedia("(forced-colors: active)").matches) {
18934 return rgb;
18935 }
18936 for (const [name, RGB] of this._colors) {
18937 if (RGB.every((x, i) => x === rgb[i])) {
18938 return ColorManager._colorsMapping.get(name);
18939 }
18940 }
18941 return rgb;
18942 }
18943 getHexCode(name) {
18944 const rgb = this._colors.get(name);
18945 if (!rgb) {
18946 return name;
18947 }
18948 return _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.Util.makeHexColor(...rgb);
18949 }
18950}
18951class AnnotationEditorUIManager {
18952 #activeEditor = null;
18953 #allEditors = new Map();
18954 #allLayers = new Map();
18955 #altTextManager = null;
18956 #annotationStorage = null;
18957 #commandManager = new CommandManager();
18958 #currentPageIndex = 0;
18959 #deletedAnnotationsElementIds = new Set();
18960 #draggingEditors = null;
18961 #editorTypes = null;
18962 #editorsToRescale = new Set();
18963 #enableHighlightFloatingButton = false;
18964 #filterFactory = null;
18965 #focusMainContainerTimeoutId = null;
18966 #highlightColors = null;
18967 #highlightWhenShiftUp = false;
18968 #highlightToolbar = null;
18969 #idManager = new IdManager();
18970 #isEnabled = false;
18971 #isWaiting = false;
18972 #lastActiveElement = null;
18973 #mainHighlightColorPicker = null;
18974 #mlManager = null;
18975 #mode = _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.NONE;
18976 #selectedEditors = new Set();
18977 #selectedTextNode = null;
18978 #pageColors = null;
18979 #showAllStates = null;
18980 #boundBlur = this.blur.bind(this);
18981 #boundFocus = this.focus.bind(this);
18982 #boundCopy = this.copy.bind(this);
18983 #boundCut = this.cut.bind(this);
18984 #boundPaste = this.paste.bind(this);
18985 #boundKeydown = this.keydown.bind(this);
18986 #boundKeyup = this.keyup.bind(this);
18987 #boundOnEditingAction = this.onEditingAction.bind(this);
18988 #boundOnPageChanging = this.onPageChanging.bind(this);
18989 #boundOnScaleChanging = this.onScaleChanging.bind(this);
18990 #boundSelectionChange = this.#selectionChange.bind(this);
18991 #boundOnRotationChanging = this.onRotationChanging.bind(this);
18992 #previousStates = {
18993 isEditing: false,
18994 isEmpty: true,
18995 hasSomethingToUndo: false,
18996 hasSomethingToRedo: false,
18997 hasSelectedEditor: false,
18998 hasSelectedText: false
18999 };
19000 #translation = [0, 0];
19001 #translationTimeoutId = null;
19002 #container = null;
19003 #viewer = null;
19004 static TRANSLATE_SMALL = 1;
19005 static TRANSLATE_BIG = 10;
19006 static get _keyboardManager() {
19007 const proto = AnnotationEditorUIManager.prototype;
19008 const arrowChecker = self => self.#container.contains(document.activeElement) && document.activeElement.tagName !== "BUTTON" && self.hasSomethingToControl();
19009 const textInputChecker = (_self, _ref2) => {
19010 let {
19011 target: el
19012 } = _ref2;
19013 if (el instanceof HTMLInputElement) {
19014 const {
19015 type
19016 } = el;
19017 return type !== "text" && type !== "number";
19018 }
19019 return true;
19020 };
19021 const small = this.TRANSLATE_SMALL;
19022 const big = this.TRANSLATE_BIG;
19023 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.shadow)(this, "_keyboardManager", new KeyboardManager([[["ctrl+a", "mac+meta+a"], proto.selectAll, {
19024 checker: textInputChecker
19025 }], [["ctrl+z", "mac+meta+z"], proto.undo, {
19026 checker: textInputChecker
19027 }], [["ctrl+y", "ctrl+shift+z", "mac+meta+shift+z", "ctrl+shift+Z", "mac+meta+shift+Z"], proto.redo, {
19028 checker: textInputChecker
19029 }], [["Backspace", "alt+Backspace", "ctrl+Backspace", "shift+Backspace", "mac+Backspace", "mac+alt+Backspace", "mac+ctrl+Backspace", "Delete", "ctrl+Delete", "shift+Delete", "mac+Delete"], proto.delete, {
19030 checker: textInputChecker
19031 }], [["Enter", "mac+Enter"], proto.addNewEditorFromKeyboard, {
19032 checker: (self, _ref3) => {
19033 let {
19034 target: el
19035 } = _ref3;
19036 return !(el instanceof HTMLButtonElement) && self.#container.contains(el) && !self.isEnterHandled;
19037 }
19038 }], [[" ", "mac+ "], proto.addNewEditorFromKeyboard, {
19039 checker: (self, _ref4) => {
19040 let {
19041 target: el
19042 } = _ref4;
19043 return !(el instanceof HTMLButtonElement) && self.#container.contains(document.activeElement);
19044 }
19045 }], [["Escape", "mac+Escape"], proto.unselectAll], [["ArrowLeft", "mac+ArrowLeft"], proto.translateSelectedEditors, {
19046 args: [-small, 0],
19047 checker: arrowChecker
19048 }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], proto.translateSelectedEditors, {
19049 args: [-big, 0],
19050 checker: arrowChecker
19051 }], [["ArrowRight", "mac+ArrowRight"], proto.translateSelectedEditors, {
19052 args: [small, 0],
19053 checker: arrowChecker
19054 }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], proto.translateSelectedEditors, {
19055 args: [big, 0],
19056 checker: arrowChecker
19057 }], [["ArrowUp", "mac+ArrowUp"], proto.translateSelectedEditors, {
19058 args: [0, -small],
19059 checker: arrowChecker
19060 }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], proto.translateSelectedEditors, {
19061 args: [0, -big],
19062 checker: arrowChecker
19063 }], [["ArrowDown", "mac+ArrowDown"], proto.translateSelectedEditors, {
19064 args: [0, small],
19065 checker: arrowChecker
19066 }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], proto.translateSelectedEditors, {
19067 args: [0, big],
19068 checker: arrowChecker
19069 }]]));
19070 }
19071 constructor(container, viewer, altTextManager, eventBus, pdfDocument, pageColors, highlightColors, enableHighlightFloatingButton, mlManager) {
19072 this.#container = container;
19073 this.#viewer = viewer;
19074 this.#altTextManager = altTextManager;
19075 this._eventBus = eventBus;
19076 this._eventBus._on("editingaction", this.#boundOnEditingAction);
19077 this._eventBus._on("pagechanging", this.#boundOnPageChanging);
19078 this._eventBus._on("scalechanging", this.#boundOnScaleChanging);
19079 this._eventBus._on("rotationchanging", this.#boundOnRotationChanging);
19080 this.#addSelectionListener();
19081 this.#addKeyboardManager();
19082 this.#annotationStorage = pdfDocument.annotationStorage;
19083 this.#filterFactory = pdfDocument.filterFactory;
19084 this.#pageColors = pageColors;
19085 this.#highlightColors = highlightColors || null;
19086 this.#enableHighlightFloatingButton = enableHighlightFloatingButton;
19087 this.#mlManager = mlManager || null;
19088 this.viewParameters = {
19089 realScale: _display_utils_js__WEBPACK_IMPORTED_MODULE_20__.PixelsPerInch.PDF_TO_CSS_UNITS,
19090 rotation: 0
19091 };
19092 this.isShiftKeyDown = false;
19093 }
19094 destroy() {
19095 this.#removeKeyboardManager();
19096 this.#removeFocusManager();
19097 this._eventBus._off("editingaction", this.#boundOnEditingAction);
19098 this._eventBus._off("pagechanging", this.#boundOnPageChanging);
19099 this._eventBus._off("scalechanging", this.#boundOnScaleChanging);
19100 this._eventBus._off("rotationchanging", this.#boundOnRotationChanging);
19101 for (const layer of this.#allLayers.values()) {
19102 layer.destroy();
19103 }
19104 this.#allLayers.clear();
19105 this.#allEditors.clear();
19106 this.#editorsToRescale.clear();
19107 this.#activeEditor = null;
19108 this.#selectedEditors.clear();
19109 this.#commandManager.destroy();
19110 this.#altTextManager?.destroy();
19111 this.#highlightToolbar?.hide();
19112 this.#highlightToolbar = null;
19113 if (this.#focusMainContainerTimeoutId) {
19114 clearTimeout(this.#focusMainContainerTimeoutId);
19115 this.#focusMainContainerTimeoutId = null;
19116 }
19117 if (this.#translationTimeoutId) {
19118 clearTimeout(this.#translationTimeoutId);
19119 this.#translationTimeoutId = null;
19120 }
19121 this.#removeSelectionListener();
19122 }
19123 async mlGuess(data) {
19124 return this.#mlManager?.guess(data) || null;
19125 }
19126 get hasMLManager() {
19127 return !!this.#mlManager;
19128 }
19129 get hcmFilter() {
19130 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.shadow)(this, "hcmFilter", this.#pageColors ? this.#filterFactory.addHCMFilter(this.#pageColors.foreground, this.#pageColors.background) : "none");
19131 }
19132 get direction() {
19133 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.shadow)(this, "direction", getComputedStyle(this.#container).direction);
19134 }
19135 get highlightColors() {
19136 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.shadow)(this, "highlightColors", this.#highlightColors ? new Map(this.#highlightColors.split(",").map(pair => pair.split("=").map(x => x.trim()))) : null);
19137 }
19138 get highlightColorNames() {
19139 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.shadow)(this, "highlightColorNames", this.highlightColors ? new Map(Array.from(this.highlightColors, e => e.reverse())) : null);
19140 }
19141 setMainHighlightColorPicker(colorPicker) {
19142 this.#mainHighlightColorPicker = colorPicker;
19143 }
19144 editAltText(editor) {
19145 this.#altTextManager?.editAltText(this, editor);
19146 }
19147 onPageChanging(_ref5) {
19148 let {
19149 pageNumber
19150 } = _ref5;
19151 this.#currentPageIndex = pageNumber - 1;
19152 }
19153 focusMainContainer() {
19154 this.#container.focus();
19155 }
19156 findParent(x, y) {
19157 for (const layer of this.#allLayers.values()) {
19158 const {
19159 x: layerX,
19160 y: layerY,
19161 width,
19162 height
19163 } = layer.div.getBoundingClientRect();
19164 if (x >= layerX && x <= layerX + width && y >= layerY && y <= layerY + height) {
19165 return layer;
19166 }
19167 }
19168 return null;
19169 }
19170 disableUserSelect() {
19171 let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
19172 this.#viewer.classList.toggle("noUserSelect", value);
19173 }
19174 addShouldRescale(editor) {
19175 this.#editorsToRescale.add(editor);
19176 }
19177 removeShouldRescale(editor) {
19178 this.#editorsToRescale.delete(editor);
19179 }
19180 onScaleChanging(_ref6) {
19181 let {
19182 scale
19183 } = _ref6;
19184 this.commitOrRemove();
19185 this.viewParameters.realScale = scale * _display_utils_js__WEBPACK_IMPORTED_MODULE_20__.PixelsPerInch.PDF_TO_CSS_UNITS;
19186 for (const editor of this.#editorsToRescale) {
19187 editor.onScaleChanging();
19188 }
19189 }
19190 onRotationChanging(_ref7) {
19191 let {
19192 pagesRotation
19193 } = _ref7;
19194 this.commitOrRemove();
19195 this.viewParameters.rotation = pagesRotation;
19196 }
19197 #getAnchorElementForSelection(_ref8) {
19198 let {
19199 anchorNode
19200 } = _ref8;
19201 return anchorNode.nodeType === Node.TEXT_NODE ? anchorNode.parentElement : anchorNode;
19202 }
19203 highlightSelection() {
19204 let methodOfCreation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
19205 const selection = document.getSelection();
19206 if (!selection || selection.isCollapsed) {
19207 return;
19208 }
19209 const {
19210 anchorNode,
19211 anchorOffset,
19212 focusNode,
19213 focusOffset
19214 } = selection;
19215 const text = selection.toString();
19216 const anchorElement = this.#getAnchorElementForSelection(selection);
19217 const textLayer = anchorElement.closest(".textLayer");
19218 const boxes = this.getSelectionBoxes(textLayer);
19219 if (!boxes) {
19220 return;
19221 }
19222 selection.empty();
19223 if (this.#mode === _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.NONE) {
19224 this._eventBus.dispatch("showannotationeditorui", {
19225 source: this,
19226 mode: _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.HIGHLIGHT
19227 });
19228 this.showAllEditors("highlight", true, true);
19229 }
19230 for (const layer of this.#allLayers.values()) {
19231 if (layer.hasTextLayer(textLayer)) {
19232 layer.createAndAddNewEditor({
19233 x: 0,
19234 y: 0
19235 }, false, {
19236 methodOfCreation,
19237 boxes,
19238 anchorNode,
19239 anchorOffset,
19240 focusNode,
19241 focusOffset,
19242 text
19243 });
19244 break;
19245 }
19246 }
19247 }
19248 #displayHighlightToolbar() {
19249 const selection = document.getSelection();
19250 if (!selection || selection.isCollapsed) {
19251 return;
19252 }
19253 const anchorElement = this.#getAnchorElementForSelection(selection);
19254 const textLayer = anchorElement.closest(".textLayer");
19255 const boxes = this.getSelectionBoxes(textLayer);
19256 if (!boxes) {
19257 return;
19258 }
19259 this.#highlightToolbar ||= new _toolbar_js__WEBPACK_IMPORTED_MODULE_21__.HighlightToolbar(this);
19260 this.#highlightToolbar.show(textLayer, boxes, this.direction === "ltr");
19261 }
19262 addToAnnotationStorage(editor) {
19263 if (!editor.isEmpty() && this.#annotationStorage && !this.#annotationStorage.has(editor.id)) {
19264 this.#annotationStorage.setValue(editor.id, editor);
19265 }
19266 }
19267 #selectionChange() {
19268 const selection = document.getSelection();
19269 if (!selection || selection.isCollapsed) {
19270 if (this.#selectedTextNode) {
19271 this.#highlightToolbar?.hide();
19272 this.#selectedTextNode = null;
19273 this.#dispatchUpdateStates({
19274 hasSelectedText: false
19275 });
19276 }
19277 return;
19278 }
19279 const {
19280 anchorNode
19281 } = selection;
19282 if (anchorNode === this.#selectedTextNode) {
19283 return;
19284 }
19285 const anchorElement = this.#getAnchorElementForSelection(selection);
19286 const textLayer = anchorElement.closest(".textLayer");
19287 if (!textLayer) {
19288 if (this.#selectedTextNode) {
19289 this.#highlightToolbar?.hide();
19290 this.#selectedTextNode = null;
19291 this.#dispatchUpdateStates({
19292 hasSelectedText: false
19293 });
19294 }
19295 return;
19296 }
19297 this.#highlightToolbar?.hide();
19298 this.#selectedTextNode = anchorNode;
19299 this.#dispatchUpdateStates({
19300 hasSelectedText: true
19301 });
19302 if (this.#mode !== _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.HIGHLIGHT && this.#mode !== _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.NONE) {
19303 return;
19304 }
19305 if (this.#mode === _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.HIGHLIGHT) {
19306 this.showAllEditors("highlight", true, true);
19307 }
19308 this.#highlightWhenShiftUp = this.isShiftKeyDown;
19309 if (!this.isShiftKeyDown) {
19310 const pointerup = e => {
19311 if (e.type === "pointerup" && e.button !== 0) {
19312 return;
19313 }
19314 window.removeEventListener("pointerup", pointerup);
19315 window.removeEventListener("blur", pointerup);
19316 if (e.type === "pointerup") {
19317 this.#onSelectEnd("main_toolbar");
19318 }
19319 };
19320 window.addEventListener("pointerup", pointerup);
19321 window.addEventListener("blur", pointerup);
19322 }
19323 }
19324 #onSelectEnd() {
19325 let methodOfCreation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
19326 if (this.#mode === _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.HIGHLIGHT) {
19327 this.highlightSelection(methodOfCreation);
19328 } else if (this.#enableHighlightFloatingButton) {
19329 this.#displayHighlightToolbar();
19330 }
19331 }
19332 #addSelectionListener() {
19333 document.addEventListener("selectionchange", this.#boundSelectionChange);
19334 }
19335 #removeSelectionListener() {
19336 document.removeEventListener("selectionchange", this.#boundSelectionChange);
19337 }
19338 #addFocusManager() {
19339 window.addEventListener("focus", this.#boundFocus);
19340 window.addEventListener("blur", this.#boundBlur);
19341 }
19342 #removeFocusManager() {
19343 window.removeEventListener("focus", this.#boundFocus);
19344 window.removeEventListener("blur", this.#boundBlur);
19345 }
19346 blur() {
19347 this.isShiftKeyDown = false;
19348 if (this.#highlightWhenShiftUp) {
19349 this.#highlightWhenShiftUp = false;
19350 this.#onSelectEnd("main_toolbar");
19351 }
19352 if (!this.hasSelection) {
19353 return;
19354 }
19355 const {
19356 activeElement
19357 } = document;
19358 for (const editor of this.#selectedEditors) {
19359 if (editor.div.contains(activeElement)) {
19360 this.#lastActiveElement = [editor, activeElement];
19361 editor._focusEventsAllowed = false;
19362 break;
19363 }
19364 }
19365 }
19366 focus() {
19367 if (!this.#lastActiveElement) {
19368 return;
19369 }
19370 const [lastEditor, lastActiveElement] = this.#lastActiveElement;
19371 this.#lastActiveElement = null;
19372 lastActiveElement.addEventListener("focusin", () => {
19373 lastEditor._focusEventsAllowed = true;
19374 }, {
19375 once: true
19376 });
19377 lastActiveElement.focus();
19378 }
19379 #addKeyboardManager() {
19380 window.addEventListener("keydown", this.#boundKeydown);
19381 window.addEventListener("keyup", this.#boundKeyup);
19382 }
19383 #removeKeyboardManager() {
19384 window.removeEventListener("keydown", this.#boundKeydown);
19385 window.removeEventListener("keyup", this.#boundKeyup);
19386 }
19387 #addCopyPasteListeners() {
19388 document.addEventListener("copy", this.#boundCopy);
19389 document.addEventListener("cut", this.#boundCut);
19390 document.addEventListener("paste", this.#boundPaste);
19391 }
19392 #removeCopyPasteListeners() {
19393 document.removeEventListener("copy", this.#boundCopy);
19394 document.removeEventListener("cut", this.#boundCut);
19395 document.removeEventListener("paste", this.#boundPaste);
19396 }
19397 addEditListeners() {
19398 this.#addKeyboardManager();
19399 this.#addCopyPasteListeners();
19400 }
19401 removeEditListeners() {
19402 this.#removeKeyboardManager();
19403 this.#removeCopyPasteListeners();
19404 }
19405 copy(event) {
19406 event.preventDefault();
19407 this.#activeEditor?.commitOrRemove();
19408 if (!this.hasSelection) {
19409 return;
19410 }
19411 const editors = [];
19412 for (const editor of this.#selectedEditors) {
19413 const serialized = editor.serialize(true);
19414 if (serialized) {
19415 editors.push(serialized);
19416 }
19417 }
19418 if (editors.length === 0) {
19419 return;
19420 }
19421 event.clipboardData.setData("application/pdfjs", JSON.stringify(editors));
19422 }
19423 cut(event) {
19424 this.copy(event);
19425 this.delete();
19426 }
19427 paste(event) {
19428 event.preventDefault();
19429 const {
19430 clipboardData
19431 } = event;
19432 for (const item of clipboardData.items) {
19433 for (const editorType of this.#editorTypes) {
19434 if (editorType.isHandlingMimeForPasting(item.type)) {
19435 editorType.paste(item, this.currentLayer);
19436 return;
19437 }
19438 }
19439 }
19440 let data = clipboardData.getData("application/pdfjs");
19441 if (!data) {
19442 return;
19443 }
19444 try {
19445 data = JSON.parse(data);
19446 } catch (ex) {
19447 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.warn)(`paste: "${ex.message}".`);
19448 return;
19449 }
19450 if (!Array.isArray(data)) {
19451 return;
19452 }
19453 this.unselectAll();
19454 const layer = this.currentLayer;
19455 try {
19456 const newEditors = [];
19457 for (const editor of data) {
19458 const deserializedEditor = layer.deserialize(editor);
19459 if (!deserializedEditor) {
19460 return;
19461 }
19462 newEditors.push(deserializedEditor);
19463 }
19464 const cmd = () => {
19465 for (const editor of newEditors) {
19466 this.#addEditorToLayer(editor);
19467 }
19468 this.#selectEditors(newEditors);
19469 };
19470 const undo = () => {
19471 for (const editor of newEditors) {
19472 editor.remove();
19473 }
19474 };
19475 this.addCommands({
19476 cmd,
19477 undo,
19478 mustExec: true
19479 });
19480 } catch (ex) {
19481 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.warn)(`paste: "${ex.message}".`);
19482 }
19483 }
19484 keydown(event) {
19485 if (!this.isShiftKeyDown && event.key === "Shift") {
19486 this.isShiftKeyDown = true;
19487 }
19488 if (this.#mode !== _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.NONE && !this.isEditorHandlingKeyboard) {
19489 AnnotationEditorUIManager._keyboardManager.exec(this, event);
19490 }
19491 }
19492 keyup(event) {
19493 if (this.isShiftKeyDown && event.key === "Shift") {
19494 this.isShiftKeyDown = false;
19495 if (this.#highlightWhenShiftUp) {
19496 this.#highlightWhenShiftUp = false;
19497 this.#onSelectEnd("main_toolbar");
19498 }
19499 }
19500 }
19501 onEditingAction(_ref9) {
19502 let {
19503 name
19504 } = _ref9;
19505 switch (name) {
19506 case "undo":
19507 case "redo":
19508 case "delete":
19509 case "selectAll":
19510 this[name]();
19511 break;
19512 case "highlightSelection":
19513 this.highlightSelection("context_menu");
19514 break;
19515 }
19516 }
19517 #dispatchUpdateStates(details) {
19518 const hasChanged = Object.entries(details).some(_ref10 => {
19519 let [key, value] = _ref10;
19520 return this.#previousStates[key] !== value;
19521 });
19522 if (hasChanged) {
19523 this._eventBus.dispatch("annotationeditorstateschanged", {
19524 source: this,
19525 details: Object.assign(this.#previousStates, details)
19526 });
19527 if (this.#mode === _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.HIGHLIGHT && details.hasSelectedEditor === false) {
19528 this.#dispatchUpdateUI([[_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorParamsType.HIGHLIGHT_FREE, true]]);
19529 }
19530 }
19531 }
19532 #dispatchUpdateUI(details) {
19533 this._eventBus.dispatch("annotationeditorparamschanged", {
19534 source: this,
19535 details
19536 });
19537 }
19538 setEditingState(isEditing) {
19539 if (isEditing) {
19540 this.#addFocusManager();
19541 this.#addCopyPasteListeners();
19542 this.#dispatchUpdateStates({
19543 isEditing: this.#mode !== _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.NONE,
19544 isEmpty: this.#isEmpty(),
19545 hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),
19546 hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),
19547 hasSelectedEditor: false
19548 });
19549 } else {
19550 this.#removeFocusManager();
19551 this.#removeCopyPasteListeners();
19552 this.#dispatchUpdateStates({
19553 isEditing: false
19554 });
19555 this.disableUserSelect(false);
19556 }
19557 }
19558 registerEditorTypes(types) {
19559 if (this.#editorTypes) {
19560 return;
19561 }
19562 this.#editorTypes = types;
19563 for (const editorType of this.#editorTypes) {
19564 this.#dispatchUpdateUI(editorType.defaultPropertiesToUpdate);
19565 }
19566 }
19567 getId() {
19568 return this.#idManager.id;
19569 }
19570 get currentLayer() {
19571 return this.#allLayers.get(this.#currentPageIndex);
19572 }
19573 getLayer(pageIndex) {
19574 return this.#allLayers.get(pageIndex);
19575 }
19576 get currentPageIndex() {
19577 return this.#currentPageIndex;
19578 }
19579 addLayer(layer) {
19580 this.#allLayers.set(layer.pageIndex, layer);
19581 if (this.#isEnabled) {
19582 layer.enable();
19583 } else {
19584 layer.disable();
19585 }
19586 }
19587 removeLayer(layer) {
19588 this.#allLayers.delete(layer.pageIndex);
19589 }
19590 updateMode(mode) {
19591 let editId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
19592 let isFromKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
19593 if (this.#mode === mode) {
19594 return;
19595 }
19596 this.#mode = mode;
19597 if (mode === _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.NONE) {
19598 this.setEditingState(false);
19599 this.#disableAll();
19600 return;
19601 }
19602 this.setEditingState(true);
19603 this.#enableAll();
19604 this.unselectAll();
19605 for (const layer of this.#allLayers.values()) {
19606 layer.updateMode(mode);
19607 }
19608 if (!editId && isFromKeyboard) {
19609 this.addNewEditorFromKeyboard();
19610 return;
19611 }
19612 if (!editId) {
19613 return;
19614 }
19615 for (const editor of this.#allEditors.values()) {
19616 if (editor.annotationElementId === editId) {
19617 this.setSelected(editor);
19618 editor.enterInEditMode();
19619 break;
19620 }
19621 }
19622 }
19623 addNewEditorFromKeyboard() {
19624 if (this.currentLayer.canCreateNewEmptyEditor()) {
19625 this.currentLayer.addNewEditor();
19626 }
19627 }
19628 updateToolbar(mode) {
19629 if (mode === this.#mode) {
19630 return;
19631 }
19632 this._eventBus.dispatch("switchannotationeditormode", {
19633 source: this,
19634 mode
19635 });
19636 }
19637 updateParams(type, value) {
19638 if (!this.#editorTypes) {
19639 return;
19640 }
19641 switch (type) {
19642 case _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorParamsType.CREATE:
19643 this.currentLayer.addNewEditor();
19644 return;
19645 case _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
19646 this.#mainHighlightColorPicker?.updateColor(value);
19647 break;
19648 case _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
19649 this._eventBus.dispatch("reporttelemetry", {
19650 source: this,
19651 details: {
19652 type: "editing",
19653 data: {
19654 type: "highlight",
19655 action: "toggle_visibility"
19656 }
19657 }
19658 });
19659 (this.#showAllStates ||= new Map()).set(type, value);
19660 this.showAllEditors("highlight", value);
19661 break;
19662 }
19663 for (const editor of this.#selectedEditors) {
19664 editor.updateParams(type, value);
19665 }
19666 for (const editorType of this.#editorTypes) {
19667 editorType.updateDefaultParams(type, value);
19668 }
19669 }
19670 showAllEditors(type, visible) {
19671 let updateButton = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
19672 for (const editor of this.#allEditors.values()) {
19673 if (editor.editorType === type) {
19674 editor.show(visible);
19675 }
19676 }
19677 const state = this.#showAllStates?.get(_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL) ?? true;
19678 if (state !== visible) {
19679 this.#dispatchUpdateUI([[_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL, visible]]);
19680 }
19681 }
19682 enableWaiting() {
19683 let mustWait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
19684 if (this.#isWaiting === mustWait) {
19685 return;
19686 }
19687 this.#isWaiting = mustWait;
19688 for (const layer of this.#allLayers.values()) {
19689 if (mustWait) {
19690 layer.disableClick();
19691 } else {
19692 layer.enableClick();
19693 }
19694 layer.div.classList.toggle("waiting", mustWait);
19695 }
19696 }
19697 #enableAll() {
19698 if (!this.#isEnabled) {
19699 this.#isEnabled = true;
19700 for (const layer of this.#allLayers.values()) {
19701 layer.enable();
19702 }
19703 for (const editor of this.#allEditors.values()) {
19704 editor.enable();
19705 }
19706 }
19707 }
19708 #disableAll() {
19709 this.unselectAll();
19710 if (this.#isEnabled) {
19711 this.#isEnabled = false;
19712 for (const layer of this.#allLayers.values()) {
19713 layer.disable();
19714 }
19715 for (const editor of this.#allEditors.values()) {
19716 editor.disable();
19717 }
19718 }
19719 }
19720 getEditors(pageIndex) {
19721 const editors = [];
19722 for (const editor of this.#allEditors.values()) {
19723 if (editor.pageIndex === pageIndex) {
19724 editors.push(editor);
19725 }
19726 }
19727 return editors;
19728 }
19729 getEditor(id) {
19730 return this.#allEditors.get(id);
19731 }
19732 addEditor(editor) {
19733 this.#allEditors.set(editor.id, editor);
19734 }
19735 removeEditor(editor) {
19736 if (editor.div.contains(document.activeElement)) {
19737 if (this.#focusMainContainerTimeoutId) {
19738 clearTimeout(this.#focusMainContainerTimeoutId);
19739 }
19740 this.#focusMainContainerTimeoutId = setTimeout(() => {
19741 this.focusMainContainer();
19742 this.#focusMainContainerTimeoutId = null;
19743 }, 0);
19744 }
19745 this.#allEditors.delete(editor.id);
19746 this.unselect(editor);
19747 if (!editor.annotationElementId || !this.#deletedAnnotationsElementIds.has(editor.annotationElementId)) {
19748 this.#annotationStorage?.remove(editor.id);
19749 }
19750 }
19751 addDeletedAnnotationElement(editor) {
19752 this.#deletedAnnotationsElementIds.add(editor.annotationElementId);
19753 editor.deleted = true;
19754 }
19755 isDeletedAnnotationElement(annotationElementId) {
19756 return this.#deletedAnnotationsElementIds.has(annotationElementId);
19757 }
19758 removeDeletedAnnotationElement(editor) {
19759 this.#deletedAnnotationsElementIds.delete(editor.annotationElementId);
19760 editor.deleted = false;
19761 }
19762 #addEditorToLayer(editor) {
19763 const layer = this.#allLayers.get(editor.pageIndex);
19764 if (layer) {
19765 layer.addOrRebuild(editor);
19766 } else {
19767 this.addEditor(editor);
19768 this.addToAnnotationStorage(editor);
19769 }
19770 }
19771 setActiveEditor(editor) {
19772 if (this.#activeEditor === editor) {
19773 return;
19774 }
19775 this.#activeEditor = editor;
19776 if (editor) {
19777 this.#dispatchUpdateUI(editor.propertiesToUpdate);
19778 }
19779 }
19780 get #lastSelectedEditor() {
19781 let ed = null;
19782 for (ed of this.#selectedEditors) {}
19783 return ed;
19784 }
19785 updateUI(editor) {
19786 if (this.#lastSelectedEditor === editor) {
19787 this.#dispatchUpdateUI(editor.propertiesToUpdate);
19788 }
19789 }
19790 toggleSelected(editor) {
19791 if (this.#selectedEditors.has(editor)) {
19792 this.#selectedEditors.delete(editor);
19793 editor.unselect();
19794 this.#dispatchUpdateStates({
19795 hasSelectedEditor: this.hasSelection
19796 });
19797 return;
19798 }
19799 this.#selectedEditors.add(editor);
19800 editor.select();
19801 this.#dispatchUpdateUI(editor.propertiesToUpdate);
19802 this.#dispatchUpdateStates({
19803 hasSelectedEditor: true
19804 });
19805 }
19806 setSelected(editor) {
19807 for (const ed of this.#selectedEditors) {
19808 if (ed !== editor) {
19809 ed.unselect();
19810 }
19811 }
19812 this.#selectedEditors.clear();
19813 this.#selectedEditors.add(editor);
19814 editor.select();
19815 this.#dispatchUpdateUI(editor.propertiesToUpdate);
19816 this.#dispatchUpdateStates({
19817 hasSelectedEditor: true
19818 });
19819 }
19820 isSelected(editor) {
19821 return this.#selectedEditors.has(editor);
19822 }
19823 get firstSelectedEditor() {
19824 return this.#selectedEditors.values().next().value;
19825 }
19826 unselect(editor) {
19827 editor.unselect();
19828 this.#selectedEditors.delete(editor);
19829 this.#dispatchUpdateStates({
19830 hasSelectedEditor: this.hasSelection
19831 });
19832 }
19833 get hasSelection() {
19834 return this.#selectedEditors.size !== 0;
19835 }
19836 get isEnterHandled() {
19837 return this.#selectedEditors.size === 1 && this.firstSelectedEditor.isEnterHandled;
19838 }
19839 undo() {
19840 this.#commandManager.undo();
19841 this.#dispatchUpdateStates({
19842 hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),
19843 hasSomethingToRedo: true,
19844 isEmpty: this.#isEmpty()
19845 });
19846 }
19847 redo() {
19848 this.#commandManager.redo();
19849 this.#dispatchUpdateStates({
19850 hasSomethingToUndo: true,
19851 hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),
19852 isEmpty: this.#isEmpty()
19853 });
19854 }
19855 addCommands(params) {
19856 this.#commandManager.add(params);
19857 this.#dispatchUpdateStates({
19858 hasSomethingToUndo: true,
19859 hasSomethingToRedo: false,
19860 isEmpty: this.#isEmpty()
19861 });
19862 }
19863 #isEmpty() {
19864 if (this.#allEditors.size === 0) {
19865 return true;
19866 }
19867 if (this.#allEditors.size === 1) {
19868 for (const editor of this.#allEditors.values()) {
19869 return editor.isEmpty();
19870 }
19871 }
19872 return false;
19873 }
19874 delete() {
19875 this.commitOrRemove();
19876 if (!this.hasSelection) {
19877 return;
19878 }
19879 const editors = [...this.#selectedEditors];
19880 const cmd = () => {
19881 for (const editor of editors) {
19882 editor.remove();
19883 }
19884 };
19885 const undo = () => {
19886 for (const editor of editors) {
19887 this.#addEditorToLayer(editor);
19888 }
19889 };
19890 this.addCommands({
19891 cmd,
19892 undo,
19893 mustExec: true
19894 });
19895 }
19896 commitOrRemove() {
19897 this.#activeEditor?.commitOrRemove();
19898 }
19899 hasSomethingToControl() {
19900 return this.#activeEditor || this.hasSelection;
19901 }
19902 #selectEditors(editors) {
19903 for (const editor of this.#selectedEditors) {
19904 editor.unselect();
19905 }
19906 this.#selectedEditors.clear();
19907 for (const editor of editors) {
19908 if (editor.isEmpty()) {
19909 continue;
19910 }
19911 this.#selectedEditors.add(editor);
19912 editor.select();
19913 }
19914 this.#dispatchUpdateStates({
19915 hasSelectedEditor: this.hasSelection
19916 });
19917 }
19918 selectAll() {
19919 for (const editor of this.#selectedEditors) {
19920 editor.commit();
19921 }
19922 this.#selectEditors(this.#allEditors.values());
19923 }
19924 unselectAll() {
19925 if (this.#activeEditor) {
19926 this.#activeEditor.commitOrRemove();
19927 if (this.#mode !== _shared_util_js__WEBPACK_IMPORTED_MODULE_19__.AnnotationEditorType.NONE) {
19928 return;
19929 }
19930 }
19931 if (!this.hasSelection) {
19932 return;
19933 }
19934 for (const editor of this.#selectedEditors) {
19935 editor.unselect();
19936 }
19937 this.#selectedEditors.clear();
19938 this.#dispatchUpdateStates({
19939 hasSelectedEditor: false
19940 });
19941 }
19942 translateSelectedEditors(x, y) {
19943 let noCommit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
19944 if (!noCommit) {
19945 this.commitOrRemove();
19946 }
19947 if (!this.hasSelection) {
19948 return;
19949 }
19950 this.#translation[0] += x;
19951 this.#translation[1] += y;
19952 const [totalX, totalY] = this.#translation;
19953 const editors = [...this.#selectedEditors];
19954 const TIME_TO_WAIT = 1000;
19955 if (this.#translationTimeoutId) {
19956 clearTimeout(this.#translationTimeoutId);
19957 }
19958 this.#translationTimeoutId = setTimeout(() => {
19959 this.#translationTimeoutId = null;
19960 this.#translation[0] = this.#translation[1] = 0;
19961 this.addCommands({
19962 cmd: () => {
19963 for (const editor of editors) {
19964 if (this.#allEditors.has(editor.id)) {
19965 editor.translateInPage(totalX, totalY);
19966 }
19967 }
19968 },
19969 undo: () => {
19970 for (const editor of editors) {
19971 if (this.#allEditors.has(editor.id)) {
19972 editor.translateInPage(-totalX, -totalY);
19973 }
19974 }
19975 },
19976 mustExec: false
19977 });
19978 }, TIME_TO_WAIT);
19979 for (const editor of editors) {
19980 editor.translateInPage(x, y);
19981 }
19982 }
19983 setUpDragSession() {
19984 if (!this.hasSelection) {
19985 return;
19986 }
19987 this.disableUserSelect(true);
19988 this.#draggingEditors = new Map();
19989 for (const editor of this.#selectedEditors) {
19990 this.#draggingEditors.set(editor, {
19991 savedX: editor.x,
19992 savedY: editor.y,
19993 savedPageIndex: editor.pageIndex,
19994 newX: 0,
19995 newY: 0,
19996 newPageIndex: -1
19997 });
19998 }
19999 }
20000 endDragSession() {
20001 if (!this.#draggingEditors) {
20002 return false;
20003 }
20004 this.disableUserSelect(false);
20005 const map = this.#draggingEditors;
20006 this.#draggingEditors = null;
20007 let mustBeAddedInUndoStack = false;
20008 for (const [{
20009 x,
20010 y,
20011 pageIndex
20012 }, value] of map) {
20013 value.newX = x;
20014 value.newY = y;
20015 value.newPageIndex = pageIndex;
20016 mustBeAddedInUndoStack ||= x !== value.savedX || y !== value.savedY || pageIndex !== value.savedPageIndex;
20017 }
20018 if (!mustBeAddedInUndoStack) {
20019 return false;
20020 }
20021 const move = (editor, x, y, pageIndex) => {
20022 if (this.#allEditors.has(editor.id)) {
20023 const parent = this.#allLayers.get(pageIndex);
20024 if (parent) {
20025 editor._setParentAndPosition(parent, x, y);
20026 } else {
20027 editor.pageIndex = pageIndex;
20028 editor.x = x;
20029 editor.y = y;
20030 }
20031 }
20032 };
20033 this.addCommands({
20034 cmd: () => {
20035 for (const [editor, {
20036 newX,
20037 newY,
20038 newPageIndex
20039 }] of map) {
20040 move(editor, newX, newY, newPageIndex);
20041 }
20042 },
20043 undo: () => {
20044 for (const [editor, {
20045 savedX,
20046 savedY,
20047 savedPageIndex
20048 }] of map) {
20049 move(editor, savedX, savedY, savedPageIndex);
20050 }
20051 },
20052 mustExec: true
20053 });
20054 return true;
20055 }
20056 dragSelectedEditors(tx, ty) {
20057 if (!this.#draggingEditors) {
20058 return;
20059 }
20060 for (const editor of this.#draggingEditors.keys()) {
20061 editor.drag(tx, ty);
20062 }
20063 }
20064 rebuild(editor) {
20065 if (editor.parent === null) {
20066 const parent = this.getLayer(editor.pageIndex);
20067 if (parent) {
20068 parent.changeParent(editor);
20069 parent.addOrRebuild(editor);
20070 } else {
20071 this.addEditor(editor);
20072 this.addToAnnotationStorage(editor);
20073 editor.rebuild();
20074 }
20075 } else {
20076 editor.parent.addOrRebuild(editor);
20077 }
20078 }
20079 get isEditorHandlingKeyboard() {
20080 return this.getActive()?.shouldGetKeyboardEvents() || this.#selectedEditors.size === 1 && this.firstSelectedEditor.shouldGetKeyboardEvents();
20081 }
20082 isActive(editor) {
20083 return this.#activeEditor === editor;
20084 }
20085 getActive() {
20086 return this.#activeEditor;
20087 }
20088 getMode() {
20089 return this.#mode;
20090 }
20091 get imageManager() {
20092 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_19__.shadow)(this, "imageManager", new ImageManager());
20093 }
20094 getSelectionBoxes(textLayer) {
20095 if (!textLayer) {
20096 return null;
20097 }
20098 const selection = document.getSelection();
20099 for (let i = 0, ii = selection.rangeCount; i < ii; i++) {
20100 if (!textLayer.contains(selection.getRangeAt(i).commonAncestorContainer)) {
20101 return null;
20102 }
20103 }
20104 const {
20105 x: layerX,
20106 y: layerY,
20107 width: parentWidth,
20108 height: parentHeight
20109 } = textLayer.getBoundingClientRect();
20110 let rotator;
20111 switch (textLayer.getAttribute("data-main-rotation")) {
20112 case "90":
20113 rotator = (x, y, w, h) => ({
20114 x: (y - layerY) / parentHeight,
20115 y: 1 - (x + w - layerX) / parentWidth,
20116 width: h / parentHeight,
20117 height: w / parentWidth
20118 });
20119 break;
20120 case "180":
20121 rotator = (x, y, w, h) => ({
20122 x: 1 - (x + w - layerX) / parentWidth,
20123 y: 1 - (y + h - layerY) / parentHeight,
20124 width: w / parentWidth,
20125 height: h / parentHeight
20126 });
20127 break;
20128 case "270":
20129 rotator = (x, y, w, h) => ({
20130 x: 1 - (y + h - layerY) / parentHeight,
20131 y: (x - layerX) / parentWidth,
20132 width: h / parentHeight,
20133 height: w / parentWidth
20134 });
20135 break;
20136 default:
20137 rotator = (x, y, w, h) => ({
20138 x: (x - layerX) / parentWidth,
20139 y: (y - layerY) / parentHeight,
20140 width: w / parentWidth,
20141 height: h / parentHeight
20142 });
20143 break;
20144 }
20145 const boxes = [];
20146 for (let i = 0, ii = selection.rangeCount; i < ii; i++) {
20147 const range = selection.getRangeAt(i);
20148 if (range.collapsed) {
20149 continue;
20150 }
20151 for (const {
20152 x,
20153 y,
20154 width,
20155 height
20156 } of range.getClientRects()) {
20157 if (width === 0 || height === 0) {
20158 continue;
20159 }
20160 boxes.push(rotator(x, y, width, height));
20161 }
20162 }
20163 return boxes.length === 0 ? null : boxes;
20164 }
20165}
20166
20167
20168/***/ }),
20169
20170/***/ 4094:
20171/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
20172
20173/* harmony export */ __webpack_require__.d(__webpack_exports__, {
20174/* harmony export */ PDFFetchStream: () => (/* binding */ PDFFetchStream)
20175/* harmony export */ });
20176/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
20177/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6573);
20178/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8100);
20179/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7936);
20180/* harmony import */ var core_js_modules_es_promise_with_resolvers_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4628);
20181/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7467);
20182/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4732);
20183/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9577);
20184/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4292);
20185/* harmony import */ var _network_utils_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(6490);
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196function createFetchOptions(headers, withCredentials, abortController) {
20197 return {
20198 method: "GET",
20199 headers,
20200 signal: abortController.signal,
20201 mode: "cors",
20202 credentials: withCredentials ? "include" : "same-origin",
20203 redirect: "follow"
20204 };
20205}
20206function createHeaders(httpHeaders) {
20207 const headers = new Headers();
20208 for (const property in httpHeaders) {
20209 const value = httpHeaders[property];
20210 if (value === undefined) {
20211 continue;
20212 }
20213 headers.append(property, value);
20214 }
20215 return headers;
20216}
20217function getArrayBuffer(val) {
20218 if (val instanceof Uint8Array) {
20219 return val.buffer;
20220 }
20221 if (val instanceof ArrayBuffer) {
20222 return val;
20223 }
20224 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_8__.warn)(`getArrayBuffer - unexpected data format: ${val}`);
20225 return new Uint8Array(val).buffer;
20226}
20227class PDFFetchStream {
20228 constructor(source) {
20229 this.source = source;
20230 this.isHttp = /^https?:/i.test(source.url);
20231 this.httpHeaders = this.isHttp && source.httpHeaders || {};
20232 this._fullRequestReader = null;
20233 this._rangeRequestReaders = [];
20234 }
20235 get _progressiveDataLength() {
20236 return this._fullRequestReader?._loaded ?? 0;
20237 }
20238 getFullReader() {
20239 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_8__.assert)(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
20240 this._fullRequestReader = new PDFFetchStreamReader(this);
20241 return this._fullRequestReader;
20242 }
20243 getRangeReader(begin, end) {
20244 if (end <= this._progressiveDataLength) {
20245 return null;
20246 }
20247 const reader = new PDFFetchStreamRangeReader(this, begin, end);
20248 this._rangeRequestReaders.push(reader);
20249 return reader;
20250 }
20251 cancelAllRequests(reason) {
20252 this._fullRequestReader?.cancel(reason);
20253 for (const reader of this._rangeRequestReaders.slice(0)) {
20254 reader.cancel(reason);
20255 }
20256 }
20257}
20258class PDFFetchStreamReader {
20259 constructor(stream) {
20260 this._stream = stream;
20261 this._reader = null;
20262 this._loaded = 0;
20263 this._filename = null;
20264 const source = stream.source;
20265 this._withCredentials = source.withCredentials || false;
20266 this._contentLength = source.length;
20267 this._headersCapability = Promise.withResolvers();
20268 this._disableRange = source.disableRange || false;
20269 this._rangeChunkSize = source.rangeChunkSize;
20270 if (!this._rangeChunkSize && !this._disableRange) {
20271 this._disableRange = true;
20272 }
20273 this._abortController = new AbortController();
20274 this._isStreamingSupported = !source.disableStream;
20275 this._isRangeSupported = !source.disableRange;
20276 this._headers = createHeaders(this._stream.httpHeaders);
20277 const url = source.url;
20278 fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
20279 if (!(0,_network_utils_js__WEBPACK_IMPORTED_MODULE_9__.validateResponseStatus)(response.status)) {
20280 throw (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_9__.createResponseStatusError)(response.status, url);
20281 }
20282 this._reader = response.body.getReader();
20283 this._headersCapability.resolve();
20284 const getResponseHeader = name => response.headers.get(name);
20285 const {
20286 allowRangeRequests,
20287 suggestedLength
20288 } = (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_9__.validateRangeRequestCapabilities)({
20289 getResponseHeader,
20290 isHttp: this._stream.isHttp,
20291 rangeChunkSize: this._rangeChunkSize,
20292 disableRange: this._disableRange
20293 });
20294 this._isRangeSupported = allowRangeRequests;
20295 this._contentLength = suggestedLength || this._contentLength;
20296 this._filename = (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_9__.extractFilenameFromHeader)(getResponseHeader);
20297 if (!this._isStreamingSupported && this._isRangeSupported) {
20298 this.cancel(new _shared_util_js__WEBPACK_IMPORTED_MODULE_8__.AbortException("Streaming is disabled."));
20299 }
20300 }).catch(this._headersCapability.reject);
20301 this.onProgress = null;
20302 }
20303 get headersReady() {
20304 return this._headersCapability.promise;
20305 }
20306 get filename() {
20307 return this._filename;
20308 }
20309 get contentLength() {
20310 return this._contentLength;
20311 }
20312 get isRangeSupported() {
20313 return this._isRangeSupported;
20314 }
20315 get isStreamingSupported() {
20316 return this._isStreamingSupported;
20317 }
20318 async read() {
20319 await this._headersCapability.promise;
20320 const {
20321 value,
20322 done
20323 } = await this._reader.read();
20324 if (done) {
20325 return {
20326 value,
20327 done
20328 };
20329 }
20330 this._loaded += value.byteLength;
20331 this.onProgress?.({
20332 loaded: this._loaded,
20333 total: this._contentLength
20334 });
20335 return {
20336 value: getArrayBuffer(value),
20337 done: false
20338 };
20339 }
20340 cancel(reason) {
20341 this._reader?.cancel(reason);
20342 this._abortController.abort();
20343 }
20344}
20345class PDFFetchStreamRangeReader {
20346 constructor(stream, begin, end) {
20347 this._stream = stream;
20348 this._reader = null;
20349 this._loaded = 0;
20350 const source = stream.source;
20351 this._withCredentials = source.withCredentials || false;
20352 this._readCapability = Promise.withResolvers();
20353 this._isStreamingSupported = !source.disableStream;
20354 this._abortController = new AbortController();
20355 this._headers = createHeaders(this._stream.httpHeaders);
20356 this._headers.append("Range", `bytes=${begin}-${end - 1}`);
20357 const url = source.url;
20358 fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
20359 if (!(0,_network_utils_js__WEBPACK_IMPORTED_MODULE_9__.validateResponseStatus)(response.status)) {
20360 throw (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_9__.createResponseStatusError)(response.status, url);
20361 }
20362 this._readCapability.resolve();
20363 this._reader = response.body.getReader();
20364 }).catch(this._readCapability.reject);
20365 this.onProgress = null;
20366 }
20367 get isStreamingSupported() {
20368 return this._isStreamingSupported;
20369 }
20370 async read() {
20371 await this._readCapability.promise;
20372 const {
20373 value,
20374 done
20375 } = await this._reader.read();
20376 if (done) {
20377 return {
20378 value,
20379 done
20380 };
20381 }
20382 this._loaded += value.byteLength;
20383 this.onProgress?.({
20384 loaded: this._loaded
20385 });
20386 return {
20387 value: getArrayBuffer(value),
20388 done: false
20389 };
20390 }
20391 cancel(reason) {
20392 this._reader?.cancel(reason);
20393 this._abortController.abort();
20394 }
20395}
20396
20397
20398/***/ }),
20399
20400/***/ 10:
20401/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
20402
20403/* harmony export */ __webpack_require__.d(__webpack_exports__, {
20404/* harmony export */ FontFaceObject: () => (/* binding */ FontFaceObject),
20405/* harmony export */ FontLoader: () => (/* binding */ FontLoader)
20406/* harmony export */ });
20407/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
20408/* harmony import */ var core_js_modules_esnext_set_difference_v2_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3375);
20409/* harmony import */ var core_js_modules_esnext_set_intersection_v2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9225);
20410/* harmony import */ var core_js_modules_esnext_set_is_disjoint_from_v2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3972);
20411/* harmony import */ var core_js_modules_esnext_set_is_subset_of_v2_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9209);
20412/* harmony import */ var core_js_modules_esnext_set_is_superset_of_v2_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5714);
20413/* harmony import */ var core_js_modules_esnext_set_symmetric_difference_v2_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7561);
20414/* harmony import */ var core_js_modules_esnext_set_union_v2_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6197);
20415/* harmony import */ var core_js_modules_web_dom_exception_stack_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4979);
20416/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(4292);
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427class FontLoader {
20428 #systemFonts = new Set();
20429 constructor(_ref) {
20430 let {
20431 ownerDocument = globalThis.document,
20432 styleElement = null
20433 } = _ref;
20434 this._document = ownerDocument;
20435 this.nativeFontFaces = new Set();
20436 this.styleElement = null;
20437 this.loadingRequests = [];
20438 this.loadTestFontId = 0;
20439 }
20440 addNativeFontFace(nativeFontFace) {
20441 this.nativeFontFaces.add(nativeFontFace);
20442 this._document.fonts.add(nativeFontFace);
20443 }
20444 removeNativeFontFace(nativeFontFace) {
20445 this.nativeFontFaces.delete(nativeFontFace);
20446 this._document.fonts.delete(nativeFontFace);
20447 }
20448 insertRule(rule) {
20449 if (!this.styleElement) {
20450 this.styleElement = this._document.createElement("style");
20451 this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement);
20452 }
20453 const styleSheet = this.styleElement.sheet;
20454 styleSheet.insertRule(rule, styleSheet.cssRules.length);
20455 }
20456 clear() {
20457 for (const nativeFontFace of this.nativeFontFaces) {
20458 this._document.fonts.delete(nativeFontFace);
20459 }
20460 this.nativeFontFaces.clear();
20461 this.#systemFonts.clear();
20462 if (this.styleElement) {
20463 this.styleElement.remove();
20464 this.styleElement = null;
20465 }
20466 }
20467 async loadSystemFont(_ref2) {
20468 let {
20469 systemFontInfo: info,
20470 _inspectFont
20471 } = _ref2;
20472 if (!info || this.#systemFonts.has(info.loadedName)) {
20473 return;
20474 }
20475 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.assert)(!this.disableFontFace, "loadSystemFont shouldn't be called when `disableFontFace` is set.");
20476 if (this.isFontLoadingAPISupported) {
20477 const {
20478 loadedName,
20479 src,
20480 style
20481 } = info;
20482 const fontFace = new FontFace(loadedName, src, style);
20483 this.addNativeFontFace(fontFace);
20484 try {
20485 await fontFace.load();
20486 this.#systemFonts.add(loadedName);
20487 _inspectFont?.(info);
20488 } catch {
20489 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.warn)(`Cannot load system font: ${info.baseFontName}, installing it could help to improve PDF rendering.`);
20490 this.removeNativeFontFace(fontFace);
20491 }
20492 return;
20493 }
20494 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.unreachable)("Not implemented: loadSystemFont without the Font Loading API.");
20495 }
20496 async bind(font) {
20497 if (font.attached || font.missingFile && !font.systemFontInfo) {
20498 return;
20499 }
20500 font.attached = true;
20501 if (font.systemFontInfo) {
20502 await this.loadSystemFont(font);
20503 return;
20504 }
20505 if (this.isFontLoadingAPISupported) {
20506 const nativeFontFace = font.createNativeFontFace();
20507 if (nativeFontFace) {
20508 this.addNativeFontFace(nativeFontFace);
20509 try {
20510 await nativeFontFace.loaded;
20511 } catch (ex) {
20512 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.warn)(`Failed to load font '${nativeFontFace.family}': '${ex}'.`);
20513 font.disableFontFace = true;
20514 throw ex;
20515 }
20516 }
20517 return;
20518 }
20519 const rule = font.createFontFaceRule();
20520 if (rule) {
20521 this.insertRule(rule);
20522 if (this.isSyncFontLoadingSupported) {
20523 return;
20524 }
20525 await new Promise(resolve => {
20526 const request = this._queueLoadingCallback(resolve);
20527 this._prepareFontLoadEvent(font, request);
20528 });
20529 }
20530 }
20531 get isFontLoadingAPISupported() {
20532 const hasFonts = !!this._document?.fonts;
20533 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.shadow)(this, "isFontLoadingAPISupported", hasFonts);
20534 }
20535 get isSyncFontLoadingSupported() {
20536 let supported = false;
20537 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.isNodeJS) {
20538 supported = true;
20539 } else if (typeof navigator !== "undefined" && typeof navigator?.userAgent === "string" && /Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)) {
20540 supported = true;
20541 }
20542 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.shadow)(this, "isSyncFontLoadingSupported", supported);
20543 }
20544 _queueLoadingCallback(callback) {
20545 function completeRequest() {
20546 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.assert)(!request.done, "completeRequest() cannot be called twice.");
20547 request.done = true;
20548 while (loadingRequests.length > 0 && loadingRequests[0].done) {
20549 const otherRequest = loadingRequests.shift();
20550 setTimeout(otherRequest.callback, 0);
20551 }
20552 }
20553 const {
20554 loadingRequests
20555 } = this;
20556 const request = {
20557 done: false,
20558 complete: completeRequest,
20559 callback
20560 };
20561 loadingRequests.push(request);
20562 return request;
20563 }
20564 get _loadTestFont() {
20565 const testFont = atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA" + "FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA" + "ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA" + "AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1" + "AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD" + "6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM" + "AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D" + "IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA" + "AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA" + "AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB" + "AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY" + "AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA" + "AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA" + "AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC" + "AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3" + "Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj" + "FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");
20566 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.shadow)(this, "_loadTestFont", testFont);
20567 }
20568 _prepareFontLoadEvent(font, request) {
20569 function int32(data, offset) {
20570 return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
20571 }
20572 function spliceString(s, offset, remove, insert) {
20573 const chunk1 = s.substring(0, offset);
20574 const chunk2 = s.substring(offset + remove);
20575 return chunk1 + insert + chunk2;
20576 }
20577 let i, ii;
20578 const canvas = this._document.createElement("canvas");
20579 canvas.width = 1;
20580 canvas.height = 1;
20581 const ctx = canvas.getContext("2d");
20582 let called = 0;
20583 function isFontReady(name, callback) {
20584 if (++called > 30) {
20585 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.warn)("Load test font never loaded.");
20586 callback();
20587 return;
20588 }
20589 ctx.font = "30px " + name;
20590 ctx.fillText(".", 0, 20);
20591 const imageData = ctx.getImageData(0, 0, 1, 1);
20592 if (imageData.data[3] > 0) {
20593 callback();
20594 return;
20595 }
20596 setTimeout(isFontReady.bind(null, name, callback));
20597 }
20598 const loadTestFontId = `lt${Date.now()}${this.loadTestFontId++}`;
20599 let data = this._loadTestFont;
20600 const COMMENT_OFFSET = 976;
20601 data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
20602 const CFF_CHECKSUM_OFFSET = 16;
20603 const XXXX_VALUE = 0x58585858;
20604 let checksum = int32(data, CFF_CHECKSUM_OFFSET);
20605 for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
20606 checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
20607 }
20608 if (i < loadTestFontId.length) {
20609 checksum = checksum - XXXX_VALUE + int32(loadTestFontId + "XXX", i) | 0;
20610 }
20611 data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.string32)(checksum));
20612 const url = `url(data:font/opentype;base64,${btoa(data)});`;
20613 const rule = `@font-face {font-family:"${loadTestFontId}";src:${url}}`;
20614 this.insertRule(rule);
20615 const div = this._document.createElement("div");
20616 div.style.visibility = "hidden";
20617 div.style.width = div.style.height = "10px";
20618 div.style.position = "absolute";
20619 div.style.top = div.style.left = "0px";
20620 for (const name of [font.loadedName, loadTestFontId]) {
20621 const span = this._document.createElement("span");
20622 span.textContent = "Hi";
20623 span.style.fontFamily = name;
20624 div.append(span);
20625 }
20626 this._document.body.append(div);
20627 isFontReady(loadTestFontId, () => {
20628 div.remove();
20629 request.complete();
20630 });
20631 }
20632}
20633class FontFaceObject {
20634 constructor(translatedData, _ref3) {
20635 let {
20636 isEvalSupported = true,
20637 disableFontFace = false,
20638 ignoreErrors = false,
20639 inspectFont = null
20640 } = _ref3;
20641 this.compiledGlyphs = Object.create(null);
20642 for (const i in translatedData) {
20643 this[i] = translatedData[i];
20644 }
20645 this.isEvalSupported = isEvalSupported !== false;
20646 this.disableFontFace = disableFontFace === true;
20647 this.ignoreErrors = ignoreErrors === true;
20648 this._inspectFont = inspectFont;
20649 }
20650 createNativeFontFace() {
20651 if (!this.data || this.disableFontFace) {
20652 return null;
20653 }
20654 let nativeFontFace;
20655 if (!this.cssFontInfo) {
20656 nativeFontFace = new FontFace(this.loadedName, this.data, {});
20657 } else {
20658 const css = {
20659 weight: this.cssFontInfo.fontWeight
20660 };
20661 if (this.cssFontInfo.italicAngle) {
20662 css.style = `oblique ${this.cssFontInfo.italicAngle}deg`;
20663 }
20664 nativeFontFace = new FontFace(this.cssFontInfo.fontFamily, this.data, css);
20665 }
20666 this._inspectFont?.(this);
20667 return nativeFontFace;
20668 }
20669 createFontFaceRule() {
20670 if (!this.data || this.disableFontFace) {
20671 return null;
20672 }
20673 const data = (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.bytesToString)(this.data);
20674 const url = `url(data:${this.mimetype};base64,${btoa(data)});`;
20675 let rule;
20676 if (!this.cssFontInfo) {
20677 rule = `@font-face {font-family:"${this.loadedName}";src:${url}}`;
20678 } else {
20679 let css = `font-weight: ${this.cssFontInfo.fontWeight};`;
20680 if (this.cssFontInfo.italicAngle) {
20681 css += `font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;
20682 }
20683 rule = `@font-face {font-family:"${this.cssFontInfo.fontFamily}";${css}src:${url}}`;
20684 }
20685 this._inspectFont?.(this, url);
20686 return rule;
20687 }
20688 getPathGenerator(objs, character) {
20689 if (this.compiledGlyphs[character] !== undefined) {
20690 return this.compiledGlyphs[character];
20691 }
20692 let cmds;
20693 try {
20694 cmds = objs.get(this.loadedName + "_path_" + character);
20695 } catch (ex) {
20696 if (!this.ignoreErrors) {
20697 throw ex;
20698 }
20699 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_9__.warn)(`getPathGenerator - ignoring character: "${ex}".`);
20700 return this.compiledGlyphs[character] = function (c, size) {};
20701 }
20702 if (this.isEvalSupported && _shared_util_js__WEBPACK_IMPORTED_MODULE_9__.FeatureTest.isEvalSupported) {
20703 const jsBuf = [];
20704 for (const current of cmds) {
20705 const args = current.args !== undefined ? current.args.join(",") : "";
20706 jsBuf.push("c.", current.cmd, "(", args, ");\n");
20707 }
20708 return this.compiledGlyphs[character] = new Function("c", "size", jsBuf.join(""));
20709 }
20710 return this.compiledGlyphs[character] = function (c, size) {
20711 for (const current of cmds) {
20712 if (current.cmd === "scale") {
20713 current.args = [size, -size];
20714 }
20715 c[current.cmd].apply(c, current.args);
20716 }
20717 };
20718 }
20719}
20720
20721
20722/***/ }),
20723
20724/***/ 6062:
20725/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
20726
20727/* harmony export */ __webpack_require__.d(__webpack_exports__, {
20728/* harmony export */ Metadata: () => (/* binding */ Metadata)
20729/* harmony export */ });
20730/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4292);
20731
20732class Metadata {
20733 #metadataMap;
20734 #data;
20735 constructor(_ref) {
20736 let {
20737 parsedData,
20738 rawData
20739 } = _ref;
20740 this.#metadataMap = parsedData;
20741 this.#data = rawData;
20742 }
20743 getRaw() {
20744 return this.#data;
20745 }
20746 get(name) {
20747 return this.#metadataMap.get(name) ?? null;
20748 }
20749 getAll() {
20750 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.objectFromMap)(this.#metadataMap);
20751 }
20752 has(name) {
20753 return this.#metadataMap.has(name);
20754 }
20755}
20756
20757
20758/***/ }),
20759
20760/***/ 7457:
20761/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
20762
20763/* harmony export */ __webpack_require__.d(__webpack_exports__, {
20764/* harmony export */ PDFNetworkStream: () => (/* binding */ PDFNetworkStream)
20765/* harmony export */ });
20766/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
20767/* harmony import */ var core_js_modules_es_promise_with_resolvers_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4628);
20768/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4292);
20769/* harmony import */ var _network_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6490);
20770
20771
20772
20773
20774const OK_RESPONSE = 200;
20775const PARTIAL_CONTENT_RESPONSE = 206;
20776function getArrayBuffer(xhr) {
20777 const data = xhr.response;
20778 if (typeof data !== "string") {
20779 return data;
20780 }
20781 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_2__.stringToBytes)(data).buffer;
20782}
20783class NetworkManager {
20784 constructor(url) {
20785 let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
20786 this.url = url;
20787 this.isHttp = /^https?:/i.test(url);
20788 this.httpHeaders = this.isHttp && args.httpHeaders || Object.create(null);
20789 this.withCredentials = args.withCredentials || false;
20790 this.currXhrId = 0;
20791 this.pendingRequests = Object.create(null);
20792 }
20793 requestRange(begin, end, listeners) {
20794 const args = {
20795 begin,
20796 end
20797 };
20798 for (const prop in listeners) {
20799 args[prop] = listeners[prop];
20800 }
20801 return this.request(args);
20802 }
20803 requestFull(listeners) {
20804 return this.request(listeners);
20805 }
20806 request(args) {
20807 const xhr = new XMLHttpRequest();
20808 const xhrId = this.currXhrId++;
20809 const pendingRequest = this.pendingRequests[xhrId] = {
20810 xhr
20811 };
20812 xhr.open("GET", this.url);
20813 xhr.withCredentials = this.withCredentials;
20814 for (const property in this.httpHeaders) {
20815 const value = this.httpHeaders[property];
20816 if (value === undefined) {
20817 continue;
20818 }
20819 xhr.setRequestHeader(property, value);
20820 }
20821 if (this.isHttp && "begin" in args && "end" in args) {
20822 xhr.setRequestHeader("Range", `bytes=${args.begin}-${args.end - 1}`);
20823 pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
20824 } else {
20825 pendingRequest.expectedStatus = OK_RESPONSE;
20826 }
20827 xhr.responseType = "arraybuffer";
20828 if (args.onError) {
20829 xhr.onerror = function (evt) {
20830 args.onError(xhr.status);
20831 };
20832 }
20833 xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
20834 xhr.onprogress = this.onProgress.bind(this, xhrId);
20835 pendingRequest.onHeadersReceived = args.onHeadersReceived;
20836 pendingRequest.onDone = args.onDone;
20837 pendingRequest.onError = args.onError;
20838 pendingRequest.onProgress = args.onProgress;
20839 xhr.send(null);
20840 return xhrId;
20841 }
20842 onProgress(xhrId, evt) {
20843 const pendingRequest = this.pendingRequests[xhrId];
20844 if (!pendingRequest) {
20845 return;
20846 }
20847 pendingRequest.onProgress?.(evt);
20848 }
20849 onStateChange(xhrId, evt) {
20850 const pendingRequest = this.pendingRequests[xhrId];
20851 if (!pendingRequest) {
20852 return;
20853 }
20854 const xhr = pendingRequest.xhr;
20855 if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
20856 pendingRequest.onHeadersReceived();
20857 delete pendingRequest.onHeadersReceived;
20858 }
20859 if (xhr.readyState !== 4) {
20860 return;
20861 }
20862 if (!(xhrId in this.pendingRequests)) {
20863 return;
20864 }
20865 delete this.pendingRequests[xhrId];
20866 if (xhr.status === 0 && this.isHttp) {
20867 pendingRequest.onError?.(xhr.status);
20868 return;
20869 }
20870 const xhrStatus = xhr.status || OK_RESPONSE;
20871 const ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
20872 if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
20873 pendingRequest.onError?.(xhr.status);
20874 return;
20875 }
20876 const chunk = getArrayBuffer(xhr);
20877 if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
20878 const rangeHeader = xhr.getResponseHeader("Content-Range");
20879 const matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
20880 pendingRequest.onDone({
20881 begin: parseInt(matches[1], 10),
20882 chunk
20883 });
20884 } else if (chunk) {
20885 pendingRequest.onDone({
20886 begin: 0,
20887 chunk
20888 });
20889 } else {
20890 pendingRequest.onError?.(xhr.status);
20891 }
20892 }
20893 getRequestXhr(xhrId) {
20894 return this.pendingRequests[xhrId].xhr;
20895 }
20896 isPendingRequest(xhrId) {
20897 return xhrId in this.pendingRequests;
20898 }
20899 abortRequest(xhrId) {
20900 const xhr = this.pendingRequests[xhrId].xhr;
20901 delete this.pendingRequests[xhrId];
20902 xhr.abort();
20903 }
20904}
20905class PDFNetworkStream {
20906 constructor(source) {
20907 this._source = source;
20908 this._manager = new NetworkManager(source.url, {
20909 httpHeaders: source.httpHeaders,
20910 withCredentials: source.withCredentials
20911 });
20912 this._rangeChunkSize = source.rangeChunkSize;
20913 this._fullRequestReader = null;
20914 this._rangeRequestReaders = [];
20915 }
20916 _onRangeRequestReaderClosed(reader) {
20917 const i = this._rangeRequestReaders.indexOf(reader);
20918 if (i >= 0) {
20919 this._rangeRequestReaders.splice(i, 1);
20920 }
20921 }
20922 getFullReader() {
20923 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_2__.assert)(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once.");
20924 this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
20925 return this._fullRequestReader;
20926 }
20927 getRangeReader(begin, end) {
20928 const reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
20929 reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
20930 this._rangeRequestReaders.push(reader);
20931 return reader;
20932 }
20933 cancelAllRequests(reason) {
20934 this._fullRequestReader?.cancel(reason);
20935 for (const reader of this._rangeRequestReaders.slice(0)) {
20936 reader.cancel(reason);
20937 }
20938 }
20939}
20940class PDFNetworkStreamFullRequestReader {
20941 constructor(manager, source) {
20942 this._manager = manager;
20943 const args = {
20944 onHeadersReceived: this._onHeadersReceived.bind(this),
20945 onDone: this._onDone.bind(this),
20946 onError: this._onError.bind(this),
20947 onProgress: this._onProgress.bind(this)
20948 };
20949 this._url = source.url;
20950 this._fullRequestId = manager.requestFull(args);
20951 this._headersReceivedCapability = Promise.withResolvers();
20952 this._disableRange = source.disableRange || false;
20953 this._contentLength = source.length;
20954 this._rangeChunkSize = source.rangeChunkSize;
20955 if (!this._rangeChunkSize && !this._disableRange) {
20956 this._disableRange = true;
20957 }
20958 this._isStreamingSupported = false;
20959 this._isRangeSupported = false;
20960 this._cachedChunks = [];
20961 this._requests = [];
20962 this._done = false;
20963 this._storedError = undefined;
20964 this._filename = null;
20965 this.onProgress = null;
20966 }
20967 _onHeadersReceived() {
20968 const fullRequestXhrId = this._fullRequestId;
20969 const fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
20970 const getResponseHeader = name => fullRequestXhr.getResponseHeader(name);
20971 const {
20972 allowRangeRequests,
20973 suggestedLength
20974 } = (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_3__.validateRangeRequestCapabilities)({
20975 getResponseHeader,
20976 isHttp: this._manager.isHttp,
20977 rangeChunkSize: this._rangeChunkSize,
20978 disableRange: this._disableRange
20979 });
20980 if (allowRangeRequests) {
20981 this._isRangeSupported = true;
20982 }
20983 this._contentLength = suggestedLength || this._contentLength;
20984 this._filename = (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_3__.extractFilenameFromHeader)(getResponseHeader);
20985 if (this._isRangeSupported) {
20986 this._manager.abortRequest(fullRequestXhrId);
20987 }
20988 this._headersReceivedCapability.resolve();
20989 }
20990 _onDone(data) {
20991 if (data) {
20992 if (this._requests.length > 0) {
20993 const requestCapability = this._requests.shift();
20994 requestCapability.resolve({
20995 value: data.chunk,
20996 done: false
20997 });
20998 } else {
20999 this._cachedChunks.push(data.chunk);
21000 }
21001 }
21002 this._done = true;
21003 if (this._cachedChunks.length > 0) {
21004 return;
21005 }
21006 for (const requestCapability of this._requests) {
21007 requestCapability.resolve({
21008 value: undefined,
21009 done: true
21010 });
21011 }
21012 this._requests.length = 0;
21013 }
21014 _onError(status) {
21015 this._storedError = (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_3__.createResponseStatusError)(status, this._url);
21016 this._headersReceivedCapability.reject(this._storedError);
21017 for (const requestCapability of this._requests) {
21018 requestCapability.reject(this._storedError);
21019 }
21020 this._requests.length = 0;
21021 this._cachedChunks.length = 0;
21022 }
21023 _onProgress(evt) {
21024 this.onProgress?.({
21025 loaded: evt.loaded,
21026 total: evt.lengthComputable ? evt.total : this._contentLength
21027 });
21028 }
21029 get filename() {
21030 return this._filename;
21031 }
21032 get isRangeSupported() {
21033 return this._isRangeSupported;
21034 }
21035 get isStreamingSupported() {
21036 return this._isStreamingSupported;
21037 }
21038 get contentLength() {
21039 return this._contentLength;
21040 }
21041 get headersReady() {
21042 return this._headersReceivedCapability.promise;
21043 }
21044 async read() {
21045 if (this._storedError) {
21046 throw this._storedError;
21047 }
21048 if (this._cachedChunks.length > 0) {
21049 const chunk = this._cachedChunks.shift();
21050 return {
21051 value: chunk,
21052 done: false
21053 };
21054 }
21055 if (this._done) {
21056 return {
21057 value: undefined,
21058 done: true
21059 };
21060 }
21061 const requestCapability = Promise.withResolvers();
21062 this._requests.push(requestCapability);
21063 return requestCapability.promise;
21064 }
21065 cancel(reason) {
21066 this._done = true;
21067 this._headersReceivedCapability.reject(reason);
21068 for (const requestCapability of this._requests) {
21069 requestCapability.resolve({
21070 value: undefined,
21071 done: true
21072 });
21073 }
21074 this._requests.length = 0;
21075 if (this._manager.isPendingRequest(this._fullRequestId)) {
21076 this._manager.abortRequest(this._fullRequestId);
21077 }
21078 this._fullRequestReader = null;
21079 }
21080}
21081class PDFNetworkStreamRangeRequestReader {
21082 constructor(manager, begin, end) {
21083 this._manager = manager;
21084 const args = {
21085 onDone: this._onDone.bind(this),
21086 onError: this._onError.bind(this),
21087 onProgress: this._onProgress.bind(this)
21088 };
21089 this._url = manager.url;
21090 this._requestId = manager.requestRange(begin, end, args);
21091 this._requests = [];
21092 this._queuedChunk = null;
21093 this._done = false;
21094 this._storedError = undefined;
21095 this.onProgress = null;
21096 this.onClosed = null;
21097 }
21098 _close() {
21099 this.onClosed?.(this);
21100 }
21101 _onDone(data) {
21102 const chunk = data.chunk;
21103 if (this._requests.length > 0) {
21104 const requestCapability = this._requests.shift();
21105 requestCapability.resolve({
21106 value: chunk,
21107 done: false
21108 });
21109 } else {
21110 this._queuedChunk = chunk;
21111 }
21112 this._done = true;
21113 for (const requestCapability of this._requests) {
21114 requestCapability.resolve({
21115 value: undefined,
21116 done: true
21117 });
21118 }
21119 this._requests.length = 0;
21120 this._close();
21121 }
21122 _onError(status) {
21123 this._storedError = (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_3__.createResponseStatusError)(status, this._url);
21124 for (const requestCapability of this._requests) {
21125 requestCapability.reject(this._storedError);
21126 }
21127 this._requests.length = 0;
21128 this._queuedChunk = null;
21129 }
21130 _onProgress(evt) {
21131 if (!this.isStreamingSupported) {
21132 this.onProgress?.({
21133 loaded: evt.loaded
21134 });
21135 }
21136 }
21137 get isStreamingSupported() {
21138 return false;
21139 }
21140 async read() {
21141 if (this._storedError) {
21142 throw this._storedError;
21143 }
21144 if (this._queuedChunk !== null) {
21145 const chunk = this._queuedChunk;
21146 this._queuedChunk = null;
21147 return {
21148 value: chunk,
21149 done: false
21150 };
21151 }
21152 if (this._done) {
21153 return {
21154 value: undefined,
21155 done: true
21156 };
21157 }
21158 const requestCapability = Promise.withResolvers();
21159 this._requests.push(requestCapability);
21160 return requestCapability.promise;
21161 }
21162 cancel(reason) {
21163 this._done = true;
21164 for (const requestCapability of this._requests) {
21165 requestCapability.resolve({
21166 value: undefined,
21167 done: true
21168 });
21169 }
21170 this._requests.length = 0;
21171 if (this._manager.isPendingRequest(this._requestId)) {
21172 this._manager.abortRequest(this._requestId);
21173 }
21174 this._close();
21175 }
21176}
21177
21178
21179/***/ }),
21180
21181/***/ 6490:
21182/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
21183
21184
21185// EXPORTS
21186__webpack_require__.d(__webpack_exports__, {
21187 createResponseStatusError: () => (/* binding */ createResponseStatusError),
21188 extractFilenameFromHeader: () => (/* binding */ extractFilenameFromHeader),
21189 validateRangeRequestCapabilities: () => (/* binding */ validateRangeRequestCapabilities),
21190 validateResponseStatus: () => (/* binding */ validateResponseStatus)
21191});
21192
21193// EXTERNAL MODULE: ./src/shared/util.js
21194var util = __webpack_require__(4292);
21195// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
21196var es_array_push = __webpack_require__(4114);
21197// EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-exception.stack.js
21198var web_dom_exception_stack = __webpack_require__(4979);
21199;// CONCATENATED MODULE: ./src/display/content_disposition.js
21200
21201
21202
21203function getFilenameFromContentDispositionHeader(contentDisposition) {
21204 let needsEncodingFixup = true;
21205 let tmp = toParamRegExp("filename\\*", "i").exec(contentDisposition);
21206 if (tmp) {
21207 tmp = tmp[1];
21208 let filename = rfc2616unquote(tmp);
21209 filename = unescape(filename);
21210 filename = rfc5987decode(filename);
21211 filename = rfc2047decode(filename);
21212 return fixupEncoding(filename);
21213 }
21214 tmp = rfc2231getparam(contentDisposition);
21215 if (tmp) {
21216 const filename = rfc2047decode(tmp);
21217 return fixupEncoding(filename);
21218 }
21219 tmp = toParamRegExp("filename", "i").exec(contentDisposition);
21220 if (tmp) {
21221 tmp = tmp[1];
21222 let filename = rfc2616unquote(tmp);
21223 filename = rfc2047decode(filename);
21224 return fixupEncoding(filename);
21225 }
21226 function toParamRegExp(attributePattern, flags) {
21227 return new RegExp("(?:^|;)\\s*" + attributePattern + "\\s*=\\s*" + "(" + '[^";\\s][^;\\s]*' + "|" + '"(?:[^"\\\\]|\\\\"?)+"?' + ")", flags);
21228 }
21229 function textdecode(encoding, value) {
21230 if (encoding) {
21231 if (!/^[\x00-\xFF]+$/.test(value)) {
21232 return value;
21233 }
21234 try {
21235 const decoder = new TextDecoder(encoding, {
21236 fatal: true
21237 });
21238 const buffer = (0,util.stringToBytes)(value);
21239 value = decoder.decode(buffer);
21240 needsEncodingFixup = false;
21241 } catch {}
21242 }
21243 return value;
21244 }
21245 function fixupEncoding(value) {
21246 if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
21247 value = textdecode("utf-8", value);
21248 if (needsEncodingFixup) {
21249 value = textdecode("iso-8859-1", value);
21250 }
21251 }
21252 return value;
21253 }
21254 function rfc2231getparam(contentDispositionStr) {
21255 const matches = [];
21256 let match;
21257 const iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
21258 while ((match = iter.exec(contentDispositionStr)) !== null) {
21259 let [, n, quot, part] = match;
21260 n = parseInt(n, 10);
21261 if (n in matches) {
21262 if (n === 0) {
21263 break;
21264 }
21265 continue;
21266 }
21267 matches[n] = [quot, part];
21268 }
21269 const parts = [];
21270 for (let n = 0; n < matches.length; ++n) {
21271 if (!(n in matches)) {
21272 break;
21273 }
21274 let [quot, part] = matches[n];
21275 part = rfc2616unquote(part);
21276 if (quot) {
21277 part = unescape(part);
21278 if (n === 0) {
21279 part = rfc5987decode(part);
21280 }
21281 }
21282 parts.push(part);
21283 }
21284 return parts.join("");
21285 }
21286 function rfc2616unquote(value) {
21287 if (value.startsWith('"')) {
21288 const parts = value.slice(1).split('\\"');
21289 for (let i = 0; i < parts.length; ++i) {
21290 const quotindex = parts[i].indexOf('"');
21291 if (quotindex !== -1) {
21292 parts[i] = parts[i].slice(0, quotindex);
21293 parts.length = i + 1;
21294 }
21295 parts[i] = parts[i].replaceAll(/\\(.)/g, "$1");
21296 }
21297 value = parts.join('"');
21298 }
21299 return value;
21300 }
21301 function rfc5987decode(extvalue) {
21302 const encodingend = extvalue.indexOf("'");
21303 if (encodingend === -1) {
21304 return extvalue;
21305 }
21306 const encoding = extvalue.slice(0, encodingend);
21307 const langvalue = extvalue.slice(encodingend + 1);
21308 const value = langvalue.replace(/^[^']*'/, "");
21309 return textdecode(encoding, value);
21310 }
21311 function rfc2047decode(value) {
21312 if (!value.startsWith("=?") || /[\x00-\x19\x80-\xff]/.test(value)) {
21313 return value;
21314 }
21315 return value.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (matches, charset, encoding, text) {
21316 if (encoding === "q" || encoding === "Q") {
21317 text = text.replaceAll("_", " ");
21318 text = text.replaceAll(/=([0-9a-fA-F]{2})/g, function (match, hex) {
21319 return String.fromCharCode(parseInt(hex, 16));
21320 });
21321 return textdecode(charset, text);
21322 }
21323 try {
21324 text = atob(text);
21325 } catch {}
21326 return textdecode(charset, text);
21327 });
21328 }
21329 return "";
21330}
21331
21332// EXTERNAL MODULE: ./src/display/display_utils.js
21333var display_utils = __webpack_require__(5419);
21334;// CONCATENATED MODULE: ./src/display/network_utils.js
21335
21336
21337
21338function validateRangeRequestCapabilities(_ref) {
21339 let {
21340 getResponseHeader,
21341 isHttp,
21342 rangeChunkSize,
21343 disableRange
21344 } = _ref;
21345 const returnValues = {
21346 allowRangeRequests: false,
21347 suggestedLength: undefined
21348 };
21349 const length = parseInt(getResponseHeader("Content-Length"), 10);
21350 if (!Number.isInteger(length)) {
21351 return returnValues;
21352 }
21353 returnValues.suggestedLength = length;
21354 if (length <= 2 * rangeChunkSize) {
21355 return returnValues;
21356 }
21357 if (disableRange || !isHttp) {
21358 return returnValues;
21359 }
21360 if (getResponseHeader("Accept-Ranges") !== "bytes") {
21361 return returnValues;
21362 }
21363 const contentEncoding = getResponseHeader("Content-Encoding") || "identity";
21364 if (contentEncoding !== "identity") {
21365 return returnValues;
21366 }
21367 returnValues.allowRangeRequests = true;
21368 return returnValues;
21369}
21370function extractFilenameFromHeader(getResponseHeader) {
21371 const contentDisposition = getResponseHeader("Content-Disposition");
21372 if (contentDisposition) {
21373 let filename = getFilenameFromContentDispositionHeader(contentDisposition);
21374 if (filename.includes("%")) {
21375 try {
21376 filename = decodeURIComponent(filename);
21377 } catch {}
21378 }
21379 if ((0,display_utils.isPdfFile)(filename)) {
21380 return filename;
21381 }
21382 }
21383 return null;
21384}
21385function createResponseStatusError(status, url) {
21386 if (status === 404 || status === 0 && url.startsWith("file:")) {
21387 return new util.MissingPDFException('Missing PDF "' + url + '".');
21388 }
21389 return new util.UnexpectedResponseException(`Unexpected server response (${status}) while retrieving PDF "${url}".`, status);
21390}
21391function validateResponseStatus(status) {
21392 return status === 200 || status === 206;
21393}
21394
21395
21396/***/ }),
21397
21398/***/ 4786:
21399/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
21400
21401__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
21402/* harmony export */ __webpack_require__.d(__webpack_exports__, {
21403/* harmony export */ PDFNodeStream: () => (/* binding */ PDFNodeStream)
21404/* harmony export */ });
21405/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
21406/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6573);
21407/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8100);
21408/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7936);
21409/* harmony import */ var core_js_modules_es_promise_with_resolvers_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4628);
21410/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7467);
21411/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4732);
21412/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9577);
21413/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4292);
21414/* harmony import */ var _network_utils_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(6490);
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425let fs, http, https, url;
21426if (_shared_util_js__WEBPACK_IMPORTED_MODULE_8__.isNodeJS) {
21427 fs = await import( /*webpackIgnore: true*/"fs");
21428 http = await import( /*webpackIgnore: true*/"http");
21429 https = await import( /*webpackIgnore: true*/"https");
21430 url = await import( /*webpackIgnore: true*/"url");
21431}
21432const fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
21433function parseUrl(sourceUrl) {
21434 const parsedUrl = url.parse(sourceUrl);
21435 if (parsedUrl.protocol === "file:" || parsedUrl.host) {
21436 return parsedUrl;
21437 }
21438 if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
21439 return url.parse(`file:///${sourceUrl}`);
21440 }
21441 if (!parsedUrl.host) {
21442 parsedUrl.protocol = "file:";
21443 }
21444 return parsedUrl;
21445}
21446class PDFNodeStream {
21447 constructor(source) {
21448 this.source = source;
21449 this.url = parseUrl(source.url);
21450 this.isHttp = this.url.protocol === "http:" || this.url.protocol === "https:";
21451 this.isFsUrl = this.url.protocol === "file:";
21452 this.httpHeaders = this.isHttp && source.httpHeaders || {};
21453 this._fullRequestReader = null;
21454 this._rangeRequestReaders = [];
21455 }
21456 get _progressiveDataLength() {
21457 return this._fullRequestReader?._loaded ?? 0;
21458 }
21459 getFullReader() {
21460 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_8__.assert)(!this._fullRequestReader, "PDFNodeStream.getFullReader can only be called once.");
21461 this._fullRequestReader = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
21462 return this._fullRequestReader;
21463 }
21464 getRangeReader(start, end) {
21465 if (end <= this._progressiveDataLength) {
21466 return null;
21467 }
21468 const rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
21469 this._rangeRequestReaders.push(rangeReader);
21470 return rangeReader;
21471 }
21472 cancelAllRequests(reason) {
21473 this._fullRequestReader?.cancel(reason);
21474 for (const reader of this._rangeRequestReaders.slice(0)) {
21475 reader.cancel(reason);
21476 }
21477 }
21478}
21479class BaseFullReader {
21480 constructor(stream) {
21481 this._url = stream.url;
21482 this._done = false;
21483 this._storedError = null;
21484 this.onProgress = null;
21485 const source = stream.source;
21486 this._contentLength = source.length;
21487 this._loaded = 0;
21488 this._filename = null;
21489 this._disableRange = source.disableRange || false;
21490 this._rangeChunkSize = source.rangeChunkSize;
21491 if (!this._rangeChunkSize && !this._disableRange) {
21492 this._disableRange = true;
21493 }
21494 this._isStreamingSupported = !source.disableStream;
21495 this._isRangeSupported = !source.disableRange;
21496 this._readableStream = null;
21497 this._readCapability = Promise.withResolvers();
21498 this._headersCapability = Promise.withResolvers();
21499 }
21500 get headersReady() {
21501 return this._headersCapability.promise;
21502 }
21503 get filename() {
21504 return this._filename;
21505 }
21506 get contentLength() {
21507 return this._contentLength;
21508 }
21509 get isRangeSupported() {
21510 return this._isRangeSupported;
21511 }
21512 get isStreamingSupported() {
21513 return this._isStreamingSupported;
21514 }
21515 async read() {
21516 await this._readCapability.promise;
21517 if (this._done) {
21518 return {
21519 value: undefined,
21520 done: true
21521 };
21522 }
21523 if (this._storedError) {
21524 throw this._storedError;
21525 }
21526 const chunk = this._readableStream.read();
21527 if (chunk === null) {
21528 this._readCapability = Promise.withResolvers();
21529 return this.read();
21530 }
21531 this._loaded += chunk.length;
21532 this.onProgress?.({
21533 loaded: this._loaded,
21534 total: this._contentLength
21535 });
21536 const buffer = new Uint8Array(chunk).buffer;
21537 return {
21538 value: buffer,
21539 done: false
21540 };
21541 }
21542 cancel(reason) {
21543 if (!this._readableStream) {
21544 this._error(reason);
21545 return;
21546 }
21547 this._readableStream.destroy(reason);
21548 }
21549 _error(reason) {
21550 this._storedError = reason;
21551 this._readCapability.resolve();
21552 }
21553 _setReadableStream(readableStream) {
21554 this._readableStream = readableStream;
21555 readableStream.on("readable", () => {
21556 this._readCapability.resolve();
21557 });
21558 readableStream.on("end", () => {
21559 readableStream.destroy();
21560 this._done = true;
21561 this._readCapability.resolve();
21562 });
21563 readableStream.on("error", reason => {
21564 this._error(reason);
21565 });
21566 if (!this._isStreamingSupported && this._isRangeSupported) {
21567 this._error(new _shared_util_js__WEBPACK_IMPORTED_MODULE_8__.AbortException("streaming is disabled"));
21568 }
21569 if (this._storedError) {
21570 this._readableStream.destroy(this._storedError);
21571 }
21572 }
21573}
21574class BaseRangeReader {
21575 constructor(stream) {
21576 this._url = stream.url;
21577 this._done = false;
21578 this._storedError = null;
21579 this.onProgress = null;
21580 this._loaded = 0;
21581 this._readableStream = null;
21582 this._readCapability = Promise.withResolvers();
21583 const source = stream.source;
21584 this._isStreamingSupported = !source.disableStream;
21585 }
21586 get isStreamingSupported() {
21587 return this._isStreamingSupported;
21588 }
21589 async read() {
21590 await this._readCapability.promise;
21591 if (this._done) {
21592 return {
21593 value: undefined,
21594 done: true
21595 };
21596 }
21597 if (this._storedError) {
21598 throw this._storedError;
21599 }
21600 const chunk = this._readableStream.read();
21601 if (chunk === null) {
21602 this._readCapability = Promise.withResolvers();
21603 return this.read();
21604 }
21605 this._loaded += chunk.length;
21606 this.onProgress?.({
21607 loaded: this._loaded
21608 });
21609 const buffer = new Uint8Array(chunk).buffer;
21610 return {
21611 value: buffer,
21612 done: false
21613 };
21614 }
21615 cancel(reason) {
21616 if (!this._readableStream) {
21617 this._error(reason);
21618 return;
21619 }
21620 this._readableStream.destroy(reason);
21621 }
21622 _error(reason) {
21623 this._storedError = reason;
21624 this._readCapability.resolve();
21625 }
21626 _setReadableStream(readableStream) {
21627 this._readableStream = readableStream;
21628 readableStream.on("readable", () => {
21629 this._readCapability.resolve();
21630 });
21631 readableStream.on("end", () => {
21632 readableStream.destroy();
21633 this._done = true;
21634 this._readCapability.resolve();
21635 });
21636 readableStream.on("error", reason => {
21637 this._error(reason);
21638 });
21639 if (this._storedError) {
21640 this._readableStream.destroy(this._storedError);
21641 }
21642 }
21643}
21644function createRequestOptions(parsedUrl, headers) {
21645 return {
21646 protocol: parsedUrl.protocol,
21647 auth: parsedUrl.auth,
21648 host: parsedUrl.hostname,
21649 port: parsedUrl.port,
21650 path: parsedUrl.path,
21651 method: "GET",
21652 headers
21653 };
21654}
21655class PDFNodeStreamFullReader extends BaseFullReader {
21656 constructor(stream) {
21657 super(stream);
21658 const handleResponse = response => {
21659 if (response.statusCode === 404) {
21660 const error = new _shared_util_js__WEBPACK_IMPORTED_MODULE_8__.MissingPDFException(`Missing PDF "${this._url}".`);
21661 this._storedError = error;
21662 this._headersCapability.reject(error);
21663 return;
21664 }
21665 this._headersCapability.resolve();
21666 this._setReadableStream(response);
21667 const getResponseHeader = name => this._readableStream.headers[name.toLowerCase()];
21668 const {
21669 allowRangeRequests,
21670 suggestedLength
21671 } = (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_9__.validateRangeRequestCapabilities)({
21672 getResponseHeader,
21673 isHttp: stream.isHttp,
21674 rangeChunkSize: this._rangeChunkSize,
21675 disableRange: this._disableRange
21676 });
21677 this._isRangeSupported = allowRangeRequests;
21678 this._contentLength = suggestedLength || this._contentLength;
21679 this._filename = (0,_network_utils_js__WEBPACK_IMPORTED_MODULE_9__.extractFilenameFromHeader)(getResponseHeader);
21680 };
21681 this._request = null;
21682 if (this._url.protocol === "http:") {
21683 this._request = http.request(createRequestOptions(this._url, stream.httpHeaders), handleResponse);
21684 } else {
21685 this._request = https.request(createRequestOptions(this._url, stream.httpHeaders), handleResponse);
21686 }
21687 this._request.on("error", reason => {
21688 this._storedError = reason;
21689 this._headersCapability.reject(reason);
21690 });
21691 this._request.end();
21692 }
21693}
21694class PDFNodeStreamRangeReader extends BaseRangeReader {
21695 constructor(stream, start, end) {
21696 super(stream);
21697 this._httpHeaders = {};
21698 for (const property in stream.httpHeaders) {
21699 const value = stream.httpHeaders[property];
21700 if (value === undefined) {
21701 continue;
21702 }
21703 this._httpHeaders[property] = value;
21704 }
21705 this._httpHeaders.Range = `bytes=${start}-${end - 1}`;
21706 const handleResponse = response => {
21707 if (response.statusCode === 404) {
21708 const error = new _shared_util_js__WEBPACK_IMPORTED_MODULE_8__.MissingPDFException(`Missing PDF "${this._url}".`);
21709 this._storedError = error;
21710 return;
21711 }
21712 this._setReadableStream(response);
21713 };
21714 this._request = null;
21715 if (this._url.protocol === "http:") {
21716 this._request = http.request(createRequestOptions(this._url, this._httpHeaders), handleResponse);
21717 } else {
21718 this._request = https.request(createRequestOptions(this._url, this._httpHeaders), handleResponse);
21719 }
21720 this._request.on("error", reason => {
21721 this._storedError = reason;
21722 });
21723 this._request.end();
21724 }
21725}
21726class PDFNodeStreamFsFullReader extends BaseFullReader {
21727 constructor(stream) {
21728 super(stream);
21729 let path = decodeURIComponent(this._url.path);
21730 if (fileUriRegex.test(this._url.href)) {
21731 path = path.replace(/^\//, "");
21732 }
21733 fs.promises.lstat(path).then(stat => {
21734 this._contentLength = stat.size;
21735 this._setReadableStream(fs.createReadStream(path));
21736 this._headersCapability.resolve();
21737 }, error => {
21738 if (error.code === "ENOENT") {
21739 error = new _shared_util_js__WEBPACK_IMPORTED_MODULE_8__.MissingPDFException(`Missing PDF "${path}".`);
21740 }
21741 this._storedError = error;
21742 this._headersCapability.reject(error);
21743 });
21744 }
21745}
21746class PDFNodeStreamFsRangeReader extends BaseRangeReader {
21747 constructor(stream, start, end) {
21748 super(stream);
21749 let path = decodeURIComponent(this._url.path);
21750 if (fileUriRegex.test(this._url.href)) {
21751 path = path.replace(/^\//, "");
21752 }
21753 this._setReadableStream(fs.createReadStream(path, {
21754 start,
21755 end: end - 1
21756 }));
21757 }
21758}
21759
21760__webpack_async_result__();
21761} catch(e) { __webpack_async_result__(e); } }, 1);
21762
21763/***/ }),
21764
21765/***/ 1573:
21766/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
21767
21768__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
21769/* harmony export */ __webpack_require__.d(__webpack_exports__, {
21770/* harmony export */ NodeCMapReaderFactory: () => (/* binding */ NodeCMapReaderFactory),
21771/* harmony export */ NodeCanvasFactory: () => (/* binding */ NodeCanvasFactory),
21772/* harmony export */ NodeFilterFactory: () => (/* binding */ NodeFilterFactory),
21773/* harmony export */ NodeStandardFontDataFactory: () => (/* binding */ NodeStandardFontDataFactory)
21774/* harmony export */ });
21775/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6573);
21776/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8100);
21777/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7936);
21778/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7467);
21779/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4732);
21780/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9577);
21781/* harmony import */ var _base_factory_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2583);
21782/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4292);
21783
21784
21785
21786
21787
21788
21789
21790
21791let fs, canvas, path2d;
21792if (_shared_util_js__WEBPACK_IMPORTED_MODULE_7__.isNodeJS) {
21793 fs = await import( /*webpackIgnore: true*/"fs");
21794 try {
21795 canvas = await import( /*webpackIgnore: true*/"canvas");
21796 } catch {}
21797 try {
21798 path2d = await import( /*webpackIgnore: true*/"path2d");
21799 } catch {}
21800}
21801{
21802 (function checkDOMMatrix() {
21803 if (globalThis.DOMMatrix || !_shared_util_js__WEBPACK_IMPORTED_MODULE_7__.isNodeJS) {
21804 return;
21805 }
21806 const DOMMatrix = canvas?.DOMMatrix;
21807 if (DOMMatrix) {
21808 globalThis.DOMMatrix = DOMMatrix;
21809 } else {
21810 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_7__.warn)("Cannot polyfill `DOMMatrix`, rendering may be broken.");
21811 }
21812 })();
21813 (function checkPath2D() {
21814 if (globalThis.Path2D || !_shared_util_js__WEBPACK_IMPORTED_MODULE_7__.isNodeJS) {
21815 return;
21816 }
21817 const CanvasRenderingContext2D = canvas?.CanvasRenderingContext2D;
21818 const applyPath2DToCanvasRenderingContext = path2d?.applyPath2DToCanvasRenderingContext;
21819 const Path2D = path2d?.Path2D;
21820 if (CanvasRenderingContext2D && applyPath2DToCanvasRenderingContext && Path2D) {
21821 applyPath2DToCanvasRenderingContext(CanvasRenderingContext2D);
21822 globalThis.Path2D = Path2D;
21823 } else {
21824 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_7__.warn)("Cannot polyfill `Path2D`, rendering may be broken.");
21825 }
21826 })();
21827}
21828const fetchData = function (url) {
21829 return fs.promises.readFile(url).then(data => new Uint8Array(data));
21830};
21831class NodeFilterFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_6__.BaseFilterFactory {}
21832class NodeCanvasFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_6__.BaseCanvasFactory {
21833 _createCanvas(width, height) {
21834 return canvas.createCanvas(width, height);
21835 }
21836}
21837class NodeCMapReaderFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_6__.BaseCMapReaderFactory {
21838 _fetchData(url, compressionType) {
21839 return fetchData(url).then(data => ({
21840 cMapData: data,
21841 compressionType
21842 }));
21843 }
21844}
21845class NodeStandardFontDataFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_6__.BaseStandardFontDataFactory {
21846 _fetchData(url) {
21847 return fetchData(url);
21848 }
21849}
21850
21851__webpack_async_result__();
21852} catch(e) { __webpack_async_result__(e); } }, 1);
21853
21854/***/ }),
21855
21856/***/ 5626:
21857/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
21858
21859/* harmony export */ __webpack_require__.d(__webpack_exports__, {
21860/* harmony export */ OptionalContentConfig: () => (/* binding */ OptionalContentConfig)
21861/* harmony export */ });
21862/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4292);
21863/* harmony import */ var _shared_murmurhash3_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7651);
21864
21865
21866const INTERNAL = Symbol("INTERNAL");
21867class OptionalContentGroup {
21868 #isDisplay = false;
21869 #isPrint = false;
21870 #userSet = false;
21871 #visible = true;
21872 constructor(renderingIntent, _ref) {
21873 let {
21874 name,
21875 intent,
21876 usage
21877 } = _ref;
21878 this.#isDisplay = !!(renderingIntent & _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.DISPLAY);
21879 this.#isPrint = !!(renderingIntent & _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.PRINT);
21880 this.name = name;
21881 this.intent = intent;
21882 this.usage = usage;
21883 }
21884 get visible() {
21885 if (this.#userSet) {
21886 return this.#visible;
21887 }
21888 if (!this.#visible) {
21889 return false;
21890 }
21891 const {
21892 print,
21893 view
21894 } = this.usage;
21895 if (this.#isDisplay) {
21896 return view?.viewState !== "OFF";
21897 } else if (this.#isPrint) {
21898 return print?.printState !== "OFF";
21899 }
21900 return true;
21901 }
21902 _setVisible(internal, visible) {
21903 let userSet = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
21904 if (internal !== INTERNAL) {
21905 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Internal method `_setVisible` called.");
21906 }
21907 this.#userSet = userSet;
21908 this.#visible = visible;
21909 }
21910}
21911class OptionalContentConfig {
21912 #cachedGetHash = null;
21913 #groups = new Map();
21914 #initialHash = null;
21915 #order = null;
21916 constructor(data) {
21917 let renderingIntent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.DISPLAY;
21918 this.renderingIntent = renderingIntent;
21919 this.name = null;
21920 this.creator = null;
21921 if (data === null) {
21922 return;
21923 }
21924 this.name = data.name;
21925 this.creator = data.creator;
21926 this.#order = data.order;
21927 for (const group of data.groups) {
21928 this.#groups.set(group.id, new OptionalContentGroup(renderingIntent, group));
21929 }
21930 if (data.baseState === "OFF") {
21931 for (const group of this.#groups.values()) {
21932 group._setVisible(INTERNAL, false);
21933 }
21934 }
21935 for (const on of data.on) {
21936 this.#groups.get(on)._setVisible(INTERNAL, true);
21937 }
21938 for (const off of data.off) {
21939 this.#groups.get(off)._setVisible(INTERNAL, false);
21940 }
21941 this.#initialHash = this.getHash();
21942 }
21943 #evaluateVisibilityExpression(array) {
21944 const length = array.length;
21945 if (length < 2) {
21946 return true;
21947 }
21948 const operator = array[0];
21949 for (let i = 1; i < length; i++) {
21950 const element = array[i];
21951 let state;
21952 if (Array.isArray(element)) {
21953 state = this.#evaluateVisibilityExpression(element);
21954 } else if (this.#groups.has(element)) {
21955 state = this.#groups.get(element).visible;
21956 } else {
21957 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Optional content group not found: ${element}`);
21958 return true;
21959 }
21960 switch (operator) {
21961 case "And":
21962 if (!state) {
21963 return false;
21964 }
21965 break;
21966 case "Or":
21967 if (state) {
21968 return true;
21969 }
21970 break;
21971 case "Not":
21972 return !state;
21973 default:
21974 return true;
21975 }
21976 }
21977 return operator === "And";
21978 }
21979 isVisible(group) {
21980 if (this.#groups.size === 0) {
21981 return true;
21982 }
21983 if (!group) {
21984 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.info)("Optional content group not defined.");
21985 return true;
21986 }
21987 if (group.type === "OCG") {
21988 if (!this.#groups.has(group.id)) {
21989 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Optional content group not found: ${group.id}`);
21990 return true;
21991 }
21992 return this.#groups.get(group.id).visible;
21993 } else if (group.type === "OCMD") {
21994 if (group.expression) {
21995 return this.#evaluateVisibilityExpression(group.expression);
21996 }
21997 if (!group.policy || group.policy === "AnyOn") {
21998 for (const id of group.ids) {
21999 if (!this.#groups.has(id)) {
22000 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Optional content group not found: ${id}`);
22001 return true;
22002 }
22003 if (this.#groups.get(id).visible) {
22004 return true;
22005 }
22006 }
22007 return false;
22008 } else if (group.policy === "AllOn") {
22009 for (const id of group.ids) {
22010 if (!this.#groups.has(id)) {
22011 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Optional content group not found: ${id}`);
22012 return true;
22013 }
22014 if (!this.#groups.get(id).visible) {
22015 return false;
22016 }
22017 }
22018 return true;
22019 } else if (group.policy === "AnyOff") {
22020 for (const id of group.ids) {
22021 if (!this.#groups.has(id)) {
22022 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Optional content group not found: ${id}`);
22023 return true;
22024 }
22025 if (!this.#groups.get(id).visible) {
22026 return true;
22027 }
22028 }
22029 return false;
22030 } else if (group.policy === "AllOff") {
22031 for (const id of group.ids) {
22032 if (!this.#groups.has(id)) {
22033 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Optional content group not found: ${id}`);
22034 return true;
22035 }
22036 if (this.#groups.get(id).visible) {
22037 return false;
22038 }
22039 }
22040 return true;
22041 }
22042 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Unknown optional content policy ${group.policy}.`);
22043 return true;
22044 }
22045 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Unknown group type ${group.type}.`);
22046 return true;
22047 }
22048 setVisibility(id) {
22049 let visible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
22050 const group = this.#groups.get(id);
22051 if (!group) {
22052 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Optional content group not found: ${id}`);
22053 return;
22054 }
22055 group._setVisible(INTERNAL, !!visible, true);
22056 this.#cachedGetHash = null;
22057 }
22058 setOCGState(_ref2) {
22059 let {
22060 state,
22061 preserveRB
22062 } = _ref2;
22063 let operator;
22064 for (const elem of state) {
22065 switch (elem) {
22066 case "ON":
22067 case "OFF":
22068 case "Toggle":
22069 operator = elem;
22070 continue;
22071 }
22072 const group = this.#groups.get(elem);
22073 if (!group) {
22074 continue;
22075 }
22076 switch (operator) {
22077 case "ON":
22078 group._setVisible(INTERNAL, true);
22079 break;
22080 case "OFF":
22081 group._setVisible(INTERNAL, false);
22082 break;
22083 case "Toggle":
22084 group._setVisible(INTERNAL, !group.visible);
22085 break;
22086 }
22087 }
22088 this.#cachedGetHash = null;
22089 }
22090 get hasInitialVisibility() {
22091 return this.#initialHash === null || this.getHash() === this.#initialHash;
22092 }
22093 getOrder() {
22094 if (!this.#groups.size) {
22095 return null;
22096 }
22097 if (this.#order) {
22098 return this.#order.slice();
22099 }
22100 return [...this.#groups.keys()];
22101 }
22102 getGroups() {
22103 return this.#groups.size > 0 ? (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.objectFromMap)(this.#groups) : null;
22104 }
22105 getGroup(id) {
22106 return this.#groups.get(id) || null;
22107 }
22108 getHash() {
22109 if (this.#cachedGetHash !== null) {
22110 return this.#cachedGetHash;
22111 }
22112 const hash = new _shared_murmurhash3_js__WEBPACK_IMPORTED_MODULE_1__.MurmurHash3_64();
22113 for (const [id, group] of this.#groups) {
22114 hash.update(`${id}:${group.visible}`);
22115 }
22116 return this.#cachedGetHash = hash.hexdigest();
22117 }
22118}
22119
22120
22121/***/ }),
22122
22123/***/ 6814:
22124/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
22125
22126/* harmony export */ __webpack_require__.d(__webpack_exports__, {
22127/* harmony export */ cleanupTextLayer: () => (/* binding */ cleanupTextLayer),
22128/* harmony export */ renderTextLayer: () => (/* binding */ renderTextLayer),
22129/* harmony export */ updateTextLayer: () => (/* binding */ updateTextLayer)
22130/* harmony export */ });
22131/* unused harmony export TextLayerRenderTask */
22132/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
22133/* harmony import */ var core_js_modules_es_promise_with_resolvers_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4628);
22134/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4292);
22135/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5419);
22136
22137
22138
22139
22140const MAX_TEXT_DIVS_TO_RENDER = 100000;
22141const DEFAULT_FONT_SIZE = 30;
22142const DEFAULT_FONT_ASCENT = 0.8;
22143const ascentCache = new Map();
22144let _canvasContext = null;
22145function getCtx() {
22146 if (!_canvasContext) {
22147 const canvas = document.createElement("canvas");
22148 canvas.className = "hiddenCanvasElement";
22149 document.body.append(canvas);
22150 _canvasContext = canvas.getContext("2d", {
22151 alpha: false
22152 });
22153 }
22154 return _canvasContext;
22155}
22156function cleanupTextLayer() {
22157 _canvasContext?.canvas.remove();
22158 _canvasContext = null;
22159}
22160function getAscent(fontFamily) {
22161 const cachedAscent = ascentCache.get(fontFamily);
22162 if (cachedAscent) {
22163 return cachedAscent;
22164 }
22165 const ctx = getCtx();
22166 const savedFont = ctx.font;
22167 ctx.canvas.width = ctx.canvas.height = DEFAULT_FONT_SIZE;
22168 ctx.font = `${DEFAULT_FONT_SIZE}px ${fontFamily}`;
22169 const metrics = ctx.measureText("");
22170 let ascent = metrics.fontBoundingBoxAscent;
22171 let descent = Math.abs(metrics.fontBoundingBoxDescent);
22172 if (ascent) {
22173 const ratio = ascent / (ascent + descent);
22174 ascentCache.set(fontFamily, ratio);
22175 ctx.canvas.width = ctx.canvas.height = 0;
22176 ctx.font = savedFont;
22177 return ratio;
22178 }
22179 ctx.strokeStyle = "red";
22180 ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
22181 ctx.strokeText("g", 0, 0);
22182 let pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE).data;
22183 descent = 0;
22184 for (let i = pixels.length - 1 - 3; i >= 0; i -= 4) {
22185 if (pixels[i] > 0) {
22186 descent = Math.ceil(i / 4 / DEFAULT_FONT_SIZE);
22187 break;
22188 }
22189 }
22190 ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
22191 ctx.strokeText("A", 0, DEFAULT_FONT_SIZE);
22192 pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE).data;
22193 ascent = 0;
22194 for (let i = 0, ii = pixels.length; i < ii; i += 4) {
22195 if (pixels[i] > 0) {
22196 ascent = DEFAULT_FONT_SIZE - Math.floor(i / 4 / DEFAULT_FONT_SIZE);
22197 break;
22198 }
22199 }
22200 ctx.canvas.width = ctx.canvas.height = 0;
22201 ctx.font = savedFont;
22202 if (ascent) {
22203 const ratio = ascent / (ascent + descent);
22204 ascentCache.set(fontFamily, ratio);
22205 return ratio;
22206 }
22207 ascentCache.set(fontFamily, DEFAULT_FONT_ASCENT);
22208 return DEFAULT_FONT_ASCENT;
22209}
22210function appendText(task, geom, styles) {
22211 const textDiv = document.createElement("span");
22212 const textDivProperties = {
22213 angle: 0,
22214 canvasWidth: 0,
22215 hasText: geom.str !== "",
22216 hasEOL: geom.hasEOL,
22217 fontSize: 0
22218 };
22219 task._textDivs.push(textDiv);
22220 const tx = _shared_util_js__WEBPACK_IMPORTED_MODULE_2__.Util.transform(task._transform, geom.transform);
22221 let angle = Math.atan2(tx[1], tx[0]);
22222 const style = styles[geom.fontName];
22223 if (style.vertical) {
22224 angle += Math.PI / 2;
22225 }
22226 const fontFamily = task._fontInspectorEnabled && style.fontSubstitution || style.fontFamily;
22227 const fontHeight = Math.hypot(tx[2], tx[3]);
22228 const fontAscent = fontHeight * getAscent(fontFamily);
22229 let left, top;
22230 if (angle === 0) {
22231 left = tx[4];
22232 top = tx[5] - fontAscent;
22233 } else {
22234 left = tx[4] + fontAscent * Math.sin(angle);
22235 top = tx[5] - fontAscent * Math.cos(angle);
22236 }
22237 const scaleFactorStr = "calc(var(--scale-factor)*";
22238 const divStyle = textDiv.style;
22239 if (task._container === task._rootContainer) {
22240 divStyle.left = `${(100 * left / task._pageWidth).toFixed(2)}%`;
22241 divStyle.top = `${(100 * top / task._pageHeight).toFixed(2)}%`;
22242 } else {
22243 divStyle.left = `${scaleFactorStr}${left.toFixed(2)}px)`;
22244 divStyle.top = `${scaleFactorStr}${top.toFixed(2)}px)`;
22245 }
22246 divStyle.fontSize = `${scaleFactorStr}${fontHeight.toFixed(2)}px)`;
22247 divStyle.fontFamily = fontFamily;
22248 textDivProperties.fontSize = fontHeight;
22249 textDiv.setAttribute("role", "presentation");
22250 textDiv.textContent = geom.str;
22251 textDiv.dir = geom.dir;
22252 if (task._fontInspectorEnabled) {
22253 textDiv.dataset.fontName = style.fontSubstitutionLoadedName || geom.fontName;
22254 }
22255 if (angle !== 0) {
22256 textDivProperties.angle = angle * (180 / Math.PI);
22257 }
22258 let shouldScaleText = false;
22259 if (geom.str.length > 1) {
22260 shouldScaleText = true;
22261 } else if (geom.str !== " " && geom.transform[0] !== geom.transform[3]) {
22262 const absScaleX = Math.abs(geom.transform[0]),
22263 absScaleY = Math.abs(geom.transform[3]);
22264 if (absScaleX !== absScaleY && Math.max(absScaleX, absScaleY) / Math.min(absScaleX, absScaleY) > 1.5) {
22265 shouldScaleText = true;
22266 }
22267 }
22268 if (shouldScaleText) {
22269 textDivProperties.canvasWidth = style.vertical ? geom.height : geom.width;
22270 }
22271 task._textDivProperties.set(textDiv, textDivProperties);
22272 if (task._isReadableStream) {
22273 task._layoutText(textDiv);
22274 }
22275}
22276function layout(params) {
22277 const {
22278 div,
22279 scale,
22280 properties,
22281 ctx,
22282 prevFontSize,
22283 prevFontFamily
22284 } = params;
22285 const {
22286 style
22287 } = div;
22288 let transform = "";
22289 if (properties.canvasWidth !== 0 && properties.hasText) {
22290 const {
22291 fontFamily
22292 } = style;
22293 const {
22294 canvasWidth,
22295 fontSize
22296 } = properties;
22297 if (prevFontSize !== fontSize || prevFontFamily !== fontFamily) {
22298 ctx.font = `${fontSize * scale}px ${fontFamily}`;
22299 params.prevFontSize = fontSize;
22300 params.prevFontFamily = fontFamily;
22301 }
22302 const {
22303 width
22304 } = ctx.measureText(div.textContent);
22305 if (width > 0) {
22306 transform = `scaleX(${canvasWidth * scale / width})`;
22307 }
22308 }
22309 if (properties.angle !== 0) {
22310 transform = `rotate(${properties.angle}deg) ${transform}`;
22311 }
22312 if (transform.length > 0) {
22313 style.transform = transform;
22314 }
22315}
22316function render(task) {
22317 if (task._canceled) {
22318 return;
22319 }
22320 const textDivs = task._textDivs;
22321 const capability = task._capability;
22322 const textDivsLength = textDivs.length;
22323 if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
22324 capability.resolve();
22325 return;
22326 }
22327 if (!task._isReadableStream) {
22328 for (const textDiv of textDivs) {
22329 task._layoutText(textDiv);
22330 }
22331 }
22332 capability.resolve();
22333}
22334class TextLayerRenderTask {
22335 constructor(_ref) {
22336 let {
22337 textContentSource,
22338 container,
22339 viewport,
22340 textDivs,
22341 textDivProperties,
22342 textContentItemsStr
22343 } = _ref;
22344 this._textContentSource = textContentSource;
22345 this._isReadableStream = textContentSource instanceof ReadableStream;
22346 this._container = this._rootContainer = container;
22347 this._textDivs = textDivs || [];
22348 this._textContentItemsStr = textContentItemsStr || [];
22349 this._fontInspectorEnabled = !!globalThis.FontInspector?.enabled;
22350 this._reader = null;
22351 this._textDivProperties = textDivProperties || new WeakMap();
22352 this._canceled = false;
22353 this._capability = Promise.withResolvers();
22354 this._layoutTextParams = {
22355 prevFontSize: null,
22356 prevFontFamily: null,
22357 div: null,
22358 scale: viewport.scale * (globalThis.devicePixelRatio || 1),
22359 properties: null,
22360 ctx: getCtx()
22361 };
22362 const {
22363 pageWidth,
22364 pageHeight,
22365 pageX,
22366 pageY
22367 } = viewport.rawDims;
22368 this._transform = [1, 0, 0, -1, -pageX, pageY + pageHeight];
22369 this._pageWidth = pageWidth;
22370 this._pageHeight = pageHeight;
22371 (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_3__.setLayerDimensions)(container, viewport);
22372 this._capability.promise.finally(() => {
22373 this._layoutTextParams = null;
22374 }).catch(() => {});
22375 }
22376 get promise() {
22377 return this._capability.promise;
22378 }
22379 cancel() {
22380 this._canceled = true;
22381 if (this._reader) {
22382 this._reader.cancel(new _shared_util_js__WEBPACK_IMPORTED_MODULE_2__.AbortException("TextLayer task cancelled.")).catch(() => {});
22383 this._reader = null;
22384 }
22385 this._capability.reject(new _shared_util_js__WEBPACK_IMPORTED_MODULE_2__.AbortException("TextLayer task cancelled."));
22386 }
22387 _processItems(items, styleCache) {
22388 for (const item of items) {
22389 if (item.str === undefined) {
22390 if (item.type === "beginMarkedContentProps" || item.type === "beginMarkedContent") {
22391 const parent = this._container;
22392 this._container = document.createElement("span");
22393 this._container.classList.add("markedContent");
22394 if (item.id !== null) {
22395 this._container.setAttribute("id", `${item.id}`);
22396 }
22397 parent.append(this._container);
22398 } else if (item.type === "endMarkedContent") {
22399 this._container = this._container.parentNode;
22400 }
22401 continue;
22402 }
22403 this._textContentItemsStr.push(item.str);
22404 appendText(this, item, styleCache);
22405 }
22406 }
22407 _layoutText(textDiv) {
22408 const textDivProperties = this._layoutTextParams.properties = this._textDivProperties.get(textDiv);
22409 this._layoutTextParams.div = textDiv;
22410 layout(this._layoutTextParams);
22411 if (textDivProperties.hasText) {
22412 this._container.append(textDiv);
22413 }
22414 if (textDivProperties.hasEOL) {
22415 const br = document.createElement("br");
22416 br.setAttribute("role", "presentation");
22417 this._container.append(br);
22418 }
22419 }
22420 _render() {
22421 const {
22422 promise,
22423 resolve,
22424 reject
22425 } = Promise.withResolvers();
22426 let styleCache = Object.create(null);
22427 if (this._isReadableStream) {
22428 const pump = () => {
22429 this._reader.read().then(_ref2 => {
22430 let {
22431 value,
22432 done
22433 } = _ref2;
22434 if (done) {
22435 resolve();
22436 return;
22437 }
22438 Object.assign(styleCache, value.styles);
22439 this._processItems(value.items, styleCache);
22440 pump();
22441 }, reject);
22442 };
22443 this._reader = this._textContentSource.getReader();
22444 pump();
22445 } else if (this._textContentSource) {
22446 const {
22447 items,
22448 styles
22449 } = this._textContentSource;
22450 this._processItems(items, styles);
22451 resolve();
22452 } else {
22453 throw new Error('No "textContentSource" parameter specified.');
22454 }
22455 promise.then(() => {
22456 styleCache = null;
22457 render(this);
22458 }, this._capability.reject);
22459 }
22460}
22461function renderTextLayer(params) {
22462 const task = new TextLayerRenderTask(params);
22463 task._render();
22464 return task;
22465}
22466function updateTextLayer(_ref3) {
22467 let {
22468 container,
22469 viewport,
22470 textDivs,
22471 textDivProperties,
22472 mustRotate = true,
22473 mustRescale = true
22474 } = _ref3;
22475 if (mustRotate) {
22476 (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_3__.setLayerDimensions)(container, {
22477 rotation: viewport.rotation
22478 });
22479 }
22480 if (mustRescale) {
22481 const ctx = getCtx();
22482 const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
22483 const params = {
22484 prevFontSize: null,
22485 prevFontFamily: null,
22486 div: null,
22487 scale,
22488 properties: null,
22489 ctx
22490 };
22491 for (const div of textDivs) {
22492 params.properties = textDivProperties.get(div);
22493 params.div = div;
22494 layout(params);
22495 }
22496 }
22497}
22498
22499
22500/***/ }),
22501
22502/***/ 585:
22503/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
22504
22505/* harmony export */ __webpack_require__.d(__webpack_exports__, {
22506/* harmony export */ PDFDataTransportStream: () => (/* binding */ PDFDataTransportStream)
22507/* harmony export */ });
22508/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
22509/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6573);
22510/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8100);
22511/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7936);
22512/* harmony import */ var core_js_modules_es_promise_with_resolvers_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4628);
22513/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7467);
22514/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4732);
22515/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9577);
22516/* harmony import */ var core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(8992);
22517/* harmony import */ var core_js_modules_esnext_iterator_some_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(7550);
22518/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(4292);
22519/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(5419);
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532class PDFDataTransportStream {
22533 constructor(pdfDataRangeTransport, _ref) {
22534 let {
22535 disableRange = false,
22536 disableStream = false
22537 } = _ref;
22538 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_10__.assert)(pdfDataRangeTransport, 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');
22539 const {
22540 length,
22541 initialData,
22542 progressiveDone,
22543 contentDispositionFilename
22544 } = pdfDataRangeTransport;
22545 this._queuedChunks = [];
22546 this._progressiveDone = progressiveDone;
22547 this._contentDispositionFilename = contentDispositionFilename;
22548 if (initialData?.length > 0) {
22549 const buffer = initialData instanceof Uint8Array && initialData.byteLength === initialData.buffer.byteLength ? initialData.buffer : new Uint8Array(initialData).buffer;
22550 this._queuedChunks.push(buffer);
22551 }
22552 this._pdfDataRangeTransport = pdfDataRangeTransport;
22553 this._isStreamingSupported = !disableStream;
22554 this._isRangeSupported = !disableRange;
22555 this._contentLength = length;
22556 this._fullRequestReader = null;
22557 this._rangeReaders = [];
22558 pdfDataRangeTransport.addRangeListener((begin, chunk) => {
22559 this._onReceiveData({
22560 begin,
22561 chunk
22562 });
22563 });
22564 pdfDataRangeTransport.addProgressListener((loaded, total) => {
22565 this._onProgress({
22566 loaded,
22567 total
22568 });
22569 });
22570 pdfDataRangeTransport.addProgressiveReadListener(chunk => {
22571 this._onReceiveData({
22572 chunk
22573 });
22574 });
22575 pdfDataRangeTransport.addProgressiveDoneListener(() => {
22576 this._onProgressiveDone();
22577 });
22578 pdfDataRangeTransport.transportReady();
22579 }
22580 _onReceiveData(_ref2) {
22581 let {
22582 begin,
22583 chunk
22584 } = _ref2;
22585 const buffer = chunk instanceof Uint8Array && chunk.byteLength === chunk.buffer.byteLength ? chunk.buffer : new Uint8Array(chunk).buffer;
22586 if (begin === undefined) {
22587 if (this._fullRequestReader) {
22588 this._fullRequestReader._enqueue(buffer);
22589 } else {
22590 this._queuedChunks.push(buffer);
22591 }
22592 } else {
22593 const found = this._rangeReaders.some(function (rangeReader) {
22594 if (rangeReader._begin !== begin) {
22595 return false;
22596 }
22597 rangeReader._enqueue(buffer);
22598 return true;
22599 });
22600 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_10__.assert)(found, "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");
22601 }
22602 }
22603 get _progressiveDataLength() {
22604 return this._fullRequestReader?._loaded ?? 0;
22605 }
22606 _onProgress(evt) {
22607 if (evt.total === undefined) {
22608 this._rangeReaders[0]?.onProgress?.({
22609 loaded: evt.loaded
22610 });
22611 } else {
22612 this._fullRequestReader?.onProgress?.({
22613 loaded: evt.loaded,
22614 total: evt.total
22615 });
22616 }
22617 }
22618 _onProgressiveDone() {
22619 this._fullRequestReader?.progressiveDone();
22620 this._progressiveDone = true;
22621 }
22622 _removeRangeReader(reader) {
22623 const i = this._rangeReaders.indexOf(reader);
22624 if (i >= 0) {
22625 this._rangeReaders.splice(i, 1);
22626 }
22627 }
22628 getFullReader() {
22629 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_10__.assert)(!this._fullRequestReader, "PDFDataTransportStream.getFullReader can only be called once.");
22630 const queuedChunks = this._queuedChunks;
22631 this._queuedChunks = null;
22632 return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone, this._contentDispositionFilename);
22633 }
22634 getRangeReader(begin, end) {
22635 if (end <= this._progressiveDataLength) {
22636 return null;
22637 }
22638 const reader = new PDFDataTransportStreamRangeReader(this, begin, end);
22639 this._pdfDataRangeTransport.requestDataRange(begin, end);
22640 this._rangeReaders.push(reader);
22641 return reader;
22642 }
22643 cancelAllRequests(reason) {
22644 this._fullRequestReader?.cancel(reason);
22645 for (const reader of this._rangeReaders.slice(0)) {
22646 reader.cancel(reason);
22647 }
22648 this._pdfDataRangeTransport.abort();
22649 }
22650}
22651class PDFDataTransportStreamReader {
22652 constructor(stream, queuedChunks) {
22653 let progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
22654 let contentDispositionFilename = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
22655 this._stream = stream;
22656 this._done = progressiveDone || false;
22657 this._filename = (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_11__.isPdfFile)(contentDispositionFilename) ? contentDispositionFilename : null;
22658 this._queuedChunks = queuedChunks || [];
22659 this._loaded = 0;
22660 for (const chunk of this._queuedChunks) {
22661 this._loaded += chunk.byteLength;
22662 }
22663 this._requests = [];
22664 this._headersReady = Promise.resolve();
22665 stream._fullRequestReader = this;
22666 this.onProgress = null;
22667 }
22668 _enqueue(chunk) {
22669 if (this._done) {
22670 return;
22671 }
22672 if (this._requests.length > 0) {
22673 const requestCapability = this._requests.shift();
22674 requestCapability.resolve({
22675 value: chunk,
22676 done: false
22677 });
22678 } else {
22679 this._queuedChunks.push(chunk);
22680 }
22681 this._loaded += chunk.byteLength;
22682 }
22683 get headersReady() {
22684 return this._headersReady;
22685 }
22686 get filename() {
22687 return this._filename;
22688 }
22689 get isRangeSupported() {
22690 return this._stream._isRangeSupported;
22691 }
22692 get isStreamingSupported() {
22693 return this._stream._isStreamingSupported;
22694 }
22695 get contentLength() {
22696 return this._stream._contentLength;
22697 }
22698 async read() {
22699 if (this._queuedChunks.length > 0) {
22700 const chunk = this._queuedChunks.shift();
22701 return {
22702 value: chunk,
22703 done: false
22704 };
22705 }
22706 if (this._done) {
22707 return {
22708 value: undefined,
22709 done: true
22710 };
22711 }
22712 const requestCapability = Promise.withResolvers();
22713 this._requests.push(requestCapability);
22714 return requestCapability.promise;
22715 }
22716 cancel(reason) {
22717 this._done = true;
22718 for (const requestCapability of this._requests) {
22719 requestCapability.resolve({
22720 value: undefined,
22721 done: true
22722 });
22723 }
22724 this._requests.length = 0;
22725 }
22726 progressiveDone() {
22727 if (this._done) {
22728 return;
22729 }
22730 this._done = true;
22731 }
22732}
22733class PDFDataTransportStreamRangeReader {
22734 constructor(stream, begin, end) {
22735 this._stream = stream;
22736 this._begin = begin;
22737 this._end = end;
22738 this._queuedChunk = null;
22739 this._requests = [];
22740 this._done = false;
22741 this.onProgress = null;
22742 }
22743 _enqueue(chunk) {
22744 if (this._done) {
22745 return;
22746 }
22747 if (this._requests.length === 0) {
22748 this._queuedChunk = chunk;
22749 } else {
22750 const requestsCapability = this._requests.shift();
22751 requestsCapability.resolve({
22752 value: chunk,
22753 done: false
22754 });
22755 for (const requestCapability of this._requests) {
22756 requestCapability.resolve({
22757 value: undefined,
22758 done: true
22759 });
22760 }
22761 this._requests.length = 0;
22762 }
22763 this._done = true;
22764 this._stream._removeRangeReader(this);
22765 }
22766 get isStreamingSupported() {
22767 return false;
22768 }
22769 async read() {
22770 if (this._queuedChunk) {
22771 const chunk = this._queuedChunk;
22772 this._queuedChunk = null;
22773 return {
22774 value: chunk,
22775 done: false
22776 };
22777 }
22778 if (this._done) {
22779 return {
22780 value: undefined,
22781 done: true
22782 };
22783 }
22784 const requestCapability = Promise.withResolvers();
22785 this._requests.push(requestCapability);
22786 return requestCapability.promise;
22787 }
22788 cancel(reason) {
22789 this._done = true;
22790 for (const requestCapability of this._requests) {
22791 requestCapability.resolve({
22792 value: undefined,
22793 done: true
22794 });
22795 }
22796 this._requests.length = 0;
22797 this._stream._removeRangeReader(this);
22798 }
22799}
22800
22801
22802/***/ }),
22803
22804/***/ 6164:
22805/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
22806
22807/* harmony export */ __webpack_require__.d(__webpack_exports__, {
22808/* harmony export */ GlobalWorkerOptions: () => (/* binding */ GlobalWorkerOptions)
22809/* harmony export */ });
22810class GlobalWorkerOptions {
22811 static #port = null;
22812 static #src = "";
22813 static get workerPort() {
22814 return this.#port;
22815 }
22816 static set workerPort(val) {
22817 if (!(typeof Worker !== "undefined" && val instanceof Worker) && val !== null) {
22818 throw new Error("Invalid `workerPort` type.");
22819 }
22820 this.#port = val;
22821 }
22822 static get workerSrc() {
22823 return this.#src;
22824 }
22825 static set workerSrc(val) {
22826 if (typeof val !== "string") {
22827 throw new Error("Invalid `workerSrc` type.");
22828 }
22829 this.#src = val;
22830 }
22831}
22832
22833
22834/***/ }),
22835
22836/***/ 8284:
22837/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
22838
22839/* harmony export */ __webpack_require__.d(__webpack_exports__, {
22840/* harmony export */ XfaLayer: () => (/* binding */ XfaLayer)
22841/* harmony export */ });
22842/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
22843/* harmony import */ var _xfa_text_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2050);
22844
22845
22846class XfaLayer {
22847 static setupStorage(html, id, element, storage, intent) {
22848 const storedData = storage.getValue(id, {
22849 value: null
22850 });
22851 switch (element.name) {
22852 case "textarea":
22853 if (storedData.value !== null) {
22854 html.textContent = storedData.value;
22855 }
22856 if (intent === "print") {
22857 break;
22858 }
22859 html.addEventListener("input", event => {
22860 storage.setValue(id, {
22861 value: event.target.value
22862 });
22863 });
22864 break;
22865 case "input":
22866 if (element.attributes.type === "radio" || element.attributes.type === "checkbox") {
22867 if (storedData.value === element.attributes.xfaOn) {
22868 html.setAttribute("checked", true);
22869 } else if (storedData.value === element.attributes.xfaOff) {
22870 html.removeAttribute("checked");
22871 }
22872 if (intent === "print") {
22873 break;
22874 }
22875 html.addEventListener("change", event => {
22876 storage.setValue(id, {
22877 value: event.target.checked ? event.target.getAttribute("xfaOn") : event.target.getAttribute("xfaOff")
22878 });
22879 });
22880 } else {
22881 if (storedData.value !== null) {
22882 html.setAttribute("value", storedData.value);
22883 }
22884 if (intent === "print") {
22885 break;
22886 }
22887 html.addEventListener("input", event => {
22888 storage.setValue(id, {
22889 value: event.target.value
22890 });
22891 });
22892 }
22893 break;
22894 case "select":
22895 if (storedData.value !== null) {
22896 html.setAttribute("value", storedData.value);
22897 for (const option of element.children) {
22898 if (option.attributes.value === storedData.value) {
22899 option.attributes.selected = true;
22900 } else if (option.attributes.hasOwnProperty("selected")) {
22901 delete option.attributes.selected;
22902 }
22903 }
22904 }
22905 html.addEventListener("input", event => {
22906 const options = event.target.options;
22907 const value = options.selectedIndex === -1 ? "" : options[options.selectedIndex].value;
22908 storage.setValue(id, {
22909 value
22910 });
22911 });
22912 break;
22913 }
22914 }
22915 static setAttributes(_ref) {
22916 let {
22917 html,
22918 element,
22919 storage = null,
22920 intent,
22921 linkService
22922 } = _ref;
22923 const {
22924 attributes
22925 } = element;
22926 const isHTMLAnchorElement = html instanceof HTMLAnchorElement;
22927 if (attributes.type === "radio") {
22928 attributes.name = `${attributes.name}-${intent}`;
22929 }
22930 for (const [key, value] of Object.entries(attributes)) {
22931 if (value === null || value === undefined) {
22932 continue;
22933 }
22934 switch (key) {
22935 case "class":
22936 if (value.length) {
22937 html.setAttribute(key, value.join(" "));
22938 }
22939 break;
22940 case "dataId":
22941 break;
22942 case "id":
22943 html.setAttribute("data-element-id", value);
22944 break;
22945 case "style":
22946 Object.assign(html.style, value);
22947 break;
22948 case "textContent":
22949 html.textContent = value;
22950 break;
22951 default:
22952 if (!isHTMLAnchorElement || key !== "href" && key !== "newWindow") {
22953 html.setAttribute(key, value);
22954 }
22955 }
22956 }
22957 if (isHTMLAnchorElement) {
22958 linkService.addLinkAttributes(html, attributes.href, attributes.newWindow);
22959 }
22960 if (storage && attributes.dataId) {
22961 this.setupStorage(html, attributes.dataId, element, storage);
22962 }
22963 }
22964 static render(parameters) {
22965 const storage = parameters.annotationStorage;
22966 const linkService = parameters.linkService;
22967 const root = parameters.xfaHtml;
22968 const intent = parameters.intent || "display";
22969 const rootHtml = document.createElement(root.name);
22970 if (root.attributes) {
22971 this.setAttributes({
22972 html: rootHtml,
22973 element: root,
22974 intent,
22975 linkService
22976 });
22977 }
22978 const isNotForRichText = intent !== "richText";
22979 const rootDiv = parameters.div;
22980 rootDiv.append(rootHtml);
22981 if (parameters.viewport) {
22982 const transform = `matrix(${parameters.viewport.transform.join(",")})`;
22983 rootDiv.style.transform = transform;
22984 }
22985 if (isNotForRichText) {
22986 rootDiv.setAttribute("class", "xfaLayer xfaFont");
22987 }
22988 const textDivs = [];
22989 if (root.children.length === 0) {
22990 if (root.value) {
22991 const node = document.createTextNode(root.value);
22992 rootHtml.append(node);
22993 if (isNotForRichText && _xfa_text_js__WEBPACK_IMPORTED_MODULE_1__.XfaText.shouldBuildText(root.name)) {
22994 textDivs.push(node);
22995 }
22996 }
22997 return {
22998 textDivs
22999 };
23000 }
23001 const stack = [[root, -1, rootHtml]];
23002 while (stack.length > 0) {
23003 const [parent, i, html] = stack.at(-1);
23004 if (i + 1 === parent.children.length) {
23005 stack.pop();
23006 continue;
23007 }
23008 const child = parent.children[++stack.at(-1)[1]];
23009 if (child === null) {
23010 continue;
23011 }
23012 const {
23013 name
23014 } = child;
23015 if (name === "#text") {
23016 const node = document.createTextNode(child.value);
23017 textDivs.push(node);
23018 html.append(node);
23019 continue;
23020 }
23021 const childHtml = child?.attributes?.xmlns ? document.createElementNS(child.attributes.xmlns, name) : document.createElement(name);
23022 html.append(childHtml);
23023 if (child.attributes) {
23024 this.setAttributes({
23025 html: childHtml,
23026 element: child,
23027 storage,
23028 intent,
23029 linkService
23030 });
23031 }
23032 if (child.children?.length > 0) {
23033 stack.push([child, -1, childHtml]);
23034 } else if (child.value) {
23035 const node = document.createTextNode(child.value);
23036 if (isNotForRichText && _xfa_text_js__WEBPACK_IMPORTED_MODULE_1__.XfaText.shouldBuildText(name)) {
23037 textDivs.push(node);
23038 }
23039 childHtml.append(node);
23040 }
23041 }
23042 for (const el of rootDiv.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea")) {
23043 el.setAttribute("readOnly", true);
23044 }
23045 return {
23046 textDivs
23047 };
23048 }
23049 static update(parameters) {
23050 const transform = `matrix(${parameters.viewport.transform.join(",")})`;
23051 parameters.div.style.transform = transform;
23052 parameters.div.hidden = false;
23053 }
23054}
23055
23056
23057/***/ }),
23058
23059/***/ 2050:
23060/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
23061
23062/* harmony export */ __webpack_require__.d(__webpack_exports__, {
23063/* harmony export */ XfaText: () => (/* binding */ XfaText)
23064/* harmony export */ });
23065/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
23066
23067class XfaText {
23068 static textContent(xfa) {
23069 const items = [];
23070 const output = {
23071 items,
23072 styles: Object.create(null)
23073 };
23074 function walk(node) {
23075 if (!node) {
23076 return;
23077 }
23078 let str = null;
23079 const name = node.name;
23080 if (name === "#text") {
23081 str = node.value;
23082 } else if (!XfaText.shouldBuildText(name)) {
23083 return;
23084 } else if (node?.attributes?.textContent) {
23085 str = node.attributes.textContent;
23086 } else if (node.value) {
23087 str = node.value;
23088 }
23089 if (str !== null) {
23090 items.push({
23091 str
23092 });
23093 }
23094 if (!node.children) {
23095 return;
23096 }
23097 for (const child of node.children) {
23098 walk(child);
23099 }
23100 }
23101 walk(xfa);
23102 return output;
23103 }
23104 static shouldBuildText(name) {
23105 return !(name === "textarea" || name === "input" || name === "option" || name === "select");
23106 }
23107}
23108
23109
23110/***/ }),
23111
23112/***/ 1228:
23113/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
23114
23115__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
23116/* harmony export */ __webpack_require__.d(__webpack_exports__, {
23117/* harmony export */ AbortException: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AbortException),
23118/* harmony export */ AnnotationEditorLayer: () => (/* reexport safe */ _display_editor_annotation_editor_layer_js__WEBPACK_IMPORTED_MODULE_4__.AnnotationEditorLayer),
23119/* harmony export */ AnnotationEditorParamsType: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType),
23120/* harmony export */ AnnotationEditorType: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType),
23121/* harmony export */ AnnotationEditorUIManager: () => (/* reexport safe */ _display_editor_tools_js__WEBPACK_IMPORTED_MODULE_5__.AnnotationEditorUIManager),
23122/* harmony export */ AnnotationLayer: () => (/* reexport safe */ _display_annotation_layer_js__WEBPACK_IMPORTED_MODULE_6__.AnnotationLayer),
23123/* harmony export */ AnnotationMode: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode),
23124/* harmony export */ CMapCompressionType: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.CMapCompressionType),
23125/* harmony export */ ColorPicker: () => (/* reexport safe */ _display_editor_color_picker_js__WEBPACK_IMPORTED_MODULE_7__.ColorPicker),
23126/* harmony export */ DOMSVGFactory: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.DOMSVGFactory),
23127/* harmony export */ DrawLayer: () => (/* reexport safe */ _display_draw_layer_js__WEBPACK_IMPORTED_MODULE_8__.DrawLayer),
23128/* harmony export */ FeatureTest: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.FeatureTest),
23129/* harmony export */ GlobalWorkerOptions: () => (/* reexport safe */ _display_worker_options_js__WEBPACK_IMPORTED_MODULE_11__.GlobalWorkerOptions),
23130/* harmony export */ ImageKind: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.ImageKind),
23131/* harmony export */ InvalidPDFException: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.InvalidPDFException),
23132/* harmony export */ MissingPDFException: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.MissingPDFException),
23133/* harmony export */ OPS: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.OPS),
23134/* harmony export */ Outliner: () => (/* reexport safe */ _display_editor_outliner_js__WEBPACK_IMPORTED_MODULE_9__.Outliner),
23135/* harmony export */ PDFDataRangeTransport: () => (/* reexport safe */ _display_api_js__WEBPACK_IMPORTED_MODULE_1__.PDFDataRangeTransport),
23136/* harmony export */ PDFDateString: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.PDFDateString),
23137/* harmony export */ PDFWorker: () => (/* reexport safe */ _display_api_js__WEBPACK_IMPORTED_MODULE_1__.PDFWorker),
23138/* harmony export */ PasswordResponses: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PasswordResponses),
23139/* harmony export */ PermissionFlag: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag),
23140/* harmony export */ PixelsPerInch: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.PixelsPerInch),
23141/* harmony export */ RenderingCancelledException: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.RenderingCancelledException),
23142/* harmony export */ UnexpectedResponseException: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.UnexpectedResponseException),
23143/* harmony export */ Util: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.Util),
23144/* harmony export */ VerbosityLevel: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.VerbosityLevel),
23145/* harmony export */ XfaLayer: () => (/* reexport safe */ _display_xfa_layer_js__WEBPACK_IMPORTED_MODULE_10__.XfaLayer),
23146/* harmony export */ build: () => (/* reexport safe */ _display_api_js__WEBPACK_IMPORTED_MODULE_1__.build),
23147/* harmony export */ createValidAbsoluteUrl: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.createValidAbsoluteUrl),
23148/* harmony export */ fetchData: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.fetchData),
23149/* harmony export */ getDocument: () => (/* reexport safe */ _display_api_js__WEBPACK_IMPORTED_MODULE_1__.getDocument),
23150/* harmony export */ getFilenameFromUrl: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.getFilenameFromUrl),
23151/* harmony export */ getPdfFilenameFromUrl: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.getPdfFilenameFromUrl),
23152/* harmony export */ getXfaPageViewport: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.getXfaPageViewport),
23153/* harmony export */ isDataScheme: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.isDataScheme),
23154/* harmony export */ isPdfFile: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.isPdfFile),
23155/* harmony export */ noContextMenu: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.noContextMenu),
23156/* harmony export */ normalizeUnicode: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.normalizeUnicode),
23157/* harmony export */ renderTextLayer: () => (/* reexport safe */ _display_text_layer_js__WEBPACK_IMPORTED_MODULE_3__.renderTextLayer),
23158/* harmony export */ setLayerDimensions: () => (/* reexport safe */ _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.setLayerDimensions),
23159/* harmony export */ shadow: () => (/* reexport safe */ _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.shadow),
23160/* harmony export */ updateTextLayer: () => (/* reexport safe */ _display_text_layer_js__WEBPACK_IMPORTED_MODULE_3__.updateTextLayer),
23161/* harmony export */ version: () => (/* reexport safe */ _display_api_js__WEBPACK_IMPORTED_MODULE_1__.version)
23162/* harmony export */ });
23163/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4292);
23164/* harmony import */ var _display_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3831);
23165/* harmony import */ var _display_display_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5419);
23166/* harmony import */ var _display_text_layer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6814);
23167/* harmony import */ var _display_editor_annotation_editor_layer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9731);
23168/* harmony import */ var _display_editor_tools_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7830);
23169/* harmony import */ var _display_annotation_layer_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6976);
23170/* harmony import */ var _display_editor_color_picker_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2259);
23171/* harmony import */ var _display_draw_layer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4047);
23172/* harmony import */ var _display_worker_options_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(6164);
23173/* harmony import */ var _display_editor_outliner_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(4061);
23174/* harmony import */ var _display_xfa_layer_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(8284);
23175var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_display_api_js__WEBPACK_IMPORTED_MODULE_1__]);
23176_display_api_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189const pdfjsVersion = "4.1.392";
23190const pdfjsBuild = "fcb76a78d";
23191
23192__webpack_async_result__();
23193} catch(e) { __webpack_async_result__(e); } });
23194
23195/***/ }),
23196
23197/***/ 5178:
23198/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
23199
23200/* harmony export */ __webpack_require__.d(__webpack_exports__, {
23201/* harmony export */ MessageHandler: () => (/* binding */ MessageHandler)
23202/* harmony export */ });
23203/* harmony import */ var core_js_modules_es_promise_with_resolvers_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4628);
23204/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4292);
23205
23206
23207const CallbackKind = {
23208 UNKNOWN: 0,
23209 DATA: 1,
23210 ERROR: 2
23211};
23212const StreamKind = {
23213 UNKNOWN: 0,
23214 CANCEL: 1,
23215 CANCEL_COMPLETE: 2,
23216 CLOSE: 3,
23217 ENQUEUE: 4,
23218 ERROR: 5,
23219 PULL: 6,
23220 PULL_COMPLETE: 7,
23221 START_COMPLETE: 8
23222};
23223function wrapReason(reason) {
23224 if (!(reason instanceof Error || typeof reason === "object" && reason !== null)) {
23225 (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
23226 }
23227 switch (reason.name) {
23228 case "AbortException":
23229 return new _util_js__WEBPACK_IMPORTED_MODULE_1__.AbortException(reason.message);
23230 case "MissingPDFException":
23231 return new _util_js__WEBPACK_IMPORTED_MODULE_1__.MissingPDFException(reason.message);
23232 case "PasswordException":
23233 return new _util_js__WEBPACK_IMPORTED_MODULE_1__.PasswordException(reason.message, reason.code);
23234 case "UnexpectedResponseException":
23235 return new _util_js__WEBPACK_IMPORTED_MODULE_1__.UnexpectedResponseException(reason.message, reason.status);
23236 case "UnknownErrorException":
23237 return new _util_js__WEBPACK_IMPORTED_MODULE_1__.UnknownErrorException(reason.message, reason.details);
23238 default:
23239 return new _util_js__WEBPACK_IMPORTED_MODULE_1__.UnknownErrorException(reason.message, reason.toString());
23240 }
23241}
23242class MessageHandler {
23243 constructor(sourceName, targetName, comObj) {
23244 this.sourceName = sourceName;
23245 this.targetName = targetName;
23246 this.comObj = comObj;
23247 this.callbackId = 1;
23248 this.streamId = 1;
23249 this.streamSinks = Object.create(null);
23250 this.streamControllers = Object.create(null);
23251 this.callbackCapabilities = Object.create(null);
23252 this.actionHandler = Object.create(null);
23253 this._onComObjOnMessage = event => {
23254 const data = event.data;
23255 if (data.targetName !== this.sourceName) {
23256 return;
23257 }
23258 if (data.stream) {
23259 this.#processStreamMessage(data);
23260 return;
23261 }
23262 if (data.callback) {
23263 const callbackId = data.callbackId;
23264 const capability = this.callbackCapabilities[callbackId];
23265 if (!capability) {
23266 throw new Error(`Cannot resolve callback ${callbackId}`);
23267 }
23268 delete this.callbackCapabilities[callbackId];
23269 if (data.callback === CallbackKind.DATA) {
23270 capability.resolve(data.data);
23271 } else if (data.callback === CallbackKind.ERROR) {
23272 capability.reject(wrapReason(data.reason));
23273 } else {
23274 throw new Error("Unexpected callback case");
23275 }
23276 return;
23277 }
23278 const action = this.actionHandler[data.action];
23279 if (!action) {
23280 throw new Error(`Unknown action from worker: ${data.action}`);
23281 }
23282 if (data.callbackId) {
23283 const cbSourceName = this.sourceName;
23284 const cbTargetName = data.sourceName;
23285 new Promise(function (resolve) {
23286 resolve(action(data.data));
23287 }).then(function (result) {
23288 comObj.postMessage({
23289 sourceName: cbSourceName,
23290 targetName: cbTargetName,
23291 callback: CallbackKind.DATA,
23292 callbackId: data.callbackId,
23293 data: result
23294 });
23295 }, function (reason) {
23296 comObj.postMessage({
23297 sourceName: cbSourceName,
23298 targetName: cbTargetName,
23299 callback: CallbackKind.ERROR,
23300 callbackId: data.callbackId,
23301 reason: wrapReason(reason)
23302 });
23303 });
23304 return;
23305 }
23306 if (data.streamId) {
23307 this.#createStreamSink(data);
23308 return;
23309 }
23310 action(data.data);
23311 };
23312 comObj.addEventListener("message", this._onComObjOnMessage);
23313 }
23314 on(actionName, handler) {
23315 const ah = this.actionHandler;
23316 if (ah[actionName]) {
23317 throw new Error(`There is already an actionName called "${actionName}"`);
23318 }
23319 ah[actionName] = handler;
23320 }
23321 send(actionName, data, transfers) {
23322 this.comObj.postMessage({
23323 sourceName: this.sourceName,
23324 targetName: this.targetName,
23325 action: actionName,
23326 data
23327 }, transfers);
23328 }
23329 sendWithPromise(actionName, data, transfers) {
23330 const callbackId = this.callbackId++;
23331 const capability = Promise.withResolvers();
23332 this.callbackCapabilities[callbackId] = capability;
23333 try {
23334 this.comObj.postMessage({
23335 sourceName: this.sourceName,
23336 targetName: this.targetName,
23337 action: actionName,
23338 callbackId,
23339 data
23340 }, transfers);
23341 } catch (ex) {
23342 capability.reject(ex);
23343 }
23344 return capability.promise;
23345 }
23346 sendWithStream(actionName, data, queueingStrategy, transfers) {
23347 const streamId = this.streamId++,
23348 sourceName = this.sourceName,
23349 targetName = this.targetName,
23350 comObj = this.comObj;
23351 return new ReadableStream({
23352 start: controller => {
23353 const startCapability = Promise.withResolvers();
23354 this.streamControllers[streamId] = {
23355 controller,
23356 startCall: startCapability,
23357 pullCall: null,
23358 cancelCall: null,
23359 isClosed: false
23360 };
23361 comObj.postMessage({
23362 sourceName,
23363 targetName,
23364 action: actionName,
23365 streamId,
23366 data,
23367 desiredSize: controller.desiredSize
23368 }, transfers);
23369 return startCapability.promise;
23370 },
23371 pull: controller => {
23372 const pullCapability = Promise.withResolvers();
23373 this.streamControllers[streamId].pullCall = pullCapability;
23374 comObj.postMessage({
23375 sourceName,
23376 targetName,
23377 stream: StreamKind.PULL,
23378 streamId,
23379 desiredSize: controller.desiredSize
23380 });
23381 return pullCapability.promise;
23382 },
23383 cancel: reason => {
23384 (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.assert)(reason instanceof Error, "cancel must have a valid reason");
23385 const cancelCapability = Promise.withResolvers();
23386 this.streamControllers[streamId].cancelCall = cancelCapability;
23387 this.streamControllers[streamId].isClosed = true;
23388 comObj.postMessage({
23389 sourceName,
23390 targetName,
23391 stream: StreamKind.CANCEL,
23392 streamId,
23393 reason: wrapReason(reason)
23394 });
23395 return cancelCapability.promise;
23396 }
23397 }, queueingStrategy);
23398 }
23399 #createStreamSink(data) {
23400 const streamId = data.streamId,
23401 sourceName = this.sourceName,
23402 targetName = data.sourceName,
23403 comObj = this.comObj;
23404 const self = this,
23405 action = this.actionHandler[data.action];
23406 const streamSink = {
23407 enqueue(chunk) {
23408 let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
23409 let transfers = arguments.length > 2 ? arguments[2] : undefined;
23410 if (this.isCancelled) {
23411 return;
23412 }
23413 const lastDesiredSize = this.desiredSize;
23414 this.desiredSize -= size;
23415 if (lastDesiredSize > 0 && this.desiredSize <= 0) {
23416 this.sinkCapability = Promise.withResolvers();
23417 this.ready = this.sinkCapability.promise;
23418 }
23419 comObj.postMessage({
23420 sourceName,
23421 targetName,
23422 stream: StreamKind.ENQUEUE,
23423 streamId,
23424 chunk
23425 }, transfers);
23426 },
23427 close() {
23428 if (this.isCancelled) {
23429 return;
23430 }
23431 this.isCancelled = true;
23432 comObj.postMessage({
23433 sourceName,
23434 targetName,
23435 stream: StreamKind.CLOSE,
23436 streamId
23437 });
23438 delete self.streamSinks[streamId];
23439 },
23440 error(reason) {
23441 (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.assert)(reason instanceof Error, "error must have a valid reason");
23442 if (this.isCancelled) {
23443 return;
23444 }
23445 this.isCancelled = true;
23446 comObj.postMessage({
23447 sourceName,
23448 targetName,
23449 stream: StreamKind.ERROR,
23450 streamId,
23451 reason: wrapReason(reason)
23452 });
23453 },
23454 sinkCapability: Promise.withResolvers(),
23455 onPull: null,
23456 onCancel: null,
23457 isCancelled: false,
23458 desiredSize: data.desiredSize,
23459 ready: null
23460 };
23461 streamSink.sinkCapability.resolve();
23462 streamSink.ready = streamSink.sinkCapability.promise;
23463 this.streamSinks[streamId] = streamSink;
23464 new Promise(function (resolve) {
23465 resolve(action(data.data, streamSink));
23466 }).then(function () {
23467 comObj.postMessage({
23468 sourceName,
23469 targetName,
23470 stream: StreamKind.START_COMPLETE,
23471 streamId,
23472 success: true
23473 });
23474 }, function (reason) {
23475 comObj.postMessage({
23476 sourceName,
23477 targetName,
23478 stream: StreamKind.START_COMPLETE,
23479 streamId,
23480 reason: wrapReason(reason)
23481 });
23482 });
23483 }
23484 #processStreamMessage(data) {
23485 const streamId = data.streamId,
23486 sourceName = this.sourceName,
23487 targetName = data.sourceName,
23488 comObj = this.comObj;
23489 const streamController = this.streamControllers[streamId],
23490 streamSink = this.streamSinks[streamId];
23491 switch (data.stream) {
23492 case StreamKind.START_COMPLETE:
23493 if (data.success) {
23494 streamController.startCall.resolve();
23495 } else {
23496 streamController.startCall.reject(wrapReason(data.reason));
23497 }
23498 break;
23499 case StreamKind.PULL_COMPLETE:
23500 if (data.success) {
23501 streamController.pullCall.resolve();
23502 } else {
23503 streamController.pullCall.reject(wrapReason(data.reason));
23504 }
23505 break;
23506 case StreamKind.PULL:
23507 if (!streamSink) {
23508 comObj.postMessage({
23509 sourceName,
23510 targetName,
23511 stream: StreamKind.PULL_COMPLETE,
23512 streamId,
23513 success: true
23514 });
23515 break;
23516 }
23517 if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
23518 streamSink.sinkCapability.resolve();
23519 }
23520 streamSink.desiredSize = data.desiredSize;
23521 new Promise(function (resolve) {
23522 resolve(streamSink.onPull?.());
23523 }).then(function () {
23524 comObj.postMessage({
23525 sourceName,
23526 targetName,
23527 stream: StreamKind.PULL_COMPLETE,
23528 streamId,
23529 success: true
23530 });
23531 }, function (reason) {
23532 comObj.postMessage({
23533 sourceName,
23534 targetName,
23535 stream: StreamKind.PULL_COMPLETE,
23536 streamId,
23537 reason: wrapReason(reason)
23538 });
23539 });
23540 break;
23541 case StreamKind.ENQUEUE:
23542 (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.assert)(streamController, "enqueue should have stream controller");
23543 if (streamController.isClosed) {
23544 break;
23545 }
23546 streamController.controller.enqueue(data.chunk);
23547 break;
23548 case StreamKind.CLOSE:
23549 (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.assert)(streamController, "close should have stream controller");
23550 if (streamController.isClosed) {
23551 break;
23552 }
23553 streamController.isClosed = true;
23554 streamController.controller.close();
23555 this.#deleteStreamController(streamController, streamId);
23556 break;
23557 case StreamKind.ERROR:
23558 (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.assert)(streamController, "error should have stream controller");
23559 streamController.controller.error(wrapReason(data.reason));
23560 this.#deleteStreamController(streamController, streamId);
23561 break;
23562 case StreamKind.CANCEL_COMPLETE:
23563 if (data.success) {
23564 streamController.cancelCall.resolve();
23565 } else {
23566 streamController.cancelCall.reject(wrapReason(data.reason));
23567 }
23568 this.#deleteStreamController(streamController, streamId);
23569 break;
23570 case StreamKind.CANCEL:
23571 if (!streamSink) {
23572 break;
23573 }
23574 new Promise(function (resolve) {
23575 resolve(streamSink.onCancel?.(wrapReason(data.reason)));
23576 }).then(function () {
23577 comObj.postMessage({
23578 sourceName,
23579 targetName,
23580 stream: StreamKind.CANCEL_COMPLETE,
23581 streamId,
23582 success: true
23583 });
23584 }, function (reason) {
23585 comObj.postMessage({
23586 sourceName,
23587 targetName,
23588 stream: StreamKind.CANCEL_COMPLETE,
23589 streamId,
23590 reason: wrapReason(reason)
23591 });
23592 });
23593 streamSink.sinkCapability.reject(wrapReason(data.reason));
23594 streamSink.isCancelled = true;
23595 delete this.streamSinks[streamId];
23596 break;
23597 default:
23598 throw new Error("Unexpected stream case");
23599 }
23600 }
23601 async #deleteStreamController(streamController, streamId) {
23602 await Promise.allSettled([streamController.startCall?.promise, streamController.pullCall?.promise, streamController.cancelCall?.promise]);
23603 delete this.streamControllers[streamId];
23604 }
23605 destroy() {
23606 this.comObj.removeEventListener("message", this._onComObjOnMessage);
23607 }
23608}
23609
23610
23611/***/ }),
23612
23613/***/ 7651:
23614/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
23615
23616/* harmony export */ __webpack_require__.d(__webpack_exports__, {
23617/* harmony export */ MurmurHash3_64: () => (/* binding */ MurmurHash3_64)
23618/* harmony export */ });
23619/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6573);
23620/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8100);
23621/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7936);
23622/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7467);
23623/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4732);
23624/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9577);
23625
23626
23627
23628
23629
23630
23631const SEED = 0xc3d2e1f0;
23632const MASK_HIGH = 0xffff0000;
23633const MASK_LOW = 0xffff;
23634class MurmurHash3_64 {
23635 constructor(seed) {
23636 this.h1 = seed ? seed & 0xffffffff : SEED;
23637 this.h2 = seed ? seed & 0xffffffff : SEED;
23638 }
23639 update(input) {
23640 let data, length;
23641 if (typeof input === "string") {
23642 data = new Uint8Array(input.length * 2);
23643 length = 0;
23644 for (let i = 0, ii = input.length; i < ii; i++) {
23645 const code = input.charCodeAt(i);
23646 if (code <= 0xff) {
23647 data[length++] = code;
23648 } else {
23649 data[length++] = code >>> 8;
23650 data[length++] = code & 0xff;
23651 }
23652 }
23653 } else if (ArrayBuffer.isView(input)) {
23654 data = input.slice();
23655 length = data.byteLength;
23656 } else {
23657 throw new Error("Invalid data format, must be a string or TypedArray.");
23658 }
23659 const blockCounts = length >> 2;
23660 const tailLength = length - blockCounts * 4;
23661 const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
23662 let k1 = 0,
23663 k2 = 0;
23664 let h1 = this.h1,
23665 h2 = this.h2;
23666 const C1 = 0xcc9e2d51,
23667 C2 = 0x1b873593;
23668 const C1_LOW = C1 & MASK_LOW,
23669 C2_LOW = C2 & MASK_LOW;
23670 for (let i = 0; i < blockCounts; i++) {
23671 if (i & 1) {
23672 k1 = dataUint32[i];
23673 k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
23674 k1 = k1 << 15 | k1 >>> 17;
23675 k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
23676 h1 ^= k1;
23677 h1 = h1 << 13 | h1 >>> 19;
23678 h1 = h1 * 5 + 0xe6546b64;
23679 } else {
23680 k2 = dataUint32[i];
23681 k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
23682 k2 = k2 << 15 | k2 >>> 17;
23683 k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
23684 h2 ^= k2;
23685 h2 = h2 << 13 | h2 >>> 19;
23686 h2 = h2 * 5 + 0xe6546b64;
23687 }
23688 }
23689 k1 = 0;
23690 switch (tailLength) {
23691 case 3:
23692 k1 ^= data[blockCounts * 4 + 2] << 16;
23693 case 2:
23694 k1 ^= data[blockCounts * 4 + 1] << 8;
23695 case 1:
23696 k1 ^= data[blockCounts * 4];
23697 k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
23698 k1 = k1 << 15 | k1 >>> 17;
23699 k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
23700 if (blockCounts & 1) {
23701 h1 ^= k1;
23702 } else {
23703 h2 ^= k1;
23704 }
23705 }
23706 this.h1 = h1;
23707 this.h2 = h2;
23708 }
23709 hexdigest() {
23710 let h1 = this.h1,
23711 h2 = this.h2;
23712 h1 ^= h2 >>> 1;
23713 h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
23714 h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
23715 h1 ^= h2 >>> 1;
23716 h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
23717 h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
23718 h1 ^= h2 >>> 1;
23719 return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
23720 }
23721}
23722
23723
23724/***/ }),
23725
23726/***/ 4292:
23727/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
23728
23729/* harmony export */ __webpack_require__.d(__webpack_exports__, {
23730/* harmony export */ AbortException: () => (/* binding */ AbortException),
23731/* harmony export */ AnnotationBorderStyleType: () => (/* binding */ AnnotationBorderStyleType),
23732/* harmony export */ AnnotationEditorParamsType: () => (/* binding */ AnnotationEditorParamsType),
23733/* harmony export */ AnnotationEditorPrefix: () => (/* binding */ AnnotationEditorPrefix),
23734/* harmony export */ AnnotationEditorType: () => (/* binding */ AnnotationEditorType),
23735/* harmony export */ AnnotationMode: () => (/* binding */ AnnotationMode),
23736/* harmony export */ AnnotationPrefix: () => (/* binding */ AnnotationPrefix),
23737/* harmony export */ AnnotationType: () => (/* binding */ AnnotationType),
23738/* harmony export */ BaseException: () => (/* binding */ BaseException),
23739/* harmony export */ CMapCompressionType: () => (/* binding */ CMapCompressionType),
23740/* harmony export */ FONT_IDENTITY_MATRIX: () => (/* binding */ FONT_IDENTITY_MATRIX),
23741/* harmony export */ FeatureTest: () => (/* binding */ FeatureTest),
23742/* harmony export */ FormatError: () => (/* binding */ FormatError),
23743/* harmony export */ IDENTITY_MATRIX: () => (/* binding */ IDENTITY_MATRIX),
23744/* harmony export */ ImageKind: () => (/* binding */ ImageKind),
23745/* harmony export */ InvalidPDFException: () => (/* binding */ InvalidPDFException),
23746/* harmony export */ LINE_FACTOR: () => (/* binding */ LINE_FACTOR),
23747/* harmony export */ MAX_IMAGE_SIZE_TO_CACHE: () => (/* binding */ MAX_IMAGE_SIZE_TO_CACHE),
23748/* harmony export */ MissingPDFException: () => (/* binding */ MissingPDFException),
23749/* harmony export */ OPS: () => (/* binding */ OPS),
23750/* harmony export */ PasswordException: () => (/* binding */ PasswordException),
23751/* harmony export */ PasswordResponses: () => (/* binding */ PasswordResponses),
23752/* harmony export */ PermissionFlag: () => (/* binding */ PermissionFlag),
23753/* harmony export */ RenderingIntentFlag: () => (/* binding */ RenderingIntentFlag),
23754/* harmony export */ TextRenderingMode: () => (/* binding */ TextRenderingMode),
23755/* harmony export */ UnexpectedResponseException: () => (/* binding */ UnexpectedResponseException),
23756/* harmony export */ UnknownErrorException: () => (/* binding */ UnknownErrorException),
23757/* harmony export */ Util: () => (/* binding */ Util),
23758/* harmony export */ VerbosityLevel: () => (/* binding */ VerbosityLevel),
23759/* harmony export */ assert: () => (/* binding */ assert),
23760/* harmony export */ bytesToString: () => (/* binding */ bytesToString),
23761/* harmony export */ createValidAbsoluteUrl: () => (/* binding */ createValidAbsoluteUrl),
23762/* harmony export */ getUuid: () => (/* binding */ getUuid),
23763/* harmony export */ getVerbosityLevel: () => (/* binding */ getVerbosityLevel),
23764/* harmony export */ info: () => (/* binding */ info),
23765/* harmony export */ isNodeJS: () => (/* binding */ isNodeJS),
23766/* harmony export */ normalizeUnicode: () => (/* binding */ normalizeUnicode),
23767/* harmony export */ objectFromMap: () => (/* binding */ objectFromMap),
23768/* harmony export */ setVerbosityLevel: () => (/* binding */ setVerbosityLevel),
23769/* harmony export */ shadow: () => (/* binding */ shadow),
23770/* harmony export */ string32: () => (/* binding */ string32),
23771/* harmony export */ stringToBytes: () => (/* binding */ stringToBytes),
23772/* harmony export */ unreachable: () => (/* binding */ unreachable),
23773/* harmony export */ warn: () => (/* binding */ warn)
23774/* harmony export */ });
23775/* unused harmony exports AnnotationActionEventType, AnnotationFieldFlag, AnnotationFlag, AnnotationReplyType, BASELINE_FACTOR, DocumentActionEventType, getModificationDate, isArrayEqual, LINE_DESCENT_FACTOR, objectSize, PageActionEventType, stringToPDFString, stringToUTF8String, utf8StringToString */
23776/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4114);
23777/* harmony import */ var core_js_modules_es_array_buffer_detached_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6573);
23778/* harmony import */ var core_js_modules_es_array_buffer_transfer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8100);
23779/* harmony import */ var core_js_modules_es_array_buffer_transfer_to_fixed_length_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7936);
23780/* harmony import */ var core_js_modules_es_typed_array_to_reversed_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7467);
23781/* harmony import */ var core_js_modules_es_typed_array_to_sorted_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4732);
23782/* harmony import */ var core_js_modules_es_typed_array_with_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9577);
23783/* harmony import */ var core_js_modules_web_url_search_params_delete_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4603);
23784/* harmony import */ var core_js_modules_web_url_search_params_has_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(7566);
23785/* harmony import */ var core_js_modules_web_url_search_params_size_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(8721);
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
23797const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
23798const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
23799const MAX_IMAGE_SIZE_TO_CACHE = 10e6;
23800const LINE_FACTOR = 1.35;
23801const LINE_DESCENT_FACTOR = 0.35;
23802const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
23803const RenderingIntentFlag = {
23804 ANY: 0x01,
23805 DISPLAY: 0x02,
23806 PRINT: 0x04,
23807 SAVE: 0x08,
23808 ANNOTATIONS_FORMS: 0x10,
23809 ANNOTATIONS_STORAGE: 0x20,
23810 ANNOTATIONS_DISABLE: 0x40,
23811 OPLIST: 0x100
23812};
23813const AnnotationMode = {
23814 DISABLE: 0,
23815 ENABLE: 1,
23816 ENABLE_FORMS: 2,
23817 ENABLE_STORAGE: 3
23818};
23819const AnnotationEditorPrefix = "pdfjs_internal_editor_";
23820const AnnotationEditorType = {
23821 DISABLE: -1,
23822 NONE: 0,
23823 FREETEXT: 3,
23824 HIGHLIGHT: 9,
23825 STAMP: 13,
23826 INK: 15
23827};
23828const AnnotationEditorParamsType = {
23829 RESIZE: 1,
23830 CREATE: 2,
23831 FREETEXT_SIZE: 11,
23832 FREETEXT_COLOR: 12,
23833 FREETEXT_OPACITY: 13,
23834 INK_COLOR: 21,
23835 INK_THICKNESS: 22,
23836 INK_OPACITY: 23,
23837 HIGHLIGHT_COLOR: 31,
23838 HIGHLIGHT_DEFAULT_COLOR: 32,
23839 HIGHLIGHT_THICKNESS: 33,
23840 HIGHLIGHT_FREE: 34,
23841 HIGHLIGHT_SHOW_ALL: 35
23842};
23843const PermissionFlag = {
23844 PRINT: 0x04,
23845 MODIFY_CONTENTS: 0x08,
23846 COPY: 0x10,
23847 MODIFY_ANNOTATIONS: 0x20,
23848 FILL_INTERACTIVE_FORMS: 0x100,
23849 COPY_FOR_ACCESSIBILITY: 0x200,
23850 ASSEMBLE: 0x400,
23851 PRINT_HIGH_QUALITY: 0x800
23852};
23853const TextRenderingMode = {
23854 FILL: 0,
23855 STROKE: 1,
23856 FILL_STROKE: 2,
23857 INVISIBLE: 3,
23858 FILL_ADD_TO_PATH: 4,
23859 STROKE_ADD_TO_PATH: 5,
23860 FILL_STROKE_ADD_TO_PATH: 6,
23861 ADD_TO_PATH: 7,
23862 FILL_STROKE_MASK: 3,
23863 ADD_TO_PATH_FLAG: 4
23864};
23865const ImageKind = {
23866 GRAYSCALE_1BPP: 1,
23867 RGB_24BPP: 2,
23868 RGBA_32BPP: 3
23869};
23870const AnnotationType = {
23871 TEXT: 1,
23872 LINK: 2,
23873 FREETEXT: 3,
23874 LINE: 4,
23875 SQUARE: 5,
23876 CIRCLE: 6,
23877 POLYGON: 7,
23878 POLYLINE: 8,
23879 HIGHLIGHT: 9,
23880 UNDERLINE: 10,
23881 SQUIGGLY: 11,
23882 STRIKEOUT: 12,
23883 STAMP: 13,
23884 CARET: 14,
23885 INK: 15,
23886 POPUP: 16,
23887 FILEATTACHMENT: 17,
23888 SOUND: 18,
23889 MOVIE: 19,
23890 WIDGET: 20,
23891 SCREEN: 21,
23892 PRINTERMARK: 22,
23893 TRAPNET: 23,
23894 WATERMARK: 24,
23895 THREED: 25,
23896 REDACT: 26
23897};
23898const AnnotationReplyType = {
23899 GROUP: "Group",
23900 REPLY: "R"
23901};
23902const AnnotationFlag = {
23903 INVISIBLE: 0x01,
23904 HIDDEN: 0x02,
23905 PRINT: 0x04,
23906 NOZOOM: 0x08,
23907 NOROTATE: 0x10,
23908 NOVIEW: 0x20,
23909 READONLY: 0x40,
23910 LOCKED: 0x80,
23911 TOGGLENOVIEW: 0x100,
23912 LOCKEDCONTENTS: 0x200
23913};
23914const AnnotationFieldFlag = {
23915 READONLY: 0x0000001,
23916 REQUIRED: 0x0000002,
23917 NOEXPORT: 0x0000004,
23918 MULTILINE: 0x0001000,
23919 PASSWORD: 0x0002000,
23920 NOTOGGLETOOFF: 0x0004000,
23921 RADIO: 0x0008000,
23922 PUSHBUTTON: 0x0010000,
23923 COMBO: 0x0020000,
23924 EDIT: 0x0040000,
23925 SORT: 0x0080000,
23926 FILESELECT: 0x0100000,
23927 MULTISELECT: 0x0200000,
23928 DONOTSPELLCHECK: 0x0400000,
23929 DONOTSCROLL: 0x0800000,
23930 COMB: 0x1000000,
23931 RICHTEXT: 0x2000000,
23932 RADIOSINUNISON: 0x2000000,
23933 COMMITONSELCHANGE: 0x4000000
23934};
23935const AnnotationBorderStyleType = {
23936 SOLID: 1,
23937 DASHED: 2,
23938 BEVELED: 3,
23939 INSET: 4,
23940 UNDERLINE: 5
23941};
23942const AnnotationActionEventType = {
23943 E: "Mouse Enter",
23944 X: "Mouse Exit",
23945 D: "Mouse Down",
23946 U: "Mouse Up",
23947 Fo: "Focus",
23948 Bl: "Blur",
23949 PO: "PageOpen",
23950 PC: "PageClose",
23951 PV: "PageVisible",
23952 PI: "PageInvisible",
23953 K: "Keystroke",
23954 F: "Format",
23955 V: "Validate",
23956 C: "Calculate"
23957};
23958const DocumentActionEventType = {
23959 WC: "WillClose",
23960 WS: "WillSave",
23961 DS: "DidSave",
23962 WP: "WillPrint",
23963 DP: "DidPrint"
23964};
23965const PageActionEventType = {
23966 O: "PageOpen",
23967 C: "PageClose"
23968};
23969const VerbosityLevel = {
23970 ERRORS: 0,
23971 WARNINGS: 1,
23972 INFOS: 5
23973};
23974const CMapCompressionType = {
23975 NONE: 0,
23976 BINARY: 1
23977};
23978const OPS = {
23979 dependency: 1,
23980 setLineWidth: 2,
23981 setLineCap: 3,
23982 setLineJoin: 4,
23983 setMiterLimit: 5,
23984 setDash: 6,
23985 setRenderingIntent: 7,
23986 setFlatness: 8,
23987 setGState: 9,
23988 save: 10,
23989 restore: 11,
23990 transform: 12,
23991 moveTo: 13,
23992 lineTo: 14,
23993 curveTo: 15,
23994 curveTo2: 16,
23995 curveTo3: 17,
23996 closePath: 18,
23997 rectangle: 19,
23998 stroke: 20,
23999 closeStroke: 21,
24000 fill: 22,
24001 eoFill: 23,
24002 fillStroke: 24,
24003 eoFillStroke: 25,
24004 closeFillStroke: 26,
24005 closeEOFillStroke: 27,
24006 endPath: 28,
24007 clip: 29,
24008 eoClip: 30,
24009 beginText: 31,
24010 endText: 32,
24011 setCharSpacing: 33,
24012 setWordSpacing: 34,
24013 setHScale: 35,
24014 setLeading: 36,
24015 setFont: 37,
24016 setTextRenderingMode: 38,
24017 setTextRise: 39,
24018 moveText: 40,
24019 setLeadingMoveText: 41,
24020 setTextMatrix: 42,
24021 nextLine: 43,
24022 showText: 44,
24023 showSpacedText: 45,
24024 nextLineShowText: 46,
24025 nextLineSetSpacingShowText: 47,
24026 setCharWidth: 48,
24027 setCharWidthAndBounds: 49,
24028 setStrokeColorSpace: 50,
24029 setFillColorSpace: 51,
24030 setStrokeColor: 52,
24031 setStrokeColorN: 53,
24032 setFillColor: 54,
24033 setFillColorN: 55,
24034 setStrokeGray: 56,
24035 setFillGray: 57,
24036 setStrokeRGBColor: 58,
24037 setFillRGBColor: 59,
24038 setStrokeCMYKColor: 60,
24039 setFillCMYKColor: 61,
24040 shadingFill: 62,
24041 beginInlineImage: 63,
24042 beginImageData: 64,
24043 endInlineImage: 65,
24044 paintXObject: 66,
24045 markPoint: 67,
24046 markPointProps: 68,
24047 beginMarkedContent: 69,
24048 beginMarkedContentProps: 70,
24049 endMarkedContent: 71,
24050 beginCompat: 72,
24051 endCompat: 73,
24052 paintFormXObjectBegin: 74,
24053 paintFormXObjectEnd: 75,
24054 beginGroup: 76,
24055 endGroup: 77,
24056 beginAnnotation: 80,
24057 endAnnotation: 81,
24058 paintImageMaskXObject: 83,
24059 paintImageMaskXObjectGroup: 84,
24060 paintImageXObject: 85,
24061 paintInlineImageXObject: 86,
24062 paintInlineImageXObjectGroup: 87,
24063 paintImageXObjectRepeat: 88,
24064 paintImageMaskXObjectRepeat: 89,
24065 paintSolidColorImageMask: 90,
24066 constructPath: 91
24067};
24068const PasswordResponses = {
24069 NEED_PASSWORD: 1,
24070 INCORRECT_PASSWORD: 2
24071};
24072let verbosity = VerbosityLevel.WARNINGS;
24073function setVerbosityLevel(level) {
24074 if (Number.isInteger(level)) {
24075 verbosity = level;
24076 }
24077}
24078function getVerbosityLevel() {
24079 return verbosity;
24080}
24081function info(msg) {
24082 if (verbosity >= VerbosityLevel.INFOS) {
24083 console.log(`Info: ${msg}`);
24084 }
24085}
24086function warn(msg) {
24087 if (verbosity >= VerbosityLevel.WARNINGS) {
24088 console.log(`Warning: ${msg}`);
24089 }
24090}
24091function unreachable(msg) {
24092 throw new Error(msg);
24093}
24094function assert(cond, msg) {
24095 if (!cond) {
24096 unreachable(msg);
24097 }
24098}
24099function _isValidProtocol(url) {
24100 switch (url?.protocol) {
24101 case "http:":
24102 case "https:":
24103 case "ftp:":
24104 case "mailto:":
24105 case "tel:":
24106 return true;
24107 default:
24108 return false;
24109 }
24110}
24111function createValidAbsoluteUrl(url) {
24112 let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
24113 let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
24114 if (!url) {
24115 return null;
24116 }
24117 try {
24118 if (options && typeof url === "string") {
24119 if (options.addDefaultProtocol && url.startsWith("www.")) {
24120 const dots = url.match(/\./g);
24121 if (dots?.length >= 2) {
24122 url = `http://${url}`;
24123 }
24124 }
24125 if (options.tryConvertEncoding) {
24126 try {
24127 url = stringToUTF8String(url);
24128 } catch {}
24129 }
24130 }
24131 const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
24132 if (_isValidProtocol(absoluteUrl)) {
24133 return absoluteUrl;
24134 }
24135 } catch {}
24136 return null;
24137}
24138function shadow(obj, prop, value) {
24139 let nonSerializable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
24140 Object.defineProperty(obj, prop, {
24141 value,
24142 enumerable: !nonSerializable,
24143 configurable: true,
24144 writable: false
24145 });
24146 return value;
24147}
24148const BaseException = function BaseExceptionClosure() {
24149 function BaseException(message, name) {
24150 if (this.constructor === BaseException) {
24151 unreachable("Cannot initialize BaseException.");
24152 }
24153 this.message = message;
24154 this.name = name;
24155 }
24156 BaseException.prototype = new Error();
24157 BaseException.constructor = BaseException;
24158 return BaseException;
24159}();
24160class PasswordException extends BaseException {
24161 constructor(msg, code) {
24162 super(msg, "PasswordException");
24163 this.code = code;
24164 }
24165}
24166class UnknownErrorException extends BaseException {
24167 constructor(msg, details) {
24168 super(msg, "UnknownErrorException");
24169 this.details = details;
24170 }
24171}
24172class InvalidPDFException extends BaseException {
24173 constructor(msg) {
24174 super(msg, "InvalidPDFException");
24175 }
24176}
24177class MissingPDFException extends BaseException {
24178 constructor(msg) {
24179 super(msg, "MissingPDFException");
24180 }
24181}
24182class UnexpectedResponseException extends BaseException {
24183 constructor(msg, status) {
24184 super(msg, "UnexpectedResponseException");
24185 this.status = status;
24186 }
24187}
24188class FormatError extends BaseException {
24189 constructor(msg) {
24190 super(msg, "FormatError");
24191 }
24192}
24193class AbortException extends BaseException {
24194 constructor(msg) {
24195 super(msg, "AbortException");
24196 }
24197}
24198function bytesToString(bytes) {
24199 if (typeof bytes !== "object" || bytes?.length === undefined) {
24200 unreachable("Invalid argument for bytesToString");
24201 }
24202 const length = bytes.length;
24203 const MAX_ARGUMENT_COUNT = 8192;
24204 if (length < MAX_ARGUMENT_COUNT) {
24205 return String.fromCharCode.apply(null, bytes);
24206 }
24207 const strBuf = [];
24208 for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
24209 const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
24210 const chunk = bytes.subarray(i, chunkEnd);
24211 strBuf.push(String.fromCharCode.apply(null, chunk));
24212 }
24213 return strBuf.join("");
24214}
24215function stringToBytes(str) {
24216 if (typeof str !== "string") {
24217 unreachable("Invalid argument for stringToBytes");
24218 }
24219 const length = str.length;
24220 const bytes = new Uint8Array(length);
24221 for (let i = 0; i < length; ++i) {
24222 bytes[i] = str.charCodeAt(i) & 0xff;
24223 }
24224 return bytes;
24225}
24226function string32(value) {
24227 return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
24228}
24229function objectSize(obj) {
24230 return Object.keys(obj).length;
24231}
24232function objectFromMap(map) {
24233 const obj = Object.create(null);
24234 for (const [key, value] of map) {
24235 obj[key] = value;
24236 }
24237 return obj;
24238}
24239function isLittleEndian() {
24240 const buffer8 = new Uint8Array(4);
24241 buffer8[0] = 1;
24242 const view32 = new Uint32Array(buffer8.buffer, 0, 1);
24243 return view32[0] === 1;
24244}
24245function isEvalSupported() {
24246 try {
24247 new Function("");
24248 return true;
24249 } catch {
24250 return false;
24251 }
24252}
24253class FeatureTest {
24254 static get isLittleEndian() {
24255 return shadow(this, "isLittleEndian", isLittleEndian());
24256 }
24257 static get isEvalSupported() {
24258 return shadow(this, "isEvalSupported", isEvalSupported());
24259 }
24260 static get isOffscreenCanvasSupported() {
24261 return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
24262 }
24263 static get platform() {
24264 if (typeof navigator !== "undefined" && typeof navigator?.platform === "string") {
24265 return shadow(this, "platform", {
24266 isMac: navigator.platform.includes("Mac")
24267 });
24268 }
24269 return shadow(this, "platform", {
24270 isMac: false
24271 });
24272 }
24273 static get isCSSRoundSupported() {
24274 return shadow(this, "isCSSRoundSupported", globalThis.CSS?.supports?.("width: round(1.5px, 1px)"));
24275 }
24276}
24277const hexNumbers = Array.from(Array(256).keys(), n => n.toString(16).padStart(2, "0"));
24278class Util {
24279 static makeHexColor(r, g, b) {
24280 return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
24281 }
24282 static scaleMinMax(transform, minMax) {
24283 let temp;
24284 if (transform[0]) {
24285 if (transform[0] < 0) {
24286 temp = minMax[0];
24287 minMax[0] = minMax[2];
24288 minMax[2] = temp;
24289 }
24290 minMax[0] *= transform[0];
24291 minMax[2] *= transform[0];
24292 if (transform[3] < 0) {
24293 temp = minMax[1];
24294 minMax[1] = minMax[3];
24295 minMax[3] = temp;
24296 }
24297 minMax[1] *= transform[3];
24298 minMax[3] *= transform[3];
24299 } else {
24300 temp = minMax[0];
24301 minMax[0] = minMax[1];
24302 minMax[1] = temp;
24303 temp = minMax[2];
24304 minMax[2] = minMax[3];
24305 minMax[3] = temp;
24306 if (transform[1] < 0) {
24307 temp = minMax[1];
24308 minMax[1] = minMax[3];
24309 minMax[3] = temp;
24310 }
24311 minMax[1] *= transform[1];
24312 minMax[3] *= transform[1];
24313 if (transform[2] < 0) {
24314 temp = minMax[0];
24315 minMax[0] = minMax[2];
24316 minMax[2] = temp;
24317 }
24318 minMax[0] *= transform[2];
24319 minMax[2] *= transform[2];
24320 }
24321 minMax[0] += transform[4];
24322 minMax[1] += transform[5];
24323 minMax[2] += transform[4];
24324 minMax[3] += transform[5];
24325 }
24326 static transform(m1, m2) {
24327 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]];
24328 }
24329 static applyTransform(p, m) {
24330 const xt = p[0] * m[0] + p[1] * m[2] + m[4];
24331 const yt = p[0] * m[1] + p[1] * m[3] + m[5];
24332 return [xt, yt];
24333 }
24334 static applyInverseTransform(p, m) {
24335 const d = m[0] * m[3] - m[1] * m[2];
24336 const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
24337 const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
24338 return [xt, yt];
24339 }
24340 static getAxialAlignedBoundingBox(r, m) {
24341 const p1 = this.applyTransform(r, m);
24342 const p2 = this.applyTransform(r.slice(2, 4), m);
24343 const p3 = this.applyTransform([r[0], r[3]], m);
24344 const p4 = this.applyTransform([r[2], r[1]], m);
24345 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])];
24346 }
24347 static inverseTransform(m) {
24348 const d = m[0] * m[3] - m[1] * m[2];
24349 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];
24350 }
24351 static singularValueDecompose2dScale(m) {
24352 const transpose = [m[0], m[2], m[1], m[3]];
24353 const a = m[0] * transpose[0] + m[1] * transpose[2];
24354 const b = m[0] * transpose[1] + m[1] * transpose[3];
24355 const c = m[2] * transpose[0] + m[3] * transpose[2];
24356 const d = m[2] * transpose[1] + m[3] * transpose[3];
24357 const first = (a + d) / 2;
24358 const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
24359 const sx = first + second || 1;
24360 const sy = first - second || 1;
24361 return [Math.sqrt(sx), Math.sqrt(sy)];
24362 }
24363 static normalizeRect(rect) {
24364 const r = rect.slice(0);
24365 if (rect[0] > rect[2]) {
24366 r[0] = rect[2];
24367 r[2] = rect[0];
24368 }
24369 if (rect[1] > rect[3]) {
24370 r[1] = rect[3];
24371 r[3] = rect[1];
24372 }
24373 return r;
24374 }
24375 static intersect(rect1, rect2) {
24376 const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
24377 const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
24378 if (xLow > xHigh) {
24379 return null;
24380 }
24381 const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
24382 const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
24383 if (yLow > yHigh) {
24384 return null;
24385 }
24386 return [xLow, yLow, xHigh, yHigh];
24387 }
24388 static #getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {
24389 if (t <= 0 || t >= 1) {
24390 return;
24391 }
24392 const mt = 1 - t;
24393 const tt = t * t;
24394 const ttt = tt * t;
24395 const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;
24396 const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;
24397 minMax[0] = Math.min(minMax[0], x);
24398 minMax[1] = Math.min(minMax[1], y);
24399 minMax[2] = Math.max(minMax[2], x);
24400 minMax[3] = Math.max(minMax[3], y);
24401 }
24402 static #getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
24403 if (Math.abs(a) < 1e-12) {
24404 if (Math.abs(b) >= 1e-12) {
24405 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, -c / b, minMax);
24406 }
24407 return;
24408 }
24409 const delta = b ** 2 - 4 * c * a;
24410 if (delta < 0) {
24411 return;
24412 }
24413 const sqrtDelta = Math.sqrt(delta);
24414 const a2 = 2 * a;
24415 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
24416 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
24417 }
24418 static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
24419 if (minMax) {
24420 minMax[0] = Math.min(minMax[0], x0, x3);
24421 minMax[1] = Math.min(minMax[1], y0, y3);
24422 minMax[2] = Math.max(minMax[2], x0, x3);
24423 minMax[3] = Math.max(minMax[3], y0, y3);
24424 } else {
24425 minMax = [Math.min(x0, x3), Math.min(y0, y3), Math.max(x0, x3), Math.max(y0, y3)];
24426 }
24427 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);
24428 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);
24429 return minMax;
24430 }
24431}
24432const 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]));
24433function stringToPDFString(str) {
24434 if (str[0] >= "\xEF") {
24435 let encoding;
24436 if (str[0] === "\xFE" && str[1] === "\xFF") {
24437 encoding = "utf-16be";
24438 if (str.length % 2 === 1) {
24439 str = str.slice(0, -1);
24440 }
24441 } else if (str[0] === "\xFF" && str[1] === "\xFE") {
24442 encoding = "utf-16le";
24443 if (str.length % 2 === 1) {
24444 str = str.slice(0, -1);
24445 }
24446 } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
24447 encoding = "utf-8";
24448 }
24449 if (encoding) {
24450 try {
24451 const decoder = new TextDecoder(encoding, {
24452 fatal: true
24453 });
24454 const buffer = stringToBytes(str);
24455 const decoded = decoder.decode(buffer);
24456 if (!decoded.includes("\x1b")) {
24457 return decoded;
24458 }
24459 return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
24460 } catch (ex) {
24461 warn(`stringToPDFString: "${ex}".`);
24462 }
24463 }
24464 }
24465 const strBuf = [];
24466 for (let i = 0, ii = str.length; i < ii; i++) {
24467 const charCode = str.charCodeAt(i);
24468 if (charCode === 0x1b) {
24469 while (++i < ii && str.charCodeAt(i) !== 0x1b) {}
24470 continue;
24471 }
24472 const code = PDFStringTranslateTable[charCode];
24473 strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
24474 }
24475 return strBuf.join("");
24476}
24477function stringToUTF8String(str) {
24478 return decodeURIComponent(escape(str));
24479}
24480function utf8StringToString(str) {
24481 return unescape(encodeURIComponent(str));
24482}
24483function isArrayEqual(arr1, arr2) {
24484 if (arr1.length !== arr2.length) {
24485 return false;
24486 }
24487 for (let i = 0, ii = arr1.length; i < ii; i++) {
24488 if (arr1[i] !== arr2[i]) {
24489 return false;
24490 }
24491 }
24492 return true;
24493}
24494function getModificationDate() {
24495 let date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
24496 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")];
24497 return buffer.join("");
24498}
24499let NormalizeRegex = null;
24500let NormalizationMap = null;
24501function normalizeUnicode(str) {
24502 if (!NormalizeRegex) {
24503 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;
24504 NormalizationMap = new Map([["ſt", "ſt"]]);
24505 }
24506 return str.replaceAll(NormalizeRegex, (_, p1, p2) => p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2));
24507}
24508function getUuid() {
24509 if (typeof crypto !== "undefined" && typeof crypto?.randomUUID === "function") {
24510 return crypto.randomUUID();
24511 }
24512 const buf = new Uint8Array(32);
24513 if (typeof crypto !== "undefined" && typeof crypto?.getRandomValues === "function") {
24514 crypto.getRandomValues(buf);
24515 } else {
24516 for (let i = 0; i < 32; i++) {
24517 buf[i] = Math.floor(Math.random() * 255);
24518 }
24519 }
24520 return bytesToString(buf);
24521}
24522const AnnotationPrefix = "pdfjs_internal_id_";
24523
24524
24525/***/ })
24526
24527/******/ });
24528/************************************************************************/
24529/******/ // The module cache
24530/******/ var __webpack_module_cache__ = {};
24531/******/
24532/******/ // The require function
24533/******/ function __webpack_require__(moduleId) {
24534/******/ // Check if module is in cache
24535/******/ var cachedModule = __webpack_module_cache__[moduleId];
24536/******/ if (cachedModule !== undefined) {
24537/******/ return cachedModule.exports;
24538/******/ }
24539/******/ // Create a new module (and put it into the cache)
24540/******/ var module = __webpack_module_cache__[moduleId] = {
24541/******/ // no module.id needed
24542/******/ // no module.loaded needed
24543/******/ exports: {}
24544/******/ };
24545/******/
24546/******/ // Execute the module function
24547/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
24548/******/
24549/******/ // Return the exports of the module
24550/******/ return module.exports;
24551/******/ }
24552/******/
24553/************************************************************************/
24554/******/ /* webpack/runtime/async module */
24555/******/ (() => {
24556/******/ var webpackQueues = typeof Symbol === "function" ? Symbol("webpack queues") : "__webpack_queues__";
24557/******/ var webpackExports = typeof Symbol === "function" ? Symbol("webpack exports") : "__webpack_exports__";
24558/******/ var webpackError = typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__";
24559/******/ var resolveQueue = (queue) => {
24560/******/ if(queue && queue.d < 1) {
24561/******/ queue.d = 1;
24562/******/ queue.forEach((fn) => (fn.r--));
24563/******/ queue.forEach((fn) => (fn.r-- ? fn.r++ : fn()));
24564/******/ }
24565/******/ }
24566/******/ var wrapDeps = (deps) => (deps.map((dep) => {
24567/******/ if(dep !== null && typeof dep === "object") {
24568/******/ if(dep[webpackQueues]) return dep;
24569/******/ if(dep.then) {
24570/******/ var queue = [];
24571/******/ queue.d = 0;
24572/******/ dep.then((r) => {
24573/******/ obj[webpackExports] = r;
24574/******/ resolveQueue(queue);
24575/******/ }, (e) => {
24576/******/ obj[webpackError] = e;
24577/******/ resolveQueue(queue);
24578/******/ });
24579/******/ var obj = {};
24580/******/ obj[webpackQueues] = (fn) => (fn(queue));
24581/******/ return obj;
24582/******/ }
24583/******/ }
24584/******/ var ret = {};
24585/******/ ret[webpackQueues] = x => {};
24586/******/ ret[webpackExports] = dep;
24587/******/ return ret;
24588/******/ }));
24589/******/ __webpack_require__.a = (module, body, hasAwait) => {
24590/******/ var queue;
24591/******/ hasAwait && ((queue = []).d = -1);
24592/******/ var depQueues = new Set();
24593/******/ var exports = module.exports;
24594/******/ var currentDeps;
24595/******/ var outerResolve;
24596/******/ var reject;
24597/******/ var promise = new Promise((resolve, rej) => {
24598/******/ reject = rej;
24599/******/ outerResolve = resolve;
24600/******/ });
24601/******/ promise[webpackExports] = exports;
24602/******/ promise[webpackQueues] = (fn) => (queue && fn(queue), depQueues.forEach(fn), promise["catch"](x => {}));
24603/******/ module.exports = promise;
24604/******/ body((deps) => {
24605/******/ currentDeps = wrapDeps(deps);
24606/******/ var fn;
24607/******/ var getResult = () => (currentDeps.map((d) => {
24608/******/ if(d[webpackError]) throw d[webpackError];
24609/******/ return d[webpackExports];
24610/******/ }))
24611/******/ var promise = new Promise((resolve) => {
24612/******/ fn = () => (resolve(getResult));
24613/******/ fn.r = 0;
24614/******/ var fnQueue = (q) => (q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))));
24615/******/ currentDeps.map((dep) => (dep[webpackQueues](fnQueue)));
24616/******/ });
24617/******/ return fn.r ? promise : getResult();
24618/******/ }, (err) => ((err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)));
24619/******/ queue && queue.d < 0 && (queue.d = 0);
24620/******/ };
24621/******/ })();
24622/******/
24623/******/ /* webpack/runtime/define property getters */
24624/******/ (() => {
24625/******/ // define getter functions for harmony exports
24626/******/ __webpack_require__.d = (exports, definition) => {
24627/******/ for(var key in definition) {
24628/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
24629/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
24630/******/ }
24631/******/ }
24632/******/ };
24633/******/ })();
24634/******/
24635/******/ /* webpack/runtime/hasOwnProperty shorthand */
24636/******/ (() => {
24637/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
24638/******/ })();
24639/******/
24640/************************************************************************/
24641/******/
24642/******/ // startup
24643/******/ // Load entry module and return exports
24644/******/ // This entry module used 'module' so it can't be inlined
24645/******/ var __webpack_exports__ = __webpack_require__(1228);
24646/******/ __webpack_exports__ = globalThis.pdfjsLib = await (globalThis.pdfjsLibPromise = __webpack_exports__);
24647/******/ var __webpack_exports__AbortException = __webpack_exports__.AbortException;
24648/******/ var __webpack_exports__AnnotationEditorLayer = __webpack_exports__.AnnotationEditorLayer;
24649/******/ var __webpack_exports__AnnotationEditorParamsType = __webpack_exports__.AnnotationEditorParamsType;
24650/******/ var __webpack_exports__AnnotationEditorType = __webpack_exports__.AnnotationEditorType;
24651/******/ var __webpack_exports__AnnotationEditorUIManager = __webpack_exports__.AnnotationEditorUIManager;
24652/******/ var __webpack_exports__AnnotationLayer = __webpack_exports__.AnnotationLayer;
24653/******/ var __webpack_exports__AnnotationMode = __webpack_exports__.AnnotationMode;
24654/******/ var __webpack_exports__CMapCompressionType = __webpack_exports__.CMapCompressionType;
24655/******/ var __webpack_exports__ColorPicker = __webpack_exports__.ColorPicker;
24656/******/ var __webpack_exports__DOMSVGFactory = __webpack_exports__.DOMSVGFactory;
24657/******/ var __webpack_exports__DrawLayer = __webpack_exports__.DrawLayer;
24658/******/ var __webpack_exports__FeatureTest = __webpack_exports__.FeatureTest;
24659/******/ var __webpack_exports__GlobalWorkerOptions = __webpack_exports__.GlobalWorkerOptions;
24660/******/ var __webpack_exports__ImageKind = __webpack_exports__.ImageKind;
24661/******/ var __webpack_exports__InvalidPDFException = __webpack_exports__.InvalidPDFException;
24662/******/ var __webpack_exports__MissingPDFException = __webpack_exports__.MissingPDFException;
24663/******/ var __webpack_exports__OPS = __webpack_exports__.OPS;
24664/******/ var __webpack_exports__Outliner = __webpack_exports__.Outliner;
24665/******/ var __webpack_exports__PDFDataRangeTransport = __webpack_exports__.PDFDataRangeTransport;
24666/******/ var __webpack_exports__PDFDateString = __webpack_exports__.PDFDateString;
24667/******/ var __webpack_exports__PDFWorker = __webpack_exports__.PDFWorker;
24668/******/ var __webpack_exports__PasswordResponses = __webpack_exports__.PasswordResponses;
24669/******/ var __webpack_exports__PermissionFlag = __webpack_exports__.PermissionFlag;
24670/******/ var __webpack_exports__PixelsPerInch = __webpack_exports__.PixelsPerInch;
24671/******/ var __webpack_exports__RenderingCancelledException = __webpack_exports__.RenderingCancelledException;
24672/******/ var __webpack_exports__UnexpectedResponseException = __webpack_exports__.UnexpectedResponseException;
24673/******/ var __webpack_exports__Util = __webpack_exports__.Util;
24674/******/ var __webpack_exports__VerbosityLevel = __webpack_exports__.VerbosityLevel;
24675/******/ var __webpack_exports__XfaLayer = __webpack_exports__.XfaLayer;
24676/******/ var __webpack_exports__build = __webpack_exports__.build;
24677/******/ var __webpack_exports__createValidAbsoluteUrl = __webpack_exports__.createValidAbsoluteUrl;
24678/******/ var __webpack_exports__fetchData = __webpack_exports__.fetchData;
24679/******/ var __webpack_exports__getDocument = __webpack_exports__.getDocument;
24680/******/ var __webpack_exports__getFilenameFromUrl = __webpack_exports__.getFilenameFromUrl;
24681/******/ var __webpack_exports__getPdfFilenameFromUrl = __webpack_exports__.getPdfFilenameFromUrl;
24682/******/ var __webpack_exports__getXfaPageViewport = __webpack_exports__.getXfaPageViewport;
24683/******/ var __webpack_exports__isDataScheme = __webpack_exports__.isDataScheme;
24684/******/ var __webpack_exports__isPdfFile = __webpack_exports__.isPdfFile;
24685/******/ var __webpack_exports__noContextMenu = __webpack_exports__.noContextMenu;
24686/******/ var __webpack_exports__normalizeUnicode = __webpack_exports__.normalizeUnicode;
24687/******/ var __webpack_exports__renderTextLayer = __webpack_exports__.renderTextLayer;
24688/******/ var __webpack_exports__setLayerDimensions = __webpack_exports__.setLayerDimensions;
24689/******/ var __webpack_exports__shadow = __webpack_exports__.shadow;
24690/******/ var __webpack_exports__updateTextLayer = __webpack_exports__.updateTextLayer;
24691/******/ var __webpack_exports__version = __webpack_exports__.version;
24692/******/ export { __webpack_exports__AbortException as AbortException, __webpack_exports__AnnotationEditorLayer as AnnotationEditorLayer, __webpack_exports__AnnotationEditorParamsType as AnnotationEditorParamsType, __webpack_exports__AnnotationEditorType as AnnotationEditorType, __webpack_exports__AnnotationEditorUIManager as AnnotationEditorUIManager, __webpack_exports__AnnotationLayer as AnnotationLayer, __webpack_exports__AnnotationMode as AnnotationMode, __webpack_exports__CMapCompressionType as CMapCompressionType, __webpack_exports__ColorPicker as ColorPicker, __webpack_exports__DOMSVGFactory as DOMSVGFactory, __webpack_exports__DrawLayer as DrawLayer, __webpack_exports__FeatureTest as FeatureTest, __webpack_exports__GlobalWorkerOptions as GlobalWorkerOptions, __webpack_exports__ImageKind as ImageKind, __webpack_exports__InvalidPDFException as InvalidPDFException, __webpack_exports__MissingPDFException as MissingPDFException, __webpack_exports__OPS as OPS, __webpack_exports__Outliner as Outliner, __webpack_exports__PDFDataRangeTransport as PDFDataRangeTransport, __webpack_exports__PDFDateString as PDFDateString, __webpack_exports__PDFWorker as PDFWorker, __webpack_exports__PasswordResponses as PasswordResponses, __webpack_exports__PermissionFlag as PermissionFlag, __webpack_exports__PixelsPerInch as PixelsPerInch, __webpack_exports__RenderingCancelledException as RenderingCancelledException, __webpack_exports__UnexpectedResponseException as UnexpectedResponseException, __webpack_exports__Util as Util, __webpack_exports__VerbosityLevel as VerbosityLevel, __webpack_exports__XfaLayer as XfaLayer, __webpack_exports__build as build, __webpack_exports__createValidAbsoluteUrl as createValidAbsoluteUrl, __webpack_exports__fetchData as fetchData, __webpack_exports__getDocument as getDocument, __webpack_exports__getFilenameFromUrl as getFilenameFromUrl, __webpack_exports__getPdfFilenameFromUrl as getPdfFilenameFromUrl, __webpack_exports__getXfaPageViewport as getXfaPageViewport, __webpack_exports__isDataScheme as isDataScheme, __webpack_exports__isPdfFile as isPdfFile, __webpack_exports__noContextMenu as noContextMenu, __webpack_exports__normalizeUnicode as normalizeUnicode, __webpack_exports__renderTextLayer as renderTextLayer, __webpack_exports__setLayerDimensions as setLayerDimensions, __webpack_exports__shadow as shadow, __webpack_exports__updateTextLayer as updateTextLayer, __webpack_exports__version as version };
24693/******/
24694
24695//# sourceMappingURL=pdf.mjs.map
\No newline at end of file