snice 4.9.0 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (733) hide show
  1. package/adapters/react/app-tiles.d.ts +28 -0
  2. package/adapters/react/app-tiles.d.ts.map +1 -0
  3. package/adapters/react/app-tiles.js +24 -0
  4. package/adapters/react/app-tiles.js.map +1 -0
  5. package/adapters/react/app-tiles.tsx +36 -0
  6. package/adapters/react/book.d.ts +28 -0
  7. package/adapters/react/book.d.ts.map +1 -0
  8. package/adapters/react/book.js +24 -0
  9. package/adapters/react/book.js.map +1 -0
  10. package/adapters/react/book.tsx +36 -0
  11. package/adapters/react/comments.d.ts +29 -0
  12. package/adapters/react/comments.d.ts.map +1 -0
  13. package/adapters/react/comments.js +24 -0
  14. package/adapters/react/comments.js.map +1 -0
  15. package/adapters/react/comments.tsx +37 -0
  16. package/adapters/react/components.d.ts +52 -0
  17. package/adapters/react/components.d.ts.map +1 -1
  18. package/adapters/react/components.js +26 -0
  19. package/adapters/react/components.js.map +1 -1
  20. package/adapters/react/components.ts +52 -0
  21. package/adapters/react/countdown.d.ts +31 -0
  22. package/adapters/react/countdown.d.ts.map +1 -0
  23. package/adapters/react/countdown.js +24 -0
  24. package/adapters/react/countdown.js.map +1 -0
  25. package/adapters/react/countdown.tsx +39 -0
  26. package/adapters/react/cropper.d.ts +29 -0
  27. package/adapters/react/cropper.d.ts.map +1 -0
  28. package/adapters/react/cropper.js +24 -0
  29. package/adapters/react/cropper.js.map +1 -0
  30. package/adapters/react/cropper.tsx +37 -0
  31. package/adapters/react/diff.d.ts +31 -0
  32. package/adapters/react/diff.d.ts.map +1 -0
  33. package/adapters/react/diff.js +24 -0
  34. package/adapters/react/diff.js.map +1 -0
  35. package/adapters/react/diff.tsx +39 -0
  36. package/adapters/react/flip-card.d.ts +28 -0
  37. package/adapters/react/flip-card.d.ts.map +1 -0
  38. package/adapters/react/flip-card.js +24 -0
  39. package/adapters/react/flip-card.js.map +1 -0
  40. package/adapters/react/flip-card.tsx +36 -0
  41. package/adapters/react/flow.d.ts +32 -0
  42. package/adapters/react/flow.d.ts.map +1 -0
  43. package/adapters/react/flow.js +24 -0
  44. package/adapters/react/flow.js.map +1 -0
  45. package/adapters/react/flow.tsx +40 -0
  46. package/adapters/react/gantt.d.ts +27 -0
  47. package/adapters/react/gantt.d.ts.map +1 -0
  48. package/adapters/react/gantt.js +24 -0
  49. package/adapters/react/gantt.js.map +1 -0
  50. package/adapters/react/gantt.tsx +35 -0
  51. package/adapters/react/map.d.ts +30 -0
  52. package/adapters/react/map.d.ts.map +1 -0
  53. package/adapters/react/map.js +24 -0
  54. package/adapters/react/map.js.map +1 -0
  55. package/adapters/react/map.tsx +38 -0
  56. package/adapters/react/markdown.d.ts +26 -0
  57. package/adapters/react/markdown.d.ts.map +1 -0
  58. package/adapters/react/markdown.js +24 -0
  59. package/adapters/react/markdown.js.map +1 -0
  60. package/adapters/react/markdown.tsx +34 -0
  61. package/adapters/react/notification-center.d.ts +26 -0
  62. package/adapters/react/notification-center.d.ts.map +1 -0
  63. package/adapters/react/notification-center.js +24 -0
  64. package/adapters/react/notification-center.js.map +1 -0
  65. package/adapters/react/notification-center.tsx +34 -0
  66. package/adapters/react/org-chart.d.ts +28 -0
  67. package/adapters/react/org-chart.d.ts.map +1 -0
  68. package/adapters/react/org-chart.js +24 -0
  69. package/adapters/react/org-chart.js.map +1 -0
  70. package/adapters/react/org-chart.tsx +36 -0
  71. package/adapters/react/pdf-viewer.d.ts +28 -0
  72. package/adapters/react/pdf-viewer.d.ts.map +1 -0
  73. package/adapters/react/pdf-viewer.js +24 -0
  74. package/adapters/react/pdf-viewer.js.map +1 -0
  75. package/adapters/react/pdf-viewer.tsx +36 -0
  76. package/adapters/react/podcast-player.d.ts +40 -0
  77. package/adapters/react/podcast-player.d.ts.map +1 -0
  78. package/adapters/react/podcast-player.js +24 -0
  79. package/adapters/react/podcast-player.js.map +1 -0
  80. package/adapters/react/podcast-player.tsx +48 -0
  81. package/adapters/react/pricing-table.d.ts +27 -0
  82. package/adapters/react/pricing-table.d.ts.map +1 -0
  83. package/adapters/react/pricing-table.js +24 -0
  84. package/adapters/react/pricing-table.js.map +1 -0
  85. package/adapters/react/pricing-table.tsx +35 -0
  86. package/adapters/react/rating.d.ts +30 -0
  87. package/adapters/react/rating.d.ts.map +1 -0
  88. package/adapters/react/rating.js +24 -0
  89. package/adapters/react/rating.js.map +1 -0
  90. package/adapters/react/rating.tsx +38 -0
  91. package/adapters/react/recipe.d.ts +43 -0
  92. package/adapters/react/recipe.d.ts.map +1 -0
  93. package/adapters/react/recipe.js +24 -0
  94. package/adapters/react/recipe.js.map +1 -0
  95. package/adapters/react/recipe.tsx +51 -0
  96. package/adapters/react/sortable.d.ts +28 -0
  97. package/adapters/react/sortable.d.ts.map +1 -0
  98. package/adapters/react/sortable.js +24 -0
  99. package/adapters/react/sortable.js.map +1 -0
  100. package/adapters/react/sortable.tsx +36 -0
  101. package/adapters/react/spotlight.d.ts +27 -0
  102. package/adapters/react/spotlight.d.ts.map +1 -0
  103. package/adapters/react/spotlight.js +24 -0
  104. package/adapters/react/spotlight.js.map +1 -0
  105. package/adapters/react/spotlight.tsx +35 -0
  106. package/adapters/react/spreadsheet.d.ts +27 -0
  107. package/adapters/react/spreadsheet.d.ts.map +1 -0
  108. package/adapters/react/spreadsheet.js +24 -0
  109. package/adapters/react/spreadsheet.js.map +1 -0
  110. package/adapters/react/spreadsheet.tsx +35 -0
  111. package/adapters/react/tag-input.d.ts +33 -0
  112. package/adapters/react/tag-input.d.ts.map +1 -0
  113. package/adapters/react/tag-input.js +24 -0
  114. package/adapters/react/tag-input.js.map +1 -0
  115. package/adapters/react/tag-input.tsx +41 -0
  116. package/adapters/react/testimonial.d.ts +31 -0
  117. package/adapters/react/testimonial.d.ts.map +1 -0
  118. package/adapters/react/testimonial.js +24 -0
  119. package/adapters/react/testimonial.js.map +1 -0
  120. package/adapters/react/testimonial.tsx +39 -0
  121. package/adapters/react/video-player.d.ts +34 -0
  122. package/adapters/react/video-player.d.ts.map +1 -0
  123. package/adapters/react/video-player.js +24 -0
  124. package/adapters/react/video-player.js.map +1 -0
  125. package/adapters/react/video-player.tsx +42 -0
  126. package/adapters/react/waterfall.d.ts +29 -0
  127. package/adapters/react/waterfall.d.ts.map +1 -0
  128. package/adapters/react/waterfall.js +24 -0
  129. package/adapters/react/waterfall.js.map +1 -0
  130. package/adapters/react/waterfall.tsx +37 -0
  131. package/adapters/react/weather.d.ts +27 -0
  132. package/adapters/react/weather.d.ts.map +1 -0
  133. package/adapters/react/weather.js +24 -0
  134. package/adapters/react/weather.js.map +1 -0
  135. package/adapters/react/weather.tsx +35 -0
  136. package/dist/cdn/accordion/snice-accordion.js +1 -1
  137. package/dist/cdn/accordion/snice-accordion.min.js +1 -1
  138. package/dist/cdn/alert/snice-alert.js +1 -1
  139. package/dist/cdn/alert/snice-alert.min.js +1 -1
  140. package/dist/cdn/app-tiles/README.md +27 -0
  141. package/dist/cdn/app-tiles/snice-app-tiles.js +333 -0
  142. package/dist/cdn/app-tiles/snice-app-tiles.js.map +1 -0
  143. package/dist/cdn/app-tiles/snice-app-tiles.min.js +11 -0
  144. package/dist/cdn/app-tiles/snice-app-tiles.min.js.map +1 -0
  145. package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
  146. package/dist/cdn/audio-recorder/snice-audio-recorder.min.js +1 -1
  147. package/dist/cdn/avatar/snice-avatar.js +1 -1
  148. package/dist/cdn/avatar/snice-avatar.min.js +1 -1
  149. package/dist/cdn/badge/snice-badge.js +1 -1
  150. package/dist/cdn/badge/snice-badge.min.js +1 -1
  151. package/dist/cdn/banner/snice-banner.js +1 -1
  152. package/dist/cdn/banner/snice-banner.min.js +1 -1
  153. package/dist/cdn/book/README.md +27 -0
  154. package/dist/cdn/book/snice-book.js +353 -0
  155. package/dist/cdn/book/snice-book.js.map +1 -0
  156. package/dist/cdn/book/snice-book.min.js +13 -0
  157. package/dist/cdn/book/snice-book.min.js.map +1 -0
  158. package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
  159. package/dist/cdn/breadcrumbs/snice-breadcrumbs.min.js +1 -1
  160. package/dist/cdn/button/snice-button.js +1 -1
  161. package/dist/cdn/button/snice-button.min.js +1 -1
  162. package/dist/cdn/calendar/snice-calendar.js +1 -1
  163. package/dist/cdn/calendar/snice-calendar.min.js +1 -1
  164. package/dist/cdn/camera/snice-camera.js +1 -1
  165. package/dist/cdn/camera/snice-camera.min.js +1 -1
  166. package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
  167. package/dist/cdn/camera-annotate/snice-camera-annotate.min.js +1 -1
  168. package/dist/cdn/candlestick/snice-candlestick.js +1 -1
  169. package/dist/cdn/candlestick/snice-candlestick.min.js +1 -1
  170. package/dist/cdn/card/snice-card.js +1 -1
  171. package/dist/cdn/card/snice-card.min.js +1 -1
  172. package/dist/cdn/carousel/snice-carousel.js +1 -1
  173. package/dist/cdn/carousel/snice-carousel.min.js +1 -1
  174. package/dist/cdn/chart/snice-chart.js +1 -1
  175. package/dist/cdn/chart/snice-chart.min.js +1 -1
  176. package/dist/cdn/chat/snice-chat.js +1 -1
  177. package/dist/cdn/chat/snice-chat.min.js +1 -1
  178. package/dist/cdn/checkbox/snice-checkbox.js +1 -1
  179. package/dist/cdn/checkbox/snice-checkbox.min.js +1 -1
  180. package/dist/cdn/chip/snice-chip.js +1 -1
  181. package/dist/cdn/chip/snice-chip.min.js +1 -1
  182. package/dist/cdn/code-block/snice-code-block.js +1 -1
  183. package/dist/cdn/code-block/snice-code-block.min.js +1 -1
  184. package/dist/cdn/color-display/snice-color-display.js +1 -1
  185. package/dist/cdn/color-display/snice-color-display.min.js +1 -1
  186. package/dist/cdn/color-picker/snice-color-picker.js +1 -1
  187. package/dist/cdn/color-picker/snice-color-picker.min.js +1 -1
  188. package/dist/cdn/command-palette/snice-command-palette.js +1 -1
  189. package/dist/cdn/command-palette/snice-command-palette.min.js +1 -1
  190. package/dist/cdn/comments/README.md +27 -0
  191. package/dist/cdn/comments/snice-comments.js +544 -0
  192. package/dist/cdn/comments/snice-comments.js.map +1 -0
  193. package/dist/cdn/comments/snice-comments.min.js +100 -0
  194. package/dist/cdn/comments/snice-comments.min.js.map +1 -0
  195. package/dist/cdn/countdown/README.md +27 -0
  196. package/dist/cdn/countdown/snice-countdown.js +235 -0
  197. package/dist/cdn/countdown/snice-countdown.js.map +1 -0
  198. package/dist/cdn/countdown/snice-countdown.min.js +14 -0
  199. package/dist/cdn/countdown/snice-countdown.min.js.map +1 -0
  200. package/dist/cdn/cropper/README.md +27 -0
  201. package/dist/cdn/cropper/snice-cropper.js +352 -0
  202. package/dist/cdn/cropper/snice-cropper.js.map +1 -0
  203. package/dist/cdn/cropper/snice-cropper.min.js +25 -0
  204. package/dist/cdn/cropper/snice-cropper.min.js.map +1 -0
  205. package/dist/cdn/date-picker/snice-date-picker.js +1 -1
  206. package/dist/cdn/date-picker/snice-date-picker.min.js +1 -1
  207. package/dist/cdn/diff/README.md +27 -0
  208. package/dist/cdn/diff/snice-diff.js +441 -0
  209. package/dist/cdn/diff/snice-diff.js.map +1 -0
  210. package/dist/cdn/diff/snice-diff.min.js +54 -0
  211. package/dist/cdn/diff/snice-diff.min.js.map +1 -0
  212. package/dist/cdn/divider/snice-divider.js +1 -1
  213. package/dist/cdn/divider/snice-divider.min.js +1 -1
  214. package/dist/cdn/doc/snice-doc.js +1 -1
  215. package/dist/cdn/doc/snice-doc.min.js +1 -1
  216. package/dist/cdn/draw/snice-draw.js +1 -1
  217. package/dist/cdn/draw/snice-draw.min.js +1 -1
  218. package/dist/cdn/drawer/snice-drawer.js +1 -1
  219. package/dist/cdn/drawer/snice-drawer.min.js +1 -1
  220. package/dist/cdn/empty-state/snice-empty-state.js +1 -1
  221. package/dist/cdn/empty-state/snice-empty-state.min.js +1 -1
  222. package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
  223. package/dist/cdn/file-gallery/snice-file-gallery.min.js +1 -1
  224. package/dist/cdn/file-upload/snice-file-upload.js +1 -1
  225. package/dist/cdn/file-upload/snice-file-upload.min.js +1 -1
  226. package/dist/cdn/flip-card/README.md +27 -0
  227. package/dist/cdn/flip-card/snice-flip-card.js +183 -0
  228. package/dist/cdn/flip-card/snice-flip-card.js.map +1 -0
  229. package/dist/cdn/flip-card/snice-flip-card.min.js +22 -0
  230. package/dist/cdn/flip-card/snice-flip-card.min.js.map +1 -0
  231. package/dist/cdn/flow/README.md +27 -0
  232. package/dist/cdn/flow/snice-flow.js +822 -0
  233. package/dist/cdn/flow/snice-flow.js.map +1 -0
  234. package/dist/cdn/flow/snice-flow.min.js +17 -0
  235. package/dist/cdn/flow/snice-flow.min.js.map +1 -0
  236. package/dist/cdn/funnel/snice-funnel.js +1 -1
  237. package/dist/cdn/funnel/snice-funnel.min.js +1 -1
  238. package/dist/cdn/gantt/README.md +27 -0
  239. package/dist/cdn/gantt/snice-gantt.js +436 -0
  240. package/dist/cdn/gantt/snice-gantt.js.map +1 -0
  241. package/dist/cdn/gantt/snice-gantt.min.js +60 -0
  242. package/dist/cdn/gantt/snice-gantt.min.js.map +1 -0
  243. package/dist/cdn/gauge/snice-gauge.js +1 -1
  244. package/dist/cdn/gauge/snice-gauge.min.js +1 -1
  245. package/dist/cdn/heatmap/snice-heatmap.js +1 -1
  246. package/dist/cdn/heatmap/snice-heatmap.min.js +1 -1
  247. package/dist/cdn/image/snice-image.js +1 -1
  248. package/dist/cdn/image/snice-image.min.js +1 -1
  249. package/dist/cdn/input/snice-input.js +1 -1
  250. package/dist/cdn/input/snice-input.min.js +1 -1
  251. package/dist/cdn/kanban/snice-kanban.js +1 -1
  252. package/dist/cdn/kanban/snice-kanban.min.js +1 -1
  253. package/dist/cdn/kpi/snice-kpi.js +1 -1
  254. package/dist/cdn/kpi/snice-kpi.min.js +1 -1
  255. package/dist/cdn/layout/snice-layout.js +1 -1
  256. package/dist/cdn/layout/snice-layout.min.js +1 -1
  257. package/dist/cdn/link/snice-link.js +1 -1
  258. package/dist/cdn/link/snice-link.min.js +1 -1
  259. package/dist/cdn/link-preview/snice-link-preview.js +1 -1
  260. package/dist/cdn/link-preview/snice-link-preview.min.js +1 -1
  261. package/dist/cdn/list/snice-list.js +1 -1
  262. package/dist/cdn/list/snice-list.min.js +1 -1
  263. package/dist/cdn/location/snice-location.js +1 -1
  264. package/dist/cdn/location/snice-location.min.js +1 -1
  265. package/dist/cdn/login/snice-login.js +1 -1
  266. package/dist/cdn/login/snice-login.min.js +1 -1
  267. package/dist/cdn/map/README.md +27 -0
  268. package/dist/cdn/map/snice-map.js +415 -0
  269. package/dist/cdn/map/snice-map.js.map +1 -0
  270. package/dist/cdn/map/snice-map.min.js +52 -0
  271. package/dist/cdn/map/snice-map.min.js.map +1 -0
  272. package/dist/cdn/markdown/README.md +27 -0
  273. package/dist/cdn/markdown/snice-markdown.js +317 -0
  274. package/dist/cdn/markdown/snice-markdown.js.map +1 -0
  275. package/dist/cdn/markdown/snice-markdown.min.js +11 -0
  276. package/dist/cdn/markdown/snice-markdown.min.js.map +1 -0
  277. package/dist/cdn/masonry/snice-masonry.js +1 -1
  278. package/dist/cdn/masonry/snice-masonry.min.js +1 -1
  279. package/dist/cdn/menu/snice-menu.js +1 -1
  280. package/dist/cdn/menu/snice-menu.min.js +1 -1
  281. package/dist/cdn/modal/snice-modal.js +1 -1
  282. package/dist/cdn/modal/snice-modal.min.js +1 -1
  283. package/dist/cdn/music-player/snice-music-player.js +1 -1
  284. package/dist/cdn/music-player/snice-music-player.min.js +1 -1
  285. package/dist/cdn/nav/snice-nav.js +1 -1
  286. package/dist/cdn/nav/snice-nav.min.js +1 -1
  287. package/dist/cdn/network-graph/snice-network-graph.js +1 -1
  288. package/dist/cdn/network-graph/snice-network-graph.min.js +1 -1
  289. package/dist/cdn/notification-center/README.md +27 -0
  290. package/dist/cdn/notification-center/snice-notification-center.js +204 -0
  291. package/dist/cdn/notification-center/snice-notification-center.js.map +1 -0
  292. package/dist/cdn/notification-center/snice-notification-center.min.js +33 -0
  293. package/dist/cdn/notification-center/snice-notification-center.min.js.map +1 -0
  294. package/dist/cdn/org-chart/README.md +27 -0
  295. package/dist/cdn/org-chart/snice-org-chart.js +294 -0
  296. package/dist/cdn/org-chart/snice-org-chart.js.map +1 -0
  297. package/dist/cdn/org-chart/snice-org-chart.min.js +32 -0
  298. package/dist/cdn/org-chart/snice-org-chart.min.js.map +1 -0
  299. package/dist/cdn/pagination/snice-pagination.js +1 -1
  300. package/dist/cdn/pagination/snice-pagination.min.js +1 -1
  301. package/dist/cdn/paint/snice-paint.js +1 -1
  302. package/dist/cdn/paint/snice-paint.min.js +1 -1
  303. package/dist/cdn/pdf-viewer/README.md +27 -0
  304. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +594 -0
  305. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js.map +1 -0
  306. package/dist/cdn/pdf-viewer/snice-pdf-viewer.min.js +88 -0
  307. package/dist/cdn/pdf-viewer/snice-pdf-viewer.min.js.map +1 -0
  308. package/dist/cdn/podcast-player/README.md +27 -0
  309. package/dist/cdn/podcast-player/snice-podcast-player.js +835 -0
  310. package/dist/cdn/podcast-player/snice-podcast-player.js.map +1 -0
  311. package/dist/cdn/podcast-player/snice-podcast-player.min.js +209 -0
  312. package/dist/cdn/podcast-player/snice-podcast-player.min.js.map +1 -0
  313. package/dist/cdn/pricing-table/README.md +27 -0
  314. package/dist/cdn/pricing-table/snice-pricing-table.js +491 -0
  315. package/dist/cdn/pricing-table/snice-pricing-table.js.map +1 -0
  316. package/dist/cdn/pricing-table/snice-pricing-table.min.js +141 -0
  317. package/dist/cdn/pricing-table/snice-pricing-table.min.js.map +1 -0
  318. package/dist/cdn/progress/snice-progress.js +1 -1
  319. package/dist/cdn/progress/snice-progress.min.js +1 -1
  320. package/dist/cdn/qr-code/snice-qr-code.js +1 -1
  321. package/dist/cdn/qr-code/snice-qr-code.min.js +1 -1
  322. package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
  323. package/dist/cdn/qr-reader/snice-qr-reader.min.js +1 -1
  324. package/dist/cdn/radio/snice-radio.js +1 -1
  325. package/dist/cdn/radio/snice-radio.min.js +1 -1
  326. package/dist/cdn/rating/README.md +27 -0
  327. package/dist/cdn/rating/snice-rating.js +210 -0
  328. package/dist/cdn/rating/snice-rating.js.map +1 -0
  329. package/dist/cdn/rating/snice-rating.min.js +25 -0
  330. package/dist/cdn/rating/snice-rating.min.js.map +1 -0
  331. package/dist/cdn/recipe/README.md +27 -0
  332. package/dist/cdn/recipe/snice-recipe.js +619 -0
  333. package/dist/cdn/recipe/snice-recipe.js.map +1 -0
  334. package/dist/cdn/recipe/snice-recipe.min.js +185 -0
  335. package/dist/cdn/recipe/snice-recipe.min.js.map +1 -0
  336. package/dist/cdn/runtime/snice-runtime.esm.js +3 -3
  337. package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
  338. package/dist/cdn/runtime/snice-runtime.esm.min.js +3 -3
  339. package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
  340. package/dist/cdn/runtime/snice-runtime.js +3 -3
  341. package/dist/cdn/runtime/snice-runtime.js.map +1 -1
  342. package/dist/cdn/runtime/snice-runtime.min.js +3 -3
  343. package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
  344. package/dist/cdn/sankey/snice-sankey.js +1 -1
  345. package/dist/cdn/sankey/snice-sankey.min.js +1 -1
  346. package/dist/cdn/select/snice-select.js +1 -1
  347. package/dist/cdn/select/snice-select.min.js +1 -1
  348. package/dist/cdn/skeleton/snice-skeleton.js +1 -1
  349. package/dist/cdn/skeleton/snice-skeleton.min.js +1 -1
  350. package/dist/cdn/slider/snice-slider.js +1 -1
  351. package/dist/cdn/slider/snice-slider.min.js +1 -1
  352. package/dist/cdn/sortable/README.md +27 -0
  353. package/dist/cdn/sortable/snice-sortable.js +254 -0
  354. package/dist/cdn/sortable/snice-sortable.js.map +1 -0
  355. package/dist/cdn/sortable/snice-sortable.min.js +12 -0
  356. package/dist/cdn/sortable/snice-sortable.min.js.map +1 -0
  357. package/dist/cdn/sparkline/snice-sparkline.js +1 -1
  358. package/dist/cdn/sparkline/snice-sparkline.min.js +1 -1
  359. package/dist/cdn/spinner/snice-spinner.js +1 -1
  360. package/dist/cdn/spinner/snice-spinner.min.js +1 -1
  361. package/dist/cdn/split-pane/snice-split-pane.js +1 -1
  362. package/dist/cdn/split-pane/snice-split-pane.min.js +1 -1
  363. package/dist/cdn/spotlight/README.md +27 -0
  364. package/dist/cdn/spotlight/snice-spotlight.js +397 -0
  365. package/dist/cdn/spotlight/snice-spotlight.js.map +1 -0
  366. package/dist/cdn/spotlight/snice-spotlight.min.js +8 -0
  367. package/dist/cdn/spotlight/snice-spotlight.min.js.map +1 -0
  368. package/dist/cdn/spreadsheet/README.md +27 -0
  369. package/dist/cdn/spreadsheet/snice-spreadsheet.js +1171 -0
  370. package/dist/cdn/spreadsheet/snice-spreadsheet.js.map +1 -0
  371. package/dist/cdn/spreadsheet/snice-spreadsheet.min.js +30 -0
  372. package/dist/cdn/spreadsheet/snice-spreadsheet.min.js.map +1 -0
  373. package/dist/cdn/stepper/snice-stepper.js +1 -1
  374. package/dist/cdn/stepper/snice-stepper.min.js +1 -1
  375. package/dist/cdn/switch/snice-switch.js +1 -1
  376. package/dist/cdn/switch/snice-switch.min.js +1 -1
  377. package/dist/cdn/table/snice-table.js +1 -1
  378. package/dist/cdn/table/snice-table.min.js +1 -1
  379. package/dist/cdn/tabs/snice-tabs.js +1 -1
  380. package/dist/cdn/tabs/snice-tabs.min.js +1 -1
  381. package/dist/cdn/tag-input/README.md +27 -0
  382. package/dist/cdn/tag-input/snice-tag-input.js +387 -0
  383. package/dist/cdn/tag-input/snice-tag-input.js.map +1 -0
  384. package/dist/cdn/tag-input/snice-tag-input.min.js +65 -0
  385. package/dist/cdn/tag-input/snice-tag-input.min.js.map +1 -0
  386. package/dist/cdn/terminal/snice-terminal.js +1 -1
  387. package/dist/cdn/terminal/snice-terminal.min.js +1 -1
  388. package/dist/cdn/testimonial/README.md +27 -0
  389. package/dist/cdn/testimonial/snice-testimonial.js +187 -0
  390. package/dist/cdn/testimonial/snice-testimonial.js.map +1 -0
  391. package/dist/cdn/testimonial/snice-testimonial.min.js +21 -0
  392. package/dist/cdn/testimonial/snice-testimonial.min.js.map +1 -0
  393. package/dist/cdn/textarea/snice-textarea.js +1 -1
  394. package/dist/cdn/textarea/snice-textarea.min.js +1 -1
  395. package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
  396. package/dist/cdn/time-range-picker/snice-time-range-picker.min.js +1 -1
  397. package/dist/cdn/timeline/snice-timeline.js +1 -1
  398. package/dist/cdn/timeline/snice-timeline.min.js +1 -1
  399. package/dist/cdn/timer/snice-timer.js +1 -1
  400. package/dist/cdn/timer/snice-timer.min.js +1 -1
  401. package/dist/cdn/toast/snice-toast.js +1 -1
  402. package/dist/cdn/toast/snice-toast.min.js +1 -1
  403. package/dist/cdn/tooltip/snice-tooltip.js +1 -1
  404. package/dist/cdn/tooltip/snice-tooltip.min.js +1 -1
  405. package/dist/cdn/tree/snice-tree.js +1 -1
  406. package/dist/cdn/tree/snice-tree.min.js +1 -1
  407. package/dist/cdn/treemap/snice-treemap.js +1 -1
  408. package/dist/cdn/treemap/snice-treemap.min.js +1 -1
  409. package/dist/cdn/video-player/README.md +27 -0
  410. package/dist/cdn/video-player/snice-video-player.js +721 -0
  411. package/dist/cdn/video-player/snice-video-player.js.map +1 -0
  412. package/dist/cdn/video-player/snice-video-player.min.js +153 -0
  413. package/dist/cdn/video-player/snice-video-player.min.js.map +1 -0
  414. package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
  415. package/dist/cdn/virtual-scroller/snice-virtual-scroller.min.js +1 -1
  416. package/dist/cdn/waterfall/README.md +27 -0
  417. package/dist/cdn/waterfall/snice-waterfall.js +292 -0
  418. package/dist/cdn/waterfall/snice-waterfall.js.map +1 -0
  419. package/dist/cdn/waterfall/snice-waterfall.min.js +12 -0
  420. package/dist/cdn/waterfall/snice-waterfall.min.js.map +1 -0
  421. package/dist/cdn/weather/README.md +27 -0
  422. package/dist/cdn/weather/snice-weather.js +194 -0
  423. package/dist/cdn/weather/snice-weather.js.map +1 -0
  424. package/dist/cdn/weather/snice-weather.min.js +42 -0
  425. package/dist/cdn/weather/snice-weather.min.js.map +1 -0
  426. package/dist/components/app-tiles/snice-app-tiles.d.ts +36 -0
  427. package/dist/components/app-tiles/snice-app-tiles.js +265 -0
  428. package/dist/components/app-tiles/snice-app-tiles.js.map +1 -0
  429. package/dist/components/app-tiles/snice-app-tiles.types.d.ts +22 -0
  430. package/dist/components/book/snice-book.d.ts +46 -0
  431. package/dist/components/book/snice-book.js +285 -0
  432. package/dist/components/book/snice-book.js.map +1 -0
  433. package/dist/components/book/snice-book.types.d.ts +21 -0
  434. package/dist/components/comments/snice-comments.d.ts +62 -0
  435. package/dist/components/comments/snice-comments.js +476 -0
  436. package/dist/components/comments/snice-comments.js.map +1 -0
  437. package/dist/components/comments/snice-comments.types.d.ts +64 -0
  438. package/dist/components/countdown/snice-countdown.d.ts +21 -0
  439. package/dist/components/countdown/snice-countdown.js +168 -0
  440. package/dist/components/countdown/snice-countdown.js.map +1 -0
  441. package/dist/components/countdown/snice-countdown.types.d.ts +18 -0
  442. package/dist/components/cropper/snice-cropper.d.ts +32 -0
  443. package/dist/components/cropper/snice-cropper.js +285 -0
  444. package/dist/components/cropper/snice-cropper.js.map +1 -0
  445. package/dist/components/cropper/snice-cropper.types.d.ts +26 -0
  446. package/dist/components/diff/snice-diff.d.ts +32 -0
  447. package/dist/components/diff/snice-diff.js +374 -0
  448. package/dist/components/diff/snice-diff.js.map +1 -0
  449. package/dist/components/diff/snice-diff.types.d.ts +26 -0
  450. package/dist/components/flip-card/snice-flip-card.d.ts +15 -0
  451. package/dist/components/flip-card/snice-flip-card.js +116 -0
  452. package/dist/components/flip-card/snice-flip-card.js.map +1 -0
  453. package/dist/components/flip-card/snice-flip-card.types.d.ts +16 -0
  454. package/dist/components/flow/snice-flow.d.ts +91 -0
  455. package/dist/components/flow/snice-flow.js +755 -0
  456. package/dist/components/flow/snice-flow.js.map +1 -0
  457. package/dist/components/flow/snice-flow.types.d.ts +64 -0
  458. package/dist/components/gantt/snice-gantt.d.ts +34 -0
  459. package/dist/components/gantt/snice-gantt.js +369 -0
  460. package/dist/components/gantt/snice-gantt.js.map +1 -0
  461. package/dist/components/gantt/snice-gantt.types.d.ts +37 -0
  462. package/dist/components/map/snice-map.d.ts +44 -0
  463. package/dist/components/map/snice-map.js +348 -0
  464. package/dist/components/map/snice-map.js.map +1 -0
  465. package/dist/components/map/snice-map.types.d.ts +41 -0
  466. package/dist/components/markdown/snice-markdown.d.ts +24 -0
  467. package/dist/components/markdown/snice-markdown.js +250 -0
  468. package/dist/components/markdown/snice-markdown.js.map +1 -0
  469. package/dist/components/markdown/snice-markdown.types.d.ts +16 -0
  470. package/dist/components/notification-center/snice-notification-center.d.ts +18 -0
  471. package/dist/components/notification-center/snice-notification-center.js +137 -0
  472. package/dist/components/notification-center/snice-notification-center.js.map +1 -0
  473. package/dist/components/notification-center/snice-notification-center.types.d.ts +24 -0
  474. package/dist/components/org-chart/snice-org-chart.d.ts +28 -0
  475. package/dist/components/org-chart/snice-org-chart.js +227 -0
  476. package/dist/components/org-chart/snice-org-chart.js.map +1 -0
  477. package/dist/components/org-chart/snice-org-chart.types.d.ts +28 -0
  478. package/dist/components/pdf-viewer/pdf.min.mjs +21 -0
  479. package/dist/components/pdf-viewer/pdf.worker.min.mjs +21 -0
  480. package/dist/components/pdf-viewer/snice-pdf-viewer.d.ts +59 -0
  481. package/dist/components/pdf-viewer/snice-pdf-viewer.js +527 -0
  482. package/dist/components/pdf-viewer/snice-pdf-viewer.js.map +1 -0
  483. package/dist/components/pdf-viewer/snice-pdf-viewer.types.d.ts +25 -0
  484. package/dist/components/podcast-player/snice-podcast-player.d.ts +72 -0
  485. package/dist/components/podcast-player/snice-podcast-player.js +768 -0
  486. package/dist/components/podcast-player/snice-podcast-player.js.map +1 -0
  487. package/dist/components/podcast-player/snice-podcast-player.types.d.ts +79 -0
  488. package/dist/components/pricing-table/snice-pricing-table.d.ts +51 -0
  489. package/dist/components/pricing-table/snice-pricing-table.js +422 -0
  490. package/dist/components/pricing-table/snice-pricing-table.js.map +1 -0
  491. package/dist/components/pricing-table/snice-pricing-table.types.d.ts +49 -0
  492. package/dist/components/rating/snice-rating.d.ts +15 -0
  493. package/dist/components/rating/snice-rating.js +143 -0
  494. package/dist/components/rating/snice-rating.js.map +1 -0
  495. package/dist/components/rating/snice-rating.types.d.ts +15 -0
  496. package/dist/components/recipe/snice-recipe.d.ts +53 -0
  497. package/dist/components/recipe/snice-recipe.js +552 -0
  498. package/dist/components/recipe/snice-recipe.js.map +1 -0
  499. package/dist/components/recipe/snice-recipe.types.d.ts +56 -0
  500. package/dist/components/sortable/snice-sortable.d.ts +24 -0
  501. package/dist/components/sortable/snice-sortable.js +187 -0
  502. package/dist/components/sortable/snice-sortable.js.map +1 -0
  503. package/dist/components/sortable/snice-sortable.types.d.ts +20 -0
  504. package/dist/components/spotlight/snice-spotlight.d.ts +42 -0
  505. package/dist/components/spotlight/snice-spotlight.js +330 -0
  506. package/dist/components/spotlight/snice-spotlight.js.map +1 -0
  507. package/dist/components/spotlight/snice-spotlight.types.d.ts +26 -0
  508. package/dist/components/spreadsheet/snice-spreadsheet.d.ts +102 -0
  509. package/dist/components/spreadsheet/snice-spreadsheet.js +1104 -0
  510. package/dist/components/spreadsheet/snice-spreadsheet.js.map +1 -0
  511. package/dist/components/spreadsheet/snice-spreadsheet.types.d.ts +54 -0
  512. package/dist/components/tag-input/snice-tag-input.d.ts +40 -0
  513. package/dist/components/tag-input/snice-tag-input.js +320 -0
  514. package/dist/components/tag-input/snice-tag-input.js.map +1 -0
  515. package/dist/components/tag-input/snice-tag-input.types.d.ts +29 -0
  516. package/dist/components/testimonial/snice-testimonial.d.ts +15 -0
  517. package/dist/components/testimonial/snice-testimonial.js +120 -0
  518. package/dist/components/testimonial/snice-testimonial.js.map +1 -0
  519. package/dist/components/testimonial/snice-testimonial.types.d.ts +10 -0
  520. package/dist/components/video-player/snice-video-player.d.ts +78 -0
  521. package/dist/components/video-player/snice-video-player.js +654 -0
  522. package/dist/components/video-player/snice-video-player.js.map +1 -0
  523. package/dist/components/video-player/snice-video-player.types.d.ts +47 -0
  524. package/dist/components/waterfall/snice-waterfall.d.ts +30 -0
  525. package/dist/components/waterfall/snice-waterfall.js +225 -0
  526. package/dist/components/waterfall/snice-waterfall.js.map +1 -0
  527. package/dist/components/waterfall/snice-waterfall.types.d.ts +23 -0
  528. package/dist/components/weather/snice-weather.d.ts +10 -0
  529. package/dist/components/weather/snice-weather.js +127 -0
  530. package/dist/components/weather/snice-weather.js.map +1 -0
  531. package/dist/components/weather/snice-weather.types.d.ts +22 -0
  532. package/dist/index.cjs +1 -1
  533. package/dist/index.esm.js +1 -1
  534. package/dist/index.iife.js +1 -1
  535. package/dist/symbols.cjs +1 -1
  536. package/dist/symbols.esm.js +1 -1
  537. package/dist/transitions.cjs +1 -1
  538. package/dist/transitions.esm.js +1 -1
  539. package/docs/ai/DEVELOPMENT.md +1 -1
  540. package/docs/ai/api.md +6 -3
  541. package/docs/ai/components/accordion.md +0 -34
  542. package/docs/ai/components/app-tiles.md +77 -0
  543. package/docs/ai/components/audio-recorder.md +2 -0
  544. package/docs/ai/components/badge.md +7 -0
  545. package/docs/ai/components/book.md +78 -0
  546. package/docs/ai/components/button.md +5 -0
  547. package/docs/ai/components/chart.md +0 -24
  548. package/docs/ai/components/chat.md +7 -95
  549. package/docs/ai/components/code-block.md +3 -82
  550. package/docs/ai/components/color-display.md +3 -3
  551. package/docs/ai/components/color-picker.md +4 -4
  552. package/docs/ai/components/comments.md +75 -0
  553. package/docs/ai/components/countdown.md +54 -0
  554. package/docs/ai/components/cropper.md +57 -0
  555. package/docs/ai/components/date-picker.md +15 -9
  556. package/docs/ai/components/diff.md +66 -0
  557. package/docs/ai/components/divider.md +1 -1
  558. package/docs/ai/components/draw.md +5 -5
  559. package/docs/ai/components/drawer.md +5 -5
  560. package/docs/ai/components/empty-state.md +2 -2
  561. package/docs/ai/components/file-gallery.md +16 -87
  562. package/docs/ai/components/file-upload.md +6 -6
  563. package/docs/ai/components/flip-card.md +52 -0
  564. package/docs/ai/components/flow.md +104 -0
  565. package/docs/ai/components/funnel.md +3 -3
  566. package/docs/ai/components/gantt.md +63 -0
  567. package/docs/ai/components/gauge.md +1 -1
  568. package/docs/ai/components/heatmap.md +5 -5
  569. package/docs/ai/components/input.md +20 -18
  570. package/docs/ai/components/kanban.md +2 -2
  571. package/docs/ai/components/kpi.md +4 -53
  572. package/docs/ai/components/layout.md +10 -235
  573. package/docs/ai/components/link-preview.md +20 -29
  574. package/docs/ai/components/link.md +27 -47
  575. package/docs/ai/components/list.md +51 -31
  576. package/docs/ai/components/location.md +15 -27
  577. package/docs/ai/components/login.md +43 -94
  578. package/docs/ai/components/map.md +72 -0
  579. package/docs/ai/components/markdown.md +63 -0
  580. package/docs/ai/components/masonry.md +10 -6
  581. package/docs/ai/components/menu.md +40 -72
  582. package/docs/ai/components/modal.md +25 -42
  583. package/docs/ai/components/music-player.md +37 -89
  584. package/docs/ai/components/nav.md +25 -39
  585. package/docs/ai/components/network-graph.md +39 -43
  586. package/docs/ai/components/notification-center.md +79 -0
  587. package/docs/ai/components/org-chart.md +62 -0
  588. package/docs/ai/components/pagination.md +16 -18
  589. package/docs/ai/components/pdf-viewer.md +57 -0
  590. package/docs/ai/components/podcast-player.md +94 -0
  591. package/docs/ai/components/pricing-table.md +87 -0
  592. package/docs/ai/components/progress.md +23 -39
  593. package/docs/ai/components/qr-code.md +37 -84
  594. package/docs/ai/components/qr-reader.md +51 -61
  595. package/docs/ai/components/radio.md +27 -39
  596. package/docs/ai/components/rating.md +56 -0
  597. package/docs/ai/components/recipe.md +90 -0
  598. package/docs/ai/components/skeleton.md +0 -8
  599. package/docs/ai/components/slider.md +10 -50
  600. package/docs/ai/components/sortable.md +57 -0
  601. package/docs/ai/components/sparkline.md +26 -152
  602. package/docs/ai/components/spinner.md +0 -21
  603. package/docs/ai/components/split-pane.md +16 -38
  604. package/docs/ai/components/spotlight.md +61 -0
  605. package/docs/ai/components/spreadsheet.md +138 -0
  606. package/docs/ai/components/stepper.md +37 -183
  607. package/docs/ai/components/switch.md +28 -35
  608. package/docs/ai/components/table.md +43 -172
  609. package/docs/ai/components/tabs.md +31 -52
  610. package/docs/ai/components/tag-input.md +70 -0
  611. package/docs/ai/components/terminal.md +34 -116
  612. package/docs/ai/components/testimonial.md +56 -0
  613. package/docs/ai/components/textarea.md +11 -43
  614. package/docs/ai/components/theme.md +120 -0
  615. package/docs/ai/components/time-range-picker.md +17 -49
  616. package/docs/ai/components/timeline.md +7 -46
  617. package/docs/ai/components/timer.md +41 -37
  618. package/docs/ai/components/toast.md +19 -90
  619. package/docs/ai/components/tooltip.md +17 -104
  620. package/docs/ai/components/tree.md +38 -162
  621. package/docs/ai/components/treemap.md +23 -44
  622. package/docs/ai/components/video-player.md +91 -0
  623. package/docs/ai/components/virtual-scroller.md +23 -46
  624. package/docs/ai/components/waterfall.md +56 -0
  625. package/docs/ai/components/weather.md +78 -0
  626. package/docs/ai/decorators.md +25 -3
  627. package/docs/ai/patterns.md +17 -1
  628. package/docs/components/accordion.md +8 -6
  629. package/docs/components/alert.md +2 -0
  630. package/docs/components/app-tiles.md +162 -0
  631. package/docs/components/audio-recorder.md +6 -0
  632. package/docs/components/avatar.md +225 -0
  633. package/docs/components/badge.md +2 -0
  634. package/docs/components/banner.md +2 -0
  635. package/docs/components/book.md +184 -0
  636. package/docs/components/breadcrumbs.md +2 -0
  637. package/docs/components/button.md +15 -0
  638. package/docs/components/calendar.md +2 -0
  639. package/docs/components/camera-annotate.md +2 -0
  640. package/docs/components/camera.md +2 -0
  641. package/docs/components/candlestick.md +2 -0
  642. package/docs/components/card.md +2 -0
  643. package/docs/components/carousel.md +205 -36
  644. package/docs/components/chart.md +2 -0
  645. package/docs/components/chat.md +2 -0
  646. package/docs/components/checkbox.md +2 -0
  647. package/docs/components/chip.md +2 -0
  648. package/docs/components/code-block.md +2 -0
  649. package/docs/components/color-display.md +2 -0
  650. package/docs/components/color-picker.md +6 -4
  651. package/docs/components/command-palette.md +2 -0
  652. package/docs/components/comments.md +235 -0
  653. package/docs/components/countdown.md +121 -0
  654. package/docs/components/cropper.md +152 -0
  655. package/docs/components/date-picker.md +201 -0
  656. package/docs/components/diff.md +177 -0
  657. package/docs/components/divider.md +132 -0
  658. package/docs/components/doc.md +2 -0
  659. package/docs/components/draw.md +2 -0
  660. package/docs/components/drawer.md +2 -0
  661. package/docs/components/empty-state.md +2 -0
  662. package/docs/components/file-gallery.md +2 -0
  663. package/docs/components/file-upload.md +2 -0
  664. package/docs/components/flip-card.md +169 -0
  665. package/docs/components/flow.md +208 -0
  666. package/docs/components/funnel.md +2 -0
  667. package/docs/components/gantt.md +187 -0
  668. package/docs/components/gauge.md +2 -0
  669. package/docs/components/heatmap.md +2 -0
  670. package/docs/components/image.md +2 -0
  671. package/docs/components/input.md +242 -0
  672. package/docs/components/kanban.md +2 -0
  673. package/docs/components/kpi.md +2 -0
  674. package/docs/components/layout.md +84 -0
  675. package/docs/components/link-preview.md +66 -92
  676. package/docs/components/link.md +73 -157
  677. package/docs/components/list.md +140 -44
  678. package/docs/components/location.md +96 -283
  679. package/docs/components/login.md +131 -498
  680. package/docs/components/map.md +203 -0
  681. package/docs/components/markdown.md +220 -0
  682. package/docs/components/masonry.md +57 -102
  683. package/docs/components/menu.md +87 -494
  684. package/docs/components/modal.md +83 -436
  685. package/docs/components/music-player.md +116 -221
  686. package/docs/components/nav.md +107 -170
  687. package/docs/components/network-graph.md +83 -111
  688. package/docs/components/notification-center.md +256 -0
  689. package/docs/components/org-chart.md +275 -0
  690. package/docs/components/pagination.md +75 -218
  691. package/docs/components/paint.md +108 -73
  692. package/docs/components/pdf-viewer.md +204 -0
  693. package/docs/components/podcast-player.md +277 -0
  694. package/docs/components/pricing-table.md +249 -0
  695. package/docs/components/progress.md +169 -0
  696. package/docs/components/qr-code.md +95 -378
  697. package/docs/components/qr-reader.md +83 -258
  698. package/docs/components/radio.md +151 -0
  699. package/docs/components/rating.md +154 -0
  700. package/docs/components/recipe.md +323 -0
  701. package/docs/components/sankey.md +84 -107
  702. package/docs/components/select.md +114 -485
  703. package/docs/components/skeleton.md +96 -0
  704. package/docs/components/slider.md +92 -235
  705. package/docs/components/sortable.md +267 -0
  706. package/docs/components/sparkline.md +76 -222
  707. package/docs/components/spinner.md +37 -18
  708. package/docs/components/split-pane.md +62 -226
  709. package/docs/components/spotlight.md +240 -0
  710. package/docs/components/spreadsheet.md +405 -0
  711. package/docs/components/stepper.md +72 -306
  712. package/docs/components/switch.md +69 -293
  713. package/docs/components/table.md +250 -0
  714. package/docs/components/tabs.md +92 -471
  715. package/docs/components/tag-input.md +257 -0
  716. package/docs/components/terminal.md +87 -391
  717. package/docs/components/testimonial.md +185 -0
  718. package/docs/components/textarea.md +96 -181
  719. package/docs/components/theme.md +216 -0
  720. package/docs/components/time-range-picker.md +99 -151
  721. package/docs/components/timeline.md +67 -115
  722. package/docs/components/timer.md +44 -86
  723. package/docs/components/toast.md +93 -432
  724. package/docs/components/tooltip.md +75 -419
  725. package/docs/components/tree.md +110 -436
  726. package/docs/components/treemap.md +86 -129
  727. package/docs/components/video-player.md +336 -0
  728. package/docs/components/virtual-scroller.md +86 -226
  729. package/docs/components/waterfall.md +217 -0
  730. package/docs/components/weather.md +239 -0
  731. package/package.json +1 -1
  732. package/docs/ai/components/popover.md +0 -70
  733. package/docs/components/popover.md +0 -333
