@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +1 -1
  2. package/package.json +42 -26
  3. package/{src/display → pdfjs/dist}/display_utils.js +344 -139
  4. package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
  5. package/pdfjs/dist/l10n_utils.js +140 -0
  6. package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
  7. package/{src/display → pdfjs/dist}/network.js +149 -87
  8. package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
  9. package/{src/display → pdfjs/dist}/node_stream.js +133 -98
  10. package/pdfjs/dist/pdf.js +12778 -0
  11. package/pdfjs/dist/pdf_link_service.js +638 -0
  12. package/pdfjs/dist/pdf_rendering_queue.js +199 -0
  13. package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
  14. package/pdfjs/dist/pdf_viewer.js +3598 -0
  15. package/pdfjs/dist/ui_utils.js +1033 -0
  16. package/{src/shared → pdfjs/dist}/util.js +301 -287
  17. package/pdfjs/dist/worker.js +62813 -0
  18. package/src/vcf-pdf-viewer.js +98 -46
  19. package/theme/lumo/vcf-pdf-viewer-styles.js +4 -4
  20. package/theme/material/vcf-pdf-viewer-styles.js +4 -4
  21. package/theme/material/vcf-pdf-viewer.js +2 -2
  22. package/src/core/.eslintrc +0 -13
  23. package/src/core/annotation.js +0 -2948
  24. package/src/core/arithmetic_decoder.js +0 -182
  25. package/src/core/ascii_85_stream.js +0 -98
  26. package/src/core/ascii_hex_stream.js +0 -79
  27. package/src/core/base_stream.js +0 -110
  28. package/src/core/bidi.js +0 -438
  29. package/src/core/calibri_factors.js +0 -308
  30. package/src/core/catalog.js +0 -1459
  31. package/src/core/ccitt.js +0 -1062
  32. package/src/core/ccitt_stream.js +0 -60
  33. package/src/core/cff_font.js +0 -116
  34. package/src/core/cff_parser.js +0 -1949
  35. package/src/core/charsets.js +0 -119
  36. package/src/core/chunked_stream.js +0 -557
  37. package/src/core/cmap.js +0 -1039
  38. package/src/core/colorspace.js +0 -1533
  39. package/src/core/core_utils.js +0 -464
  40. package/src/core/crypto.js +0 -1900
  41. package/src/core/decode_stream.js +0 -170
  42. package/src/core/decrypt_stream.js +0 -59
  43. package/src/core/default_appearance.js +0 -99
  44. package/src/core/document.js +0 -1456
  45. package/src/core/encodings.js +0 -301
  46. package/src/core/evaluator.js +0 -4601
  47. package/src/core/file_spec.js +0 -108
  48. package/src/core/flate_stream.js +0 -402
  49. package/src/core/font_renderer.js +0 -882
  50. package/src/core/fonts.js +0 -3260
  51. package/src/core/fonts_utils.js +0 -221
  52. package/src/core/function.js +0 -1257
  53. package/src/core/glyf.js +0 -706
  54. package/src/core/glyphlist.js +0 -4558
  55. package/src/core/helvetica_factors.js +0 -353
  56. package/src/core/image.js +0 -802
  57. package/src/core/image_utils.js +0 -291
  58. package/src/core/jbig2.js +0 -2572
  59. package/src/core/jbig2_stream.js +0 -73
  60. package/src/core/jpeg_stream.js +0 -105
  61. package/src/core/jpg.js +0 -1416
  62. package/src/core/jpx.js +0 -2343
  63. package/src/core/jpx_stream.js +0 -87
  64. package/src/core/liberationsans_widths.js +0 -221
  65. package/src/core/lzw_stream.js +0 -150
  66. package/src/core/metadata_parser.js +0 -146
  67. package/src/core/metrics.js +0 -2970
  68. package/src/core/murmurhash3.js +0 -139
  69. package/src/core/myriadpro_factors.js +0 -290
  70. package/src/core/name_number_tree.js +0 -153
  71. package/src/core/object_loader.js +0 -149
  72. package/src/core/opentype_file_builder.js +0 -154
  73. package/src/core/operator_list.js +0 -734
  74. package/src/core/parser.js +0 -1416
  75. package/src/core/pattern.js +0 -985
  76. package/src/core/pdf_manager.js +0 -217
  77. package/src/core/predictor_stream.js +0 -238
  78. package/src/core/primitives.js +0 -402
  79. package/src/core/ps_parser.js +0 -272
  80. package/src/core/run_length_stream.js +0 -61
  81. package/src/core/segoeui_factors.js +0 -308
  82. package/src/core/standard_fonts.js +0 -817
  83. package/src/core/stream.js +0 -103
  84. package/src/core/struct_tree.js +0 -335
  85. package/src/core/to_unicode_map.js +0 -103
  86. package/src/core/type1_font.js +0 -421
  87. package/src/core/type1_parser.js +0 -776
  88. package/src/core/unicode.js +0 -1649
  89. package/src/core/worker.js +0 -848
  90. package/src/core/worker_stream.js +0 -135
  91. package/src/core/writer.js +0 -278
  92. package/src/core/xfa/bind.js +0 -652
  93. package/src/core/xfa/builder.js +0 -207
  94. package/src/core/xfa/config.js +0 -1926
  95. package/src/core/xfa/connection_set.js +0 -202
  96. package/src/core/xfa/data.js +0 -82
  97. package/src/core/xfa/datasets.js +0 -76
  98. package/src/core/xfa/factory.js +0 -111
  99. package/src/core/xfa/fonts.js +0 -181
  100. package/src/core/xfa/formcalc_lexer.js +0 -385
  101. package/src/core/xfa/formcalc_parser.js +0 -1340
  102. package/src/core/xfa/html_utils.js +0 -639
  103. package/src/core/xfa/layout.js +0 -383
  104. package/src/core/xfa/locale_set.js +0 -345
  105. package/src/core/xfa/namespaces.js +0 -81
  106. package/src/core/xfa/parser.js +0 -184
  107. package/src/core/xfa/setup.js +0 -38
  108. package/src/core/xfa/signature.js +0 -40
  109. package/src/core/xfa/som.js +0 -338
  110. package/src/core/xfa/stylesheet.js +0 -40
  111. package/src/core/xfa/template.js +0 -6260
  112. package/src/core/xfa/text.js +0 -290
  113. package/src/core/xfa/unknown.js +0 -29
  114. package/src/core/xfa/utils.js +0 -217
  115. package/src/core/xfa/xdp.js +0 -59
  116. package/src/core/xfa/xfa_object.js +0 -1130
  117. package/src/core/xfa/xhtml.js +0 -543
  118. package/src/core/xfa_fonts.js +0 -208
  119. package/src/core/xml_parser.js +0 -507
  120. package/src/core/xref.js +0 -899
  121. package/src/display/annotation_layer.js +0 -2107
  122. package/src/display/annotation_storage.js +0 -113
  123. package/src/display/api.js +0 -3292
  124. package/src/display/base_factory.js +0 -180
  125. package/src/display/canvas.js +0 -2828
  126. package/src/display/font_loader.js +0 -484
  127. package/src/display/metadata.js +0 -41
  128. package/src/display/network_utils.js +0 -100
  129. package/src/display/node_utils.js +0 -83
  130. package/src/display/optional_content_config.js +0 -189
  131. package/src/display/pattern_helper.js +0 -659
  132. package/src/display/svg.js +0 -1709
  133. package/src/display/text_layer.js +0 -847
  134. package/src/display/transport_stream.js +0 -303
  135. package/src/display/worker_options.js +0 -40
  136. package/src/display/xfa_layer.js +0 -204
  137. package/src/doc_helper.js +0 -25
  138. package/src/images/logo.svg +0 -41
  139. package/src/interfaces.js +0 -169
  140. package/src/license_header.js +0 -14
  141. package/src/license_header_libre.js +0 -21
  142. package/src/pdf.image_decoders.js +0 -46
  143. package/src/pdf.js +0 -146
  144. package/src/pdf.sandbox.external.js +0 -181
  145. package/src/pdf.sandbox.js +0 -151
  146. package/src/pdf.scripting.js +0 -25
  147. package/src/pdf.worker.entry.js +0 -19
  148. package/src/pdf.worker.js +0 -23
  149. package/src/scripting_api/aform.js +0 -608
  150. package/src/scripting_api/app.js +0 -621
  151. package/src/scripting_api/color.js +0 -129
  152. package/src/scripting_api/common.js +0 -58
  153. package/src/scripting_api/console.js +0 -38
  154. package/src/scripting_api/constants.js +0 -208
  155. package/src/scripting_api/doc.js +0 -1195
  156. package/src/scripting_api/error.js +0 -23
  157. package/src/scripting_api/event.js +0 -232
  158. package/src/scripting_api/field.js +0 -620
  159. package/src/scripting_api/fullscreen.js +0 -145
  160. package/src/scripting_api/initialization.js +0 -223
  161. package/src/scripting_api/pdf_object.js +0 -24
  162. package/src/scripting_api/print_params.js +0 -146
  163. package/src/scripting_api/proxy.js +0 -139
  164. package/src/scripting_api/thermometer.js +0 -69
  165. package/src/scripting_api/util.js +0 -581
  166. package/src/shared/.eslintrc +0 -13
  167. package/src/shared/cffStandardStrings.js +0 -311
  168. package/src/shared/compatibility.js +0 -114
  169. package/src/shared/fonts_utils.js +0 -429
  170. package/src/shared/is_node.js +0 -27
  171. package/src/shared/scripting_utils.js +0 -85
  172. package/src/worker_loader.js +0 -32
