pdfjs-dist 2.2.228 → 2.6.347

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (229) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +8816 -19300
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +27185 -35746
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +26665 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/es5/build/pdf.min.js +22 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +61231 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/build/pdf.worker.min.js +22 -0
  17. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  18. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  19. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  20. package/es5/web/images/annotation-check.svg +11 -0
  21. package/es5/web/images/annotation-comment.svg +16 -0
  22. package/es5/web/images/annotation-help.svg +26 -0
  23. package/es5/web/images/annotation-insert.svg +10 -0
  24. package/es5/web/images/annotation-key.svg +11 -0
  25. package/es5/web/images/annotation-newparagraph.svg +11 -0
  26. package/es5/web/images/annotation-noicon.svg +7 -0
  27. package/es5/web/images/annotation-note.svg +42 -0
  28. package/es5/web/images/annotation-paragraph.svg +16 -0
  29. package/es5/web/images/loading-icon.gif +0 -0
  30. package/es5/web/images/shadow.png +0 -0
  31. package/es5/web/pdf_viewer.css +406 -0
  32. package/es5/web/pdf_viewer.js +7886 -0
  33. package/es5/web/pdf_viewer.js.map +1 -0
  34. package/image_decoders/pdf.image_decoders.js +1498 -4832
  35. package/image_decoders/pdf.image_decoders.js.map +1 -1
  36. package/image_decoders/pdf.image_decoders.min.js +22 -1
  37. package/lib/README.md +7 -0
  38. package/lib/core/annotation.js +1144 -927
  39. package/lib/core/arithmetic_decoder.js +81 -97
  40. package/lib/core/bidi.js +54 -46
  41. package/lib/core/ccitt.js +88 -81
  42. package/lib/core/ccitt_stream.js +15 -14
  43. package/lib/core/cff_parser.js +747 -716
  44. package/lib/core/charsets.js +4 -4
  45. package/lib/core/chunked_stream.js +462 -553
  46. package/lib/core/cmap.js +231 -277
  47. package/lib/core/colorspace.js +715 -857
  48. package/lib/core/core_utils.js +57 -52
  49. package/lib/core/crypto.js +416 -437
  50. package/lib/core/document.js +629 -670
  51. package/lib/core/encodings.js +15 -15
  52. package/lib/core/evaluator.js +3229 -2800
  53. package/lib/core/font_renderer.js +135 -178
  54. package/lib/core/fonts.js +602 -534
  55. package/lib/core/function.js +355 -279
  56. package/lib/core/glyphlist.js +4527 -4526
  57. package/lib/core/image.js +442 -439
  58. package/lib/core/image_utils.js +221 -61
  59. package/lib/core/jbig2.js +325 -316
  60. package/lib/core/jbig2_stream.js +18 -17
  61. package/lib/core/jpeg_stream.js +21 -26
  62. package/lib/core/jpg.js +289 -233
  63. package/lib/core/jpx.js +161 -143
  64. package/lib/core/jpx_stream.js +28 -28
  65. package/lib/core/metrics.js +2928 -2928
  66. package/lib/core/murmurhash3.js +87 -102
  67. package/lib/core/obj.js +1343 -1300
  68. package/lib/core/operator_list.js +90 -67
  69. package/lib/core/parser.js +990 -987
  70. package/lib/core/pattern.js +105 -77
  71. package/lib/core/pdf_manager.js +149 -316
  72. package/lib/core/primitives.js +156 -104
  73. package/lib/core/ps_parser.js +175 -214
  74. package/lib/core/standard_fonts.js +237 -236
  75. package/lib/core/stream.js +94 -74
  76. package/lib/core/type1_parser.js +89 -69
  77. package/lib/core/unicode.js +1654 -1654
  78. package/lib/core/worker.js +275 -290
  79. package/lib/core/worker_stream.js +101 -210
  80. package/lib/core/writer.js +242 -0
  81. package/lib/display/annotation_layer.js +772 -1041
  82. package/lib/display/annotation_storage.js +89 -0
  83. package/lib/display/api.js +1575 -1868
  84. package/lib/display/api_compatibility.js +12 -17
  85. package/lib/display/canvas.js +370 -222
  86. package/lib/display/content_disposition.js +40 -59
  87. package/lib/display/display_utils.js +341 -536
  88. package/lib/display/fetch_stream.js +188 -304
  89. package/lib/display/font_loader.js +282 -414
  90. package/lib/display/metadata.js +81 -99
  91. package/lib/display/network.js +362 -511
  92. package/lib/display/network_utils.js +25 -18
  93. package/lib/display/node_stream.js +283 -465
  94. package/lib/display/node_utils.js +87 -0
  95. package/lib/display/optional_content_config.js +184 -0
  96. package/lib/display/pattern_helper.js +93 -44
  97. package/lib/display/svg.js +1163 -1401
  98. package/lib/display/text_layer.js +154 -137
  99. package/lib/display/transport_stream.js +237 -375
  100. package/lib/display/webgl.js +70 -83
  101. package/lib/display/worker_options.js +3 -3
  102. package/lib/display/xml_parser.js +303 -392
  103. package/lib/examples/node/domstubs.js +37 -37
  104. package/lib/pdf.js +220 -58
  105. package/lib/pdf.worker.js +14 -6
  106. package/lib/shared/compatibility.js +3 -246
  107. package/lib/shared/is_node.js +7 -6
  108. package/lib/shared/message_handler.js +327 -332
  109. package/lib/shared/util.js +271 -306
  110. package/lib/test/unit/annotation_spec.js +1902 -763
  111. package/lib/test/unit/annotation_storage_spec.js +83 -0
  112. package/lib/test/unit/api_spec.js +790 -592
  113. package/lib/test/unit/bidi_spec.js +7 -7
  114. package/lib/test/unit/cff_parser_spec.js +73 -72
  115. package/lib/test/unit/clitests_helper.js +7 -9
  116. package/lib/test/unit/cmap_spec.js +86 -88
  117. package/lib/test/unit/colorspace_spec.js +346 -154
  118. package/lib/test/unit/core_utils_spec.js +125 -105
  119. package/lib/test/unit/crypto_spec.js +232 -185
  120. package/lib/test/unit/custom_spec.js +150 -24
  121. package/lib/test/unit/display_svg_spec.js +34 -39
  122. package/lib/test/unit/display_utils_spec.js +139 -149
  123. package/lib/test/unit/document_spec.js +128 -17
  124. package/lib/test/unit/encodings_spec.js +12 -34
  125. package/lib/test/unit/evaluator_spec.js +112 -91
  126. package/lib/test/unit/fetch_stream_spec.js +31 -29
  127. package/lib/test/unit/function_spec.js +206 -204
  128. package/lib/test/unit/jasmine-boot.js +48 -32
  129. package/lib/test/unit/message_handler_spec.js +173 -159
  130. package/lib/test/unit/metadata_spec.js +71 -71
  131. package/lib/test/unit/murmurhash3_spec.js +12 -12
  132. package/lib/test/unit/network_spec.js +13 -11
  133. package/lib/test/unit/network_utils_spec.js +158 -144
  134. package/lib/test/unit/node_stream_spec.js +76 -90
  135. package/lib/test/unit/parser_spec.js +108 -114
  136. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  137. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  138. package/lib/test/unit/pdf_history_spec.js +32 -32
  139. package/lib/test/unit/primitives_spec.js +337 -156
  140. package/lib/test/unit/stream_spec.js +16 -14
  141. package/lib/test/unit/test_utils.js +91 -304
  142. package/lib/test/unit/testreporter.js +33 -22
  143. package/lib/test/unit/type1_parser_spec.js +42 -42
  144. package/lib/test/unit/ui_utils_spec.js +299 -461
  145. package/lib/test/unit/unicode_spec.js +42 -42
  146. package/lib/test/unit/util_spec.js +129 -149
  147. package/lib/test/unit/writer_spec.js +84 -0
  148. package/lib/web/annotation_layer_builder.js +78 -111
  149. package/lib/web/app.js +1542 -1267
  150. package/lib/web/app_options.js +76 -91
  151. package/lib/web/base_tree_viewer.js +100 -0
  152. package/lib/web/base_viewer.js +869 -834
  153. package/lib/web/chromecom.js +165 -252
  154. package/lib/web/debugger.js +149 -205
  155. package/lib/web/download_manager.js +34 -58
  156. package/lib/web/firefox_print_service.js +62 -34
  157. package/lib/web/firefoxcom.js +206 -374
  158. package/lib/web/genericcom.js +26 -108
  159. package/lib/web/genericl10n.js +24 -153
  160. package/lib/web/grab_to_pan.js +30 -30
  161. package/lib/web/interfaces.js +80 -254
  162. package/lib/web/overlay_manager.js +70 -246
  163. package/lib/web/password_prompt.js +38 -64
  164. package/lib/web/pdf_attachment_viewer.js +150 -126
  165. package/lib/web/pdf_cursor_tools.js +75 -102
  166. package/lib/web/pdf_document_properties.js +229 -383
  167. package/lib/web/pdf_find_bar.js +136 -170
  168. package/lib/web/pdf_find_controller.js +492 -548
  169. package/lib/web/pdf_find_utils.js +13 -13
  170. package/lib/web/pdf_history.js +397 -406
  171. package/lib/web/pdf_layer_viewer.js +208 -0
  172. package/lib/web/pdf_link_service.js +304 -348
  173. package/lib/web/pdf_outline_viewer.js +119 -212
  174. package/lib/web/pdf_page_view.js +474 -513
  175. package/lib/web/pdf_presentation_mode.js +308 -357
  176. package/lib/web/pdf_print_service.js +96 -110
  177. package/lib/web/pdf_rendering_queue.js +87 -108
  178. package/lib/web/pdf_sidebar.js +286 -302
  179. package/lib/web/pdf_sidebar_resizer.js +92 -119
  180. package/lib/web/pdf_single_page_viewer.js +77 -126
  181. package/lib/web/pdf_thumbnail_view.js +289 -297
  182. package/lib/web/pdf_thumbnail_viewer.js +202 -206
  183. package/lib/web/pdf_viewer.component.js +20 -21
  184. package/lib/web/pdf_viewer.js +55 -115
  185. package/lib/web/preferences.js +69 -273
  186. package/lib/web/secondary_toolbar.js +164 -196
  187. package/lib/web/text_layer_builder.js +284 -319
  188. package/lib/web/toolbar.js +217 -210
  189. package/lib/web/ui_utils.js +274 -421
  190. package/lib/web/view_history.js +52 -226
  191. package/lib/web/viewer_compatibility.js +21 -6
  192. package/package.json +4 -9
  193. package/types/display/annotation_layer.d.ts +61 -0
  194. package/types/display/annotation_storage.d.ts +36 -0
  195. package/types/display/api.d.ts +1107 -0
  196. package/types/display/api_compatibility.d.ts +1 -0
  197. package/types/display/canvas.d.ts +4 -0
  198. package/types/display/content_disposition.d.ts +7 -0
  199. package/types/display/display_utils.d.ts +243 -0
  200. package/types/display/fetch_stream.d.ts +67 -0
  201. package/types/display/font_loader.d.ts +19 -0
  202. package/types/display/metadata.d.ts +9 -0
  203. package/types/display/network.d.ts +80 -0
  204. package/types/display/network_utils.d.ts +14 -0
  205. package/types/display/node_stream.d.ts +72 -0
  206. package/types/display/node_utils.d.ts +6 -0
  207. package/types/display/optional_content_config.d.ts +12 -0
  208. package/types/display/pattern_helper.d.ts +5 -0
  209. package/types/display/svg.d.ts +2 -0
  210. package/types/display/text_layer.d.ts +83 -0
  211. package/types/display/transport_stream.d.ts +57 -0
  212. package/types/display/webgl.d.ts +20 -0
  213. package/types/display/worker_options.d.ts +27 -0
  214. package/types/display/xml_parser.d.ts +35 -0
  215. package/types/pdf.d.ts +33 -0
  216. package/types/shared/compatibility.d.ts +1 -0
  217. package/types/shared/is_node.d.ts +1 -0
  218. package/types/shared/message_handler.d.ts +62 -0
  219. package/types/shared/util.d.ts +421 -0
  220. package/web/images/shadow.png +0 -0
  221. package/web/pdf_viewer.css +29 -27
  222. package/web/pdf_viewer.js +3524 -4746
  223. package/web/pdf_viewer.js.map +1 -1
  224. package/webpack.js +6 -5
  225. package/external/streams/streams-lib.js +0 -3962
  226. package/external/url/url-lib.js +0 -627
  227. package/lib/shared/streams_polyfill.js +0 -43
  228. package/lib/shared/url_polyfill.js +0 -56
  229. package/web/images/texture.png +0 -0
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2019 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -26,136 +26,99 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.AnnotationLayer = void 0;
28
28
 
