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