@@ -1,3 +1,7 @@
1
+ import { c as assert, l as createPromiseCapability, A as AbortException } from './util.js';
2
+ import { a as validateResponseStatus, c as createResponseStatusError, v as validateRangeRequestCapabilities, e as extractFilenameFromHeader } from './network_utils.js';
3
+ import './display_utils.js';
4
+
1
5
  /* Copyright 2012 Mozilla Foundation
2
6
  *
3
7
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,67 +17,56 @@
13
17
  * limitations under the License.
14
18
  */
15
19
 
16
- import {
17
- AbortException,
18
- assert,
19
- createPromiseCapability,
20
- } from "../shared/util.js";
21
- import {
22
- createResponseStatusError,
23
- extractFilenameFromHeader,
24
- validateRangeRequestCapabilities,
25
- validateResponseStatus,
26
- } from "./network_utils.js";
27
-
28
20
  if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
29
- throw new Error(
30
- 'Module "./fetch_stream.js" shall not be used with MOZCENTRAL builds.'
31
- );
21
+ throw new Error('Module "./fetch_stream.js" shall not be used with MOZCENTRAL builds.');
32
22
  }
33
23
 
34
24
  function createFetchOptions(headers, withCredentials, abortController) {
35
25
  return {
36
26
  method: "GET",
37
27
  headers,
38
- signal: abortController?.signal,
28
+ signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
39
29
  mode: "cors",
40
30
  credentials: withCredentials ? "include" : "same-origin",
41
- redirect: "follow",
31
+ redirect: "follow"
42
32
  };
43
33
  }