29
- var _display_utils = require("./display_utils");
29
+ var _display_utils = require("./display_utils.js");
30
30
 
31
- var _util = require("../shared/util");
31
+ var _util = require("../shared/util.js");
32
32
 
33
- function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
33
+ var _annotation_storage = require("./annotation_storage.js");
34
34
 
35
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
35
+ class AnnotationElementFactory {
36
+ static create(parameters) {
37
+ const subtype = parameters.data.annotationType;
36
38
 
37
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
39
+ switch (subtype) {
40
+ case _util.AnnotationType.LINK:
41
+ return new LinkAnnotationElement(parameters);
38
42
 
39
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
43
+ case _util.AnnotationType.TEXT:
44
+ return new TextAnnotationElement(parameters);
40
45
 
41
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
46
+ case _util.AnnotationType.WIDGET:
47
+ const fieldType = parameters.data.fieldType;
42
48
 
43
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
49
+ switch (fieldType) {
50
+ case "Tx":
51
+ return new TextWidgetAnnotationElement(parameters);
44
52
 
45
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
53
+ case "Btn":
54
+ if (parameters.data.radioButton) {
55
+ return new RadioButtonWidgetAnnotationElement(parameters);
56
+ } else if (parameters.data.checkBox) {
57
+ return new CheckboxWidgetAnnotationElement(parameters);
58
+ }
46
59
 
47
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
60
+ return new PushButtonWidgetAnnotationElement(parameters);
48
61
 
49
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
50
-
51
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
52
-
53
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
54
-
55
- var AnnotationElementFactory =
56
- /*#__PURE__*/
57
- function () {
58
- function AnnotationElementFactory() {
59
- _classCallCheck(this, AnnotationElementFactory);
60
- }
61
-
62
- _createClass(AnnotationElementFactory, null, [{
63
- key: "create",
64
- value: function create(parameters) {
65
- var subtype = parameters.data.annotationType;
66
-
67
- switch (subtype) {
68
- case _util.AnnotationType.LINK:
69
- return new LinkAnnotationElement(parameters);
70
-
71
- case _util.AnnotationType.TEXT:
72
- return new TextAnnotationElement(parameters);
73
-
74
- case _util.AnnotationType.WIDGET:
75
- var fieldType = parameters.data.fieldType;
76
-
77
- switch (fieldType) {
78
- case 'Tx':
79
- return new TextWidgetAnnotationElement(parameters);
80
-
81
- case 'Btn':
82
- if (parameters.data.radioButton) {
83
- return new RadioButtonWidgetAnnotationElement(parameters);
84
- } else if (parameters.data.checkBox) {
85
- return new CheckboxWidgetAnnotationElement(parameters);
86
- }
87
-
88
- return new PushButtonWidgetAnnotationElement(parameters);
89
-
90
- case 'Ch':
91
- return new ChoiceWidgetAnnotationElement(parameters);
92
- }
62
+ case "Ch":
63
+ return new ChoiceWidgetAnnotationElement(parameters);
64
+ }
93
65
 
94
- return new WidgetAnnotationElement(parameters);
66
+ return new WidgetAnnotationElement(parameters);
95
67
 
96
- case _util.AnnotationType.POPUP:
97
- return new PopupAnnotationElement(parameters);
68
+ case _util.AnnotationType.POPUP:
69
+ return new PopupAnnotationElement(parameters);
98
70
 
99
- case _util.AnnotationType.FREETEXT:
100
- return new FreeTextAnnotationElement(parameters);
71
+ case _util.AnnotationType.FREETEXT:
72
+ return new FreeTextAnnotationElement(parameters);
101
73
 
102
- case _util.AnnotationType.LINE:
103
- return new LineAnnotationElement(parameters);
74
+ case _util.AnnotationType.LINE:
75
+ return new LineAnnotationElement(parameters);
104
76
 
105
- case _util.AnnotationType.SQUARE:
106
- return new SquareAnnotationElement(parameters);
77
+ case _util.AnnotationType.SQUARE:
78
+ return new SquareAnnotationElement(parameters);
107
79
 
108
- case _util.AnnotationType.CIRCLE:
109
- return new CircleAnnotationElement(parameters);
80
+ case _util.AnnotationType.CIRCLE:
81
+ return new CircleAnnotationElement(parameters);
110
82
 
111
- case _util.AnnotationType.POLYLINE:
112
- return new PolylineAnnotationElement(parameters);
83
+ case _util.AnnotationType.POLYLINE:
84
+ return new PolylineAnnotationElement(parameters);
113
85
 
114
- case _util.AnnotationType.CARET:
115
- return new CaretAnnotationElement(parameters);
86
+ case _util.AnnotationType.CARET:
87
+ return new CaretAnnotationElement(parameters);
116
88
 
117
- case _util.AnnotationType.INK:
118
- return new InkAnnotationElement(parameters);
89
+ case _util.AnnotationType.INK:
90
+ return new InkAnnotationElement(parameters);
119
91
 
120
- case _util.AnnotationType.POLYGON:
121
- return new PolygonAnnotationElement(parameters);
92
+ case _util.AnnotationType.POLYGON:
93
+ return new PolygonAnnotationElement(parameters);
122
94
 
123
- case _util.AnnotationType.HIGHLIGHT:
124
- return new HighlightAnnotationElement(parameters);
95
+ case _util.AnnotationType.HIGHLIGHT:
96
+ return new HighlightAnnotationElement(parameters);
125
97
 
126
- case _util.AnnotationType.UNDERLINE:
127
- return new UnderlineAnnotationElement(parameters);
98
+ case _util.AnnotationType.UNDERLINE:
99
+ return new UnderlineAnnotationElement(parameters);
128
100
 
129
- case _util.AnnotationType.SQUIGGLY:
130
- return new SquigglyAnnotationElement(parameters);
101
+ case _util.AnnotationType.SQUIGGLY:
102
+ return new SquigglyAnnotationElement(parameters);
131
103
 
132
- case _util.AnnotationType.STRIKEOUT:
133
- return new StrikeOutAnnotationElement(parameters);
104
+ case _util.AnnotationType.STRIKEOUT:
105
+ return new StrikeOutAnnotationElement(parameters);
134
106
 
135
- case _util.AnnotationType.STAMP:
136
- return new StampAnnotationElement(parameters);
107
+ case _util.AnnotationType.STAMP:
108
+ return new StampAnnotationElement(parameters);
137
109
 
138
- case _util.AnnotationType.FILEATTACHMENT:
139
- return new FileAttachmentAnnotationElement(parameters);
110
+ case _util.AnnotationType.FILEATTACHMENT:
111
+ return new FileAttachmentAnnotationElement(parameters);
140
112
 
141
- default:
142
- return new AnnotationElement(parameters);
143
- }
113
+ default:
114
+ return new AnnotationElement(parameters);
144
115
  }
145
- }]);
146
-
147
- return AnnotationElementFactory;
148
- }();
149
-
150
- var AnnotationElement =
151
- /*#__PURE__*/
152
- function () {
153
- function AnnotationElement(parameters) {
154
- var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
155
- var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
116
+ }
156
117
 
157
- _classCallCheck(this, AnnotationElement);
118
+ }
158
119
 
120
+ class AnnotationElement {
121
+ constructor(parameters, isRenderable = false, ignoreBorder = false) {
159
122
  this.isRenderable = isRenderable;
160
123
  this.data = parameters.data;
161
124
  this.layer = parameters.layer;
@@ -166,523 +129,455 @@ function () {
166
129
  this.imageResourcesPath = parameters.imageResourcesPath;
167
130
  this.renderInteractiveForms = parameters.renderInteractiveForms;
168
131
  this.svgFactory = parameters.svgFactory;
132
+ this.annotationStorage = parameters.annotationStorage;
169
133
 
170
134
  if (isRenderable) {
171
135
  this.container = this._createContainer(ignoreBorder);
172
136
  }
173
137
  }
174
138
 
175
- _createClass(AnnotationElement, [{
176
- key: "_createContainer",
177
- value: function _createContainer() {
178
- var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
179
- var data = this.data,
139
+ _createContainer(ignoreBorder = false) {
140
+ const data = this.data,
180
141
  page = this.page,
181
142
  viewport = this.viewport;
182
- var container = document.createElement('section');
183
- var width = data.rect[2] - data.rect[0];
184
- var height = data.rect[3] - data.rect[1];
185
- container.setAttribute('data-annotation-id', data.id);
143
+ const container = document.createElement("section");
144
+ let width = data.rect[2] - data.rect[0];
145
+ let height = data.rect[3] - data.rect[1];
146
+ container.setAttribute("data-annotation-id", data.id);
186
147
 
187
- var 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]]);
148
+ 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]]);
188
149
 
189
- container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';
190
- container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';
150
+ container.style.transform = `matrix(${viewport.transform.join(",")})`;
151
+ container.style.transformOrigin = `-${rect[0]}px -${rect[1]}px`;
191
152
 
192
- if (!ignoreBorder && data.borderStyle.width > 0) {
193
- container.style.borderWidth = data.borderStyle.width + 'px';
153
+ if (!ignoreBorder && data.borderStyle.width > 0) {
154
+ container.style.borderWidth = `${data.borderStyle.width}px`;
194
155
 
195
- if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
196
- width = width - 2 * data.borderStyle.width;
197
- height = height - 2 * data.borderStyle.width;
198
- }
199
-
200
- var horizontalRadius = data.borderStyle.horizontalCornerRadius;
201
- var verticalRadius = data.borderStyle.verticalCornerRadius;
156
+ if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
157
+ width = width - 2 * data.borderStyle.width;
158
+ height = height - 2 * data.borderStyle.width;
159
+ }
202
160
 
203
- if (horizontalRadius > 0 || verticalRadius > 0) {
204
- var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
205
- container.style.borderRadius = radius;
206
- }
161
+ const horizontalRadius = data.borderStyle.horizontalCornerRadius;
162
+ const verticalRadius = data.borderStyle.verticalCornerRadius;
207
163
 
208
- switch (data.borderStyle.style) {
209
- case _util.AnnotationBorderStyleType.SOLID:
210
- container.style.borderStyle = 'solid';
211
- break;
164
+ if (horizontalRadius > 0 || verticalRadius > 0) {
165
+ const radius = `${horizontalRadius}px / ${verticalRadius}px`;
166
+ container.style.borderRadius = radius;
167
+ }
212
168
 
213
- case _util.AnnotationBorderStyleType.DASHED:
214
- container.style.borderStyle = 'dashed';
215
- break;
169
+ switch (data.borderStyle.style) {
170
+ case _util.AnnotationBorderStyleType.SOLID:
171
+ container.style.borderStyle = "solid";
172
+ break;
216
173
 
217
- case _util.AnnotationBorderStyleType.BEVELED:
218
- (0, _util.warn)('Unimplemented border style: beveled');
219
- break;
174
+ case _util.AnnotationBorderStyleType.DASHED:
175
+ container.style.borderStyle = "dashed";
176
+ break;
220
177
 
221
- case _util.AnnotationBorderStyleType.INSET:
222
- (0, _util.warn)('Unimplemented border style: inset');
223
- break;
178
+ case _util.AnnotationBorderStyleType.BEVELED:
179
+ (0, _util.warn)("Unimplemented border style: beveled");
180
+ break;
224
181
 
225
- case _util.AnnotationBorderStyleType.UNDERLINE:
226
- container.style.borderBottomStyle = 'solid';
227
- break;
182
+ case _util.AnnotationBorderStyleType.INSET:
183
+ (0, _util.warn)("Unimplemented border style: inset");
184
+ break;
228
185
 
229
- default:
230
- break;
231
- }
186
+ case _util.AnnotationBorderStyleType.UNDERLINE:
187
+ container.style.borderBottomStyle = "solid";
188
+ break;
232
189
 
233
- if (data.color) {
234
- container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
235
- } else {
236
- container.style.borderWidth = 0;
237
- }
190
+ default:
191
+ break;
238
192
  }
239
193
 
240
- container.style.left = rect[0] + 'px';
241
- container.style.top = rect[1] + 'px';
242
- container.style.width = width + 'px';
243
- container.style.height = height + 'px';
244
- return container;
245
- }
246
- }, {
247
- key: "_createPopup",
248
- value: function _createPopup(container, trigger, data) {
249
- if (!trigger) {
250
- trigger = document.createElement('div');
251
- trigger.style.height = container.style.height;
252
- trigger.style.width = container.style.width;
253
- container.appendChild(trigger);
194
+ if (data.color) {
195
+ container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
196
+ } else {
197
+ container.style.borderWidth = 0;
254
198
  }
255
-
256
- var popupElement = new PopupElement({
257
- container: container,
258
- trigger: trigger,
259
- color: data.color,
260
- title: data.title,
261
- modificationDate: data.modificationDate,
262
- contents: data.contents,
263
- hideWrapper: true
264
- });
265
- var popup = popupElement.render();
266
- popup.style.left = container.style.width;
267
- container.appendChild(popup);
268
199
  }
269
- }, {
270
- key: "render",
271
- value: function render() {
272
- (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
200
+
201
+ container.style.left = `${rect[0]}px`;
202
+ container.style.top = `${rect[1]}px`;
203
+ container.style.width = `${width}px`;
204
+ container.style.height = `${height}px`;
205
+ return container;
206
+ }
207
+
208
+ _createPopup(container, trigger, data) {
209
+ if (!trigger) {
210
+ trigger = document.createElement("div");
211
+ trigger.style.height = container.style.height;
212
+ trigger.style.width = container.style.width;
213
+ container.appendChild(trigger);
273
214
  }
274
- }]);
275
215
 
276
- return AnnotationElement;
277
- }();
216
+ const popupElement = new PopupElement({
217
+ container,
218
+ trigger,
219
+ color: data.color,
220
+ title: data.title,
221
+ modificationDate: data.modificationDate,
222
+ contents: data.contents,
223
+ hideWrapper: true
224
+ });
225
+ const popup = popupElement.render();
226
+ popup.style.left = container.style.width;
227
+ container.appendChild(popup);
228
+ }
278
229
 
279
- var LinkAnnotationElement =
280
- /*#__PURE__*/
281
- function (_AnnotationElement) {
282
- _inherits(LinkAnnotationElement, _AnnotationElement);
230
+ render() {
231
+ (0, _util.unreachable)("Abstract method `AnnotationElement.render` called");
232
+ }
283
233
 
284
- function LinkAnnotationElement(parameters) {
285
- _classCallCheck(this, LinkAnnotationElement);
234
+ }
286
235
 
287
- var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
288
- return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));
236
+ class LinkAnnotationElement extends AnnotationElement {
237
+ constructor(parameters) {
238
+ const isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
239
+ super(parameters, isRenderable);
289
240
  }
290
241
 
291
- _createClass(LinkAnnotationElement, [{
292
- key: "render",
293
- value: function render() {
294
- this.container.className = 'linkAnnotation';
295
- var data = this.data,
296
- linkService = this.linkService;
297
- var link = document.createElement('a');
242
+ render() {
243
+ this.container.className = "linkAnnotation";
244
+ const {
245
+ data,
246
+ linkService
247
+ } = this;
248
+ const link = document.createElement("a");
249
+
250
+ if (data.url) {
298
251
  (0, _display_utils.addLinkAttributes)(link, {
299
252
  url: data.url,
300
253
  target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
301
- rel: linkService.externalLinkRel
254
+ rel: linkService.externalLinkRel,
255
+ enabled: linkService.externalLinkEnabled
302
256
  });
303
-
304
- if (!data.url) {
305
- if (data.action) {
306
- this._bindNamedAction(link, data.action);
307
- } else {
308
- this._bindLink(link, data.dest);
309
- }
310
- }
311
-
312
- this.container.appendChild(link);
313
- return this.container;
257
+ } else if (data.action) {
258
+ this._bindNamedAction(link, data.action);
259
+ } else {
260
+ this._bindLink(link, data.dest);
314
261
  }
315
- }, {
316
- key: "_bindLink",
317
- value: function _bindLink(link, destination) {
318
- var _this = this;
319
-
320
- link.href = this.linkService.getDestinationHash(destination);
321
262
 
322
- link.onclick = function () {
323
- if (destination) {
324
- _this.linkService.navigateTo(destination);
325
- }
263
+ this.container.appendChild(link);
264
+ return this.container;
265
+ }
326
266
 
327
- return false;
328
- };
267
+ _bindLink(link, destination) {
268
+ link.href = this.linkService.getDestinationHash(destination);
329
269
 
270
+ link.onclick = () => {
330
271
  if (destination) {
331
- link.className = 'internalLink';
272
+ this.linkService.navigateTo(destination);
332
273
  }
333
- }
334
- }, {
335
- key: "_bindNamedAction",
336
- value: function _bindNamedAction(link, action) {
337
- var _this2 = this;
338
-
339
- link.href = this.linkService.getAnchorUrl('');
340
274
 
341
- link.onclick = function () {
342
- _this2.linkService.executeNamedAction(action);
275
+ return false;
276
+ };
343
277
 
344
- return false;
345
- };
346
-
347
- link.className = 'internalLink';
278
+ if (destination) {
279
+ link.className = "internalLink";
348
280
  }
349
- }]);
350
-
351
- return LinkAnnotationElement;
352
- }(AnnotationElement);
281
+ }
353
282
 
354
- var TextAnnotationElement =
355
- /*#__PURE__*/
356
- function (_AnnotationElement2) {
357
- _inherits(TextAnnotationElement, _AnnotationElement2);
283
+ _bindNamedAction(link, action) {
284
+ link.href = this.linkService.getAnchorUrl("");
358
285
 
359
- function TextAnnotationElement(parameters) {
360
- _classCallCheck(this, TextAnnotationElement);
286
+ link.onclick = () => {
287
+ this.linkService.executeNamedAction(action);
288
+ return false;
289
+ };
361
290
 
362
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
363
- return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));
291
+ link.className = "internalLink";
364
292
  }
365
293
 
366
- _createClass(TextAnnotationElement, [{
367
- key: "render",
368
- value: function render() {
369
- this.container.className = 'textAnnotation';
370
- var image = document.createElement('img');
371
- image.style.height = this.container.style.height;
372
- image.style.width = this.container.style.width;
373
- image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
374
- image.alt = '[{{type}} Annotation]';
375
- image.dataset.l10nId = 'text_annotation_type';
376
- image.dataset.l10nArgs = JSON.stringify({
377
- type: this.data.name
378
- });
294
+ }
379
295
 
380
- if (!this.data.hasPopup) {
381
- this._createPopup(this.container, image, this.data);
382
- }
296
+ class TextAnnotationElement extends AnnotationElement {
297
+ constructor(parameters) {
298
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
299
+ super(parameters, isRenderable);
300
+ }
383
301
 
384
- this.container.appendChild(image);
385
- return this.container;
302
+ render() {
303
+ this.container.className = "textAnnotation";
304
+ const image = document.createElement("img");
305
+ image.style.height = this.container.style.height;
306
+ image.style.width = this.container.style.width;
307
+ image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
308
+ image.alt = "[{{type}} Annotation]";
309
+ image.dataset.l10nId = "text_annotation_type";
310
+ image.dataset.l10nArgs = JSON.stringify({
311
+ type: this.data.name
312
+ });
313
+
314
+ if (!this.data.hasPopup) {
315
+ this._createPopup(this.container, image, this.data);
386
316
  }
387
- }]);
388
-
389
- return TextAnnotationElement;
390
- }(AnnotationElement);
391
-
392
- var WidgetAnnotationElement =
393
- /*#__PURE__*/
394
- function (_AnnotationElement3) {
395
- _inherits(WidgetAnnotationElement, _AnnotationElement3);
396
-
397
- function WidgetAnnotationElement() {
398
- _classCallCheck(this, WidgetAnnotationElement);
399
317
 
400
- return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));
318
+ this.container.appendChild(image);
319
+ return this.container;
401
320
  }
402
321
 
403
- _createClass(WidgetAnnotationElement, [{
404
- key: "render",
405
- value: function render() {
406
- return this.container;
407
- }
408
- }]);
322
+ }
409
323
 
410
- return WidgetAnnotationElement;
411
- }(AnnotationElement);
412
-
413
- var TextWidgetAnnotationElement =
414
- /*#__PURE__*/
415
- function (_WidgetAnnotationElem) {
416
- _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
324
+ class WidgetAnnotationElement extends AnnotationElement {
325
+ render() {
326
+ return this.container;
327
+ }
417
328
 
418
- function TextWidgetAnnotationElement(parameters) {
419
- _classCallCheck(this, TextWidgetAnnotationElement);
329
+ }
420
330
 
421
- var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
422
- return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));
331
+ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
332
+ constructor(parameters) {
333
+ const isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
334
+ super(parameters, isRenderable);
423
335
  }