@@ -0,0 +1,88 @@
1
+ /*!
2
+ * snice v4.9.0
3
+ * Imperative TypeScript framework for building vanilla web components with decorators, differential rendering, routing, and controllers. No virtual DOM, no build complexity.
4
+ * (c) 2024
5
+ * Released under the MIT License.
6
+ */
7
+ void 0===globalThis.Snice&&console.warn("[snice] snice-runtime.min.js must be loaded before snice-pdf-viewer.min.js");var SnicePdfViewer=function(t,e){"use strict";function s(t,e,s,i,n,a){function r(t){if(void 0!==t&&"function"!=typeof t)throw new TypeError("Function expected");return t}for(var o,h=i.kind,l="getter"===h?"get":"setter"===h?"set":"value",c=!e&&t?i.static?t:t.prototype:null,d=e||(c?Object.getOwnPropertyDescriptor(c,i.name):{}),u=!1,p=s.length-1;p>=0;p--){var g={};for(var f in i)g[f]="access"===f?{}:i[f];for(var f in i.access)g.access[f]=i.access[f];g.addInitializer=function(t){if(u)throw new TypeError("Cannot add initializers after decoration has completed");a.push(r(t||null))};var m=(0,s[p])("accessor"===h?{get:d.get,set:d.set}:d[l],g);if("accessor"===h){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(o=r(m.get))&&(d.get=o),(o=r(m.set))&&(d.set=o),(o=r(m.init))&&n.unshift(o)}else(o=r(m))&&("field"===h?n.unshift(o):d[l]=o)}c&&Object.defineProperty(c,i.name,d),u=!0}function i(t,e,s){for(var i=arguments.length>2,n=0;n<e.length;n++)s=i?e[n].call(t,s):e[n].call(t);return i?s:void 0}"function"==typeof SuppressedError&&SuppressedError;var n={d:(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},a=globalThis.pdfjsLib={};
8
+ /**
9
+ * @licstart The following is the entire license notice for the
10
+ * JavaScript code in this page
11
+ *
12
+ * Copyright 2023 Mozilla Foundation
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ *
26
+ * @licend The above is the entire license notice for the
27
+ * JavaScript code in this page
28
+ */n.d(a,{AbortException:()=>D,AnnotationEditorLayer:()=>pi,AnnotationEditorParamsType:()=>u,AnnotationEditorType:()=>d,AnnotationEditorUIManager:()=>kt,AnnotationLayer:()=>ei,AnnotationMode:()=>c,CMapCompressionType:()=>m,ColorPicker:()=>li,DOMSVGFactory:()=>et,DrawLayer:()=>gi,FeatureTest:()=>B,GlobalWorkerOptions:()=>me,ImageKind:()=>g,InvalidPDFException:()=>P,MissingPDFException:()=>R,OPS:()=>v,Outliner:()=>ni,PDFDataRangeTransport:()=>hs,PDFDateString:()=>pt,PDFWorker:()=>ps,PasswordResponses:()=>b,PermissionFlag:()=>p,PixelsPerInch:()=>J,RenderingCancelledException:()=>it,TextLayer:()=>Ye,UnexpectedResponseException:()=>L,Util:()=>z,VerbosityLevel:()=>f,XfaLayer:()=>Es,build:()=>ys,createValidAbsoluteUrl:()=>S,fetchData:()=>Q,getDocument:()=>as,getFilenameFromUrl:()=>rt,getPdfFilenameFromUrl:()=>ot,getXfaPageViewport:()=>gt,isDataScheme:()=>nt,isPdfFile:()=>at,noContextMenu:()=>ct,normalizeUnicode:()=>V,renderTextLayer:()=>Je,setLayerDimensions:()=>bt,shadow:()=>C,updateTextLayer:()=>Qe,version:()=>As});const r=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),o=[1,0,0,1,0,0],h=[.001,0,0,.001,0,0],l=1.35,c={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},d={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},u={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},p={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},g={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},f={ERRORS:0,WARNINGS:1,INFOS:5},m={NONE:0,BINARY:1},v={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},b={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let A=f.WARNINGS;function y(){return A}function _(t){A>=f.INFOS&&console.log(`Info: ${t}`)}function w(t){A>=f.WARNINGS&&console.log(`Warning: ${t}`)}function x(t){throw new Error(t)}function E(t,e){t||x(e)}function S(t,e=null,s=null){if(!t)return null;try{if(s&&"string"==typeof t){if(s.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(s.tryConvertEncoding)try{t=function(t){return decodeURIComponent(escape(t))}(t)}catch{}}const i=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch{}return null}function C(t,e,s,i=!1){return Object.defineProperty(t,e,{value:s,enumerable:!i,configurable:!0,writable:!1}),s}const k=function(){function t(e,s){this.constructor===t&&x("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class M extends k{constructor(t,e){super(t,"PasswordException"),this.code=e}}class T extends k{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class P extends k{constructor(t){super(t,"InvalidPDFException")}}class R extends k{constructor(t){super(t,"MissingPDFException")}}class L extends k{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class I extends k{constructor(t){super(t,"FormatError")}}class D extends k{constructor(t){super(t,"AbortException")}}function F(t){"object"==typeof t&&void 0!==t?.length||x("Invalid argument for bytesToString");const e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);const i=[];for(let n=0;n<e;n+=s){const a=Math.min(n+s,e),r=t.subarray(n,a);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function N(t){"string"!=typeof t&&x("Invalid argument for stringToBytes");const e=t.length,s=new Uint8Array(e);for(let i=0;i<e;++i)s[i]=255&t.charCodeAt(i);return s}function O(t){const e=Object.create(null);for(const[s,i]of t)e[s]=i;return e}class B{static get isLittleEndian(){return C(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return C(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return C(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?C(this,"platform",{isMac:navigator.platform.includes("Mac")}):C(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return C(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const H=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class z{static makeHexColor(t,e,s){return`#${H[t]}${H[e]}${H[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],a[0]),Math.min(s[1],i[1],n[1],a[1]),Math.max(s[0],i[0],n[0],a[0]),Math.max(s[1],i[1],n[1],a[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],r=(s+a)/2,o=Math.sqrt((s+a)**2-4*(s*a-n*i))/2,h=r+o||1,l=r-o||1;return[Math.sqrt(h),Math.sqrt(l)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[s,n,i,a]}static#t(t,e,s,i,n,a,r,o,h,l){if(h<=0||h>=1)return;const c=1-h,d=h*h,u=d*h,p=c*(c*(c*t+3*h*e)+3*d*s)+u*i,g=c*(c*(c*n+3*h*a)+3*d*r)+u*o;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],g),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],g)}static#e(t,e,s,i,n,a,r,o,h,l,c,d){if(Math.abs(h)<1e-12)return void(Math.abs(l)>=1e-12&&this.#t(t,e,s,i,n,a,r,o,-c/l,d));const u=l**2-4*c*h;if(u<0)return;const p=Math.sqrt(u),g=2*h;this.#t(t,e,s,i,n,a,r,o,(-l+p)/g,d),this.#t(t,e,s,i,n,a,r,o,(-l-p)/g,d)}static bezierBoundingBox(t,e,s,i,n,a,r,o,h){return h?(h[0]=Math.min(h[0],t,r),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,r),h[3]=Math.max(h[3],e,o)):h=[Math.min(t,r),Math.min(e,o),Math.max(t,r),Math.max(e,o)],this.#e(t,s,n,r,e,i,a,o,3*(3*(s-n)-t+r),6*(t-2*s+n),3*(s-t),h),this.#e(t,s,n,r,e,i,a,o,3*(3*(i-a)-e+o),6*(e-2*i+a),3*(i-e),h),h}}let j=null,$=null;function V(t){return j||(j=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,$=new Map([["ſt","ſt"]])),t.replaceAll(j,(t,e,s)=>e?e.normalize("NFKC"):$.get(s))}const G="pdfjs_internal_id_";class q{constructor(){this.constructor===q&&x("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class U{#s=!1;constructor({enableHWA:t=!1}={}){this.constructor===U&&x("Cannot initialize BaseCanvasFactory."),this.#s=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#s})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){x("Abstract method `_createCanvas` called.")}}class W{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===W&&x("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":""),s=this.isCompressed?m.BINARY:m.NONE;return this._fetchData(e,s).catch(t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){x("Abstract method `_fetchData` called.")}}class X{constructor({baseUrl:t=null}){this.constructor===X&&x("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch(t=>{throw new Error(`Unable to load font data at: ${e}`)})}_fetchData(t){x("Abstract method `_fetchData` called.")}}class K{constructor(){this.constructor===K&&x("Cannot initialize BaseSVGFactory.")}create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){x("Abstract method `_createSVG` called.")}}const Y="http://www.w3.org/2000/svg";class J{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Q(t,e="text"){if(lt(t,document.baseURI)){const s=await fetch(t);if(!s.ok)throw new Error(s.statusText);switch(e){case"arraybuffer":return s.arrayBuffer();case"blob":return s.blob();case"json":return s.json()}return s.text()}return new Promise((s,i)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)i(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void s(n.response)}s(n.responseText)}},n.send(null)})}class Z extends W{_fetchData(t,e){return Q(t,this.isCompressed?"arraybuffer":"text").then(t=>({cMapData:t instanceof ArrayBuffer?new Uint8Array(t):N(t),compressionType:e}))}}class tt extends X{_fetchData(t){return Q(t,"arraybuffer").then(t=>new Uint8Array(t))}}class et extends K{_createSVG(t){return document.createElementNS(Y,t)}}class st{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const r=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let h,l,c,d,u,p,g,f;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,l=0,c=0,d=1;break;case 90:h=0,l=1,c=1,d=0;break;case 270:h=0,l=-1,c=-1,d=0;break;case 0:h=1,l=0,c=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(c=-c,d=-d),0===h?(u=Math.abs(o-t[1])*e+i,p=Math.abs(r-t[0])*e+n,g=(t[3]-t[1])*e,f=(t[2]-t[0])*e):(u=Math.abs(r-t[0])*e+i,p=Math.abs(o-t[1])*e+n,g=(t[2]-t[0])*e,f=(t[3]-t[1])*e),this.transform=[h*e,l*e,c*e,d*e,u-h*e*r-c*e*o,p-l*e*r-d*e*o],this.width=g,this.height=f}get rawDims(){const{viewBox:t}=this;return C(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new st({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return z.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=z.applyTransform([t[0],t[1]],this.transform),s=z.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return z.applyInverseTransform([t,e],this.transform)}}class it extends k{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function nt(t){const e=t.length;let s=0;for(;s<e&&""===t[s].trim();)s++;return"data:"===t.substring(s,s+5).toLowerCase()}function at(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function rt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function ot(t,e="document.pdf"){if("string"!=typeof t)return e;if(nt(t))return w('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(n&&(n=n[0],n.includes("%")))try{n=s.exec(decodeURIComponent(n))[0]}catch{}return n||e}class ht{started=Object.create(null);times=[];time(t){t in this.started&&w(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||w(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:t}of this.times)e=Math.max(t.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms\n`);return t.join("")}}function lt(t,e){try{const{protocol:s}=e?new URL(t,e):new URL(t);return"http:"===s||"https:"===s}catch{return!1}}function ct(t){t.preventDefault()}function dt(t){console.log("Deprecated API usage: "+t)}let ut;class pt{static toDateObject(t){if(!t||"string"!=typeof t)return null;ut||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=ut.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let r=parseInt(e[5],10);r=r>=0&&r<=59?r:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const h=e[7]||"Z";let l=parseInt(e[8],10);l=l>=0&&l<=23?l:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===h?(a+=l,r+=c):"+"===h&&(a-=l,r-=c),new Date(Date.UTC(s,i,n,a,r,o))}}function gt(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style,a=[0,0,parseInt(i),parseInt(n)];return new st({viewBox:a,scale:e,rotation:s})}function ft(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(w(`Not a valid color format: "${t}"`),[0,0,0])}function mt(t){const{a:e,b:s,c:i,d:n,e:a,f:r}=t.getTransform();return[e,s,i,n,a,r]}function vt(t){const{a:e,b:s,c:i,d:n,e:a,f:r}=t.getTransform().invertSelf();return[e,s,i,n,a,r]}function bt(t,e,s=!1,i=!0){if(e instanceof st){const{pageWidth:i,pageHeight:n}=e.rawDims,{style:a}=t,r=B.isCSSRoundSupported,o=`var(--scale-factor) * ${i}px`,h=`var(--scale-factor) * ${n}px`,l=r?`round(${o}, 1px)`:`calc(${o})`,c=r?`round(${h}, 1px)`:`calc(${h})`;s&&e.rotation%180!=0?(a.width=c,a.height=l):(a.width=l,a.height=c)}i&&t.setAttribute("data-main-rotation",e.rotation)}class At{#i=null;#n=null;#a;#r=null;constructor(t){this.#a=t}render(){const t=this.#i=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#a._uiManager._signal;t.addEventListener("contextmenu",ct,{signal:e}),t.addEventListener("pointerdown",At.#o,{signal:e});const s=this.#r=document.createElement("div");s.className="buttons",t.append(s);const i=this.#a.toolbarPosition;if(i){const{style:e}=t,s="ltr"===this.#a._uiManager.direction?1-i[0]:i[0];e.insetInlineEnd=100*s+"%",e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#h(),t}static#o(t){t.stopPropagation()}#l(t){this.#a._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#c(t){this.#a._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#d(t){const e=this.#a._uiManager._signal;t.addEventListener("focusin",this.#l.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ct,{signal:e})}hide(){this.#i.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#i.classList.remove("hidden")}#h(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#a.editorType}-button`),this.#d(t),t.addEventListener("click",t=>{this.#a._uiManager.delete()},{signal:this.#a._uiManager._signal}),this.#r.append(t)}get#u(){const t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#d(t),this.#r.prepend(t,this.#u)}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#d(e),this.#r.prepend(e,this.#u)}remove(){this.#i.remove(),this.#n?.destroy(),this.#n=null}}class yt{#r=null;#i=null;#p;constructor(t){this.#p=t}#g(){const t=this.#i=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",ct,{signal:this.#p._signal});const e=this.#r=document.createElement("div");return e.className="buttons",t.append(e),this.#f(),t}#m(t,e){let s=0,i=0;for(const n of t){const t=n.y+n.height;if(t<s)continue;const a=n.x+(e?n.width:0);t>s?(i=a,s=t):e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#m(e,s),{style:a}=this.#i||=this.#g();t.append(this.#i),a.insetInlineEnd=100*i+"%",a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#i.remove()}#f(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=this.#p._signal;t.addEventListener("contextmenu",ct,{signal:s}),t.addEventListener("click",()=>{this.#p.highlightSelection("floating_button")},{signal:s}),this.#r.append(t)}}function _t(t,e,s){for(const i of s)e.addEventListener(i,t[i].bind(t))}class wt{#v=0;get id(){return"pdfjs_internal_editor_"+this.#v++}}class xt{#b=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto?.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);if("undefined"!=typeof crypto&&"function"==typeof crypto?.getRandomValues)crypto.getRandomValues(t);else for(let e=0;e<32;e++)t[e]=Math.floor(255*Math.random());return F(t)}();#v=0;#A=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',C(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async#y(t,e){this.#A||=new Map;let s=this.#A.get(t);if(null===s)return null;if(s?.bitmap)return s.refCounter+=1,s;try{let t;if(s||={bitmap:null,id:`image_${this.#b}_${this.#v++}`,refCounter:0,isSvg:!1},"string"==typeof e?(s.url=e,t=await Q(e,"blob")):t=s.file=e,"image/svg+xml"===t.type){const e=xt._isSVGFittingCanvas,i=new FileReader,n=new Image,a=new Promise((t,a)=>{n.onload=()=>{s.bitmap=n,s.isSvg=!0,t()},i.onload=async()=>{const t=s.svgUrl=i.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=i.onerror=a});i.readAsDataURL(t),await a}else s.bitmap=await createImageBitmap(t);s.refCounter=1}catch(t){console.error(t),s=null}return this.#A.set(t,s),s&&this.#A.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#y(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#y(t,t)}async getFromId(t){this.#A||=new Map;const e=this.#A.get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){const e=this.#A.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#A||=new Map;const e=this.#A.get(t);e&&(e.refCounter-=1,0===e.refCounter&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#b}_`)}}class Et{#_=[];#w=!1;#x;#E=-1;constructor(t=128){this.#x=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:r=!1}){if(i&&t(),this.#w)return;const o={cmd:t,undo:e,post:s,type:n};if(-1===this.#E)return this.#_.length>0&&(this.#_.length=0),this.#E=0,void this.#_.push(o);if(a&&this.#_[this.#E].type===n)return r&&(o.undo=this.#_[this.#E].undo),void(this.#_[this.#E]=o);const h=this.#E+1;h===this.#x?this.#_.splice(0,1):(this.#E=h,h<this.#_.length&&this.#_.splice(h)),this.#_.push(o)}undo(){if(-1===this.#E)return;this.#w=!0;const{undo:t,post:e}=this.#_[this.#E];t(),e?.(),this.#w=!1,this.#E-=1}redo(){if(this.#E<this.#_.length-1){this.#E+=1,this.#w=!0;const{cmd:t,post:e}=this.#_[this.#E];t(),e?.(),this.#w=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#_.length-1}destroy(){this.#_=null}}class St{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=B.platform;for(const[s,i,n={}]of t)for(const t of s){const s=t.startsWith("mac+");e&&s?(this.callbacks.set(t.slice(4),{callback:i,options:n}),this.allKeys.add(t.split("+").at(-1))):e||s||(this.callbacks.set(t,{callback:i,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#S(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(this.#S(e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:a=[],checker:r=null}}=s;r&&!r(t,e)||(i.bind(t,...a,e)(),n||(e.stopPropagation(),e.preventDefault()))}}class Ct{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const s of t.keys()){e.style.color=s;const i=window.getComputedStyle(e).color;t.set(s,ft(i))}e.remove()}(t),C(this,"_colors",t)}convert(t){const e=ft(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,s]of this._colors)if(s.every((t,s)=>t===e[s]))return Ct._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?z.makeHexColor(...e):t}}class kt{#C=new AbortController;#k=null;#M=new Map;#T=new Map;#P=null;#R=null;#L=null;#I=new Et;#D=0;#F=new Set;#N=null;#O=null;#B=new Set;#H=!1;#z=null;#j=null;#$=null;#V=!1;#G=null;#q=new wt;#U=!1;#W=!1;#X=null;#K=null;#Y=null;#J=d.NONE;#Q=new Set;#Z=null;#tt=null;#et=null;#st=this.blur.bind(this);#it=this.focus.bind(this);#nt=this.copy.bind(this);#at=this.cut.bind(this);#rt=this.paste.bind(this);#ot=this.keydown.bind(this);#ht=this.keyup.bind(this);#lt=this.onEditingAction.bind(this);#ct=this.onPageChanging.bind(this);#dt=this.onScaleChanging.bind(this);#ut=this.onRotationChanging.bind(this);#pt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#gt=[0,0];#ft=null;#mt=null;#vt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=kt.prototype,e=t=>t.#mt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return C(this,"_keyboardManager",new St([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,a,r,o,h){this._signal=this.#C.signal,this.#mt=t,this.#vt=e,this.#P=s,this._eventBus=i,this._eventBus._on("editingaction",this.#lt),this._eventBus._on("pagechanging",this.#ct),this._eventBus._on("scalechanging",this.#dt),this._eventBus._on("rotationchanging",this.#ut),this.#bt(),this.#At(),this.#yt(),this.#R=n.annotationStorage,this.#z=n.filterFactory,this.#tt=a,this.#$=r||null,this.#H=o,this.#Y=h||null,this.viewParameters={realScale:J.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#C?.abort(),this.#C=null,this._signal=null,this._eventBus._off("editingaction",this.#lt),this._eventBus._off("pagechanging",this.#ct),this._eventBus._off("scalechanging",this.#dt),this._eventBus._off("rotationchanging",this.#ut);for(const t of this.#T.values())t.destroy();this.#T.clear(),this.#M.clear(),this.#B.clear(),this.#k=null,this.#Q.clear(),this.#I.destroy(),this.#P?.destroy(),this.#G?.hide(),this.#G=null,this.#j&&(clearTimeout(this.#j),this.#j=null),this.#ft&&(clearTimeout(this.#ft),this.#ft=null)}async mlGuess(t){return this.#Y?.guess(t)||null}get hasMLManager(){return!!this.#Y}get hcmFilter(){return C(this,"hcmFilter",this.#tt?this.#z.addHCMFilter(this.#tt.foreground,this.#tt.background):"none")}get direction(){return C(this,"direction",getComputedStyle(this.#mt).direction)}get highlightColors(){return C(this,"highlightColors",this.#$?new Map(this.#$.split(",").map(t=>t.split("=").map(t=>t.trim()))):null)}get highlightColorNames(){return C(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){this.#K=t}editAltText(t){this.#P?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#D=t-1}focusMainContainer(){this.#mt.focus()}findParent(t,e){for(const s of this.#T.values()){const{x:i,y:n,width:a,height:r}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=n&&e<=n+r)return s}return null}disableUserSelect(t=!1){this.#vt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#B.add(t)}removeShouldRescale(t){this.#B.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*J.PDF_TO_CSS_UNITS;for(const t of this.#B)t.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#_t({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a}=e,r=e.toString(),o=this.#_t(e).closest(".textLayer"),h=this.getSelectionBoxes(o);if(h){e.empty(),this.#J===d.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:d.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const e of this.#T.values())if(e.hasTextLayer(o)){e.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a,text:r});break}}}#wt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#_t(t).closest(".textLayer"),s=this.getSelectionBoxes(e);s&&(this.#G||=new yt(this),this.#G.show(e,s,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#R||this.#R.has(t.id)||this.#R.setValue(t.id,t)}#xt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#Z&&(this.#G?.hide(),this.#Z=null,this.#Et({hasSelectedText:!1})));const{anchorNode:e}=t;if(e!==this.#Z)if(this.#_t(t).closest(".textLayer")){if(this.#G?.hide(),this.#Z=e,this.#Et({hasSelectedText:!0}),(this.#J===d.HIGHLIGHT||this.#J===d.NONE)&&(this.#J===d.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#V=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this._signal,e=t=>{"pointerup"===t.type&&0!==t.button||(window.removeEventListener("pointerup",e),window.removeEventListener("blur",e),"pointerup"===t.type&&this.#St("main_toolbar"))};window.addEventListener("pointerup",e,{signal:t}),window.addEventListener("blur",e,{signal:t})}}else this.#Z&&(this.#G?.hide(),this.#Z=null,this.#Et({hasSelectedText:!1}))}#St(t=""){this.#J===d.HIGHLIGHT?this.highlightSelection(t):this.#H&&this.#wt()}#bt(){document.addEventListener("selectionchange",this.#xt.bind(this),{signal:this._signal})}#Ct(){const t=this._signal;window.addEventListener("focus",this.#it,{signal:t}),window.addEventListener("blur",this.#st,{signal:t})}#kt(){window.removeEventListener("focus",this.#it),window.removeEventListener("blur",this.#st)}blur(){if(this.isShiftKeyDown=!1,this.#V&&(this.#V=!1,this.#St("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#Q)if(e.div.contains(t)){this.#X=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#X)return;const[t,e]=this.#X;this.#X=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#yt(){const t=this._signal;window.addEventListener("keydown",this.#ot,{signal:t}),window.addEventListener("keyup",this.#ht,{signal:t})}#Mt(){window.removeEventListener("keydown",this.#ot),window.removeEventListener("keyup",this.#ht)}#Tt(){const t=this._signal;document.addEventListener("copy",this.#nt,{signal:t}),document.addEventListener("cut",this.#at,{signal:t}),document.addEventListener("paste",this.#rt,{signal:t})}#Pt(){document.removeEventListener("copy",this.#nt),document.removeEventListener("cut",this.#at),document.removeEventListener("paste",this.#rt)}#At(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#yt(),this.#Tt()}removeEditListeners(){this.#Mt(),this.#Pt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#O)if(s.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#O)if(s.isHandlingMimeForPasting(e.type))return s.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#k?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#Q){const s=t.serialize(!0);s&&e.push(s)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#O)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(t){return void w(`paste: "${t.message}".`)}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const t=[];for(const e of s){const s=i.deserialize(e);if(!s)return;t.push(s)}const e=()=>{for(const e of t)this.#Rt(e);this.#Lt(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){w(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#J===d.NONE||this.isEditorHandlingKeyboard||kt._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#V&&(this.#V=!1,this.#St("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#Et(t){Object.entries(t).some(([t,e])=>this.#pt[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#pt,t)}),this.#J===d.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#It([[u.HIGHLIGHT_FREE,!0]]))}#It(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Tt(),this.#Et({isEditing:this.#J!==d.NONE,isEmpty:this.#Dt(),hasSomethingToUndo:this.#I.hasSomethingToUndo(),hasSomethingToRedo:this.#I.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#kt(),this.#Pt(),this.#Et({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#O){this.#O=t;for(const t of this.#O)this.#It(t.defaultPropertiesToUpdate)}}getId(){return this.#q.id}get currentLayer(){return this.#T.get(this.#D)}getLayer(t){return this.#T.get(t)}get currentPageIndex(){return this.#D}addLayer(t){this.#T.set(t.pageIndex,t),this.#U?t.enable():t.disable()}removeLayer(t){this.#T.delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(this.#J!==t)if(this.#J=t,t!==d.NONE){this.setEditingState(!0),this.#Ft(),this.unselectAll();for(const e of this.#T.values())e.updateMode(t);if(e||!s){if(e)for(const t of this.#M.values())if(t.annotationElementId===e){this.setSelected(t),t.enterInEditMode();break}}else this.addNewEditorFromKeyboard()}else this.setEditingState(!1),this.#Nt()}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#J&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#O){switch(t){case u.CREATE:return void this.currentLayer.addNewEditor();case u.HIGHLIGHT_DEFAULT_COLOR:this.#K?.updateColor(e);break;case u.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#et||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const s of this.#Q)s.updateParams(t,e);for(const s of this.#O)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const s of this.#M.values())s.editorType===t&&s.show(e);(this.#et?.get(u.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#It([[u.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#W!==t){this.#W=t;for(const e of this.#T.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}#Ft(){if(!this.#U){this.#U=!0;for(const t of this.#T.values())t.enable();for(const t of this.#M.values())t.enable()}}#Nt(){if(this.unselectAll(),this.#U){this.#U=!1;for(const t of this.#T.values())t.disable();for(const t of this.#M.values())t.disable()}}getEditors(t){const e=[];for(const s of this.#M.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#M.get(t)}addEditor(t){this.#M.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#j&&clearTimeout(this.#j),this.#j=setTimeout(()=>{this.focusMainContainer(),this.#j=null},0)),this.#M.delete(t.id),this.unselect(t),t.annotationElementId&&this.#F.has(t.annotationElementId)||this.#R?.remove(t.id)}addDeletedAnnotationElement(t){this.#F.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#F.has(t)}removeDeletedAnnotationElement(t){this.#F.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Rt(t){const e=this.#T.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#k!==t&&(this.#k=t,t&&this.#It(t.propertiesToUpdate))}get#Ot(){let t=null;for(t of this.#Q);return t}updateUI(t){this.#Ot===t&&this.#It(t.propertiesToUpdate)}toggleSelected(t){this.#Q.has(t)?(this.#Q.delete(t),t.unselect(),this.#Et({hasSelectedEditor:this.hasSelection})):(this.#Q.add(t),t.select(),this.#It(t.propertiesToUpdate),this.#Et({hasSelectedEditor:!0}))}setSelected(t){for(const e of this.#Q)e!==t&&e.unselect();this.#Q.clear(),this.#Q.add(t),t.select(),this.#It(t.propertiesToUpdate),this.#Et({hasSelectedEditor:!0})}isSelected(t){return this.#Q.has(t)}get firstSelectedEditor(){return this.#Q.values().next().value}unselect(t){t.unselect(),this.#Q.delete(t),this.#Et({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#Q.size}get isEnterHandled(){return 1===this.#Q.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#I.undo(),this.#Et({hasSomethingToUndo:this.#I.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Dt()})}redo(){this.#I.redo(),this.#Et({hasSomethingToUndo:!0,hasSomethingToRedo:this.#I.hasSomethingToRedo(),isEmpty:this.#Dt()})}addCommands(t){this.#I.add(t),this.#Et({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Dt()})}#Dt(){if(0===this.#M.size)return!0;if(1===this.#M.size)for(const t of this.#M.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#Q];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)this.#Rt(e)},mustExec:!0})}commitOrRemove(){this.#k?.commitOrRemove()}hasSomethingToControl(){return this.#k||this.hasSelection}#Lt(t){for(const t of this.#Q)t.unselect();this.#Q.clear();for(const e of t)e.isEmpty()||(this.#Q.add(e),e.select());this.#Et({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#Q)t.commit();this.#Lt(this.#M.values())}unselectAll(){if((!this.#k||(this.#k.commitOrRemove(),this.#J===d.NONE))&&this.hasSelection){for(const t of this.#Q)t.unselect();this.#Q.clear(),this.#Et({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#gt[0]+=t,this.#gt[1]+=e;const[i,n]=this.#gt,a=[...this.#Q];this.#ft&&clearTimeout(this.#ft),this.#ft=setTimeout(()=>{this.#ft=null,this.#gt[0]=this.#gt[1]=0,this.addCommands({cmd:()=>{for(const t of a)this.#M.has(t.id)&&t.translateInPage(i,n)},undo:()=>{for(const t of a)this.#M.has(t.id)&&t.translateInPage(-i,-n)},mustExec:!1})},1e3);for(const s of a)s.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#N=new Map;for(const t of this.#Q)this.#N.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#N)return!1;this.disableUserSelect(!1);const t=this.#N;this.#N=null;let e=!1;for(const[{x:s,y:i,pageIndex:n},a]of t)a.newX=s,a.newY=i,a.newPageIndex=n,e||=s!==a.savedX||i!==a.savedY||n!==a.savedPageIndex;if(!e)return!1;const s=(t,e,s,i)=>{if(this.#M.has(t.id)){const n=this.#T.get(i);n?t._setParentAndPosition(n,e,s):(t.pageIndex=i,t.x=e,t.y=s)}};return this.addCommands({cmd:()=>{for(const[e,{newX:i,newY:n,newPageIndex:a}]of t)s(e,i,n,a)},undo:()=>{for(const[e,{savedX:i,savedY:n,savedPageIndex:a}]of t)s(e,i,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#N)for(const s of this.#N.keys())s.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#Q.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#k===t}getActive(){return this.#k}getMode(){return this.#J}get imageManager(){return C(this,"imageManager",new xt)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let s=0,i=e.rangeCount;s<i;s++)if(!t.contains(e.getRangeAt(s).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-i)/a,y:1-(t+r-s)/n,width:o/a,height:r/n});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-s)/n,y:1-(e+o-i)/a,width:r/n,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-i)/a,y:(t-s)/n,width:o/a,height:r/n});break;default:r=(t,e,r,o)=>({x:(t-s)/n,y:(e-i)/a,width:r/n,height:o/a})}const o=[];for(let t=0,s=e.rangeCount;t<s;t++){const s=e.getRangeAt(t);if(!s.collapsed)for(const{x:t,y:e,width:i,height:n}of s.getClientRects())0!==i&&0!==n&&o.push(r(t,e,i,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#L||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#L?.delete(t)}renderAnnotationElement(t){const e=this.#L?.get(t.data.id);if(!e)return;const s=this.#R.getRawValue(e);s&&(this.#J!==d.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}}class Mt{#Bt="";#Ht=!1;#zt=null;#jt=null;#$t=null;#Vt=!1;#a=null;static _l10nPromise=null;constructor(t){this.#a=t}static initialize(t){Mt._l10nPromise||=t}async render(){const t=this.#zt=document.createElement("button");t.className="altText";const e=await Mt._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";const s=this.#a._uiManager._signal;t.addEventListener("contextmenu",ct,{signal:s}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:s});const i=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#Vt=!0,i(e))},{signal:s}),await this.#Gt(),t}finish(){this.#zt&&(this.#zt.focus({focusVisible:this.#Vt}),this.#Vt=!1)}isEmpty(){return!this.#Bt&&!this.#Ht}get data(){return{altText:this.#Bt,decorative:this.#Ht}}set data({altText:t,decorative:e}){this.#Bt===t&&this.#Ht===e||(this.#Bt=t,this.#Ht=e,this.#Gt())}toggle(t=!1){this.#zt&&(!t&&this.#$t&&(clearTimeout(this.#$t),this.#$t=null),this.#zt.disabled=!t)}destroy(){this.#zt?.remove(),this.#zt=null,this.#jt=null}async#Gt(){const t=this.#zt;if(!t)return;if(!this.#Bt&&!this.#Ht)return t.classList.remove("done"),void this.#jt?.remove();t.classList.add("done"),Mt._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(e=>{t.setAttribute("aria-label",e)});let e=this.#jt;if(!e){this.#jt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");const s=e.id=`alt-text-tooltip-${this.#a.id}`;t.setAttribute("aria-describedby",s);const i=100,n=this.#a._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#$t),this.#$t=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#$t=setTimeout(()=>{this.#$t=null,this.#jt.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#$t&&(clearTimeout(this.#$t),this.#$t=null),this.#jt?.classList.remove("show")},{signal:n})}e.innerText=this.#Ht?await Mt._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#Bt,e.parentNode||t.append(e);const s=this.#a.getImageForAltText();s?.setAttribute("aria-describedby",e.id)}}class Tt{#qt=null;#Ut=null;#Bt=null;#Wt=!1;#Xt=!1;#Kt=null;#Yt=null;#Jt=this.focusin.bind(this);#Qt=this.focusout.bind(this);#Zt=null;#te="";#ee=!1;#se=null;#ie=!1;#ne=!1;#ae=!1;#re=null;#oe=0;#he=0;#le=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#ce=!1;#de=Tt._zIndex++;static _borderLineWidth=-1;static _colorManager=new Ct;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=Tt.prototype._resizeWithKeyboard,e=kt.TRANSLATE_SMALL,s=kt.TRANSLATE_BIG;return C(this,"_resizerKeyboardManager",new St([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],Tt.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===Tt&&x("Cannot initialize AnnotationEditor."),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,a];const[r,o]=this.parentDimensions;this.x=t.x/r,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return C(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Pt({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e,s){if(Tt._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(e=>[e,t.get(e.replaceAll(/([A-Z])/g,t=>`-${t.toLowerCase()}`))])),s?.strings)for(const e of s.strings)Tt._l10nPromise.set(e,t.get(e));if(-1!==Tt._borderLineWidth)return;const i=getComputedStyle(document.documentElement);Tt._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){x("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ce}set _isDraggable(t){this.#ce=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#de}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#ue(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ee?this.#ee=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/a,this.fixAndSetPosition()}#pe([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()}translate(t,e){this.#pe(this.parentDimensions,t,e)}translateInPage(t,e){this.#se||=[this.x,this.y],this.#pe(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#se||=[this.x,this.y];const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[r,o]=this.getBaseTranslation();n+=r,a+=o,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#se&&(this.#se[0]!==this.x||this.#se[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=Tt,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:a,height:r}=this;if(a*=e,r*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-a,i)),n=Math.max(0,Math.min(s-r,n));break;case 90:i=Math.max(0,Math.min(e-r,i)),n=Math.min(s,Math.max(a,n));break;case 180:i=Math.min(e,Math.max(a,i)),n=Math.min(s,Math.max(r,n));break;case 270:i=Math.min(e,Math.max(r,i)),n=Math.max(0,Math.min(s-a,n))}this.x=i/=e,this.y=n/=s;const[o,h]=this.getBaseTranslation();i+=o,n+=h;const{style:l}=this.div;l.left=`${(100*i).toFixed(2)}%`,l.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#ge(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return Tt.#ge(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Tt.#ge(t,e,360-this.parentRotation)}#fe(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this,i=e*t,n=s*t;return B.isCSSRoundSupported?[Math.round(i),Math.round(n)]:[i,n]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,this.#Xt||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!this.#Xt&&e.endsWith("%");if(i&&n)return;const[a,r]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),this.#Xt||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#me(){if(this.#Kt)return;this.#Kt=document.createElement("div"),this.#Kt.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const t=document.createElement("div");this.#Kt.append(t),t.classList.add("resizer",s),t.setAttribute("data-resizer-name",s),t.addEventListener("pointerdown",this.#ve.bind(this,s),{signal:e}),t.addEventListener("contextmenu",ct,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#Kt)}#ve(t,e){e.preventDefault();const{isMac:s}=B.platform;if(0!==e.button||e.ctrlKey&&s)return;this.#Bt?.toggle(!1);const i=this.#be.bind(this,t),n=this._isDraggable;this._isDraggable=!1;const a=this._uiManager._signal,r={passive:!0,capture:!0,signal:a};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,r),window.addEventListener("contextmenu",ct,{signal:a});const o=this.x,h=this.y,l=this.width,c=this.height,d=this.parent.div.style.cursor,u=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const p=()=>{this.parent.togglePointerEvents(!0),this.#Bt?.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",p),window.removeEventListener("blur",p),window.removeEventListener("pointermove",i,r),window.removeEventListener("contextmenu",ct),this.parent.div.style.cursor=d,this.div.style.cursor=u,this.#Ae(o,h,l,c)};window.addEventListener("pointerup",p,{signal:a}),window.addEventListener("blur",p,{signal:a})}#Ae(t,e,s,i){const n=this.x,a=this.y,r=this.width,o=this.height;n===t&&a===e&&r===s&&o===i||this.addCommands({cmd:()=>{this.width=r,this.height=o,this.x=n,this.y=a;const[t,e]=this.parentDimensions;this.setDims(t*r,e*o),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[n,a]=this.parentDimensions;this.setDims(n*s,a*i),this.fixAndSetPosition()},mustExec:!0})}#be(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,r=this.width,o=this.height,h=Tt.MIN_SIZE/s,l=Tt.MIN_SIZE/i,c=t=>Math.round(1e4*t)/1e4,d=this.#fe(this.rotation),u=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],p=this.#fe(360-this.rotation);let g,f,m=!1,v=!1;switch(t){case"topLeft":m=!0,g=(t,e)=>[0,0],f=(t,e)=>[t,e];break;case"topMiddle":g=(t,e)=>[t/2,0],f=(t,e)=>[t/2,e];break;case"topRight":m=!0,g=(t,e)=>[t,0],f=(t,e)=>[0,e];break;case"middleRight":v=!0,g=(t,e)=>[t,e/2],f=(t,e)=>[0,e/2];break;case"bottomRight":m=!0,g=(t,e)=>[t,e],f=(t,e)=>[0,0];break;case"bottomMiddle":g=(t,e)=>[t/2,e],f=(t,e)=>[t/2,0];break;case"bottomLeft":m=!0,g=(t,e)=>[0,e],f=(t,e)=>[t,0];break;case"middleLeft":v=!0,g=(t,e)=>[0,e/2],f=(t,e)=>[t,e/2]}const b=g(r,o),A=f(r,o);let y=u(...A);const _=c(n+y[0]),w=c(a+y[1]);let x=1,E=1,[S,C]=this.screenToPageTranslation(e.movementX,e.movementY);var k,M;if([S,C]=(k=S/s,M=C/i,[p[0]*k+p[2]*M,p[1]*k+p[3]*M]),m){const t=Math.hypot(r,o);x=E=Math.max(Math.min(Math.hypot(A[0]-b[0]-S,A[1]-b[1]-C)/t,1/r,1/o),h/r,l/o)}else v?x=Math.max(h,Math.min(1,Math.abs(A[0]-b[0]-S)))/r:E=Math.max(l,Math.min(1,Math.abs(A[1]-b[1]-C)))/o;const T=c(r*x),P=c(o*E);y=u(...f(T,P));const R=_-y[0],L=w-y[1];this.width=T,this.height=P,this.x=R,this.y=L,this.setDims(s*T,i*P),this.fixAndSetPosition()}altTextFinish(){this.#Bt?.finish()}async addEditToolbar(){return this.#Zt||this.#ne||(this.#Zt=new At(this),this.div.append(this.#Zt.render()),this.#Bt&&this.#Zt.addAltTextButton(await this.#Bt.render())),this.#Zt}removeEditToolbar(){this.#Zt&&(this.#Zt.remove(),this.#Zt=null,this.#Bt?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#Bt||(Mt.initialize(Tt._l10nPromise),this.#Bt=new Mt(this),this.#qt&&(this.#Bt.data=this.#qt,this.#qt=null),await this.addEditToolbar())}get altTextData(){return this.#Bt?.data}set altTextData(t){this.#Bt&&(this.#Bt.data=t)}hasAltText(){return!this.#Bt?.isEmpty()}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#Wt?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",this.#Jt,{signal:t}),this.div.addEventListener("focusout",this.#Qt,{signal:t});const[e,s]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*s/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),_t(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=B.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ee=!0,this._isDraggable?this.#ye(t):this.#_e(t))}#_e(t){const{isMac:e}=B.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#ye(t){const e=this._uiManager.isSelected(this);let s,i;this._uiManager.setUpDragSession();const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),s={passive:!0,capture:!0,signal:n},this.#oe=t.clientX,this.#he=t.clientY,i=t=>{const{clientX:e,clientY:s}=t,[i,n]=this.screenToPageTranslation(e-this.#oe,s-this.#he);this.#oe=e,this.#he=s,this._uiManager.dragSelectedEditors(i,n)},window.addEventListener("pointermove",i,s));const a=()=>{window.removeEventListener("pointerup",a),window.removeEventListener("blur",a),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),this.#ee=!1,this._uiManager.endDragSession()||this.#_e(t)};window.addEventListener("pointerup",a,{signal:n}),window.addEventListener("blur",a,{signal:n})}moveInDOM(){this.#re&&clearTimeout(this.#re),this.#re=setTimeout(()=>{this.#re=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,a]=this.pageDimensions,[r,o]=this.pageTranslation,h=t/i,l=e/i,c=this.x*n,d=this.y*a,u=this.width*n,p=this.height*a;switch(s){case 0:return[c+h+r,a-d-l-p+o,c+h+u+r,a-d-l+o];case 90:return[c+l+r,a-d+h+o,c+l+p+r,a-d+h+u+o];case 180:return[c-h-u+r,a-d+l+o,c-h+r,a-d+l+p+o];case 270:return[c-l-p+r,a-d-h-u+o,c-l+r,a-d-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,r=n-s,o=a-i;switch(this.rotation){case 0:return[s,e-a,r,o];case 90:return[s,e-i,o,r];case 180:return[n,e-i,r,o];case 270:return[n,e-a,o,r];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#ne=!0}disableEditMode(){this.#ne=!1}isInEditMode(){return this.#ne}shouldGetKeyboardEvents(){return this.#ae}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){const t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#Jt,{signal:t}),this.div?.addEventListener("focusout",this.#Qt,{signal:t})}rotate(t){}serialize(t=!1,e=null){x("An editor must be serializable")}static deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,i.#qt=t.accessibilityData;const[n,a]=i.pageDimensions,[r,o,h,l]=i.getRectInCurrentCoords(t.rect,a);return i.x=r/n,i.y=o/a,i.width=h/n,i.height=l/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.div.removeEventListener("focusin",this.#Jt),this.div.removeEventListener("focusout",this.#Qt),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#re&&(clearTimeout(this.#re),this.#re=null),this.#ue(),this.removeEditToolbar(),this.#le){for(const t of this.#le.values())clearTimeout(t);this.#le=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#me(),this.#Kt.classList.remove("hidden"),_t(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#Yt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#Kt.children;if(!this.#Ut){this.#Ut=Array.from(e);const t=this.#we.bind(this),s=this.#xe.bind(this),i=this._uiManager._signal;for(const e of this.#Ut){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:i}),e.addEventListener("blur",s,{signal:i}),e.addEventListener("focus",this.#Ee.bind(this,n),{signal:i}),Tt._l10nPromise.get(`pdfjs-editor-resizer-label-${n}`).then(t=>e.setAttribute("aria-label",t))}}const s=this.#Ut[0];let i=0;for(const t of e){if(t===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#Ut.length/4);if(n!==i){if(n<i)for(let t=0;t<i-n;t++)this.#Kt.append(this.#Kt.firstChild);else if(n>i)for(let t=0;t<n-i;t++)this.#Kt.firstChild.before(this.#Kt.lastChild);let t=0;for(const s of e){const e=this.#Ut[t++].getAttribute("data-resizer-name");Tt._l10nPromise.get(`pdfjs-editor-resizer-label-${e}`).then(t=>s.setAttribute("aria-label",t))}}this.#Se(0),this.#ae=!0,this.#Kt.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#we(t){Tt._resizerKeyboardManager.exec(this,t)}#xe(t){this.#ae&&t.relatedTarget?.parentNode!==this.#Kt&&this.#ue()}#Ee(t){this.#te=this.#ae?t:""}#Se(t){if(this.#Ut)for(const e of this.#Ut)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#ae&&this.#be(this.#te,{movementX:t,movementY:e})}#ue(){if(this.#ae=!1,this.#Se(-1),this.#Yt){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#Yt;this.#Ae(t,e,s,i),this.#Yt=null}}_stopResizingWithKeyboard(){this.#ue(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this.#Zt?this.#Zt?.show():this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#Zt?.show()})}unselect(){this.#Kt?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#Zt?.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#ie}set isEditing(t){this.#ie=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#Xt=!0;const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#le||=new Map;const{action:e}=t;let s=this.#le.get(e);s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(t),this.#le.delete(e),0===this.#le.size&&(this.#le=null)},Tt._telemetryTimeout),this.#le.set(e,s)}else t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#Wt=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Wt=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class Pt extends Tt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const Rt=3285377520,Lt=4294901760,It=65535;class Dt{constructor(t){this.h1=t?4294967295&t:Rt,this.h2=t?4294967295&t:Rt}update(t){let e,s;if("string"==typeof t){e=new Uint8Array(2*t.length),s=0;for(let i=0,n=t.length;i<n;i++){const n=t.charCodeAt(i);n<=255?e[s++]=n:(e[s++]=n>>>8,e[s++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),s=e.byteLength}const i=s>>2,n=s-4*i,a=new Uint32Array(e.buffer,0,i);let r=0,o=0,h=this.h1,l=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let t=0;t<i;t++)1&t?(r=a[t],r=r*c&Lt|r*u&It,r=r<<15|r>>>17,r=r*d&Lt|r*p&It,h^=r,h=h<<13|h>>>19,h=5*h+3864292196):(o=a[t],o=o*c&Lt|o*u&It,o=o<<15|o>>>17,o=o*d&Lt|o*p&It,l^=o,l=l<<13|l>>>19,l=5*l+3864292196);switch(r=0,n){case 3:r^=e[4*i+2]<<16;case 2:r^=e[4*i+1]<<8;case 1:r^=e[4*i],r=r*c&Lt|r*u&It,r=r<<15|r>>>17,r=r*d&Lt|r*p&It,1&i?h^=r:l^=r}this.h1=h,this.h2=l}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Lt|36045*t&It,e=4283543511*e&Lt|(2950163797*(e<<16|t>>>16)&Lt)>>>16,t^=e>>>1,t=444984403*t&Lt|60499*t&It,e=3301882366*e&Lt|(3120437893*(e<<16|t>>>16)&Lt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Ft=Object.freeze({map:null,hash:"",transfer:void 0});class Nt{#Ce=!1;#ke=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#ke.get(t);return void 0===s?e:Object.assign(e,s)}getRawValue(t){return this.#ke.get(t)}remove(t){if(this.#ke.delete(t),0===this.#ke.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#ke.values())if(t instanceof Tt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#ke.get(t);let i=!1;if(void 0!==s)for(const[t,n]of Object.entries(e))s[t]!==n&&(i=!0,s[t]=n);else i=!0,this.#ke.set(t,e);i&&this.#Me(),e instanceof Tt&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#ke.has(t)}getAll(){return this.#ke.size>0?O(this.#ke):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#ke.size}#Me(){this.#Ce||(this.#Ce=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Ce&&(this.#Ce=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Ot(this)}get serializable(){if(0===this.#ke.size)return Ft;const t=new Map,e=new Dt,s=[],i=Object.create(null);let n=!1;for(const[s,a]of this.#ke){const r=a instanceof Tt?a.serialize(!1,i):a;r&&(t.set(s,r),e.update(`${s}:${JSON.stringify(r)}`),n||=!!r.bitmap)}if(n)for(const e of t.values())e.bitmap&&s.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Ft}get editorStats(){let t=null;const e=new Map;for(const s of this.#ke.values()){if(!(s instanceof Tt))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const a=t[n]||=new Map;for(const[t,e]of Object.entries(i)){if("type"===t)continue;let s=a.get(t);s||(s=new Map,a.set(t,s));const i=s.get(e)??0;s.set(e,i+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}}class Ot extends Nt{#Te;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#Te={map:n,hash:s,transfer:i}}get print(){x("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Te}}class Bt{#Pe=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#Pe.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#Pe.has(t.loadedName))if(E(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,a=new FontFace(s,i,n);this.addNativeFontFace(a);try{await a.load(),this.#Pe.add(s),e?.(t)}catch{w(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else x("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(s){throw w(`Failed to load font '${e.family}': '${s}'.`),t.disableFontFace=!0,s}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{const s=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,s)})}}get isFontLoadingAPISupported(){return C(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(r||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),C(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,s={done:!1,complete:function(){for(E(!s.done,"completeRequest() cannot be called twice."),s.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(s),s}get _loadTestFont(){return C(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function s(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function i(t,e,s,i){return t.substring(0,e)+i+t.substring(e+s)}let n,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.getContext("2d");let h=0;const l=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=i(c,976,l.length,l);const d=1482184792;let u=s(c,16);for(n=0,a=l.length-3;n<a;n+=4)u=u-d+s(l,n)|0;n<l.length&&(u=u-d+s(l+"XXX",n)|0),c=i(c,16,4,function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}(u));const p=`@font-face {font-family:"${l}";src:url(data:font/opentype;base64,${btoa(c)});}`;this.insertRule(p);const g=this._document.createElement("div");g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px";for(const e of[t.loadedName,l]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,g.append(t)}this._document.body.append(g),function t(e,s){if(++h>30)return w("Load test font never loaded."),void s();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?s():setTimeout(t.bind(null,e,s))}(l,()=>{g.remove(),e.complete()})}}class Ht{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=F(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),s}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(t){w(`getPathGenerator - ignoring character: "${t}".`)}if(!Array.isArray(s)||0===s.length)return this.compiledGlyphs[e]=function(t,e){};const i=[];for(let t=0,e=s.length;t<e;)switch(s[t++]){case 0:{const[e,n,a,r,o,h]=s.slice(t,t+6);i.push(t=>t.bezierCurveTo(e,n,a,r,o,h)),t+=6}break;case 1:{const[e,n]=s.slice(t,t+2);i.push(t=>t.moveTo(e,n)),t+=2}break;case 2:{const[e,n]=s.slice(t,t+2);i.push(t=>t.lineTo(e,n)),t+=2}break;case 3:{const[e,n,a,r]=s.slice(t,t+4);i.push(t=>t.quadraticCurveTo(e,n,a,r)),t+=4}break;case 4:i.push(t=>t.restore());break;case 5:i.push(t=>t.save());break;case 6:E(2===i.length,"Scale command is only valid at the third position.");break;case 7:{const[e,n,a,r,o,h]=s.slice(t,t+6);i.push(t=>t.transform(e,n,a,r,o,h)),t+=6}break;case 8:{const[e,n]=s.slice(t,t+2);i.push(t=>t.translate(e,n)),t+=2}}return this.compiledGlyphs[e]=function(t,e){i[0](t),i[1](t),t.scale(e,-e);for(let e=2,s=i.length;e<s;e++)i[e](t)}}}if(r){var zt=Promise.withResolvers(),jt=null;(async()=>{const t=await import("fs"),e=await import("http"),s=await import("https"),i=await import("url");return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:void 0,path2d:void 0}))})().then(t=>{jt=t,zt.resolve()},t=>{w(`loadPackages: ${t}`),jt=new Map,zt.resolve()})}class $t{static get promise(){return zt.promise}static get(t){return jt?.get(t)}}const Vt=function(t){return $t.get("fs").promises.readFile(t).then(t=>new Uint8Array(t))},Gt="Fill",qt="Stroke",Ut="Shading";function Wt(t,e){if(!e)return;const s=e[2]-e[0],i=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],s,i),t.clip(n)}class Xt{constructor(){this.constructor===Xt&&x("Cannot initialize BaseShadingPattern.")}getPattern(){x("Abstract method `getPattern` called.")}}class Kt extends Xt{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,s,i){let n;if(i===qt||i===Gt){const a=e.current.getClippedPathBoundingBox(i,mt(t))||[0,0,0,0],r=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,h=e.cachedCanvases.getCanvas("pattern",r,o,!0),l=h.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-a[0],-a[1]),s=z.transform(s,[1,0,0,1,a[0],a[1]]),l.transform(...e.baseTransform),this.matrix&&l.transform(...this.matrix),Wt(l,this._bbox),l.fillStyle=this._createGradient(l),l.fill(),n=t.createPattern(h.canvas,"no-repeat");const c=new DOMMatrix(s);n.setTransform(c)}else Wt(t,this._bbox),n=this._createGradient(t);return n}}function Yt(t,e,s,i,n,a,r,o){const h=e.coords,l=e.colors,c=t.data,d=4*t.width;let u;h[s+1]>h[i+1]&&(u=s,s=i,i=u,u=a,a=r,r=u),h[i+1]>h[n+1]&&(u=i,i=n,n=u,u=r,r=o,o=u),h[s+1]>h[i+1]&&(u=s,s=i,i=u,u=a,a=r,r=u);const p=(h[s]+e.offsetX)*e.scaleX,g=(h[s+1]+e.offsetY)*e.scaleY,f=(h[i]+e.offsetX)*e.scaleX,m=(h[i+1]+e.offsetY)*e.scaleY,v=(h[n]+e.offsetX)*e.scaleX,b=(h[n+1]+e.offsetY)*e.scaleY;if(g>=b)return;const A=l[a],y=l[a+1],_=l[a+2],w=l[r],x=l[r+1],E=l[r+2],S=l[o],C=l[o+1],k=l[o+2],M=Math.round(g),T=Math.round(b);let P,R,L,I,D,F,N,O;for(let t=M;t<=T;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);P=p-(p-f)*e,R=A-(A-w)*e,L=y-(y-x)*e,I=_-(_-E)*e}else{let e;e=t>b?1:m===b?0:(m-t)/(m-b),P=f-(f-v)*e,R=w-(w-S)*e,L=x-(x-C)*e,I=E-(E-k)*e}let e;e=t<g?0:t>b?1:(g-t)/(g-b),D=p-(p-v)*e,F=A-(A-S)*e,N=y-(y-C)*e,O=_-(_-k)*e;const s=Math.round(Math.min(P,D)),i=Math.round(Math.max(P,D));let n=d*t+4*s;for(let t=s;t<=i;t++)e=(P-t)/(P-D),e<0?e=0:e>1&&(e=1),c[n++]=R-(R-F)*e|0,c[n++]=L-(L-N)*e|0,c[n++]=I-(I-O)*e|0,c[n++]=255}}function Jt(t,e,s){const i=e.coords,n=e.colors;let a,r;switch(e.type){case"lattice":const o=e.verticesPerRow,h=Math.floor(i.length/o)-1,l=o-1;for(a=0;a<h;a++){let e=a*o;for(let a=0;a<l;a++,e++)Yt(t,s,i[e],i[e+1],i[e+o],n[e],n[e+1],n[e+o]),Yt(t,s,i[e+o+1],i[e+1],i[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(a=0,r=i.length;a<r;a+=3)Yt(t,s,i[a],i[a+1],i[a+2],n[a],n[a+1],n[a+2]);break;default:throw new Error("illegal figure")}}class Qt extends Xt{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-i,r=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),h=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3),l=a/o,c=r/h,d={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-n,scaleX:1/l,scaleY:1/c},u=o+4,p=h+4,g=s.getCanvas("mesh",u,p,!1),f=g.context,m=f.createImageData(o,h);if(e){const t=m.data;for(let s=0,i=t.length;s<i;s+=4)t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=255}for(const t of this._figures)Jt(m,t,d);return f.putImageData(m,2,2),{canvas:g.canvas,offsetX:i-2*l,offsetY:n-2*c,scaleX:l,scaleY:c}}getPattern(t,e,s,i){let n;if(Wt(t,this._bbox),i===Ut)n=z.singularValueDecompose2dScale(mt(t));else if(n=z.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=z.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const a=this._createMeshCanvas(n,i===Ut?null:this._background,e.cachedCanvases);return i!==Ut&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class Zt extends Xt{getPattern(){return"hotpink"}}class te{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,i=this.xstep,n=this.ystep,a=this.paintType,r=this.tilingType,o=this.color,h=this.canvasGraphicsFactory;_("TilingType: "+r);const l=s[0],c=s[1],d=s[2],u=s[3],p=z.singularValueDecompose2dScale(this.matrix),g=z.singularValueDecompose2dScale(this.baseTransform),f=[p[0]*g[0],p[1]*g[1]],m=this.getSizeAndScale(i,this.ctx.canvas.width,f[0]),v=this.getSizeAndScale(n,this.ctx.canvas.height,f[1]),b=t.cachedCanvases.getCanvas("pattern",m.size,v.size,!0),A=b.context,y=h.createCanvasGraphics(A);y.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(y,a,o);let w=l,x=c,E=d,S=u;return l<0&&(w=0,E+=Math.abs(l)),c<0&&(x=0,S+=Math.abs(c)),A.translate(-m.scale*w,-v.scale*x),y.transform(m.scale,0,0,v.scale,0,0),A.save(),this.clipBbox(y,w,x,E,S),y.baseTransform=mt(y.ctx),y.executeOperatorList(e),y.endDrawing(),{canvas:b.canvas,scaleX:m.scale,scaleY:v.scale,offsetX:w,offsetY:x}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(te.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const a=i-e,r=n-s;t.ctx.rect(e,s,a,r),t.current.updateRectMinMax(mt(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case 1:const t=this.ctx;i.fillStyle=t.fillStyle,i.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case 2:const a=z.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new I(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==Ut&&(n=z.transform(n,e.baseTransform),this.matrix&&(n=z.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let r=new DOMMatrix(n);r=r.translate(a.offsetX,a.offsetY),r=r.scale(1/a.scaleX,1/a.scaleY);const o=t.createPattern(a.canvas,"repeat");return o.setTransform(r),o}}function ee({src:t,srcPos:e=0,dest:s,width:i,height:n,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=B.isLittleEndian?4278190080:255,[h,l]=r?[a,o]:[o,a],c=i>>3,d=7&i,u=t.length;s=new Uint32Array(s.buffer);let p=0;for(let i=0;i<n;i++){for(const i=e+c;e<i;e++){const i=e<u?t[e]:255;s[p++]=128&i?l:h,s[p++]=64&i?l:h,s[p++]=32&i?l:h,s[p++]=16&i?l:h,s[p++]=8&i?l:h,s[p++]=4&i?l:h,s[p++]=2&i?l:h,s[p++]=1&i?l:h}if(0===d)continue;const i=e<u?t[e++]:255;for(let t=0;t<d;t++)s[p++]=i&1<<7-t?l:h}return{srcPos:e,destPos:p}}const se=16;class ie{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return void 0!==this.cache[t]?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function ne(t,e,s,i,n,a,r,o,h,l){const[c,d,u,p,g,f]=mt(t);if(0===d&&0===u){const m=r*c+g,v=Math.round(m),b=o*p+f,A=Math.round(b),y=(r+h)*c+g,_=Math.abs(Math.round(y)-v)||1,w=(o+l)*p+f,x=Math.abs(Math.round(w)-A)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),v,A),t.drawImage(e,s,i,n,a,0,0,_,x),t.setTransform(c,d,u,p,g,f),[_,x]}if(0===c&&0===p){const m=o*u+g,v=Math.round(m),b=r*d+f,A=Math.round(b),y=(o+l)*u+g,_=Math.abs(Math.round(y)-v)||1,w=(r+h)*d+f,x=Math.abs(Math.round(w)-A)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,v,A),t.drawImage(e,s,i,n,a,0,0,x,_),t.setTransform(c,d,u,p,g,f),[x,_]}return t.drawImage(e,s,i,n,a,r,o,h,l),[Math.hypot(c,d)*h,Math.hypot(u,p)*l]}class ae{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=o,this.textMatrixScale=1,this.fontMatrix=h,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=0,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=z.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=z.applyTransform(e,t),i=z.applyTransform(e.slice(2),t),n=z.applyTransform([e[0],e[3]],t),a=z.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],a[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],a[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],a[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],a[1])}updateScalingPathMinMax(t,e){z.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,a,r,o,h,l){const c=z.bezierBoundingBox(e,s,i,n,a,r,o,h,l);l||this.updateRectMinMax(t,c)}getPathBoundingBox(t=Gt,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===qt){e||x("Stroke bounding box must include transform.");const t=z.singularValueDecompose2dScale(e),i=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;s[0]-=i,s[1]-=n,s[2]+=i,s[3]+=n}return s}updateClipFromPath(){const t=z.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Gt,e=null){return z.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function re(t,e){if("undefined"!=typeof ImageData&&e instanceof ImageData)return void t.putImageData(e,0,0);const s=e.height,i=e.width,n=s%se,a=(s-n)/se,r=0===n?a:a+1,o=t.createImageData(i,se);let h,l=0;const c=e.data,d=o.data;let u,p,f,m;if(e.kind===g.GRAYSCALE_1BPP){const e=c.byteLength,s=new Uint32Array(d.buffer,0,d.byteLength>>2),g=s.length,m=i+7>>3,v=4294967295,b=B.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(f=u<a?se:n,h=0,p=0;p<f;p++){const t=e-l;let n=0;const a=t>m?i:8*t-7,r=-8&a;let o=0,d=0;for(;n<r;n+=8)d=c[l++],s[h++]=128&d?v:b,s[h++]=64&d?v:b,s[h++]=32&d?v:b,s[h++]=16&d?v:b,s[h++]=8&d?v:b,s[h++]=4&d?v:b,s[h++]=2&d?v:b,s[h++]=1&d?v:b;for(;n<a;n++)0===o&&(d=c[l++],o=128),s[h++]=d&o?v:b,o>>=1}for(;h<g;)s[h++]=0;t.putImageData(o,0,u*se)}}else if(e.kind===g.RGBA_32BPP){for(p=0,m=i*se*4,u=0;u<a;u++)d.set(c.subarray(l,l+m)),l+=m,t.putImageData(o,0,p),p+=se;u<r&&(m=i*n*4,d.set(c.subarray(l,l+m)),t.putImageData(o,0,p))}else{if(e.kind!==g.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(f=se,m=i*f,u=0;u<r;u++){for(u>=a&&(f=n,m=i*f),h=0,p=m;p--;)d[h++]=c[l++],d[h++]=c[l++],d[h++]=c[l++],d[h++]=255;t.putImageData(o,0,u*se)}}}function oe(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const s=e.height,i=e.width,n=s%se,a=(s-n)/se,r=0===n?a:a+1,o=t.createImageData(i,se);let h=0;const l=e.data,c=o.data;for(let e=0;e<r;e++){const s=e<a?se:n;({srcPos:h}=ee({src:l,srcPos:h,dest:c,width:i,height:s,nonBlackColor:0})),t.putImageData(o,0,e*se)}}function he(t,e){const s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of s)void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function le(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!r){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function ce(t,e){if(e)return!0;const s=z.singularValueDecompose2dScale(t);s[0]=Math.fround(s[0]),s[1]=Math.fround(s[1]);const i=Math.fround((globalThis.devicePixelRatio||1)*J.PDF_TO_CSS_UNITS);return s[0]<=i&&s[1]<=i}const de=["butt","round","square"],ue=["miter","round","bevel"],pe={},ge={};class fe{constructor(t,e,s,i,n,{optionalContentConfig:a,markedContentStack:r=null},o,h){this.ctx=t,this.current=new ae(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=r||[],this.optionalContentConfig=a,this.cachedCanvases=new ie(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,a=this.ctx.canvas.height,r=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=r,s){const t=this.cachedCanvases.getCanvas("transparent",n,a);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...mt(this.compositeCtx))}this.ctx.save(),le(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=mt(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,a=t.fnArray;let r=e||0;const o=n.length;if(o===r)return r;const h=o-r>10&&"function"==typeof s,l=h?Date.now()+15:0;let c=0;const d=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==i&&r===i.nextBreakPoint)return i.breakIt(r,s),r;if(p=a[r],p!==v.dependency)this[p].apply(this,n[r]);else for(const t of n[r]){const e=t.startsWith("g_")?d:u;if(!e.has(t))return e.get(t,s),r}if(r++,r===o)return r;if(h&&++c>10){if(Date.now()>l)return s(),r;c=0}}}#Re(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#Re(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#Le()}#Le(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const s=t.width,i=t.height;let n,a,r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),h=s,l=i,c="prescale1";for(;r>2&&h>1||o>2&&l>1;){let e=h,s=l;r>2&&h>1&&(e=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h/2),r/=h/e),o>2&&l>1&&(s=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,o/=l/s),n=this.cachedCanvases.getCanvas(c,e,s),a=n.context,a.clearRect(0,0,e,s),a.drawImage(t,0,0,h,l,0,0,e,s),t=n.canvas,h=e,l=s,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:h,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,a=this.current.patternFill,r=mt(e);let o,h,l,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;h=JSON.stringify(a?r:[r.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const s=o.get(h);if(s&&!a)return{canvas:s,offsetX:Math.round(Math.min(r[0],r[2])+r[4]),offsetY:Math.round(Math.min(r[1],r[3])+r[5])};l=s}l||(c=this.cachedCanvases.getCanvas("maskCanvas",s,i),oe(c.context,t));let d=z.transform(r,[1/s,0,0,-1/i,0,0]);d=z.transform(d,[1,0,0,1,0,-i]);const[u,p,g,f]=z.getAxialAlignedBoundingBox([0,0,s,i],d),m=Math.round(g-u)||1,v=Math.round(f-p)||1,b=this.cachedCanvases.getCanvas("fillCanvas",m,v),A=b.context,y=u,_=p;A.translate(-y,-_),A.transform(...d),l||(l=this._scaleImage(c.canvas,vt(A)),l=l.img,o&&a&&o.set(h,l)),A.imageSmoothingEnabled=ce(mt(A),t.interpolate),ne(A,l,0,0,l.width,l.height,0,0,s,i),A.globalCompositeOperation="source-in";const w=z.transform(vt(A),[1,0,0,1,-y,-_]);return A.fillStyle=a?n.getPattern(e,this,w,Gt):n,A.fillRect(0,0,s,i),o&&!a&&(this.cachedCanvases.delete("fillCanvas"),o.set(h,b.canvas)),{canvas:b.canvas,offsetX:Math.round(y),offsetY:Math.round(_)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=de[t]}setLineJoin(t){this.ctx.lineJoin=ue[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...mt(this.suspendedCtx)),he(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,s){e.translate(t,s),this.__originalTranslate(t,s)},t.scale=function(t,s){e.scale(t,s),this.__originalScale(t,s)},t.transform=function(t,s,i,n,a,r){e.transform(t,s,i,n,a,r),this.__originalTransform(t,s,i,n,a,r)},t.setTransform=function(t,s,i,n,a,r){e.setTransform(t,s,i,n,a,r),this.__originalSetTransform(t,s,i,n,a,r)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,s){e.moveTo(t,s),this.__originalMoveTo(t,s)},t.lineTo=function(t,s){e.lineTo(t,s),this.__originalLineTo(t,s)},t.bezierCurveTo=function(t,s,i,n,a,r){e.bezierCurveTo(t,s,i,n,a,r),this.__originalBezierCurveTo(t,s,i,n,a,r)},t.rect=function(t,s,i,n){e.rect(t,s,i,n),this.__originalRect(t,s,i,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),he(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){const n=i[0],a=i[1],r=i[2]-n,o=i[3]-a;0!==r&&0!==o&&(this.genericComposeSMask(e.context,s,r,o,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,a,r,o,h,l,c){let d=t.canvas,u=o-l,p=h-c;if(a)if(u<0||p<0||u+s>d.width||p+i>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",s,i),e=t.context;e.drawImage(d,-u,-p),a.some(t=>0!==t)&&(e.globalCompositeOperation="destination-atop",e.fillStyle=z.makeHexColor(...a),e.fillRect(0,0,s,i),e.globalCompositeOperation="source-over"),d=t.canvas,u=p=0}else if(a.some(t=>0!==t)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,p,s,i),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=z.makeHexColor(...a),t.fillRect(u,p,s,i),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&r?e.filter=this.filterFactory.addAlphaFilter(r):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(r));const g=new Path2D;g.rect(o,h,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,s,i,o,h,s,i),e.restore()}save(){this.inSMaskMode?(he(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),he(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,a){this.ctx.transform(t,e,s,i,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let a,r,o=n.x,h=n.y;const l=mt(i),c=0===l[0]&&0===l[3]||0===l[1]&&0===l[2],d=c?s.slice(0):null;for(let s=0,u=0,p=t.length;s<p;s++)switch(0|t[s]){case v.rectangle:o=e[u++],h=e[u++];const t=e[u++],s=e[u++],p=o+t,g=h+s;i.moveTo(o,h),0===t||0===s?i.lineTo(p,g):(i.lineTo(p,h),i.lineTo(p,g),i.lineTo(o,g)),c||n.updateRectMinMax(l,[o,h,p,g]),i.closePath();break;case v.moveTo:o=e[u++],h=e[u++],i.moveTo(o,h),c||n.updatePathMinMax(l,o,h);break;case v.lineTo:o=e[u++],h=e[u++],i.lineTo(o,h),c||n.updatePathMinMax(l,o,h);break;case v.curveTo:a=o,r=h,o=e[u+4],h=e[u+5],i.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,h),n.updateCurvePathMinMax(l,a,r,e[u],e[u+1],e[u+2],e[u+3],o,h,d),u+=6;break;case v.curveTo2:a=o,r=h,i.bezierCurveTo(o,h,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(l,a,r,o,h,e[u],e[u+1],e[u+2],e[u+3],d),o=e[u+2],h=e[u+3],u+=4;break;case v.curveTo3:a=o,r=h,o=e[u+2],h=e[u+3],i.bezierCurveTo(e[u],e[u+1],o,h,o,h),n.updateCurvePathMinMax(l,a,r,e[u],e[u+1],o,h,o,h,d),u+=4;break;case v.closePath:i.closePath()}c&&n.updateScalingPathMinMax(l,d),n.setCurrentPoint(o,h)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof s&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,vt(e),qt),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,s=this.current.fillColor;let i=!1;this.current.patternFill&&(e.save(),e.fillStyle=s.getPattern(e,this,vt(e),Gt),i=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),i&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=pe}eoClip(){this.pendingClip=ge}beginText(){this.current.textMatrix=o,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||h,0!==i.fontMatrix[0]&&0!==i.fontMatrix[3]||w("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",a=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`;let r="normal";s.black?r="900":s.bold&&(r="bold");const o=s.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${r} ${l}px ${a}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,a){this.current.textMatrix=[t,e,s,i,n,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const n=this.ctx,a=this.current,r=a.font,o=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,l=3&o,c=!!(4&o),d=a.patternFill&&!r.missingFile;let u;(r.disableFontFace||c||d)&&(u=r.getPathGenerator(this.commonObjs,t)),r.disableFontFace||d?(n.save(),n.translate(e,s),n.beginPath(),u(n,h),i&&n.setTransform(...i),0!==l&&2!==l||n.fill(),1!==l&&2!==l||n.stroke(),n.restore()):(0!==l&&2!==l||n.fillText(t,e,s),1!==l&&2!==l||n.strokeText(t,e,s)),c&&(this.pendingTextPaths||=[]).push({transform:mt(n),x:e,y:s,fontSize:h,addToPath:u})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){s=!0;break}return C(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(0===i)return;const n=this.ctx,a=e.fontSizeScale,r=e.charSpacing,o=e.wordSpacing,h=e.fontDirection,l=e.textHScale*h,c=t.length,d=s.vertical,u=d?1:-1,p=s.defaultVMetrics,g=i*e.fontMatrix[0],f=0===e.textRenderingMode&&!s.disableFontFace&&!e.patternFill;let m;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(l,-1):n.scale(l,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,vt(n),Gt);m=mt(n),n.restore(),n.fillStyle=t}let v=e.lineWidth;const b=e.textMatrixScale;if(0===b||0===v){const t=3&e.textRenderingMode;1!==t&&2!==t||(v=this.getSinglePixelWidth())}else v/=b;if(1!==a&&(n.scale(a,a),v/=a),n.lineWidth=v,s.isInvalidPDFjsFont){const s=[];let i=0;for(const e of t)s.push(e.unicode),i+=e.width;return n.fillText(s.join(""),0,0),e.x+=i*g*l,n.restore(),void this.compose()}let A,y=0;for(A=0;A<c;++A){const e=t[A];if("number"==typeof e){y+=u*e*i/1e3;continue}let l=!1;const c=(e.isSpace?o:0)+r,v=e.fontChar,b=e.accent;let _,w,x=e.width;if(d){const t=e.vmetric||p,s=-(e.vmetric?t[1]:.5*x)*g,i=t[2]*g;x=t?-t[0]:x,_=s/a,w=(y+i)/a}else _=y/a,w=0;if(s.remeasure&&x>0){const t=1e3*n.measureText(v).width/i*a;if(x<t&&this.isFontSubpixelAAEnabled){const e=x/t;l=!0,n.save(),n.scale(e,1),_/=e}else x!==t&&(_+=(x-t)/2e3*i/a)}if(this.contentVisible&&(e.isInFont||s.missingFile))if(f&&!b)n.fillText(v,_,w);else if(this.paintChar(v,_,w,m),b){const t=_+i*b.offset.x/a,e=w-i*b.offset.y/a;this.paintChar(b.fontChar,t,e,m)}y+=d?x*g-c*h:x*g+c*h,l&&n.restore()}d?e.y-=y:e.x+=y*l,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,a=s.fontDirection,r=i.vertical?1:-1,o=s.charSpacing,l=s.wordSpacing,c=s.textHScale*a,d=s.fontMatrix||h,u=t.length;let p,g,f,m;if(3!==s.textRenderingMode&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(c,a),p=0;p<u;++p){if(g=t[p],"number"==typeof g){m=r*g*n/1e3,this.ctx.translate(m,0),s.x+=m*c;continue}const a=(g.isSpace?l:0)+o,h=i.charProcOperatorList[g.operatorListId];h?(this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(h),this.restore()),f=z.applyTransform([g.width,0],d)[0]*n+a,e.translate(f,0),s.x+=f*c):w(`Type3 character "${g.operatorListId}" is not available.`)}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,a){this.ctx.rect(s,i,n-s,a-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const s=t[1],i=this.baseTransform||mt(this.ctx),n={createCanvasGraphics:t=>new fe(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new te(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const i=z.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=z.makeHexColor(t,e,s);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=function(t){switch(t[0]){case"RadialAxial":return new Kt(t);case"Mesh":return new Qt(t);case"Dummy":return new Zt}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,vt(e),Ut);const i=vt(e);if(i){const{width:t,height:s}=e.canvas,[n,a,r,o]=z.getAxialAlignedBoundingBox([0,0,t,s],i);this.ctx.fillRect(n,a,r-n,o-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){x("Should not call beginInlineImage")}beginImageData(){x("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=mt(this.ctx),e)){const t=e[2]-e[0],s=e[3]-e[1];this.ctx.rect(e[0],e[1],t,s),this.current.updateRectMinMax(mt(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||_("TODO: Support non-isolated groups."),t.knockout&&w("Knockout groups not supported.");const s=mt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=z.getAxialAlignedBoundingBox(t.bbox,mt(e));const n=[0,0,e.canvas.width,e.canvas.height];i=z.intersect(i,n)||[0,0,0,0];const a=Math.floor(i[0]),r=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-a,1),h=Math.max(Math.ceil(i[3])-r,1);this.current.startNewPathAndClipBox([0,0,o,h]);let l="groupAt"+this.groupLevel;t.smask&&(l+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(l,o,h),d=c.context;d.translate(-a,-r),d.transform(...s),t.smask?this.smaskStack.push({canvas:c.canvas,context:d,offsetX:a,offsetY:r,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,r),e.save()),he(e,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=mt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const s=z.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(t,e,s,i,n){if(this.#Re(),le(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const i=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=i,e[3]=a;const[n,r]=z.singularValueDecompose2dScale(mt(this.ctx)),{viewportScale:o}=this,h=Math.ceil(i*this.outputScaleX*o),l=Math.ceil(a*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(h,l);const{canvas:c,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(t,c),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(n,0,0,-r,0,a*r),le(this.ctx)}else le(this.ctx),this.ctx.rect(e[0],e[1],i,a),this.ctx.clip(),this.endPath()}this.current=new ae(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#Le(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const s=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(t){const{width:e,height:s}=t;if(e>1e3||s>1e3)return null;const i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let a,r,o,h=new Uint8Array(n*(s+1));const l=e+7&-8;let c=new Uint8Array(l*s),d=0;for(const e of t.data){let t=128;for(;t>0;)c[d++]=e&t?0:255,t>>=1}let u=0;for(d=0,0!==c[d]&&(h[0]=1,++u),r=1;r<e;r++)c[d]!==c[d+1]&&(h[r]=c[d]?2:1,++u),d++;for(0!==c[d]&&(h[r]=2,++u),a=1;a<s;a++){d=a*l,o=a*n,c[d-l]!==c[d]&&(h[o]=c[d]?1:8,++u);let t=(c[d]?4:0)+(c[d-l]?8:0);for(r=1;r<e;r++)t=(t>>2)+(c[d+1]?4:0)+(c[d-l+1]?8:0),i[t]&&(h[o+r]=i[t],++u),d++;if(c[d-l]!==c[d]&&(h[o+r]=c[d]?2:4,++u),u>1e3)return null}for(d=l*(s-1),o=a*n,0!==c[d]&&(h[o]=8,++u),r=1;r<e;r++)c[d]!==c[d+1]&&(h[o+r]=c[d]?4:8,++u),d++;if(0!==c[d]&&(h[o+r]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;u&&a<=s;a++){let t=a*n;const s=t+e;for(;t<s&&!h[t];)t++;if(t===s)continue;g.moveTo(t%n,a);const i=t;let r=h[t];do{const e=p[r];do{t+=e}while(!h[t]);const s=h[t];5!==s&&10!==s?(r=s,h[t]=0):(r=s&51*r>>4,h[t]&=r>>2|r<<2),g.lineTo(t%n,t/n|0),h[t]||--u}while(i!==t);--a}return c=null,h=null,function(t){t.save(),t.scale(1/e,-1/s),t.translate(0,-s),t.fill(g),t.beginPath(),t.restore()}}(t)),i.compiled))return void i.compiled(s);const n=this._createMaskCanvas(t),a=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const r=this.ctx;r.save();const o=mt(r);r.transform(e,s,i,n,0,0);const h=this._createMaskCanvas(t);r.setTransform(1,0,0,1,h.offsetX-o[4],h.offsetY-o[5]);for(let t=0,l=a.length;t<l;t+=2){const l=z.transform(o,[e,s,i,n,a[t],a[t+1]]),[c,d]=z.applyTransform([0,0],l);r.drawImage(h.canvas,c,d)}r.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:t,width:a,height:r,transform:o}=n,h=this.cachedCanvases.getCanvas("maskCanvas",a,r),l=h.context;l.save(),oe(l,this.getObject(t,n)),l.globalCompositeOperation="source-in",l.fillStyle=i?s.getPattern(l,this,vt(e),Gt):s,l.fillRect(0,0,a,r),l.restore(),e.save(),e.transform(...o),e.scale(1,-1),ne(e,h.canvas,0,0,a,r,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):w("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void w("Dependent image isn't ready yet");const a=n.width,r=n.height,o=[];for(let t=0,n=i.length;t<n;t+=2)o.push({transform:[e,0,0,s,i[t],i[t+1]],x:0,y:0,w:a,h:r});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!r){const{filter:t}=i;"none"!==t&&""!==t&&(i.filter="none")}let n;if(i.scale(1/e,-1/s),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const i=this.cachedCanvases.getCanvas("inlineImage",e,s).context;re(i,t),n=this.applyTransferMapsToCanvas(i)}const a=this._scaleImage(n,vt(i));i.imageSmoothingEnabled=ce(mt(i),t.interpolate),ne(i,a.img,0,0,a.paintWidth,a.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const e=t.width,s=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,s).context;re(n,t),i=this.applyTransferMapsToCanvas(n)}for(const t of e)s.save(),s.transform(...t.transform),s.scale(1,-1),ne(s,i,t.x,t.y,t.w,t.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===ge?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=mt(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let a,r;if(0===s&&0===i){const s=Math.abs(e),i=Math.abs(n);if(s===i)if(0===t)a=r=1/s;else{const e=s*t;a=r=e<1?1/e:1}else if(0===t)a=1/s,r=1/i;else{const e=s*t,n=i*t;a=e<1?1/e:1,r=n<1?1/n:1}}else{const o=Math.abs(e*n-s*i),h=Math.hypot(e,s),l=Math.hypot(i,n);if(0===t)a=l/o,r=h/o;else{const e=t*o;a=l>e?l/e:1,r=h>e?h/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,1===i&&1===n)return void e.stroke();const a=e.getLineDash();if(t&&e.save(),e.scale(i,n),a.length>0){const t=Math.max(i,n);e.setLineDash(a.map(e=>e/t)),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in v)void 0!==fe.prototype[t]&&(fe.prototype[v[t]]=fe.prototype[t]);class me{static#Ie=null;static#De="";static get workerPort(){return this.#Ie}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Ie=t}static get workerSrc(){return this.#De}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#De=t}}function ve(t){switch(t instanceof Error||"object"==typeof t&&null!==t||x('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new D(t.message);case"MissingPDFException":return new R(t.message);case"PasswordException":return new M(t.message,t.code);case"UnexpectedResponseException":return new L(t.message,t.status);case"UnknownErrorException":return new T(t.message,t.details);default:return new T(t.message,t.toString())}}class be{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=t=>{const e=t.data;if(e.targetName!==this.sourceName)return;if(e.stream)return void this.#Fe(e);if(e.callback){const t=e.callbackId,s=this.callbackCapabilities[t];if(!s)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)s.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");s.reject(ve(e.reason))}return}const i=this.actionHandler[e.action];if(!i)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,n=e.sourceName;new Promise(function(t){t(i(e.data))}).then(function(i){s.postMessage({sourceName:t,targetName:n,callback:1,callbackId:e.callbackId,data:i})},function(i){s.postMessage({sourceName:t,targetName:n,callback:2,callbackId:e.callbackId,reason:ve(i)})})}else e.streamId?this.#Ne(e):i(e.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,a=this.sourceName,r=this.targetName,o=this.comObj;return new ReadableStream({start:s=>{const h=Promise.withResolvers();return this.streamControllers[n]={controller:s,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:r,action:t,streamId:n,data:e,desiredSize:s.desiredSize},i),h.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:a,targetName:r,stream:6,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{E(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:a,targetName:r,stream:1,streamId:n,reason:ve(t)}),e.promise}},s)}#Ne(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t,a=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:4,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:3,streamId:e}),delete a.streamSinks[e])},error(t){E(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:5,streamId:e,reason:ve(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise(function(e){e(r(t.data,o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:8,streamId:e,success:!0})},function(t){n.postMessage({sourceName:s,targetName:i,stream:8,streamId:e,reason:ve(t)})})}#Fe(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case 8:t.success?a.startCall.resolve():a.startCall.reject(ve(t.reason));break;case 7:t.success?a.pullCall.resolve():a.pullCall.reject(ve(t.reason));break;case 6:if(!r){n.postMessage({sourceName:s,targetName:i,stream:7,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,new Promise(function(t){t(r.onPull?.())}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:7,streamId:e,success:!0})},function(t){n.postMessage({sourceName:s,targetName:i,stream:7,streamId:e,reason:ve(t)})});break;case 4:if(E(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case 3:if(E(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#Oe(a,e);break;case 5:E(a,"error should have stream controller"),a.controller.error(ve(t.reason)),this.#Oe(a,e);break;case 2:t.success?a.cancelCall.resolve():a.cancelCall.reject(ve(t.reason)),this.#Oe(a,e);break;case 1:if(!r)break;new Promise(function(e){e(r.onCancel?.(ve(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:2,streamId:e,success:!0})},function(t){n.postMessage({sourceName:s,targetName:i,stream:2,streamId:e,reason:ve(t)})}),r.sinkCapability.reject(ve(t.reason)),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#Oe(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class Ae{#Be;#He;constructor({parsedData:t,rawData:e}){this.#Be=t,this.#He=e}getRaw(){return this.#He}get(t){return this.#Be.get(t)??null}getAll(){return O(this.#Be)}has(t){return this.#Be.has(t)}}const ye=Symbol("INTERNAL");class _e{#ze=!1;#je=!1;#$e=!1;#Ve=!0;constructor(t,{name:e,intent:s,usage:i}){this.#ze=!!(2&t),this.#je=!!(4&t),this.name=e,this.intent=s,this.usage=i}get visible(){if(this.#$e)return this.#Ve;if(!this.#Ve)return!1;const{print:t,view:e}=this.usage;return this.#ze?"OFF"!==e?.viewState:!this.#je||"OFF"!==t?.printState}_setVisible(t,e,s=!1){t!==ye&&x("Internal method `_setVisible` called."),this.#$e=s,this.#Ve=e}}class we{#Ge=null;#qe=new Map;#Ue=null;#We=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#We=t.order;for(const s of t.groups)this.#qe.set(s.id,new _e(e,s));if("OFF"===t.baseState)for(const t of this.#qe.values())t._setVisible(ye,!1);for(const e of t.on)this.#qe.get(e)._setVisible(ye,!0);for(const e of t.off)this.#qe.get(e)._setVisible(ye,!1);this.#Ue=this.getHash()}}#Xe(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const e=t[i];let n;if(Array.isArray(e))n=this.#Xe(e);else{if(!this.#qe.has(e))return w(`Optional content group not found: ${e}`),!0;n=this.#qe.get(e).visible}switch(s){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===s}isVisible(t){if(0===this.#qe.size)return!0;if(!t)return _("Optional content group not defined."),!0;if("OCG"===t.type)return this.#qe.has(t.id)?this.#qe.get(t.id).visible:(w(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Xe(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#qe.has(e))return w(`Optional content group not found: ${e}`),!0;if(this.#qe.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#qe.has(e))return w(`Optional content group not found: ${e}`),!0;if(!this.#qe.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#qe.has(e))return w(`Optional content group not found: ${e}`),!0;if(!this.#qe.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#qe.has(e))return w(`Optional content group not found: ${e}`),!0;if(this.#qe.get(e).visible)return!1}return!0}return w(`Unknown optional content policy ${t.policy}.`),!0}return w(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=this.#qe.get(t);s?(s._setVisible(ye,!!e,!0),this.#Ge=null):w(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let s;for(const e of t){switch(e){case"ON":case"OFF":case"Toggle":s=e;continue}const t=this.#qe.get(e);if(t)switch(s){case"ON":t._setVisible(ye,!0);break;case"OFF":t._setVisible(ye,!1);break;case"Toggle":t._setVisible(ye,!t.visible)}}this.#Ge=null}get hasInitialVisibility(){return null===this.#Ue||this.getHash()===this.#Ue}getOrder(){return this.#qe.size?this.#We?this.#We.slice():[...this.#qe.keys()]:null}getGroups(){return this.#qe.size>0?O(this.#qe):null}getGroup(t){return this.#qe.get(t)||null}getHash(){if(null!==this.#Ge)return this.#Ge;const t=new Dt;for(const[e,s]of this.#qe)t.update(`${e}:${s.visible}`);return this.#Ge=t.hexdigest()}}class xe{constructor(t,{disableRange:e=!1,disableStream:s=!1}){E(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:a,contentDispositionFilename:r}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=r,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s):E(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(s),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){E(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Ee(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Se(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Ee{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=at(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Se{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ce({getResponseHeader:t,isHttp:e,rangeChunkSize:s,disableRange:i}){const n={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t("Content-Length"),10);return Number.isInteger(a)?(n.suggestedLength=a,a<=2*s||i||!e||"bytes"!==t("Accept-Ranges")||"identity"!==(t("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n):n}function ke(t){const e=t("Content-Disposition");if(e){let t=function(t){let e=!0,s=i("filename\\*","i").exec(t);if(s){s=s[1];let t=r(s);return t=unescape(t),t=o(t),t=h(t),a(t)}if(s=function(t){const e=[];let s;const n=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(s=n.exec(t));){let[,t,i,n]=s;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[i,n]}const a=[];for(let t=0;t<e.length&&t in e;++t){let[s,i]=e[t];i=r(i),s&&(i=unescape(i),0===t&&(i=o(i))),a.push(i)}return a.join("")}(t),s)return a(h(s));if(s=i("filename","i").exec(t),s){s=s[1];let t=r(s);return t=h(t),a(t)}function i(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,s){if(t){if(!/^[\x00-\xFF]+$/.test(s))return s;try{const i=new TextDecoder(t,{fatal:!0}),n=N(s);s=i.decode(n),e=!1}catch{}}return s}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function r(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const s=e[t].indexOf('"');-1!==s&&(e[t]=e[t].slice(0,s),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function h(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,s,i){if("q"===s||"Q"===s)return n(e,i=(i=i.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{i=atob(i)}catch{}return n(e,i)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(at(t))return t}return null}function Me(t,e){return 404===t||0===t&&e.startsWith("file:")?new R('Missing PDF "'+e+'".'):new L(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function Te(t){return 200===t||206===t}function Pe(t,e,s){return{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Re(t){const e=new Headers;for(const s in t){const i=t[s];void 0!==i&&e.append(s,i)}return e}function Le(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(w(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Ie{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return E(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new De(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Fe(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class De{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._headers=Re(this._stream.httpHeaders);const s=e.url;fetch(s,Pe(this._headers,this._withCredentials,this._abortController)).then(t=>{if(!Te(t.status))throw Me(t.status,s);this._reader=t.body.getReader(),this._headersCapability.resolve();const e=e=>t.headers.get(e),{allowRangeRequests:i,suggestedLength:n}=Ce({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=n||this._contentLength,this._filename=ke(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new D("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Le(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Fe{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=Re(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,Pe(this._headers,this._withCredentials,this._abortController)).then(t=>{if(!Te(t.status))throw Me(t.status,n);this._readCapability.resolve(),this._reader=t.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Le(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ne{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const t in s)i[t]=s[t];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const t in this.httpHeaders){const s=this.httpHeaders[t];void 0!==s&&e.setRequestHeader(t,s)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(s){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==i.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===i.status&&this.isHttp)return void s.onError?.(i.status);const n=i.status||200;if((200!==n||206!==s.expectedStatus)&&n!==s.expectedStatus)return void s.onError?.(i.status);const a=function(t){const e=t.response;return"string"!=typeof e?e:N(e).buffer}(i);if(206===n){const t=i.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);s.onDone({begin:parseInt(e[1],10),chunk:a})}else a?s.onDone({begin:0,chunk:a}):s.onError?.(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Oe{constructor(t){this._source=t,this._manager=new Ne(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return E(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Be(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new He(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Be{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),s=t=>e.getResponseHeader(t),{allowRangeRequests:i,suggestedLength:n}=Ce({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=ke(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Me(t,this._url),this._headersReceivedCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersReceivedCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class He{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=Me(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const ze=/^file:\/\/\/[a-zA-Z]:\//;class je{constructor(t){this.source=t,this.url=function(t){const e=$t.get("url"),s=e.parse(t);return"file:"===s.protocol||s.host?s:/^[a-z]:[/\\]/i.test(t)?e.parse(`file:///${t}`):(s.host||(s.protocol="file:"),s)}(t.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return E(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new We(this):new qe(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new Xe(this,t,e):new Ue(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class $e{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new D("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Ve{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function Ge(t,e){return{protocol:t.protocol,auth:t.auth,host:t.hostname,port:t.port,path:t.path,method:"GET",headers:e}}class qe extends $e{constructor(t){super(t);const e=e=>{if(404===e.statusCode){const t=new R(`Missing PDF "${this._url}".`);return this._storedError=t,void this._headersCapability.reject(t)}this._headersCapability.resolve(),this._setReadableStream(e);const s=t=>this._readableStream.headers[t.toLowerCase()],{allowRangeRequests:i,suggestedLength:n}=Ce({getResponseHeader:s,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=n||this._contentLength,this._filename=ke(s)};if(this._request=null,"http:"===this._url.protocol){const s=$t.get("http");this._request=s.request(Ge(this._url,t.httpHeaders),e)}else{const s=$t.get("https");this._request=s.request(Ge(this._url,t.httpHeaders),e)}this._request.on("error",t=>{this._storedError=t,this._headersCapability.reject(t)}),this._request.end()}}class Ue extends Ve{constructor(t,e,s){super(t),this._httpHeaders={};for(const e in t.httpHeaders){const s=t.httpHeaders[e];void 0!==s&&(this._httpHeaders[e]=s)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const i=t=>{if(404!==t.statusCode)this._setReadableStream(t);else{const t=new R(`Missing PDF "${this._url}".`);this._storedError=t}};if(this._request=null,"http:"===this._url.protocol){const t=$t.get("http");this._request=t.request(Ge(this._url,this._httpHeaders),i)}else{const t=$t.get("https");this._request=t.request(Ge(this._url,this._httpHeaders),i)}this._request.on("error",t=>{this._storedError=t}),this._request.end()}}class We extends $e{constructor(t){super(t);let e=decodeURIComponent(this._url.path);ze.test(this._url.href)&&(e=e.replace(/^\//,""));const s=$t.get("fs");s.promises.lstat(e).then(t=>{this._contentLength=t.size,this._setReadableStream(s.createReadStream(e)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=new R(`Missing PDF "${e}".`)),this._storedError=t,this._headersCapability.reject(t)})}}class Xe extends Ve{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);ze.test(this._url.href)&&(i=i.replace(/^\//,""));const n=$t.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const Ke=30;class Ye{#Ke=Promise.withResolvers();#mt=null;#Ye=!1;#Je=!!globalThis.FontInspector?.enabled;#Qe=null;#Ze=null;#ts=0;#es=0;#ss=null;#is=null;#ns=0;#as=0;#rs=Object.create(null);#os=[];#hs=null;#ls=[];#cs=new WeakMap;#ds=null;static#us=new Map;static#ps=new Map;static#gs=null;static#fs=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#hs=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#hs=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#mt=this.#is=e,this.#as=s.scale*(globalThis.devicePixelRatio||1),this.#ns=s.rotation,this.#Ze={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:n,pageX:a,pageY:r}=s.rawDims;this.#ds=[1,0,0,-1,-a,r+n],this.#es=i,this.#ts=n,Ye.#ms(),bt(e,s),this.#Ke.promise.catch(()=>{}).then(()=>{Ye.#fs.delete(this),this.#Ze=null,this.#rs=null})}render(){const t=()=>{this.#ss.read().then(({value:e,done:s})=>{s?this.#Ke.resolve():(this.#Qe??=e.lang,Object.assign(this.#rs,e.styles),this.#vs(e.items),t())},this.#Ke.reject)};return this.#ss=this.#hs.getReader(),Ye.#fs.add(this),t(),this.#Ke.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#ns&&(e?.(),this.#ns=i,bt(this.#is,{rotation:i})),s!==this.#as){e?.(),this.#as=s;const t={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:Ye.#bs(this.#Qe)};for(const e of this.#ls)t.properties=this.#cs.get(e),t.div=e,this.#As(t)}}cancel(){const t=new D("TextLayer task cancelled.");this.#ss?.cancel(t).catch(()=>{}),this.#ss=null,this.#Ke.reject(t)}get textDivs(){return this.#ls}get textContentItemsStr(){return this.#os}#vs(t){if(this.#Ye)return;this.#Ze.ctx??=Ye.#bs(this.#Qe);const e=this.#ls,s=this.#os;for(const i of t){if(e.length>1e5)return w("Ignoring additional textDivs for performance reasons."),void(this.#Ye=!0);if(void 0!==i.str)s.push(i.str),this.#ys(i);else if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){const t=this.#mt;this.#mt=document.createElement("span"),this.#mt.classList.add("markedContent"),null!==i.id&&this.#mt.setAttribute("id",`${i.id}`),t.append(this.#mt)}else"endMarkedContent"===i.type&&(this.#mt=this.#mt.parentNode)}}#ys(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#ls.push(e);const i=z.transform(this.#ds,t.transform);let n=Math.atan2(i[1],i[0]);const a=this.#rs[t.fontName];a.vertical&&(n+=Math.PI/2);const r=this.#Je&&a.fontSubstitution||a.fontFamily,o=Math.hypot(i[2],i[3]),h=o*Ye.#_s(r,this.#Qe);let l,c;0===n?(l=i[4],c=i[5]-h):(l=i[4]+h*Math.sin(n),c=i[5]-h*Math.cos(n));const d="calc(var(--scale-factor)*",u=e.style;this.#mt===this.#is?(u.left=`${(100*l/this.#es).toFixed(2)}%`,u.top=`${(100*c/this.#ts).toFixed(2)}%`):(u.left=`${d}${l.toFixed(2)}px)`,u.top=`${d}${c.toFixed(2)}px)`),u.fontSize=`${d}${(Ye.#gs*o).toFixed(2)}px)`,u.fontFamily=r,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#Je&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==n&&(s.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),s=Math.abs(t.transform[3]);e!==s&&Math.max(e,s)/Math.min(e,s)>1.5&&(p=!0)}if(p&&(s.canvasWidth=a.vertical?t.height:t.width),this.#cs.set(e,s),this.#Ze.div=e,this.#Ze.properties=s,this.#As(this.#Ze),s.hasText&&this.#mt.append(e),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#mt.append(t)}}#As(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:a}=t,{style:r}=e;let o="";if(Ye.#gs>1&&(o=`scale(${1/Ye.#gs})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:h}=r,{canvasWidth:l,fontSize:c}=s;n===c&&a===h||(i.font=`${c*this.#as}px ${h}`,t.prevFontSize=c,t.prevFontFamily=h);const{width:d}=i.measureText(e.textContent);d>0&&(o=`scaleX(${l*this.#as/d}) ${o}`)}0!==s.angle&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(r.transform=o)}static cleanup(){if(!(this.#fs.size>0)){this.#us.clear();for(const{canvas:t}of this.#ps.values())t.remove();this.#ps.clear()}}static#bs(t=null){let e=this.#ps.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#ps.set(t,e)}return e}static#ms(){if(null!==this.#gs)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),this.#gs=t.getBoundingClientRect().height,t.remove()}static#_s(t,e){const s=this.#us.get(t);if(s)return s;const i=this.#bs(e),n=i.font;i.canvas.width=i.canvas.height=Ke,i.font=`30px ${t}`;const a=i.measureText("");let r=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);if(r){const e=r/(r+o);return this.#us.set(t,e),i.canvas.width=i.canvas.height=0,i.font=n,e}i.strokeStyle="red",i.clearRect(0,0,Ke,Ke),i.strokeText("g",0,0);let h=i.getImageData(0,0,Ke,Ke).data;o=0;for(let t=h.length-1-3;t>=0;t-=4)if(h[t]>0){o=Math.ceil(t/4/Ke);break}i.clearRect(0,0,Ke,Ke),i.strokeText("A",0,Ke),h=i.getImageData(0,0,Ke,Ke).data,r=0;for(let t=0,e=h.length;t<e;t+=4)if(h[t]>0){r=Ke-Math.floor(t/4/Ke);break}i.canvas.width=i.canvas.height=0,i.font=n;const l=r?r/(r+o):.8;return this.#us.set(t,l),l}}function Je(){dt("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:t,container:e,viewport:s,...i}=arguments[0],n=Object.keys(i);n.length>0&&w("Ignoring `renderTextLayer` parameters: "+n.join(", "));const a=new Ye({textContentSource:t,container:e,viewport:s}),{textDivs:r,textContentItemsStr:o}=a;return{promise:a.render(),textDivs:r,textContentItemsStr:o}}function Qe(){dt("`updateTextLayer`, please use `TextLayer` instead.")}class Ze{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};return function t(s){if(!s)return;let i=null;const n=s.name;if("#text"===n)i=s.value;else{if(!Ze.shouldBuildText(n))return;s?.attributes?.textContent?i=s.attributes.textContent:s.value&&(i=s.value)}if(null!==i&&e.push({str:i}),s.children)for(const e of s.children)t(e)}(t),s}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const ts=65536,es=r?class extends U{_createCanvas(t,e){return $t.get("canvas").createCanvas(t,e)}}:class extends U{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}},ss=r?class extends W{_fetchData(t,e){return Vt(t).then(t=>({cMapData:t,compressionType:e}))}}:Z,is=r?class extends q{}:class extends q{#ws;#xs;#Es;#Ss;#Cs;#v=0;constructor({docId:t,ownerDocument:e=globalThis.document}={}){super(),this.#Es=t,this.#Ss=e}get#A(){return this.#ws||=new Map}get#ks(){return this.#Cs||=new Map}get#Ms(){if(!this.#xs){const t=this.#Ss.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=this.#Ss.createElementNS(Y,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#xs=this.#Ss.createElementNS(Y,"defs"),t.append(s),s.append(this.#xs),this.#Ss.body.append(t)}return this.#xs}#Ts(t){if(1===t.length){const e=t[0],s=new Array(256);for(let t=0;t<256;t++)s[t]=e[t]/255;const i=s.join(",");return[i,i,i]}const[e,s,i]=t,n=new Array(256),a=new Array(256),r=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,a[t]=s[t]/255,r[t]=i[t]/255;return[n.join(","),a.join(","),r.join(",")]}addFilter(t){if(!t)return"none";let e=this.#A.get(t);if(e)return e;const[s,i,n]=this.#Ts(t),a=1===t.length?s:`${s}${i}${n}`;if(e=this.#A.get(a),e)return this.#A.set(t,e),e;const r=`g_${this.#Es}_transfer_map_${this.#v++}`,o=`url(#${r})`;this.#A.set(t,o),this.#A.set(a,o);const h=this.#Ps(r);return this.#Rs(s,i,n,h),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let n=this.#ks.get(i);if(n?.key===s)return n.url;if(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#ks.set(i,n)),!t||!e)return n.url;const a=this.#Ls(t);t=z.makeHexColor(...a);const r=this.#Ls(e);if(e=z.makeHexColor(...r),this.#Ms.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const h=o.join(","),l=`g_${this.#Es}_hcm_filter`,c=n.filter=this.#Ps(l);this.#Rs(h,h,h,c),this.#Is(c);const d=(t,e)=>{const s=a[t]/255,i=r[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=s+t/e*(i-s);return n.join(",")};return this.#Rs(d(0,5),d(1,5),d(2,5),c),n.url=`url(#${l})`,n.url}addAlphaFilter(t){let e=this.#A.get(t);if(e)return e;const[s]=this.#Ts([t]),i=`alpha_${s}`;if(e=this.#A.get(i),e)return this.#A.set(t,e),e;const n=`g_${this.#Es}_alpha_map_${this.#v++}`,a=`url(#${n})`;this.#A.set(t,a),this.#A.set(i,a);const r=this.#Ps(n);return this.#Ds(s,r),a}addLuminosityFilter(t){let e,s,i=this.#A.get(t||"luminosity");if(i)return i;if(t?([e]=this.#Ts([t]),s=`luminosity_${e}`):s="luminosity",i=this.#A.get(s),i)return this.#A.set(t,i),i;const n=`g_${this.#Es}_luminosity_map_${this.#v++}`,a=`url(#${n})`;this.#A.set(t,a),this.#A.set(s,a);const r=this.#Ps(n);return this.#Fs(r),t&&this.#Ds(e,r),a}addHighlightHCMFilter(t,e,s,i,n){const a=`${e}-${s}-${i}-${n}`;let r=this.#ks.get(t);if(r?.key===a)return r.url;if(r?(r.filter?.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},this.#ks.set(t,r)),!e||!s)return r.url;const[o,h]=[e,s].map(this.#Ls.bind(this));let l=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[d,u]=[i,n].map(this.#Ls.bind(this));c<l&&([l,c,d,u]=[c,l,u,d]),this.#Ms.style.color="";const p=(t,e,s)=>{const i=new Array(256),n=(c-l)/s,a=t/255,r=(e-t)/(255*s);let o=0;for(let t=0;t<=s;t++){const e=Math.round(l+t*n),s=a+t*r;for(let t=o;t<=e;t++)i[t]=s;o=e+1}for(let t=o;t<256;t++)i[t]=i[o-1];return i.join(",")},g=`g_${this.#Es}_hcm_${t}_filter`,f=r.filter=this.#Ps(g);return this.#Is(f),this.#Rs(p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),f),r.url=`url(#${g})`,r.url}destroy(t=!1){t&&0!==this.#ks.size||(this.#xs&&(this.#xs.parentNode.parentNode.remove(),this.#xs=null),this.#ws&&(this.#ws.clear(),this.#ws=null),this.#v=0)}#Fs(t){const e=this.#Ss.createElementNS(Y,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#Is(t){const e=this.#Ss.createElementNS(Y,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#Ps(t){const e=this.#Ss.createElementNS(Y,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#Ms.append(e),e}#Ns(t,e,s){const i=this.#Ss.createElementNS(Y,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#Rs(t,e,s,i){const n=this.#Ss.createElementNS(Y,"feComponentTransfer");i.append(n),this.#Ns(n,"feFuncR",t),this.#Ns(n,"feFuncG",e),this.#Ns(n,"feFuncB",s)}#Ds(t,e){const s=this.#Ss.createElementNS(Y,"feComponentTransfer");e.append(s),this.#Ns(s,"feFuncA",t)}#Ls(t){return this.#Ms.style.color=t,ft(getComputedStyle(this.#Ms).getPropertyValue("color"))}},ns=r?class extends X{_fetchData(t){return Vt(t)}}:tt;function as(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new os,{docId:s}=e,i=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(r&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(r&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return N(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,o=!0===t.withCredentials,h=t.password??null,l=t.range instanceof hs?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:ts;let d=t.worker instanceof ps?t.worker:null;const u=t.verbosity,p="string"!=typeof t.docBaseUrl||nt(t.docBaseUrl)?null:t.docBaseUrl,g="string"==typeof t.cMapUrl?t.cMapUrl:null,f=!1!==t.cMapPacked,m=t.CMapReaderFactory||ss,v="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,b=t.StandardFontDataFactory||ns,y=!0!==t.stopAtErrors,_=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,w=!1!==t.isEvalSupported,x="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!r,E=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,S="boolean"==typeof t.disableFontFace?t.disableFontFace:r,C=!0===t.fontExtraProperties,k=!0===t.enableXfa,M=t.ownerDocument||globalThis.document,T=!0===t.disableRange,P=!0===t.disableStream,R=!0===t.disableAutoFetch,L=!0===t.pdfBug,I=!0===t.enableHWA,D=l?l.length:t.length??NaN,F="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!r&&!S,O="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:m===Z&&b===tt&&g&&v&&lt(g,document.baseURI)&&lt(v,document.baseURI),B=t.canvasFactory||new es({ownerDocument:M,enableHWA:I}),H=t.filterFactory||new is({docId:s,ownerDocument:M});!function(t){Number.isInteger(t)&&(A=t)}(u);const z={canvasFactory:B,filterFactory:H};if(O||(z.cMapReaderFactory=new m({baseUrl:g,isCompressed:f}),z.standardFontDataFactory=new b({baseUrl:v})),!d){const t={verbosity:u,port:me.workerPort};d=t.port?ps.fromPort(t):new ps(t),e._worker=d}const j={docId:s,apiVersion:"4.4.168",data:n,password:h,disableAutoFetch:R,rangeChunkSize:c,length:D,docBaseUrl:p,enableXfa:k,evaluatorOptions:{maxImageSize:_,disableFontFace:S,ignoreErrors:y,isEvalSupported:w,isOffscreenCanvasSupported:x,canvasMaxAreaInBytes:E,fontExtraProperties:C,useSystemFonts:F,cMapUrl:O?g:null,standardFontDataUrl:O?v:null}},$={disableFontFace:S,fontExtraProperties:C,ownerDocument:M,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:k}};return d.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const t=d.messageHandler.sendWithPromise("GetDocRequest",j,n?[n.buffer]:null);let h;if(l)h=new xe(l,{disableRange:T,disableStream:P});else if(!n){if(!i)throw new Error("getDocument - no `url` parameter provided.");h=(t=>r?"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype&&lt(t.url)?new Ie(t):new je(t):lt(t.url)?new Ie(t):new Oe(t))({url:i,length:D,httpHeaders:a,withCredentials:o,rangeChunkSize:c,disableRange:T,disableStream:P})}return t.then(t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const i=new be(s,t,d.port),n=new gs(i,e,h,$,z);e._transport=n,i.send("Ready",null)})}).catch(e._capability.reject),e}function rs(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class os{static#Es=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+os.#Es++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class hs{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){x("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class ls{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return C(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class cs{#Os=null;#Bs=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new ht:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new ms,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new st({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return C(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=c.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:r=null,annotationCanvasMap:o=null,pageColors:h=null,printAnnotationStorage:l=null}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(s,i,l),{renderingIntent:u,cacheKey:p}=d;this.#Bs=!1,this.#Hs(),r||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(4&u);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const m=t=>{g.renderTasks.delete(v),(this._maybeCleanupAfterRender||f)&&(this.#Bs=!0),this.#zs(!f),t?(v.capability.reject(t),this._abortOperatorList({intentState:g,reason:t instanceof Error?t:new Error(t)})):v.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},v=new bs({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:h});(g.renderTasks||=new Set).add(v);const b=v.task;return Promise.all([g.displayReadyCapability.promise,r]).then(([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");v.initializeGraphics({transparency:t,optionalContentConfig:e}),v.operatorListChanged()}}).catch(m),b}getOperatorList({intent:t="display",annotationMode:e=c.ENABLE,printAnnotationStorage:s=null}={}){const i=this._transport.getRenderingIntent(t,e,s,!0);let n,a=this._intentStates.get(i.cacheKey);return a||(a=Object.create(null),this._intentStates.set(i.cacheKey,a)),a.opListReadCapability||(n=Object.create(null),n.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(n))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(n),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(i)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>Ze.textContent(t));const e=this.streamTextContent(t);return new Promise(function(t,s){const i=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){i.read().then(function({value:s,done:i}){i?t(n):(n.lang??=s.lang,Object.assign(n.styles,s.styles),n.items.push(...s.items),e())},s)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#Bs=!1,this.#Hs(),Promise.all(t)}cleanup(t=!1){this.#Bs=!0;const e=this.#zs(!1);return t&&e&&(this._stats&&=new ht),e}#zs(t=!1){if(this.#Hs(),!this.#Bs||this.destroyed)return!1;if(t)return this.#Os=setTimeout(()=>{this.#Os=null,this.#zs(!1)},5e3),!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#Bs=!1,!0}#Hs(){this.#Os&&(clearTimeout(this.#Os),this.#Os=null)}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#zs(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s}){const{map:i,transfer:n}=s,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i},n).getReader(),r=this._intentStates.get(e);r.streamReader=a;const o=()=>{a.read().then(({value:t,done:e})=>{e?r.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,r),o())},t=>{if(r.streamReader=null,!this._transport.destroyed){if(r.operatorList){r.operatorList.lastChunk=!0;for(const t of r.renderTasks)t.operatorListChanged();this.#zs(!0)}if(r.displayReadyCapability)r.displayReadyCapability.reject(t);else{if(!r.opListReadCapability)throw t;r.opListReadCapability.reject(t)}}})};o()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof it){let s=100;return e.extraDelay>0&&e.extraDelay<1e3&&(s+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},s))}}if(t.streamReader.cancel(new D(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[e,s]of this._intentStates)if(s===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class ds{#js=new Set;#$s=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#$s.then(()=>{for(const t of this.#js)t.call(this,s)})}addEventListener(t,e){this.#js.add(e)}removeEventListener(t,e){this.#js.delete(e)}terminate(){this.#js.clear()}}const us={isWorkerDisabled:!1,fakeWorkerId:0};r&&(us.isWorkerDisabled=!0,me.workerSrc||="./pdf.worker.mjs"),us.isSameOrigin=function(t,e){let s;try{if(s=new URL(t),!s.origin||"null"===s.origin)return!1}catch{return!1}const i=new URL(e,s);return s.origin===i.origin},us.createCDNWrapper=function(t){const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};class ps{static#Vs;constructor({name:t=null,port:e=null,verbosity:s=y()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(ps.#Vs?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(ps.#Vs||=new WeakMap).set(e,this),this._initializeFromPort(e)}else this._initialize()}get promise(){return r?Promise.all([$t.promise,this._readyCapability.promise]):this._readyCapability.promise}#Gs(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new be("main","worker",t),this._messageHandler.on("ready",function(){}),this.#Gs()}_initialize(){if(us.isWorkerDisabled||ps.#qs)return void this._setupFakeWorker();let{workerSrc:t}=ps;try{us.isSameOrigin(window.location.href,t)||(t=us.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new be("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",t=>{n.abort(),!this.destroyed&&t?(this._messageHandler=s,this._port=e,this._webWorker=e,this.#Gs()):i()}),s.on("ready",t=>{if(n.abort(),this.destroyed)i();else try{a()}catch{this._setupFakeWorker()}});const a=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void a()}catch{_("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){us.isWorkerDisabled||(w("Setting up fake worker."),us.isWorkerDisabled=!0),ps._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new ds;this._port=e;const s="fake"+us.fakeWorkerId++,i=new be(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new be(s,s+"_worker",e),this.#Gs()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),ps.#Vs?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#Vs?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new ps(t)}static get workerSrc(){if(me.workerSrc)return me.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#qs(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return C(this,"_setupFakeWorkerGlobal",(async()=>this.#qs?this.#qs:(await import(this.workerSrc)).WorkerMessageHandler)())}}class gs{#Us=new Map;#Ws=new Map;#Xs=new Map;#Ks=new Map;#Ys=null;constructor(t,e,s,i,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new ms,this.fontLoader=new Bt({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Js(t,e=null){const s=this.#Us.get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return this.#Us.set(t,i),i}get annotationStorage(){return C(this,"annotationStorage",new Nt)}getRenderingIntent(t,e=c.ENABLE,s=null,i=!1){let n=2,a=Ft;switch(t){case"any":n=1;break;case"display":break;case"print":n=4;break;default:w(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case c.DISABLE:n+=64;break;case c.ENABLE:break;case c.ENABLE_FORMS:n+=16;break;case c.ENABLE_STORAGE:n+=32,a=(4&n&&s instanceof Ot?s:this.annotationStorage).serializable;break;default:w(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=256),{renderingIntent:n,cacheKey:`${n}_${a.hash}`,annotationStorageSerializable:a}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Ys?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Ws.values())t.push(e._destroy());this.#Ws.clear(),this.#Xs.clear(),this.#Ks.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#Us.clear(),this.filterFactory.destroy(),Ye.cleanup(),this._networkStream?.cancelAllRequests(new D("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{E(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:s}){s?e.close():(E(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",t=>{const s=Promise.withResolvers(),i=this._fullReader;return i.headersReady.then(()=>{i.isStreamingSupported&&i.isRangeSupported||(this._lastProgress&&e.onProgress?.(this._lastProgress),i.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),s.resolve({isStreamingSupported:i.isStreamingSupported,isRangeSupported:i.isRangeSupported,contentLength:i.contentLength})},s.reject),s.promise}),t.on("GetRangeReader",(t,e)=>{E(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const s=this._networkStream.getRangeReader(t.begin,t.end);s?(e.onPull=()=>{s.read().then(function({value:t,done:s}){s?e.close():(E(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{s.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new ls(t,this))}),t.on("DocException",function(t){let s;switch(t.name){case"PasswordException":s=new M(t.message,t.code);break;case"InvalidPDFException":s=new P(t.message);break;case"MissingPDFException":s=new R(t.message);break;case"UnexpectedResponseException":s=new L(t.message,t.status);break;case"UnknownErrorException":s=new T(t.message,t.details);break;default:x("DocException - expected a valid Error.")}e._capability.reject(s)}),t.on("PasswordRequest",t=>{if(this.#Ys=Promise.withResolvers(),e.onPassword){const s=t=>{t instanceof Error?this.#Ys.reject(t):this.#Ys.resolve({password:t})};try{e.onPassword(s,t.code)}catch(t){this.#Ys.reject(t)}}else this.#Ys.reject(new M(t.message,t.code));return this.#Ys.promise}),t.on("DataLoaded",t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#Ws.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,s,i])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(s){case"Font":const{disableFontFace:n,fontExtraProperties:a,pdfBug:r}=this._params;if("error"in i){const t=i.error;w(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=r&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,h=new Ht(i,{disableFontFace:n,inspectFont:o});this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!a&&h.data&&(h.data=null),this.commonObjs.resolve(e,h)});break;case"CopyLocalImage":const{imageRef:l}=i;E(l,"The imageRef must be defined.");for(const t of this.#Ws.values())for(const[,s]of t.objs)if(s?.ref===l)return s.dataLen?(this.commonObjs.resolve(e,structuredClone(s)),s.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,i);break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),t.on("obj",([t,e,s,i])=>{if(this.destroyed)return;const n=this.#Ws.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(s){case"Image":n.objs.resolve(t,i),i?.dataLen>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,i);break;default:throw new Error(`Got unknown object type ${s}`)}else i?.bitmap?.close()}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBuiltInCMap",t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(t):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(t):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&w("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.#Xs.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(s=>{if(this.destroyed)throw new Error("Transport destroyed");s.refStr&&this.#Ks.set(s.refStr,t);const i=new cs(e,s,this,this._params.pdfBug);return this.#Ws.set(e,i),i});return this.#Xs.set(e,i),i}getPageIndex(t){return rs(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#Js("GetFieldObjects")}hasJSActions(){return this.#Js("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Js("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#Js("GetOptionalContentConfig").then(e=>new we(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Us.get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new Ae(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#Us.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Ws.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Us.clear(),this.filterFactory.destroy(!0),Ye.cleanup()}}cachedPageNumber(t){if(!rs(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Ks.get(e)??null}}const fs=Symbol("INITIAL_DATA");class ms{#Qs=Object.create(null);#Zs(t){return this.#Qs[t]||={...Promise.withResolvers(),data:fs}}get(t,e=null){if(e){const s=this.#Zs(t);return s.promise.then(()=>e(s.data)),null}const s=this.#Qs[t];if(!s||s.data===fs)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#Qs[t];return!!e&&e.data!==fs}resolve(t,e=null){const s=this.#Zs(t);s.data=e,s.resolve()}clear(){for(const t in this.#Qs){const{data:e}=this.#Qs[t];e?.bitmap?.close()}this.#Qs=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Qs){const{data:e}=this.#Qs[t];e!==fs&&(yield[t,e])}}}class vs{#ti=null;constructor(t){this.#ti=t,this.onContinue=null}get promise(){return this.#ti.capability.promise}cancel(t=0){this.#ti.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#ti.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#ti;return t.form||t.canvas&&e?.size>0}}class bs{#ei=null;static#si=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:r,canvasFactory:o,filterFactory:h,useRequestAnimationFrame:l=!1,pdfBug:c=!1,pageColors:d=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=r,this.canvasFactory=o,this.filterFactory=h,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===l&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new vs(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(bs.#si.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");bs.#si.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:a}=this.params;this.gfx=new fe(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#ei&&(window.cancelAnimationFrame(this.#ei),this.#ei=null),bs.#si.delete(this._canvas),this.callback(t||new it(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#ei=window.requestAnimationFrame(()=>{this.#ei=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),bs.#si.delete(this._canvas),this.callback())))}}const As="4.4.168",ys="19fbc8998";function _s(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function ws(t){return Math.max(0,Math.min(255,255*t))}class xs{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=ws(t),t,t]}static G_HTML([t]){const e=_s(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(ws)}static RGB_HTML(t){return`#${t.map(_s).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[ws(1-Math.min(1,t+i)),ws(1-Math.min(1,s+i)),ws(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,a=1-s;return["CMYK",i,n,a,Math.min(i,n,a)]}}class Es{static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===n)break;t.addEventListener("input",t=>{i.setValue(e,{value:t.target.value})});break;case"input":if("radio"===s.attributes.type||"checkbox"===s.attributes.type){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",t=>{i.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===n)break;t.addEventListener("input",t=>{i.setValue(e,{value:t.target.value})})}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of s.children)t.attributes.value===a.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{const s=t.target.options,n=-1===s.selectedIndex?"":s[s.selectedIndex].value;i.setValue(e,{value:n})})}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:a}=e,r=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${i}`);for(const[e,s]of Object.entries(a))if(null!=s)switch(e){case"class":s.length&&t.setAttribute(e,s.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",s);break;case"style":Object.assign(t.style,s);break;case"textContent":t.textContent=s;break;default:(!r||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,s)}r&&n.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:n,linkService:s});const r="richText"!==n,o=t.div;if(o.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}r&&o.setAttribute("class","xfaLayer xfaFont");const h=[];if(0===i.children.length){if(i.value){const t=document.createTextNode(i.value);a.append(t),r&&Ze.shouldBuildText(i.name)&&h.push(t)}return{textDivs:h}}const l=[[i,-1,a]];for(;l.length>0;){const[t,i,a]=l.at(-1);if(i+1===t.children.length){l.pop();continue}const o=t.children[++l.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const t=document.createTextNode(o.value);h.push(t),a.append(t);continue}const d=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,c):document.createElement(c);if(a.append(d),o.attributes&&this.setAttributes({html:d,element:o,storage:e,intent:n,linkService:s}),o.children?.length>0)l.push([o,-1,d]);else if(o.value){const t=document.createTextNode(o.value);r&&Ze.shouldBuildText(c)&&h.push(t),d.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Ss=1e3,Cs=new WeakSet;function ks(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class Ms{static create(t){switch(t.data.annotationType){case 2:return new Ps(t);case 1:return new Rs(t);case 20:switch(t.data.fieldType){case"Tx":return new Is(t);case"Btn":return t.data.radioButton?new Ns(t):t.data.checkBox?new Fs(t):new Os(t);case"Ch":return new Bs(t);case"Sig":return new Ds(t)}return new Ls(t);case 16:return new Hs(t);case 3:return new js(t);case 4:return new $s(t);case 5:return new Vs(t);case 6:return new Gs(t);case 8:return new qs(t);case 14:return new Ws(t);case 15:return new Xs(t);case 7:return new Us(t);case 9:return new Ks(t);case 10:return new Ys(t);case 11:return new Js(t);case 12:return new Qs(t);case 13:return new Zs(t);case 17:return new ti(t);default:return new Ts(t)}}}class Ts{#ii=null;#ni=!1;#ai=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get hasPopupData(){return Ts._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#ii||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#ri(e),this.#ai?.popup.updateEdited(t)}resetEdited(){this.#ii&&(this.#ri(this.#ii.rect),this.#ai?.popup.resetEdited(),this.#ii=null)}#ri(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}}}=this;s?.splice(0,4,...t);const{width:h,height:l}=ks(t);e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===i?(e.width=100*h/n+"%",e.height=100*l/a+"%"):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Ls||(n.tabIndex=Ss);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.popupRef&&n.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Hs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=ks(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,s=e.borderStyle.verticalCornerRadius;if(t>0||s>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`;a.borderRadius=e}else if(this instanceof Ns){const t=`calc(${r}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case 1:a.borderStyle="solid";break;case 2:a.borderStyle="dashed";break;case 3:w("Unimplemented border style: beveled");break;case 4:w("Unimplemented border style: inset");break;case 5:a.borderBottomStyle="solid"}const i=e.borderColor||null;i?(this.#ni=!0,a.borderColor=z.makeHexColor(0|i[0],0|i[1],0|i[2])):a.borderWidth=0}const h=z.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:l,pageHeight:c,pageX:d,pageY:u}=i.rawDims;a.left=100*(h[0]-d)/l+"%",a.top=100*(h[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/l+"%",a.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:a}=ks(this.data.rect);let r,o;t%180==0?(r=100*n/s,o=100*a/i):(r=100*a/s,o=100*n/i),e.style.width=`${r}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,s)=>{const i=s.detail[t],n=i[0],a=i.slice(1);s.target.style[e]=xs[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:xs[`${n}_rgb`](a)})};return C(this,"_commonActions",{display:t=>{const{display:e}=t.detail,s=e%2==1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const a=s[i];a&&(a({detail:{[i]:n},target:t}),delete e[i])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){const[a,r,o,h]=t.subarray(2,6);if(i===a&&n===r&&e===o&&s===h)return}const{style:a}=this.container;let r;if(this.#ni){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=i-e,h=n-s,{svgFactory:l}=this,c=l.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);const d=l.createElement("defs");c.append(d);const u=l.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let s=2,i=t.length;s<i;s+=8){const i=t[s],a=t[s+1],c=t[s+2],d=t[s+3],p=l.createElement("rect"),g=(c-e)/o,f=(n-a)/h,m=(i-c)/o,v=(a-d)/h;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",v),u.append(p),r?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${v}"/>`)}this.#ni&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=this.#ai=new Hs({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(s.render())}render(){x("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:t,id:n,exportValues:a}of i){if(-1===t)continue;if(n===e)continue;const i="string"==typeof a?a:null,r=document.querySelector(`[data-element-id="${n}"]`);!r||Cs.has(r)?s.push({id:n,exportValue:i,domElement:r}):w(`_getElementsByName - element not allowed: ${n}`)}return s}for(const i of document.getElementsByName(t)){const{exportValue:t}=i,n=i.getAttribute("data-element-id");n!==e&&Cs.has(i)&&s.push({id:n,exportValue:t,domElement:i})}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class Ps extends Ts{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(this.#oi(s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#hi(s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),this.container}#li(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#li()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#li()}#oi(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#li()}#hi(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#li()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#li()}_bindResetFormAction(t,e){const s=t.onclick;s||(t.href=this.linkService.getAnchorUrl("")),this.#li(),this._fieldObjects?t.onclick=()=>{s?.();const{fields:t,refs:i,include:n}=e,a=[];if(0!==t.length||0!==i.length){const e=new Set(i);for(const s of t){const t=this._fieldObjects[s]||[];for(const{id:s}of t)e.add(s)}for(const t of Object.values(this._fieldObjects))for(const s of t)e.has(s.id)===n&&a.push(s)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const r=this.annotationStorage,o=[];for(const t of a){const{id:e}=t;switch(o.push(e),t.type){case"text":{const s=t.defaultValue||"";r.setValue(e,{value:s});break}case"checkbox":case"radiobutton":{const s=t.defaultValue===t.exportValues;r.setValue(e,{value:s});break}case"combobox":case"listbox":{const s=t.defaultValue||"";r.setValue(e,{value:s});break}default:continue}const s=document.querySelector(`[data-element-id="${e}"]`);s&&(Cs.has(s)?s.dispatchEvent(new Event("resetform")):w(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}:(w('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1))}}class Rs extends Ts{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Ls extends Ts{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return B.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(s,t=>{if("blur"===s){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===s){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(t)}})})}_setEventListeners(t,e,s,i){for(const[n,a]of s)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,n,a,i),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":z.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const{fontColor:e}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,i=t.style;let n;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(l*s))||1);n=Math.min(s,a(e/l))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);n=Math.min(s,a(t/l))}i.fontSize=`calc(${n}px * var(--scale-factor))`,i.color=z.makeHexColor(e[0],e[1],e[2]),null!==this.data.textAlignment&&(i.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Is extends Ls{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),n.setValue(a.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&n.length>a&&(n=n.slice(0,a));let r=i.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=r??n,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",r??n),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Cs.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=Ss,this._setRequired(s,this.data.required),a&&(s.maxLength=a),s.addEventListener("input",i=>{t.setValue(e,{value:i.target.value}),this.setPropertyOnSiblings(s,"value",i.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue??"";s.value=o.userValue=e,o.formattedValue=null});let h=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),s.addEventListener("updatefromsandbox",s=>{this.showElementAndHideCanvas(s.target);const i={value(s){o.userValue=s.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),s.target.value=o.userValue},formattedValue(s){const{formattedValue:i}=s.detail;o.formattedValue=i,null!=i&&s.target!==document.activeElement&&(s.target.value=i),t.setValue(e,{formattedValue:i})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:s=>{const{charLimit:i}=s.detail,{target:n}=s;if(0===i)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",i);let a=o.userValue;!a||a.length<=i||(a=a.slice(0,i),n.value=o.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(i,s)}),s.addEventListener("keydown",t=>{o.commitKey=1;let s=-1;if("Escape"===t.key?s=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):s=2,-1===s)return;const{value:i}=t.target;o.lastCommittedValue!==i&&(o.lastCommittedValue=i,o.userValue=i,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:s,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const i=h;h=null,s.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:s}=t.target;o.userValue=s,o.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),i(t)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;const{data:s,target:i}=t,{value:n,selectionStart:a,selectionEnd:r}=i;let h=a,l=r;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,a).match(/\w*[^\w]*$/);t&&(h-=t[0].length);break}case"deleteWordForward":{const t=n.substring(a).match(/^[^\w]*\w*/);t&&(l+=t[0].length);break}case"deleteContentBackward":a===r&&(h-=1);break;case"deleteContentForward":a===r&&(l+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:s||"",willCommit:!1,selStart:h,selEnd:l}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(h&&s.addEventListener("blur",h),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;s.classList.add("comb"),s.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ds extends Ls{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Fs extends Ls{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Cs.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Ss,n.addEventListener("change",i=>{const{name:n,checked:a}=i.target;for(const i of this._getElementsByName(n,s)){const s=a&&i.exportValue===e.exportValue;i.domElement&&(i.domElement.checked=s),t.setValue(i.id,{value:s})}t.setValue(s,{value:a})}),n.addEventListener("resetform",t=>{const s=e.defaultFieldValue||"Off";t.target.checked=s===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",e=>{const i={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(s,{value:e.target.checked})}};this._dispatchEventFromSandbox(i,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Ns extends Ls{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof i&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const i of this._getElementsByName(e.fieldName,s))t.setValue(i.id,{value:!1});const n=document.createElement("input");if(Cs.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=Ss,n.addEventListener("change",e=>{const{name:i,checked:n}=e.target;for(const e of this._getElementsByName(i,s))t.setValue(e.id,{value:!1});t.setValue(s,{value:n})}),n.addEventListener("resetform",t=>{const s=e.defaultFieldValue;t.target.checked=null!=s&&s===e.buttonValue}),this.enableScripting&&this.hasJSActions){const i=e.buttonValue;n.addEventListener("updatefromsandbox",e=>{const n={value:e=>{const n=i===e.detail.value;for(const i of this._getElementsByName(e.target.name)){const e=n&&i.id===s;i.domElement&&(i.domElement.checked=e),t.setValue(i.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Os extends Ps{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class Bs extends Ls{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Cs.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=Ss;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue;for(const t of i.options)t.selected=t.value===e});for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,s.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),i.append(e)}let a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),i.prepend(t),a=()=>{t.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const r=t=>{const e=t?"value":"textContent",{options:s,multiple:n}=i;return n?Array.prototype.filter.call(s,t=>t.selected).map(t=>t[e]):-1===s.selectedIndex?null:s[s.selectedIndex][e]};let o=r(!1);const h=t=>{const e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",s=>{const n={value(s){a?.();const n=s.detail.value,h=new Set(Array.isArray(n)?n:[n]);for(const t of i.options)t.selected=h.has(t.value);t.setValue(e,{value:r(!0)}),o=r(!1)},multipleSelection(t){i.multiple=!0},remove(s){const n=i.options,a=s.detail.remove;n[a].selected=!1,i.remove(a),n.length>0&&-1===Array.prototype.findIndex.call(n,t=>t.selected)&&(n[0].selected=!0),t.setValue(e,{value:r(!0),items:h(s)}),o=r(!1)},clear(s){for(;0!==i.length;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=r(!1)},insert(s){const{index:n,displayValue:a,exportValue:l}=s.detail.insert,c=i.children[n],d=document.createElement("option");d.textContent=a,d.value=l,c?c.before(d):i.append(d),t.setValue(e,{value:r(!0),items:h(s)}),o=r(!1)},items(s){const{items:n}=s.detail;for(;0!==i.length;)i.remove(0);for(const t of n){const{displayValue:e,exportValue:s}=t,n=document.createElement("option");n.textContent=e,n.value=s,i.append(n)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:r(!0),items:h(s)}),o=r(!1)},indices(s){const i=new Set(s.detail.indices);for(const t of s.target.options)t.selected=i.has(t.index);t.setValue(e,{value:r(!0)}),o=r(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,s)}),i.addEventListener("input",s=>{const i=r(!0),n=r(!1);t.setValue(e,{value:i}),s.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):i.addEventListener("input",function(s){t.setValue(e,{value:r(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Hs extends Ts{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:Ts._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new zs({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const s of this.elements)s.popup=t,e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(t=>`${G}${t}`).join(",")),this.container}}class zs{#ci=this.#di.bind(this);#ui=this.#pi.bind(this);#gi=this.#fi.bind(this);#mi=this.#vi.bind(this);#bi=null;#mt=null;#Ai=null;#yi=null;#_i=null;#wi=null;#xi=null;#Ei=!1;#Si=null;#E=null;#Ci=null;#ki=null;#Mi=null;#ii=null;#Ti=!1;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:r,parent:o,rect:h,parentRect:l,open:c}){this.#mt=t,this.#Mi=i,this.#Ai=a,this.#ki=r,this.#wi=o,this.#bi=e,this.#Ci=h,this.#xi=l,this.#_i=s,this.#yi=pt.toDateObject(n),this.trigger=s.flatMap(t=>t.getElementsToTriggerPopup());for(const t of this.trigger)t.addEventListener("click",this.#mi),t.addEventListener("mouseenter",this.#gi),t.addEventListener("mouseleave",this.#ui),t.classList.add("popupTriggerArea");for(const t of s)t.container?.addEventListener("keydown",this.#ci);this.#mt.hidden=!0,c&&this.#vi()}render(){if(this.#Si)return;const t=this.#Si=document.createElement("div");if(t.className="popup",this.#bi){const e=t.style.outlineColor=z.makeHexColor(...this.#bi);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=z.makeHexColor(...this.#bi.map(t=>Math.floor(e*(255-t)+t)))}}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),({dir:s.dir,str:s.textContent}=this.#Mi),t.append(e),this.#yi){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),t.setAttribute("data-l10n-args",JSON.stringify({date:this.#yi.toLocaleDateString(),time:this.#yi.toLocaleTimeString()})),e.append(t)}const i=this.#Pi;if(i)Es.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#Ai);t.append(e)}this.#mt.append(t)}get#Pi(){const t=this.#ki,e=this.#Ai;return!t?.str||e?.str&&e.str!==t.str?null:this.#ki.html||null}get#Ri(){return this.#Pi?.attributes?.style?.fontSize||0}get#Li(){return this.#Pi?.attributes?.style?.color||null}#Ii(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#Li,fontSize:this.#Ri?`calc(${this.#Ri}px * var(--scale-factor))`:""}};for(const s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return s}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let t=0,e=i.length;t<e;++t){const n=i[t];s.append(document.createTextNode(n)),t<e-1&&s.append(document.createElement("br"))}return s}#di(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#Ei)&&this.#vi()}updateEdited({rect:t,popupContent:e}){this.#ii||={contentsObj:this.#Ai,richText:this.#ki},t&&(this.#E=null),e&&(this.#ki=this.#Ii(e),this.#Ai=null),this.#Si?.remove(),this.#Si=null}resetEdited(){this.#ii&&(({contentsObj:this.#Ai,richText:this.#ki}=this.#ii),this.#ii=null,this.#Si?.remove(),this.#Si=null,this.#E=null)}#Di(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#wi;let a=!!this.#xi,r=a?this.#xi:this.#Ci;for(const t of this.#_i)if(!r||null!==z.intersect(t.data.rect,r)){r=t.data.rect,a=!0;break}const o=z.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),h=a?r[2]-r[0]+5:0,l=o[0]+h,c=o[1];this.#E=[100*(l-i)/e,100*(c-n)/s];const{style:d}=this.#mt;d.left=`${this.#E[0]}%`,d.top=`${this.#E[1]}%`}#vi(){this.#Ei=!this.#Ei,this.#Ei?(this.#fi(),this.#mt.addEventListener("click",this.#mi),this.#mt.addEventListener("keydown",this.#ci)):(this.#pi(),this.#mt.removeEventListener("click",this.#mi),this.#mt.removeEventListener("keydown",this.#ci))}#fi(){this.#Si||this.render(),this.isVisible?this.#Ei&&this.#mt.classList.add("focused"):(this.#Di(),this.#mt.hidden=!1,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)+1e3)}#pi(){this.#mt.classList.remove("focused"),!this.#Ei&&this.isVisible&&(this.#mt.hidden=!0,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)-1e3)}forceHide(){this.#Ti=this.isVisible,this.#Ti&&(this.#mt.hidden=!0)}maybeShow(){this.#Ti&&(this.#Si||this.#fi(),this.#Ti=!1,this.#mt.hidden=!1)}get isVisible(){return!1===this.#mt.hidden}}class js extends Ts{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=d.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class $s extends Ts{#Fi=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:s}=ks(t.rect),i=this.svgFactory.create(e,s,!0),n=this.#Fi=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Fi}addHighlightArea(){this.container.classList.add("highlightArea")}}class Vs extends Ts{#Ni=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:s}=ks(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,a=this.#Ni=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",s-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Ni}addHighlightArea(){this.container.classList.add("highlightArea")}}class Gs extends Ts{#Oi=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:s}=ks(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,a=this.#Oi=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",s/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",s/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Oi}addHighlightArea(){this.container.classList.add("highlightArea")}}class qs extends Ts{#Bi=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:i}}=this;if(!e)return this.container;const{width:n,height:a}=ks(t),r=this.svgFactory.create(n,a,!0);let o=[];for(let s=0,i=e.length;s<i;s+=2){const i=e[s]-t[0],n=t[3]-e[s+1];o.push(`${i},${n}`)}o=o.join(" ");const h=this.#Bi=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",o),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),r.append(h),this.container.append(r),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Bi}addHighlightArea(){this.container.classList.add("highlightArea")}}class Us extends qs{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ws extends Ts{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Xs extends Ts{#Hi=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=d.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,inkLists:e,borderStyle:s,popupRef:i}}=this,{width:n,height:a}=ks(t),r=this.svgFactory.create(n,a,!0);for(const n of e){let e=[];for(let s=0,i=n.length;s<i;s+=2){const i=n[s]-t[0],a=t[3]-n[s+1];e.push(`${i},${a}`)}e=e.join(" ");const a=this.svgFactory.createElement(this.svgElementName);this.#Hi.push(a),a.setAttribute("points",e),a.setAttribute("stroke-width",s.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),!i&&this.hasPopupData&&this._createPopup(),r.append(a)}return this.container.append(r),this.container}getElementsToTriggerPopup(){return this.#Hi}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ks extends Ts{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class Ys extends Ts{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Js extends Ts{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Qs extends Ts{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Zs extends Ts{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class ti extends Ts{#zi=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||0===e.fillAlpha?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),s.addEventListener("dblclick",this.#ji.bind(this)),this.#zi=s;const{isMac:i}=B.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(i?t.metaKey:t.ctrlKey)&&this.#ji()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#zi}addHighlightArea(){this.container.classList.add("highlightArea")}#ji(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ei{#$i=null;#Vi=null;#Gi=new Map;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a}){this.div=t,this.#$i=e,this.#Vi=s,this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}#qi(t,e){const s=t.firstChild||t;s.id=`${G}${e}`,this.div.append(t),this.#$i?.moveElementInDOM(this.div,t,s,!1)}async render(t){const{annotations:e}=t,s=this.div;bt(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new et,annotationStorage:t.annotationStorage||new Nt,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=16===t.annotationType;if(e){const e=i.get(t.id);if(!e)continue;n.elements=e}else{const{width:e,height:s}=ks(t.rect);if(e<=0||s<=0)continue}n.data=t;const s=Ms.create(n);if(!s.isRenderable)continue;if(!e&&t.popupRef){const e=i.get(t.popupRef);e?e.push(s):i.set(t.popupRef,[s])}const a=s.render();t.hidden&&(a.style.visibility="hidden"),this.#qi(a,t.id),s.annotationEditorType>0&&(this.#Gi.set(s.data.id,s),this._annotationEditorUIManager?.renderAnnotationElement(s))}this.#Ui()}update({viewport:t}){const e=this.div;this.viewport=t,bt(e,{rotation:t.rotation}),this.#Ui(),e.hidden=!1}#Ui(){if(!this.#Vi)return;const t=this.div;for(const[e,s]of this.#Vi){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?"CANVAS"===n.nodeName?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}this.#Vi.clear()}getEditableAnnotations(){return Array.from(this.#Gi.values())}getEditableAnnotation(t){return this.#Gi.get(t)}}const si=/\r\n?|\n/g;class ii extends Tt{#Wi=this.editorDivBlur.bind(this);#Xi=this.editorDivFocus.bind(this);#Ki=this.editorDivInput.bind(this);#Yi=this.editorDivKeydown.bind(this);#Ji=this.editorDivPaste.bind(this);#bi;#Qi="";#Zi=`${this.id}-editor`;#Ri;#tn=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=ii.prototype,e=t=>t.isEmpty(),s=kt.TRANSLATE_SMALL,i=kt.TRANSLATE_BIG;return C(this,"_keyboardManager",new St([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=d.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#bi=t.color||ii._defaultColor||Tt._defaultLineColor,this.#Ri=t.fontSize||ii._defaultFontSize}static initialize(t,e){Tt.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case u.FREETEXT_SIZE:ii._defaultFontSize=e;break;case u.FREETEXT_COLOR:ii._defaultColor=e}}updateParams(t,e){switch(t){case u.FREETEXT_SIZE:this.#en(e);break;case u.FREETEXT_COLOR:this.#sn(e)}}static get defaultPropertiesToUpdate(){return[[u.FREETEXT_SIZE,ii._defaultFontSize],[u.FREETEXT_COLOR,ii._defaultColor||Tt._defaultLineColor]]}get propertiesToUpdate(){return[[u.FREETEXT_SIZE,this.#Ri],[u.FREETEXT_COLOR,this.#bi]]}#en(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#Ri)*this.parentScale),this.#Ri=t,this.#in()},s=this.#Ri;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#sn(t){const e=t=>{this.#bi=this.editorDiv.style.color=t},s=this.#bi;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-ii._internalPadding*t,-(ii._internalPadding+this.#Ri)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(d.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const t=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#Yi,{signal:t}),this.editorDiv.addEventListener("focus",this.#Xi,{signal:t}),this.editorDiv.addEventListener("blur",this.#Wi,{signal:t}),this.editorDiv.addEventListener("input",this.#Ki,{signal:t}),this.editorDiv.addEventListener("paste",this.#Ji,{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Zi),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#Yi),this.editorDiv.removeEventListener("focus",this.#Xi),this.editorDiv.removeEventListener("blur",this.#Wi),this.editorDiv.removeEventListener("input",this.#Ki),this.editorDiv.removeEventListener("paste",this.#Ji),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#nn(){const t=[];this.editorDiv.normalize();for(const e of this.editorDiv.childNodes)t.push(ii.#an(e));return t.join("\n")}#in(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,i=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),s=e.getBoundingClientRect(),e.remove(),e.style.display=i,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Qi,e=this.#Qi=this.#nn().trimEnd();if(t===e)return;const s=t=>{this.#Qi=t,t?(this.#rn(),this._uiManager.rebuild(this),this.#in()):this.remove()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#in()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){ii._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Zi),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),Tt._l10nPromise.get("pdfjs-free-text-default-content").then(t=>this.editorDiv?.setAttribute("default-content",t)),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#Ri}px * var(--scale-factor))`,s.color=this.#bi,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),_t(this,this.div,["dblclick","keydown"]),this.width){const[s,i]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this.#tn;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,h]=this.pageDimensions,[l,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-l)/o,u=e+this.height-(n[1]-c)/h;break;case 90:d=t+(n[0]-l)/o,u=e-(n[1]-c)/h,[a,r]=[r,-a];break;case 180:d=t-this.width+(n[0]-l)/o,u=e-(n[1]-c)/h,[a,r]=[-a,-r];break;case 270:d=t+(n[0]-l-this.height*h)/o,u=e+(n[1]-c-this.width*o)/h,[a,r]=[-r,a]}this.setAt(d*s,u*i,a,r)}else this.setAt(t*s,e*i,this.width*s,this.height*i);this.#rn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#an(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(si,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(1===s.length&&"text/plain"===s[0])return;t.preventDefault();const i=ii.#on(e.getData("text")||"").replaceAll(si,"\n");if(!i)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const a=n.getRangeAt(0);if(!i.includes("\n"))return a.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:r,startOffset:o}=a,h=[],l=[];if(r.nodeType===Node.TEXT_NODE){const t=r.parentElement;if(l.push(r.nodeValue.slice(o).replaceAll(si,"")),t!==this.editorDiv){let e=h;for(const s of this.editorDiv.childNodes)s!==t?e.push(ii.#an(s)):e=l}h.push(r.nodeValue.slice(0,o).replaceAll(si,""))}else if(r===this.editorDiv){let t=h,e=0;for(const s of this.editorDiv.childNodes)e++===o&&(t=l),t.push(ii.#an(s))}this.#Qi=`${h.join("\n")}${i}${l.join("\n")}`,this.#rn();const c=new Range;let d=h.reduce((t,e)=>t+e.length,0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(d<=e){c.setStart(t,d),c.setEnd(t,d);break}d-=e}n.removeAllRanges(),n.addRange(c)}#rn(){if(this.editorDiv.replaceChildren(),this.#Qi)for(const t of this.#Qi.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#hn(){return this.#Qi.replaceAll(" "," ")}static#on(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static deserialize(t,e,s){let i=null;if(t instanceof js){const{data:{defaultAppearanceData:{fontSize:e,fontColor:s},rect:n,rotation:a,id:r},textContent:o,textPosition:h,parent:{page:{pageNumber:l}}}=t;if(!o||0===o.length)return null;i=t={annotationType:d.FREETEXT,color:Array.from(s),fontSize:e,value:o.join("\n"),position:h,pageIndex:l-1,rect:n.slice(0),rotation:a,id:r,deleted:!1}}const n=super.deserialize(t,e,s);return n.#Ri=t.fontSize,n.#bi=z.makeHexColor(...t.color),n.#Qi=ii.#on(t.value),n.annotationElementId=t.id||null,n.#tn=i,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=ii._internalPadding*this.parentScale,s=this.getRect(e,e),i=Tt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#bi),n={annotationType:d.FREETEXT,color:i,fontSize:this.#Ri,value:this.#hn(),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#ln(n)?null:(n.id=this.annotationElementId,n)}#ln(t){const{value:e,fontSize:s,color:i,pageIndex:n}=this.#tn;return this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((t,e)=>t!==i[e])||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:s}=e;s.fontSize=`calc(${this.#Ri}px * var(--scale-factor))`,s.color=this.#bi,e.replaceChildren();for(const t of this.#Qi.split("\n")){const s=document.createElement("div");s.append(t?document.createTextNode(t):document.createElement("br")),e.append(s)}const i=ii._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#Qi}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class ni{#cn;#dn=[];#un=[];constructor(t,e=0,s=0,i=!0){let n=1/0,a=-1/0,r=1/0,o=-1/0;const h=10**-4;for(const{x:s,y:i,width:l,height:c}of t){const t=Math.floor((s-e)/h)*h,d=Math.ceil((s+l+e)/h)*h,u=Math.floor((i-e)/h)*h,p=Math.ceil((i+c+e)/h)*h,g=[t,u,p,!0],f=[d,u,p,!1];this.#dn.push(g,f),n=Math.min(n,t),a=Math.max(a,d),r=Math.min(r,u),o=Math.max(o,p)}const l=a-n+2*s,c=o-r+2*s,d=n-s,u=r-s,p=this.#dn.at(i?-1:-2),g=[p[0],p[2]];for(const t of this.#dn){const[e,s,i]=t;t[0]=(e-d)/l,t[1]=(s-u)/c,t[2]=(i-u)/c}this.#cn={x:d,y:u,width:l,height:c,lastPoint:g}}getOutlines(){this.#dn.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of this.#dn)e[3]?(t.push(...this.#pn(e)),this.#gn(e)):(this.#fn(e),t.push(...this.#pn(e)));return this.#mn(t)}#mn(t){const e=[],s=new Set;for(const s of t){const[t,i,n]=s;e.push([t,i,s],[t,n,s])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,i=e.length;t<i;t+=2){const i=e[t][2],n=e[t+1][2];i.push(n),n.push(i),s.add(i),s.add(n)}const i=[];let n;for(;s.size>0;){const t=s.values().next().value;let[e,a,r,o,h]=t;s.delete(t);let l=e,c=a;for(n=[e,r],i.push(n);;){let t;if(s.has(o))t=o;else{if(!s.has(h))break;t=h}s.delete(t),[e,a,r,o,h]=t,l!==e&&(n.push(l,c,e,c===a?a:r),l=e),c=c===a?r:a}n.push(l,c)}return new ri(i,this.#cn)}#vn(t){const e=this.#un;let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,a=e[n][0];if(a===t)return n;a<t?s=n+1:i=n-1}return i+1}#gn([,t,e]){const s=this.#vn(t);this.#un.splice(s,0,[t,e])}#fn([,t,e]){const s=this.#vn(t);for(let i=s;i<this.#un.length;i++){const[s,n]=this.#un[i];if(s!==t)break;if(s===t&&n===e)return void this.#un.splice(i,1)}for(let i=s-1;i>=0;i--){const[s,n]=this.#un[i];if(s!==t)break;if(s===t&&n===e)return void this.#un.splice(i,1)}}#pn(t){const[e,s,i]=t,n=[[e,s,i]],a=this.#vn(i);for(let t=0;t<a;t++){const[s,i]=this.#un[t];for(let t=0,a=n.length;t<a;t++){const[,r,o]=n[t];if(!(i<=r||o<=s))if(r>=s)if(o>i)n[t][1]=i;else{if(1===a)return[];n.splice(t,1),t--,a--}else n[t][2]=s,o>i&&n.push([e,i,o])}}return n}}class ai{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(t,e){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof hi}}class ri extends ai{#cn;#bn;constructor(t,e){super(),this.#bn=t,this.#cn=e}toSVGPath(){const t=[];for(const e of this.#bn){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const a=e[n],r=e[n+1];a===s?(t.push(`V${r}`),i=r):r===i&&(t.push(`H${a}`),s=a)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const a=[],r=s-t,o=i-e;for(const e of this.#bn){const s=new Array(e.length);for(let n=0;n<e.length;n+=2)s[n]=t+e[n]*r,s[n+1]=i-e[n+1]*o;a.push(s)}return a}get box(){return this.#cn}}class oi{#cn;#An=[];#yn;#_n;#wn=[];#xn=new Float64Array(18);#En;#Sn;#Cn;#kn;#Mn;#Tn;#Pn=[];static#Rn=8;static#Ln=2;static#In=oi.#Rn+oi.#Ln;constructor({x:t,y:e},s,i,n,a,r=0){this.#cn=s,this.#Tn=n*i,this.#_n=a,this.#xn.set([NaN,NaN,NaN,NaN,t,e],6),this.#yn=r,this.#kn=oi.#Rn*i,this.#Cn=oi.#In*i,this.#Mn=i,this.#Pn.push(t,e)}get free(){return!0}isEmpty(){return isNaN(this.#xn[8])}#Dn(){const t=this.#xn.subarray(4,6),e=this.#xn.subarray(16,18),[s,i,n,a]=this.#cn;return[(this.#En+(t[0]-e[0])/2-s)/n,(this.#Sn+(t[1]-e[1])/2-i)/a,(this.#En+(e[0]-t[0])/2-s)/n,(this.#Sn+(e[1]-t[1])/2-i)/a]}add({x:t,y:e}){this.#En=t,this.#Sn=e;const[s,i,n,a]=this.#cn;let[r,o,h,l]=this.#xn.subarray(8,12);const c=t-h,d=e-l,u=Math.hypot(c,d);if(u<this.#Cn)return!1;const p=u-this.#kn,g=p/u,f=g*c,m=g*d;let v=r,b=o;r=h,o=l,h+=f,l+=m,this.#Pn?.push(t,e);const A=f/p,y=-m/p*this.#Tn,_=A*this.#Tn;return this.#xn.set(this.#xn.subarray(2,8),0),this.#xn.set([h+y,l+_],4),this.#xn.set(this.#xn.subarray(14,18),12),this.#xn.set([h-y,l-_],16),isNaN(this.#xn[6])?(0===this.#wn.length&&(this.#xn.set([r+y,o+_],2),this.#wn.push(NaN,NaN,NaN,NaN,(r+y-s)/n,(o+_-i)/a),this.#xn.set([r-y,o-_],14),this.#An.push(NaN,NaN,NaN,NaN,(r-y-s)/n,(o-_-i)/a)),this.#xn.set([v,b,r,o,h,l],6),!this.isEmpty()):(this.#xn.set([v,b,r,o,h,l],6),Math.abs(Math.atan2(b-o,v-r)-Math.atan2(m,f))<Math.PI/2?([r,o,h,l]=this.#xn.subarray(2,6),this.#wn.push(NaN,NaN,NaN,NaN,((r+h)/2-s)/n,((o+l)/2-i)/a),[r,o,v,b]=this.#xn.subarray(14,18),this.#An.push(NaN,NaN,NaN,NaN,((v+r)/2-s)/n,((b+o)/2-i)/a),!0):([v,b,r,o,h,l]=this.#xn.subarray(0,6),this.#wn.push(((v+5*r)/6-s)/n,((b+5*o)/6-i)/a,((5*r+h)/6-s)/n,((5*o+l)/6-i)/a,((r+h)/2-s)/n,((o+l)/2-i)/a),[h,l,r,o,v,b]=this.#xn.subarray(12,18),this.#An.push(((v+5*r)/6-s)/n,((b+5*o)/6-i)/a,((5*r+h)/6-s)/n,((5*o+l)/6-i)/a,((r+h)/2-s)/n,((o+l)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#wn,e=this.#An,s=this.#xn.subarray(4,6),i=this.#xn.subarray(16,18),[n,a,r,o]=this.#cn,[h,l,c,d]=this.#Dn();if(isNaN(this.#xn[6])&&!this.isEmpty())return`M${(this.#xn[2]-n)/r} ${(this.#xn[3]-a)/o} L${(this.#xn[4]-n)/r} ${(this.#xn[5]-a)/o} L${h} ${l} L${c} ${d} L${(this.#xn[16]-n)/r} ${(this.#xn[17]-a)/o} L${(this.#xn[14]-n)/r} ${(this.#xn[15]-a)/o} Z`;const u=[];u.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?u.push(`L${t[e+4]} ${t[e+5]}`):u.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);u.push(`L${(s[0]-n)/r} ${(s[1]-a)/o} L${h} ${l} L${c} ${d} L${(i[0]-n)/r} ${(i[1]-a)/o}`);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?u.push(`L${e[t+4]} ${e[t+5]}`):u.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return u.push(`L${e[4]} ${e[5]} Z`),u.join(" ")}getOutlines(){const t=this.#wn,e=this.#An,s=this.#xn,i=s.subarray(4,6),n=s.subarray(16,18),[a,r,o,h]=this.#cn,l=new Float64Array((this.#Pn?.length??0)+2);for(let t=0,e=l.length-2;t<e;t+=2)l[t]=(this.#Pn[t]-a)/o,l[t+1]=(this.#Pn[t+1]-r)/h;l[l.length-2]=(this.#En-a)/o,l[l.length-1]=(this.#Sn-r)/h;const[c,d,u,p]=this.#Dn();if(isNaN(s[6])&&!this.isEmpty()){const t=new Float64Array(36);return t.set([NaN,NaN,NaN,NaN,(s[2]-a)/o,(s[3]-r)/h,NaN,NaN,NaN,NaN,(s[4]-a)/o,(s[5]-r)/h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,(s[16]-a)/o,(s[17]-r)/h,NaN,NaN,NaN,NaN,(s[14]-a)/o,(s[15]-r)/h],0),new hi(t,l,this.#cn,this.#Mn,this.#yn,this.#_n)}const g=new Float64Array(this.#wn.length+24+this.#An.length);let f=t.length;for(let e=0;e<f;e+=2)isNaN(t[e])?g[e]=g[e+1]=NaN:(g[e]=t[e],g[e+1]=t[e+1]);g.set([NaN,NaN,NaN,NaN,(i[0]-a)/o,(i[1]-r)/h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,(n[0]-a)/o,(n[1]-r)/h],f),f+=24;for(let t=e.length-6;t>=6;t-=6)for(let s=0;s<6;s+=2)isNaN(e[t+s])?(g[f]=g[f+1]=NaN,f+=2):(g[f]=e[t+s],g[f+1]=e[t+s+1],f+=2);return g.set([NaN,NaN,NaN,NaN,e[4],e[5]],f),new hi(g,l,this.#cn,this.#Mn,this.#yn,this.#_n)}}class hi extends ai{#cn;#Fn=null;#yn;#_n;#Pn;#Mn;#Nn;constructor(t,e,s,i,n,a){super(),this.#Nn=t,this.#Pn=e,this.#cn=s,this.#Mn=i,this.#yn=n,this.#_n=a,this.#On(a);const{x:r,y:o,width:h,height:l}=this.#Fn;for(let e=0,s=t.length;e<s;e+=2)t[e]=(t[e]-r)/h,t[e+1]=(t[e+1]-o)/l;for(let t=0,s=e.length;t<s;t+=2)e[t]=(e[t]-r)/h,e[t+1]=(e[t+1]-o)/l}toSVGPath(){const t=[`M${this.#Nn[4]} ${this.#Nn[5]}`];for(let e=6,s=this.#Nn.length;e<s;e+=6)isNaN(this.#Nn[e])?t.push(`L${this.#Nn[e+4]} ${this.#Nn[e+5]}`):t.push(`C${this.#Nn[e]} ${this.#Nn[e+1]} ${this.#Nn[e+2]} ${this.#Nn[e+3]} ${this.#Nn[e+4]} ${this.#Nn[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){const a=s-t,r=i-e;let o,h;switch(n){case 0:o=this.#Bn(this.#Nn,t,i,a,-r),h=this.#Bn(this.#Pn,t,i,a,-r);break;case 90:o=this.#Hn(this.#Nn,t,e,a,r),h=this.#Hn(this.#Pn,t,e,a,r);break;case 180:o=this.#Bn(this.#Nn,s,e,-a,r),h=this.#Bn(this.#Pn,s,e,-a,r);break;case 270:o=this.#Hn(this.#Nn,s,i,-a,-r),h=this.#Hn(this.#Pn,s,i,-a,-r)}return{outline:Array.from(o),points:[Array.from(h)]}}#Bn(t,e,s,i,n){const a=new Float64Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*i,a[r+1]=s+t[r+1]*n;return a}#Hn(t,e,s,i,n){const a=new Float64Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*i,a[r+1]=s+t[r]*n;return a}#On(t){const e=this.#Nn;let s=e[4],i=e[5],n=s,a=i,r=s,o=i,h=s,l=i;const c=t?Math.max:Math.min;for(let t=6,d=e.length;t<d;t+=6){if(isNaN(e[t]))n=Math.min(n,e[t+4]),a=Math.min(a,e[t+5]),r=Math.max(r,e[t+4]),o=Math.max(o,e[t+5]),l<e[t+5]?(h=e[t+4],l=e[t+5]):l===e[t+5]&&(h=c(h,e[t+4]));else{const d=z.bezierBoundingBox(s,i,...e.slice(t,t+6));n=Math.min(n,d[0]),a=Math.min(a,d[1]),r=Math.max(r,d[2]),o=Math.max(o,d[3]),l<d[3]?(h=d[2],l=d[3]):l===d[3]&&(h=c(h,d[2]))}s=e[t+4],i=e[t+5]}const d=n-this.#yn,u=a-this.#yn,p=r-n+2*this.#yn,g=o-a+2*this.#yn;this.#Fn={x:d,y:u,width:p,height:g,lastPoint:[h,l]}}get box(){return this.#Fn}getNewOutline(t,e){const{x:s,y:i,width:n,height:a}=this.#Fn,[r,o,h,l]=this.#cn,c=n*h,d=a*l,u=s*h+r,p=i*l+o,g=new oi({x:this.#Pn[0]*c+u,y:this.#Pn[1]*d+p},this.#cn,this.#Mn,t,this.#_n,e??this.#yn);for(let t=2;t<this.#Pn.length;t+=2)g.add({x:this.#Pn[t]*c+u,y:this.#Pn[t+1]*d+p});return g.getOutlines()}}class li{#ci=this.#di.bind(this);#zn=this.#o.bind(this);#jn=null;#$n=null;#Vn;#Gn=null;#qn=!1;#Un=!1;#a=null;#Wn;#p=null;#Xn;static get _keyboardManager(){return C(this,"_keyboardManager",new St([[["Escape","mac+Escape"],li.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],li.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],li.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],li.prototype._moveToPrevious],[["Home","mac+Home"],li.prototype._moveToBeginning],[["End","mac+End"],li.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#Un=!1,this.#Xn=u.HIGHLIGHT_COLOR,this.#a=t):(this.#Un=!0,this.#Xn=u.HIGHLIGHT_DEFAULT_COLOR),this.#p=t?._uiManager||e,this.#Wn=this.#p._eventBus,this.#Vn=t?.color||this.#p?.highlightColors.values().next().value||"#FFFF98"}renderButton(){const t=this.#jn=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#p._signal;t.addEventListener("click",this.#Kn.bind(this),{signal:e}),t.addEventListener("keydown",this.#ci,{signal:e});const s=this.#$n=document.createElement("span");return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=this.#Vn,t.append(s),t}renderMainDropdown(){const t=this.#Gn=this.#Yn();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Yn(){const t=document.createElement("div"),e=this.#p._signal;t.addEventListener("contextmenu",ct,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of this.#p.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${s}`);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=i,n.setAttribute("aria-selected",i===this.#Vn),n.addEventListener("click",this.#Jn.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#ci,{signal:e}),t}#Jn(t,e){e.stopPropagation(),this.#Wn.dispatch("switchannotationeditorparams",{source:this,type:this.#Xn,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#jn)return void this.#Kn(t);const e=t.target.getAttribute("data-color");e&&this.#Jn(e,t)}_moveToNext(t){this.#Qn?t.target!==this.#jn?t.target.nextSibling?.focus():this.#Gn.firstChild?.focus():this.#Kn(t)}_moveToPrevious(t){t.target!==this.#Gn?.firstChild&&t.target!==this.#jn?(this.#Qn||this.#Kn(t),t.target.previousSibling?.focus()):this.#Qn&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Qn?this.#Gn.firstChild?.focus():this.#Kn(t)}_moveToEnd(t){this.#Qn?this.#Gn.lastChild?.focus():this.#Kn(t)}#di(t){li._keyboardManager.exec(this,t)}#Kn(t){if(this.#Qn)return void this.hideDropdown();if(this.#qn=0===t.detail,window.addEventListener("pointerdown",this.#zn,{signal:this.#p._signal}),this.#Gn)return void this.#Gn.classList.remove("hidden");const e=this.#Gn=this.#Yn();this.#jn.append(e)}#o(t){this.#Gn?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Gn?.classList.add("hidden"),window.removeEventListener("pointerdown",this.#zn)}get#Qn(){return this.#Gn&&!this.#Gn.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#Un||(this.#Qn?(this.hideDropdown(),this.#jn.focus({preventScroll:!0,focusVisible:this.#qn})):this.#a?.unselect())}updateColor(t){if(this.#$n&&(this.#$n.style.backgroundColor=t),!this.#Gn)return;const e=this.#p.highlightColors.values();for(const s of this.#Gn.children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#jn?.remove(),this.#jn=null,this.#$n=null,this.#Gn?.remove(),this.#Gn=null}}class ci extends Tt{#Zn=null;#ta=0;#ea;#sa=null;#n=null;#ia=null;#na=null;#aa=0;#ra=null;#oa=null;#v=null;#ha=!1;#ot=this.#la.bind(this);#ca=null;#da;#ua=null;#pa="";#Tn;#ga="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=d.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=ci.prototype;return C(this,"_keyboardManager",new St([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||ci._defaultColor,this.#Tn=t.thickness||ci._defaultThickness,this.#da=t.opacity||ci._defaultOpacity,this.#ea=t.boxes||null,this.#ga=t.methodOfCreation||"",this.#pa=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#ha=!0,this.#fa(t),this.#ma()):(this.#Zn=t.anchorNode,this.#ta=t.anchorOffset,this.#na=t.focusNode,this.#aa=t.focusOffset,this.#va(),this.#ma(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#ha?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#Tn,methodOfCreation:this.#ga}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#va(){const t=new ni(this.#ea,.001);this.#oa=t.getOutlines(),({x:this.x,y:this.y,width:this.width,height:this.height}=this.#oa.box);const e=new ni(this.#ea,.0025,.001,"ltr"===this._uiManager.direction);this.#ia=e.getOutlines();const{lastPoint:s}=this.#ia.box;this.#ca=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#fa({highlightOutlines:t,highlightId:e,clipPathId:s}){if(this.#oa=t,this.#ia=t.getNewOutline(this.#Tn/2+1.5,.0025),e>=0)this.#v=e,this.#sa=s,this.parent.drawLayer.finalizeLine(e,t),this.#ua=this.parent.drawLayer.highlightOutline(this.#ia);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#v,t),this.parent.drawLayer.updateBox(this.#v,ci.#ba(this.#oa.box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#ua,this.#ia),this.parent.drawLayer.updateBox(this.#ua,ci.#ba(this.#ia.box,e))}const{x:i,y:n,width:a,height:r}=t.box;switch(this.rotation){case 0:this.x=i,this.y=n,this.width=a,this.height=r;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-i,this.width=a*e/t,this.height=r*t/e;break}case 180:this.x=1-i,this.y=1-n,this.width=a,this.height=r;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=i,this.width=a*e/t,this.height=r*t/e;break}}const{lastPoint:o}=this.#ia.box;this.#ca=[(o[0]-i)/a,(o[1]-n)/r]}static initialize(t,e){Tt.initialize(t,e),ci._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case u.HIGHLIGHT_DEFAULT_COLOR:ci._defaultColor=e;break;case u.HIGHLIGHT_THICKNESS:ci._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#ca}updateParams(t,e){switch(t){case u.HIGHLIGHT_COLOR:this.#sn(e);break;case u.HIGHLIGHT_THICKNESS:this.#Aa(e)}}static get defaultPropertiesToUpdate(){return[[u.HIGHLIGHT_DEFAULT_COLOR,ci._defaultColor],[u.HIGHLIGHT_THICKNESS,ci._defaultThickness]]}get propertiesToUpdate(){return[[u.HIGHLIGHT_COLOR,this.color||ci._defaultColor],[u.HIGHLIGHT_THICKNESS,this.#Tn||ci._defaultThickness],[u.HIGHLIGHT_FREE,this.#ha]]}#sn(t){const e=t=>{this.color=t,this.parent?.drawLayer.changeColor(this.#v,t),this.#n?.updateColor(t)},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#Aa(t){const e=this.#Tn,s=t=>{this.#Tn=t,this.#ya(t)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new li({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#_a())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#_a())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#wa(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ma(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#wa():t&&(this.#ma(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#ya(t){if(!this.#ha)return;this.#fa({highlightOutlines:this.#oa.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}#wa(){null!==this.#v&&this.parent&&(this.parent.drawLayer.remove(this.#v),this.#v=null,this.parent.drawLayer.remove(this.#ua),this.#ua=null)}#ma(t=this.parent){null===this.#v&&(({id:this.#v,clipPathId:this.#sa}=t.drawLayer.highlight(this.#oa,this.color,this.#da)),this.#ua=t.drawLayer.highlightOutline(this.#ia),this.#ra&&(this.#ra.style.clipPath=this.#sa))}static#ba({x:t,y:e,width:s,height:i},n){switch(n){case 90:return{x:1-e-i,y:t,width:i,height:s};case 180:return{x:1-t-s,y:1-e-i,width:s,height:i};case 270:return{x:e,y:1-t-s,width:i,height:s}}return{x:t,y:e,width:s,height:i}}rotate(t){const{drawLayer:e}=this.parent;let s;this.#ha?(t=(t-this.rotation+360)%360,s=ci.#ba(this.#oa.box,t)):s=ci.#ba(this,t),e.rotate(this.#v,t),e.rotate(this.#ua,t),e.updateBox(this.#v,s),e.updateBox(this.#ua,ci.#ba(this.#ia.box,t))}render(){if(this.div)return this.div;const t=super.render();this.#pa&&(t.setAttribute("aria-label",this.#pa),t.setAttribute("role","mark")),this.#ha?t.classList.add("free"):this.div.addEventListener("keydown",this.#ot,{signal:this._uiManager._signal});const e=this.#ra=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#sa;const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),_t(this,this.#ra,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(this.#ua,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#ua,"hovered")}#la(t){ci._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#xa(!0);break;case 1:case 3:this.#xa(!1)}}#xa(t){if(!this.#Zn)return;const e=window.getSelection();t?e.setPosition(this.#Zn,this.#ta):e.setPosition(this.#na,this.#aa)}select(){super.select(),this.#ua&&(this.parent?.drawLayer.removeClass(this.#ua,"hovered"),this.parent?.drawLayer.addClass(this.#ua,"selected"))}unselect(){super.unselect(),this.#ua&&(this.parent?.drawLayer.removeClass(this.#ua,"selected"),this.#ha||this.#xa(!1))}get _mustFixPosition(){return!this.#ha}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(this.#v,t),this.parent.drawLayer.show(this.#ua,t))}#_a(){return this.#ha?this.rotation:0}#Ea(){if(this.#ha)return null;const[t,e]=this.pageDimensions,s=this.#ea,i=new Float32Array(8*s.length);let n=0;for(const{x:a,y:r,width:o,height:h}of s){const s=a*t,l=(1-r-h)*e;i[n]=i[n+4]=s,i[n+1]=i[n+3]=l,i[n+2]=i[n+6]=s+o*t,i[n+5]=i[n+7]=l+h*e,n+=8}return i}#Sa(t){return this.#oa.serialize(t,this.#_a())}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:a,y:r,width:o,height:h}=s.getBoundingClientRect(),l=e=>{this.#Ca(t,e)},c=t._signal,d={capture:!0,passive:!1,signal:c},u=t=>{t.preventDefault(),t.stopPropagation()},p=e=>{s.removeEventListener("pointermove",l),window.removeEventListener("blur",p),window.removeEventListener("pointerup",p),window.removeEventListener("pointerdown",u,d),window.removeEventListener("contextmenu",ct),this.#ka(t,e)};window.addEventListener("blur",p,{signal:c}),window.addEventListener("pointerup",p,{signal:c}),window.addEventListener("pointerdown",u,d),window.addEventListener("contextmenu",ct,{signal:c}),s.addEventListener("pointermove",l,{signal:c}),this._freeHighlight=new oi({x:i,y:n},[a,r,o,h],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0))}static#Ca(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#ka(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static deserialize(t,e,s){const i=super.deserialize(t,e,s),{rect:[n,a,r,o],color:h,quadPoints:l}=t;i.color=z.makeHexColor(...h),i.#da=t.opacity;const[c,d]=i.pageDimensions;i.width=(r-n)/c,i.height=(o-a)/d;const u=i.#ea=[];for(let t=0;t<l.length;t+=8)u.push({x:(l[4]-r)/c,y:(o-(1-l[t+5]))/d,width:(l[t+2]-l[t])/c,height:(l[t+5]-l[t+1])/d});return i.#va(),i}serialize(t=!1){if(this.isEmpty()||t)return null;const e=this.getRect(0,0),s=Tt._colorManager.convert(this.color);return{annotationType:d.HIGHLIGHT,color:s,opacity:this.#da,thickness:this.#Tn,quadPoints:this.#Ea(),outlines:this.#Sa(e),pageIndex:this.pageIndex,rect:e,rotation:this.#_a(),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}}class di extends Tt{#Ma=0;#Ta=0;#Pa=this.canvasPointermove.bind(this);#Ra=this.canvasPointerleave.bind(this);#La=this.canvasPointerup.bind(this);#Ia=this.canvasPointerdown.bind(this);#Da=null;#Fa=new Path2D;#Na=!1;#Oa=!1;#Ba=!1;#Ha=null;#za=0;#ja=0;#$a=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=d.INK;constructor(t){super({...t,name:"inkEditor"}),this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,e){Tt.initialize(t,e)}static updateDefaultParams(t,e){switch(t){case u.INK_THICKNESS:di._defaultThickness=e;break;case u.INK_COLOR:di._defaultColor=e;break;case u.INK_OPACITY:di._defaultOpacity=e/100}}updateParams(t,e){switch(t){case u.INK_THICKNESS:this.#Aa(e);break;case u.INK_COLOR:this.#sn(e);break;case u.INK_OPACITY:this.#Va(e)}}static get defaultPropertiesToUpdate(){return[[u.INK_THICKNESS,di._defaultThickness],[u.INK_COLOR,di._defaultColor||Tt._defaultLineColor],[u.INK_OPACITY,Math.round(100*di._defaultOpacity)]]}get propertiesToUpdate(){return[[u.INK_THICKNESS,this.thickness||di._defaultThickness],[u.INK_COLOR,this.color||di._defaultColor||Tt._defaultLineColor],[u.INK_OPACITY,Math.round(100*(this.opacity??di._defaultOpacity))]]}#Aa(t){const e=t=>{this.thickness=t,this.#Ga()},s=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#sn(t){const e=t=>{this.color=t,this.#qa()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#Va(t){const e=t=>{this.opacity=t,this.#qa()};t/=100;const s=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(this.#Ua(),this.#Wa()),this.isAttachedToDOM||(this.parent.add(this),this.#Xa()),this.#Ga()))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#Da&&(clearTimeout(this.#Da),this.#Da=null),this.#Ha?.disconnect(),this.#Ha=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&null===t&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,e]=this.parentDimensions,s=this.width*t,i=this.height*e;this.setDimensions(s,i)}enableEditMode(){this.#Na||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#Ia,{signal:this._uiManager._signal}))}disableEditMode(){this.isInEditMode()&&null!==this.canvas&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#Ia))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}#Ka(){const{parentRotation:t,parentDimensions:[e,s]}=this;switch(t){case 90:return[0,s,s,e];case 180:return[e,s,e,s];case 270:return[e,0,s,e];default:return[0,0,e,s]}}#Ya(){const{ctx:t,color:e,opacity:s,thickness:i,parentScale:n,scaleFactor:a}=this;t.lineWidth=i*n/a,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${function(t){return Math.round(Math.min(255,Math.max(1,255*t))).toString(16).padStart(2,"0")}(s)}`}#Ja(t,e){const s=this._uiManager._signal;this.canvas.addEventListener("contextmenu",ct,{signal:s}),this.canvas.addEventListener("pointerleave",this.#Ra,{signal:s}),this.canvas.addEventListener("pointermove",this.#Pa,{signal:s}),this.canvas.addEventListener("pointerup",this.#La,{signal:s}),this.canvas.removeEventListener("pointerdown",this.#Ia),this.isEditing=!0,this.#Ba||(this.#Ba=!0,this.#Xa(),this.thickness||=di._defaultThickness,this.color||=di._defaultColor||Tt._defaultLineColor,this.opacity??=di._defaultOpacity),this.currentPath.push([t,e]),this.#Oa=!1,this.#Ya(),this.#$a=()=>{this.#Qa(),this.#$a&&window.requestAnimationFrame(this.#$a)},window.requestAnimationFrame(this.#$a)}#Za(t,e){const[s,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===s&&e===i)return;const n=this.currentPath;let a=this.#Fa;n.push([t,e]),this.#Oa=!0,n.length<=2?(a.moveTo(...n[0]),a.lineTo(t,e)):(3===n.length&&(this.#Fa=a=new Path2D,a.moveTo(...n[0])),this.#tr(a,...n.at(-3),...n.at(-2),t,e))}#er(){if(0===this.currentPath.length)return;const t=this.currentPath.at(-1);this.#Fa.lineTo(...t)}#sr(t,e){let s;if(this.#$a=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#Za(t,e),this.#er(),1!==this.currentPath.length)s=this.#ir();else{const i=[t,e];s=[[i,i.slice(),i.slice(),i]]}const i=this.#Fa,n=this.currentPath;this.currentPath=[],this.#Fa=new Path2D,this.addCommands({cmd:()=>{this.allRawPaths.push(n),this.paths.push(s),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(this.#Ua(),this.#Wa()),this.#Ga())},mustExec:!0})}#Qa(){if(!this.#Oa)return;this.#Oa=!1,Math.ceil(this.thickness*this.parentScale);const t=this.currentPath.slice(-3),e=t.map(t=>t[0]),s=t.map(t=>t[1]),{ctx:i}=(Math.min(...e),Math.max(...e),Math.min(...s),Math.max(...s),this);i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.bezierPath2D)i.stroke(t);i.stroke(this.#Fa),i.restore()}#tr(t,e,s,i,n,a,r){const o=(e+i)/2,h=(s+n)/2,l=(i+a)/2,c=(n+r)/2;t.bezierCurveTo(o+2*(i-o)/3,h+2*(n-h)/3,l+2*(i-l)/3,c+2*(n-c)/3,l,c)}#ir(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const e=[];let s,[i,n]=t[0];for(s=1;s<t.length-2;s++){const[a,r]=t[s],[o,h]=t[s+1],l=(a+o)/2,c=(r+h)/2,d=[i+2*(a-i)/3,n+2*(r-n)/3],u=[l+2*(a-l)/3,c+2*(r-c)/3];e.push([[i,n],d,u,[l,c]]),[i,n]=[l,c]}const[a,r]=t[s],[o,h]=t[s+1],l=[i+2*(a-i)/3,n+2*(r-n)/3],c=[o+2*(a-o)/3,h+2*(r-h)/3];return e.push([[i,n],l,c,[o,h]]),e}#qa(){if(this.isEmpty())return void this.#nr();this.#Ya();const{canvas:t,ctx:e}=this;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),this.#nr();for(const t of this.bezierPath2D)e.stroke(t)}commit(){this.#Na||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#Na=!0,this.div.classList.add("disabled"),this.#Ga(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){0===t.button&&this.isInEditMode()&&!this.#Na&&(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),this.#Ja(t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),this.#Za(t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),this.#ar(t)}canvasPointerleave(t){this.#ar(t)}#ar(t){this.canvas.removeEventListener("pointerleave",this.#Ra),this.canvas.removeEventListener("pointermove",this.#Pa),this.canvas.removeEventListener("pointerup",this.#La),this.canvas.addEventListener("pointerdown",this.#Ia,{signal:this._uiManager._signal}),this.#Da&&clearTimeout(this.#Da),this.#Da=setTimeout(()=>{this.#Da=null,this.canvas.removeEventListener("contextmenu",ct)},10),this.#sr(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#Ua(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#Wa(){this.#Ha=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}),this.#Ha.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#Ha?.disconnect(),this.#Ha=null},{once:!0})}get isResizable(){return!this.isEmpty()&&this.#Na}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[s,i,n,a]=this.#Ka();if(this.setAt(s,i,0,0),this.setDims(n,a),this.#Ua(),this.width){const[s,i]=this.parentDimensions;this.setAspectRatio(this.width*s,this.height*i),this.setAt(t*s,e*i,this.width*s,this.height*i),this.#Ba=!0,this.#Xa(),this.setDims(this.width*s,this.height*i),this.#qa(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#Wa(),this.div}#Xa(){if(!this.#Ba)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#nr()}setDimensions(t,e){const s=Math.round(t),i=Math.round(e);if(this.#za===s&&this.#ja===i)return;this.#za=s,this.#ja=i,this.canvas.style.visibility="hidden";const[n,a]=this.parentDimensions;this.width=t/n,this.height=e/a,this.fixAndSetPosition(),this.#Na&&this.#rr(t,e),this.#Xa(),this.#qa(),this.canvas.style.visibility="visible",this.fixDims()}#rr(t,e){const s=this.#or(),i=(t-s)/this.#Ta,n=(e-s)/this.#Ma;this.scaleFactor=Math.min(i,n)}#nr(){const t=this.#or()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#hr(t){const e=new Path2D;for(let s=0,i=t.length;s<i;s++){const[i,n,a,r]=t[s];0===s&&e.moveTo(...i),e.bezierCurveTo(n[0],n[1],a[0],a[1],r[0],r[1])}return e}static#lr(t,e,s){const[i,n,a,r]=e;switch(s){case 0:for(let e=0,s=t.length;e<s;e+=2)t[e]+=i,t[e+1]=r-t[e+1];break;case 90:for(let e=0,s=t.length;e<s;e+=2){const s=t[e];t[e]=t[e+1]+i,t[e+1]=s+n}break;case 180:for(let e=0,s=t.length;e<s;e+=2)t[e]=a-t[e],t[e+1]+=n;break;case 270:for(let e=0,s=t.length;e<s;e+=2){const s=t[e];t[e]=a-t[e+1],t[e+1]=r-s}break;default:throw new Error("Invalid rotation")}return t}static#cr(t,e,s){const[i,n,a,r]=e;switch(s){case 0:for(let e=0,s=t.length;e<s;e+=2)t[e]-=i,t[e+1]=r-t[e+1];break;case 90:for(let e=0,s=t.length;e<s;e+=2){const s=t[e];t[e]=t[e+1]-n,t[e+1]=s-i}break;case 180:for(let e=0,s=t.length;e<s;e+=2)t[e]=a-t[e],t[e+1]-=n;break;case 270:for(let e=0,s=t.length;e<s;e+=2){const s=t[e];t[e]=r-t[e+1],t[e+1]=a-s}break;default:throw new Error("Invalid rotation")}return t}#dr(t,e,s,i){const n=[],a=this.thickness/2,r=t*e+a,o=t*s+a;for(const e of this.paths){const s=[],a=[];for(let i=0,n=e.length;i<n;i++){const[h,l,c,d]=e[i];if(h[0]===d[0]&&h[1]===d[1]&&1===n){const e=t*h[0]+r,i=t*h[1]+o;s.push(e,i),a.push(e,i);break}const u=t*h[0]+r,p=t*h[1]+o,g=t*l[0]+r,f=t*l[1]+o,m=t*c[0]+r,v=t*c[1]+o,b=t*d[0]+r,A=t*d[1]+o;0===i&&(s.push(u,p),a.push(u,p)),s.push(g,f,m,v,b,A),a.push(g,f),i===n-1&&a.push(b,A)}n.push({bezier:di.#lr(s,i,this.rotation),points:di.#lr(a,i,this.rotation)})}return n}#ur(){let t=1/0,e=-1/0,s=1/0,i=-1/0;for(const n of this.paths)for(const[a,r,o,h]of n){const n=z.bezierBoundingBox(...a,...r,...o,...h);t=Math.min(t,n[0]),s=Math.min(s,n[1]),e=Math.max(e,n[2]),i=Math.max(i,n[3])}return[t,s,e,i]}#or(){return this.#Na?Math.ceil(this.thickness*this.parentScale):0}#Ga(t=!1){if(this.isEmpty())return;if(!this.#Na)return void this.#qa();const e=this.#ur(),s=this.#or();this.#Ta=Math.max(Tt.MIN_SIZE,e[2]-e[0]),this.#Ma=Math.max(Tt.MIN_SIZE,e[3]-e[1]);const i=Math.ceil(s+this.#Ta*this.scaleFactor),n=Math.ceil(s+this.#Ma*this.scaleFactor),[a,r]=this.parentDimensions;this.width=i/a,this.height=n/r,this.setAspectRatio(i,n);const o=this.translationX,h=this.translationY;this.translationX=-e[0],this.translationY=-e[1],this.#Xa(),this.#qa(),this.#za=i,this.#ja=n,this.setDims(i,n);const l=t?s/this.scaleFactor/2:0;this.translate(o-this.translationX-l,h-this.translationY-l)}static deserialize(t,e,s){if(t instanceof Xs)return null;const i=super.deserialize(t,e,s);i.thickness=t.thickness,i.color=z.makeHexColor(...t.color),i.opacity=t.opacity;const[n,a]=i.pageDimensions,r=i.width*n,o=i.height*a,h=i.parentScale,l=t.thickness/2;i.#Na=!0,i.#za=Math.round(r),i.#ja=Math.round(o);const{paths:c,rect:d,rotation:u}=t;for(let{bezier:t}of c){t=di.#cr(t,d,u);const e=[];i.paths.push(e);let s=h*(t[0]-l),n=h*(t[1]-l);for(let i=2,a=t.length;i<a;i+=6){const a=h*(t[i]-l),r=h*(t[i+1]-l),o=h*(t[i+2]-l),c=h*(t[i+3]-l),d=h*(t[i+4]-l),u=h*(t[i+5]-l);e.push([[s,n],[a,r],[o,c],[d,u]]),s=d,n=u}const a=this.#hr(e);i.bezierPath2D.push(a)}const p=i.#ur();return i.#Ta=Math.max(Tt.MIN_SIZE,p[2]-p[0]),i.#Ma=Math.max(Tt.MIN_SIZE,p[3]-p[1]),i.#rr(r,o),i}serialize(){if(this.isEmpty())return null;const t=this.getRect(0,0),e=Tt._colorManager.convert(this.ctx.strokeStyle);return{annotationType:d.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:this.#dr(this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class ui extends Tt{#pr=null;#gr=null;#fr=null;#mr=null;#vr=null;#br="";#Ar=null;#Ha=null;#yr=null;#_r=!1;#wr=!1;static _type="stamp";static _editorType=d.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#mr=t.bitmapUrl,this.#vr=t.bitmapFile}static initialize(t,e){Tt.initialize(t,e)}static get supportedTypes(){return C(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return C(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(d.STAMP,{bitmapFile:t.getAsFile()})}#xr(t,e=!1){t?(this.#pr=t.bitmap,e||(this.#gr=t.id,this.#_r=t.isSvg),t.file&&(this.#br=t.file.name),this.#Ua()):this.remove()}#Er(){this.#fr=null,this._uiManager.enableWaiting(!1),this.#Ar&&this.div.focus()}#Sr(){if(this.#gr)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#gr).then(t=>this.#xr(t,!0)).finally(()=>this.#Er());if(this.#mr){const t=this.#mr;return this.#mr=null,this._uiManager.enableWaiting(!0),void(this.#fr=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#xr(t)).finally(()=>this.#Er()))}if(this.#vr){const t=this.#vr;return this.#vr=null,this._uiManager.enableWaiting(!0),void(this.#fr=this._uiManager.imageManager.getFromFile(t).then(t=>this.#xr(t)).finally(()=>this.#Er()))}const t=document.createElement("input");t.type="file",t.accept=ui.supportedTypesStr;const e=this._uiManager._signal;this.#fr=new Promise(s=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this.#xr(e)}else this.remove();s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#Er()),t.click()}remove(){this.#gr&&(this.#pr=null,this._uiManager.imageManager.deleteId(this.#gr),this.#Ar?.remove(),this.#Ar=null,this.#Ha?.disconnect(),this.#Ha=null,this.#yr&&(clearTimeout(this.#yr),this.#yr=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#gr&&null===this.#Ar&&this.#Sr(),this.isAttachedToDOM||this.parent.add(this))):this.#gr&&this.#Sr()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#fr||this.#pr||this.#mr||this.#vr||this.#gr)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#pr?this.#Ua():this.#Sr(),this.width){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i)}return this.div}#Ua(){const{div:t}=this;let{width:e,height:s}=this.#pr;const[i,n]=this.pageDimensions,a=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>a*i||s>a*n){const t=Math.min(a*i/e,a*n/s);e*=t,s*=t}const[r,o]=this.parentDimensions;this.setDims(e*r/i,s*o/n),this._uiManager.enableWaiting(!1);const h=this.#Ar=document.createElement("canvas");t.append(h),t.hidden=!1,this.#Cr(e,s),this.#Wa(),this.#wr||(this.parent.addUndoableEditor(this),this.#wr=!0),this._reportTelemetry({action:"inserted_image"}),this.#br&&h.setAttribute("aria-label",this.#br)}#kr(t,e){const[s,i]=this.parentDimensions;this.width=t/s,this.height=e/i,this.setDims(t,e),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==this.#yr&&clearTimeout(this.#yr),this.#yr=setTimeout(()=>{this.#yr=null,this.#Cr(t,e)},200)}#Mr(t,e){const{width:s,height:i}=this.#pr;let n=s,a=i,r=this.#pr;for(;n>2*t||a>2*e;){const s=n,i=a;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(n,a);o.getContext("2d").drawImage(r,0,0,s,i,0,0,n,a),r=o.transferToImageBitmap()}return r}#Cr(t,e){t=Math.ceil(t),e=Math.ceil(e);const s=this.#Ar;if(!s||s.width===t&&s.height===e)return;s.width=t,s.height=e;const i=this.#_r?this.#pr:this.#Mr(t,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){const s=new OffscreenCanvas(t,e).getContext("2d");s.drawImage(i,0,0,i.width,i.height,0,0,t,e),this._uiManager.mlGuess({service:"image-to-text",request:{data:s.getImageData(0,0,t,e).data,width:t,height:e,channels:4}}).then(t=>{const e=t?.output||"";this.parent&&e&&!this.hasAltText()&&(this.altTextData={altText:e,decorative:!1})})}const n=s.getContext("2d");n.filter=this._uiManager.hcmFilter,n.drawImage(i,0,0,i.width,i.height,0,0,t,e)}getImageForAltText(){return this.#Ar}#Tr(t){if(t){if(this.#_r){const t=this._uiManager.imageManager.getSvgUrl(this.#gr);if(t)return t}const t=document.createElement("canvas");return({width:t.width,height:t.height}=this.#pr),t.getContext("2d").drawImage(this.#pr,0,0),t.toDataURL()}if(this.#_r){const[t,e]=this.pageDimensions,s=Math.round(this.width*t*J.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*J.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(s,i);return n.getContext("2d").drawImage(this.#pr,0,0,this.#pr.width,this.#pr.height,0,0,s,i),n.transferToImageBitmap()}return structuredClone(this.#pr)}#Wa(){this._uiManager._signal&&(this.#Ha=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.#kr(e.width,e.height)}),this.#Ha.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#Ha?.disconnect(),this.#Ha=null},{once:!0}))}static deserialize(t,e,s){if(t instanceof Zs)return null;const i=super.deserialize(t,e,s),{rect:n,bitmapUrl:a,bitmapId:r,isSvg:o,accessibilityData:h}=t;r&&s.imageManager.isValidId(r)?i.#gr=r:i.#mr=a,i.#_r=o;const[l,c]=i.pageDimensions;return i.width=(n[2]-n[0])/l,i.height=(n[3]-n[1])/c,h&&(i.altTextData=h),i}serialize(t=!1,e=null){if(this.isEmpty())return null;const s={annotationType:d.STAMP,bitmapId:this.#gr,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#_r,structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=this.#Tr(!0),s.accessibilityData=this.altTextData,s;const{decorative:i,altText:n}=this.altTextData;if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),null===e)return s;e.stamps||=new Map;const a=this.#_r?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(e.stamps.has(this.#gr)){if(this.#_r){const t=e.stamps.get(this.#gr);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Tr(!1))}}else e.stamps.set(this.#gr,{area:a,serialized:s}),s.bitmap=this.#Tr(!1);return s}}class pi{#$i;#Pr=!1;#Rr=null;#Lr=null;#Ir=null;#Dr=null;#Fr=null;#Nr=new Map;#Or=!1;#Br=!1;#Hr=!1;#zr=null;#p;static _initialized=!1;static#O=new Map([ii,di,ui,ci].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,accessibilityManager:i,annotationLayer:n,drawLayer:a,textLayer:r,viewport:o,l10n:h}){const l=[...pi.#O.values()];if(!pi._initialized){pi._initialized=!0;for(const e of l)e.initialize(h,t)}t.registerEditorTypes(l),this.#p=t,this.pageIndex=e,this.div=s,this.#$i=i,this.#Rr=n,this.viewport=o,this.#zr=r,this.drawLayer=a,this.#p.addLayer(this)}get isEmpty(){return 0===this.#Nr.size}get isInvisible(){return this.isEmpty&&this.#p.getMode()===d.NONE}updateToolbar(t){this.#p.updateToolbar(t)}updateMode(t=this.#p.getMode()){switch(this.#jr(),t){case d.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case d.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case d.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of pi.#O.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#zr?.div}addInkEditorIfNeeded(t){if(this.#p.getMode()===d.INK){if(!t)for(const t of this.#Nr.values())if(t.isEmpty())return void t.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(t){this.#p.setEditingState(t)}addCommands(t){this.#p.addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Rr?.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#Nr.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#p.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#Rr)return;const e=this.#Rr.getEditableAnnotations();for(const s of e){if(s.hide(),this.#p.isDeletedAnnotationElement(s.data.id))continue;if(t.has(s.data.id))continue;const e=this.deserialize(s);e&&(this.addOrRebuild(e),e.enableEditing())}}disable(){this.#Hr=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const s of this.#Nr.values())s.disableEditing(),s.annotationElementId&&(null===s.serialize()?(e.set(s.annotationElementId,s),this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()):t.set(s.annotationElementId,s));if(this.#Rr){const s=this.#Rr.getEditableAnnotations();for(const i of s){const{id:s}=i.data;if(this.#p.isDeletedAnnotationElement(s))continue;let n=e.get(s);n?(n.resetAnnotationElement(i),n.show(!1),i.show()):(n=t.get(s),n&&(this.#p.addChangedExistingAnnotation(n),n.renderAnnotationElement(i),n.show(!1)),i.show())}}this.#jr(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const t of pi.#O.values())s.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#Hr=!1}getEditableAnnotation(t){return this.#Rr?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#p.getActive()!==t&&this.#p.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1,this.#zr?.div&&!this.#Dr&&(this.#Dr=this.#$r.bind(this),this.#zr.div.addEventListener("pointerdown",this.#Dr,{signal:this.#p._signal}),this.#zr.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#zr?.div&&this.#Dr&&(this.#zr.div.removeEventListener("pointerdown",this.#Dr),this.#Dr=null,this.#zr.div.classList.remove("highlighting"))}#$r(t){if(this.#p.unselectAll(),t.target===this.#zr.div){const{isMac:e}=B.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#p.showAllEditors("highlight",!0,!0),this.#zr.div.classList.add("free"),ci.startHighlighting(this,"ltr"===this.#p.direction,t),this.#zr.div.addEventListener("pointerup",()=>{this.#zr.div.classList.remove("free")},{once:!0,signal:this.#p._signal}),t.preventDefault()}}enableClick(){if(this.#Ir)return;const t=this.#p._signal;this.#Ir=this.pointerdown.bind(this),this.#Lr=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#Ir,{signal:t}),this.div.addEventListener("pointerup",this.#Lr,{signal:t})}disableClick(){this.#Ir&&(this.div.removeEventListener("pointerdown",this.#Ir),this.div.removeEventListener("pointerup",this.#Lr),this.#Ir=null,this.#Lr=null)}attach(t){this.#Nr.set(t.id,t);const{annotationElementId:e}=t;e&&this.#p.isDeletedAnnotationElement(e)&&this.#p.removeDeletedAnnotationElement(t)}detach(t){this.#Nr.delete(t.id),this.#$i?.removePointerInTextLayer(t.contentDiv),!this.#Hr&&t.annotationElementId&&this.#p.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#p.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#Br||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#p.addDeletedAnnotationElement(t.annotationElementId),Tt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#p.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#p.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Fr&&(t._focusEventsAllowed=!1,this.#Fr=setTimeout(()=>{this.#Fr=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#p._signal}),e.focus())},0)),t._structTreeParentId=this.#$i?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#p.getId()}get#Vr(){return pi.#O.get(this.#p.getMode())}get _signal(){return this.#p._signal}#Gr(t){const e=this.#Vr;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Vr?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#p.updateToolbar(t),this.#p.updateMode(t);const{offsetX:s,offsetY:i}=this.#qr(),n=this.getNextId(),a=this.#Gr({parent:this,id:n,x:s,y:i,uiManager:this.#p,isCentered:!0,...e});a&&this.add(a)}deserialize(t){return pi.#O.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#p)||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=this.#Gr({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#p,isCentered:e,...s});return n&&this.add(n),n}#qr(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),r=(n+Math.min(window.innerWidth,t+s))/2-t,o=(a+Math.min(window.innerHeight,e+i))/2-e,[h,l]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:h,offsetY:l}}addNewEditor(){this.createAndAddNewEditor(this.#qr(),!0)}setSelected(t){this.#p.setSelected(t)}toggleSelected(t){this.#p.toggleSelected(t)}isSelected(t){return this.#p.isSelected(t)}unselect(t){this.#p.unselect(t)}pointerup(t){const{isMac:e}=B.platform;0!==t.button||t.ctrlKey&&e||t.target!==this.div||!this.#Or||(this.#Or=!1,this.#Pr?this.#p.getMode()!==d.STAMP?this.createAndAddNewEditor(t,!1):this.#p.unselectAll():this.#Pr=!0)}pointerdown(t){if(this.#p.getMode()===d.HIGHLIGHT&&this.enableTextSelection(),this.#Or)return void(this.#Or=!1);const{isMac:e}=B.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;this.#Or=!0;const s=this.#p.getActive();this.#Pr=!s||s.isEmpty()}findNewParent(t,e,s){const i=this.#p.findParent(e,s);return null!==i&&i!==this&&(i.changeParent(t),!0)}destroy(){this.#p.getActive()?.parent===this&&(this.#p.commitOrRemove(),this.#p.setActiveEditor(null)),this.#Fr&&(clearTimeout(this.#Fr),this.#Fr=null);for(const t of this.#Nr.values())this.#$i?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Nr.clear(),this.#p.removeLayer(this)}#jr(){this.#Br=!0;for(const t of this.#Nr.values())t.isEmpty()&&t.remove();this.#Br=!1}render({viewport:t}){this.viewport=t,bt(this.div,t);for(const t of this.#p.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#p.commitOrRemove(),this.#jr();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,bt(this.div,{rotation:s}),e!==s)for(const t of this.#Nr.values())t.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#p.viewParameters.realScale}}class gi{#wi=null;#v=0;#Ur=new Map;#Wr=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#wi){if(this.#wi!==t){if(this.#Ur.size>0)for(const e of this.#Ur.values())e.remove(),t.append(e);this.#wi=t}}else this.#wi=t}static get _svgFactory(){return C(this,"_svgFactory",new et)}static#Xr(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:a}=t;a.top=100*s+"%",a.left=100*e+"%",a.width=100*i+"%",a.height=100*n+"%"}#Kr(t){const e=gi._svgFactory.create(1,1,!0);return this.#wi.append(e),e.setAttribute("aria-hidden",!0),gi.#Xr(e,t),e}#Yr(t,e){const s=gi._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=gi._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}highlight(t,e,s,i=!1){const n=this.#v++,a=this.#Kr(t.box);a.classList.add("highlight"),t.free&&a.classList.add("free");const r=gi._svgFactory.createElement("defs");a.append(r);const o=gi._svgFactory.createElement("path");r.append(o);const h=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",h),o.setAttribute("d",t.toSVGPath()),i&&this.#Wr.set(n,o);const l=this.#Yr(r,h),c=gi._svgFactory.createElement("use");return a.append(c),a.setAttribute("fill",e),a.setAttribute("fill-opacity",s),c.setAttribute("href",`#${h}`),this.#Ur.set(n,a),{id:n,clipPathId:`url(#${l})`}}highlightOutline(t){const e=this.#v++,s=this.#Kr(t.box);s.classList.add("highlightOutline");const i=gi._svgFactory.createElement("defs");s.append(i);const n=gi._svgFactory.createElement("path");i.append(n);const a=`path_p${this.pageIndex}_${e}`;let r;if(n.setAttribute("id",a),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke"),t.free){s.classList.add("free");const t=gi._svgFactory.createElement("mask");i.append(t),r=`mask_p${this.pageIndex}_${e}`,t.setAttribute("id",r),t.setAttribute("maskUnits","objectBoundingBox");const n=gi._svgFactory.createElement("rect");t.append(n),n.setAttribute("width","1"),n.setAttribute("height","1"),n.setAttribute("fill","white");const o=gi._svgFactory.createElement("use");t.append(o),o.setAttribute("href",`#${a}`),o.setAttribute("stroke","none"),o.setAttribute("fill","black"),o.setAttribute("fill-rule","nonzero"),o.classList.add("mask")}const o=gi._svgFactory.createElement("use");s.append(o),o.setAttribute("href",`#${a}`),r&&o.setAttribute("mask",`url(#${r})`);const h=o.cloneNode();return s.append(h),o.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.#Ur.set(e,s),e}finalizeLine(t,e){const s=this.#Wr.get(t);this.#Wr.delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#Ur.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),this.#Wr.delete(t)}updatePath(t,e){this.#Wr.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){gi.#Xr(this.#Ur.get(t),e)}show(t,e){this.#Ur.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#Ur.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#Ur.get(t).setAttribute("fill",e)}changeOpacity(t,e){this.#Ur.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#Ur.get(t).classList.add(e)}removeClass(t,e){this.#Ur.get(t).classList.remove(e)}remove(t){null!==this.#wi&&(this.#Ur.get(t).remove(),this.#Ur.delete(t))}destroy(){this.#wi=null;for(const t of this.#Ur.values())t.remove();this.#Ur.clear()}}var fi=a.GlobalWorkerOptions,mi=a.getDocument;{const t=document.currentScript,e=t?.src||document.querySelectorAll('script[src*="pdf-viewer"]')[0]?.src||"";e&&(fi.workerSrc=e.replace(/[^/]+$/,"pdf.worker.min.mjs"))}let vi=(()=>{let t,n,a,r,o,h,l,c,d,u,p,g,f,m,v,b,A,y,_,w,x,E,S,C,k,M,T,P,R,L,I,D,F,N,O,B=[e.element("snice-pdf-viewer")],H=[],z=HTMLElement,j=[],$=[],V=[],G=[],q=[],U=[],W=[],X=[],K=[],Y=[],J=[],Q=[],Z=[],tt=[],et=[],st=[],it=[],nt=[],at=[],rt=[],ot=[],ht=[],lt=[],ct=[],dt=[],ut=[],pt=[],gt=[],ft=[],mt=[],vt=[],bt=[],At=[],yt=[],_t=[],wt=[],xt=[],Et=[],St=[],Ct=[],kt=[],Mt=[],Tt=[];return class extends z{static{n=this}static{const Pt="function"==typeof Symbol&&Symbol.metadata?Object.create(z[Symbol.metadata]??null):void 0;a=[e.property()],r=[e.property({type:Number})],o=[e.property({type:Number})],h=[e.property()],l=[e.query(".pdf-viewport")],c=[e.query(".pdf-canvas-wrapper canvas")],d=[e.query(".pdf-loading")],u=[e.query(".pdf-error")],p=[e.query(".pdf-error-msg")],g=[e.query(".pdf-empty")],f=[e.query(".pdf-canvas-wrapper")],m=[e.query(".pdf-page-input")],v=[e.query(".pdf-page-total")],b=[e.query(".pdf-zoom-info")],A=[e.query(".pdf-btn-prev")],y=[e.query(".pdf-btn-next")],_=[e.query(".pdf-btn-zoom-out")],w=[e.query(".pdf-btn-zoom-in")],x=[e.query(".pdf-btn-download")],E=[e.query(".pdf-btn-print")],S=[e.query(".pdf-fit-select")],C=[e.styles()],k=[e.ready()],M=[e.dispose()],T=[e.watch("src")],P=[e.watch("page")],R=[e.watch("zoom")],L=[e.watch("fit")],I=[e.on("keydown")],D=[e.dispatch("page-change",{bubbles:!0,composed:!0})],F=[e.dispatch("pdf-loaded",{bubbles:!0,composed:!0})],N=[e.dispatch("pdf-error",{bubbles:!0,composed:!0})],O=[e.render({once:!0})],s(this,null,C,{kind:"method",name:"componentStyles",static:!1,private:!1,access:{has:t=>"componentStyles"in t,get:t=>t.componentStyles},metadata:Pt},null,j),s(this,null,k,{kind:"method",name:"init",static:!1,private:!1,access:{has:t=>"init"in t,get:t=>t.init},metadata:Pt},null,j),s(this,null,M,{kind:"method",name:"cleanup",static:!1,private:!1,access:{has:t=>"cleanup"in t,get:t=>t.cleanup},metadata:Pt},null,j),s(this,null,T,{kind:"method",name:"handleSrcChange",static:!1,private:!1,access:{has:t=>"handleSrcChange"in t,get:t=>t.handleSrcChange},metadata:Pt},null,j),s(this,null,P,{kind:"method",name:"handlePageChange",static:!1,private:!1,access:{has:t=>"handlePageChange"in t,get:t=>t.handlePageChange},metadata:Pt},null,j),s(this,null,R,{kind:"method",name:"handleZoomChange",static:!1,private:!1,access:{has:t=>"handleZoomChange"in t,get:t=>t.handleZoomChange},metadata:Pt},null,j),s(this,null,L,{kind:"method",name:"handleFitChange",static:!1,private:!1,access:{has:t=>"handleFitChange"in t,get:t=>t.handleFitChange},metadata:Pt},null,j),s(this,null,I,{kind:"method",name:"handleKeydown",static:!1,private:!1,access:{has:t=>"handleKeydown"in t,get:t=>t.handleKeydown},metadata:Pt},null,j),s(this,null,D,{kind:"method",name:"emitPageChange",static:!1,private:!1,access:{has:t=>"emitPageChange"in t,get:t=>t.emitPageChange},metadata:Pt},null,j),s(this,null,F,{kind:"method",name:"emitLoaded",static:!1,private:!1,access:{has:t=>"emitLoaded"in t,get:t=>t.emitLoaded},metadata:Pt},null,j),s(this,null,N,{kind:"method",name:"emitError",static:!1,private:!1,access:{has:t=>"emitError"in t,get:t=>t.emitError},metadata:Pt},null,j),s(this,null,O,{kind:"method",name:"renderViewer",static:!1,private:!1,access:{has:t=>"renderViewer"in t,get:t=>t.renderViewer},metadata:Pt},null,j),s(null,null,a,{kind:"field",name:"src",static:!1,private:!1,access:{has:t=>"src"in t,get:t=>t.src,set:(t,e)=>{t.src=e}},metadata:Pt},$,V),s(null,null,r,{kind:"field",name:"page",static:!1,private:!1,access:{has:t=>"page"in t,get:t=>t.page,set:(t,e)=>{t.page=e}},metadata:Pt},G,q),s(null,null,o,{kind:"field",name:"zoom",static:!1,private:!1,access:{has:t=>"zoom"in t,get:t=>t.zoom,set:(t,e)=>{t.zoom=e}},metadata:Pt},U,W),s(null,null,h,{kind:"field",name:"fit",static:!1,private:!1,access:{has:t=>"fit"in t,get:t=>t.fit,set:(t,e)=>{t.fit=e}},metadata:Pt},X,K),s(null,null,l,{kind:"field",name:"viewportEl",static:!1,private:!1,access:{has:t=>"viewportEl"in t,get:t=>t.viewportEl,set:(t,e)=>{t.viewportEl=e}},metadata:Pt},Y,J),s(null,null,c,{kind:"field",name:"canvas",static:!1,private:!1,access:{has:t=>"canvas"in t,get:t=>t.canvas,set:(t,e)=>{t.canvas=e}},metadata:Pt},Q,Z),s(null,null,d,{kind:"field",name:"loadingEl",static:!1,private:!1,access:{has:t=>"loadingEl"in t,get:t=>t.loadingEl,set:(t,e)=>{t.loadingEl=e}},metadata:Pt},tt,et),s(null,null,u,{kind:"field",name:"errorEl",static:!1,private:!1,access:{has:t=>"errorEl"in t,get:t=>t.errorEl,set:(t,e)=>{t.errorEl=e}},metadata:Pt},st,it),s(null,null,p,{kind:"field",name:"errorMsgEl",static:!1,private:!1,access:{has:t=>"errorMsgEl"in t,get:t=>t.errorMsgEl,set:(t,e)=>{t.errorMsgEl=e}},metadata:Pt},nt,at),s(null,null,g,{kind:"field",name:"emptyEl",static:!1,private:!1,access:{has:t=>"emptyEl"in t,get:t=>t.emptyEl,set:(t,e)=>{t.emptyEl=e}},metadata:Pt},rt,ot),s(null,null,f,{kind:"field",name:"canvasWrapperEl",static:!1,private:!1,access:{has:t=>"canvasWrapperEl"in t,get:t=>t.canvasWrapperEl,set:(t,e)=>{t.canvasWrapperEl=e}},metadata:Pt},ht,lt),s(null,null,m,{kind:"field",name:"pageInputEl",static:!1,private:!1,access:{has:t=>"pageInputEl"in t,get:t=>t.pageInputEl,set:(t,e)=>{t.pageInputEl=e}},metadata:Pt},ct,dt),s(null,null,v,{kind:"field",name:"pageTotalEl",static:!1,private:!1,access:{has:t=>"pageTotalEl"in t,get:t=>t.pageTotalEl,set:(t,e)=>{t.pageTotalEl=e}},metadata:Pt},ut,pt),s(null,null,b,{kind:"field",name:"zoomInfoEl",static:!1,private:!1,access:{has:t=>"zoomInfoEl"in t,get:t=>t.zoomInfoEl,set:(t,e)=>{t.zoomInfoEl=e}},metadata:Pt},gt,ft),s(null,null,A,{kind:"field",name:"btnPrev",static:!1,private:!1,access:{has:t=>"btnPrev"in t,get:t=>t.btnPrev,set:(t,e)=>{t.btnPrev=e}},metadata:Pt},mt,vt),s(null,null,y,{kind:"field",name:"btnNext",static:!1,private:!1,access:{has:t=>"btnNext"in t,get:t=>t.btnNext,set:(t,e)=>{t.btnNext=e}},metadata:Pt},bt,At),s(null,null,_,{kind:"field",name:"btnZoomOut",static:!1,private:!1,access:{has:t=>"btnZoomOut"in t,get:t=>t.btnZoomOut,set:(t,e)=>{t.btnZoomOut=e}},metadata:Pt},yt,_t),s(null,null,w,{kind:"field",name:"btnZoomIn",static:!1,private:!1,access:{has:t=>"btnZoomIn"in t,get:t=>t.btnZoomIn,set:(t,e)=>{t.btnZoomIn=e}},metadata:Pt},wt,xt),s(null,null,x,{kind:"field",name:"btnDownload",static:!1,private:!1,access:{has:t=>"btnDownload"in t,get:t=>t.btnDownload,set:(t,e)=>{t.btnDownload=e}},metadata:Pt},Et,St),s(null,null,E,{kind:"field",name:"btnPrint",static:!1,private:!1,access:{has:t=>"btnPrint"in t,get:t=>t.btnPrint,set:(t,e)=>{t.btnPrint=e}},metadata:Pt},Ct,kt),s(null,null,S,{kind:"field",name:"fitSelectEl",static:!1,private:!1,access:{has:t=>"fitSelectEl"in t,get:t=>t.fitSelectEl,set:(t,e)=>{t.fitSelectEl=e}},metadata:Pt},Mt,Tt),s(null,t={value:n},B,{kind:"class",name:n.name,metadata:Pt},null,H),n=t.value,Pt&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:Pt}),i(n,H)}componentStyles(){return e.css`${":host{display:block;font-family:var(--snice-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);contain:layout style paint;width:100%}.pdf-container{display:flex;flex-direction:column;background:var(--snice-color-background,rgb(255 255 255));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-lg,.5rem);overflow:hidden}.pdf-toolbar{display:flex;align-items:center;gap:var(--snice-spacing-xs,.5rem);padding:var(--snice-spacing-xs,.5rem) var(--snice-spacing-sm,.75rem);background:var(--snice-color-background-element,rgb(252 251 249));border-bottom:1px solid var(--snice-color-border,rgb(226 226 226));flex-wrap:wrap}.pdf-toolbar-group{display:flex;align-items:center;gap:var(--snice-spacing-2xs,.25rem)}.pdf-toolbar-separator{width:1px;height:1.5rem;background:var(--snice-color-border,rgb(226 226 226));margin:0 var(--snice-spacing-2xs,.25rem)}.pdf-toolbar-spacer{flex:1}.pdf-btn{background:0 0;border:1px solid transparent;cursor:pointer;padding:var(--snice-spacing-2xs,.25rem) var(--snice-spacing-xs,.5rem);border-radius:var(--snice-border-radius-md,.25rem);color:var(--snice-color-text,rgb(23 23 23));display:inline-flex;align-items:center;justify-content:center;transition:background-color var(--snice-transition-fast, 150ms) ease;font-size:var(--snice-font-size-sm, .875rem);line-height:1}.pdf-btn:hover:not(:disabled){background:var(--snice-color-background-hover,rgb(241 241 241))}.pdf-btn:active:not(:disabled){background:var(--snice-color-background-active,rgb(226 226 226))}.pdf-btn:disabled{opacity:.4;cursor:not-allowed}.pdf-btn:focus-visible{outline:var(--snice-focus-ring-width,2px) solid var(--snice-focus-ring-color,rgb(59 130 246 / .5));outline-offset:var(--snice-focus-ring-offset,2px)}.pdf-btn svg{width:1.125rem;height:1.125rem}.pdf-page-input{width:3rem;text-align:center;padding:var(--snice-spacing-3xs,.125rem) var(--snice-spacing-2xs,.25rem);border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);font-size:var(--snice-font-size-sm, .875rem);font-family:inherit;background:var(--snice-color-background,rgb(255 255 255));color:var(--snice-color-text,rgb(23 23 23))}.pdf-page-input:focus{outline:var(--snice-focus-ring-width,2px) solid var(--snice-focus-ring-color,rgb(59 130 246 / .5));outline-offset:var(--snice-focus-ring-offset,2px)}.pdf-page-info{font-size:var(--snice-font-size-sm, .875rem);color:var(--snice-color-text-secondary,rgb(82 82 82));font-variant-numeric:tabular-nums;white-space:nowrap}.pdf-zoom-info{font-size:var(--snice-font-size-sm, .875rem);color:var(--snice-color-text-secondary,rgb(82 82 82));min-width:3rem;text-align:center}.pdf-fit-select{padding:var(--snice-spacing-3xs,.125rem) var(--snice-spacing-xs,.5rem);border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);font-size:var(--snice-font-size-sm, .875rem);font-family:inherit;background:var(--snice-color-background,rgb(255 255 255));color:var(--snice-color-text,rgb(23 23 23));cursor:pointer}.pdf-viewport{flex:1;overflow:auto;display:flex;justify-content:center;align-items:flex-start;padding:var(--snice-spacing-md,1rem);background:rgb(82 82 82);min-height:30rem}.pdf-canvas-wrapper{box-shadow:var(--snice-shadow-lg,0 10px 15px -3px rgb(0 0 0 / .1),0 4px 6px -4px rgb(0 0 0 / .1));background:rgb(255 255 255);line-height:0}.pdf-canvas-wrapper canvas{display:block}.pdf-canvas-wrapper,.pdf-empty,.pdf-error,.pdf-loading{display:none}.pdf-empty.is-visible,.pdf-error.is-visible,.pdf-loading.is-visible{display:flex}.pdf-canvas-wrapper.is-visible{display:block}.pdf-loading.is-visible{flex-direction:column;align-items:center;justify-content:center;gap:var(--snice-spacing-md,1rem);padding:var(--snice-spacing-xl,2rem);color:rgb(255 255 255)}.pdf-loading-spinner{width:2.5rem;height:2.5rem;border:3px solid;border-top-color:rgb(255 255 255);border-radius:50%;animation:.8s linear infinite pdf-spin}@keyframes pdf-spin{to{transform:rotate(360deg)}}.pdf-error.is-visible{flex-direction:column;align-items:center;justify-content:center;gap:var(--snice-spacing-md,1rem);padding:var(--snice-spacing-xl,2rem);color:rgb(255 255 255);text-align:center}.pdf-error-icon svg{width:3rem;height:3rem;color:var(--snice-color-danger,rgb(220 38 38))}.pdf-empty.is-visible{flex-direction:column;align-items:center;justify-content:center;gap:var(--snice-spacing-md,1rem);padding:var(--snice-spacing-xl,2rem);color:rgb(200 200 200)}.pdf-empty svg{width:4rem;height:4rem;opacity:.5}"}`}init(){this.attachListeners(),this.updateView(),this.src&&this.loadDocument()}cleanup(){this.pdfDoc&&(this.pdfDoc.destroy(),this.pdfDoc=null)}handleSrcChange(){this.loadDocument()}handlePageChange(){this.updateToolbar(),this.pdfDoc&&this.page>=1&&this.page<=this.totalPages&&this.renderPage()}handleZoomChange(){this.updateToolbar(),this.pdfDoc&&this.renderPage()}handleFitChange(){this.fitSelectEl&&(this.fitSelectEl.value=this.fit),this.pdfDoc&&this.renderPage()}async loadDocument(){if(this.src){this.loading=!0,this.error="",this.pdfDoc=null,this.totalPages=0,this.updateView();try{const t=mi(this.src);this.pdfDoc=await t.promise,this.totalPages=this.pdfDoc.numPages,this.loading=!1,this.page>this.totalPages&&(this.page=1),this.updateView(),this.emitLoaded(),this.renderPage()}catch(t){this.loading=!1,this.error=t?.message||"Failed to load PDF",this.updateView(),this.emitError(this.error)}}}async renderPage(){if(this.pdfDoc&&!this.rendering&&!(this.page<1||this.page>this.totalPages)){this.rendering=!0;try{const t=await this.pdfDoc.getPage(this.page),e=t.getViewport({scale:1});let s=this.zoom;if(this.viewportEl&&"page"!==this.fit){const t=this.viewportEl.clientWidth-32,i=this.viewportEl.clientHeight-32;"width"===this.fit?s=t/e.width*this.zoom:"height"===this.fit&&(s=i/e.height*this.zoom)}else if(this.viewportEl&&"page"===this.fit){const t=this.viewportEl.clientWidth-32,i=this.viewportEl.clientHeight-32;s=Math.min(t/e.width,i/e.height)*this.zoom}const i=t.getViewport({scale:s});if(!this.canvas)return void(this.rendering=!1);const n=this.canvas.getContext("2d");if(!n)return void(this.rendering=!1);this.canvas.width=i.width,this.canvas.height=i.height,await t.render({canvasContext:n,viewport:i}).promise,this.rendering=!1}catch{this.rendering=!1}}}goToPage(t){t>=1&&t<=this.totalPages&&(this.page=t,this.emitPageChange())}nextPage(){this.page<this.totalPages&&this.goToPage(this.page+1)}prevPage(){this.page>1&&this.goToPage(this.page-1)}print(){if(!this.src)return;const t=window.open(this.src);t&&t.addEventListener("load",()=>t.print())}download(){if(!this.src)return;const t=document.createElement("a");t.href=this.src,t.download=this.src.split("/").pop()||"document.pdf",t.click()}zoomIn(){this.zoom=Math.min(5,Math.round(100*(this.zoom+.25))/100)}zoomOut(){this.zoom=Math.max(.25,Math.round(100*(this.zoom-.25))/100)}handleKeydown(t){switch(t.key){case"ArrowRight":case"PageDown":t.preventDefault(),this.nextPage();break;case"ArrowLeft":case"PageUp":t.preventDefault(),this.prevPage();break;case"+":case"=":(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this.zoomIn());break;case"-":(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this.zoomOut())}}updateView(){this.loadingEl?.classList.remove("is-visible"),this.errorEl?.classList.remove("is-visible"),this.emptyEl?.classList.remove("is-visible"),this.canvasWrapperEl?.classList.remove("is-visible"),this.loading?this.loadingEl?.classList.add("is-visible"):this.error?(this.errorEl?.classList.add("is-visible"),this.errorMsgEl&&(this.errorMsgEl.textContent=this.error)):this.src&&this.pdfDoc?this.canvasWrapperEl?.classList.add("is-visible"):this.emptyEl?.classList.add("is-visible"),this.updateToolbar()}updateToolbar(){this.pageInputEl&&(this.pageInputEl.value=String(this.page),this.pageInputEl.max=String(this.totalPages)),this.pageTotalEl&&(this.pageTotalEl.textContent=`/ ${this.totalPages||"-"}`),this.zoomInfoEl&&(this.zoomInfoEl.textContent=`${Math.round(100*this.zoom)}%`),this.btnPrev&&(this.btnPrev.disabled=this.page<=1),this.btnNext&&(this.btnNext.disabled=this.page>=this.totalPages),this.btnZoomOut&&(this.btnZoomOut.disabled=this.zoom<=.25),this.btnZoomIn&&(this.btnZoomIn.disabled=this.zoom>=5),this.btnDownload&&(this.btnDownload.disabled=!this.src),this.btnPrint&&(this.btnPrint.disabled=!this.src)}attachListeners(){this.listenersAttached||(this.listenersAttached=!0,this.btnPrev?.addEventListener("click",()=>this.prevPage()),this.btnNext?.addEventListener("click",()=>this.nextPage()),this.btnZoomOut?.addEventListener("click",()=>this.zoomOut()),this.btnZoomIn?.addEventListener("click",()=>this.zoomIn()),this.btnDownload?.addEventListener("click",()=>this.download()),this.btnPrint?.addEventListener("click",()=>this.print()),this.pageInputEl?.addEventListener("change",t=>{const e=parseInt(t.target.value,10);isNaN(e)||this.goToPage(e)}),this.pageInputEl?.addEventListener("keydown",t=>{if("Enter"===t.key){const e=parseInt(t.target.value,10);isNaN(e)||this.goToPage(e)}}),this.fitSelectEl?.addEventListener("change",t=>{this.fit=t.target.value}))}emitPageChange(){return{page:this.page,totalPages:this.totalPages}}emitLoaded(){return{totalPages:this.totalPages}}emitError(t){return{error:t}}renderViewer(){return e.html`
29
+ <div class="pdf-container" tabindex="0">
30
+ <div class="pdf-toolbar">
31
+ <div class="pdf-toolbar-group">
32
+ <button class="pdf-btn pdf-btn-prev" title="Previous page">
33
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
34
+ </button>
35
+ <input class="pdf-page-input" type="number" min="1" />
36
+ <span class="pdf-page-total">/ -</span>
37
+ <button class="pdf-btn pdf-btn-next" title="Next page">
38
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
39
+ </button>
40
+ </div>
41
+ <div class="pdf-toolbar-separator"></div>
42
+ <div class="pdf-toolbar-group">
43
+ <button class="pdf-btn pdf-btn-zoom-out" title="Zoom out">
44
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
45
+ </button>
46
+ <span class="pdf-zoom-info">100%</span>
47
+ <button class="pdf-btn pdf-btn-zoom-in" title="Zoom in">
48
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
49
+ </button>
50
+ </div>
51
+ <div class="pdf-toolbar-separator"></div>
52
+ <select class="pdf-fit-select">
53
+ <option value="width">Fit width</option>
54
+ <option value="height">Fit height</option>
55
+ <option value="page">Fit page</option>
56
+ </select>
57
+ <div class="pdf-toolbar-spacer"></div>
58
+ <div class="pdf-toolbar-group">
59
+ <button class="pdf-btn pdf-btn-download" title="Download">
60
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
61
+ </button>
62
+ <button class="pdf-btn pdf-btn-print" title="Print">
63
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 6 2 18 2 18 9"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>
64
+ </button>
65
+ </div>
66
+ </div>
67
+ <div class="pdf-viewport">
68
+ <div class="pdf-loading">
69
+ <div class="pdf-loading-spinner"></div>
70
+ <span>Loading PDF...</span>
71
+ </div>
72
+ <div class="pdf-error">
73
+ <div class="pdf-error-icon">
74
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
75
+ </div>
76
+ <span class="pdf-error-msg"></span>
77
+ </div>
78
+ <div class="pdf-empty">
79
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
80
+ <span>No PDF loaded</span>
81
+ </div>
82
+ <div class="pdf-canvas-wrapper">
83
+ <canvas></canvas>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ `}constructor(){super(...arguments),this.src=(i(this,j),i(this,$,"")),this.page=(i(this,V),i(this,G,1)),this.zoom=(i(this,q),i(this,U,1)),this.fit=(i(this,W),i(this,X,"width")),this.totalPages=(i(this,K),0),this.pdfDoc=null,this.loading=!1,this.error="",this.rendering=!1,this.listenersAttached=!1,this.viewportEl=i(this,Y,void 0),this.canvas=(i(this,J),i(this,Q,void 0)),this.loadingEl=(i(this,Z),i(this,tt,void 0)),this.errorEl=(i(this,et),i(this,st,void 0)),this.errorMsgEl=(i(this,it),i(this,nt,void 0)),this.emptyEl=(i(this,at),i(this,rt,void 0)),this.canvasWrapperEl=(i(this,ot),i(this,ht,void 0)),this.pageInputEl=(i(this,lt),i(this,ct,void 0)),this.pageTotalEl=(i(this,dt),i(this,ut,void 0)),this.zoomInfoEl=(i(this,pt),i(this,gt,void 0)),this.btnPrev=(i(this,ft),i(this,mt,void 0)),this.btnNext=(i(this,vt),i(this,bt,void 0)),this.btnZoomOut=(i(this,At),i(this,yt,void 0)),this.btnZoomIn=(i(this,_t),i(this,wt,void 0)),this.btnDownload=(i(this,xt),i(this,Et,void 0)),this.btnPrint=(i(this,St),i(this,Ct,void 0)),this.fitSelectEl=(i(this,kt),i(this,Mt,void 0)),i(this,Tt)}},n})();return t.SnicePdfViewer=vi,t}({},Snice);
88
+ //# sourceMappingURL=snice-pdf-viewer.min.js.map