44
34
 
45
35
  function createHeaders(httpHeaders) {
46
36
  const headers = new Headers();
37
+
47
38
  for (const property in httpHeaders) {
48
39
  const value = httpHeaders[property];
40
+
49
41
  if (typeof value === "undefined") {
50
42
  continue;
51
43
  }
44
+
52
45
  headers.append(property, value);
53
46
  }
47
+
54
48
  return headers;
55
49
  }
56
-
57
50
  /** @implements {IPDFStream} */
51
+
52
+
58
53
  class PDFFetchStream {
59
54
  constructor(source) {
60
55
  this.source = source;
61
56
  this.isHttp = /^https?:/i.test(source.url);
62
- this.httpHeaders = (this.isHttp && source.httpHeaders) || {};
63
-
57
+ this.httpHeaders = this.isHttp && source.httpHeaders || {};
64
58
  this._fullRequestReader = null;
65
59
  this._rangeRequestReaders = [];
66
60
  }
67
61
 
68
62
  get _progressiveDataLength() {
69
- return this._fullRequestReader?._loaded ?? 0;
63
+ var _this$_fullRequestRea, _this$_fullRequestRea2;
64
+
65
+ return (_this$_fullRequestRea = (_this$_fullRequestRea2 = this._fullRequestReader) === null || _this$_fullRequestRea2 === void 0 ? void 0 : _this$_fullRequestRea2._loaded) !== null && _this$_fullRequestRea !== void 0 ? _this$_fullRequestRea : 0;
70
66
  }
71
67
 
72
68
  getFullReader() {
73
- assert(
74
- !this._fullRequestReader,
75
- "PDFFetchStream.getFullReader can only be called once."
76
- );
69
+ assert(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
77
70
  this._fullRequestReader = new PDFFetchStreamReader(this);
78
71
  return this._fullRequestReader;
79
72
  }
@@ -82,8 +75,11 @@ class PDFFetchStream {
82
75
  if (end <= this._progressiveDataLength) {
83
76
  return null;
84
77
  }
78
+
85
79
  const reader = new PDFFetchStreamRangeReader(this, begin, end);
80
+
86
81
  this._rangeRequestReaders.push(reader);
82
+
87
83
  return reader;
88
84
  }
89
85
 
@@ -91,13 +87,16 @@ class PDFFetchStream {
91
87
  if (this._fullRequestReader) {
92
88
  this._fullRequestReader.cancel(reason);
93
89
  }
90
+
94
91
  for (const reader of this._rangeRequestReaders.slice(0)) {
95
92
  reader.cancel(reason);
96
93
  }
97
94
  }
98
- }
99
95
 
96
+ }
100
97
  /** @implements {IPDFStreamReader} */