424
336
 
425
- _createClass(TextWidgetAnnotationElement, [{
426
- key: "render",
427
- value: function render() {
428
- var TEXT_ALIGNMENT = ['left', 'center', 'right'];
429
- this.container.className = 'textWidgetAnnotation';
430
- var element = null;
431
-
432
- if (this.renderInteractiveForms) {
433
- if (this.data.multiLine) {
434
- element = document.createElement('textarea');
435
- element.textContent = this.data.fieldValue;
436
- } else {
437
- element = document.createElement('input');
438
- element.type = 'text';
439
- element.setAttribute('value', this.data.fieldValue);
440
- }
441
-
442
- element.disabled = this.data.readOnly;
337
+ render() {
338
+ const TEXT_ALIGNMENT = ["left", "center", "right"];
339
+ const storage = this.annotationStorage;
340
+ const id = this.data.id;
341
+ this.container.className = "textWidgetAnnotation";
342
+ let element = null;
443
343
 
444
- if (this.data.maxLen !== null) {
445
- element.maxLength = this.data.maxLen;
446
- }
344
+ if (this.renderInteractiveForms) {
345
+ const textContent = storage.getOrCreateValue(id, this.data.fieldValue);
447
346
 
448
- if (this.data.comb) {
449
- var fieldWidth = this.data.rect[2] - this.data.rect[0];
450
- var combWidth = fieldWidth / this.data.maxLen;
451
- element.classList.add('comb');
452
- element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
453
- }
347
+ if (this.data.multiLine) {
348
+ element = document.createElement("textarea");
349
+ element.textContent = textContent;
454
350
  } else {
455
- element = document.createElement('div');
456
- element.textContent = this.data.fieldValue;
457
- element.style.verticalAlign = 'middle';
458
- element.style.display = 'table-cell';
459
- var font = null;
460
-
461
- if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
462
- font = this.page.commonObjs.get(this.data.fontRefName);
463
- }
464
-
465
- this._setTextStyle(element, font);
351
+ element = document.createElement("input");
352
+ element.type = "text";
353
+ element.setAttribute("value", textContent);
466
354
  }
467
355
 
468
- if (this.data.textAlignment !== null) {
469
- element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
356
+ element.addEventListener("input", function (event) {
357
+ storage.setValue(id, event.target.value);
358
+ });
359
+ element.disabled = this.data.readOnly;
360
+ element.name = this.data.fieldName;
361
+
362
+ if (this.data.maxLen !== null) {
363
+ element.maxLength = this.data.maxLen;
470
364
  }
471
365
 
472
- this.container.appendChild(element);
473
- return this.container;
474
- }
475
- }, {
476
- key: "_setTextStyle",
477
- value: function _setTextStyle(element, font) {
478
- var style = element.style;
479
- style.fontSize = this.data.fontSize + 'px';
480
- style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
481
-
482
- if (!font) {
483
- return;
366
+ if (this.data.comb) {
367
+ const fieldWidth = this.data.rect[2] - this.data.rect[0];
368
+ const combWidth = fieldWidth / this.data.maxLen;
369
+ element.classList.add("comb");
370
+ element.style.letterSpacing = `calc(${combWidth}px - 1ch)`;
371
+ }
372
+ } else {
373
+ element = document.createElement("div");
374
+ element.textContent = this.data.fieldValue;
375
+ element.style.verticalAlign = "middle";
376
+ element.style.display = "table-cell";
377
+ let font = null;
378
+
379
+ if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
380
+ font = this.page.commonObjs.get(this.data.fontRefName);
484
381
  }
485
382
 
486
- style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
487
- style.fontStyle = font.italic ? 'italic' : 'normal';
488
- var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
489
- var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
490
- style.fontFamily = fontFamily + fallbackName;
383
+ this._setTextStyle(element, font);
491
384
  }
492
- }]);
493
-
494
- return TextWidgetAnnotationElement;
495
- }(WidgetAnnotationElement);
496
385
 
497
- var CheckboxWidgetAnnotationElement =
498
- /*#__PURE__*/
499
- function (_WidgetAnnotationElem2) {
500
- _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
501
-
502
- function CheckboxWidgetAnnotationElement(parameters) {
503
- _classCallCheck(this, CheckboxWidgetAnnotationElement);
386
+ if (this.data.textAlignment !== null) {
387
+ element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
388
+ }
504
389
 
505
- return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
390
+ this.container.appendChild(element);
391
+ return this.container;
506
392
  }
507
393
 
508
- _createClass(CheckboxWidgetAnnotationElement, [{
509
- key: "render",
510
- value: function render() {
511
- this.container.className = 'buttonWidgetAnnotation checkBox';
512
- var element = document.createElement('input');
513
- element.disabled = this.data.readOnly;
514
- element.type = 'checkbox';
515
-
516
- if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
517
- element.setAttribute('checked', true);
518
- }
394
+ _setTextStyle(element, font) {
395
+ const style = element.style;
396
+ style.fontSize = `${this.data.fontSize}px`;
397
+ style.direction = this.data.fontDirection < 0 ? "rtl" : "ltr";
519
398
 
520
- this.container.appendChild(element);
521
- return this.container;
399
+ if (!font) {
400
+ return;
522
401
  }
523
- }]);
524
-
525
- return CheckboxWidgetAnnotationElement;
526
- }(WidgetAnnotationElement);
527
402
 
528
- var RadioButtonWidgetAnnotationElement =
529
- /*#__PURE__*/
530
- function (_WidgetAnnotationElem3) {
531
- _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
403
+ let bold = "normal";
532
404
 
533
- function RadioButtonWidgetAnnotationElement(parameters) {
534
- _classCallCheck(this, RadioButtonWidgetAnnotationElement);
405
+ if (font.black) {
406
+ bold = "900";
407
+ } else if (font.bold) {
408
+ bold = "bold";
409
+ }
535
410
 
536
- return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
411
+ style.fontWeight = bold;
412
+ style.fontStyle = font.italic ? "italic" : "normal";
413
+ const fontFamily = font.loadedName ? `"${font.loadedName}", ` : "";
414
+ const fallbackName = font.fallbackName || "Helvetica, sans-serif";
415
+ style.fontFamily = fontFamily + fallbackName;
537
416
  }
538
417
 
539
- _createClass(RadioButtonWidgetAnnotationElement, [{
540
- key: "render",
541
- value: function render() {
542
- this.container.className = 'buttonWidgetAnnotation radioButton';
543
- var element = document.createElement('input');
544
- element.disabled = this.data.readOnly;
545
- element.type = 'radio';
546
- element.name = this.data.fieldName;
418
+ }
547
419
 
548
- if (this.data.fieldValue === this.data.buttonValue) {
549
- element.setAttribute('checked', true);
550
- }
420
+ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
421
+ constructor(parameters) {
422
+ super(parameters, parameters.renderInteractiveForms);
423
+ }
551
424
 
552
- this.container.appendChild(element);
553
- return this.container;
425
+ render() {
426
+ const storage = this.annotationStorage;
427
+ const data = this.data;
428
+ const id = data.id;
429
+ const value = storage.getOrCreateValue(id, data.fieldValue && data.fieldValue !== "Off");
430
+ this.container.className = "buttonWidgetAnnotation checkBox";
431
+ const element = document.createElement("input");
432
+ element.disabled = data.readOnly;
433
+ element.type = "checkbox";
434
+ element.name = this.data.fieldName;
435
+
436
+ if (value) {
437
+ element.setAttribute("checked", true);
554
438
  }
555
- }]);
556
-
557
- return RadioButtonWidgetAnnotationElement;
558
- }(WidgetAnnotationElement);
559
439
 
560
- var PushButtonWidgetAnnotationElement =
561
- /*#__PURE__*/
562
- function (_LinkAnnotationElemen) {
563
- _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
440
+ element.addEventListener("change", function (event) {
441
+ storage.setValue(id, event.target.checked);
442
+ });
443
+ this.container.appendChild(element);
444
+ return this.container;
445
+ }
564
446
 
565
- function PushButtonWidgetAnnotationElement() {
566
- _classCallCheck(this, PushButtonWidgetAnnotationElement);
447
+ }
567
448
 
568
- return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));
449
+ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
450
+ constructor(parameters) {
451
+ super(parameters, parameters.renderInteractiveForms);
569
452
  }
570
453
 
571
- _createClass(PushButtonWidgetAnnotationElement, [{
572
- key: "render",
573
- value: function render() {
574
- var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
575
-
576
- container.className = 'buttonWidgetAnnotation pushButton';
577
- return container;
454
+ render() {
455
+ this.container.className = "buttonWidgetAnnotation radioButton";
456
+ const storage = this.annotationStorage;
457
+ const data = this.data;
458
+ const id = data.id;
459
+ const value = storage.getOrCreateValue(id, data.fieldValue === data.buttonValue);
460
+ const element = document.createElement("input");
461
+ element.disabled = data.readOnly;
462
+ element.type = "radio";
463
+ element.name = data.fieldName;
464
+
465
+ if (value) {
466
+ element.setAttribute("checked", true);
578
467
  }
579
- }]);
580
-
581
- return PushButtonWidgetAnnotationElement;
582
- }(LinkAnnotationElement);
583
468
 
584
- var ChoiceWidgetAnnotationElement =
585
- /*#__PURE__*/
586
- function (_WidgetAnnotationElem4) {
587
- _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
469
+ element.addEventListener("change", function (event) {
470
+ const name = event.target.name;
588
471
 
589
- function ChoiceWidgetAnnotationElement(parameters) {
590
- _classCallCheck(this, ChoiceWidgetAnnotationElement);
472
+ for (const radio of document.getElementsByName(name)) {
473
+ if (radio !== event.target) {
474
+ storage.setValue(radio.parentNode.getAttribute("data-annotation-id"), false);
475
+ }
476
+ }
591
477
 
592
- return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
478
+ storage.setValue(id, event.target.checked);
479
+ });
480
+ this.container.appendChild(element);
481
+ return this.container;
593
482
  }
594
483
 
595
- _createClass(ChoiceWidgetAnnotationElement, [{
596
- key: "render",
597
- value: function render() {
598
- this.container.className = 'choiceWidgetAnnotation';
599
- var selectElement = document.createElement('select');
600
- selectElement.disabled = this.data.readOnly;
484
+ }
601
485
 
602
- if (!this.data.combo) {
603
- selectElement.size = this.data.options.length;
486
+ class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
487
+ render() {
488
+ const container = super.render();
489
+ container.className = "buttonWidgetAnnotation pushButton";
490
+ return container;
491
+ }
604
492
 
605
- if (this.data.multiSelect) {
606
- selectElement.multiple = true;
607
- }
608
- }
493
+ }
609
494
 
610
- for (var i = 0, ii = this.data.options.length; i < ii; i++) {
611
- var option = this.data.options[i];
612
- var optionElement = document.createElement('option');
613
- optionElement.textContent = option.displayValue;
614
- optionElement.value = option.exportValue;
495
+ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
496
+ constructor(parameters) {
497
+ super(parameters, parameters.renderInteractiveForms);
498
+ }
615
499
 
616
- if (this.data.fieldValue.includes(option.displayValue)) {
617
- optionElement.setAttribute('selected', true);
618
- }
500
+ render() {
501
+ this.container.className = "choiceWidgetAnnotation";
502
+ const storage = this.annotationStorage;
503
+ const id = this.data.id;
504
+ storage.getOrCreateValue(id, this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : null);
505
+ const selectElement = document.createElement("select");
506
+ selectElement.disabled = this.data.readOnly;
507
+ selectElement.name = this.data.fieldName;
619
508
 
620
- selectElement.appendChild(optionElement);
621
- }
509
+ if (!this.data.combo) {
510
+ selectElement.size = this.data.options.length;
622
511
 
623
- this.container.appendChild(selectElement);
624
- return this.container;
512
+ if (this.data.multiSelect) {
513
+ selectElement.multiple = true;
514
+ }
625
515
  }
626
- }]);
627
516
 
628
- return ChoiceWidgetAnnotationElement;
629
- }(WidgetAnnotationElement);
517
+ for (const option of this.data.options) {
518
+ const optionElement = document.createElement("option");
519
+ optionElement.textContent = option.displayValue;
520
+ optionElement.value = option.exportValue;
630
521
 
631
- var PopupAnnotationElement =
632
- /*#__PURE__*/
633
- function (_AnnotationElement4) {
634
- _inherits(PopupAnnotationElement, _AnnotationElement4);
522
+ if (this.data.fieldValue.includes(option.exportValue)) {
523
+ optionElement.setAttribute("selected", true);
524
+ }
635
525
 
636
- function PopupAnnotationElement(parameters) {
637
- _classCallCheck(this, PopupAnnotationElement);
526
+ selectElement.appendChild(optionElement);
527
+ }
638
528
 
639
- var isRenderable = !!(parameters.data.title || parameters.data.contents);
640
- return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));
529
+ selectElement.addEventListener("input", function (event) {
530
+ const options = event.target.options;
531
+ const value = options[options.selectedIndex].value;
532
+ storage.setValue(id, value);
533
+ });
534
+ this.container.appendChild(selectElement);
535
+ return this.container;
641
536
  }
642
537
 
643
- _createClass(PopupAnnotationElement, [{
644
- key: "render",
645
- value: function render() {
646
- var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
647
- this.container.className = 'popupAnnotation';
538
+ }
648
539
 
649
- if (IGNORE_TYPES.includes(this.data.parentType)) {
650
- return this.container;
651
- }
540
+ class PopupAnnotationElement extends AnnotationElement {
541
+ constructor(parameters) {
542
+ const isRenderable = !!(parameters.data.title || parameters.data.contents);
543
+ super(parameters, isRenderable);
544
+ }
652
545
 
653
- var selector = '[data-annotation-id="' + this.data.parentId + '"]';
654
- var parentElement = this.layer.querySelector(selector);
546
+ render() {
547
+ const IGNORE_TYPES = ["Line", "Square", "Circle", "PolyLine", "Polygon", "Ink"];
548
+ this.container.className = "popupAnnotation";
655
549
 
656
- if (!parentElement) {
657
- return this.container;
658
- }
550
+ if (IGNORE_TYPES.includes(this.data.parentType)) {
551
+ return this.container;
552
+ }
659
553
 
660
- var popup = new PopupElement({
661
- container: this.container,
662
- trigger: parentElement,
663
- color: this.data.color,
664
- title: this.data.title,
665
- modificationDate: this.data.modificationDate,
666
- contents: this.data.contents
667
- });
668
- var parentLeft = parseFloat(parentElement.style.left);
669
- var parentWidth = parseFloat(parentElement.style.width);
670
- this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;
671
- this.container.style.left = parentLeft + parentWidth + 'px';
672
- this.container.appendChild(popup.render());
554
+ const selector = `[data-annotation-id="${this.data.parentId}"]`;
555
+ const parentElement = this.layer.querySelector(selector);
556
+
557
+ if (!parentElement) {
673
558
  return this.container;
674
559
  }
675
- }]);
676
560
 
677
- return PopupAnnotationElement;
678
- }(AnnotationElement);
561
+ const popup = new PopupElement({
562
+ container: this.container,
563
+ trigger: parentElement,
564
+ color: this.data.color,
565
+ title: this.data.title,
566
+ modificationDate: this.data.modificationDate,
567
+ contents: this.data.contents
568
+ });
569
+ const parentLeft = parseFloat(parentElement.style.left);
570
+ const parentWidth = parseFloat(parentElement.style.width);
571
+ this.container.style.transformOrigin = `-${parentLeft + parentWidth}px -${parentElement.style.top}`;
572
+ this.container.style.left = `${parentLeft + parentWidth}px`;
573
+ this.container.appendChild(popup.render());
574
+ return this.container;
575
+ }
679
576
 
680
- var PopupElement =
681
- /*#__PURE__*/
682
- function () {
683
- function PopupElement(parameters) {
684
- _classCallCheck(this, PopupElement);
577
+ }
685
578
 
579
+ class PopupElement {
580
+ constructor(parameters) {
686
581
  this.container = parameters.container;
687
582
  this.trigger = parameters.trigger;
688
583
  this.color = parameters.color;
@@ -693,669 +588,505 @@ function () {
693
588
  this.pinned = false;
694
589
  }
695
590
 
696
- _createClass(PopupElement, [{
697
- key: "render",
698
- value: function render() {
699
- var BACKGROUND_ENLIGHT = 0.7;
700
- var wrapper = document.createElement('div');
701
- wrapper.className = 'popupWrapper';
702
- this.hideElement = this.hideWrapper ? wrapper : this.container;
703
- this.hideElement.setAttribute('hidden', true);
704
- var popup = document.createElement('div');
705
- popup.className = 'popup';
706
- var color = this.color;
707
-
708
- if (color) {
709
- var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
710
- var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
711
- var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
712
- popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
713
- }
591
+ render() {
592
+ const BACKGROUND_ENLIGHT = 0.7;
593
+ const wrapper = document.createElement("div");
594
+ wrapper.className = "popupWrapper";
595
+ this.hideElement = this.hideWrapper ? wrapper : this.container;
596
+ this.hideElement.setAttribute("hidden", true);
597
+ const popup = document.createElement("div");
598
+ popup.className = "popup";
599
+ const color = this.color;
600
+
601
+ if (color) {
602
+ const r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
603
+ const g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
604
+ const b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
605
+ popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
606
+ }
714
607
 
715
- var title = document.createElement('h1');
716
- title.textContent = this.title;
717
- popup.appendChild(title);
718
-
719
- var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
720
-
721
- if (dateObject) {
722
- var modificationDate = document.createElement('span');
723
- modificationDate.textContent = '{{date}}, {{time}}';
724
- modificationDate.dataset.l10nId = 'annotation_date_string';
725
- modificationDate.dataset.l10nArgs = JSON.stringify({
726
- date: dateObject.toLocaleDateString(),
727
- time: dateObject.toLocaleTimeString()
728
- });
729
- popup.appendChild(modificationDate);
730
- }
608
+ const title = document.createElement("h1");
609
+ title.textContent = this.title;
610
+ popup.appendChild(title);
731
611
 
732
- var contents = this._formatContents(this.contents);
612
+ const dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
733
613
 
734
- popup.appendChild(contents);
735
- this.trigger.addEventListener('click', this._toggle.bind(this));
736
- this.trigger.addEventListener('mouseover', this._show.bind(this, false));
737
- this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
738
- popup.addEventListener('click', this._hide.bind(this, true));
739
- wrapper.appendChild(popup);
740
- return wrapper;
614
+ if (dateObject) {
615
+ const modificationDate = document.createElement("span");
616
+ modificationDate.textContent = "{{date}}, {{time}}";
617
+ modificationDate.dataset.l10nId = "annotation_date_string";
618
+ modificationDate.dataset.l10nArgs = JSON.stringify({
619
+ date: dateObject.toLocaleDateString(),
620
+ time: dateObject.toLocaleTimeString()
621
+ });
622
+ popup.appendChild(modificationDate);
741
623
  }
742
- }, {
743
- key: "_formatContents",
744
- value: function _formatContents(contents) {
745
- var p = document.createElement('p');
746
- var lines = contents.split(/(?:\r\n?|\n)/);
747
-
748
- for (var i = 0, ii = lines.length; i < ii; ++i) {
749
- var line = lines[i];
750
- p.appendChild(document.createTextNode(line));
751
-
752
- if (i < ii - 1) {
753
- p.appendChild(document.createElement('br'));
754
- }
755
- }
756
624
 
757
- return p;
758
- }
759
- }, {
760
- key: "_toggle",
761
- value: function _toggle() {
762
- if (this.pinned) {
763
- this._hide(true);
764
- } else {
765
- this._show(true);
766
- }
767
- }
768
- }, {
769
- key: "_show",
770
- value: function _show() {
771
- var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
625
+ const contents = this._formatContents(this.contents);
772
626
 
773
- if (pin) {
774
- this.pinned = true;
775
- }
627
+ popup.appendChild(contents);
628
+ this.trigger.addEventListener("click", this._toggle.bind(this));
629
+ this.trigger.addEventListener("mouseover", this._show.bind(this, false));
630
+ this.trigger.addEventListener("mouseout", this._hide.bind(this, false));
631
+ popup.addEventListener("click", this._hide.bind(this, true));
632
+ wrapper.appendChild(popup);
633
+ return wrapper;
634
+ }
776
635
 
777
- if (this.hideElement.hasAttribute('hidden')) {
778
- this.hideElement.removeAttribute('hidden');
779
- this.container.style.zIndex += 1;
780
- }
781
- }
782
- }, {
783
- key: "_hide",
784
- value: function _hide() {
785
- var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
636
+ _formatContents(contents) {
637
+ const p = document.createElement("p");
638
+ const lines = contents.split(/(?:\r\n?|\n)/);
786
639
 
787
- if (unpin) {
788
- this.pinned = false;
789
- }
640
+ for (let i = 0, ii = lines.length; i < ii; ++i) {
641
+ const line = lines[i];
642
+ p.appendChild(document.createTextNode(line));
790
643
 
791
- if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
792
- this.hideElement.setAttribute('hidden', true);
793
- this.container.style.zIndex -= 1;
644
+ if (i < ii - 1) {
645
+ p.appendChild(document.createElement("br"));
794
646
  }
795
647
  }
796
- }]);
797
648
 
798
- return PopupElement;
799
- }();
800
-
801
- var FreeTextAnnotationElement =
802
- /*#__PURE__*/
803
- function (_AnnotationElement5) {
804
- _inherits(FreeTextAnnotationElement, _AnnotationElement5);
805
-
806
- function FreeTextAnnotationElement(parameters) {
807
- _classCallCheck(this, FreeTextAnnotationElement);
808
-
809
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
810
- return _possibleConstructorReturn(this, _getPrototypeOf(FreeTextAnnotationElement).call(this, parameters, isRenderable, true));
649
+ return p;
811
650
  }
812
651
 
813
- _createClass(FreeTextAnnotationElement, [{
814
- key: "render",
815
- value: function render() {
816
- this.container.className = 'freeTextAnnotation';
817
-
818
- if (!this.data.hasPopup) {
819
- this._createPopup(this.container, null, this.data);
820
- }
821
-
822
- return this.container;
652
+ _toggle() {
653
+ if (this.pinned) {
654
+ this._hide(true);
655
+ } else {
656
+ this._show(true);
823
657
  }
824
- }]);
825
-
826
- return FreeTextAnnotationElement;
827
- }(AnnotationElement);
828
-
829
- var LineAnnotationElement =
830
- /*#__PURE__*/
831
- function (_AnnotationElement6) {
832
- _inherits(LineAnnotationElement, _AnnotationElement6);
833
-
834
- function LineAnnotationElement(parameters) {
835
- _classCallCheck(this, LineAnnotationElement);
836
-
837
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
838
- return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));
839
658
  }
840
659
 
841
- _createClass(LineAnnotationElement, [{
842
- key: "render",
843
- value: function render() {
844
- this.container.className = 'lineAnnotation';
845
- var data = this.data;
846
- var width = data.rect[2] - data.rect[0];
847
- var height = data.rect[3] - data.rect[1];
848
- var svg = this.svgFactory.create(width, height);
849
- var line = this.svgFactory.createElement('svg:line');
850
- line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
851
- line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
852
- line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
853
- line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
854
- line.setAttribute('stroke-width', data.borderStyle.width);
855
- line.setAttribute('stroke', 'transparent');
856
- svg.appendChild(line);
857
- this.container.append(svg);
858
-
859
- this._createPopup(this.container, line, data);
660
+ _show(pin = false) {
661
+ if (pin) {
662
+ this.pinned = true;
663
+ }
860
664
 
861
- return this.container;
665
+ if (this.hideElement.hasAttribute("hidden")) {
666
+ this.hideElement.removeAttribute("hidden");
667
+ this.container.style.zIndex += 1;
862
668
  }
863
- }]);
669
+ }
864
670
 
865
- return LineAnnotationElement;
866
- }(AnnotationElement);
671
+ _hide(unpin = true) {
672
+ if (unpin) {
673
+ this.pinned = false;
674
+ }
867
675
 
868
- var SquareAnnotationElement =
869
- /*#__PURE__*/
870
- function (_AnnotationElement7) {
871
- _inherits(SquareAnnotationElement, _AnnotationElement7);
676
+ if (!this.hideElement.hasAttribute("hidden") && !this.pinned) {
677
+ this.hideElement.setAttribute("hidden", true);
678
+ this.container.style.zIndex -= 1;
679
+ }
680
+ }
872
681
 
873
- function SquareAnnotationElement(parameters) {
874
- _classCallCheck(this, SquareAnnotationElement);
682
+ }
875
683
 
876
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
877
- return _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotationElement).call(this, parameters, isRenderable, true));
684
+ class FreeTextAnnotationElement extends AnnotationElement {
685
+ constructor(parameters) {
686
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
687
+ super(parameters, isRenderable, true);
878
688
  }
879
689
 
880
- _createClass(SquareAnnotationElement, [{
881
- key: "render",
882
- value: function render() {
883
- this.container.className = 'squareAnnotation';
884
- var data = this.data;
885
- var width = data.rect[2] - data.rect[0];
886
- var height = data.rect[3] - data.rect[1];
887
- var svg = this.svgFactory.create(width, height);
888
- var borderWidth = data.borderStyle.width;
889
- var square = this.svgFactory.createElement('svg:rect');
890
- square.setAttribute('x', borderWidth / 2);
891
- square.setAttribute('y', borderWidth / 2);
892
- square.setAttribute('width', width - borderWidth);
893
- square.setAttribute('height', height - borderWidth);
894
- square.setAttribute('stroke-width', borderWidth);
895
- square.setAttribute('stroke', 'transparent');
896
- square.setAttribute('fill', 'none');
897
- svg.appendChild(square);
898
- this.container.append(svg);
899
-
900
- this._createPopup(this.container, square, data);
690
+ render() {
691
+ this.container.className = "freeTextAnnotation";
901
692
 
902
- return this.container;
693
+ if (!this.data.hasPopup) {
694
+ this._createPopup(this.container, null, this.data);
903
695
  }
904
- }]);
905
696
 
906
- return SquareAnnotationElement;
907
- }(AnnotationElement);
908
-
909
- var CircleAnnotationElement =
910
- /*#__PURE__*/
911
- function (_AnnotationElement8) {
912
- _inherits(CircleAnnotationElement, _AnnotationElement8);
697
+ return this.container;
698
+ }
913
699
 
914
- function CircleAnnotationElement(parameters) {
915
- _classCallCheck(this, CircleAnnotationElement);
700
+ }
916
701
 
917
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
918
- return _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotationElement).call(this, parameters, isRenderable, true));
702
+ class LineAnnotationElement extends AnnotationElement {
703
+ constructor(parameters) {
704
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
705
+ super(parameters, isRenderable, true);
919
706
  }
920
707
 
921
- _createClass(CircleAnnotationElement, [{
922
- key: "render",
923
- value: function render() {
924
- this.container.className = 'circleAnnotation';
925
- var data = this.data;
926
- var width = data.rect[2] - data.rect[0];
927
- var height = data.rect[3] - data.rect[1];
928
- var svg = this.svgFactory.create(width, height);
929
- var borderWidth = data.borderStyle.width;
930
- var circle = this.svgFactory.createElement('svg:ellipse');
931
- circle.setAttribute('cx', width / 2);
932
- circle.setAttribute('cy', height / 2);
933
- circle.setAttribute('rx', width / 2 - borderWidth / 2);
934
- circle.setAttribute('ry', height / 2 - borderWidth / 2);
935
- circle.setAttribute('stroke-width', borderWidth);
936
- circle.setAttribute('stroke', 'transparent');
937
- circle.setAttribute('fill', 'none');
938
- svg.appendChild(circle);
939
- this.container.append(svg);
940
-
941
- this._createPopup(this.container, circle, data);
942
-
943
- return this.container;
944
- }
945
- }]);
708
+ render() {
709
+ this.container.className = "lineAnnotation";
710
+ const data = this.data;
711
+ const width = data.rect[2] - data.rect[0];
712
+ const height = data.rect[3] - data.rect[1];
713
+ const svg = this.svgFactory.create(width, height);
714
+ const line = this.svgFactory.createElement("svg:line");
715
+ line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
716
+ line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
717
+ line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
718
+ line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
719
+ line.setAttribute("stroke-width", data.borderStyle.width || 1);
720
+ line.setAttribute("stroke", "transparent");
721
+ svg.appendChild(line);
722
+ this.container.append(svg);
723
+
724
+ this._createPopup(this.container, line, data);
725
+
726
+ return this.container;
727
+ }
946
728
 
947
- return CircleAnnotationElement;
948
- }(AnnotationElement);
729
+ }
949
730
 
950
- var PolylineAnnotationElement =
951
- /*#__PURE__*/
952
- function (_AnnotationElement9) {
953
- _inherits(PolylineAnnotationElement, _AnnotationElement9);
731
+ class SquareAnnotationElement extends AnnotationElement {
732
+ constructor(parameters) {
733
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
734
+ super(parameters, isRenderable, true);
735
+ }
954
736
 
955
- function PolylineAnnotationElement(parameters) {
956
- var _this3;
737
+ render() {
738
+ this.container.className = "squareAnnotation";
739
+ const data = this.data;
740
+ const width = data.rect[2] - data.rect[0];
741
+ const height = data.rect[3] - data.rect[1];
742
+ const svg = this.svgFactory.create(width, height);
743
+ const borderWidth = data.borderStyle.width;
744
+ const square = this.svgFactory.createElement("svg:rect");
745
+ square.setAttribute("x", borderWidth / 2);
746
+ square.setAttribute("y", borderWidth / 2);
747
+ square.setAttribute("width", width - borderWidth);
748
+ square.setAttribute("height", height - borderWidth);
749
+ square.setAttribute("stroke-width", borderWidth || 1);
750
+ square.setAttribute("stroke", "transparent");
751
+ square.setAttribute("fill", "none");
752
+ svg.appendChild(square);
753
+ this.container.append(svg);
754
+
755
+ this._createPopup(this.container, square, data);
756
+
757
+ return this.container;
758
+ }
957
759
 
958
- _classCallCheck(this, PolylineAnnotationElement);
760
+ }
959
761
 
960
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
961
- _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotationElement).call(this, parameters, isRenderable, true));
962
- _this3.containerClassName = 'polylineAnnotation';
963
- _this3.svgElementName = 'svg:polyline';
964
- return _this3;
762
+ class CircleAnnotationElement extends AnnotationElement {
763
+ constructor(parameters) {
764
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
765
+ super(parameters, isRenderable, true);
965
766
  }
966
767
 
967
- _createClass(PolylineAnnotationElement, [{
968
- key: "render",
969
- value: function render() {
970
- this.container.className = this.containerClassName;
971
- var data = this.data;
972
- var width = data.rect[2] - data.rect[0];
973
- var height = data.rect[3] - data.rect[1];
974
- var svg = this.svgFactory.create(width, height);
975
- var vertices = data.vertices;
976
- var points = [];
977
-
978
- for (var i = 0, ii = vertices.length; i < ii; i++) {
979
- var x = vertices[i].x - data.rect[0];
980
- var y = data.rect[3] - vertices[i].y;
981
- points.push(x + ',' + y);
982
- }
768
+ render() {
769
+ this.container.className = "circleAnnotation";
770
+ const data = this.data;
771
+ const width = data.rect[2] - data.rect[0];
772
+ const height = data.rect[3] - data.rect[1];
773
+ const svg = this.svgFactory.create(width, height);
774
+ const borderWidth = data.borderStyle.width;
775
+ const circle = this.svgFactory.createElement("svg:ellipse");
776
+ circle.setAttribute("cx", width / 2);
777
+ circle.setAttribute("cy", height / 2);
778
+ circle.setAttribute("rx", width / 2 - borderWidth / 2);
779
+ circle.setAttribute("ry", height / 2 - borderWidth / 2);
780
+ circle.setAttribute("stroke-width", borderWidth || 1);
781
+ circle.setAttribute("stroke", "transparent");
782
+ circle.setAttribute("fill", "none");
783
+ svg.appendChild(circle);
784
+ this.container.append(svg);
785
+
786
+ this._createPopup(this.container, circle, data);
787
+
788
+ return this.container;
789
+ }
983
790
 
984
- points = points.join(' ');
985
- var borderWidth = data.borderStyle.width;
986
- var polyline = this.svgFactory.createElement(this.svgElementName);
987
- polyline.setAttribute('points', points);
988
- polyline.setAttribute('stroke-width', borderWidth);
989
- polyline.setAttribute('stroke', 'transparent');
990
- polyline.setAttribute('fill', 'none');
991
- svg.appendChild(polyline);
992
- this.container.append(svg);
791
+ }
993
792
 
994
- this._createPopup(this.container, polyline, data);
793
+ class PolylineAnnotationElement extends AnnotationElement {
794
+ constructor(parameters) {
795
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
796
+ super(parameters, isRenderable, true);
797
+ this.containerClassName = "polylineAnnotation";
798
+ this.svgElementName = "svg:polyline";
799
+ }
995
800
 
996
- return this.container;
801
+ render() {
802
+ this.container.className = this.containerClassName;
803
+ const data = this.data;
804
+ const width = data.rect[2] - data.rect[0];
805
+ const height = data.rect[3] - data.rect[1];
806
+ const svg = this.svgFactory.create(width, height);
807
+ let points = [];
808
+
809
+ for (const coordinate of data.vertices) {
810
+ const x = coordinate.x - data.rect[0];
811
+ const y = data.rect[3] - coordinate.y;
812
+ points.push(x + "," + y);
997
813
  }
998
- }]);
999
814
 
1000
- return PolylineAnnotationElement;
1001
- }(AnnotationElement);
815
+ points = points.join(" ");
816
+ const polyline = this.svgFactory.createElement(this.svgElementName);
817
+ polyline.setAttribute("points", points);
818
+ polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
819
+ polyline.setAttribute("stroke", "transparent");
820
+ polyline.setAttribute("fill", "none");
821
+ svg.appendChild(polyline);
822
+ this.container.append(svg);
1002
823
 
1003
- var PolygonAnnotationElement =
1004
- /*#__PURE__*/
1005
- function (_PolylineAnnotationEl) {
1006
- _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
824
+ this._createPopup(this.container, polyline, data);
1007
825
 
1008
- function PolygonAnnotationElement(parameters) {
1009
- var _this4;
1010
-
1011
- _classCallCheck(this, PolygonAnnotationElement);
1012
-
1013
- _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotationElement).call(this, parameters));
1014
- _this4.containerClassName = 'polygonAnnotation';
1015
- _this4.svgElementName = 'svg:polygon';
1016
- return _this4;
826
+ return this.container;
1017
827
  }
1018
828
 
1019
- return PolygonAnnotationElement;
1020
- }(PolylineAnnotationElement);
829
+ }
1021
830
 
1022
- var CaretAnnotationElement =
1023
- /*#__PURE__*/
1024
- function (_AnnotationElement10) {
1025
- _inherits(CaretAnnotationElement, _AnnotationElement10);
831
+ class PolygonAnnotationElement extends PolylineAnnotationElement {
832
+ constructor(parameters) {
833
+ super(parameters);
834
+ this.containerClassName = "polygonAnnotation";
835
+ this.svgElementName = "svg:polygon";
836
+ }
1026
837
 
1027
- function CaretAnnotationElement(parameters) {
1028
- _classCallCheck(this, CaretAnnotationElement);
838
+ }
1029
839
 
1030
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1031
- return _possibleConstructorReturn(this, _getPrototypeOf(CaretAnnotationElement).call(this, parameters, isRenderable, true));
840
+ class CaretAnnotationElement extends AnnotationElement {
841
+ constructor(parameters) {
842
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
843
+ super(parameters, isRenderable, true);
1032
844
  }
1033
845
 
1034
- _createClass(CaretAnnotationElement, [{
1035
- key: "render",
1036
- value: function render() {
1037
- this.container.className = 'caretAnnotation';
846
+ render() {
847
+ this.container.className = "caretAnnotation";
1038
848
 
1039
- if (!this.data.hasPopup) {
1040
- this._createPopup(this.container, null, this.data);
1041
- }
1042
-
1043
- return this.container;
849
+ if (!this.data.hasPopup) {
850
+ this._createPopup(this.container, null, this.data);
1044
851
  }
1045
- }]);
1046
-
1047
- return CaretAnnotationElement;
1048
- }(AnnotationElement);
1049
852
 
1050
- var InkAnnotationElement =
1051
- /*#__PURE__*/
1052
- function (_AnnotationElement11) {
1053
- _inherits(InkAnnotationElement, _AnnotationElement11);
1054
-
1055
- function InkAnnotationElement(parameters) {
1056
- var _this5;
853
+ return this.container;
854
+ }
1057
855
 
1058
- _classCallCheck(this, InkAnnotationElement);
856
+ }
1059
857
 
1060
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1061
- _this5 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotationElement).call(this, parameters, isRenderable, true));
1062
- _this5.containerClassName = 'inkAnnotation';
1063
- _this5.svgElementName = 'svg:polyline';
1064
- return _this5;
858
+ class InkAnnotationElement extends AnnotationElement {
859
+ constructor(parameters) {
860
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
861
+ super(parameters, isRenderable, true);
862
+ this.containerClassName = "inkAnnotation";
863
+ this.svgElementName = "svg:polyline";
1065
864
  }
1066
865
 
1067
- _createClass(InkAnnotationElement, [{
1068
- key: "render",
1069
- value: function render() {
1070
- this.container.className = this.containerClassName;
1071
- var data = this.data;
1072
- var width = data.rect[2] - data.rect[0];
1073
- var height = data.rect[3] - data.rect[1];
1074
- var svg = this.svgFactory.create(width, height);
1075
- var inkLists = data.inkLists;
1076
-
1077
- for (var i = 0, ii = inkLists.length; i < ii; i++) {
1078
- var inkList = inkLists[i];
1079
- var points = [];
1080
-
1081
- for (var j = 0, jj = inkList.length; j < jj; j++) {
1082
- var x = inkList[j].x - data.rect[0];
1083
- var y = data.rect[3] - inkList[j].y;
1084
- points.push(x + ',' + y);
1085
- }
1086
-
1087
- points = points.join(' ');
1088
- var borderWidth = data.borderStyle.width;
1089
- var polyline = this.svgFactory.createElement(this.svgElementName);
1090
- polyline.setAttribute('points', points);
1091
- polyline.setAttribute('stroke-width', borderWidth);
1092
- polyline.setAttribute('stroke', 'transparent');
1093
- polyline.setAttribute('fill', 'none');
866
+ render() {
867
+ this.container.className = this.containerClassName;
868
+ const data = this.data;
869
+ const width = data.rect[2] - data.rect[0];
870
+ const height = data.rect[3] - data.rect[1];
871
+ const svg = this.svgFactory.create(width, height);
1094
872
 
1095
- this._createPopup(this.container, polyline, data);
873
+ for (const inkList of data.inkLists) {
874
+ let points = [];
1096
875
 
1097
- svg.appendChild(polyline);
876
+ for (const coordinate of inkList) {
877
+ const x = coordinate.x - data.rect[0];
878
+ const y = data.rect[3] - coordinate.y;
879
+ points.push(`${x},${y}`);
1098
880
  }
1099
881
 
1100
- this.container.append(svg);
1101
- return this.container;
1102
- }
1103
- }]);
1104
-
1105
- return InkAnnotationElement;
1106
- }(AnnotationElement);
882
+ points = points.join(" ");
883
+ const polyline = this.svgFactory.createElement(this.svgElementName);
884
+ polyline.setAttribute("points", points);
885
+ polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
886
+ polyline.setAttribute("stroke", "transparent");
887
+ polyline.setAttribute("fill", "none");
1107
888
 
1108
- var HighlightAnnotationElement =
1109
- /*#__PURE__*/
1110
- function (_AnnotationElement12) {
1111
- _inherits(HighlightAnnotationElement, _AnnotationElement12);
889
+ this._createPopup(this.container, polyline, data);
1112
890
 
1113
- function HighlightAnnotationElement(parameters) {
1114
- _classCallCheck(this, HighlightAnnotationElement);
891
+ svg.appendChild(polyline);
892
+ }
1115
893
 
1116
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1117
- return _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotationElement).call(this, parameters, isRenderable, true));
894
+ this.container.append(svg);
895
+ return this.container;
1118
896
  }
1119
897
 
1120
- _createClass(HighlightAnnotationElement, [{
1121
- key: "render",
1122
- value: function render() {
1123
- this.container.className = 'highlightAnnotation';
898
+ }
1124
899
 
1125
- if (!this.data.hasPopup) {
1126
- this._createPopup(this.container, null, this.data);
1127
- }
900
+ class HighlightAnnotationElement extends AnnotationElement {
901
+ constructor(parameters) {
902
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
903
+ super(parameters, isRenderable, true);
904
+ }
1128
905
 
1129
- return this.container;
1130
- }
1131
- }]);
906
+ render() {
907
+ this.container.className = "highlightAnnotation";
1132
908
 
1133
- return HighlightAnnotationElement;
1134
- }(AnnotationElement);
909
+ if (!this.data.hasPopup) {
910
+ this._createPopup(this.container, null, this.data);
911
+ }
1135
912
 
1136
- var UnderlineAnnotationElement =
1137
- /*#__PURE__*/
1138
- function (_AnnotationElement13) {
1139
- _inherits(UnderlineAnnotationElement, _AnnotationElement13);
913
+ return this.container;
914
+ }
1140
915
 
1141
- function UnderlineAnnotationElement(parameters) {
1142
- _classCallCheck(this, UnderlineAnnotationElement);
916
+ }
1143
917
 
1144
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1145
- return _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotationElement).call(this, parameters, isRenderable, true));
918
+ class UnderlineAnnotationElement extends AnnotationElement {
919
+ constructor(parameters) {
920
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
921
+ super(parameters, isRenderable, true);
1146
922
  }
1147
923
 
1148
- _createClass(UnderlineAnnotationElement, [{
1149
- key: "render",
1150
- value: function render() {
1151
- this.container.className = 'underlineAnnotation';
1152
-
1153
- if (!this.data.hasPopup) {
1154
- this._createPopup(this.container, null, this.data);
1155
- }
924
+ render() {
925
+ this.container.className = "underlineAnnotation";
1156
926
 
1157
- return this.container;
927
+ if (!this.data.hasPopup) {
928
+ this._createPopup(this.container, null, this.data);
1158
929
  }
1159
- }]);
1160
930
 
1161
- return UnderlineAnnotationElement;
1162
- }(AnnotationElement);
1163
-
1164
- var SquigglyAnnotationElement =
1165
- /*#__PURE__*/
1166
- function (_AnnotationElement14) {
1167
- _inherits(SquigglyAnnotationElement, _AnnotationElement14);
931
+ return this.container;
932
+ }
1168
933
 
1169
- function SquigglyAnnotationElement(parameters) {
1170
- _classCallCheck(this, SquigglyAnnotationElement);
934
+ }
1171
935
 
1172
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1173
- return _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotationElement).call(this, parameters, isRenderable, true));
936
+ class SquigglyAnnotationElement extends AnnotationElement {
937
+ constructor(parameters) {
938
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
939
+ super(parameters, isRenderable, true);
1174
940
  }
1175
941
 
1176
- _createClass(SquigglyAnnotationElement, [{
1177
- key: "render",
1178
- value: function render() {
1179
- this.container.className = 'squigglyAnnotation';
942
+ render() {
943
+ this.container.className = "squigglyAnnotation";
1180
944
 
1181
- if (!this.data.hasPopup) {
1182
- this._createPopup(this.container, null, this.data);
1183
- }
1184
-
1185
- return this.container;
945
+ if (!this.data.hasPopup) {
946
+ this._createPopup(this.container, null, this.data);
1186
947
  }
1187
- }]);
1188
948
 
1189
- return SquigglyAnnotationElement;
1190
- }(AnnotationElement);
1191
-
1192
- var StrikeOutAnnotationElement =
1193
- /*#__PURE__*/
1194
- function (_AnnotationElement15) {
1195
- _inherits(StrikeOutAnnotationElement, _AnnotationElement15);
949
+ return this.container;
950
+ }
1196
951
 
1197
- function StrikeOutAnnotationElement(parameters) {
1198
- _classCallCheck(this, StrikeOutAnnotationElement);
952
+ }
1199
953
 
1200
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1201
- return _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotationElement).call(this, parameters, isRenderable, true));
954
+ class StrikeOutAnnotationElement extends AnnotationElement {
955
+ constructor(parameters) {
956
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
957
+ super(parameters, isRenderable, true);
1202
958
  }
1203
959
 
1204
- _createClass(StrikeOutAnnotationElement, [{
1205
- key: "render",
1206
- value: function render() {
1207
- this.container.className = 'strikeoutAnnotation';
1208
-
1209
- if (!this.data.hasPopup) {
1210
- this._createPopup(this.container, null, this.data);
1211
- }
960
+ render() {
961
+ this.container.className = "strikeoutAnnotation";
1212
962
 
1213
- return this.container;
963
+ if (!this.data.hasPopup) {
964
+ this._createPopup(this.container, null, this.data);
1214
965
  }
1215
- }]);
1216
-
1217
- return StrikeOutAnnotationElement;
1218
- }(AnnotationElement);
1219
966
 
1220
- var StampAnnotationElement =
1221
- /*#__PURE__*/
1222
- function (_AnnotationElement16) {
1223
- _inherits(StampAnnotationElement, _AnnotationElement16);
967
+ return this.container;
968
+ }
1224
969
 
1225
- function StampAnnotationElement(parameters) {
1226
- _classCallCheck(this, StampAnnotationElement);
970
+ }
1227
971
 
1228
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1229
- return _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotationElement).call(this, parameters, isRenderable, true));
972
+ class StampAnnotationElement extends AnnotationElement {
973
+ constructor(parameters) {
974
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
975
+ super(parameters, isRenderable, true);
1230
976
  }
1231
977
 
1232
- _createClass(StampAnnotationElement, [{
1233
- key: "render",
1234
- value: function render() {
1235
- this.container.className = 'stampAnnotation';
978
+ render() {
979
+ this.container.className = "stampAnnotation";
1236
980
 
1237
- if (!this.data.hasPopup) {
1238
- this._createPopup(this.container, null, this.data);
1239
- }
1240
-
1241
- return this.container;
981
+ if (!this.data.hasPopup) {
982
+ this._createPopup(this.container, null, this.data);
1242
983
  }
1243
- }]);
1244
984
 
1245
- return StampAnnotationElement;
1246
- }(AnnotationElement);
985
+ return this.container;
986
+ }
1247
987
 
1248
- var FileAttachmentAnnotationElement =
1249
- /*#__PURE__*/
1250
- function (_AnnotationElement17) {
1251
- _inherits(FileAttachmentAnnotationElement, _AnnotationElement17);
988
+ }
989
+
990
+ class FileAttachmentAnnotationElement extends AnnotationElement {
991
+ constructor(parameters) {
992
+ super(parameters, true);
993
+ const {
994
+ filename,
995
+ content
996
+ } = this.data.file;
997
+ this.filename = (0, _display_utils.getFilenameFromUrl)(filename);
998
+ this.content = content;
999
+
1000
+ if (this.linkService.eventBus) {
1001
+ this.linkService.eventBus.dispatch("fileattachmentannotation", {
1002
+ source: this,
1003
+ id: (0, _util.stringToPDFString)(filename),
1004
+ filename,
1005
+ content
1006
+ });
1007
+ }
1008
+ }
1252
1009
 
1253
- function FileAttachmentAnnotationElement(parameters) {
1254
- var _this6;
1010
+ render() {
1011
+ this.container.className = "fileAttachmentAnnotation";
1012
+ const trigger = document.createElement("div");
1013
+ trigger.style.height = this.container.style.height;
1014
+ trigger.style.width = this.container.style.width;
1015
+ trigger.addEventListener("dblclick", this._download.bind(this));
1255
1016
 
1256
- _classCallCheck(this, FileAttachmentAnnotationElement);
1017
+ if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
1018
+ this._createPopup(this.container, trigger, this.data);
1019
+ }
1257
1020
 
1258
- _this6 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotationElement).call(this, parameters, true));
1259
- var _this6$data$file = _this6.data.file,
1260
- filename = _this6$data$file.filename,
1261
- content = _this6$data$file.content;
1262
- _this6.filename = (0, _display_utils.getFilenameFromUrl)(filename);
1263
- _this6.content = content;
1021
+ this.container.appendChild(trigger);
1022
+ return this.container;
1023
+ }
1264
1024
 
1265
- if (_this6.linkService.eventBus) {
1266
- _this6.linkService.eventBus.dispatch('fileattachmentannotation', {
1267
- source: _assertThisInitialized(_this6),
1268
- id: (0, _util.stringToPDFString)(filename),
1269
- filename: filename,
1270
- content: content
1271
- });
1025
+ _download() {
1026
+ if (!this.downloadManager) {
1027
+ (0, _util.warn)("Download cannot be started due to unavailable download manager");
1028
+ return;
1272
1029
  }
1273
1030
 
1274
- return _this6;
1031
+ this.downloadManager.downloadData(this.content, this.filename, "");
1275
1032
  }
1276
1033
 
1277
- _createClass(FileAttachmentAnnotationElement, [{
1278
- key: "render",
1279
- value: function render() {
1280
- this.container.className = 'fileAttachmentAnnotation';
1281
- var trigger = document.createElement('div');
1282
- trigger.style.height = this.container.style.height;
1283
- trigger.style.width = this.container.style.width;
1284
- trigger.addEventListener('dblclick', this._download.bind(this));
1285
-
1286
- if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
1287
- this._createPopup(this.container, trigger, this.data);
1034
+ }
1035
+
1036
+ class AnnotationLayer {
1037
+ static render(parameters) {
1038
+ const sortedAnnotations = [],
1039
+ popupAnnotations = [];
1040
+
1041
+ for (const data of parameters.annotations) {
1042
+ if (!data) {
1043
+ continue;
1288
1044
  }
1289
1045
 
1290
- this.container.appendChild(trigger);
1291
- return this.container;
1292
- }
1293
- }, {
1294
- key: "_download",
1295
- value: function _download() {
1296
- if (!this.downloadManager) {
1297
- (0, _util.warn)('Download cannot be started due to unavailable download manager');
1298
- return;
1046
+ if (data.annotationType === _util.AnnotationType.POPUP) {
1047
+ popupAnnotations.push(data);
1048
+ continue;
1299
1049
  }
1300
1050
 
1301
- this.downloadManager.downloadData(this.content, this.filename, '');
1051
+ sortedAnnotations.push(data);
1302
1052
  }
1303
- }]);
1304
1053
 
1305
- return FileAttachmentAnnotationElement;
1306
- }(AnnotationElement);
1054
+ if (popupAnnotations.length) {
1055
+ sortedAnnotations.push(...popupAnnotations);
1056
+ }
1307
1057
 
1308
- var AnnotationLayer =
1309
- /*#__PURE__*/
1310
- function () {
1311
- function AnnotationLayer() {
1312
- _classCallCheck(this, AnnotationLayer);
1313
- }
1058
+ for (const data of sortedAnnotations) {
1059
+ const element = AnnotationElementFactory.create({
1060
+ data,
1061
+ layer: parameters.div,
1062
+ page: parameters.page,
1063
+ viewport: parameters.viewport,
1064
+ linkService: parameters.linkService,
1065
+ downloadManager: parameters.downloadManager,
1066
+ imageResourcesPath: parameters.imageResourcesPath || "",
1067
+ renderInteractiveForms: typeof parameters.renderInteractiveForms === "boolean" ? parameters.renderInteractiveForms : true,
1068
+ svgFactory: new _display_utils.DOMSVGFactory(),
1069
+ annotationStorage: parameters.annotationStorage || new _annotation_storage.AnnotationStorage()
1070
+ });
1314
1071
 
1315
- _createClass(AnnotationLayer, null, [{
1316
- key: "render",
1317
- value: function render(parameters) {
1318
- for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
1319
- var data = parameters.annotations[i];
1072
+ if (element.isRenderable) {
1073
+ parameters.div.appendChild(element.render());
1074
+ }
1075
+ }
1076
+ }
1320
1077
 
1321
- if (!data) {
1322
- continue;
1323
- }
1078
+ static update(parameters) {
1079
+ for (const data of parameters.annotations) {
1080
+ const element = parameters.div.querySelector(`[data-annotation-id="${data.id}"]`);
1324
1081
 
1325
- var element = AnnotationElementFactory.create({
1326
- data: data,
1327
- layer: parameters.div,
1328
- page: parameters.page,
1329
- viewport: parameters.viewport,
1330
- linkService: parameters.linkService,
1331
- downloadManager: parameters.downloadManager,
1332
- imageResourcesPath: parameters.imageResourcesPath || '',
1333
- renderInteractiveForms: parameters.renderInteractiveForms || false,
1334
- svgFactory: new _display_utils.DOMSVGFactory()
1335
- });
1336
-
1337
- if (element.isRenderable) {
1338
- parameters.div.appendChild(element.render());
1339
- }
1082
+ if (element) {
1083
+ element.style.transform = `matrix(${parameters.viewport.transform.join(",")})`;
1340
1084
  }
1341
1085
  }
1342
- }, {
1343
- key: "update",
1344
- value: function update(parameters) {
1345
- for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
1346
- var data = parameters.annotations[i];
1347
- var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
1348
-
1349
- if (element) {
1350
- element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')';
1351
- }
1352
- }
1353
1086
 
1354
- parameters.div.removeAttribute('hidden');
1355
- }
1356
- }]);
1087
+ parameters.div.removeAttribute("hidden");
1088
+ }
1357
1089
 
1358
- return AnnotationLayer;
1359
- }();
1090
+ }
1360
1091
 
1361
1092
  exports.AnnotationLayer = AnnotationLayer;