98
+
99
+
101
100
  class PDFFetchStreamReader {
102
101
  constructor(stream) {
103
102
  this._stream = stream;
@@ -110,6 +109,7 @@ class PDFFetchStreamReader {
110
109
  this._headersCapability = createPromiseCapability();
111
110
  this._disableRange = source.disableRange || false;
112
111
  this._rangeChunkSize = source.rangeChunkSize;
112
+
113
113
  if (!this._rangeChunkSize && !this._disableRange) {
114
114
  this._disableRange = true;
115
115
  }
@@ -117,52 +117,43 @@ class PDFFetchStreamReader {
117
117
  if (typeof AbortController !== "undefined") {
118
118
  this._abortController = new AbortController();
119
119
  }
120
+
120
121
  this._isStreamingSupported = !source.disableStream;
121
122
  this._isRangeSupported = !source.disableRange;
122
-
123
123
  this._headers = createHeaders(this._stream.httpHeaders);
124
-
125
124
  const url = source.url;
126
- fetch(
127
- url,
128
- createFetchOptions(
129
- this._headers,
130
- this._withCredentials,
131
- this._abortController
132
- )
133
- )
134
- .then(response => {
135
- if (!validateResponseStatus(response.status)) {
136
- throw createResponseStatusError(response.status, url);
137
- }
138
- this._reader = response.body.getReader();
139
- this._headersCapability.resolve();
140
-
141
- const getResponseHeader = name => {
142
- return response.headers.get(name);
143
- };
144
- const { allowRangeRequests, suggestedLength } =
145
- validateRangeRequestCapabilities({
146
- getResponseHeader,
147
- isHttp: this._stream.isHttp,
148
- rangeChunkSize: this._rangeChunkSize,
149
- disableRange: this._disableRange,
150
- });
151
-
152
- this._isRangeSupported = allowRangeRequests;
153
- // Setting right content length.
154
- this._contentLength = suggestedLength || this._contentLength;
155
-
156
- this._filename = extractFilenameFromHeader(getResponseHeader);
157
-
158
- // We need to stop reading when range is supported and streaming is
159
- // disabled.
160
- if (!this._isStreamingSupported && this._isRangeSupported) {
161
- this.cancel(new AbortException("Streaming is disabled."));
162
- }
163
- })
164
- .catch(this._headersCapability.reject);
125
+ fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
126
+ if (!validateResponseStatus(response.status)) {
127
+ throw createResponseStatusError(response.status, url);
128
+ }
129
+
130
+ this._reader = response.body.getReader();
131
+
132
+ this._headersCapability.resolve();
133
+
134
+ const getResponseHeader = name => {
135
+ return response.headers.get(name);
136
+ };
137
+
138
+ const {
139
+ allowRangeRequests,
140
+ suggestedLength
141
+ } = validateRangeRequestCapabilities({
142
+ getResponseHeader,
143
+ isHttp: this._stream.isHttp,
144
+ rangeChunkSize: this._rangeChunkSize,
145
+ disableRange: this._disableRange
146
+ });
147
+ this._isRangeSupported = allowRangeRequests; // Setting right content length.
148
+
149
+ this._contentLength = suggestedLength || this._contentLength;
150
+ this._filename = extractFilenameFromHeader(getResponseHeader); // We need to stop reading when range is supported and streaming is
151
+ // disabled.
165
152
 
153
+ if (!this._isStreamingSupported && this._isRangeSupported) {
154
+ this.cancel(new AbortException("Streaming is disabled."));
155
+ }
156
+ }).catch(this._headersCapability.reject);
166
157
  this.onProgress = null;
167
158
  }
168
159
 
@@ -188,32 +179,48 @@ class PDFFetchStreamReader {
188
179
 
189
180
  async read() {
190
181
  await this._headersCapability.promise;
191
- const { value, done } = await this._reader.read();
182
+ const {
183
+ value,
184
+ done
185
+ } = await this._reader.read();
186
+
192
187
  if (done) {
193
- return { value, done };
188
+ return {
189
+ value,
190
+ done
191
+ };
194
192
  }
193
+
195
194
  this._loaded += value.byteLength;
195
+
196
196
  if (this.onProgress) {
197
197
  this.onProgress({
198
198
  loaded: this._loaded,
199
- total: this._contentLength,
199
+ total: this._contentLength
200
200
  });
201
201
  }
202
+
202
203
  const buffer = new Uint8Array(value).buffer;
203
- return { value: buffer, done: false };
204
+ return {
205
+ value: buffer,
206
+ done: false
207
+ };
204
208
  }
205
209
 
206
210
  cancel(reason) {
207
211
  if (this._reader) {
208
212
  this._reader.cancel(reason);
209
213
  }
214
+
210
215
  if (this._abortController) {
211
216
  this._abortController.abort();
212
217
  }
213
218
  }
214
- }
215
219
 
220
+ }
216
221
  /** @implements {IPDFStreamRangeReader} */
222
+
223
+
217
224
  class PDFFetchStreamRangeReader {
218
225
  constructor(stream, begin, end) {
219
226
  this._stream = stream;
@@ -229,31 +236,25 @@ class PDFFetchStreamRangeReader {
229
236
  }
230
237
 
231
238
  this._headers = createHeaders(this._stream.httpHeaders);
239
+
232
240
  this._headers.append("Range", `bytes=${begin}-${end - 1}`);
233
241
 
234
242
  const url = source.url;
235
- fetch(
236
- url,
237
- createFetchOptions(
238
- this._headers,
239
- this._withCredentials,
240
- this._abortController
241
- )
242
- )
243
- .then(response => {
244
- if (!validateResponseStatus(response.status)) {
245
- throw createResponseStatusError(response.status, url);
246
- }
247
- this._readCapability.resolve();
248
- this._reader = response.body.getReader();
249
- })
250
- .catch(reason => {
251
- if (reason?.name === "AbortError") {
252
- return;
253
- }
254
- throw reason;
255
- });
243
+ fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
244
+ if (!validateResponseStatus(response.status)) {
245
+ throw createResponseStatusError(response.status, url);
246
+ }
247
+
248
+ this._readCapability.resolve();
249
+
250
+ this._reader = response.body.getReader();
251
+ }).catch(reason => {
252
+ if ((reason === null || reason === void 0 ? void 0 : reason.name) === "AbortError") {
253
+ return;
254
+ }
256
255
 
256
+ throw reason;
257
+ });
257
258
  this.onProgress = null;
258
259
  }
259
260
 
@@ -263,26 +264,43 @@ class PDFFetchStreamRangeReader {
263
264
 
264
265
  async read() {
265
266
  await this._readCapability.promise;
266
- const { value, done } = await this._reader.read();
267
+ const {
268
+ value,
269
+ done
270
+ } = await this._reader.read();
271
+
267
272
  if (done) {
268
- return { value, done };
273
+ return {
274
+ value,
275
+ done
276
+ };
269
277
  }
278
+
270
279
  this._loaded += value.byteLength;
280
+
271
281
  if (this.onProgress) {
272
- this.onProgress({ loaded: this._loaded });
282
+ this.onProgress({
283
+ loaded: this._loaded
284
+ });
273
285
  }
286
+
274
287
  const buffer = new Uint8Array(value).buffer;
275
- return { value: buffer, done: false };
288
+ return {
289
+ value: buffer,
290
+ done: false
291
+ };
276
292
  }
277
293
 
278
294
  cancel(reason) {
279
295
  if (this._reader) {
280
296
  this._reader.cancel(reason);
281
297
  }
298
+
282
299
  if (this._abortController) {
283
300
  this._abortController.abort();
284
301
  }
285
302
  }
303
+
286
304
  }
287
305
 
288
306
  export { PDFFetchStream };
@@ -0,0 +1,140 @@
1
+ /* Copyright 2021 Mozilla Foundation
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ /**
17
+ * A subset of the l10n strings in the `l10n/en-US/viewer.properties` file.
18
+ */
19
+ const DEFAULT_L10N_STRINGS = {
20
+ of_pages: "of {{pagesCount}}",
21
+ page_of_pages: "({{pageNumber}} of {{pagesCount}})",
22
+ document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
23
+ document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
24
+ document_properties_date_string: "{{date}}, {{time}}",
25
+ document_properties_page_size_unit_inches: "in",
26
+ document_properties_page_size_unit_millimeters: "mm",
27
+ document_properties_page_size_orientation_portrait: "portrait",
28
+ document_properties_page_size_orientation_landscape: "landscape",
29
+ document_properties_page_size_name_a3: "A3",
30
+ document_properties_page_size_name_a4: "A4",
31
+ document_properties_page_size_name_letter: "Letter",
32
+ document_properties_page_size_name_legal: "Legal",
33
+ document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
34
+ document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
35
+ document_properties_linearized_yes: "Yes",
36
+ document_properties_linearized_no: "No",
37
+ print_progress_percent: "{{progress}}%",
38
+ "toggle_sidebar.title": "Toggle Sidebar",
39
+ "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)",
40
+ additional_layers: "Additional Layers",
41
+ page_landmark: "Page {{page}}",
42
+ thumb_page_title: "Page {{page}}",
43
+ thumb_page_canvas: "Thumbnail of Page {{page}}",
44
+ find_reached_top: "Reached top of document, continued from bottom",
45
+ find_reached_bottom: "Reached end of document, continued from top",
46
+ "find_match_count[one]": "{{current}} of {{total}} match",
47
+ "find_match_count[other]": "{{current}} of {{total}} matches",
48
+ "find_match_count_limit[one]": "More than {{limit}} match",
49
+ "find_match_count_limit[other]": "More than {{limit}} matches",
50
+ find_not_found: "Phrase not found",
51
+ error_version_info: "PDF.js v{{version}} (build: {{build}})",
52
+ error_message: "Message: {{message}}",
53
+ error_stack: "Stack: {{stack}}",
54
+ error_file: "File: {{file}}",
55
+ error_line: "Line: {{line}}",
56
+ rendering_error: "An error occurred while rendering the page.",
57
+ page_scale_width: "Page Width",
58
+ page_scale_fit: "Page Fit",
59
+ page_scale_auto: "Automatic Zoom",
60
+ page_scale_actual: "Actual Size",
61
+ page_scale_percent: "{{scale}}%",
62
+ loading: "Loading…",
63
+ loading_error: "An error occurred while loading the PDF.",
64
+ invalid_file_error: "Invalid or corrupted PDF file.",
65
+ missing_file_error: "Missing PDF file.",
66
+ unexpected_response_error: "Unexpected server response.",
67
+ printing_not_supported: "Warning: Printing is not fully supported by this browser.",
68
+ printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
69
+ web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts."
70
+ };
71
+
72
+ function getL10nFallback(key, args) {
73
+ switch (key) {
74
+ case "find_match_count":
75
+ key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
76
+ break;
77
+
78
+ case "find_match_count_limit":
79
+ key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
80
+ break;
81
+ }
82
+
83
+ return DEFAULT_L10N_STRINGS[key] || "";
84
+ }
85
+
86
+ const PARTIAL_LANG_CODES = {
87
+ en: "en-US",
88
+ es: "es-ES",
89
+ fy: "fy-NL",
90
+ ga: "ga-IE",
91
+ gu: "gu-IN",
92
+ hi: "hi-IN",
93
+ hy: "hy-AM",
94
+ nb: "nb-NO",
95
+ ne: "ne-NP",
96
+ nn: "nn-NO",
97
+ pa: "pa-IN",
98
+ pt: "pt-PT",
99
+ sv: "sv-SE",
100
+ zh: "zh-CN"
101
+ }; // Try to support "incompletely" specified language codes (see issue 13689).
102
+
103
+ function fixupLangCode(langCode) {
104
+ return PARTIAL_LANG_CODES[langCode === null || langCode === void 0 ? void 0 : langCode.toLowerCase()] || langCode;
105
+ } // Replaces {{arguments}} with their values.
106
+
107
+
108
+ function formatL10nValue(text, args) {
109
+ if (!args) {
110
+ return text;
111
+ }
112
+
113
+ return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
114
+ return name in args ? args[name] : "{{" + name + "}}";
115
+ });
116
+ }
117
+ /**
118
+ * No-op implementation of the localization service.
119
+ * @implements {IL10n}
120
+ */
121
+
122
+
123
+ const NullL10n = {
124
+ async getLanguage() {
125
+ return "en-us";
126
+ },
127
+
128
+ async getDirection() {
129
+ return "ltr";
130
+ },
131
+
132
+ async get(key, args = null, fallback = getL10nFallback(key, args)) {
133
+ return formatL10nValue(fallback, args);
134
+ },
135
+
136
+ async translate(element) {}
137
+
138
+ };
139
+
140
+ export { NullL10n, fixupLangCode, getL10nFallback };