@nocobase/plugin-file-manager 2.1.0-beta.36 → 2.1.0-beta.37

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 (468) hide show
  1. package/dist/client/764.96d72bc6fd4adb28.js +15 -0
  2. package/dist/client/876.ca16d7a6e6387862.js +11 -0
  3. package/dist/client/index.js +1 -1
  4. package/dist/client-v2/764.d5a27ea47a2d3239.js +15 -0
  5. package/dist/client-v2/876.22cd8e41ac8631ed.js +11 -0
  6. package/dist/client-v2/index.js +1 -1
  7. package/dist/externalVersion.js +9 -9
  8. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  9. package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
  10. package/dist/node_modules/ali-oss/package.json +1 -1
  11. package/dist/node_modules/cos-nodejs-sdk-v5/package.json +1 -1
  12. package/dist/node_modules/mime-match/package.json +1 -1
  13. package/dist/node_modules/mime-types/package.json +1 -1
  14. package/dist/node_modules/mkdirp/package.json +1 -1
  15. package/dist/node_modules/pdfjs-dist/LICENSE +177 -0
  16. package/dist/node_modules/pdfjs-dist/build/pdf.mjs +26514 -0
  17. package/dist/node_modules/pdfjs-dist/cmaps/78-EUC-H.bcmap +0 -0
  18. package/dist/node_modules/pdfjs-dist/cmaps/78-EUC-V.bcmap +0 -0
  19. package/dist/node_modules/pdfjs-dist/cmaps/78-H.bcmap +0 -0
  20. package/dist/node_modules/pdfjs-dist/cmaps/78-RKSJ-H.bcmap +0 -0
  21. package/dist/node_modules/pdfjs-dist/cmaps/78-RKSJ-V.bcmap +0 -0
  22. package/dist/node_modules/pdfjs-dist/cmaps/78-V.bcmap +0 -0
  23. package/dist/node_modules/pdfjs-dist/cmaps/78ms-RKSJ-H.bcmap +0 -0
  24. package/dist/node_modules/pdfjs-dist/cmaps/78ms-RKSJ-V.bcmap +0 -0
  25. package/dist/node_modules/pdfjs-dist/cmaps/83pv-RKSJ-H.bcmap +0 -0
  26. package/dist/node_modules/pdfjs-dist/cmaps/90ms-RKSJ-H.bcmap +0 -0
  27. package/dist/node_modules/pdfjs-dist/cmaps/90ms-RKSJ-V.bcmap +0 -0
  28. package/dist/node_modules/pdfjs-dist/cmaps/90msp-RKSJ-H.bcmap +0 -0
  29. package/dist/node_modules/pdfjs-dist/cmaps/90msp-RKSJ-V.bcmap +0 -0
  30. package/dist/node_modules/pdfjs-dist/cmaps/90pv-RKSJ-H.bcmap +0 -0
  31. package/dist/node_modules/pdfjs-dist/cmaps/90pv-RKSJ-V.bcmap +0 -0
  32. package/dist/node_modules/pdfjs-dist/cmaps/Add-H.bcmap +0 -0
  33. package/dist/node_modules/pdfjs-dist/cmaps/Add-RKSJ-H.bcmap +0 -0
  34. package/dist/node_modules/pdfjs-dist/cmaps/Add-RKSJ-V.bcmap +0 -0
  35. package/dist/node_modules/pdfjs-dist/cmaps/Add-V.bcmap +0 -0
  36. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-CNS1-0.bcmap +0 -0
  37. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-CNS1-1.bcmap +0 -0
  38. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-CNS1-2.bcmap +0 -0
  39. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-CNS1-3.bcmap +0 -0
  40. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-CNS1-4.bcmap +0 -0
  41. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-CNS1-5.bcmap +0 -0
  42. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-CNS1-6.bcmap +0 -0
  43. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  44. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-GB1-0.bcmap +0 -0
  45. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-GB1-1.bcmap +0 -0
  46. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-GB1-2.bcmap +0 -0
  47. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-GB1-3.bcmap +0 -0
  48. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-GB1-4.bcmap +0 -0
  49. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-GB1-5.bcmap +0 -0
  50. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  51. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Japan1-0.bcmap +0 -0
  52. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Japan1-1.bcmap +0 -0
  53. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Japan1-2.bcmap +0 -0
  54. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Japan1-3.bcmap +0 -0
  55. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Japan1-4.bcmap +0 -0
  56. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Japan1-5.bcmap +0 -0
  57. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Japan1-6.bcmap +0 -0
  58. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  59. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Korea1-0.bcmap +0 -0
  60. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Korea1-1.bcmap +0 -0
  61. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Korea1-2.bcmap +0 -0
  62. package/dist/node_modules/pdfjs-dist/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  63. package/dist/node_modules/pdfjs-dist/cmaps/B5-H.bcmap +0 -0
  64. package/dist/node_modules/pdfjs-dist/cmaps/B5-V.bcmap +0 -0
  65. package/dist/node_modules/pdfjs-dist/cmaps/B5pc-H.bcmap +0 -0
  66. package/dist/node_modules/pdfjs-dist/cmaps/B5pc-V.bcmap +0 -0
  67. package/dist/node_modules/pdfjs-dist/cmaps/CNS-EUC-H.bcmap +0 -0
  68. package/dist/node_modules/pdfjs-dist/cmaps/CNS-EUC-V.bcmap +0 -0
  69. package/dist/node_modules/pdfjs-dist/cmaps/CNS1-H.bcmap +0 -0
  70. package/dist/node_modules/pdfjs-dist/cmaps/CNS1-V.bcmap +0 -0
  71. package/dist/node_modules/pdfjs-dist/cmaps/CNS2-H.bcmap +0 -0
  72. package/dist/node_modules/pdfjs-dist/cmaps/CNS2-V.bcmap +3 -0
  73. package/dist/node_modules/pdfjs-dist/cmaps/ETHK-B5-H.bcmap +0 -0
  74. package/dist/node_modules/pdfjs-dist/cmaps/ETHK-B5-V.bcmap +0 -0
  75. package/dist/node_modules/pdfjs-dist/cmaps/ETen-B5-H.bcmap +0 -0
  76. package/dist/node_modules/pdfjs-dist/cmaps/ETen-B5-V.bcmap +0 -0
  77. package/dist/node_modules/pdfjs-dist/cmaps/ETenms-B5-H.bcmap +3 -0
  78. package/dist/node_modules/pdfjs-dist/cmaps/ETenms-B5-V.bcmap +0 -0
  79. package/dist/node_modules/pdfjs-dist/cmaps/EUC-H.bcmap +0 -0
  80. package/dist/node_modules/pdfjs-dist/cmaps/EUC-V.bcmap +0 -0
  81. package/dist/node_modules/pdfjs-dist/cmaps/Ext-H.bcmap +0 -0
  82. package/dist/node_modules/pdfjs-dist/cmaps/Ext-RKSJ-H.bcmap +0 -0
  83. package/dist/node_modules/pdfjs-dist/cmaps/Ext-RKSJ-V.bcmap +0 -0
  84. package/dist/node_modules/pdfjs-dist/cmaps/Ext-V.bcmap +0 -0
  85. package/dist/node_modules/pdfjs-dist/cmaps/GB-EUC-H.bcmap +0 -0
  86. package/dist/node_modules/pdfjs-dist/cmaps/GB-EUC-V.bcmap +0 -0
  87. package/dist/node_modules/pdfjs-dist/cmaps/GB-H.bcmap +4 -0
  88. package/dist/node_modules/pdfjs-dist/cmaps/GB-V.bcmap +0 -0
  89. package/dist/node_modules/pdfjs-dist/cmaps/GBK-EUC-H.bcmap +0 -0
  90. package/dist/node_modules/pdfjs-dist/cmaps/GBK-EUC-V.bcmap +0 -0
  91. package/dist/node_modules/pdfjs-dist/cmaps/GBK2K-H.bcmap +0 -0
  92. package/dist/node_modules/pdfjs-dist/cmaps/GBK2K-V.bcmap +0 -0
  93. package/dist/node_modules/pdfjs-dist/cmaps/GBKp-EUC-H.bcmap +0 -0
  94. package/dist/node_modules/pdfjs-dist/cmaps/GBKp-EUC-V.bcmap +0 -0
  95. package/dist/node_modules/pdfjs-dist/cmaps/GBT-EUC-H.bcmap +0 -0
  96. package/dist/node_modules/pdfjs-dist/cmaps/GBT-EUC-V.bcmap +0 -0
  97. package/dist/node_modules/pdfjs-dist/cmaps/GBT-H.bcmap +0 -0
  98. package/dist/node_modules/pdfjs-dist/cmaps/GBT-V.bcmap +0 -0
  99. package/dist/node_modules/pdfjs-dist/cmaps/GBTpc-EUC-H.bcmap +0 -0
  100. package/dist/node_modules/pdfjs-dist/cmaps/GBTpc-EUC-V.bcmap +0 -0
  101. package/dist/node_modules/pdfjs-dist/cmaps/GBpc-EUC-H.bcmap +0 -0
  102. package/dist/node_modules/pdfjs-dist/cmaps/GBpc-EUC-V.bcmap +0 -0
  103. package/dist/node_modules/pdfjs-dist/cmaps/H.bcmap +0 -0
  104. package/dist/node_modules/pdfjs-dist/cmaps/HKdla-B5-H.bcmap +0 -0
  105. package/dist/node_modules/pdfjs-dist/cmaps/HKdla-B5-V.bcmap +0 -0
  106. package/dist/node_modules/pdfjs-dist/cmaps/HKdlb-B5-H.bcmap +0 -0
  107. package/dist/node_modules/pdfjs-dist/cmaps/HKdlb-B5-V.bcmap +0 -0
  108. package/dist/node_modules/pdfjs-dist/cmaps/HKgccs-B5-H.bcmap +0 -0
  109. package/dist/node_modules/pdfjs-dist/cmaps/HKgccs-B5-V.bcmap +0 -0
  110. package/dist/node_modules/pdfjs-dist/cmaps/HKm314-B5-H.bcmap +0 -0
  111. package/dist/node_modules/pdfjs-dist/cmaps/HKm314-B5-V.bcmap +0 -0
  112. package/dist/node_modules/pdfjs-dist/cmaps/HKm471-B5-H.bcmap +0 -0
  113. package/dist/node_modules/pdfjs-dist/cmaps/HKm471-B5-V.bcmap +0 -0
  114. package/dist/node_modules/pdfjs-dist/cmaps/HKscs-B5-H.bcmap +0 -0
  115. package/dist/node_modules/pdfjs-dist/cmaps/HKscs-B5-V.bcmap +0 -0
  116. package/dist/node_modules/pdfjs-dist/cmaps/Hankaku.bcmap +0 -0
  117. package/dist/node_modules/pdfjs-dist/cmaps/Hiragana.bcmap +0 -0
  118. package/dist/node_modules/pdfjs-dist/cmaps/KSC-EUC-H.bcmap +0 -0
  119. package/dist/node_modules/pdfjs-dist/cmaps/KSC-EUC-V.bcmap +0 -0
  120. package/dist/node_modules/pdfjs-dist/cmaps/KSC-H.bcmap +0 -0
  121. package/dist/node_modules/pdfjs-dist/cmaps/KSC-Johab-H.bcmap +0 -0
  122. package/dist/node_modules/pdfjs-dist/cmaps/KSC-Johab-V.bcmap +0 -0
  123. package/dist/node_modules/pdfjs-dist/cmaps/KSC-V.bcmap +0 -0
  124. package/dist/node_modules/pdfjs-dist/cmaps/KSCms-UHC-H.bcmap +0 -0
  125. package/dist/node_modules/pdfjs-dist/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  126. package/dist/node_modules/pdfjs-dist/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  127. package/dist/node_modules/pdfjs-dist/cmaps/KSCms-UHC-V.bcmap +0 -0
  128. package/dist/node_modules/pdfjs-dist/cmaps/KSCpc-EUC-H.bcmap +0 -0
  129. package/dist/node_modules/pdfjs-dist/cmaps/KSCpc-EUC-V.bcmap +0 -0
  130. package/dist/node_modules/pdfjs-dist/cmaps/Katakana.bcmap +0 -0
  131. package/dist/node_modules/pdfjs-dist/cmaps/NWP-H.bcmap +0 -0
  132. package/dist/node_modules/pdfjs-dist/cmaps/NWP-V.bcmap +0 -0
  133. package/dist/node_modules/pdfjs-dist/cmaps/RKSJ-H.bcmap +0 -0
  134. package/dist/node_modules/pdfjs-dist/cmaps/RKSJ-V.bcmap +0 -0
  135. package/dist/node_modules/pdfjs-dist/cmaps/Roman.bcmap +0 -0
  136. package/dist/node_modules/pdfjs-dist/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  137. package/dist/node_modules/pdfjs-dist/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  138. package/dist/node_modules/pdfjs-dist/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  139. package/dist/node_modules/pdfjs-dist/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  140. package/dist/node_modules/pdfjs-dist/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  141. package/dist/node_modules/pdfjs-dist/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  142. package/dist/node_modules/pdfjs-dist/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  143. package/dist/node_modules/pdfjs-dist/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  144. package/dist/node_modules/pdfjs-dist/cmaps/UniGB-UCS2-H.bcmap +0 -0
  145. package/dist/node_modules/pdfjs-dist/cmaps/UniGB-UCS2-V.bcmap +0 -0
  146. package/dist/node_modules/pdfjs-dist/cmaps/UniGB-UTF16-H.bcmap +0 -0
  147. package/dist/node_modules/pdfjs-dist/cmaps/UniGB-UTF16-V.bcmap +0 -0
  148. package/dist/node_modules/pdfjs-dist/cmaps/UniGB-UTF32-H.bcmap +0 -0
  149. package/dist/node_modules/pdfjs-dist/cmaps/UniGB-UTF32-V.bcmap +0 -0
  150. package/dist/node_modules/pdfjs-dist/cmaps/UniGB-UTF8-H.bcmap +0 -0
  151. package/dist/node_modules/pdfjs-dist/cmaps/UniGB-UTF8-V.bcmap +0 -0
  152. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  153. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  154. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  155. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  156. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  157. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  158. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  159. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  160. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  161. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  162. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  163. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  164. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  165. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  166. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  167. package/dist/node_modules/pdfjs-dist/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  168. package/dist/node_modules/pdfjs-dist/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  169. package/dist/node_modules/pdfjs-dist/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  170. package/dist/node_modules/pdfjs-dist/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  171. package/dist/node_modules/pdfjs-dist/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  172. package/dist/node_modules/pdfjs-dist/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  173. package/dist/node_modules/pdfjs-dist/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  174. package/dist/node_modules/pdfjs-dist/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  175. package/dist/node_modules/pdfjs-dist/cmaps/UniKS-UCS2-H.bcmap +0 -0
  176. package/dist/node_modules/pdfjs-dist/cmaps/UniKS-UCS2-V.bcmap +0 -0
  177. package/dist/node_modules/pdfjs-dist/cmaps/UniKS-UTF16-H.bcmap +0 -0
  178. package/dist/node_modules/pdfjs-dist/cmaps/UniKS-UTF16-V.bcmap +0 -0
  179. package/dist/node_modules/pdfjs-dist/cmaps/UniKS-UTF32-H.bcmap +0 -0
  180. package/dist/node_modules/pdfjs-dist/cmaps/UniKS-UTF32-V.bcmap +0 -0
  181. package/dist/node_modules/pdfjs-dist/cmaps/UniKS-UTF8-H.bcmap +0 -0
  182. package/dist/node_modules/pdfjs-dist/cmaps/UniKS-UTF8-V.bcmap +0 -0
  183. package/dist/node_modules/pdfjs-dist/cmaps/V.bcmap +0 -0
  184. package/dist/node_modules/pdfjs-dist/cmaps/WP-Symbol.bcmap +0 -0
  185. package/dist/node_modules/pdfjs-dist/iccs/CGATS001Compat-v2-micro.icc +0 -0
  186. package/dist/node_modules/pdfjs-dist/legacy/build/pdf.d.mts +1 -0
  187. package/dist/node_modules/pdfjs-dist/legacy/web/images/altText_add.svg +3 -0
  188. package/dist/node_modules/pdfjs-dist/legacy/web/images/altText_disclaimer.svg +3 -0
  189. package/dist/node_modules/pdfjs-dist/legacy/web/images/altText_done.svg +3 -0
  190. package/dist/node_modules/pdfjs-dist/legacy/web/images/altText_spinner.svg +30 -0
  191. package/dist/node_modules/pdfjs-dist/legacy/web/images/altText_warning.svg +3 -0
  192. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-check.svg +11 -0
  193. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-comment.svg +16 -0
  194. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-help.svg +26 -0
  195. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-insert.svg +10 -0
  196. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-key.svg +11 -0
  197. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-newparagraph.svg +11 -0
  198. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-noicon.svg +7 -0
  199. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-note.svg +42 -0
  200. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-paperclip.svg +6 -0
  201. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-paragraph.svg +16 -0
  202. package/dist/node_modules/pdfjs-dist/legacy/web/images/annotation-pushpin.svg +7 -0
  203. package/dist/node_modules/pdfjs-dist/legacy/web/images/checkmark.svg +5 -0
  204. package/dist/node_modules/pdfjs-dist/legacy/web/images/comment-actionsButton.svg +3 -0
  205. package/dist/node_modules/pdfjs-dist/legacy/web/images/comment-closeButton.svg +3 -0
  206. package/dist/node_modules/pdfjs-dist/legacy/web/images/comment-editButton.svg +8 -0
  207. package/dist/node_modules/pdfjs-dist/legacy/web/images/comment-popup-editButton.svg +5 -0
  208. package/dist/node_modules/pdfjs-dist/legacy/web/images/cursor-editorFreeHighlight.svg +6 -0
  209. package/dist/node_modules/pdfjs-dist/legacy/web/images/cursor-editorFreeText.svg +3 -0
  210. package/dist/node_modules/pdfjs-dist/legacy/web/images/cursor-editorInk.svg +4 -0
  211. package/dist/node_modules/pdfjs-dist/legacy/web/images/cursor-editorTextHighlight.svg +8 -0
  212. package/dist/node_modules/pdfjs-dist/legacy/web/images/editor-toolbar-delete.svg +5 -0
  213. package/dist/node_modules/pdfjs-dist/legacy/web/images/editor-toolbar-edit.svg +3 -0
  214. package/dist/node_modules/pdfjs-dist/legacy/web/images/findbarButton-next.svg +3 -0
  215. package/dist/node_modules/pdfjs-dist/legacy/web/images/findbarButton-previous.svg +3 -0
  216. package/dist/node_modules/pdfjs-dist/legacy/web/images/gv-toolbarButton-download.svg +3 -0
  217. package/dist/node_modules/pdfjs-dist/legacy/web/images/loading.svg +1 -0
  218. package/dist/node_modules/pdfjs-dist/legacy/web/images/messageBar_closingButton.svg +3 -0
  219. package/dist/node_modules/pdfjs-dist/legacy/web/images/messageBar_info.svg +3 -0
  220. package/dist/node_modules/pdfjs-dist/legacy/web/images/messageBar_warning.svg +3 -0
  221. package/dist/node_modules/pdfjs-dist/legacy/web/images/pages_closeButton.svg +3 -0
  222. package/dist/node_modules/pdfjs-dist/legacy/web/images/pages_selected.svg +7 -0
  223. package/dist/node_modules/pdfjs-dist/legacy/web/images/pages_viewArrow.svg +3 -0
  224. package/dist/node_modules/pdfjs-dist/legacy/web/images/pages_viewButton.svg +3 -0
  225. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-documentProperties.svg +3 -0
  226. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-firstPage.svg +3 -0
  227. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-handTool.svg +3 -0
  228. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-lastPage.svg +3 -0
  229. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-rotateCcw.svg +3 -0
  230. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-rotateCw.svg +3 -0
  231. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-scrollHorizontal.svg +3 -0
  232. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-scrollPage.svg +3 -0
  233. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-scrollVertical.svg +3 -0
  234. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-scrollWrapped.svg +3 -0
  235. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-selectTool.svg +3 -0
  236. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-spreadEven.svg +3 -0
  237. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-spreadNone.svg +3 -0
  238. package/dist/node_modules/pdfjs-dist/legacy/web/images/secondaryToolbarButton-spreadOdd.svg +3 -0
  239. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-bookmark.svg +3 -0
  240. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-currentOutlineItem.svg +3 -0
  241. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-download.svg +4 -0
  242. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-editorFreeText.svg +5 -0
  243. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-editorHighlight.svg +6 -0
  244. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-editorInk.svg +4 -0
  245. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-editorSignature.svg +6 -0
  246. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-editorStamp.svg +8 -0
  247. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-menuArrow.svg +3 -0
  248. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-openFile.svg +3 -0
  249. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-pageDown.svg +3 -0
  250. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-pageUp.svg +3 -0
  251. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-presentationMode.svg +3 -0
  252. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-print.svg +3 -0
  253. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-search.svg +3 -0
  254. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-secondaryToolbarToggle.svg +3 -0
  255. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-viewAttachments.svg +3 -0
  256. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-viewLayers.svg +3 -0
  257. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-viewOutline.svg +3 -0
  258. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-viewThumbnail.svg +3 -0
  259. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-viewsManagerToggle.svg +3 -0
  260. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-zoomIn.svg +3 -0
  261. package/dist/node_modules/pdfjs-dist/legacy/web/images/toolbarButton-zoomOut.svg +3 -0
  262. package/dist/node_modules/pdfjs-dist/legacy/web/images/treeitem-collapsed.svg +1 -0
  263. package/dist/node_modules/pdfjs-dist/legacy/web/images/treeitem-expanded.svg +1 -0
  264. package/dist/node_modules/pdfjs-dist/legacy/web/pdf_viewer.css +6989 -0
  265. package/dist/node_modules/pdfjs-dist/legacy/web/pdf_viewer.d.mts +1 -0
  266. package/dist/node_modules/pdfjs-dist/package.json +1 -0
  267. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitDingbats.pfb +0 -0
  268. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitFixed.pfb +0 -0
  269. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitFixedBold.pfb +0 -0
  270. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  271. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitFixedItalic.pfb +0 -0
  272. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitSerif.pfb +0 -0
  273. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitSerifBold.pfb +0 -0
  274. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  275. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitSerifItalic.pfb +0 -0
  276. package/dist/node_modules/pdfjs-dist/standard_fonts/FoxitSymbol.pfb +0 -0
  277. package/dist/node_modules/pdfjs-dist/standard_fonts/LICENSE_FOXIT +27 -0
  278. package/dist/node_modules/pdfjs-dist/standard_fonts/LICENSE_LIBERATION +102 -0
  279. package/dist/node_modules/pdfjs-dist/standard_fonts/LiberationSans-Bold.ttf +0 -0
  280. package/dist/node_modules/pdfjs-dist/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  281. package/dist/node_modules/pdfjs-dist/standard_fonts/LiberationSans-Italic.ttf +0 -0
  282. package/dist/node_modules/pdfjs-dist/standard_fonts/LiberationSans-Regular.ttf +0 -0
  283. package/dist/node_modules/pdfjs-dist/types/src/display/annotation_layer.d.ts +276 -0
  284. package/dist/node_modules/pdfjs-dist/types/src/display/annotation_storage.d.ts +94 -0
  285. package/dist/node_modules/pdfjs-dist/types/src/display/api.d.ts +1630 -0
  286. package/dist/node_modules/pdfjs-dist/types/src/display/api_utils.d.ts +13 -0
  287. package/dist/node_modules/pdfjs-dist/types/src/display/canvas.d.ts +207 -0
  288. package/dist/node_modules/pdfjs-dist/types/src/display/canvas_dependency_tracker.d.ts +160 -0
  289. package/dist/node_modules/pdfjs-dist/types/src/display/canvas_factory.d.ts +27 -0
  290. package/dist/node_modules/pdfjs-dist/types/src/display/cmap_reader_factory.d.ts +25 -0
  291. package/dist/node_modules/pdfjs-dist/types/src/display/content_disposition.d.ts +7 -0
  292. package/dist/node_modules/pdfjs-dist/types/src/display/display_utils.d.ts +366 -0
  293. package/dist/node_modules/pdfjs-dist/types/src/display/draw_layer.d.ts +22 -0
  294. package/dist/node_modules/pdfjs-dist/types/src/display/editor/alt_text.d.ts +34 -0
  295. package/dist/node_modules/pdfjs-dist/types/src/display/editor/annotation_editor_layer.d.ts +233 -0
  296. package/dist/node_modules/pdfjs-dist/types/src/display/editor/color_picker.d.ts +39 -0
  297. package/dist/node_modules/pdfjs-dist/types/src/display/editor/comment.d.ts +59 -0
  298. package/dist/node_modules/pdfjs-dist/types/src/display/editor/draw.d.ts +117 -0
  299. package/dist/node_modules/pdfjs-dist/types/src/display/editor/drawers/contour.d.ts +3 -0
  300. package/dist/node_modules/pdfjs-dist/types/src/display/editor/drawers/freedraw.d.ts +32 -0
  301. package/dist/node_modules/pdfjs-dist/types/src/display/editor/drawers/highlight.d.ts +37 -0
  302. package/dist/node_modules/pdfjs-dist/types/src/display/editor/drawers/inkdraw.d.ts +129 -0
  303. package/dist/node_modules/pdfjs-dist/types/src/display/editor/drawers/outline.d.ts +19 -0
  304. package/dist/node_modules/pdfjs-dist/types/src/display/editor/drawers/signaturedraw.d.ts +79 -0
  305. package/dist/node_modules/pdfjs-dist/types/src/display/editor/editor.d.ts +578 -0
  306. package/dist/node_modules/pdfjs-dist/types/src/display/editor/freetext.d.ts +63 -0
  307. package/dist/node_modules/pdfjs-dist/types/src/display/editor/highlight.d.ts +76 -0
  308. package/dist/node_modules/pdfjs-dist/types/src/display/editor/ink.d.ts +42 -0
  309. package/dist/node_modules/pdfjs-dist/types/src/display/editor/signature.d.ts +77 -0
  310. package/dist/node_modules/pdfjs-dist/types/src/display/editor/stamp.d.ts +49 -0
  311. package/dist/node_modules/pdfjs-dist/types/src/display/editor/toolbar.d.ts +26 -0
  312. package/dist/node_modules/pdfjs-dist/types/src/display/editor/tools.d.ts +481 -0
  313. package/dist/node_modules/pdfjs-dist/types/src/display/fetch_stream.d.ts +7 -0
  314. package/dist/node_modules/pdfjs-dist/types/src/display/filter_factory.d.ts +29 -0
  315. package/dist/node_modules/pdfjs-dist/types/src/display/font_loader.d.ts +67 -0
  316. package/dist/node_modules/pdfjs-dist/types/src/display/metadata.d.ts +10 -0
  317. package/dist/node_modules/pdfjs-dist/types/src/display/network.d.ts +20 -0
  318. package/dist/node_modules/pdfjs-dist/types/src/display/network_utils.d.ts +15 -0
  319. package/dist/node_modules/pdfjs-dist/types/src/display/node_stream.d.ts +5 -0
  320. package/dist/node_modules/pdfjs-dist/types/src/display/node_utils.d.ts +32 -0
  321. package/dist/node_modules/pdfjs-dist/types/src/display/optional_content_config.d.ts +18 -0
  322. package/dist/node_modules/pdfjs-dist/types/src/display/pattern_helper.d.ts +77 -0
  323. package/dist/node_modules/pdfjs-dist/types/src/display/pdf_objects.d.ts +40 -0
  324. package/dist/node_modules/pdfjs-dist/types/src/display/standard_fontdata_factory.d.ts +20 -0
  325. package/dist/node_modules/pdfjs-dist/types/src/display/svg_factory.d.ts +14 -0
  326. package/dist/node_modules/pdfjs-dist/types/src/display/text_layer.d.ts +85 -0
  327. package/dist/node_modules/pdfjs-dist/types/src/display/touch_manager.d.ts +18 -0
  328. package/dist/node_modules/pdfjs-dist/types/src/display/transport_stream.d.ts +10 -0
  329. package/dist/node_modules/pdfjs-dist/types/src/display/wasm_factory.d.ts +20 -0
  330. package/dist/node_modules/pdfjs-dist/types/src/display/worker_options.d.ts +25 -0
  331. package/dist/node_modules/pdfjs-dist/types/src/display/xfa_layer.d.ts +47 -0
  332. package/dist/node_modules/pdfjs-dist/types/src/display/xfa_text.d.ts +21 -0
  333. package/dist/node_modules/pdfjs-dist/types/src/pdf.d.ts +64 -0
  334. package/dist/node_modules/pdfjs-dist/types/src/shared/base_pdf_stream.d.ts +120 -0
  335. package/dist/node_modules/pdfjs-dist/types/src/shared/image_utils.d.ts +17 -0
  336. package/dist/node_modules/pdfjs-dist/types/src/shared/message_handler.d.ts +48 -0
  337. package/dist/node_modules/pdfjs-dist/types/src/shared/murmurhash3.d.ts +7 -0
  338. package/dist/node_modules/pdfjs-dist/types/src/shared/obj-bin-transform.d.ts +90 -0
  339. package/dist/node_modules/pdfjs-dist/types/src/shared/scripting_utils.d.ts +18 -0
  340. package/dist/node_modules/pdfjs-dist/types/src/shared/util.d.ts +420 -0
  341. package/dist/node_modules/pdfjs-dist/types/web/annotation_editor_layer_builder.d.ts +65 -0
  342. package/dist/node_modules/pdfjs-dist/types/web/annotation_layer_builder.d.ts +108 -0
  343. package/dist/node_modules/pdfjs-dist/types/web/app_options.d.ts +16 -0
  344. package/dist/node_modules/pdfjs-dist/types/web/autolinker.d.ts +29 -0
  345. package/dist/node_modules/pdfjs-dist/types/web/base_pdf_page_view.d.ts +28 -0
  346. package/dist/node_modules/pdfjs-dist/types/web/comment_manager.d.ts +20 -0
  347. package/dist/node_modules/pdfjs-dist/types/web/download_manager.d.ts +13 -0
  348. package/dist/node_modules/pdfjs-dist/types/web/draw_layer_builder.d.ts +22 -0
  349. package/dist/node_modules/pdfjs-dist/types/web/event_utils.d.ts +77 -0
  350. package/dist/node_modules/pdfjs-dist/types/web/generic_scripting.d.ts +8 -0
  351. package/dist/node_modules/pdfjs-dist/types/web/genericl10n.d.ts +22 -0
  352. package/dist/node_modules/pdfjs-dist/types/web/interfaces.d.ts +174 -0
  353. package/dist/node_modules/pdfjs-dist/types/web/l10n.d.ts +34 -0
  354. package/dist/node_modules/pdfjs-dist/types/web/menu.d.ts +11 -0
  355. package/dist/node_modules/pdfjs-dist/types/web/pdf_find_controller.d.ts +134 -0
  356. package/dist/node_modules/pdfjs-dist/types/web/pdf_find_utils.d.ts +16 -0
  357. package/dist/node_modules/pdfjs-dist/types/web/pdf_history.d.ts +116 -0
  358. package/dist/node_modules/pdfjs-dist/types/web/pdf_link_service.d.ts +147 -0
  359. package/dist/node_modules/pdfjs-dist/types/web/pdf_page_detail_view.d.ts +33 -0
  360. package/dist/node_modules/pdfjs-dist/types/web/pdf_page_view.d.ts +244 -0
  361. package/dist/node_modules/pdfjs-dist/types/web/pdf_rendering_queue.d.ts +54 -0
  362. package/dist/node_modules/pdfjs-dist/types/web/pdf_scripting_manager.component.d.ts +5 -0
  363. package/dist/node_modules/pdfjs-dist/types/web/pdf_scripting_manager.d.ts +57 -0
  364. package/dist/node_modules/pdfjs-dist/types/web/pdf_single_page_viewer.d.ts +7 -0
  365. package/dist/node_modules/pdfjs-dist/types/web/pdf_thumbnail_view.d.ts +108 -0
  366. package/dist/node_modules/pdfjs-dist/types/web/pdf_thumbnail_viewer.d.ts +136 -0
  367. package/dist/node_modules/pdfjs-dist/types/web/pdf_viewer.component.d.ts +23 -0
  368. package/dist/node_modules/pdfjs-dist/types/web/pdf_viewer.d.ts +625 -0
  369. package/dist/node_modules/pdfjs-dist/types/web/sidebar.d.ts +65 -0
  370. package/dist/node_modules/pdfjs-dist/types/web/struct_tree_layer_builder.d.ts +25 -0
  371. package/dist/node_modules/pdfjs-dist/types/web/text_accessibility.d.ts +44 -0
  372. package/dist/node_modules/pdfjs-dist/types/web/text_highlighter.d.ts +63 -0
  373. package/dist/node_modules/pdfjs-dist/types/web/text_layer_builder.d.ts +65 -0
  374. package/dist/node_modules/pdfjs-dist/types/web/ui_utils.d.ts +274 -0
  375. package/dist/node_modules/pdfjs-dist/types/web/xfa_layer_builder.d.ts +50 -0
  376. package/dist/node_modules/pdfjs-dist/wasm/LICENSE_JBIG2 +196 -0
  377. package/dist/node_modules/pdfjs-dist/wasm/LICENSE_OPENJPEG +39 -0
  378. package/dist/node_modules/pdfjs-dist/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  379. package/dist/node_modules/pdfjs-dist/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  380. package/dist/node_modules/pdfjs-dist/wasm/LICENSE_PDFJS_QCMS +22 -0
  381. package/dist/node_modules/pdfjs-dist/wasm/LICENSE_QCMS +21 -0
  382. package/dist/node_modules/pdfjs-dist/wasm/jbig2.wasm +0 -0
  383. package/dist/node_modules/pdfjs-dist/wasm/openjpeg.wasm +0 -0
  384. package/dist/node_modules/pdfjs-dist/wasm/openjpeg_nowasm_fallback.js +17 -0
  385. package/dist/node_modules/pdfjs-dist/wasm/qcms_bg.wasm +0 -0
  386. package/dist/node_modules/pdfjs-dist/web/images/altText_add.svg +3 -0
  387. package/dist/node_modules/pdfjs-dist/web/images/altText_disclaimer.svg +3 -0
  388. package/dist/node_modules/pdfjs-dist/web/images/altText_done.svg +3 -0
  389. package/dist/node_modules/pdfjs-dist/web/images/altText_spinner.svg +30 -0
  390. package/dist/node_modules/pdfjs-dist/web/images/altText_warning.svg +3 -0
  391. package/dist/node_modules/pdfjs-dist/web/images/annotation-check.svg +11 -0
  392. package/dist/node_modules/pdfjs-dist/web/images/annotation-comment.svg +16 -0
  393. package/dist/node_modules/pdfjs-dist/web/images/annotation-help.svg +26 -0
  394. package/dist/node_modules/pdfjs-dist/web/images/annotation-insert.svg +10 -0
  395. package/dist/node_modules/pdfjs-dist/web/images/annotation-key.svg +11 -0
  396. package/dist/node_modules/pdfjs-dist/web/images/annotation-newparagraph.svg +11 -0
  397. package/dist/node_modules/pdfjs-dist/web/images/annotation-noicon.svg +7 -0
  398. package/dist/node_modules/pdfjs-dist/web/images/annotation-note.svg +42 -0
  399. package/dist/node_modules/pdfjs-dist/web/images/annotation-paperclip.svg +6 -0
  400. package/dist/node_modules/pdfjs-dist/web/images/annotation-paragraph.svg +16 -0
  401. package/dist/node_modules/pdfjs-dist/web/images/annotation-pushpin.svg +7 -0
  402. package/dist/node_modules/pdfjs-dist/web/images/checkmark.svg +5 -0
  403. package/dist/node_modules/pdfjs-dist/web/images/comment-actionsButton.svg +3 -0
  404. package/dist/node_modules/pdfjs-dist/web/images/comment-closeButton.svg +3 -0
  405. package/dist/node_modules/pdfjs-dist/web/images/comment-editButton.svg +8 -0
  406. package/dist/node_modules/pdfjs-dist/web/images/comment-popup-editButton.svg +5 -0
  407. package/dist/node_modules/pdfjs-dist/web/images/cursor-editorFreeHighlight.svg +6 -0
  408. package/dist/node_modules/pdfjs-dist/web/images/cursor-editorFreeText.svg +3 -0
  409. package/dist/node_modules/pdfjs-dist/web/images/cursor-editorInk.svg +4 -0
  410. package/dist/node_modules/pdfjs-dist/web/images/cursor-editorTextHighlight.svg +8 -0
  411. package/dist/node_modules/pdfjs-dist/web/images/editor-toolbar-delete.svg +5 -0
  412. package/dist/node_modules/pdfjs-dist/web/images/editor-toolbar-edit.svg +3 -0
  413. package/dist/node_modules/pdfjs-dist/web/images/findbarButton-next.svg +3 -0
  414. package/dist/node_modules/pdfjs-dist/web/images/findbarButton-previous.svg +3 -0
  415. package/dist/node_modules/pdfjs-dist/web/images/gv-toolbarButton-download.svg +3 -0
  416. package/dist/node_modules/pdfjs-dist/web/images/loading.svg +1 -0
  417. package/dist/node_modules/pdfjs-dist/web/images/messageBar_closingButton.svg +3 -0
  418. package/dist/node_modules/pdfjs-dist/web/images/messageBar_info.svg +3 -0
  419. package/dist/node_modules/pdfjs-dist/web/images/messageBar_warning.svg +3 -0
  420. package/dist/node_modules/pdfjs-dist/web/images/pages_closeButton.svg +3 -0
  421. package/dist/node_modules/pdfjs-dist/web/images/pages_selected.svg +7 -0
  422. package/dist/node_modules/pdfjs-dist/web/images/pages_viewArrow.svg +3 -0
  423. package/dist/node_modules/pdfjs-dist/web/images/pages_viewButton.svg +3 -0
  424. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-documentProperties.svg +3 -0
  425. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-firstPage.svg +3 -0
  426. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-handTool.svg +3 -0
  427. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-lastPage.svg +3 -0
  428. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-rotateCcw.svg +3 -0
  429. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-rotateCw.svg +3 -0
  430. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-scrollHorizontal.svg +3 -0
  431. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-scrollPage.svg +3 -0
  432. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-scrollVertical.svg +3 -0
  433. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-scrollWrapped.svg +3 -0
  434. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-selectTool.svg +3 -0
  435. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-spreadEven.svg +3 -0
  436. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-spreadNone.svg +3 -0
  437. package/dist/node_modules/pdfjs-dist/web/images/secondaryToolbarButton-spreadOdd.svg +3 -0
  438. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-bookmark.svg +3 -0
  439. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-currentOutlineItem.svg +3 -0
  440. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-download.svg +4 -0
  441. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-editorFreeText.svg +5 -0
  442. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-editorHighlight.svg +6 -0
  443. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-editorInk.svg +4 -0
  444. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-editorSignature.svg +6 -0
  445. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-editorStamp.svg +8 -0
  446. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-menuArrow.svg +3 -0
  447. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-openFile.svg +3 -0
  448. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-pageDown.svg +3 -0
  449. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-pageUp.svg +3 -0
  450. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-presentationMode.svg +3 -0
  451. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-print.svg +3 -0
  452. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-search.svg +3 -0
  453. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-secondaryToolbarToggle.svg +3 -0
  454. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-viewAttachments.svg +3 -0
  455. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-viewLayers.svg +3 -0
  456. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-viewOutline.svg +3 -0
  457. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-viewThumbnail.svg +3 -0
  458. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-viewsManagerToggle.svg +3 -0
  459. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-zoomIn.svg +3 -0
  460. package/dist/node_modules/pdfjs-dist/web/images/toolbarButton-zoomOut.svg +3 -0
  461. package/dist/node_modules/pdfjs-dist/web/images/treeitem-collapsed.svg +1 -0
  462. package/dist/node_modules/pdfjs-dist/web/images/treeitem-expanded.svg +1 -0
  463. package/dist/node_modules/pdfjs-dist/web/pdf_viewer.css +6989 -0
  464. package/dist/node_modules/pdfjs-dist/web/pdf_viewer.d.mts +1 -0
  465. package/dist/node_modules/url-join/package.json +1 -1
  466. package/dist/shared/previewer/filePreviewTypes.d.ts +1 -0
  467. package/dist/shared/previewer/filePreviewTypes.js +238 -6
  468. package/package.json +4 -5
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunk_nocobase_plugin_file_manager=self.webpackChunk_nocobase_plugin_file_manager||[]).push([["876"],{583:function(t,e,i){i.r(e),i.d(e,{AbortException:function(){return P},AnnotationEditorLayer:function(){return sP},AnnotationEditorParamsType:function(){return h},AnnotationEditorType:function(){return l},AnnotationEditorUIManager:function(){return tk},AnnotationLayer:function(){return so},AnnotationMode:function(){return a},AnnotationType:function(){return u},CSSConstants:function(){return tc},ColorPicker:function(){return iF},DOMSVGFactory:function(){return iz},DrawLayer:function(){return sk},FeatureTest:function(){return I},GlobalWorkerOptions:function(){return eK},ImageKind:function(){return c},InvalidPDFException:function(){return E},MathClamp:function(){return z},OPS:function(){return g},OutputScale:function(){return tl},PDFDataRangeTransport:function(){return iS},PDFDateString:function(){return ti},PDFWorker:function(){return iM},PagesMapper:function(){return tw},PasswordResponses:function(){return m},PermissionFlag:function(){return d},PixelsPerInch:function(){return j},RenderingCancelledException:function(){return X},ResponseException:function(){return M},SignatureExtractor:function(){return sS},SupportedImageMimeTypes:function(){return th},TextLayer:function(){return ix},TouchManager:function(){return tF},Util:function(){return F},VerbosityLevel:function(){return p},XfaLayer:function(){return $},applyOpacity:function(){return tu},build:function(){return iB},createValidAbsoluteUrl:function(){return w},fetchData:function(){return V},findContrastColor:function(){return tA},getDocument:function(){return i_},getFilenameFromUrl:function(){return Y},getPdfFilenameFromUrl:function(){return Q},getRGB:function(){return tn},getUuid:function(){return O},getXfaPageViewport:function(){return ts},isDataScheme:function(){return q},isPdfFile:function(){return K},isValidExplicitDest:function(){return tY},noContextMenu:function(){return tt},normalizeUnicode:function(){return N},renderRichText:function(){return tv},setLayerDimensions:function(){return to},shadow:function(){return _},stopEvent:function(){return te},updateUrlHash:function(){return x},version:function(){return iI}});var s={};s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var e={};let n="object"==typeof process&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&"browser"!==process.type),r=[.001,0,0,.001,0,0],a={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},o="pdfjs_internal_editor_",l={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},h={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},d={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},c={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},u={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},p={ERRORS:0,WARNINGS:1,INFOS:5},g={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,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},m={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},f=p.WARNINGS;function b(t){f>=p.INFOS&&console.info(`Info: ${t}`)}function A(t){f>=p.WARNINGS&&console.warn(`Warning: ${t}`)}function v(t){throw Error(t)}function y(t,e){t||v(e)}function w(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var s;s=t,t=decodeURIComponent(escape(s))}catch{}}let n=e?URL.parse(t,e):URL.parse(t);return!function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(n)?null:n}function x(t,e,i=!1){let s=URL.parse(t);return s?(s.hash=e,s.href):i&&w(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function _(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}let C=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class S extends C{constructor(t,e){super(t,"PasswordException"),this.code=e}}class T extends C{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class E extends C{constructor(t){super(t,"InvalidPDFException")}}class M extends C{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class D extends C{constructor(t){super(t,"FormatError")}}class P extends C{constructor(t){super(t,"AbortException")}}function k(t){"string"!=typeof t&&v("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class I{static get isLittleEndian(){let t;return _(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]))}static get isEvalSupported(){return _(this,"isEvalSupported",function(){try{return Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return _(this,"isOffscreenCanvasSupported","u">typeof OffscreenCanvas)}static get isImageDecoderSupported(){return _(this,"isImageDecoderSupported","u">typeof ImageDecoder)}static get isFloat16ArraySupported(){return _(this,"isFloat16ArraySupported","u">typeof Float16Array)}static get isSanitizerSupported(){return _(this,"isSanitizerSupported","u">typeof Sanitizer)}static get platform(){let{platform:t,userAgent:e}=navigator;return _(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return _(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let B=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class F{static makeHexColor(t,e,i){return`#${B[t]}${B[e]}${B[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){let s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){let s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){let h=t[i+e],d=t[i+e+1];t[i+e]=h*s+d*r+o,t[i+e+1]=h*n+d*a+l}}static applyInverseTransform(t,e){let i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){let s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3],p=s*h+o,g=p,m=s*c+o,f=m,b=a*d+l,A=b,v=a*u+l,y=v;if(0!==n||0!==r){let t=n*h,e=n*c,i=r*d,s=r*u;p+=i,f+=i,m+=s,g+=s,b+=t,y+=t,v+=e,A+=e}i[0]=Math.min(i[0],p,m,g,f),i[1]=Math.min(i[1],b,v,A,y),i[2]=Math.max(i[2],p,m,g,f),i[3]=Math.max(i[3],b,v,A,y)}static inverseTransform(t){let 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,e){let i=t[0],s=t[1],n=t[2],r=t[3],a=i**2+s**2,o=n**2+r**2,l=(a+o)/2,h=Math.sqrt(l**2-(a*o-(i*n+s*r)**2));e[0]=Math.sqrt(l+h||1),e[1]=Math.sqrt(l-h||1)}static normalizeRect(t){let 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){let i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;let n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static #t(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*n+3*l*r)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,s,n,r,a,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,r,a,o,(-h+p)/g,c),this.#t(t,e,i,s,n,r,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,i,n,a,e,s,r,o,3*(-t+3*(i-n)+a),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,a,e,s,r,o,3*(-e+3*(s-r)+o),6*(e-2*s+r),3*(s-e),l)}}let L=null,R=null;function N(t){return L||(L=/([\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,R=new Map([["ſt","ſt"]])),t.replaceAll(L,(t,e,i)=>e?e.normalize("NFKC"):R.get(i))}function O(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),function(t){("object"!=typeof t||t?.length===void 0)&&v("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let s=0;s<e;s+=8192){let n=Math.min(s+8192,e),r=t.subarray(s,n);i.push(String.fromCharCode.apply(null,r))}return i.join("")}(t)}let U="pdfjs_internal_id_";function z(t,e,i){return Math.min(Math.max(t,e),i)}"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});class H{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let s=null,n=i.name;if("#text"===n)s=i.value;else{if(!H.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return"textarea"!==t&&"input"!==t&&"option"!==t&&"select"!==t}}class ${static setupStorage(t,e,i,s,n){let r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==r.value)for(let e of(t.setAttribute("value",r.value),i.children))e.attributes.value===r.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){let{attributes:r}=e,a=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===r.type&&(r.name=`${r.name}-${s}`),Object.entries(r)))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:a&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});let a="richText"!==n,o=t.div;if(o.append(r),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);r.append(t),a&&H.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,r]];for(;h.length>0;){let[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),r.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(r.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);a&&H.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}let G="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 V(t,e="text"){if(Z(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let 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){switch(e){case"arraybuffer":case"blob":case"json":i(n.response);return}i(n.responseText);return}s(Error(n.statusText))}},n.send(null)})}class W{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){let o,l,h,d,c,u,p,g;this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const m=(t[2]+t[0])/2,f=(t[3]+t[1])/2;switch((s%=360)<0&&(s+=360),s){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(h=-h,d=-d),0===o?(c=Math.abs(f-t[1])*i+n,u=Math.abs(m-t[0])*i+r,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(m-t[0])*i+n,u=Math.abs(f-t[1])*i+r,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*m-h*i*f,u-l*i*m-d*i*f],this.width=p,this.height=g}get rawDims(){let t=this.viewBox;return _(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:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new W({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){let i=[t,e];return F.applyTransform(i,this.transform),i}convertToViewportRectangle(t){let e=[t[0],t[1]];F.applyTransform(e,this.transform);let i=[t[2],t[3]];return F.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){let i=[t,e];return F.applyInverseTransform(i,this.transform),i}}class X extends C{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function q(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function K(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Y(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Q(t,e="document.pdf"){if("string"!=typeof t)return e;if(q(t))return A('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;let s=t=>{try{let e=decodeURIComponent(t);if(e.includes("/")){if((e=e.split("/").at(-1)).test(/^\.pdf$/i))return e;return t}return e}catch{return t}},n=/\.pdf$/i,r=i.pathname.split("/").at(-1);if(n.test(r))return s(r);if(i.searchParams.size>0){for(let t of Array.from(i.searchParams.values()).reverse())if(n.test(t))return s(t);for(let t of Array.from(i.searchParams.keys()).reverse())if(n.test(t))return s(t)}if(i.hash){let t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return s(t[0])}return e}class J{started=Object.create(null);times=[];time(t){t in this.started&&A(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||A(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:t}of this.times)e=Math.max(t.length,e);for(let{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms
11
+ `);return t.join("")}}function Z(t,e){let i=e?URL.parse(t,e):URL.parse(t);return i?.protocol==="http:"||i?.protocol==="https:"}function tt(t){t.preventDefault()}function te(t){t.preventDefault(),t.stopPropagation()}class ti{static #i;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#i||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#i.exec(t);if(!e)return null;let i=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(r+=h,a+=d):"+"===l&&(r-=h,a-=d),new Date(Date.UTC(i,s,n,r,a,o))}}function ts(t,{scale:e=1,rotation:i=0}){let{width:s,height:n}=t.attributes.style;return new W({viewBox:[0,0,parseInt(s),parseInt(n)],userUnit:1,scale:e,rotation:i})}function tn(t){if(t.startsWith("#")){let e=parseInt(t.slice(1),16);return[(0xff0000&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):(A(`Not a valid color format: "${t}"`),[0,0,0])}function tr(t){let{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function ta(t){let{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function to(t,e,i=!1,s=!0){if(e instanceof W){let{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=I.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}class tl{constructor(){const{pixelRatio:t}=tl;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,n=-1){let r=1/0,a=1/0,o=1/0;(i=tl.capPixels(i,n))>0&&(r=Math.sqrt(i/(t*e))),-1!==s&&(a=s/t,o=s/e);let l=Math.min(r,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}let th=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class td{static get isDarkMode(){return _(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class tc{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:i}=window.getComputedStyle(t);return t.remove(),_(this,"commentForegroundColor",tn(i))}}function tu(t,e,i,s){let n=255*(1-(s=Math.min(Math.max(s??1,0),1)));return[t=Math.round(t*s+n),e=Math.round(e*s+n),i=Math.round(i*s+n)]}function tp(t,e){let i=t[0]/255,s=t[1]/255,n=t[2]/255,r=Math.max(i,s,n),a=Math.min(i,s,n),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{let t=r-a;switch(e[1]=o<.5?t/(r+a):t/(2-r-a),r){case i:e[0]=((s-n)/t+6*(s<n))*60;break;case s:e[0]=((n-i)/t+2)*60;break;case n:e[0]=((i-s)/t+4)*60}}e[2]=o}function tg(t,e){let i=t[0],s=t[1],n=t[2],r=(1-Math.abs(2*n-1))*s,a=r*(1-Math.abs(i/60%2-1)),o=n-r/2;switch(Math.floor(i/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o}}function tm(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function tf(t,e,i){tg(t,i),i.map(tm);let s=.2126*i[0]+.7152*i[1]+.0722*i[2];tg(e,i),i.map(tm);let n=.2126*i[0]+.7152*i[1]+.0722*i[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}let tb=new Map;function tA(t,e){let i=t[0]+256*t[1]+65536*t[2]+0x1000000*e[0]+0x100000000*e[1]+0x10000000000*e[2],s=tb.get(i);if(s)return s;let n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);tp(t,a);let o=n.subarray(6,9);tp(e,o);let l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),tf(a,o,r)<h){let t,e;for(l?(t=a[2],e=1):(t=0,e=a[2]);e-t>.005;){let i=a[2]=(t+e)/2;l===tf(a,o,r)<h?t=i:e=i}a[2]=l?e:t}return tg(a,r),s=F.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),tb.set(i,s),s}function tv({html:t,dir:e,className:i},s){let n=document.createDocumentFragment();if("string"==typeof t){let i=document.createElement("p");i.dir=e||"auto";let s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){let n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}n.append(i)}else $.render({xfaHtml:t,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",i),s.append(n)}function ty(t){let e=new Path2D;if(!t)return e;for(let i=0,s=t.length;i<s;)switch(t[i++]){case 0:e.moveTo(t[i++],t[i++]);break;case 1:e.lineTo(t[i++],t[i++]);break;case 2:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case 3:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case 4:e.closePath();break;default:A(`Unrecognized drawing path operator: ${t[i-1]}`)}return e}class tw{static #s=null;static #n=null;static #r=null;static #a=0;static #o=[];get pagesNumber(){return tw.#a}set pagesNumber(t){tw.#a!==t&&(tw.#a=t,0===t&&(tw.#n=null,tw.#s=null))}addListener(t){tw.#o.push(t)}removeListener(t){let e=tw.#o.indexOf(t);e>=0&&tw.#o.splice(e,1)}#l(){for(let t of tw.#o)t()}#h(t){if(tw.#n)return;let e=tw.#a,i=new Uint32Array(3*e),s=tw.#n=i.subarray(0,e),n=tw.#s=i.subarray(e,2*e);if(t)for(let t=0;t<e;t++)s[t]=n[t]=t+1;tw.#r=i.subarray(2*e)}movePages(t,e,i){this.#h(!0);let s=tw.#n,n=tw.#s;tw.#r.set(n);let r=e.length,a=new Uint32Array(r),o=0;for(let t=0;t<r;t++){let n=e[t]-1;a[t]=s[n],n<i&&(o+=1)}let l=tw.#a,h=i-o,d=l-r;h=z(h,0,d);for(let e=0,i=0;e<l;e++)t.has(e+1)||(s[i++]=s[e]);s.copyWithin(h+r,h,d),s.set(a,h);let c=!1;for(let t=0;t<l;t++){let e=s[t];c||=e!==t+1,n[e-1]=t+1}this.#l(),c||(this.pagesNumber=0)}hasBeenAltered(){return null!==tw.#n}getPageMappingForSaving(){return{pageIndices:tw.#s?tw.#s.map(t=>t-1):null}}getPrevPageNumber(t){return tw.#r[tw.#n[t-1]-1]}getPageNumber(t){return tw.#s?.[t-1]??t}getPageId(t){return tw.#n?.[t-1]??t}static get instance(){return _(this,"instance",new tw)}getMapping(){return tw.#n.subarray(0,this.pagesNumber)}}class tx{#d=null;#c=null;#u;#p=null;#g=null;#m=null;#f=null;#b=null;static #A=null;constructor(t){this.#u=t,tx.#A||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#d=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#u._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",tt,{signal:e}),t.addEventListener("pointerdown",tx.#v,{signal:e}));let i=this.#p=document.createElement("div");i.className="buttons",t.append(i);let s=this.#u.toolbarPosition;if(s){let{style:e}=t,i="ltr"===this.#u._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#d}static #v(t){t.stopPropagation()}#y(t){this.#u._focusEventsAllowed=!1,te(t)}#w(t){this.#u._focusEventsAllowed=!0,te(t)}#x(t){let e=this.#u._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#y.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#w.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",tt,{signal:e}),!0)}hide(){this.#d.classList.add("hidden"),this.#c?.hideDropdown()}show(){this.#d.classList.remove("hidden"),this.#g?.shown(),this.#m?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#u,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",tx.#A[t]),this.#x(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#p.append(i)}get #_(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#x(e),this.#p.append(e,this.#_),this.#g=t}addComment(t,e=null){if(this.#m)return;let i=t.renderForToolbar();if(!i)return;this.#x(i);let s=this.#f=this.#_;e?(this.#p.insertBefore(i,e),this.#p.insertBefore(s,e)):this.#p.append(i,s),this.#m=t,t.toolbar=this}addColorPicker(t){if(this.#c)return;this.#c=t;let e=t.renderButton();this.#x(e),this.#p.append(e,this.#_)}async addEditSignatureButton(t){let e=this.#b=await t.renderEditButton(this.#u);this.#x(e),this.#p.append(e,this.#_)}removeButton(t){"comment"===t&&(this.#m?.removeToolbarCommentButton(),this.#m=null,this.#f?.remove(),this.#f=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e)}}async addButtonBefore(t,e,i){if(!e&&"comment"===t)return;let s=this.#p.querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){this.#b&&(this.#b.title=t)}remove(){this.#d.remove(),this.#c?.destroy(),this.#c=null}}class t_{#p=null;#d=null;#C;constructor(t){this.#C=t}#S(){let t=this.#d=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#C._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",tt,{signal:e});let i=this.#p=document.createElement("div");return i.className="buttons",t.append(i),this.#C.hasCommentManager()&&this.#T("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#C.commentSelection("floating_button")}),this.#T("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#C.highlightSelection("floating_button")}),t}#E(t,e){let i=0,s=0;for(let n of t){let t=n.y+n.height;if(t<i)continue;let r=n.x+(e?n.width:0);if(t>i){s=r,i=t;continue}e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){let[s,n]=this.#E(e,i),{style:r}=this.#d||=this.#S();t.append(this.#d),r.insetInlineEnd=`${100*s}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#d.remove()}#T(t,e,i,s){let n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);let r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",i);let a=this.#C._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",tt,{signal:a}),n.addEventListener("click",s,{signal:a})),this.#p.append(n)}}function tC(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class tS{static #M=NaN;static #D=null;static #P=NaN;static #k=null;static initializeAndAddPointerId(t){(tS.#D||=new Set).add(t)}static setPointer(t,e){tS.#M||=e,tS.#k??=t}static setTimeStamp(t){tS.#P=t}static isSamePointerId(t){return tS.#M===t}static isSamePointerIdOrRemove(t){return tS.#M===t||(tS.#D?.delete(t),!1)}static isSamePointerType(t){return tS.#k===t}static isInitializedAndDifferentPointerType(t){return null!==tS.#k&&!tS.isSamePointerType(t)}static isSameTimeStamp(t){return tS.#P===t}static isUsingMultiplePointers(){return tS.#D?.size>=1}static clearPointerType(){tS.#k=null}static clearPointerIds(){tS.#M=NaN,tS.#D=null}static clearTimeStamp(){tS.#P=NaN}}class tT{#I=0;get id(){return`${o}${this.#I++}`}}class tE{#B=O();#I=0;#F=null;static get _isSVGFittingCanvas(){let 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>',_(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 #L(t,e){this.#F||=new Map;let i=this.#F.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#B}_${this.#I++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await V(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=tE._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r});s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){A(t),i=null}return this.#F.set(t,i),i&&this.#F.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:n}=t;return this.#L(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#L(t,t)}async getFromBlob(t,e){let i=await e;return this.#L(t,i)}async getFromId(t){this.#F||=new Map;let e=this.#F.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#F||=new Map;let i=this.#F.get(t);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#B}_${this.#I++}`,refCounter:1,isSvg:!1},this.#F.set(t,i),this.#F.set(i.id,i),i}getSvgUrl(t){let e=this.#F.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#F||=new Map;let e=this.#F.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;let{bitmap:i}=e;if(!e.url&&!e.file){let t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#B}_`)}}class tM{#R=[];#N=!1;#O;#U=-1;constructor(t=128){this.#O=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#N)return;let o={cmd:t,undo:e,post:i,type:n};if(-1===this.#U){this.#R.length>0&&(this.#R.length=0),this.#U=0,this.#R.push(o);return}if(r&&this.#R[this.#U].type===n){a&&(o.undo=this.#R[this.#U].undo),this.#R[this.#U]=o;return}let l=this.#U+1;l===this.#O?this.#R.splice(0,1):(this.#U=l,l<this.#R.length&&this.#R.splice(l)),this.#R.push(o)}undo(){if(-1===this.#U)return;this.#N=!0;let{undo:t,post:e}=this.#R[this.#U];t(),e?.(),this.#N=!1,this.#U-=1}redo(){if(this.#U<this.#R.length-1){this.#U+=1,this.#N=!0;let{cmd:t,post:e}=this.#R[this.#U];t(),e?.(),this.#N=!1}}hasSomethingToUndo(){return -1!==this.#U}hasSomethingToRedo(){return this.#U<this.#R.length-1}cleanType(t){if(-1!==this.#U){for(let e=this.#U;e>=0;e--)if(this.#R[e].type!==t){this.#R.splice(e+1,this.#U-e),this.#U=e;return}this.#R.length=0,this.#U=-1}}destroy(){this.#R=null}}class tD{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=I.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#z(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);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let i=this.callbacks.get(this.#z(e));if(!i)return;let{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;(!a||a(t,e))&&(s.bind(t,...r,e)(),n||te(e))}}class tP{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]),e=document.createElement("span");for(let i of(e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e),t.keys())){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,tn(s))}return e.remove(),_(this,"_colors",t)}convert(t){let e=tn(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return tP._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?F.makeHexColor(...e):t}}class tk{#H=new AbortController;#$=null;#G=null;#j=new Map;#V=new Map;#W=null;#X=null;#q=null;#K=new tM;#Y=null;#Q=null;#J=null;#Z=0;#tt=new Set;#te=null;#ti=null;#ts=new Set;_editorUndoBar=null;#tn=!1;#tr=!1;#ta=!1;#to=null;#tl=null;#th=null;#td=null;#tc=!1;#tu=null;#tp=new tT;#tg=!1;#tm=!1;#tf=!1;#tb=null;#tA=null;#tv=null;#ty=null;#tw=null;#tx=l.NONE;#t_=new Set;#tC=null;#tS=null;#tT=null;#tE=null;#tM=null;#tD={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#tP=[0,0];#tk=null;#tI=null;#tB=null;#tF=null;#tL=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tk.prototype,e=t=>t.#tI.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return _(this,"_keyboardManager",new tD([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["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:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tI.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tI.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,r,a,o,l,h,d,c,u,p,g,m){const f=this._signal=this.#H.signal;this.#tI=t,this.#tB=e,this.#tF=i,this.#W=s,this.#Y=n,this.#tS=r,this.#tM=o,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:f}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),a._on("setpreference",this.onSetPreference.bind(this),{signal:f}),a._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:f}),a._on("pagesedited",this.onPagesEdited.bind(this),{signal:f}),window.addEventListener("pointerdown",()=>{this.#tm=!0},{capture:!0,signal:f}),window.addEventListener("pointerup",()=>{this.#tm=!1},{capture:!0,signal:f}),this.#tR(),this.#tN(),this.#tO(),this.#X=o.annotationStorage,this.#to=o.filterFactory,this.#tT=l,this.#td=h||null,this.#tn=d,this.#tr=c,this.#ta=u,this.#tw=p||null,this.viewParameters={realScale:j.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==m,n?.setSidebarUiManager(this)}destroy(){for(let t of(this.#tL?.resolve(),this.#tL=null,this.#H?.abort(),this.#H=null,this._signal=null,this.#V.values()))t.destroy();this.#V.clear(),this.#j.clear(),this.#ts.clear(),this.#ty?.clear(),this.#$=null,this.#t_.clear(),this.#K.destroy(),this.#W?.destroy(),this.#Y?.destroy(),this.#tS?.destroy(),this.#tu?.hide(),this.#tu=null,this.#tv?.destroy(),this.#tv=null,this.#G=null,this.#tl&&(clearTimeout(this.#tl),this.#tl=null),this.#tk&&(clearTimeout(this.#tk),this.#tk=null),this._editorUndoBar?.destroy(),this.#tM=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#tw}get useNewAltTextFlow(){return this.#tr}get useNewAltTextWhenAddingImage(){return this.#ta}get hcmFilter(){return _(this,"hcmFilter",this.#tT?this.#to.addHCMFilter(this.#tT.foreground,this.#tT.background):"none")}get direction(){return _(this,"direction",getComputedStyle(this.#tI).direction)}get _highlightColors(){return _(this,"_highlightColors",this.#td?new Map(this.#td.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return _(this,"highlightColors",null);let e=new Map,i=!!this.#tT;for(let[s,n]of t){let t=s.endsWith("_HCM");if(i&&t){e.set(s.replace("_HCM",""),n);continue}i||t||e.set(s,n)}return _(this,"highlightColors",e)}get highlightColorNames(){return _(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#J=t}setMainHighlightColorPicker(t){this.#tv=t}editAltText(t,e=!1){this.#W?.editAltText(this,t,e)}hasCommentManager(){return!!this.#Y}editComment(t,e,i,s){this.#Y?.showDialog(this,t,e,i,s)}selectComment(t,e){let i=this.#V.get(t),s=i?.getEditorByUID(e);s?.toggleComment(!0,!0)}updateComment(t){this.#Y?.updateComment(t.getData())}updatePopupColor(t){this.#Y?.updatePopupColor(t)}removeComment(t){this.#Y?.removeComments([t.uid])}deleteComment(t,e){let i=()=>{t.comment=e},s=()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:s,undo:i,mustExec:!0})}toggleComment(t,e,i){this.#Y?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#Y?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#Y?.dialogElement||null}async waitForEditorsRendered(t){if(this.#V.has(t-1))return;let{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s),await i}getSignature(t){this.#tS?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#tS}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){"enableNewAltTextWhenAddingImage"===t&&(this.#ta=e)}onPagesEdited({pagesMapper:t}){for(let e of this.#j.values())e.updatePageIndex(t.getPrevPageNumber(e.pageIndex+1)-1);let e=this.#V,i=this.#V=new Map;for(let[s,n]of e){let e=t.getPrevPageNumber(s+1)-1;if(-1===e){n.destroy();continue}i.set(e,n),n.updatePageIndex(e)}}onPageChanging({pageNumber:t}){this.#Z=t-1}focusMainContainer(){this.#tI.focus()}findParent(t,e){for(let i of this.#V.values()){let{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#tB.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#ts.add(t)}removeShouldRescale(t){this.#ts.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*j.PDF_TO_CSS_UNITS,this.#ts))e.onScaleChanging();this.#J?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tU({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#tz(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#V.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a}=i,o=i.toString(),h=this.#tU(i).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;i.empty();let c=this.#tz(h),u=this.#tx===l.NONE,p=()=>{let i=c?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a,text:o});u&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};u?this.switchToMode(l.HIGHLIGHT,p):p()}commentSelection(t=""){this.highlightSelection(t,!0)}#tH(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tU(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#tu||=new t_(this),this.#tu.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#X)return null;let e=`${o}${t}`,i=this.#X.getRawValue(e);return i&&this.#X.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#X||this.#X.has(t.id)||this.#X.setValue(t.id,t)}a11yAlert(t,e=null){let i=this.#tF;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#t$(){let t=document.getSelection();if(!t||t.isCollapsed){this.#tC&&(this.#tu?.hide(),this.#tC=null,this.#tG({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#tC)return;let i=this.#tU(t).closest(".textLayer");if(!i){this.#tC&&(this.#tu?.hide(),this.#tC=null,this.#tG({hasSelectedText:!1}));return}if(this.#tu?.hide(),this.#tC=e,this.#tG({hasSelectedText:!0}),(this.#tx===l.HIGHLIGHT||this.#tx===l.NONE)&&(this.#tx===l.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#tc=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this.#tx===l.HIGHLIGHT?this.#tz(i):null;if(t?.toggleDrawing(),this.#tm){let e=new AbortController,i=this.combinedSignal(e),s=i=>{("pointerup"!==i.type||0===i.button)&&(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#tj("main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else t?.toggleDrawing(!0),this.#tj("main_toolbar")}}#tj(t=""){this.#tx===l.HIGHLIGHT?this.highlightSelection(t):this.#tn&&this.#tH()}#tR(){document.addEventListener("selectionchange",this.#t$.bind(this),{signal:this._signal})}#tV(){if(this.#th)return;this.#th=new AbortController;let t=this.combinedSignal(this.#th);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#tW(){this.#th?.abort(),this.#th=null}blur(){if(this.isShiftKeyDown=!1,this.#tc&&(this.#tc=!1,this.#tj("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#t_)if(e.div.contains(t)){this.#tA=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#tA)return;let[t,e]=this.#tA;this.#tA=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tO(){if(this.#tb)return;this.#tb=new AbortController;let t=this.combinedSignal(this.#tb);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#tX(){this.#tb?.abort(),this.#tb=null}#tq(){if(this.#Q)return;this.#Q=new AbortController;let t=this.combinedSignal(this.#Q);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#tK(){this.#Q?.abort(),this.#Q=null}#tN(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tO(),this.setEditingState(!0)}removeEditListeners(){this.#tX(),this.setEditingState(!1)}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#ti)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#ti)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#$?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#t_){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#ti)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){A(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=await s.deserialize(e);if(!i)return;t.push(i)}let e=()=>{for(let e of t)this.#tY(e);this.#tQ(t)};this.addCommands({cmd:e,undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){A(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#tx===l.NONE||this.isEditorHandlingKeyboard||tk._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#tc&&(this.#tc=!1,this.#tj("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}#tG(t){Object.entries(t).some(([t,e])=>this.#tD[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#tD,t)}),this.#tx===l.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tJ([[h.HIGHLIGHT_FREE,!0]]))}#tJ(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tV(),this.#tq(),this.#tG({isEditing:this.#tx!==l.NONE,isEmpty:this.#tZ(),hasSomethingToUndo:this.#K.hasSomethingToUndo(),hasSomethingToRedo:this.#K.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#tW(),this.#tK(),this.#tG({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#ti)for(let e of(this.#ti=t,this.#ti))this.#tJ(e.defaultPropertiesToUpdate)}getId(){return this.#tp.id}get currentLayer(){return this.#V.get(this.#Z)}getLayer(t){return this.#V.get(t)}get currentPageIndex(){return this.#Z}addLayer(t){this.#V.set(t.pageIndex,t),this.#tg?t.enable():t.disable()}removeLayer(t){this.#V.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,n=!1,r=!1){if(this.#tx!==t&&(!this.#tL||(await this.#tL.promise,this.#tL))){if(this.#tL=Promise.withResolvers(),this.#J?.commitOrRemove(),this.#tx===l.POPUP&&this.#Y?.hideSidebar(),this.#Y?.destroyPopup(),this.#tx=t,t===l.NONE){for(let t of(this.setEditingState(!1),this.#t0(),this.#j.values()))t.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#tL.resolve();return}for(let t of this.#j.values())t.addStandaloneCommentButton();for(let e of(t===l.SIGNATURE&&await this.#tS?.loadSignatures(),i&&tS.clearPointerType(),this.setEditingState(!0),await this.#t1(),this.unselectAll(),this.#V.values()))e.updateMode(t);if(t===l.POPUP){this.#G||=await this.#tM.getAnnotationsByType(new Set(this.#ti.map(t=>t._editorType)));let t=new Set,e=[];for(let i of this.#j.values()){let{annotationElementId:s,hasComment:n,deleted:r}=i;s&&t.add(s),n&&!r&&e.push(i.getData())}for(let i of this.#G){let{id:s,popupRef:n,contentsObj:r}=i;n&&r?.str&&!t.has(s)&&!this.#tt.has(s)&&e.push(i)}this.#Y?.showSidebar(e)}if(!e){s&&this.addNewEditorFromKeyboard(),this.#tL.resolve();return}for(let t of this.#j.values())t.uid===e?(this.setSelected(t),r?t.editComment():n?t.enterInEditMode():t.focus()):t.unselect();this.#tL.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#tx&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#ti){switch(t){case h.CREATE:this.currentLayer.addNewEditor(e);return;case h.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#tE||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(let i of this.#t_)i.updateParams(t,e);else for(let i of this.#ti)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#j.values())i.editorType===t&&i.show(e);(this.#tE?.get(h.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tJ([[h.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tf!==t)for(let e of(this.#tf=t,this.#V.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}async #t1(){if(!this.#tg){this.#tg=!0;let t=[];for(let e of this.#V.values())t.push(e.enable());for(let e of(await Promise.all(t),this.#j.values()))e.enable()}}#t0(){if(this.unselectAll(),this.#tg){for(let t of(this.#tg=!1,this.#V.values()))t.disable();for(let t of this.#j.values())t.disable()}}*getEditors(t){for(let e of this.#j.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#j.get(t)}addEditor(t){this.#j.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#tl&&clearTimeout(this.#tl),this.#tl=setTimeout(()=>{this.focusMainContainer(),this.#tl=null},0)),this.#j.delete(t.id),t.annotationElementId&&this.#ty?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#tt.has(t.annotationElementId)||this.#X?.remove(t.id)}addDeletedAnnotationElement(t){this.#tt.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#tt.has(t)}removeDeletedAnnotationElement(t){this.#tt.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tY(t){let e=this.#V.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#$!==t&&(this.#$=t,t&&this.#tJ(t.propertiesToUpdate))}get #t2(){let t=null;for(t of this.#t_);return t}updateUI(t){this.#t2===t&&this.#tJ(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#tJ(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#t_.has(t)){this.#t_.delete(t),t.unselect(),this.#tG({hasSelectedEditor:this.hasSelection});return}this.#t_.add(t),t.select(),this.#tJ(t.propertiesToUpdate),this.#tG({hasSelectedEditor:!0})}setSelected(t){for(let e of(this.updateToolbar({mode:t.mode,editId:t.uid}),this.#J?.commitOrRemove(),this.#t_))e!==t&&e.unselect();this.#t_.clear(),this.#t_.add(t),t.select(),this.#tJ(t.propertiesToUpdate),this.#tG({hasSelectedEditor:!0})}isSelected(t){return this.#t_.has(t)}get firstSelectedEditor(){return this.#t_.values().next().value}unselect(t){t.unselect(),this.#t_.delete(t),this.#tG({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#t_.size}get isEnterHandled(){return 1===this.#t_.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#K.undo(),this.#tG({hasSomethingToUndo:this.#K.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#tZ()}),this._editorUndoBar?.hide()}redo(){this.#K.redo(),this.#tG({hasSomethingToUndo:!0,hasSomethingToRedo:this.#K.hasSomethingToRedo(),isEmpty:this.#tZ()})}addCommands(t){this.#K.add(t),this.#tG({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#tZ()})}cleanUndoStack(t){this.#K.cleanType(t)}#tZ(){if(0===this.#j.size)return!0;if(1===this.#j.size)for(let t of this.#j.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#t_],i=()=>{for(let t of(this._editorUndoBar?.show(s,1===e.length?e[0].editorType:e.length),e))t.remove()},s=()=>{for(let t of e)this.#tY(t)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#$?.commitOrRemove()}hasSomethingToControl(){return this.#$||this.hasSelection}#tQ(t){for(let t of this.#t_)t.unselect();for(let e of(this.#t_.clear(),t))e.isEmpty()||(this.#t_.add(e),e.select());this.#tG({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#t_)t.commit();this.#tQ(this.#j.values())}unselectAll(){if(!this.#$||(this.#$.commitOrRemove(),this.#tx===l.NONE)){if(!this.#J?.commitOrRemove()&&this.hasSelection){for(let t of this.#t_)t.unselect();this.#t_.clear(),this.#tG({hasSelectedEditor:!1})}}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#tP[0]+=t,this.#tP[1]+=e;let[s,n]=this.#tP,r=[...this.#t_];for(let i of(this.#tk&&clearTimeout(this.#tk),this.#tk=setTimeout(()=>{this.#tk=null,this.#tP[0]=this.#tP[1]=0,this.addCommands({cmd:()=>{for(let t of r)this.#j.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(let t of r)this.#j.has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})},1e3),r))i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#te=new Map,this.#t_))this.#te.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#te)return!1;this.disableUserSelect(!1);let t=this.#te;this.#te=null;let e=!1;for(let[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#j.has(t.id)){let n=this.#V.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(let[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#te)for(let i of this.#te.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let 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.#t_.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#$===t}getActive(){return this.#$}getMode(){return this.#tx}isEditingMode(){return this.#tx!==l.NONE}get imageManager(){return _(this,"imageManager",new tE)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:s,y:n,width:r,height:a}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-n)/a,y:1-(t+i-s)/r,width:o/a,height:i/r});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-s)/r,y:1-(e+o-n)/a,width:i/r,height:o/a});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-n)/a,y:(t-s)/r,width:o/a,height:i/r});break;default:e=(t,e,i,o)=>({x:(t-s)/r,y:(e-n)/a,width:i/r,height:o/a})}let o=[];for(let t=0,s=i.rangeCount;t<s;t++){let s=i.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:i,width:n,height:r}of s.getClientRects())0!==n&&0!==r&&o.push(e(t,i,n,r))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#q||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#q?.delete(t)}renderAnnotationElement(t){let e=this.#q?.get(t.data.id);if(!e)return;let i=this.#X.getRawValue(e);!i||(this.#tx!==l.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){let s=this.#ty?.get(t);s&&(s.setCanvas(e,i),this.#ty.delete(t))}addMissingCanvas(t,e){(this.#ty||=new Map).set(t,e)}}class tI{#g=null;#t3=!1;#t5=null;#t4=null;#t6=null;#t8=null;#t7=!1;#t9=null;#u=null;#et=null;#ee=null;#ei=!1;static #es=null;static _l10n=null;constructor(t){this.#u=t,this.#ei=t._uiManager.useNewAltTextFlow,tI.#es||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){tI._l10n??=t}async render(){let t=this.#t5=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#t4=document.createElement("span");t.append(e),this.#ei?(t.classList.add("new"),t.setAttribute("data-l10n-id",tI.#es.missing),e.setAttribute("data-l10n-id",tI.#es["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#u._uiManager._signal;t.addEventListener("contextmenu",tt,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#u._uiManager.editAltText(this.#u),this.#ei&&this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#en}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#t7=!0,s(e))},{signal:i}),await this.#er(),t}get #en(){return this.#g&&"added"||null===this.#g&&this.guessedText&&"review"||"missing"}finish(){this.#t5&&(this.#t5.focus({focusVisible:this.#t7}),this.#t7=!1)}isEmpty(){return this.#ei?null===this.#g:!this.#g&&!this.#t3}hasData(){return this.#ei?null!==this.#g||!!this.#et:this.isEmpty()}get guessedText(){return this.#et}async setGuessedText(t){null===this.#g&&(this.#et=t,this.#ee=await tI._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#er())}toggleAltTextBadge(t=!1){if(!this.#ei||this.#g){this.#t9?.remove(),this.#t9=null;return}if(!this.#t9){let t=this.#t9=document.createElement("div");t.className="noAltTextBadge",this.#u.div.append(t)}this.#t9.classList.toggle("hidden",!t)}serialize(t){let e=this.#g;return t||this.#et!==e||(e=this.#ee),{altText:e,decorative:this.#t3,guessedText:this.#et,textWithDisclaimer:this.#ee}}get data(){return{altText:this.#g,decorative:this.#t3}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#et=i,this.#ee=s),(this.#g!==t||this.#t3!==e)&&(n||(this.#g=t,this.#t3=e),this.#er())}toggle(t=!1){this.#t5&&(!t&&this.#t8&&(clearTimeout(this.#t8),this.#t8=null),this.#t5.disabled=!t)}shown(){this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#en}})}destroy(){this.#t5?.remove(),this.#t5=null,this.#t4=null,this.#t6=null,this.#t9?.remove(),this.#t9=null}async #er(){let t=this.#t5;if(!t)return;if(this.#ei){if(t.classList.toggle("done",!!this.#g),t.setAttribute("data-l10n-id",tI.#es[this.#en]),this.#t4?.setAttribute("data-l10n-id",tI.#es[`${this.#en}-label`]),!this.#g)return void this.#t6?.remove()}else{if(!this.#g&&!this.#t3){t.classList.remove("done"),this.#t6?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#t6;if(!e){this.#t6=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#u.id}`;let i=this.#u._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#t8),this.#t8=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#t8=setTimeout(()=>{this.#t8=null,this.#t6.classList.add("show"),this.#u._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#t8&&(clearTimeout(this.#t8),this.#t8=null),this.#t6?.classList.remove("show")},{signal:i})}this.#t3?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#g),e.parentNode||t.append(e);let i=this.#u.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class tB{#ea=null;#eo=null;#el=!1;#u=null;#eh=null;#ed=null;#ec=null;#eu=null;#ep=!1;#eg=null;constructor(t){this.#u=t}renderForToolbar(){let t=this.#eo=document.createElement("button");return t.className="comment",this.#S(t,!1)}renderForStandalone(){let t=this.#ea=document.createElement("button");t.className="annotationCommentButton";let e=this.#u.commentButtonPosition;if(e){let{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#u._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let s=this.#u.commentButtonColor;s&&(i.backgroundColor=s)}return this.#S(t,!0)}focusButton(){setTimeout(()=>{(this.#ea??this.#eo)?.focus()},0)}onUpdatedColor(){if(!this.#ea)return;let t=this.#u.commentButtonColor;t&&(this.#ea.style.backgroundColor=t),this.#u._uiManager.updatePopupColor(this.#u)}get commentButtonWidth(){return(this.#ea?.getBoundingClientRect().width??0)/this.#u.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#eg)return this.#eg;if(!this.#ea)return null;let{x:t,y:e,height:i}=this.#ea.getBoundingClientRect(),{x:s,y:n,width:r,height:a}=this.#u.parent.boundingClientRect;return[(t-s)/r,(e+i-n)/a]}set commentPopupPositionInLayer(t){this.#eg=t}hasDefaultPopupPosition(){return null===this.#eg}removeStandaloneCommentButton(){this.#ea?.remove(),this.#ea=null}removeToolbarCommentButton(){this.#eo?.remove(),this.#eo=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#ea&&(this.#ea.classList.toggle("selected",t),this.#ea.ariaExpanded=e)}#S(t,e){if(!this.#u._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#u._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));let i=this.#u._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",tt,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#u._focusEventsAllowed=!1,te(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#u._focusEventsAllowed=!0,te(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=e=>{e.preventDefault(),t===this.#eo?this.edit():this.#u.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#el=!0,s(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#u.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#u.toggleComment(!1,!1)},{signal:i}),t}edit(t){let e,i,s=this.commentPopupPositionInLayer;if(s)[e,i]=s;else{[e,i]=this.#u.commentButtonPosition;let{width:t,height:s,x:n,y:r}=this.#u;e=n+e*t,i=r+i*s}let n=this.#u.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;this.#u._uiManager.editComment(this.#u,r+e*o,a+i*l,{...t,parentDimensions:n})}finish(){this.#eo&&(this.#eo.focus({focusVisible:this.#el}),this.#el=!1)}isDeleted(){return this.#ep||""===this.#ec}isEmpty(){return null===this.#ec}hasBeenEdited(){return this.isDeleted()||this.#ec!==this.#eh}serialize(){return this.data}get data(){return{text:this.#ec,richText:this.#ed,date:this.#eu,deleted:this.isDeleted()}}set data(t){if(t!==this.#ec&&(this.#ed=null),null===t){this.#ec="",this.#ep=!0;return}this.#ec=t,this.#eu=new Date,this.#ep=!1}restoreData({text:t,richText:e,date:i}){this.#ec=t,this.#ed=e,this.#eu=i,this.#ep=!1}setInitialText(t,e=null){this.#eh=t,this.data=t,this.#eu=null,this.#ed=e}shown(){}destroy(){this.#eo?.remove(),this.#eo=null,this.#ea?.remove(),this.#ea=null,this.#ec="",this.#ed=null,this.#eu=null,this.#u=null,this.#el=!1,this.#ep=!1}}class tF{#tI;#em=!1;#ef=null;#eb;#eA;#ev;#ey;#ew=null;#ex;#e_=null;#eC;#eS=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#tI=t,this.#ef=i,this.#eb=e,this.#eA=s,this.#ev=n,this.#ey=r,this.#eC=new AbortController,this.#ex=AbortSignal.any([a,this.#eC.signal]),t.addEventListener("touchstart",this.#eT.bind(this),{passive:!1,signal:this.#ex})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/tl.pixelRatio}#eT(t){if(this.#eb?.())return;if(1===t.touches.length){if(this.#ew)return;let t=this.#ew=new AbortController,e=AbortSignal.any([this.#ex,t.signal]),i=this.#tI,s={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#ew?.abort(),this.#ew=null)};i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(te(t),n(t))},s),i.addEventListener("pointerup",n,s),i.addEventListener("pointercancel",n,s);return}if(!this.#eS){this.#eS=new AbortController;let t=AbortSignal.any([this.#ex,this.#eS.signal]),e=this.#tI,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#eE.bind(this),i);let s=this.#eM.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",te,i),e.addEventListener("pointermove",te,i),e.addEventListener("pointercancel",te,i),e.addEventListener("pointerup",te,i),this.#eA?.()}if(te(t),2!==t.touches.length||this.#ef?.()){this.#e_=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#e_={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#eE(t){if(!this.#e_||2!==t.touches.length)return;te(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:s,screenY:n}=e,{screenX:r,screenY:a}=i,o=this.#e_,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=Math.hypot(r-s,a-n)||1,p=Math.hypot(d-l,c-h)||1;if(!this.#em&&Math.abs(p-u)<=tF.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=n,o.touch1X=r,o.touch1Y=a,!this.#em){this.#em=!0;return}let g=[(s+r)/2,(n+a)/2];this.#ev?.(g,p,u)}#eM(t){t.touches.length>=2||(this.#eS&&(this.#eS.abort(),this.#eS=null,this.#ey?.()),this.#e_&&(te(t),this.#e_=null,this.#em=!1))}destroy(){this.#eC?.abort(),this.#eC=null,this.#ew?.abort(),this.#ew=null}}class tL{#eD=null;#eP=null;#g=null;#m=null;#ea=null;#ek=!1;#eI=null;#eB="";#eF=null;#eL=null;#eR=null;#eN=null;#eO=null;#eU="";#ez=!1;#eH=null;#e$=!1;#eG=!1;#ej=!1;#eV=null;#eW=0;#eX=0;#eq=null;#eK=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#eY=!1;#eQ=tL._zIndex++;static _borderLineWidth=-1;static _colorManager=new tP;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=tL.prototype._resizeWithKeyboard,e=tk.TRANSLATE_SMALL,i=tk.TRANSLATE_BIG;return _(this,"_resizerKeyboardManager",new tD([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],tL.prototype._stopResizingWithKeyboard]]))}constructor(t){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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return _(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new tR({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){if(tL._l10n??=t,tL._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==tL._borderLineWidth)return;let i=getComputedStyle(document.documentElement);tL._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){v("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#eY}set _isDraggable(t){this.#eY=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[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.#eQ}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#eJ(),this.#eN?.remove(),this.#eN=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ez?this.#ez=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let e=t.relatedTarget;!e?.closest(`#${this.id}`)&&(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){let[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#eZ([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#eZ(this.parentDimensions,t,e)}translateInPage(t,e){this.#eH||=[this.x,this.y,this.width,this.height],this.#eZ(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#eH||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{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:r,y:a}=this,[o,l]=this.getBaseTranslation();r+=o,a+=l;let{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#eH&&(this.#eH[0]!==this.x||this.#eH[1]!==this.y)}get _hasBeenResized(){return!!this.#eH&&(this.#eH[2]!==this.width||this.#eH[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=tL,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,s]}=this,{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=z(n,0,i-a),r=z(r,0,s-o);break;case 90:n=z(n,0,i-o),r=z(r,a,s);break;case 180:n=z(n,a,i),r=z(r,o,s);break;case 270:n=z(n,o,i),r=z(r,0,s-a)}this.x=n/=i,this.y=r/=s;let[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static #e0(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return tL.#e0(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return tL.#e0(t,e,360-this.parentRotation)}#e1(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[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(){let{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){let{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#e2(){if(this.#eF)return;this.#eF=document.createElement("div"),this.#eF.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#eF.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#e3.bind(this,i),{signal:e}),t.addEventListener("contextmenu",tt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#eF)}#e3(t,e){e.preventDefault();let{isMac:i}=I.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#g?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#eL=[e.screenX,e.screenY];let n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#e5.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",te,{passive:!1,signal:r}),window.addEventListener("contextmenu",tt,{signal:r}),this.#eR={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#g?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#e4()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#e6(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#e4(){if(!this.#eR)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#eR;this.#eR=null;let n=this.x,r=this.y,a=this.width,o=this.height;(n!==t||r!==e||a!==i||o!==s)&&this.addCommands({cmd:this.#e6.bind(this,n,r,a,o),undo:this.#e6.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#e5(t,e){let i,s,n,r,a,o,[l,h]=this.parentDimensions,d=this.x,c=this.y,u=this.width,p=this.height,g=tL.MIN_SIZE/l,m=tL.MIN_SIZE/h,f=this.#e1(this.rotation),b=(t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e],A=this.#e1(360-this.rotation),v=!1,y=!1;switch(t){case"topLeft":v=!0,i=(t,e)=>[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":v=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":y=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":v=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":v=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":y=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let w=i(u,p),x=s(u,p),_=b(...x),C=tL._round(d+_[0]),S=tL._round(c+_[1]),T=1,E=1;if(e.fromKeyboard)({deltaX:n,deltaY:r}=e);else{let{screenX:t,screenY:i}=e,[s,a]=this.#eL;[n,r]=this.screenToPageTranslation(t-s,i-a),this.#eL[0]=t,this.#eL[1]=i}if([n,r]=(a=n/l,o=r/h,[A[0]*a+A[2]*o,A[1]*a+A[3]*o]),v){let t=Math.hypot(u,p);T=E=Math.max(Math.min(Math.hypot(x[0]-w[0]-n,x[1]-w[1]-r)/t,1/u,1/p),g/u,m/p)}else y?T=z(Math.abs(x[0]-w[0]-n),g,1)/u:E=z(Math.abs(x[1]-w[1]-r),m,1)/p;let M=tL._round(u*T),D=tL._round(p*E),P=C-(_=b(...s(M,D)))[0],k=S-_[1];this.#eH||=[this.x,this.y,this.width,this.height],this.width=M,this.height=D,this.x=P,this.y=k,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#g?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#eG)return this._editToolbar;this._editToolbar=new tx(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#g?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return!this.#g&&(tI.initialize(tL._l10n),this.#g=new tI(this),this.#eD&&(this.#g.data=this.#eD,this.#eD=null)),this.#g}get altTextData(){return this.#g?.data}set altTextData(t){this.#g&&(this.#g.data=t)}get guessedAltText(){return this.#g?.guessedText}async setGuessedAltText(t){await this.#g?.setGuessedText(t)}serializeAltText(t){return this.#g?.serialize(t)}hasAltText(){return!!this.#g&&!this.#g.isEmpty()}hasAltTextData(){return this.#g?.hasData()??!1}focusCommentButton(){this.#m?.focusButton()}addCommentButton(){return this.canAddComment?this.#m||=new tB(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#ea){this._uiManager.isEditingMode()&&this.#ea.classList.remove("hidden");return}this.hasComment&&(this.#ea=this.#m.renderForStandalone(),this.div.append(this.#ea))}}removeStandaloneCommentButton(){this.#m.removeStandaloneCommentButton(),this.#ea=null}hideStandaloneCommentButton(){this.#ea?.classList.add("hidden")}get comment(){if(!this.#m)return null;let{data:{richText:t,text:e,date:i,deleted:s}}=this.#m;return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#m||=new tB(this),"object"==typeof t&&null!==t?this.#m.restoreData(t):this.#m.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e||(this.#m||=new tB(this),this.#m.setInitialText(t,i),!this.annotationElementId))return;let s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#m?.hasBeenEdited()}get hasDeletedComment(){return this.#m?.isDeleted()}get hasComment(){return!!this.#m&&!this.#m.isEmpty()&&!this.#m.isDeleted()}async editComment(t){this.#m||=new tB(this),this.#m.edit(t)}toggleComment(t,e){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#m.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,e]=t.rect,[i]=this.pageDimensions,[s]=this.pageTranslation,n=s+i+1;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[n,e-100,n+180,e]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#m.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#ek?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#e8();let[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);let[s,n]=this.getInitialTranslation();return this.translate(s,n),tC(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#eK||=new tF({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#e7.bind(this),onPinching:this.#e9.bind(this),onPinchEnd:this.#it.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#e7(){this.#eR={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#g?.toggle(!1),this.parent.togglePointerEvents(!1)}#e9(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;let n=this.#e1(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height;s=Math.max(Math.min(s,1/d,1/c),tL.MIN_SIZE/a/d,tL.MIN_SIZE/o/c);let u=tL._round(d*s),p=tL._round(c*s);if(u===d&&p===c)return;this.#eH||=[l,h,d,c];let g=r(d/2,c/2),m=tL._round(l+g[0]),f=tL._round(h+g[1]),b=r(u/2,p/2);this.x=m-b[0],this.y=f-b[1],this.width=u,this.height=p,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#it(){this.#g?.toggle(!0),this.parent.togglePointerEvents(!0),this.#e4()}pointerdown(t){let{isMac:e}=I.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ez=!0,this._isDraggable)?this.#ie(t):this.#ii(t)}#ii(t){let{isMac:e}=I.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#ie(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),this.#eI=null,this.#ez=!1,this._uiManager.endDragSession()||this.#ii(t),i&&this._onStopDragging()};e&&(this.#eW=t.clientX,this.#eX=t.clientY,this.#eI=t.pointerId,this.#eB=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#eI)return void te(t);let[r,a]=this.screenToPageTranslation(e-this.#eW,s-this.#eX);this.#eW=e,this.#eX=s,this._uiManager.dragSelectedEditors(r,a)},r),window.addEventListener("touchmove",te,r),window.addEventListener("pointerdown",t=>{t.pointerType===this.#eB&&(this.#eK||t.isPrimary)&&a(t),te(t)},r));let o=t=>{this.#eI&&this.#eI!==t.pointerId?te(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#eV&&clearTimeout(this.#eV),this.#eV=setTimeout(()=>{this.#eV=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){let s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[d+l+a,r-c-h-p+o,d+l+u+a,r-c-h+o];case 90:return[d+h+a,r-c+l+o,d+h+p+a,r-c+l+u+o];case 180:return[d-l-u+a,r-c+h+o,d-l+a,r-c+h+p+o];case 270:return[d-h-p+a,r-c-l-u+o,d-h+a,r-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&tL._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#m?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:i,opacity:s,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!n,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#eG=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#eG=!1,!0)}isInEditMode(){return this.#eG}shouldGetKeyboardEvents(){return this.#ej}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#e8(){if(this.#eO||!this.div)return;this.#eO=new AbortController;let t=this._uiManager.combinedSignal(this.#eO);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#e8()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){let s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#eD=t.accessibilityData,s._isCopy=t.isCopy||!1;let[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#eO?.abort(),this.#eO=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#eV&&(clearTimeout(this.#eV),this.#eV=null),this.#eJ(),this.removeEditToolbar(),this.#eq){for(let t of this.#eq.values())clearTimeout(t);this.#eq=null}this.parent=null,this.#eK?.destroy(),this.#eK=null,this.#eN?.remove(),this.#eN=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#e2(),this.#eF.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[i,s,n,r]=this.getPDFRect();return[tL._round(i+(n-i)*t),tL._round(s+(r-s)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#m.commentPopupPositionInLayer}set commentPopupPosition(t){this.#m.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#m.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#m.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#m?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#eR={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#eF.children;if(!this.#eP){this.#eP=Array.from(e);let t=this.#is.bind(this),i=this.#ir.bind(this),s=this._uiManager._signal;for(let e of this.#eP){let n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#ia.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",tL._l10nResizer[n])}}let i=this.#eP[0],s=0;for(let t of e){if(t===i)break;s++}let n=(360-this.rotation+this.parentRotation)%360/90*(this.#eP.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#eF.append(this.#eF.firstElementChild);else if(n>s)for(let t=0;t<n-s;t++)this.#eF.firstElementChild.before(this.#eF.lastElementChild);let t=0;for(let i of e){let e=this.#eP[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",tL._l10nResizer[e])}}this.#io(0),this.#ej=!0,this.#eF.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#is(t){tL._resizerKeyboardManager.exec(this,t)}#ir(t){this.#ej&&t.relatedTarget?.parentNode!==this.#eF&&this.#eJ()}#ia(t){this.#eU=this.#ej?t:""}#io(t){if(this.#eP)for(let e of this.#eP)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#ej&&this.#e5(this.#eU,{deltaX:t,deltaY:e,fromKeyboard:!0})}#eJ(){this.#ej=!1,this.#io(-1),this.#e4()}_stopResizingWithKeyboard(){this.#eJ(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar)?(this._editToolbar?.show(),this.#g?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#eF?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#g?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#e$}set isEditing(t){this.#e$=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}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.#eq||=new Map;let{action:e}=t,i=this.#eq.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#eq.delete(e),0===this.#eq.size&&(this.#eq=null)},tL._telemetryTimeout),this.#eq.set(e,i);return}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.#ek=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ek=!0}updateFakeAnnotationElement(t){if(!this.#eN&&!this.deleted){this.#eN=t.addFakeAnnotation(this);return}if(this.deleted){this.#eN.remove(),this.#eN=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#eN.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class tR extends tL{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}class tN{constructor(t){this.h1=t?0|t:0xc3d2e1f0,this.h2=t?0|t:0xc3d2e1f0}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){let n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s),a=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<s;t++)1&t?(l^=a=0x1b873593*(a=(a=0xcc9e2d51*(a=r[t])&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(h^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=r[t])&0xffff0000|11601*o&65535)<<15|o>>>17)&0xffff0000|13715*o&65535,h=5*(h=h<<13|h>>>19)+0xe6546b64);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=0x1b873593*(a=(a=0xcc9e2d51*a&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=0xff51afd7*e&0xffff0000|((e<<16|(t=0xed558ccd*t&0xffff0000|36045*t&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,t^=e>>>1,e=0xc4ceb9fe*e&0xffff0000|((e<<16|(t=0x1a85ec53*t&0xffff0000|60499*t&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let tO=Object.freeze({map:null,hash:"",transfer:void 0});class tU{#il=!1;#ih=null;#id=null;#ic=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let i=this.#ic.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#ic.get(t)}remove(t){let e=this.#ic.get(t);if(void 0!==e&&(e instanceof tL&&this.#id.delete(e.annotationElementId),this.#ic.delete(t),0===this.#ic.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(let t of this.#ic.values())if(t instanceof tL)return;this.onAnnotationEditor(null)}}setValue(t,e){let i=this.#ic.get(t),s=!1;if(void 0!==i)for(let[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#ic.set(t,e);s&&this.#iu(),e instanceof tL&&((this.#id||=new Map).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#ic.has(t)}get size(){return this.#ic.size}#iu(){this.#il||(this.#il=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#il&&(this.#il=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new tz(this)}get serializable(){if(0===this.#ic.size)return tO;let t=new Map,e=new tN,i=[],s=Object.create(null),n=!1;for(let[i,r]of this.#ic){let a=r instanceof tL?r.serialize(!1,s):r;r.page&&(r.pageIndex=r.page._pageIndex,delete r.page),a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),n||=!!a.bitmap)}if(n)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:tO}get editorStats(){let t=null,e=new Map,i=0,s=0;for(let n of this.#ic.values()){if(!(n instanceof tL)){n.popup&&(n.popup.deleted?s+=1:i+=1);continue}n.isCommentDeleted?s+=1:n.hasEditedComment&&(i+=1);let r=n.telemetryFinalData;if(!r)continue;let{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(n).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[t,e]of Object.entries(r)){if("type"===t)continue;let i=o.get(t);i||(i=new Map,o.set(t,i));let s=i.get(e)??0;i.set(e,s+1)}}if((s>0||i>0)&&((t||=Object.create(null)).comments={deleted:s,edited:i}),!t)return null;for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#ih=null}updateEditor(t,e){let i=this.#id?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#id?.get(t)||null}get modifiedIds(){if(this.#ih)return this.#ih;let t=[];if(this.#id)for(let e of this.#id.values())e.serialize()&&t.push(e.annotationElementId);return this.#ih={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#ic.entries()}}class tz extends tU{#ip;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ip={map:n,hash:i,transfer:s}}get print(){v("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ip}get modifiedIds(){return _(this,"modifiedIds",{ids:new Set,hash:""})}}class tH{#ig=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));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ig.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(!(!t||this.#ig.has(t.loadedName))){if(y(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:e,src:s,style:n}=t,r=new FontFace(e,s,n);this.addNativeFontFace(r);try{await r.load(),this.#ig.add(e),i?.(t)}catch{A(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}v("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){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw A(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return _(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return _(this,"isSyncFontLoadingSupported",n||I.platform.isFirefox)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(y(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return _(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let s,n;function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function a(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=r(c=a(c,976,d.length,d),16);for(s=0,n=d.length-3;s<n;s+=4)u=u-0x58585858+r(d,s)|0;s<d.length&&(u=u-0x58585858+r(d+"XXX",s)|0),c=a(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let m=this._document.createElement("div");for(let e of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++h>30){A("Load test font never loaded."),i();return}(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0)?i():setTimeout(t.bind(null,e,i))}(d,()=>{m.remove(),e.complete()})}}class t${#im;constructor(t,e=null,i,s){this.compiledGlyphs=Object.create(null),this.#im=t,this._inspectFont=e,i&&Object.assign(this,i),s&&(this.charProcOperatorList=s)}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let 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(){let t;if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),t}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e;try{i=t.get(s)}catch(t){A(`getPathGenerator - ignoring character: "${t}".`)}let n=ty(i?.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}get black(){return this.#im.black}get bold(){return this.#im.bold}get disableFontFace(){return this.#im.disableFontFace??!1}set disableFontFace(t){_(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#im.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#im.isInvalidPDFjsFont}get isType3Font(){return this.#im.isType3Font}get italic(){return this.#im.italic}get missingFile(){return this.#im.missingFile}get remeasure(){return this.#im.remeasure}get vertical(){return this.#im.vertical}get ascent(){return this.#im.ascent}get defaultWidth(){return this.#im.defaultWidth}get descent(){return this.#im.descent}get bbox(){return this.#im.bbox}set bbox(t){_(this,"bbox",t)}get fontMatrix(){return this.#im.fontMatrix}get fallbackName(){return this.#im.fallbackName}get loadedName(){return this.#im.loadedName}get mimetype(){return this.#im.mimetype}get name(){return this.#im.name}get data(){return this.#im.data}clearData(){this.#im.clearData()}get cssFontInfo(){return this.#im.cssFontInfo}get systemFontInfo(){return this.#im.systemFontInfo}get defaultVMetrics(){return this.#im.defaultVMetrics}}class tG{#ib;#iA;#iv;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){let e=new TextEncoder,i={},s=0;for(let n of tG.strings){let r=e.encode(t[n]);i[n]=r,s+=4+r.length}let n=new ArrayBuffer(s),r=new Uint8Array(n),a=new DataView(n),o=0;for(let t of tG.strings){let e=i[t],s=e.length;a.setUint32(o,s),r.set(e,o+4),o+=4+s}return y(o===n.byteLength,"CssFontInfo.write: Buffer overflow"),n}constructor(t){this.#ib=t,this.#iA=new DataView(this.#ib),this.#iv=new TextDecoder}#iy(t){y(t<tG.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#iA.getUint32(e)+4;let i=this.#iA.getUint32(e);return this.#iv.decode(new Uint8Array(this.#ib,e+4,i))}get fontFamily(){return this.#iy(0)}get fontWeight(){return this.#iy(1)}get italicAngle(){return this.#iy(2)}}class tj{#ib;#iA;#iv;static strings=["css","loadedName","baseFontName","src"];static write(t){let e=new TextEncoder,i={},s=0;for(let n of tj.strings){let r=e.encode(t[n]);i[n]=r,s+=4+r.length}let n,r,a=1+(s+=4);t.style&&(n=e.encode(t.style.style),r=e.encode(t.style.weight),a+=4+n.length+4+r.length);let o=new ArrayBuffer(a),l=new Uint8Array(o),h=new DataView(o),d=0;for(let e of(h.setUint8(d++,+!!t.guessFallback),h.setUint32(d,0),d+=4,s=0,tj.strings)){let t=i[e],n=t.length;s+=4+n,h.setUint32(d,n),l.set(t,d+4),d+=4+n}return h.setUint32(d-s-4,s),t.style&&(h.setUint32(d,n.length),l.set(n,d+4),d+=4+n.length,h.setUint32(d,r.length),l.set(r,d+4),d+=4+r.length),y(d<=o.byteLength,"SubstitionInfo.write: Buffer overflow"),o.transferToFixedLength(d)}constructor(t){this.#ib=t,this.#iA=new DataView(this.#ib),this.#iv=new TextDecoder}get guessFallback(){return 0!==this.#iA.getUint8(0)}#iy(t){y(t<tj.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#iA.getUint32(e)+4;let i=this.#iA.getUint32(e);return this.#iv.decode(new Uint8Array(this.#ib,e+4,i))}get css(){return this.#iy(0)}get loadedName(){return this.#iy(1)}get baseFontName(){return this.#iy(2)}get src(){return this.#iy(3)}get style(){let t=1;t+=4+this.#iA.getUint32(t);let e=this.#iA.getUint32(t),i=this.#iv.decode(new Uint8Array(this.#ib,t+4,e));t+=4+e;let s=this.#iA.getUint32(t),n=this.#iv.decode(new Uint8Array(this.#ib,t+4,s));return{style:i,weight:n}}}class tV{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static #iw=Math.ceil(2*this.bools.length/8);static #ix=this.#iw+8*this.numbers.length;static #i_=this.#ix+1+8;static #iC=this.#i_+1+48;static #iS=this.#iC+1+6;#ib;#iv;#iA;constructor({data:t,extra:e}){this.#ib=t,this.#iv=new TextDecoder,this.#iA=new DataView(this.#ib),e&&Object.assign(this,e)}#iT(t){y(t<tV.bools.length,"Invalid boolean index");let e=Math.floor(t/4),i=this.#iA.getUint8(e)>>2*t%8&3;return 0===i?void 0:2===i}get black(){return this.#iT(0)}get bold(){return this.#iT(1)}get disableFontFace(){return this.#iT(2)}get fontExtraProperties(){return this.#iT(3)}get isInvalidPDFjsFont(){return this.#iT(4)}get isType3Font(){return this.#iT(5)}get italic(){return this.#iT(6)}get missingFile(){return this.#iT(7)}get remeasure(){return this.#iT(8)}get vertical(){return this.#iT(9)}#iE(t){return y(t<tV.numbers.length,"Invalid number index"),this.#iA.getFloat64(tV.#iw+8*t)}get ascent(){return this.#iE(0)}get defaultWidth(){return this.#iE(1)}get descent(){return this.#iE(2)}get bbox(){let t=tV.#ix;if(0===this.#iA.getUint8(t))return;t+=1;let e=[];for(let i=0;i<4;i++)e.push(this.#iA.getInt16(t,!0)),t+=2;return e}get fontMatrix(){let t=tV.#i_;if(0===this.#iA.getUint8(t))return;t+=1;let e=[];for(let i=0;i<6;i++)e.push(this.#iA.getFloat64(t,!0)),t+=8;return e}get defaultVMetrics(){let t=tV.#iC;if(0===this.#iA.getUint8(t))return;t+=1;let e=[];for(let i=0;i<3;i++)e.push(this.#iA.getInt16(t,!0)),t+=2;return e}#iy(t){y(t<tV.strings.length,"Invalid string index");let e=tV.#iS+4;for(let i=0;i<t;i++)e+=this.#iA.getUint32(e)+4;let i=this.#iA.getUint32(e),s=new Uint8Array(i);return s.set(new Uint8Array(this.#ib,e+4,i)),this.#iv.decode(s)}get fallbackName(){return this.#iy(0)}get loadedName(){return this.#iy(1)}get mimetype(){return this.#iy(2)}get name(){return this.#iy(3)}get data(){let t=tV.#iS,e=this.#iA.getUint32(t);t+=4+e;let i=this.#iA.getUint32(t);t+=4+i;let s=this.#iA.getUint32(t);t+=4+s;let n=this.#iA.getUint32(t);if(0!==n)return new Uint8Array(this.#ib,t+4,n)}clearData(){let t=tV.#iS,e=this.#iA.getUint32(t);t+=4+e;let i=this.#iA.getUint32(t);t+=4+i;let s=this.#iA.getUint32(t);t+=4+s;let n=this.#iA.getUint32(t);new Uint8Array(this.#ib,t+4,n).fill(0),this.#iA.setUint32(t,0)}get cssFontInfo(){let t=tV.#iS,e=this.#iA.getUint32(t);t+=4+e;let i=this.#iA.getUint32(t);t+=4+i;let s=this.#iA.getUint32(t);if(0===s)return null;let n=new Uint8Array(s);return n.set(new Uint8Array(this.#ib,t+4,s)),new tG(n.buffer)}get systemFontInfo(){let t=tV.#iS,e=this.#iA.getUint32(t);t+=4+e;let i=this.#iA.getUint32(t);if(0===i)return null;let s=new Uint8Array(i);return s.set(new Uint8Array(this.#ib,t+4,i)),new tj(s.buffer)}static write(t){let e=t.systemFontInfo?tj.write(t.systemFontInfo):null,i=t.cssFontInfo?tG.write(t.cssFontInfo):null,s=new TextEncoder,n={},r=0;for(let e of tV.strings)n[e]=s.encode(t[e]),r+=4+n[e].length;let a=new ArrayBuffer(tV.#iS+4+r+4+(e?e.byteLength:0)+4+(i?i.byteLength:0)+4+(t.data?t.data.length:0)),o=new Uint8Array(a),l=new DataView(a),h=0,d=tV.bools.length,c=0,u=0;for(let e=0;e<d;e++){let i=t[tV.bools[e]];c|=(void 0===i?0:i?2:1)<<u,(8===(u+=2)||e===d-1)&&(l.setUint8(h++,c),c=0,u=0)}for(let e of(y(h===tV.#iw,"FontInfo.write: Boolean properties offset mismatch"),tV.numbers))l.setFloat64(h,t[e]),h+=8;if(y(h===tV.#ix,"FontInfo.write: Number properties offset mismatch"),t.bbox)for(let e of(l.setUint8(h++,4),t.bbox))l.setInt16(h,e,!0),h+=2;else l.setUint8(h++,0),h+=8;if(y(h===tV.#i_,"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix)for(let e of(l.setUint8(h++,6),t.fontMatrix))l.setFloat64(h,e,!0),h+=8;else l.setUint8(h++,0),h+=48;if(y(h===tV.#iC,"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics)for(let e of(l.setUint8(h++,1),t.defaultVMetrics))l.setInt16(h,e,!0),h+=2;else l.setUint8(h++,0),h+=6;for(let t of(y(h===tV.#iS,"FontInfo.write: DefaultVMetrics properties offset mismatch"),l.setUint32(tV.#iS,0),h+=4,tV.strings)){let e=n[t],i=e.length;l.setUint32(h,i),o.set(e,h+4),h+=4+i}if(l.setUint32(tV.#iS,h-tV.#iS-4),e){let t=e.byteLength;l.setUint32(h,t),y(h+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),o.set(new Uint8Array(e),h+4),h+=4+t}else l.setUint32(h,0),h+=4;if(i){let t=i.byteLength;l.setUint32(h,t),y(h+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),o.set(new Uint8Array(i),h+4),h+=4+t}else l.setUint32(h,0),h+=4;return void 0===t.data?(l.setUint32(h,0),h+=4):(l.setUint32(h,t.data.length),o.set(t.data,h+4),h+=4+t.data.length),y(h<=a.byteLength,"FontInfo.write: Buffer overflow"),a.transferToFixedLength(h)}}class tW{static #iM=0;static #iD=1;static #iP=2;static #ik=3;static #iI=4;static #iB=8;static #iF=12;static #iL=16;constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}static write(t){let e,i=null,s=[],n=[],r=[],a=[],o=null,l=null;switch(t[0]){case"RadialAxial":e="axial"===t[1]?1:2,i=t[2],r=t[3],1===e?s.push(...t[4],...t[5]):s.push(t[4][0],t[4][1],t[6],t[5][0],t[5][1],t[7]);break;case"Mesh":e=3,o=t[1],s=t[2],n=t[3],a=t[4]||[],i=t[6],l=t[7];break;default:throw Error(`Unsupported pattern type: ${t[0]}`)}let h=Math.floor(s.length/2),d=Math.floor(n.length/3),c=r.length,u=a.length,p=0;for(let t of a)p+=1,p=4*Math.ceil(p/4)+(4+4*t.coords.length)+(4+4*t.colors.length),void 0!==t.verticesPerRow&&(p+=4);let g=new ArrayBuffer(20+8*h+3*d+8*c+16*!!i+3*!!l+p),m=new DataView(g),f=new Uint8Array(g);m.setUint8(tW.#iM,e),m.setUint8(tW.#iD,+!!i),m.setUint8(tW.#iP,+!!l),m.setUint8(tW.#ik,o),m.setUint32(tW.#iI,h,!0),m.setUint32(tW.#iB,d,!0),m.setUint32(tW.#iF,c,!0),m.setUint32(tW.#iL,u,!0);let b=20;for(let[t,e]of(new Float32Array(g,20,2*h).set(s),b+=8*h,f.set(n,b),b+=3*d,r))m.setFloat32(b,t,!0),b+=4,m.setUint32(b,parseInt(e.slice(1),16),!0),b+=4;if(i)for(let t of i)m.setFloat32(b,t,!0),b+=4;l&&(f.set(l,b),b+=3);for(let t=0;t<a.length;t++){let e=a[t];m.setUint8(b,e.type),b+=1,b=4*Math.ceil(b/4),m.setUint32(b,e.coords.length,!0),new Int32Array(g,b+=4,e.coords.length).set(e.coords),b+=4*e.coords.length,m.setUint32(b,e.colors.length,!0),new Int32Array(g,b+=4,e.colors.length).set(e.colors),b+=4*e.colors.length,void 0!==e.verticesPerRow&&(m.setUint32(b,e.verticesPerRow,!0),b+=4)}return g}getIR(){let t=this.view,e=this.data[tW.#iM],i=!!this.data[tW.#iD],s=!!this.data[tW.#iP],n=t.getUint32(tW.#iI,!0),r=t.getUint32(tW.#iB,!0),a=t.getUint32(tW.#iF,!0),o=t.getUint32(tW.#iL,!0),l=20,h=new Float32Array(this.buffer,l,2*n);l+=8*n;let d=new Uint8Array(this.buffer,l,3*r);l+=3*r;let c=[];for(let e=0;e<a;++e){let e=t.getFloat32(l,!0);l+=4;let i=t.getUint32(l,!0);l+=4,c.push([e,`#${i.toString(16).padStart(6,"0")}`])}let u=null;if(i){u=[];for(let e=0;e<4;++e)u.push(t.getFloat32(l,!0)),l+=4}let p=null;s&&(p=new Uint8Array(this.buffer,l,3),l+=3);let g=[];for(let e=0;e<o;++e){let e=t.getUint8(l);l+=1,l=4*Math.ceil(l/4);let i=t.getUint32(l,!0);l+=4;let s=new Int32Array(this.buffer,l,i);l+=4*i;let n=t.getUint32(l,!0);l+=4;let r=new Int32Array(this.buffer,l,n);l+=4*n;let a={type:e,coords:s,colors:r};2===e&&(a.verticesPerRow=t.getUint32(l,!0),l+=4),g.push(a)}if(1===e)return["RadialAxial","axial",u,c,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(2===e)return["RadialAxial","radial",u,c,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(3===e){let t=this.data[tW.#ik],e=null;if(h.length>0){let t=h[0],i=h[0],s=h[1],n=h[1];for(let e=0;e<h.length;e+=2){let r=h[e],a=h[e+1];t=t>r?r:t,s=s>a?a:s,i=i<r?r:i,n=n<a?a:n}e=[t,s,i,n]}return["Mesh",t,h,d,g,e,u,p]}throw Error(`Unsupported pattern kind: ${e}`)}}class tX{static write(t){let e;return(I.isFloat16ArraySupported?new Float16Array(e=new ArrayBuffer(2*t.length)):new Float32Array(e=new ArrayBuffer(4*t.length))).set(t),e}#ib;constructor(t){this.#ib=t}get path(){return I.isFloat16ArraySupported?new Float16Array(this.#ib):new Float32Array(this.#ib)}}function tq(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}let tK=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,tY=(function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;let[s,n,...r]=i;if(!t(s)&&!Number.isInteger(s)||!e(n))return!1;let a=r.length,o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(let t of r)if("number"!=typeof t&&(!o||null!==t))return!1;return!0}).bind(null,tK,t=>"object"==typeof t&&"string"==typeof t?.name);class tQ{#o=new Map;#iR=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#iR.then(()=>{for(let[t]of this.#o)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:n}=i;if(n.aborted)return void A("LoopbackPort - cannot use an `aborted` signal.");let r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#o.set(e,s)}removeEventListener(t,e){let i=this.#o.get(e);i?.(),this.#o.delete(e)}terminate(){for(let[,t]of this.#o)t?.();this.#o.clear()}}function tJ(){}function tZ(t){if(t instanceof P||t instanceof E||t instanceof S||t instanceof M||t instanceof T)return t;switch(!(t instanceof Error||"object"==typeof t&&null!==t)&&v('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new P(t.message);case"InvalidPDFException":return new E(t.message);case"PasswordException":return new S(t.message,t.code);case"ResponseException":return new M(t.message,t.status,t.missing);case"UnknownErrorException":return new T(t.message,t.details)}return new T(t.message,t.toString())}class t0{#iN=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#iO.bind(this),{signal:this.#iN.signal})}#iO({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#iU(t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else if(2===t.callback)i.reject(tZ(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(e){n.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})},function(e){n.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:tZ(e)})});return}t.streamId?this.#iz(t):e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){let s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){let n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:6,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{y(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:1,streamId:n,reason:tZ(t)}),e.promise}},i)}#iz(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete r.streamSinks[e])},error(t){y(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:tZ(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,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:tZ(t)})})}#iU(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case 8:t.success?r.startCall.resolve():r.startCall.reject(tZ(t.reason));break;case 7:t.success?r.pullCall.resolve():r.pullCall.reject(tZ(t.reason));break;case 6:if(!a){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||tJ).then(function(){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:tZ(t)})});break;case 4:if(y(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case 3:if(y(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#iH(r,e);break;case 5:y(r,"error should have stream controller"),r.controller.error(tZ(t.reason)),this.#iH(r,e);break;case 2:t.success?r.cancelCall.resolve():r.cancelCall.reject(tZ(t.reason)),this.#iH(r,e);break;case 1:if(!a)break;let o=tZ(t.reason);Promise.try(a.onCancel||tJ,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:tZ(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #iH(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#iN?.abort(),this.#iN=null}}class t1{#i$=!1;constructor({enableHWA:t=!1}){this.#i$=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#i$})}}reset(t,e,i){if(!t.canvas)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){v("Abstract method `_createCanvas` called.")}}class t2 extends t1{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class t3{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){v("Abstract method `_fetch` called.")}}class t5 extends t3{async _fetch(t){let e=await V(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):k(e)}}class t4{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class t6 extends t4{#iG;#ij;#iV;#iW;#iX;#iq;#I=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#iW=t,this.#iX=e}get #F(){return this.#ij||=new Map}get #iK(){return this.#iq||=new Map}get #iY(){if(!this.#iV){let t=this.#iX.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;let i=this.#iX.createElementNS(G,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#iV=this.#iX.createElementNS(G,"defs"),t.append(i),i.append(this.#iV),this.#iX.body.append(t)}return this.#iV}#iQ(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,n=Array(256),r=Array(256),a=Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,a[t]=s[t]/255;return[n.join(","),r.join(","),a.join(",")]}#iJ(t){if(void 0===this.#iG){this.#iG="";let t=this.#iX.URL;t!==this.#iX.baseURI&&(q(t)?A('#createUrl: ignore "data:"-URL for performance reasons.'):this.#iG=x(t,""))}return`url(${this.#iG}#${t})`}addFilter(t){if(!t)return"none";let e=this.#F.get(t);if(e)return e;let[i,s,n]=this.#iQ(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#F.get(r))return this.#F.set(t,e),e;let a=`g_${this.#iW}_transfer_map_${this.#I++}`,o=this.#iJ(a);this.#F.set(t,o),this.#F.set(r,o);let l=this.#iZ(a);return this.#i0(i,s,n,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",n=this.#iK.get(s);if(n?.key===i||(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#iK.set(s,n)),!t||!e))return n.url;let r=this.#i1(t);t=F.makeHexColor(...r);let a=this.#i1(e);if(e=F.makeHexColor(...a),this.#iY.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#iW}_hcm_filter`,d=n.filter=this.#iZ(h);this.#i0(l,l,l,d),this.#i2(d);let c=(t,e)=>{let i=r[t]/255,s=a[t]/255,n=Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#i0(c(0,5),c(1,5),c(2,5),d),n.url=this.#iJ(h),n.url}addAlphaFilter(t){let e=this.#F.get(t);if(e)return e;let[i]=this.#iQ([t]),s=`alpha_${i}`;if(e=this.#F.get(s))return this.#F.set(t,e),e;let n=`g_${this.#iW}_alpha_map_${this.#I++}`,r=this.#iJ(n);this.#F.set(t,r),this.#F.set(s,r);let a=this.#iZ(n);return this.#i3(i,a),r}addLuminosityFilter(t){let e,i,s=this.#F.get(t||"luminosity");if(s)return s;if(t?([e]=this.#iQ([t]),i=`luminosity_${e}`):i="luminosity",s=this.#F.get(i))return this.#F.set(t,s),s;let n=`g_${this.#iW}_luminosity_map_${this.#I++}`,r=this.#iJ(n);this.#F.set(t,r),this.#F.set(i,r);let a=this.#iZ(n);return this.#i5(a),t&&this.#i3(e,a),r}addHighlightHCMFilter(t,e,i,s,n){let r=`${e}-${i}-${s}-${n}`,a=this.#iK.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#iK.set(t,a)),!e||!i))return a.url;let[o,l]=[e,i].map(this.#i1.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,n].map(this.#i1.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#iY.style.color="";let p=(t,e,i)=>{let s=Array(256),n=(d-h)/i,r=t/255,a=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*n),i=r+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#iW}_hcm_${t}_filter`,m=a.filter=this.#iZ(g);return this.#i2(m),this.#i0(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),a.url=this.#iJ(g),a.url}destroy(t=!1){t&&this.#iq?.size||(this.#iV?.parentNode.parentNode.remove(),this.#iV=null,this.#ij?.clear(),this.#ij=null,this.#iq?.clear(),this.#iq=null,this.#I=0)}#i5(t){let e=this.#iX.createElementNS(G,"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)}#i2(t){let e=this.#iX.createElementNS(G,"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)}#iZ(t){let e=this.#iX.createElementNS(G,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#iY.append(e),e}#i4(t,e,i){let s=this.#iX.createElementNS(G,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#i0(t,e,i,s){let n=this.#iX.createElementNS(G,"feComponentTransfer");s.append(n),this.#i4(n,"feFuncR",t),this.#i4(n,"feFuncG",e),this.#i4(n,"feFuncB",i)}#i3(t,e){let i=this.#iX.createElementNS(G,"feComponentTransfer");e.append(i),this.#i4(i,"feFuncA",t)}#i1(t){return this.#iY.style.color=t,tn(getComputedStyle(this.#iY).getPropertyValue("color"))}}class t8{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load font data at: ${e}`)})}async _fetch(t){v("Abstract method `_fetch` called.")}}class t7 extends t8{async _fetch(t){return new Uint8Array(await V(t,"arraybuffer"))}}class t9{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw Error("Wasm filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){v("Abstract method `_fetch` called.")}}class et extends t9{async _fetch(t){return new Uint8Array(await V(t,"arraybuffer"))}}async function ee(t){let e=process.getBuiltinModule("fs");return new Uint8Array(await e.promises.readFile(t))}n&&A("Please use the `legacy` build in Node.js environments.");class ei extends t4{}class es extends t1{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("file:///home/runner/work/nocobase/nocobase/node_modules/pdfjs-dist/build/pdf.mjs")("@napi-rs/canvas").createCanvas(t,e)}}class en extends t3{async _fetch(t){return ee(t)}}class er extends t8{async _fetch(t){return ee(t)}}class ea extends t9{async _fetch(t){return ee(t)}}let eo="__forcedDependency",{floor:el,ceil:eh}=Math;function ed(t,e,i,s,n,r){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],n),t[4*e+3]=Math.max(t[4*e+3],r)}let ec=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class eu{#i6;#i8;constructor(t,e){this.#i6=t,this.#i8=e}get length(){return this.#i6.length}isEmpty(t){return this.#i6[t]===ec}minX(t){return this.#i8[4*t+0]/256}minY(t){return this.#i8[4*t+1]/256}maxX(t){return(this.#i8[4*t+2]+1)/256}maxY(t){return(this.#i8[4*t+3]+1)/256}}let ep=(t,e)=>{if(!t)return;let i=t.get(e);return i||(i={dependencies:new Set,isRenderingOperation:!1},t.set(e,i)),i};class eg{#i7={__proto__:null};#i9={__proto__:null,transform:[],moveText:[],sameLineText:[],[eo]:[]};#st=new Map;#se=[];#si=[];#ss=[[1,0,0,1,0,0]];#sn=[-1/0,-1/0,1/0,1/0];#sr=new Float64Array([1/0,1/0,-1/0,-1/0]);#sa=-1;#so=new Set;#sl=new Map;#sh=new Map;#sd;#sc;#su;#i6;#sp;constructor(t,e,i=!1){this.#sd=t.width,this.#sc=t.height,this.#sg(e),i&&(this.#sp=new Map)}growOperationsCount(t){t>=this.#i6.length&&this.#sg(t,this.#i6)}#sg(t,e){let i=new ArrayBuffer(4*t);this.#su=new Uint8ClampedArray(i),this.#i6=new Uint32Array(i),e&&e.length>0?(this.#i6.set(e),this.#i6.fill(ec,e.length)):this.#i6.fill(ec)}save(t){return this.#i7={__proto__:this.#i7},this.#i9={__proto__:this.#i9,transform:{__proto__:this.#i9.transform},moveText:{__proto__:this.#i9.moveText},sameLineText:{__proto__:this.#i9.sameLineText},[eo]:{__proto__:this.#i9[eo]}},this.#sn={__proto__:this.#sn},this.#se.push(t),this}restore(t){let e=Object.getPrototypeOf(this.#i7);if(null===e)return this;this.#i7=e,this.#i9=Object.getPrototypeOf(this.#i9),this.#sn=Object.getPrototypeOf(this.#sn);let i=this.#se.pop();return void 0!==i&&(ep(this.#sp,t)?.dependencies.add(i),this.#i6[t]=this.#i6[i]),this}recordOpenMarker(t){return this.#se.push(t),this}getOpenMarker(){return 0===this.#se.length?null:this.#se.at(-1)}recordCloseMarker(t){let e=this.#se.pop();return void 0!==e&&(ep(this.#sp,t)?.dependencies.add(e),this.#i6[t]=this.#i6[e]),this}beginMarkedContent(t){return this.#si.push(t),this}endMarkedContent(t){let e=this.#si.pop();return void 0!==e&&(ep(this.#sp,t)?.dependencies.add(e),this.#i6[t]=this.#i6[e]),this}pushBaseTransform(t){return this.#ss.push(F.multiplyByDOMMatrix(this.#ss.at(-1),t.getTransform())),this}popBaseTransform(){return this.#ss.length>1&&this.#ss.pop(),this}recordSimpleData(t,e){return this.#i7[t]=e,this}recordIncrementalData(t,e){return this.#i9[t].push(e),this}resetIncrementalData(t,e){return this.#i9[t].length=0,this}recordNamedData(t,e){return this.#st.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#i7[t]=this.#st.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(eo,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#i7&&this.recordFutureForcedDependency(e,this.#i7[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#so)this.recordFutureForcedDependency(eo,t);return this}resetBBox(t){return this.#sa!==t&&(this.#sa=t,this.#sr[0]=1/0,this.#sr[1]=1/0,this.#sr[2]=-1/0,this.#sr[3]=-1/0),this}recordClipBox(t,e,i,s,n,r){let a=F.multiplyByDOMMatrix(this.#ss.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];F.axialAlignedBoundingBox([i,n,s,r],a,o);let l=F.intersect(this.#sn,o);return l?(this.#sn[0]=l[0],this.#sn[1]=l[1],this.#sn[2]=l[2],this.#sn[3]=l[3]):(this.#sn[0]=this.#sn[1]=1/0,this.#sn[2]=this.#sn[3]=-1/0),this}recordBBox(t,e,i,s,n,r){let a=this.#sn;if(a[0]===1/0)return this;let o=F.multiplyByDOMMatrix(this.#ss.at(-1),e.getTransform());if(a[0]===-1/0)return F.axialAlignedBoundingBox([i,n,s,r],o,this.#sr),this;let l=[1/0,1/0,-1/0,-1/0];return F.axialAlignedBoundingBox([i,n,s,r],o,l),this.#sr[0]=Math.min(this.#sr[0],Math.max(l[0],a[0])),this.#sr[1]=Math.min(this.#sr[1],Math.max(l[1],a[1])),this.#sr[2]=Math.max(this.#sr[2],Math.min(l[2],a[2])),this.#sr[3]=Math.max(this.#sr[3],Math.min(l[3],a[3])),this}recordCharacterBBox(t,e,i,s=1,n=0,r=0,a){let o,l,h=i.bbox;if(h&&!1!==(o=h[2]!==h[0]&&h[3]!==h[1]&&this.#sh.get(i))&&(l=[0,0,0,0],F.axialAlignedBoundingBox(h,i.fontMatrix,l),(1!==s||0!==n||0!==r)&&F.scaleMinMax([s,0,0,-s,n,r],l),o))return this.recordBBox(t,e,l[0],l[2],l[1],l[3]);if(!a)return this.recordFullPageBBox(t);let d=a();return h&&l&&void 0===o&&(o=l[0]<=n-d.actualBoundingBoxLeft&&l[2]>=n+d.actualBoundingBoxRight&&l[1]<=r-d.actualBoundingBoxAscent&&l[3]>=r+d.actualBoundingBoxDescent,this.#sh.set(i,o),o)?this.recordBBox(t,e,l[0],l[2],l[1],l[3]):this.recordBBox(t,e,n-d.actualBoundingBoxLeft,n+d.actualBoundingBoxRight,r-d.actualBoundingBoxAscent,r+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#sr[0]=Math.max(0,this.#sn[0]),this.#sr[1]=Math.max(0,this.#sn[1]),this.#sr[2]=Math.min(this.#sd,this.#sn[2]),this.#sr[3]=Math.min(this.#sc,this.#sn[3]),this}getSimpleIndex(t){return this.#i7[t]}recordDependencies(t,e){let i=this.#so,s=this.#i7,n=this.#i9;for(let t of e)t in this.#i7?i.add(s[t]):t in n&&n[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#st.has(e)&&this.#so.add(this.#st.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[eo]),this.#sp){let e=ep(this.#sp,t),{dependencies:i}=e;this.#so.forEach(i.add,i),this.#se.forEach(i.add,i),this.#si.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(this.#sa===t){let i=el(256*this.#sr[0]/this.#sd),s=el(256*this.#sr[1]/this.#sc),n=eh(256*this.#sr[2]/this.#sd),r=eh(256*this.#sr[3]/this.#sc);for(let e of(ed(this.#su,t,i,s,n,r),this.#so))e!==t&&ed(this.#su,e,i,s,n,r);for(let e of this.#se)e!==t&&ed(this.#su,e,i,s,n,r);for(let e of this.#si)e!==t&&ed(this.#su,e,i,s,n,r);e||(this.#so.clear(),this.#sa=-1)}return this}recordShowTextOperation(t,e=!1){let i=Array.from(this.#so);for(let s of(this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t),i))this.recordIncrementalData("sameLineText",s);return this}bboxToClipBoxDropOperation(t,e=!1){return this.#sa===t&&(this.#sa=-1,this.#sn[0]=Math.max(this.#sn[0],this.#sr[0]),this.#sn[1]=Math.max(this.#sn[1],this.#sr[1]),this.#sn[2]=Math.min(this.#sn[2],this.#sr[2]),this.#sn[3]=Math.min(this.#sn[3],this.#sr[3]),e||this.#so.clear()),this}_takePendingDependencies(){let t=this.#so;return this.#so=new Set,t}_extractOperation(t){let e=this.#sl.get(t);return this.#sl.delete(t),e}_pushPendingDependencies(t){for(let e of t)this.#so.add(e)}take(){return this.#sh.clear(),new eu(this.#i6,this.#su)}takeDebugMetadata(){return this.#sp}}class em{#sm;#sf;#sb;#sA=0;#sv=0;constructor(t,e,i){if(t instanceof em&&!!i===t.#sb)return t;this.#sm=t,this.#sf=e,this.#sb=!!i}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#sv++,this.#sm.save(this.#sf),this}restore(t){return this.#sv>0&&(this.#sm.restore(this.#sf),this.#sv--),this}recordOpenMarker(t){return this.#sA++,this}getOpenMarker(){return this.#sA>0?this.#sf:this.#sm.getOpenMarker()}recordCloseMarker(t){return this.#sA--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#sm.pushBaseTransform(t),this}popBaseTransform(){return this.#sm.popBaseTransform(),this}recordSimpleData(t,e){return this.#sm.recordSimpleData(t,this.#sf),this}recordIncrementalData(t,e){return this.#sm.recordIncrementalData(t,this.#sf),this}resetIncrementalData(t,e){return this.#sm.resetIncrementalData(t,this.#sf),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#sm.recordSimpleDataFromNamed(t,e,this.#sf),this}recordFutureForcedDependency(t,e){return this.#sm.recordFutureForcedDependency(t,this.#sf),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#sm.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#sm.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#sb||this.#sm.resetBBox(this.#sf),this}recordClipBox(t,e,i,s,n,r){return this.#sb||this.#sm.recordClipBox(this.#sf,e,i,s,n,r),this}recordBBox(t,e,i,s,n,r){return this.#sb||this.#sm.recordBBox(this.#sf,e,i,s,n,r),this}recordCharacterBBox(t,e,i,s,n,r,a){return this.#sb||this.#sm.recordCharacterBBox(this.#sf,e,i,s,n,r,a),this}recordFullPageBBox(t){return this.#sb||this.#sm.recordFullPageBBox(this.#sf),this}getSimpleIndex(t){return this.#sm.getSimpleIndex(t)}recordDependencies(t,e){return this.#sm.recordDependencies(this.#sf,e),this}recordNamedDependency(t,e){return this.#sm.recordNamedDependency(this.#sf,e),this}recordOperation(t){return this.#sm.recordOperation(this.#sf,!0),this}recordShowTextOperation(t){return this.#sm.recordShowTextOperation(this.#sf,!0),this}bboxToClipBoxDropOperation(t){return this.#sb||this.#sm.bboxToClipBoxDropOperation(this.#sf,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}let ef=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],eb=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],eA=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],ev=["filter","fillColor","fillAlpha"],ey=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],ew=["transform"],ex=["transform","fillColor"],e_="Fill",eC="Stroke",eS="Shading";function eT(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class eE{isModifyingCurrentTransform(){return!1}getPattern(){v("Abstract method `getPattern` called.")}}class eM extends eE{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}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}_createGradient(t,e=null){let i,s=this._p0,n=this._p1;if(e&&(s=s.slice(),n=n.slice(),F.applyTransform(s,e),F.applyTransform(n,e)),"axial"===this._type)i=t.createLinearGradient(s[0],s[1],n[0],n[1]);else if("radial"===this._type){let r=this._r0,a=this._r1;if(e){let t=new Float32Array(2);F.singularValueDecompose2dScale(e,t),r*=t[0],a*=t[0]}i=t.createRadialGradient(s[0],s[1],r,n[0],n[1],a)}for(let t of this._colorStops)i.addColorStop(t[0],t[1]);return i}getPattern(t,e,i,s){let n;if(s===eC||s===e_){if(this.isOriginBased()){let s=F.transform(i,e.baseTransform);this.matrix&&(s=F.transform(s,this.matrix));let n=Math.hypot(s[0],s[1]),r=Math.hypot(s[2],s[3]);if(.001>Math.abs((s[0]*s[2]+s[1]*s[3])/(n*r))){if(!this.isRadial())return this._createGradient(t,s);else if(.001>Math.abs(n-r))return this._createGradient(t,s)}}let r=e.current.getClippedPathBoundingBox(s,tr(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=F.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),eT(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");let d=new DOMMatrix(i);n.setTransform(d)}else eT(t,this._bbox),n=this._createGradient(t);return n}}function eD(t,e,i,s,n,r,a,o){let l,h,d,c,u,p,g,m,f,b=e.coords,A=e.colors,v=t.data,y=4*t.width;b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=r,r=a,a=l),b[s+1]>b[n+1]&&(l=s,s=n,n=l,l=a,a=o,o=l),b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=r,r=a,a=l);let w=(b[i]+e.offsetX)*e.scaleX,x=(b[i+1]+e.offsetY)*e.scaleY,_=(b[s]+e.offsetX)*e.scaleX,C=(b[s+1]+e.offsetY)*e.scaleY,S=(b[n]+e.offsetX)*e.scaleX,T=(b[n+1]+e.offsetY)*e.scaleY;if(x>=T)return;let E=A[r],M=A[r+1],D=A[r+2],P=A[a],k=A[a+1],I=A[a+2],B=A[o],F=A[o+1],L=A[o+2],R=Math.round(x),N=Math.round(T);for(let t=R;t<=N;t++){let e;if(t<C){let e=t<x?0:(x-t)/(x-C);h=w-(w-_)*e,d=E-(E-P)*e,c=M-(M-k)*e,u=D-(D-I)*e}else{let e;h=_-(_-S)*(e=t>T?1:C===T?0:(C-t)/(C-T)),d=P-(P-B)*e,c=k-(k-F)*e,u=I-(I-L)*e}p=w-(w-S)*(e=t<x?0:t>T?1:(x-t)/(x-T)),g=E-(E-B)*e,m=M-(M-F)*e,f=D-(D-L)*e;let i=Math.round(Math.min(h,p)),s=Math.round(Math.max(h,p)),n=y*t+4*i;for(let t=i;t<=s;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),v[n++]=d-(d-g)*e|0,v[n++]=c-(c-m)*e|0,v[n++]=u-(u-f)*e|0,v[n++]=255}}class eP extends eE{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),m=g.context,f=m.createImageData(o,l);if(e){let t=f.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(let t of this._figures)!function(t,e,i){let s,n,r=e.coords,a=e.colors;switch(e.type){case 2:let o=e.verticesPerRow,l=Math.floor(r.length/o)-1,h=o-1;for(s=0;s<l;s++){let e=s*o;for(let s=0;s<h;s++,e++)eD(t,i,r[e],r[e+1],r[e+o],a[e],a[e+1],a[e+o]),eD(t,i,r[e+o+1],r[e+1],r[e+o],a[e+o+1],a[e+1],a[e+o])}break;case 1:for(s=0,n=r.length;s<n;s+=3)eD(t,i,r[s],r[s+1],r[s+2],a[s],a[s+1],a[s+2]);break;default:throw Error("illegal figure")}}(f,t,c);return m.putImageData(f,2,2),{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){eT(t,this._bbox);let n=new Float32Array(2);if(s===eS)F.singularValueDecompose2dScale(tr(t),n);else if(this.matrix){F.singularValueDecompose2dScale(this.matrix,n);let[t,i]=n;F.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else F.singularValueDecompose2dScale(e.baseTransform,n);let r=this._createMeshCanvas(n,s===eS?null:this._background,e.cachedCanvases);return s!==eS&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class ek extends eE{getPattern(){return"hotpink"}}class eI{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],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.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t,e){let{bbox:i,operatorList:s,paintType:n,tilingType:r,color:a,canvasGraphicsFactory:o}=this,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),b("TilingType: "+r);let d=i[0],c=i[1],u=i[2],p=i[3],g=u-d,m=p-c,f=new Float32Array(2);F.singularValueDecompose2dScale(this.matrix,f);let[A,v]=f;F.singularValueDecompose2dScale(this.baseTransform,f);let y=A*f[0],w=v*f[1],x=g,_=m,C=!1,S=!1,T=Math.ceil(h*w),E=Math.ceil(m*w);Math.ceil(l*y)>=Math.ceil(g*y)?x=l:C=!0,T>=E?_=h:S=!0;let M=this.getSizeAndScale(x,this.ctx.canvas.width,y),D=this.getSizeAndScale(_,this.ctx.canvas.height,w),P=t.cachedCanvases.getCanvas("pattern",M.size,D.size),k=P.context,I=o.createCanvasGraphics(k,e);if(I.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(I,n,a),k.translate(-M.scale*d,-D.scale*c),I.transform(0,M.scale,0,0,D.scale,0,0),k.save(),I.dependencyTracker?.save(),this.clipBbox(I,d,c,u,p),I.baseTransform=tr(I.ctx),I.executeOperatorList(s),I.endDrawing(),I.dependencyTracker?.restore(),k.restore(),C||S){let e=P.canvas;C&&(x=l),S&&(_=h);let i=this.getSizeAndScale(x,this.ctx.canvas.width,y),s=this.getSizeAndScale(_,this.ctx.canvas.height,w),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),o=a.context,u=C?Math.floor(g/l):0,p=S?Math.floor(m/h):0;for(let t=0;t<=u;t++)for(let i=0;i<=p;i++)o.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:d,offsetY:c}}return{canvas:P.canvas,scaleX:M.scale,scaleY:D.scale,offsetX:d,offsetY:c}}getSizeAndScale(t,e,i){let s=Math.max(eI.MAX_PATTERN_SIZE,e),n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){let r=s-e,a=n-i;t.ctx.rect(e,i,r,a),F.axialAlignedBoundingBox([e,i,s,n],tr(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,n=t.current;switch(e){case 1:let{fillStyle:r,strokeStyle:a}=this.ctx;s.fillStyle=n.fillColor=r,s.strokeStyle=n.strokeColor=a;break;case 2:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new D(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,n){let r=i;s!==eS&&(r=F.transform(r,e.baseTransform),this.matrix&&(r=F.transform(r,this.matrix)));let a=this.createPatternCanvas(e,n),o=new DOMMatrix(r);o=(o=o.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}}let eB=new DOMMatrix,eF=new Float32Array(2),eL=new Float32Array([1/0,1/0,-1/0,-1/0]);class eR{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function eN(t,e,i,s,n,r,a,o,l,h){let[d,c,u,p,g,m]=tr(t);if(0===c&&0===u){let f=Math.round(a*d+g),b=Math.round(o*p+m),A=Math.abs(Math.round((a+l)*d+g)-f)||1,v=Math.abs(Math.round((o+h)*p+m)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),f,b),t.drawImage(e,i,s,n,r,0,0,A,v),t.setTransform(d,c,u,p,g,m),[A,v]}if(0===d&&0===p){let f=Math.round(o*u+g),b=Math.round(a*c+m),A=Math.abs(Math.round((o+h)*u+g)-f)||1,v=Math.abs(Math.round((a+l)*c+m)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,f,b),t.drawImage(e,i,s,n,r,0,0,v,A),t.setTransform(d,c,u,p,g,m),[v,A]}return t.drawImage(e,i,s,n,r,a,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class eO{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=r;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,i){i?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=eL.slice()}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=e_,e=null){let i=this.minMax.slice();if(t===eC){e||v("Stroke bounding box must include transform."),F.singularValueDecompose2dScale(e,eF);let t=eF[0]*this.lineWidth/2,s=eF[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){let t=F.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(eL,0)}getClippedPathBoundingBox(t=e_,e=null){return F.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function eU(t,e){let i,s,n,r;if(e instanceof ImageData)return void t.putImageData(e,0,0);let a=e.height,o=e.width,l=a%16,h=(a-l)/16,d=0===l?h:h+1,u=t.createImageData(o,16),p=0,g,m=e.data,f=u.data;if(e.kind===c.GRAYSCALE_1BPP){let e=m.byteLength,r=new Uint32Array(f.buffer,0,f.byteLength>>2),a=r.length,c=o+7>>3,b=I.isLittleEndian?0xff000000:255;for(i=0;i<d;i++){for(s=0,n=i<h?16:l,g=0;s<n;s++){let t=e-p,i=0,s=t>c?o:8*t-7,n=-8&s,a=0,l=0;for(;i<n;i+=8)l=m[p++],r[g++]=128&l?0xffffffff:b,r[g++]=64&l?0xffffffff:b,r[g++]=32&l?0xffffffff:b,r[g++]=16&l?0xffffffff:b,r[g++]=8&l?0xffffffff:b,r[g++]=4&l?0xffffffff:b,r[g++]=2&l?0xffffffff:b,r[g++]=1&l?0xffffffff:b;for(;i<s;i++)0===a&&(l=m[p++],a=128),r[g++]=l&a?0xffffffff:b,a>>=1}for(;g<a;)r[g++]=0;t.putImageData(u,0,16*i)}}else if(e.kind===c.RGBA_32BPP){for(i=0,s=0,r=16*o*4;i<h;i++)f.set(m.subarray(p,p+r)),p+=r,t.putImageData(u,0,s),s+=16;i<d&&(r=o*l*4,f.set(m.subarray(p,p+r)),t.putImageData(u,0,s))}else if(e.kind===c.RGB_24BPP)for(i=0,r=o*(n=16);i<d;i++){for(i>=h&&(r=o*(n=l)),g=0,s=r;s--;)f[g++]=m[p++],f[g++]=m[p++],f[g++]=m[p++],f[g++]=255;t.putImageData(u,0,16*i)}else throw Error(`bad image kind: ${e.kind}`)}function ez(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);let i=e.height,s=e.width,n=i%16,r=(i-n)/16,a=0===n?r:r+1,o=t.createImageData(s,16),l=0,h=e.data,d=o.data;for(let e=0;e<a;e++){let i=e<r?16:n;({srcPos:l}=function({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=0xffffffff,inverseDecode:a=!1}){let o=I.isLittleEndian?0xff000000:255,[l,h]=a?[r,o]:[o,r],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(let s=e+d;e<s;e++){let s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;let s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function eH(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function e$(t){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);let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function eG(t,e){if(e)return!0;F.singularValueDecompose2dScale(t,eF);let i=Math.fround(tl.pixelRatio*j.PDF_TO_CSS_UNITS);return eF[0]<=i&&eF[1]<=i}let ej=["butt","round","square"],eV=["miter","round","bevel"],eW={},eX={};class eq{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l,h){this.ctx=t,this.current=new eO(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=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new eR(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){let n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){let t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...tr(this.compositeCtx))}this.ctx.save(),e$(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=tr(this.ctx)}executeOperatorList(t,e,i,s,n){let r,a,o=t.argsArray,l=t.fnArray,h=e||0,d=o.length;if(d===h)return h;let c=d-h>10&&"function"==typeof i,u=c?Date.now()+15:0,p=0,m=this.commonObjs,f=this.objs;for(;;){if(void 0!==s&&h===s.nextBreakPoint)return s.breakIt(h,i),h;if(!n||n(h))if(r=l[h],a=o[h]??null,r!==g.dependency)null===a?this[r](h):this[r](h,...a);else for(let t of a){this.dependencyTracker?.recordNamedData(t,h);let e=t.startsWith("g_")?m:f;if(!e.has(t))return e.get(t,i),h}if(++h===d)return h;if(c&&++p>10){if(Date.now()>u)return i(),h;p=0}}}#sy(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,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(){for(let t of(this.#sy(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#sw()}#sw(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i,s,n=t.width??t.displayWidth,r=t.height??t.displayHeight,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=n,h=r,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,n=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(n=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/n),(s=(i=this.cachedCanvases.getCanvas(d,e,n)).context).clearRect(0,0,e,n),s.drawImage(t,0,0,l,h,0,0,e,n),t=i.canvas,l=e,h=n,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t,e){let i,s,n,r,a=this.ctx,{width:o,height:l}=e,h=this.current.fillColor,d=this.current.patternFill,c=tr(a);if((e.bitmap||e.data)&&e.count>1){let r=e.bitmap||e.data.buffer;s=JSON.stringify(d?c:[c.slice(0,4),h]),(i=this._cachedBitmapsMap.get(r))||(i=new Map,this._cachedBitmapsMap.set(r,i));let a=i.get(s);if(a&&!d){let e=Math.round(Math.min(c[0],c[2])+c[4]),i=Math.round(Math.min(c[1],c[3])+c[5]);return this.dependencyTracker?.recordDependencies(t,ex),{canvas:a,offsetX:e,offsetY:i}}n=a}n||ez((r=this.cachedCanvases.getCanvas("maskCanvas",o,l)).context,e);let u=F.transform(c,[1/o,0,0,-1/l,0,0]);u=F.transform(u,[1,0,0,1,0,-l]);let p=eL.slice();F.axialAlignedBoundingBox([0,0,o,l],u,p);let[g,m,f,b]=p,A=Math.round(f-g)||1,v=Math.round(b-m)||1,y=this.cachedCanvases.getCanvas("fillCanvas",A,v),w=y.context;w.translate(-g,-m),w.transform(...u),!n&&(n=(n=this._scaleImage(r.canvas,ta(w))).img,i&&d&&i.set(s,n)),w.imageSmoothingEnabled=eG(tr(w),e.interpolate),eN(w,n,0,0,n.width,n.height,0,0,o,l),w.globalCompositeOperation="source-in";let x=F.transform(ta(w),[1,0,0,1,-g,-m]);return w.fillStyle=d?h.getPattern(a,this,x,e_,t):h,w.fillRect(0,0,o,l),i&&!d&&(this.cachedCanvases.delete("fillCanvas"),i.set(s,y.canvas)),this.dependencyTracker?.recordDependencies(t,ex),{canvas:y.canvas,offsetX:Math.round(g),offsetY:Math.round(m)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=ej[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=eV[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);let s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(e),s.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[i,s]of e)switch(i){case"LW":this.setLineWidth(t,s);break;case"LC":this.setLineCap(t,s);break;case"LJ":this.setLineJoin(t,s);break;case"ML":this.setMiterLimit(t,s);break;case"D":this.setDash(t,s[0],s[1]);break;case"RI":this.setRenderingIntent(t,s);break;case"FL":this.setFlatness(t,s);break;case"Font":this.setFont(t,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,i=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(s,e,i);this.suspendedCtx=this.ctx;let r=this.ctx=n.context;r.setTransform(this.suspendedCtx.getTransform()),eH(this.suspendedCtx,r);var a=this.suspendedCtx;if(r._removeMirroring)throw Error("Context is already forwarding operations.");r.__originalSave=r.save,r.__originalRestore=r.restore,r.__originalRotate=r.rotate,r.__originalScale=r.scale,r.__originalTranslate=r.translate,r.__originalTransform=r.transform,r.__originalSetTransform=r.setTransform,r.__originalResetTransform=r.resetTransform,r.__originalClip=r.clip,r.__originalMoveTo=r.moveTo,r.__originalLineTo=r.lineTo,r.__originalBezierCurveTo=r.bezierCurveTo,r.__originalRect=r.rect,r.__originalClosePath=r.closePath,r.__originalBeginPath=r.beginPath,r._removeMirroring=()=>{r.save=r.__originalSave,r.restore=r.__originalRestore,r.rotate=r.__originalRotate,r.scale=r.__originalScale,r.translate=r.__originalTranslate,r.transform=r.__originalTransform,r.setTransform=r.__originalSetTransform,r.resetTransform=r.__originalResetTransform,r.clip=r.__originalClip,r.moveTo=r.__originalMoveTo,r.lineTo=r.__originalLineTo,r.bezierCurveTo=r.__originalBezierCurveTo,r.rect=r.__originalRect,r.closePath=r.__originalClosePath,r.beginPath=r.__originalBeginPath,delete r._removeMirroring},r.save=function(){a.save(),this.__originalSave()},r.restore=function(){a.restore(),this.__originalRestore()},r.translate=function(t,e){a.translate(t,e),this.__originalTranslate(t,e)},r.scale=function(t,e){a.scale(t,e),this.__originalScale(t,e)},r.transform=function(t,e,i,s,n,r){a.transform(t,e,i,s,n,r),this.__originalTransform(t,e,i,s,n,r)},r.setTransform=function(t,e,i,s,n,r){a.setTransform(t,e,i,s,n,r),this.__originalSetTransform(t,e,i,s,n,r)},r.resetTransform=function(){a.resetTransform(),this.__originalResetTransform()},r.rotate=function(t){a.rotate(t),this.__originalRotate(t)},r.clip=function(t){a.clip(t),this.__originalClip(t)},r.moveTo=function(t,e){a.moveTo(t,e),this.__originalMoveTo(t,e)},r.lineTo=function(t,e){a.lineTo(t,e),this.__originalLineTo(t,e)},r.bezierCurveTo=function(t,e,i,s,n,r){a.bezierCurveTo(t,e,i,s,n,r),this.__originalBezierCurveTo(t,e,i,s,n,r)},r.rect=function(t,e,i,s){a.rect(t,e,i,s),this.__originalRect(t,e,i,s)},r.closePath=function(){a.closePath(),this.__originalClosePath()},r.beginPath=function(){a.beginPath(),this.__originalBeginPath()},this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),eH(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];let e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,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,i,s){let n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r)if(u<0||p<0||u+i>c.width||p+s>c.height){let t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(c,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=r,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let e=new Path2D;e.rect(u,p,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(u,p,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));let g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(t){this.inSMaskMode&&eH(this.ctx,this.suspendedCtx),this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),0===this.stateStack.length){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&eH(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,i,s,n,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[n]=i;if(!s){n||=i[0]=new Path2D,this[e](t,n);return}if(null!==this.dependencyTracker){let i=e===g.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}n instanceof Path2D||(n=i[0]=ty(n)),F.axialAlignedBoundingBox(s,tr(this.ctx),this.current.minMax),this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){let s=this.ctx,n=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof n&&n?.getPattern){let i=n.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=n.getPattern(s,this,ta(s),eC,t),i){let t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),s.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,ef),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(eC,tr(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){let s=this.ctx,n=this.current.fillColor,r=this.current.patternFill,a=!1;if(r){let i=n.isModifyingCurrentTransform()?s.getTransform():null;if(this.dependencyTracker?.save(t),s.save(),s.fillStyle=n.getPattern(s,this,ta(s),e_,t),i){let t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}a=!0}let o=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==o&&(this.pendingEOFill?(s.fill(e,"evenodd"),this.pendingEOFill=!1):s.fill(e)),this.dependencyTracker?.recordDependencies(t,eb),a&&(s.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,o)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,ev).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=eW}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=eX}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){let t=new Path2D,s=i.getTransform().invertSelf();for(let{transform:i,x:n,y:r,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(s).translate(n,r).scale(a,-a));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let s=this.commonObjs.get(e),n=this.current;if(!s)throw Error(`Can't find font for ${e}`);if(n.fontMatrix=s.fontMatrix||r,(0===n.fontMatrix[0]||0===n.fontMatrix[3])&&A("Invalid font matrix for font "+e),i<0?(i=-i,n.fontDirection=-1):n.fontDirection=1,this.current.font=s,this.current.fontSize=i,s.isType3Font)return;let a=s.loadedName||"sans-serif",o=s.systemFontInfo?.css||`"${a}", ${s.fallbackName}`,l="normal";s.black?l="900":s.bold&&(l="bold");let h=s.italic?"italic":"normal",d=i;i<16?d=16:i>100&&(d=100),this.current.fontSizeScale=i/d,this.ctx.font=`${h} ${l} ${d}px ${o}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);let{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#sx(t,e,i){let s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n,r){let a,o=this.ctx,l=this.current,h=l.font,d=l.textRenderingMode,c=l.fontSize/l.fontSizeScale,u=3&d,p=!!(4&d),g=l.patternFill&&!h.missingFile,m=l.patternStroke&&!h.missingFile;if((h.disableFontFace||p||g||m)&&!h.missingFile&&(a=h.getPathGenerator(this.commonObjs,e)),a&&(h.disableFontFace||g||m)){let e;if(o.save(),o.translate(i,s),o.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,o,h),0===u||2===u)if(n){e=o.getTransform(),o.setTransform(...n);let t=this.#sx(a,e,n);o.fill(t)}else o.fill(a);if(1===u||2===u)if(r){e||=o.getTransform(),o.setTransform(...r);let{a:t,b:i,c:s,d:n}=e,l=F.inverseTransform(r),h=F.transform([t,i,s,n,0,0],l);F.singularValueDecompose2dScale(h,eF),o.lineWidth*=Math.max(eF[0],eF[1])/c,o.stroke(this.#sx(a,e,r))}else o.lineWidth/=c,o.stroke(a);o.restore()}else(0===u||2===u)&&(o.fillText(e,i,s),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e))),(1===u||2===u)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e)).recordDependencies(t,ef),o.strokeText(e,i,s));p&&((this.pendingTextPaths||=[]).push({transform:tr(o),x:i,y:s,fontSize:c,path:a}),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s))}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return _(this,"isFontSubpixelAAEnabled",i)}showText(t,e){let i,s;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,ey).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());let n=this.current,r=n.font;if(r.isType3Font){this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t);return}let a=n.fontSize;if(0===a)return void this.dependencyTracker?.recordOperation(t);let o=this.ctx,l=n.fontSizeScale,h=n.charSpacing,d=n.wordSpacing,c=n.fontDirection,u=n.textHScale*c,p=e.length,g=r.vertical,m=g?1:-1,f=r.defaultVMetrics,b=a*n.fontMatrix[0],A=0===n.textRenderingMode&&!r.disableFontFace&&!n.patternFill;o.save(),n.textMatrix&&o.transform(...n.textMatrix),o.translate(n.x,n.y+n.textRise),c>0?o.scale(u,-1):o.scale(u,1);let v=3&n.textRenderingMode,y=1===v||2===v;if((0===v||2===v)&&n.patternFill){o.save();let e=n.fillColor.getPattern(o,this,ta(o),e_,t);i=tr(o),o.restore(),o.fillStyle=e}if(y&&n.patternStroke){o.save();let e=n.strokeColor.getPattern(o,this,ta(o),eC,t);s=tr(o),o.restore(),o.strokeStyle=e}let w=n.lineWidth,x=n.textMatrixScale;if(0===x||0===w?y&&(w=this.getSinglePixelWidth()):w/=x,1!==l&&(o.scale(l,l),w/=l),o.lineWidth=w,r.isInvalidPDFjsFont){let i=[],s=0;for(let t of e)i.push(t.unicode),s+=t.width;let r=i.join("");if(o.fillText(r,0,0),null!==this.dependencyTracker){let e=o.measureText(r);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}n.x+=s*b*u,o.restore(),this.compose();return}let _=0,C;for(C=0;C<p;++C){let n,u,p,v=e[C];if("number"==typeof v){_+=m*v*a/1e3;continue}let y=!1,w=(v.isSpace?d:0)+h,x=v.fontChar,S=v.accent,T=v.width;if(g){let t=v.vmetric||f,e=-(v.vmetric?t[1]:.5*T)*b,i=t[2]*b;T=t?-t[0]:T,n=e/l,u=(_+i)/l}else n=_/l,u=0;if(r.remeasure&&T>0){let t=1e3*(p=o.measureText(x)).width/a*l;if(T<t&&this.isFontSubpixelAAEnabled){let e=T/t;y=!0,o.save(),o.scale(e,1),n/=e}else T!==t&&(n+=(T-t)/2e3*a/l)}if(this.contentVisible&&(v.isInFont||r.missingFile)){if(A&&!S)o.fillText(x,n,u),this.dependencyTracker?.recordCharacterBBox(t,o,p?{bbox:null}:r,a/l,n,u,()=>p??o.measureText(x));else if(this.paintChar(t,x,n,u,i,s),S){let e=n+a*S.offset.x/l,r=u-a*S.offset.y/l;this.paintChar(t,S.fontChar,e,r,i,s)}}_+=g?T*b-w*c:T*b+w*c,y&&o.restore()}g?n.y-=_:n.x+=_*u,o.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){let i,s,n,a,o=this.ctx,l=this.current,h=l.font,d=l.fontSize,c=l.fontDirection,u=h.vertical?1:-1,p=l.charSpacing,g=l.wordSpacing,m=l.textHScale*c,f=l.fontMatrix||r,b=e.length;if(3===l.textRenderingMode||0===d)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,o.save(),l.textMatrix&&o.transform(...l.textMatrix),o.translate(l.x,l.y+l.textRise),o.scale(m,c);let v=this.dependencyTracker;for(i=0,this.dependencyTracker=v?new em(v,t):null;i<b;++i){if("number"==typeof(s=e[i])){a=u*s*d/1e3,this.ctx.translate(a,0),l.x+=a*m;continue}let t=(s.isSpace?g:0)+p,r=h.charProcOperatorList[s.operatorListId];r?this.contentVisible&&(this.save(),o.scale(d,d),o.transform(...f),this.executeOperatorList(r),this.restore()):A(`Type3 character "${s.operatorListId}" is not available.`);let c=[s.width,0];F.applyTransform(c,f),n=c[0]*d+t,o.translate(n,0),l.x+=n*m}o.restore(),v&&(this.dependencyTracker=v)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,s,n,r,a){let o=new Path2D;o.rect(s,n,r-s,a-n),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,s,r,n,a).recordClipBox(t,this.ctx,s,r,n,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){let t=this.baseTransform||tr(this.ctx);i=new eI(e,this.ctx,{createCanvasGraphics:(t,e)=>new eq(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new em(this.dependencyTracker,e,!0):null)},t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new eM(t);case"Mesh":return new eP(t);case"Dummy":return new ek}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){if(!this.contentVisible)return;let i=this.ctx;this.save(t),i.fillStyle=this._getPattern(t,e).getPattern(i,this,ta(i),eS,t);let s=ta(i);if(s){let{width:t,height:e}=i.canvas,n=eL.slice();F.axialAlignedBoundingBox([0,0,t,e],s,n);let[r,a,o,l]=n;this.ctx.fillRect(r,a,o-r,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,ew).recordDependencies(t,eb).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){v("Should not call beginInlineImage")}beginImageData(){v("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=tr(this.ctx),i)){F.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);let[e,s,n,r]=i,a=new Path2D;a.rect(e,s,n-e,r-s),this.ctx.clip(a),this.dependencyTracker?.recordClipBox(t,this.ctx,e,n,s,r),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let i=this.ctx;e.isolated||b("TODO: Support non-isolated groups."),e.knockout&&A("Knockout groups not supported.");let s=tr(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw Error("Bounding box is required.");let n=eL.slice();F.axialAlignedBoundingBox(e.bbox,tr(i),n);let r=[0,0,i.canvas.width,i.canvas.height],a=Math.floor((n=F.intersect(n,r)||[0,0,0,0])[0]),o=Math.floor(n[1]),l=Math.max(Math.ceil(n[2])-a,1),h=Math.max(Math.ceil(n[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);let c=this.cachedCanvases.getCanvas(d,l,h),u=c.context;u.translate(-a,-o),u.transform(...s);let p=new Path2D,[g,m,f,v]=e.bbox;if(p.rect(g,m,f-g,v-m),e.matrix){let t=new Path2D;t.addPath(p,new DOMMatrix(e.matrix)),p=t}u.clip(p),e.smask&&this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(a,o),i.save()),eH(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let i=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();let e=tr(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);let s=eL.slice();F.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,s),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(t,e,i,s,n,r){if(this.#sy(),e$(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){let n=i[2]-i[0],a=i[3]-i[1];if(r&&this.annotationCanvasMap){s=s.slice(),s[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=n,i[3]=a,F.singularValueDecompose2dScale(tr(this.ctx),eF);let{viewportScale:t}=this,r=Math.ceil(n*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,o);let{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(eF[0],0,0,-eF[1],0,a*eF[1]),e$(this.ctx)}else{e$(this.ctx),this.endPath(t);let e=new Path2D;e.rect(i[0],i[1],n,a),this.ctx.clip(e)}}this.current=new eO(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...s),this.transform(t,...n)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#sw(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let i=e.count;(e=this.getObject(t,e.data,e)).count=i;let s=this.ctx,n=this._createMaskCanvas(t,e),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+r.width,n.offsetY,n.offsetY+r.height).recordOperation(t),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,s=0,n=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.ctx;o.save();let l=tr(o);o.transform(i,s,n,r,0,0);let h=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,d=a.length;e<d;e+=2){let d=F.transform(l,[i,s,n,r,a[e],a[e+1]]);o.drawImage(h.canvas,d[4],d[5]),this.dependencyTracker?.recordBBox(t,this.ctx,d[4],d[4]+h.canvas.width,d[5],d[5]+h.canvas.height)}o.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let i=this.ctx,s=this.current.fillColor,n=this.current.patternFill;for(let r of(this.dependencyTracker?.resetBBox(t).recordDependencies(t,ex),e)){let{data:e,width:a,height:o,transform:l}=r,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=h.context;d.save(),ez(d,this.getObject(t,e,r)),d.globalCompositeOperation="source-in",d.fillStyle=n?s.getPattern(d,this,ta(i),e_,t):s,d.fillRect(0,0,a,o),d.restore(),i.save(),i.transform(...l),i.scale(1,-1),eN(i,h.canvas,0,0,a,o,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,a,0,o),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;let i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):A("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,n){if(!this.contentVisible)return;let r=this.getObject(t,e);if(!r)return void A("Dependent image isn't ready yet");let a=r.width,o=r.height,l=[];for(let t=0,e=n.length;t<e;t+=2)l.push({transform:[i,0,0,s,n[t],n[t+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}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;let{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t,e){let i;if(!this.contentVisible)return;let s=e.width,n=e.height,r=this.ctx;this.save(t);let{filter:a}=r;if("none"!==a&&""!==a&&(r.filter="none"),r.scale(1/s,-1/n),e.bitmap)i=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)i=e;else{let t=this.cachedCanvases.getCanvas("inlineImage",s,n).context;eU(t,e),i=this.applyTransferMapsToCanvas(t)}let o=this._scaleImage(i,ta(r));r.imageSmoothingEnabled=eG(tr(r),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,r,0,s,-n,0).recordDependencies(t,eA).recordOperation(t),eN(r,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,s,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){let s;if(!this.contentVisible)return;let n=this.ctx;if(e.bitmap)s=e.bitmap;else{let t=e.width,i=e.height,n=this.cachedCanvases.getCanvas("inlineImage",t,i).context;eU(n,e),s=this.applyTransferMapsToCanvas(n)}for(let e of(this.dependencyTracker?.resetBBox(t),i))n.save(),n.transform(...e.transform),n.scale(1,-1),eN(n,s,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,eb).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){let s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);let n=this.ctx;this.pendingClip?(s||(this.pendingClip===eX?n.clip(e,"evenodd"):n.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=tr(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let t,e,{lineWidth:i}=this.current,{a:s,b:n,c:r,d:a}=this.ctx.getTransform();if(0===n&&0===r){let n=Math.abs(s),r=Math.abs(a);if(n===r)if(0===i)t=e=1/n;else{let s=n*i;t=e=s<1?1/s:1}else if(0===i)t=1/n,e=1/r;else{let s=n*i,a=r*i;t=s<1?1/s:1,e=a<1?1/a:1}}else{let o=Math.abs(s*a-n*r),l=Math.hypot(s,n),h=Math.hypot(r,a);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:i,current:{lineWidth:s}}=this,[n,r]=this.getScaleForStroking();if(n===r){i.lineWidth=(s||1)*n,i.stroke(t);return}let a=i.getLineDash();e&&i.save(),i.scale(n,r),eB.a=1/n,eB.d=1/r;let o=new Path2D;if(o.addPath(t,eB),a.length>0){let t=Math.max(n,r);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in g)void 0!==eq.prototype[t]&&(eq.prototype[g[t]]=eq.prototype[t]);class eK{static #s_=null;static #sC="";static get workerPort(){return this.#s_}static set workerPort(t){if(!("u">typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#s_=t}static get workerSrc(){return this.#sC}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#sC=t}}class eY{#sS;#sT;constructor({parsedData:t,rawData:e}){this.#sS=t,this.#sT=e}getRaw(){return this.#sT}get(t){return this.#sS.get(t)??null}[Symbol.iterator](){return this.#sS.entries()}}let eQ=Symbol("INTERNAL");class eJ{#sE=!1;#sM=!1;#sD=!1;#sP=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#sE=!!(2&t),this.#sM=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#sD)return this.#sP;if(!this.#sP)return!1;let{print:t,view:e}=this.usage;return this.#sE?e?.viewState!=="OFF":!this.#sM||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==eQ&&v("Internal method `_setVisible` called."),this.#sD=i,this.#sP=e}}class eZ{#sk=null;#sI=new Map;#sB=null;#sF=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null===t)return;for(const i of(this.name=t.name,this.creator=t.creator,this.#sF=t.order,t.groups))this.#sI.set(i.id,new eJ(e,i));if("OFF"===t.baseState)for(const t of this.#sI.values())t._setVisible(eQ,!1);for(const e of t.on)this.#sI.get(e)._setVisible(eQ,!0);for(const e of t.off)this.#sI.get(e)._setVisible(eQ,!1);this.#sB=this.getHash()}#sL(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e,n=t[s];if(Array.isArray(n))e=this.#sL(n);else{if(!this.#sI.has(n))return A(`Optional content group not found: ${n}`),!0;e=this.#sI.get(n).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#sI.size)return!0;if(!t)return b("Optional content group not defined."),!0;if("OCG"===t.type)return this.#sI.has(t.id)?this.#sI.get(t.id).visible:(A(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#sL(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#sI.has(e)){A(`Optional content group not found: ${e}`);break}if(!this.#sI.get(e).visible)return!1}return!0}else if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#sI.has(e))return A(`Optional content group not found: ${e}`),!0;if(!this.#sI.get(e).visible)return!0}return!1}else if("AllOff"===t.policy){for(let e of t.ids){if(!this.#sI.has(e)){A(`Optional content group not found: ${e}`);break}if(this.#sI.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#sI.has(e))return A(`Optional content group not found: ${e}`),!0;if(this.#sI.get(e).visible)return!0}return!1}return A(`Unknown optional content policy ${t.policy}.`),!0}return A(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let s=this.#sI.get(t);if(!s)return void A(`Optional content group not found: ${t}`);if(i&&e&&s.rbGroups.length)for(let e of s.rbGroups)for(let i of e)i!==t&&this.#sI.get(i)?._setVisible(eQ,!1,!0);s._setVisible(eQ,!!e,!0),this.#sk=null}setOCGState({state:t,preserveRB:e}){let i;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let t=this.#sI.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#sk=null}get hasInitialVisibility(){return null===this.#sB||this.getHash()===this.#sB}getOrder(){return this.#sI.size?this.#sF?this.#sF.slice():[...this.#sI.keys()]:null}getGroup(t){return this.#sI.get(t)||null}getHash(){if(null!==this.#sk)return this.#sk;let t=new tN;for(let[e,i]of this.#sI)t.update(`${e}:${i.visible}`);return this.#sk=t.hexdigest()}[Symbol.iterator](){return this.#sI.entries()}}class e0{#sR=null;#sN=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,i){this._source=t,this.#sR=e,this.#sN=i}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return y(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#sR(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new this.#sN(this,t,e);return this._rangeReaders.add(i),i}cancelAllRequests(t){for(let e of(this._fullReader?.cancel(t),new Set(this._rangeReaders)))e.cancel(t)}}class e1{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}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(){v("Abstract method `read` called")}cancel(t){v("Abstract method `cancel` called")}}class e2{_stream=null;constructor(t,e,i){this._stream=t}async read(){v("Abstract method `read` called")}cancel(t){v("Abstract method `cancel` called")}}function e3(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}class e5 extends e0{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,e4,e6);const{pdfDataRangeTransport:e}=t,{initialData:i,progressiveDone:s}=e;if(i?.length>0){const t=e3(i);this._queuedChunks.push(t)}this._progressiveDone=s,e.addRangeListener((t,e)=>{this.#sO(t,e)}),e.addProgressListener((t,e)=>{void 0!==e&&this._fullReader?.onProgress?.({loaded:t,total:e})}),e.addProgressiveReadListener(t=>{this.#sO(void 0,t)}),e.addProgressiveDoneListener(()=>{this._fullReader?.progressiveDone(),this._progressiveDone=!0}),e.transportReady()}#sO(t,e){let i=e3(e);if(void 0===t)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{let e=this._rangeReaders.keys().find(e=>e._begin===t);y(e,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),e._enqueue(i)}}getFullReader(){let t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){let i=super.getRangeReader(t,e);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,e)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class e4 extends e1{_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:i,disableStream:s}=t._source,{length:n,contentDispositionFilename:r}=e;for(const e of(this._queuedChunks=t._queuedChunks||[],this._queuedChunks))this._loaded+=e.byteLength;this._done=t._progressiveDone,this._contentLength=n,this._isStreamingSupported=!s,this._isRangeSupported=!i,K(r)&&(this._filename=r),this._headersCapability.resolve()}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||=!0}}class e6 extends e2{onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,i){super(t,e,i),this._begin=e}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{for(let e of(this._requests.shift().resolve({value:t,done:!1}),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this.onDone?.()}}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this.onDone?.()}}function e8(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let s=e[t];void 0!==s&&i.append(t,s)}return i}function e7(t){return URL.parse(t)?.origin??null}function e9({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);return Number.isInteger(r)&&(n.suggestedLength=r,r<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0)),n}function it(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){let t=a(i=i[1]);return r(t=l(t=o(t=unescape(t))))}if(i=function(t){let e,i=[],n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=n.exec(t));){let[,t,s,n]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[s,n]}let r=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=a(s),e&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t))return r(l(i));if(i=s("filename","i").exec(t)){let t=a(i=i[1]);return r(t=l(t))}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),n=k(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return -1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return n(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(K(t))return t}return null}function ie(t,e){return new M(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function ii(t,e){if(t!==e)throw Error(`Expected range response-origin "${t}" to match "${e}".`)}function is(t,e,i,s){return fetch(t,{method:"GET",headers:e,signal:s.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function ir(t,e){if(200!==t&&206!==t)throw ie(t,e)}function ia(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(A(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class io extends e0{_responseOrigin=null;constructor(t){super(t,il,ih),this.isHttp=/^https?:/i.test(t.url),this.headers=e8(this.isHttp,t.httpHeaders)}}class il extends e1{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,length:s,rangeChunkSize:n,url:r,withCredentials:a}=t._source;this._contentLength=s,this._isStreamingSupported=!i,this._isRangeSupported=!e,is(r,new Headers(t.headers),a,this._abortController).then(i=>{t._responseOrigin=e7(i.url),ir(i.status,r),this._reader=i.body.getReader();let s=i.headers,{allowRangeRequests:a,suggestedLength:o}=e9({responseHeaders:s,isHttp:t.isHttp,rangeChunkSize:n,disableRange:e});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=it(s),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new P("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{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:ia(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ih extends e2{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s,withCredentials:n}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${e}-${i-1}`),is(s,r,n,this._abortController).then(e=>{ii(e7(e.url),t._responseOrigin),ir(e.status,s),this._reader=e.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:ia(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class id extends e0{#sU=new WeakMap;_responseOrigin=null;constructor(t){super(t,ic,iu),this.url=t.url,this.isHttp=/^https?:/i.test(this.url),this.headers=e8(this.isHttp,t.httpHeaders)}_request(t){let e=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};for(let[t,s]of(this.#sU.set(e,i),e.open("GET",this.url),e.withCredentials=this._source.withCredentials,this.headers))e.setRequestHeader(t,s);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.validateStatus=t=>206===t||200===t):i.validateStatus=t=>200===t,e.responseType="arraybuffer",y(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#sz.bind(this,e),e.onprogress=this.#sH.bind(this,e),e.send(null),e}#sH(t,e){let i=this.#sU.get(t);i?.onProgress?.(e)}#sz(t,e){var i;let s=this.#sU.get(t);if(!s||(t.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==t.readyState||!this.#sU.has(t)))return;if(this.#sU.delete(t),0===t.status&&this.isHttp)return void s.onError(t.status);let n=t.status||200;if(!s.validateStatus(n))return void s.onError(t.status);let r="string"!=typeof(i=t.response)?i:k(i).buffer;if(206===n){let e=t.getResponseHeader("Content-Range");/bytes (\d+)-(\d+)\/(\d+)/.test(e)?s.onDone(r):(A('Missing or invalid "Content-Range" header.'),s.onError(0))}else r?s.onDone(r):s.onError(t.status)}_abortRequest(t){this.#sU.has(t)&&(this.#sU.delete(t),t.abort())}getRangeReader(t,e){let i=super.getRangeReader(t,e);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}class ic extends e1{_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t);const{length:e}=t._source;this._contentLength=e,this._fullRequestXhr=t._request({onHeadersReceived:this.#s$.bind(this),onDone:this.#sG.bind(this),onError:this.#sj.bind(this),onProgress:this.#sH.bind(this)})}#s$(){let t=this._stream,{disableRange:e,rangeChunkSize:i}=t._source,s=this._fullRequestXhr;t._responseOrigin=e7(s.responseURL);let n=s.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:a,suggestedLength:o}=e9({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:i,disableRange:e});a&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=it(r),this._isRangeSupported&&t._abortRequest(s),this._headersCapability.resolve()}#sG(t){if(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}#sj(t){for(let e of(this._storedError=ie(t,this._stream.url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#sH(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}async read(){if(await this._headersCapability.promise,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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class iu extends e2{onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,i){super(t,e,i),this._requestXhr=t._request({begin:e,end:i,onHeadersReceived:this.#s$.bind(this),onDone:this.#sG.bind(this),onError:this.#sj.bind(this),onProgress:null})}#s$(){let t=e7(this._requestXhr?.responseURL);try{ii(t,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#sj(0)}}#sG(t){for(let e of(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this.onClosed?.()}#sj(t){for(let e of(this._storedError??=ie(t,this._stream.url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}let ip=/^[a-z][a-z0-9\-+.]+:/i;function ig(t){let{Readable:e}=process.getBuiltinModule("stream");return"function"==typeof e.toWeb?e.toWeb(t):process.getBuiltinModule("module").createRequire("file:///home/runner/work/nocobase/nocobase/node_modules/pdfjs-dist/build/pdf.mjs")("node-readable-to-web-readable-stream").makeDefaultReadableStreamFromNodeReadable(t)}function im(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(A(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class ib extends e0{constructor(t){super(t,iA,iv),this.url=function(t){return new URL(ip.test(t)?t:process.getBuiltinModule("url").pathToFileURL(t))}(t.url),y("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs.")}}class iA extends e1{_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,length:s,rangeChunkSize:n}=t._source;this._contentLength=s,this._isStreamingSupported=!i,this._isRangeSupported=!e;const r=t.url,a=process.getBuiltinModule("fs");a.promises.lstat(r).then(t=>{let e=ig(a.createReadStream(r));this._reader=e.getReader();let{size:i}=t;i<=2*n&&(this._isRangeSupported=!1),this._contentLength=i,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new P("Streaming is disabled.")),this._headersCapability.resolve()}).catch(t=>{"ENOENT"===t.code&&(t=ie(0,r.href)),this._headersCapability.reject(t)})}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:im(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class iv extends e2{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const s=t.url,n=process.getBuiltinModule("fs");try{const t=n.createReadStream(s,{start:e,end:i-1}),r=ig(t);this._reader=r.getReader(),this._readCapability.resolve()}catch(t){this._readCapability.reject(t)}}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:im(t),done:!1}}cancel(t){this._reader?.cancel(t)}}let iy=Symbol("INITIAL_DATA");class iw{#sV=Object.create(null);#sW(t){return this.#sV[t]||={...Promise.withResolvers(),data:iy}}get(t,e=null){if(e){let i=this.#sW(t);return i.promise.then(()=>e(i.data)),null}let i=this.#sV[t];if(!i||i.data===iy)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#sV[t];return!!e&&e.data!==iy}delete(t){let e=this.#sV[t];return!!e&&e.data!==iy&&(delete this.#sV[t],!0)}resolve(t,e=null){let i=this.#sW(t);i.data=e,i.resolve()}clear(){for(let t in this.#sV){let{data:e}=this.#sV[t];e?.bitmap?.close()}this.#sV=Object.create(null)}*[Symbol.iterator](){for(let t in this.#sV){let{data:e}=this.#sV[t];e!==iy&&(yield[t,e])}}}class ix{#sX=Promise.withResolvers();#tI=null;#sq=!1;#sK=!!globalThis.FontInspector?.enabled;#sY=null;#sQ=null;#sJ=0;#sZ=0;#s0=null;#s1=null;#s2=0;#s3=0;#s5=Object.create(null);#s4=[];#s6=null;#s8=[];#s7=new WeakMap;#s9=null;static #nt=new Map;static #ne=new Map;static #ni=new WeakMap;static #ns=null;static #nn=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#s6=t;else if("object"==typeof t)this.#s6=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');this.#tI=this.#s1=e,this.#s3=i.scale*tl.pixelRatio,this.#s2=i.rotation,this.#sQ={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:n,pageX:r,pageY:a}=i.rawDims;this.#s9=[1,0,0,-1,-r,a+n],this.#sZ=s,this.#sJ=n,ix.#nr(),e.style.setProperty("--min-font-size",ix.#ns),to(e,i),this.#sX.promise.finally(()=>{ix.#nn.delete(this),this.#sQ=null,this.#s5=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=I.platform;return _(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#s0.read().then(({value:e,done:i})=>{i?this.#sX.resolve():(this.#sY??=e.lang,Object.assign(this.#s5,e.styles),this.#na(e.items),t())},this.#sX.reject)};return this.#s0=this.#s6.getReader(),ix.#nn.add(this),t(),this.#sX.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*tl.pixelRatio,s=t.rotation;if(s!==this.#s2&&(e?.(),this.#s2=s,to(this.#s1,{rotation:s})),i!==this.#s3){e?.(),this.#s3=i;let t={div:null,properties:null,ctx:ix.#no(this.#sY)};for(let e of this.#s8)t.properties=this.#s7.get(e),t.div=e,this.#nl(t)}}cancel(){let t=new P("TextLayer task cancelled.");this.#s0?.cancel(t).catch(()=>{}),this.#s0=null,this.#sX.reject(t)}get textDivs(){return this.#s8}get textContentItemsStr(){return this.#s4}#na(t){if(this.#sq)return;this.#sQ.ctx??=ix.#no(this.#sY);let e=this.#s8,i=this.#s4;for(let s of t){if(e.length>1e5){A("Ignoring additional textDivs for performance reasons."),this.#sq=!0;return}if(void 0===s.str){if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#tI;this.#tI=document.createElement("span"),this.#tI.classList.add("markedContent"),s.id&&this.#tI.setAttribute("id",`${s.id}`),"Artifact"===s.tag&&(this.#tI.ariaHidden=!0),t.append(this.#tI)}else"endMarkedContent"===s.type&&(this.#tI=this.#tI.parentNode);continue}i.push(s.str),this.#nh(s)}}#nh(t){let e,i,s=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#s8.push(s);let r=F.transform(this.#s9,t.transform),a=Math.atan2(r[1],r[0]),o=this.#s5[t.fontName];o.vertical&&(a+=Math.PI/2);let l=this.#sK&&o.fontSubstitution||o.fontFamily;l=ix.fontFamilyMap.get(l)||l;let h=Math.hypot(r[2],r[3]),d=h*ix.#nd(l,o,this.#sY);0===a?(e=r[4],i=r[5]-d):(e=r[4]+d*Math.sin(a),i=r[5]-d*Math.cos(a));let c=s.style;c.left=`${(100*e/this.#sZ).toFixed(2)}%`,c.top=`${(100*i/this.#sJ).toFixed(2)}%`,c.setProperty("--font-height",`${h.toFixed(2)}px`),c.fontFamily=l,n.fontSize=h,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,this.#sK&&(s.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==a&&(n.angle=180/Math.PI*a);let u=!1;if(t.str.length>1)u=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(u=!0)}if(u&&(n.canvasWidth=o.vertical?t.height:t.width),this.#s7.set(s,n),this.#sQ.div=s,this.#sQ.properties=n,this.#nl(this.#sQ),n.hasText&&this.#tI.append(s),n.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tI.append(t)}}#nl(t){let{div:e,properties:i,ctx:s}=t,{style:n}=e;if(0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=n,{canvasWidth:r,fontSize:a}=i;ix.#nc(s,a*this.#s3,t);let{width:o}=s.measureText(e.textContent);o>0&&n.setProperty("--scale-x",r*this.#s3/o)}0!==i.angle&&n.setProperty("--rotate",`${i.angle}deg`)}static cleanup(){if(!(this.#nn.size>0)){for(let{canvas:t}of(this.#nt.clear(),this.#ne.values()))t.remove();this.#ne.clear()}}static #no(t=null){let e=this.#ne.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#ne.set(t,e),this.#ni.set(e,{size:0,family:""})}return e}static #nc(t,e,i){let s=this.#ni.get(t);(e!==s.size||i!==s.family)&&(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static #nr(){if(null!==this.#ns)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#ns=t.getBoundingClientRect().height,t.remove()}static #nd(t,e,i){let s=this.#nt.get(t);if(s)return s;let n=this.#no(i);n.canvas.width=n.canvas.height=30,this.#nc(n,30,t);let r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return a?l=a/(a+o):(I.platform.isFirefox&&A("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#nt.set(t,l),l}}function i_(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e=new iC,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(n)return t;let e=URL.parse(t,window.location);if(e)return e.href}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,r=t.data?function(t){if(n&&"u">typeof Buffer&&t instanceof Buffer)throw 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 k(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw 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,l=t.password??null,h=t.range instanceof iS?t.range:null,d=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,c=t.worker instanceof iM?t.worker:null,u=t.verbosity,p="string"!=typeof t.docBaseUrl||q(t.docBaseUrl)?null:t.docBaseUrl,g=tq(t.cMapUrl),m=!1!==t.cMapPacked,b=t.CMapReaderFactory||(n?en:t5),A=tq(t.iccUrl),v=tq(t.standardFontDataUrl),y=t.StandardFontDataFactory||(n?er:t7),w=tq(t.wasmUrl),x=t.WasmFactory||(n?ea:et),_=!0!==t.stopAtErrors,C=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,S=!1!==t.isEvalSupported,T="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!n,E="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!n&&(I.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,D="boolean"==typeof t.disableFontFace?t.disableFontFace:n,P=!0===t.fontExtraProperties,B=!0===t.enableXfa,F=t.ownerDocument||globalThis.document,L=!0===t.disableRange,R=!0===t.disableStream,N=!0===t.disableAutoFetch,O=!0===t.pdfBug,U=t.CanvasFactory||(n?es:t2),z=t.FilterFactory||(n?ei:t6),H=!0===t.enableHWA,$=!1!==t.useWasm,G=h?h.length:t.length??NaN,j="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!n&&!D,V="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(b===t5&&y===t7&&x===et&&g&&v&&w&&Z(g,document.baseURI)&&Z(v,document.baseURI)&&Z(w,document.baseURI));Number.isInteger(u)&&(f=u);let W={canvasFactory:new U({ownerDocument:F,enableHWA:H}),filterFactory:new z({docId:i,ownerDocument:F}),cMapReaderFactory:V?null:new b({baseUrl:g,isCompressed:m}),standardFontDataFactory:V?null:new y({baseUrl:v}),wasmFactory:V?null:new x({baseUrl:w})};c||(e._worker=c=iM.create({verbosity:u,port:eK.workerPort}));let X={docId:i,apiVersion:"5.4.624",data:r,password:l,disableAutoFetch:N,rangeChunkSize:d,length:G,docBaseUrl:p,enableXfa:B,evaluatorOptions:{maxImageSize:C,disableFontFace:D,ignoreErrors:_,isEvalSupported:S,isOffscreenCanvasSupported:T,isImageDecoderSupported:E,canvasMaxAreaInBytes:M,fontExtraProperties:P,useSystemFonts:j,useWasm:$,useWorkerFetch:V,cMapUrl:g,iccUrl:A,standardFontDataUrl:v,wasmUrl:w}},K={ownerDocument:F,pdfBug:O,styleElement:null,enableHWA:H,loadingParams:{disableAutoFetch:N,enableXfa:B}};return c.promise.then(function(){let t;if(e.destroyed)throw Error("Loading aborted");if(c.destroyed)throw Error("Worker was destroyed");let l=c.messageHandler.sendWithPromise("GetDocRequest",X,r?[r.buffer]:null);if(h)t=new e5({pdfDataRangeTransport:h,disableRange:L,disableStream:R});else if(!r){if(!s)throw Error("getDocument - no `url` parameter provided.");t=new(Z(s)?io:n?ib:id)({url:s,length:G,httpHeaders:a,withCredentials:o,rangeChunkSize:d,disableRange:L,disableStream:R})}return l.then(s=>{if(e.destroyed)throw Error("Loading aborted");if(c.destroyed)throw Error("Worker was destroyed");let n=new t0(i,s,c.port),r=new iD(n,e,t,K,W);e._transport=r,n.send("Ready",null)})}).catch(e._capability.reject),e}class iC{static #iW=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${iC.#iW++}`;destroyed=!1;onPassword=null;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?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class iS{#sX=Promise.withResolvers();#nu=[];#np=[];#ng=[];#nm=[];constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}addRangeListener(t){this.#nm.push(t)}addProgressListener(t){this.#ng.push(t)}addProgressiveReadListener(t){this.#np.push(t)}addProgressiveDoneListener(t){this.#nu.push(t)}onDataRange(t,e){for(let i of this.#nm)i(t,e)}onDataProgress(t,e){this.#sX.promise.then(()=>{for(let i of this.#ng)i(t,e)})}onDataProgressiveRead(t){this.#sX.promise.then(()=>{for(let e of this.#np)e(t)})}onDataProgressiveDone(){this.#sX.promise.then(()=>{for(let t of this.#nu)t()})}transportReady(){this.#sX.resolve()}requestDataRange(t,e){v("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class iT{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return _(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{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()}extractPages(t){return this._transport.extractPages(t)}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 iE{#nf=!1;#nb=tw.instance;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new J:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new iw,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-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:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new W({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){let{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 _(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:n=a.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:d=null,printAnnotationStorage:c=null,isEditing:u=!1,recordOperations:p=!1,operationsFilter:g=null}){this._stats?.time("Overall");let m=this._transport.getRenderingIntent(s,n,c,u),{renderingIntent:f,cacheKey:b}=m;this.#nf=!1,l||=this._transport.getOptionalContentConfig(f);let A=this._intentStates.get(b);A||(A=Object.create(null),this._intentStates.set(b,A)),A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);let v=!!(4&f);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(m));let y=!!(this._pdfBug&&globalThis.StepperManager?.enabled),w=!this.recordedBBoxes&&(p||y),x=t=>{if(A.renderTasks.delete(_),w){let t=_.gfx?.dependencyTracker.take();t&&(_.stepper&&_.stepper.setOperatorBBoxes(t,_.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=t))}v&&(this.#nf=!0),this.#nA(),t?(_.capability.reject(t),this._abortOperatorList({intentState:A,reason:t instanceof Error?t:Error(t)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new ik({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:w?new eg(e,A.operatorList.length,y):null,viewport:i,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA,operationsFilter:g});(A.renderTasks||=new Set).add(_);let C=_.task;return Promise.all([A.displayReadyCapability.promise,l]).then(([t,e])=>{if(this.destroyed)return void x();if(this._stats?.time("Rendering"),!(e.renderingIntent&f))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:t,optionalContentConfig:e}),_.operatorListChanged()}).catch(x),C}getOperatorList({intent:t="display",annotationMode:e=a.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){let n,r=this._transport.getRenderingIntent(t,e,i,s,!0),o=this._intentStates.get(r.cacheKey);return o||(o=Object.create(null),this._intentStates.set(r.cacheKey,o)),o.opListReadCapability||((n=Object.create(null)).operatorListChanged=function(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(n))},o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||=new Set).add(n),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#nb.getPageId(this._pageIndex+1)-1,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=>H.textContent(t));let e=this.streamTextContent(t);return new Promise(function(t,i){let s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#nf=!1,Promise.all(t)}cleanup(t=!1){this.#nf=!0;let e=this.#nA();return t&&e&&(this._stats&&=new J),e}#nA(){if(!this.#nf||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#nf=!1,!0}_startRenderPage(t,e){let i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#nA()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){let{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#nb.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;let l=()=>{a.read().then(({value:t,done:e})=>{if(e){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let t of(o.operatorList.lastChunk=!0,o.renderTasks))t.operatorListChanged();this.#nA()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else if(o.opListReadCapability)o.opListReadCapability.reject(t);else throw t}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof X){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new P(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class iM{#sX=Promise.withResolvers();#nv=null;#s_=null;#ny=null;static #nw=0;static #nx=!1;static #n_=new WeakMap;static{n&&(this.#nx=!0,eK.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;let s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{if(console.log("Deprecated API usage: `PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=f}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(iM.#n_.has(e))throw Error("Cannot use more than one PDFWorker per port.");iM.#n_.set(e,this),this.#nC(e)}else this.#nS()}get promise(){return this.#sX.promise}#nT(){this.#sX.resolve(),this.#nv.send("configure",{verbosity:this.verbosity})}get port(){return this.#s_}get messageHandler(){return this.#nv}#nC(t){this.#s_=t,this.#nv=new t0("main","worker",t),this.#nv.on("ready",()=>{}),this.#nT()}#nS(){if(iM.#nx||iM.#nE)return void this.#nM();let{workerSrc:t}=iM;try{iM._isSameOrigin(window.location,t)||(t=iM._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new t0("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this.#sX.reject(Error("Worker was destroyed")):this.#nM()},n=new AbortController;e.addEventListener("error",()=>{this.#ny||s()},{signal:n.signal}),i.on("test",t=>{(n.abort(),this.destroyed||!t)?s():(this.#nv=i,this.#s_=e,this.#ny=e,this.#nT())}),i.on("ready",t=>{if(n.abort(),this.destroyed)return void s();try{r()}catch{this.#nM()}});let r=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};r();return}catch{b("The worker has been disabled.")}this.#nM()}#nM(){iM.#nx||(A("Setting up fake worker."),iM.#nx=!0),iM._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this.#sX.reject(Error("Worker was destroyed"));let e=new tQ;this.#s_=e;let i=`fake${iM.#nw++}`,s=new t0(i+"_worker",i,e);t.setup(s,e),this.#nv=new t0(i,i+"_worker",e),this.#nT()}).catch(t=>{this.#sX.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#ny?.terminate(),this.#ny=null,iM.#n_.delete(this.#s_),this.#s_=null,this.#nv?.destroy(),this.#nv=null}static create(t){let e=this.#n_.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new iM(t)}static get workerSrc(){if(eK.workerSrc)return eK.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #nE(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return _(this,"_setupFakeWorkerGlobal",(async()=>this.#nE?this.#nE:(await import(this.workerSrc)).WorkerMessageHandler)())}}class iD{downloadInfoCapability=Promise.withResolvers();#nD=null;#nP=new Map;#nk=null;#nI=new Map;#nB=new Map;#nF=new Map;#nL=null;#nb=tw.instance;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.#nk=i,this.commonObjs=new iw,this.fontLoader=new tH({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.enableHWA=s.enableHWA,this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler(),this.#nb.addListener(this.#nR.bind(this))}#nR(){let t=new Map,e=new Map;for(let i=0,s=this.#nb.pagesNumber;i<s;i++){let s=this.#nb.getPrevPageNumber(i+1)-1,n=this.#nI.get(s);n&&t.set(i,n);let r=this.#nB.get(s);r&&e.set(i,r)}this.#nI=t,this.#nB=e}#nN(t,e=null){let i=this.#nP.get(t);if(i)return i;let s=this.messageHandler.sendWithPromise(t,e);return this.#nP.set(t,s),s}#sH({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:z(Math.round(t/e*100),0,100)})}get annotationStorage(){return _(this,"annotationStorage",new tU)}getRenderingIntent(t,e=a.ENABLE,i=null,s=!1,n=!1){let r=2,o=tO;switch(t){case"any":r=1;break;case"display":break;case"print":r=4;break;default:A(`getRenderingIntent - invalid intent: ${t}`)}let l=4&r&&i instanceof tz?i:this.annotationStorage;switch(e){case a.DISABLE:r+=64;break;case a.ENABLE:break;case a.ENABLE_FORMS:r+=16;break;case a.ENABLE_STORAGE:r+=32,o=l.serializable;break;default:A(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=128),n&&(r+=256);let{ids:h,hash:d}=l.modifiedIds,c=[r,o.hash,d];return{renderingIntent:r,cacheKey:c.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#nL?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#nI.values())t.push(e._destroy());this.#nI.clear(),this.#nB.clear(),this.#nF.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#nP.clear(),this.filterFactory.destroy(),ix.cleanup(),this.#nk?.cancelAllRequests(new P("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{y(this.#nk,"GetReader - no `BasePDFStream` instance available."),this.#nD=this.#nk.getFullReader(),this.#nD.onProgress=t=>this.#sH(t),e.onPull=()=>{this.#nD.read().then(function({value:t,done:i}){i?e.close():(y(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this.#nD.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this.#nD.headersReady;let{isStreamingSupported:e,isRangeSupported:i,contentLength:s}=this.#nD;return e&&i&&(this.#nD.onProgress=null),{isStreamingSupported:e,isRangeSupported:i,contentLength:s}}),t.on("GetRangeReader",(t,e)=>{y(this.#nk,"GetRangeReader - no `BasePDFStream` instance available.");let i=this.#nk.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(y(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this.#nb.pagesNumber=t.numPages,this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new iT(t,this))}),t.on("DocException",t=>{e._capability.reject(tZ(t))}),t.on("PasswordRequest",t=>{this.#nL=Promise.withResolvers();try{if(!e.onPassword)throw tZ(t);let i=t=>{t instanceof Error?this.#nL.reject(t):this.#nL.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#nL.reject(t)}return this.#nL.promise}),t.on("DataLoaded",t=>{this.#sH({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#nI.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){let t=s.error;A(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let n=new t$(new tV(s),this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,s.extra,s.charProcOperatorList);this.fontLoader.bind(n).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!n.fontExtraProperties&&n.data&&n.clearData(),this.commonObjs.resolve(e,n)});break;case"CopyLocalImage":let{imageRef:r}=s;for(let t of(y(r,"The imageRef must be defined."),this.#nI.values()))for(let[,i]of t.objs)if(i?.ref===r){if(!i.dataLen)return null;return this.commonObjs.resolve(e,structuredClone(i)),i.dataLen}break;case"FontPath":this.commonObjs.resolve(e,new tX(s));break;case"Image":this.commonObjs.resolve(e,s);break;case"Pattern":let a=new tW(s);this.commonObjs.resolve(e,a.getIR());break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let n=this.#nI.get(e);if(!n.objs.has(t)){if(0===n._intentStates.size)return void s?.bitmap?.close();switch(i){case"Image":case"Pattern":n.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||this.#sH(t)}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");let e=this[t.type];if(!e)throw Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&A("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#nD?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){return this.messageHandler.sendWithPromise("ExtractPages",{pageInfos:t})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.#nb.pagesNumber)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.#nb.getPageId(t)-1,s=this.#nB.get(e);if(s)return s;let n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(t=>{if(this.destroyed)throw Error("Transport destroyed");t.refStr&&this.#nF.set(t.refStr,i);let s=new iE(e,t,this,this._params.pdfBug);return this.#nI.set(e,s),s});return this.#nB.set(e,n),n}async getPageIndex(t){if(!tK(t))throw Error("Invalid pageIndex request.");let e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen});return this.#nb.getPageNumber(e+1)-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.#nb.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#nN("GetFieldObjects")}hasJSActions(){return this.#nN("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(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)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#nN("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.#nb.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.#nb.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#nN("GetOptionalContentConfig").then(e=>new eZ(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#nP.get(t);if(e)return e;let i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new eY(t[1]):null,contentDispositionFilename:this.#nD?.filename??null,contentLength:this.#nD?.contentLength??null,hasStructTree:t[2]}));return this.#nP.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#nI.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#nP.clear(),this.filterFactory.destroy(!0),ix.cleanup()}}cachedPageNumber(t){if(!tK(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`,i=this.#nF.get(e);return i>=0?this.#nb.getPageNumber(i+1):null}}class iP{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}}class ik{#nO=null;static #nU=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"u">typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new iP(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(ik.#nU.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ik.#nU.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());let{viewport:i,transform:s,background:n,dependencyTracker:r}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new eq(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r),this.gfx.beginDrawing({transform:s,viewport:i,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#nO&&(window.cancelAnimationFrame(this.#nO),this.#nO=null),ik.#nU.delete(this._canvas),t||=new X(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#nO=window.requestAnimationFrame(()=>{this.#nO=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._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),ik.#nU.delete(this._canvas),this.callback())))}}let iI="5.4.624",iB="384c6208b";class iF{#nz=null;#nH=null;#n$;#nG=null;#nj=!1;#nV=!1;#u=null;#nW;#nX=null;#C=null;static #nq=null;static get _keyboardManager(){return _(this,"_keyboardManager",new tD([[["Escape","mac+Escape"],iF.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],iF.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],iF.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],iF.prototype._moveToPrevious],[["Home","mac+Home"],iF.prototype._moveToBeginning],[["End","mac+End"],iF.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#nV=!1,this.#u=t):this.#nV=!0,this.#C=t?._uiManager||e,this.#nW=this.#C._eventBus,this.#n$=t?.color?.toUpperCase()||this.#C?.highlightColors.values().next().value||"#FFFF98",iF.#nq||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#nz=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#u&&(t.ariaControls=`${this.#u.id}_colorpicker_dropdown`);let e=this.#C._signal;t.addEventListener("click",this.#nK.bind(this),{signal:e}),t.addEventListener("keydown",this.#nY.bind(this),{signal:e});let i=this.#nH=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#n$,t.append(i),t}renderMainDropdown(){let t=this.#nG=this.#nQ();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#nQ(){let t=document.createElement("div"),e=this.#C._signal;for(let[i,s]of(t.addEventListener("contextmenu",tt,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#u&&(t.id=`${this.#u.id}_colorpicker_dropdown`),this.#C.highlightColors)){let n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",iF.#nq[i]);let r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.ariaSelected=s===this.#n$,n.addEventListener("click",this.#nJ.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#nY.bind(this),{signal:e}),t}#nJ(t,e){e.stopPropagation(),this.#nW.dispatch("switchannotationeditorparams",{source:this,type:h.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#nz)return void this.#nK(t);let e=t.target.getAttribute("data-color");e&&this.#nJ(e,t)}_moveToNext(t){this.#nZ?t.target===this.#nz?this.#nG.firstElementChild?.focus():t.target.nextSibling?.focus():this.#nK(t)}_moveToPrevious(t){if(t.target===this.#nG?.firstElementChild||t.target===this.#nz){this.#nZ&&this._hideDropdownFromKeyboard();return}this.#nZ||this.#nK(t),t.target.previousSibling?.focus()}_moveToBeginning(t){this.#nZ?this.#nG.firstElementChild?.focus():this.#nK(t)}_moveToEnd(t){this.#nZ?this.#nG.lastElementChild?.focus():this.#nK(t)}#nY(t){iF._keyboardManager.exec(this,t)}#nK(t){if(this.#nZ)return void this.hideDropdown();if(this.#nj=0===t.detail,this.#nX||(this.#nX=new AbortController,window.addEventListener("pointerdown",this.#v.bind(this),{signal:this.#C.combinedSignal(this.#nX)})),this.#nz.ariaExpanded="true",this.#nG)return void this.#nG.classList.remove("hidden");let e=this.#nG=this.#nQ();this.#nz.append(e)}#v(t){this.#nG?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#nG?.classList.add("hidden"),this.#nz.ariaExpanded="false",this.#nX?.abort(),this.#nX=null}get #nZ(){return this.#nG&&!this.#nG.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#nV){if(!this.#nZ)return void this.#u?.unselect();this.hideDropdown(),this.#nz.focus({preventScroll:!0,focusVisible:this.#nj})}}updateColor(t){if(this.#nH&&(this.#nH.style.backgroundColor=t),!this.#nG)return;let e=this.#C.highlightColors.values();for(let i of this.#nG.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#nz?.remove(),this.#nz=null,this.#nH=null,this.#nG?.remove(),this.#nG=null}}class iL{#n0=null;#u=null;#C=null;static #nq=null;constructor(t){this.#u=t,this.#C=t._uiManager,iL.#nq||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#n0)return this.#n0;let{editorType:t,colorType:e,color:i}=this.#u,s=this.#n0=document.createElement("input");return s.type="color",s.value=i||"#000000",s.className="basicColorPicker",s.tabIndex=0,s.setAttribute("data-l10n-id",iL.#nq[t]),s.addEventListener("input",()=>{this.#C.updateParams(e,s.value)},{signal:this.#C._signal}),s}update(t){this.#n0&&(this.#n0.value=t)}destroy(){this.#n0?.remove(),this.#n0=null}hideDropdown(){}}function iR(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function iN(t){return Math.max(0,Math.min(255,255*t))}class iO{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}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=iN(t),t,t]}static G_HTML([t]){let e=iR(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(iN)}static RGB_HTML(t){return`#${t.map(iR).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[iN(1-Math.min(1,t+s)),iN(1-Math.min(1,i+s)),iN(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let s=1-t,n=1-e,r=1-i,a=Math.min(s,n,r);return["CMYK",s,n,r,a]}}class iU{create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){v("Abstract method `_createSVG` called.")}}class iz extends iU{_createSVG(t){return document.createElementNS(G,t)}}let iH=new WeakSet,i$=60*new Date().getTimezoneOffset()*1e3;class iG{static create(t){switch(t.data.annotationType){case u.LINK:return new iW(t);case u.TEXT:return new iX(t);case u.WIDGET:switch(t.data.fieldType){case"Tx":return new iK(t);case"Btn":if(t.data.radioButton)return new iJ(t);if(t.data.checkBox)return new iQ(t);return new iZ(t);case"Ch":return new i0(t);case"Sig":return new iY(t)}return new iq(t);case u.POPUP:return new i1(t);case u.FREETEXT:return new i3(t);case u.LINE:return new i5(t);case u.SQUARE:return new i4(t);case u.CIRCLE:return new i6(t);case u.POLYLINE:return new i8(t);case u.CARET:return new i9(t);case u.INK:return new st(t);case u.POLYGON:return new i7(t);case u.HIGHLIGHT:return new se(t);case u.UNDERLINE:return new si(t);case u.SQUIGGLY:return new ss(t);case u.STRIKEOUT:return new sn(t);case u.STAMP:return new sr(t);case u.FILEATTACHMENT:return new sa(t);default:return new ij(t)}}}class ij{#n1=null;#n2=!1;#n3=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return ij._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:i,rect:s}=this.data,n=-1/0,r=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>r?(r=e[t+1],n=e[t+2]):e[t+1]===r&&(n=Math.max(n,e[t+2]));return[n,r]}if(i?.length>=1){for(let t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>r?(r=t[e+1],n=t[e]):t[e+1]===r&&(n=Math.max(n,t[e]));if(n!==1/0)return[n,r]}return s?[s[2],s[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/i,t[1]=100*(t[1]-r)/s,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${o}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${o}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#n3?.popup||this.popup)?.remove(),this.#n3=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#n1||={rect:this.data.rect.slice(0)});let{rect:e,popup:i}=t;e&&this.#n5(e);let s=this.#n3?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#n3.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#n3=null,this.popup=null))}resetEdited(){this.#n1&&(this.#n5(this.#n1.rect),this.#n3?.popup.resetEdited(),this.#n1=null)}#n5(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,0===s?(e.width=`${100*(t[2]-t[0])/n}%`,e.height=`${100*(t[3]-t[1])/r}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof iq||this instanceof iW||(n.tabIndex=0);let{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof i1){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?r.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`:this instanceof iJ&&(r.borderRadius=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:r.borderStyle="solid";break;case 2:r.borderStyle="dashed";break;case 3:A("Unimplemented border style: beveled");break;case 4:A("Unimplemented border style: inset");break;case 5:r.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#n2=!0,r.borderColor=F.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}let l=F.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;r.left=`${100*(l[0]-c)/h}%`,r.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=`${100*a/h}%`,r.height=`${100*o/d}%`):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=this;t%180!=0&&([n,r]=[r,n]),e.style.width=`${100*n/i}%`,e.style.height=`${100*r/s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=iO[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:iO[`${n}_rgb`](r)})};return _(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{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=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail)){let n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,n]of Object.entries(e)){let r=i[s];r&&(r({detail:{[s]:n},target:t}),delete e[s])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,s,n,r]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,a,o,l]=e.subarray(2,6);if(n===t&&r===a&&i===o&&s===l)return}let{style:a}=this.container;if(this.#n2){let{borderColor:e,borderWidth:i}=a;a.borderWidth=0,t=["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="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=n-i,l=r-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let s=2,n=e.length;s<n;s+=8){let n=e[s],a=e[s+1],d=e[s+2],c=e[s+3],p=h.createElement("rect"),g=(d-i)/o,m=(r-a)/l,f=(n-d)/o,b=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#n2&&(t.push("</g></svg>')"),a.backgroundImage=t.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){let e,i,{data:s}=this;t?(e={str:t.text},i=t.date):(e=s.contentsObj,i=s.modificationDate),this.#n3=new i1({data:{color:s.color,titleObj:s.titleObj,modificationDate:i,contentsObj:e,richText:s.richText,parentRect:s.rect,borderStyle:0,id:`popup_${s.id}`,rotation:s.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#n3||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#n3}render(){v("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:n,exportValues:r}of s){if(-1===t||n===e)continue;let s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);if(a&&!iH.has(a)){A(`_getElementsByName - element not allowed: ${n}`);continue}i.push({id:n,exportValue:s,domElement:a})}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&iH.has(s)&&i.push({id:n,exportValue:t,domElement:s})}return i}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(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class iV extends ij{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class iW extends ij{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),s=!0):t.attachment?(this.#n4(i,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#n6(i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&(this.contentElement=i,this.container.append(i)),this.container}#n8(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#n8(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#n8()}#n4(t,e,i="",s=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#n8()}#n6(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#n8()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#n8()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#n8(),!this._fieldObjects){A('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===n&&r.push(i)}else for(let t of Object.values(this._fieldObjects))r.push(...t);let a=this.annotationStorage,o=[];for(let t of r){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!iH.has(i)){A(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class iX extends ij{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let 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.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class iq extends ij{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return I.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})})}_setEventListeners(t,e,i,s){for(let[n,r]of i)("Action"===r||this.data.actions?.[r])&&(("Focus"===r||"Blur"===r)&&(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":F.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e,{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style,r=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=Math.round(t/(1.35*s))||1;e=Math.min(s,r(t/i/1.35))}else e=Math.min(s,r(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));n.fontSize=`calc(${e}px * var(--total-scale-factor))`,n.color=F.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class iK extends iq{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,s){let n=this.annotationStorage;for(let r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),n=s.value||"",r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type=this.data.password?"password":"text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),iH.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;let{datetimeFormat:l,datetimeType:h,timeStep:d}=this.data,c=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let u=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;if(c&&(e.type=h,d&&(e.step=d)),o.userValue){let t=o.userValue;if(c)if("time"===h){let i=new Date(t);e.value=[i.getHours(),i.getMinutes(),i.getSeconds()].map(t=>t.toString().padStart(2,"0")).join(":")}else e.value=new Date(t-i$).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",c||t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s);let n={formattedValue:s};c&&(n.value=s),t.setValue(e,n)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=o.userValue;r&&!(r.length<=s)&&(n.value=o.userValue=r=r.slice(0,s),t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let s=u;u=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{target:i}=t,{value:n}=i;if(c){if(n&&"time"===h){let t=n.split(":").map(t=>parseInt(t,10));n=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else n.includes("T")||(n=`${n}T00:00`),n=new Date(n).valueOf();i.type="text"}o.userValue=n,o.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:a}=s,l=r,h=a;switch(t.inputType){case"deleteWordBackward":{let t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{let t=n.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(u&&i.addEventListener("blur",u),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else(i=document.createElement("div")).textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class iY extends iq{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class iQ extends iq{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let n=document.createElement("input");return iH.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",s=>{let{name:n,checked:r}=s.target;for(let s of this._getElementsByName(n,i)){let i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})}),n.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},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 iJ extends iq{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let n=document.createElement("input");if(iH.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=0,n.addEventListener("change",e=>{let{name:s,checked:n}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})}),n.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;n.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let n=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},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 iZ extends iW{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class i0 extends iq{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");iH.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;for(let t of(!this.data.combo&&(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue;for(let t of s.options)t.selected=t.value===e}),this.data.options)){let e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}let a=t=>{let e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},o=a(!1),l=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){r?.();let n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(let t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){let n=s.options,r=i.detail.remove;n[r].selected=!1,s.remove(r),n.length>0&&-1===Array.prototype.findIndex.call(n,t=>t.selected)&&(n[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){let{index:n,displayValue:r,exportValue:h}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){let{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(let t of n){let{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){let s=new Set(i.detail.indices);for(let t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),s.addEventListener("input",i=>{let s=a(!0),n=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,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)):s.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class i1 extends ij{constructor(t){const{data:e,elements:i,parent:s}=t,n=!!s._commentManager;if(super(t,{isRenderable:!n&&ij._hasPopupData(e)}),this.elements=i,n&&ij._hasPopupData(e)){const t=this.popup=this.#n7();for(const e of i)e.popup=t}else this.popup=null}#n7(){return new i2({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#n7(),i=[];for(let t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${U}${t}`).join(",")),this.container}}class i2{#Y=null;#n9=this.#nY.bind(this);#rt=this.#re.bind(this);#ri=this.#rs.bind(this);#rn=this.#rr.bind(this);#ra=null;#tI=null;#ro=null;#rl=null;#rh=null;#rd=null;#rc=null;#ru=!1;#rp=null;#rg=null;#U=null;#rm=null;#rf=null;#eg=null;#rb=null;#ed=null;#rA=null;#n1=null;#rv=!1;#ry=null;#rw=null;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#tI=t,this.#rA=s,this.#ro=r,this.#ed=a,this.#rd=o,this.#ra=e,this.#rb=l,this.#rc=h,this.#rh=i,this.#Y=c,this.#ry=i[0],this.#rl=ti.toDateObject(n),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),!c&&(this.#rx(),this.#tI.hidden=!0,d&&this.#rr())}#rx(){if(this.#rg)return;this.#rg=new AbortController;let{signal:t}=this.#rg;for(let e of this.trigger)e.addEventListener("click",this.#rn,{signal:t}),e.addEventListener("pointerenter",this.#ri,{signal:t}),e.addEventListener("pointerleave",this.#rt,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#rh)e.container?.addEventListener("keydown",this.#n9,{signal:t})}#r_(){let t=this.#rh.find(t=>t.hasCommentButton);t&&(this.#rf=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#rm){this.#rm.parentNode||this.#ry.container.after(this.#rm);return}if(this.#rf||this.#r_(),!this.#rf)return;let{signal:t}=this.#rg=new AbortController,e=this.#ry.hasOwnCommentButton,i=()=>{this.#Y.toggleCommentPopup(this,!0,void 0,!e)},s=()=>{this.#Y.toggleCommentPopup(this,!1,!0,!e)},n=()=>{this.#Y.toggleCommentPopup(this,!1,!1)};if(e)for(let e of(this.#rm=this.#ry.container,this.trigger))e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#n9,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),e.classList.add("popupTriggerArea");else{let e=this.#rm=document.createElement("button");e.className="annotationCommentButton";let r=this.#ry.container;e.style.zIndex=r.style.zIndex+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#rC(),this.#rS(),e.addEventListener("keydown",this.#n9,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),r.after(e)}}#rS(){if(this.#ry.extraPopupElement&&!this.#ry.editor)return;this.#rm||this.renderCommentButton();let[t,e]=this.#rf,{style:i}=this.#rm;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#rC(){this.#ry.extraPopupElement||(this.#rm||this.renderCommentButton(),this.#rm.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){let{color:t,opacity:e}=this.#ry.commentData;return t?this.#rd._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#rm?.focus()},0)}getData(){let{richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}=this.#ry.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}}get elementBeforePopup(){return this.#rm}get comment(){return this.#rw||=this.#ry.commentText,this.#rw}set comment(t){t!==this.comment&&(this.#ry.commentText=this.#rw=t)}focus(){this.#ry.container?.focus()}get parentBoundingClientRect(){return this.#ry.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#rm&&(this.#rm.classList.toggle("selected",t),this.#rm.ariaExpanded=e)}setSelectedCommentButton(t){this.#rm.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#eg)return this.#eg;let{x:t,y:e,height:i}=this.#rm.getBoundingClientRect(),{x:s,y:n,width:r,height:a}=this.#ry.layer.getBoundingClientRect();return[(t-s)/r,(e+i-n)/a]}set commentPopupPosition(t){this.#eg=t}hasDefaultPopupPosition(){return null===this.#eg}get commentButtonPosition(){return this.#rf}get commentButtonWidth(){return this.#rm.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,i]=this.#eg||this.commentButtonPosition.map(t=>t/100),s=this.parentBoundingClientRect,{x:n,y:r,width:a,height:o}=s;this.#Y.showDialog(null,this,n+e*a,r+i*o,{...t,parentDimensions:s})}render(){if(this.#rp)return;let t=this.#rp=document.createElement("div");if(t.className="popup",this.#ra){let e=t.style.outlineColor=F.makeHexColor(...this.#ra);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#rA?.str){let t=document.createElement("span");t.className="title",e.append(t),{dir:t.dir,str:t.textContent}=this.#rA}if(t.append(e),this.#rl){let t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#rl.valueOf()})),t.dateTime=this.#rl.toISOString(),e.append(t)}tv({html:this.#rT||this.#ro.str,dir:this.#ro?.dir,className:"popupContent"},t),this.#tI.append(t)}get #rT(){let t=this.#ed,e=this.#ro;return t?.str&&(!e?.str||e.str===t.str)&&this.#ed.html||null}get #rE(){return this.#rT?.attributes?.style?.fontSize||0}get #rM(){return this.#rT?.attributes?.style?.color||null}#rD(t){let e=[],i={style:{color:this.#rM,fontSize:this.#rE?`calc(${this.#rE}px * var(--total-scale-factor))`:""}};for(let s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}#nY(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#ru)&&this.#rr()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#Y){i?(this.remove(),this.#rw=null):e&&(e.deleted?this.remove():(this.#rC(),this.#rw=e.text)),t&&(this.#rf=null,this.#r_(),this.#rS());return}i||e?.deleted?this.remove():(this.#rx(),this.#n1||={contentsObj:this.#ro,richText:this.#ed},t&&(this.#U=null),e&&e.text&&(this.#ed=this.#rD(e.text),this.#rl=ti.toDateObject(e.date),this.#ro=null),this.#rp?.remove(),this.#rp=null)}resetEdited(){this.#n1&&({contentsObj:this.#ro,richText:this.#ed}=this.#n1,this.#n1=null,this.#rp?.remove(),this.#rp=null,this.#U=null)}remove(){if(this.#rg?.abort(),this.#rg=null,this.#rp?.remove(),this.#rp=null,this.#rv=!1,this.#ru=!1,this.#rm?.remove(),this.#rm=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#rP(){if(null!==this.#U)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#rd,r=!!this.#rc,a=r?this.#rc:this.#rb;for(let t of this.#rh)if(!a||null!==F.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}let o=F.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#U=[100*(h-s)/e,100*(d-n)/i];let{style:c}=this.#tI;c.left=`${this.#U[0]}%`,c.top=`${this.#U[1]}%`}#rr(){this.#Y?this.#Y.toggleCommentPopup(this,!1):(this.#ru=!this.#ru,this.#ru?(this.#rs(),this.#tI.addEventListener("click",this.#rn),this.#tI.addEventListener("keydown",this.#n9)):(this.#re(),this.#tI.removeEventListener("click",this.#rn),this.#tI.removeEventListener("keydown",this.#n9)))}#rs(){this.#rp||this.render(),this.isVisible?this.#ru&&this.#tI.classList.add("focused"):(this.#rP(),this.#tI.hidden=!1,this.#tI.style.zIndex=parseInt(this.#tI.style.zIndex)+1e3)}#re(){this.#tI.classList.remove("focused"),!this.#ru&&this.isVisible&&(this.#tI.hidden=!0,this.#tI.style.zIndex=parseInt(this.#tI.style.zIndex)-1e3)}forceHide(){this.#rv=this.isVisible,this.#rv&&(this.#tI.hidden=!0)}maybeShow(){this.#Y||(this.#rx(),this.#rv&&(this.#rp||this.#rs(),this.#rv=!1,this.#tI.hidden=!1))}get isVisible(){return!this.#Y&&!1===this.#tI.hidden}}class i3 extends ij{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=l.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=this.contentElement=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class i5 extends ij{#rk=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=this.#rk=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"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#rk}addHighlightArea(){this.container.classList.add("highlightArea")}}class i4 extends ij{#rI=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#rI=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#rI}addHighlightArea(){this.container.classList.add("highlightArea")}}class i6 extends ij{#rB=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#rB=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#rB}addHighlightArea(){this.container.classList.add("highlightArea")}}class i8 extends ij{#rF=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:n,height:r}=this;if(!e)return this.container;let a=this.svgFactory.create(n,r,!0),o=[];for(let i=0,s=e.length;i<s;i+=2){let s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");let l=this.#rF=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#rF}addHighlightArea(){this.container.classList.add("highlightArea")}}class i7 extends i8{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class i9 extends ij{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class st extends ij{#rL=null;#rR=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?l.HIGHLIGHT:l.INK}#rN(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#rN(e,t),l=this.svgFactory.create(a,o,!0),h=this.#rL=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#rR.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:s}=t,n=this.#rL;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#rR.length;t<e;t++)this.#rR[t].setAttribute("points",i[t].join(","));if(s){let{transform:t,width:e,height:i}=this.#rN(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#rR}addHighlightArea(){this.container.classList.add("highlightArea")}}class se extends ij{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=l.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class si extends ij{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class ss extends ij{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sn extends ij{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){let e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sr extends ij{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=l.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class sa extends ij{#rO=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(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#rU.bind(this)),this.#rO=t;let{isMac:s}=I.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#rU()}),!i.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#rO}addHighlightArea(){this.container.classList.add("highlightArea")}#rU(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class so{#rz=null;#rH=null;#X=null;#r$=new Map;#rG=null;#rj=null;#rh=[];#rV=!1;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#rz=e,this.#rH=i,this.#rG=a||null,this.#rj=l||null,this.#X=h||new tU,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s,this._commentManager=o||null}hasEditableAnnotations(){return this.#r$.size>0}async render(t){let{annotations:e}=t,i=this.div;to(i,this.viewport);let s=new Map,n=[],r={data:null,layer:i,linkService:this.#rj,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new iz,annotationStorage:this.#X,enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=t.annotationType===u.POPUP;if(e){let e=s.get(t.id);if(!e)continue;if(!this._commentManager){n.push(t);continue}r.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;r.data=t;let i=iG.create(r);if(!i.isRenderable)continue;if(!e&&(this.#rh.push(i),t.popupRef)){let e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}let a=i.render();t.hidden&&(a.style.visibility="hidden"),i._isEditable&&(this.#r$.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}for(let t of(await this.#rW(),n)){let e=r.elements=s.get(t.id);r.data=t;let i=iG.create(r);if(!i.isRenderable)continue;let n=i.render();i.contentElement.id=`${U}${t.id}`,t.hidden&&(n.style.visibility="hidden"),e.at(-1).container.after(n)}this.#rX()}async #rW(){if(0===this.#rh.length)return;this.div.replaceChildren();let t=[];if(!this.#rV)for(let{contentElement:e,data:{id:i}}of(this.#rV=!0,this.#rh)){let s=e.id=`${U}${i}`;t.push(this.#rG?.getAriaAttributes(s).then(t=>{if(t)for(let[i,s]of t)e.setAttribute(i,s)}))}this.#rh.sort(({data:{rect:[t,e,i,s]}},{data:{rect:[n,r,a,o]}})=>{if(t===i&&e===s)return 1;if(n===a&&r===o)return -1;let l=(e+s)/2,h=(r+o)/2;return l>=o&&h<=e?-1:h>=s&&l<=r?1:(t+i)/2-(n+a)/2});let e=document.createDocumentFragment();for(let t of this.#rh)e.append(t.container),this._commentManager?(t.extraPopupElement?.popup||t.popup)?.renderCommentButton():t.extraPopupElement&&e.append(t.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#rz)for(let t of this.#rh)this.#rz.addPointerInTextLayer(t.contentElement,!1)}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#rj,svgFactory:new iz,parent:this};for(let i of t){i.borderStyle||=so._defaultBorderStyle,e.data=i;let t=iG.create(e);t.isRenderable&&(t.render(),t.contentElement.id=`${U}${i.id}`,this.#rh.push(t))}await this.#rW()}update({viewport:t}){let e=this.div;this.viewport=t,to(e,{rotation:t.rotation}),this.#rX(),e.hidden=!1}#rX(){if(!this.#rH)return;let t=this.div;for(let[e,i]of this.#rH){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";let{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i);let r=this.#r$.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),r._hasNoCanvas=!1):r.canvas=i)}this.#rH.clear()}getEditableAnnotations(){return Array.from(this.#r$.values())}getEditableAnnotation(t){return this.#r$.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:i,rotation:s}=t,n=new iV({data:{id:i,rect:t.getPDFRect(),rotation:s},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#rj,annotationStorage:this.#X});return n.render(),n.contentElement.id=`${U}${i}`,n.createOrUpdatePopup(),this.#rh.push(n),n}removeAnnotation(t){let e=this.#rh.findIndex(e=>e.data.id===t);if(e<0)return;let[i]=this.#rh.splice(e,1);this.#rz?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(let e of t)e.updateFakeAnnotationElement(this);this.#rW()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return _(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}let sl=/\r\n?|\n/g;class sh extends tL{#rq="";#rK=`${this.id}-editor`;#rY=null;#rE;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=sh.prototype,e=t=>t.isEmpty(),i=tk.TRANSLATE_SMALL,s=tk.TRANSLATE_BIG;return _(this,"_keyboardManager",new tD([[["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:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=l.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||sh._defaultColor||tL._defaultLineColor,this.#rE=t.fontSize||sh._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static initialize(t,e){tL.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case h.FREETEXT_SIZE:sh._defaultFontSize=e;break;case h.FREETEXT_COLOR:sh._defaultColor=e}}updateParams(t,e){switch(t){case h.FREETEXT_SIZE:this.#rQ(e);break;case h.FREETEXT_COLOR:this.#rC(e)}}static get defaultPropertiesToUpdate(){return[[h.FREETEXT_SIZE,sh._defaultFontSize],[h.FREETEXT_COLOR,sh._defaultColor||tL._defaultLineColor]]}get propertiesToUpdate(){return[[h.FREETEXT_SIZE,this.#rE],[h.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new iL(this),[["colorPicker",this._colorPicker]]}get colorType(){return h.FREETEXT_COLOR}#rQ(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#rE)*this.parentScale),this.#rE=t,this.#rJ()},i=this.#rE;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:h.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#rC(t){let e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:h.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-sh._internalPadding*t,-(sh._internalPadding+this.#rE)*t]}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#rY=new AbortController;let t=this._uiManager.combinedSignal(this.#rY);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#rK),this._isDraggable=!0,this.#rY?.abort(),this.#rY=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&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()}#rZ(){let t=[];this.editorDiv.normalize();let e=null;for(let i of this.editorDiv.childNodes)(e?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName)&&(t.push(sh.#r0(i)),e=i);return t.join("\n")}#rJ(){let t,[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,n=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#rq,e=this.#rq=this.#rZ().trimEnd();if(t===e)return;let i=t=>{(this.#rq=t,t)?(this.#r1(),this._uiManager.rebuild(this),this.#rJ()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#rJ()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){sh._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)}get canChangeContent(){return!0}render(){let t,e;if(this.div)return this.div;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#rK),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#rE}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[i,s]=this.parentDimensions;if(this.annotationElementId){let n,r,{position:a}=this._initialData,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:n=t+(a[0]-c)/h,r=e+this.height-(a[1]-u)/d;break;case 90:n=t+(a[0]-c)/h,r=e-(a[1]-u)/d,[o,l]=[l,-o];break;case 180:n=t-this.width+(a[0]-c)/h,r=e-(a[1]-u)/d,[o,l]=[-o,-l];break;case 270:n=t+(a[0]-c-this.height*d)/h,r=e+(a[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(n*i,r*s,o,l)}else this._moveAfterPaste(t,e);this.#r1(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #r0(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(sl,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=sh.#r2(e.getData("text")||"").replaceAll(sl,"\n");if(!s)return;let n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();let r=n.getRangeAt(0);if(!s.includes("\n")){r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),n.collapseToStart();return}let{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(sl,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(sh.#r0(i))}}l.push(a.nodeValue.slice(0,o).replaceAll(sl,""))}else if(a===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(sh.#r0(i))}this.#rq=`${l.join("\n")}${s}${h.join("\n")}`,this.#r1();let d=new Range,c=Math.sumPrecise(l.map(t=>t.length));for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}n.removeAllRanges(),n.addRange(d)}#r1(){if(this.editorDiv.replaceChildren(),this.#rq)for(let t of this.#rq.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#r3(){return this.#rq.replaceAll("\xa0"," ")}static #r2(t){return t.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=sh._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let s=null;if(t instanceof i3){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:a,popupRef:o,richText:h,contentsObj:d,creationDate:c,modificationDate:u},textContent:p,textPosition:g,parent:{page:{pageNumber:m}}}=t;if(!p||0===p.length)return null;s=t={annotationType:l.FREETEXT,color:Array.from(i),fontSize:e,value:p.join("\n"),position:g,pageIndex:m-1,rect:n.slice(0),rotation:r,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:d?.str||null,richText:h,creationDate:c,modificationDate:u}}let n=await super.deserialize(t,e,i);return n.#rE=t.fontSize,n.color=F.makeHexColor(...t.color),n.#rq=sh.#r2(t.value),n._initialData=s,t.comment&&n.setCommentData(t),n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=tL._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#rE,value:this.#r3()});return(this.addComment(i),t)?(i.isCopy=!0,i):this.annotationElementId&&!this.#r5(i)?null:(i.id=this.annotationElementId,i)}#r5(t){let{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==n}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#rE}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren(),this.#rq.split("\n"))){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#rq}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class sd{static PRECISION=1e-4;toSVGPath(){v("Abstract method `toSVGPath` must be implemented.")}get box(){v("Abstract getter `box` must be implemented.")}serialize(t,e){v("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class sc{#r4;#r6=[];#r8;#r7;#r9=[];#at=new Float32Array(18);#ae;#ai;#as;#an;#ar;#aa;#ao=[];static #al=8;static #ah=2;static #ad=sc.#al+sc.#ah;constructor({x:t,y:e},i,s,n,r,a=0){this.#r4=i,this.#aa=n*s,this.#r7=r,this.#at.set([NaN,NaN,NaN,NaN,t,e],6),this.#r8=a,this.#an=sc.#al*s,this.#as=sc.#ad*s,this.#ar=s,this.#ao.push(t,e)}isEmpty(){return isNaN(this.#at[8])}#ac(){let t=this.#at.subarray(4,6),e=this.#at.subarray(16,18),[i,s,n,r]=this.#r4;return[(this.#ae+(t[0]-e[0])/2-i)/n,(this.#ai+(t[1]-e[1])/2-s)/r,(this.#ae+(e[0]-t[0])/2-i)/n,(this.#ai+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#ae=t,this.#ai=e;let[i,s,n,r]=this.#r4,[a,o,l,h]=this.#at.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#as)return!1;let p=u-this.#an,g=p/u,m=g*d,f=g*c,b=a,A=o;a=l,o=h,l+=m,h+=f,this.#ao?.push(t,e);let v=-f/p*this.#aa,y=m/p*this.#aa;return(this.#at.set(this.#at.subarray(2,8),0),this.#at.set([l+v,h+y],4),this.#at.set(this.#at.subarray(14,18),12),this.#at.set([l-v,h-y],16),isNaN(this.#at[6]))?(0===this.#r9.length&&(this.#at.set([a+v,o+y],2),this.#r9.push(NaN,NaN,NaN,NaN,(a+v-i)/n,(o+y-s)/r),this.#at.set([a-v,o-y],14),this.#r6.push(NaN,NaN,NaN,NaN,(a-v-i)/n,(o-y-s)/r)),this.#at.set([b,A,a,o,l,h],6),!this.isEmpty()):((this.#at.set([b,A,a,o,l,h],6),Math.abs(Math.atan2(A-o,b-a)-Math.atan2(f,m))<Math.PI/2)?([a,o,l,h]=this.#at.subarray(2,6),this.#r9.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+h)/2-s)/r),[a,o,b,A]=this.#at.subarray(14,18),this.#r6.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/n,((A+o)/2-s)/r)):([b,A,a,o,l,h]=this.#at.subarray(0,6),this.#r9.push(((b+5*a)/6-i)/n,((A+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),[l,h,a,o,b,A]=this.#at.subarray(12,18),this.#r6.push(((b+5*a)/6-i)/n,((A+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#r9,e=this.#r6;if(isNaN(this.#at[6])&&!this.isEmpty())return this.#au();let i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#ap(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#ag(i),i.join(" ")}#au(){let[t,e,i,s]=this.#r4,[n,r,a,o]=this.#ac();return`M${(this.#at[2]-t)/i} ${(this.#at[3]-e)/s} L${(this.#at[4]-t)/i} ${(this.#at[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#at[16]-t)/i} ${(this.#at[17]-e)/s} L${(this.#at[14]-t)/i} ${(this.#at[15]-e)/s} Z`}#ag(t){let e=this.#r6;t.push(`L${e[4]} ${e[5]} Z`)}#ap(t){let[e,i,s,n]=this.#r4,r=this.#at.subarray(4,6),a=this.#at.subarray(16,18),[o,l,h,d]=this.#ac();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new su(t,e,i,s,n,r)}getOutlines(){let t=this.#r9,e=this.#r6,i=this.#at,[s,n,r,a]=this.#r4,o=new Float32Array((this.#ao?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ao[t]-s)/r,o[t+1]=(this.#ao[t+1]-n)/a;if(o[o.length-2]=(this.#ae-s)/r,o[o.length-1]=(this.#ai-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#am(o);let l=new Float32Array(this.#r9.length+24+this.#r6.length),h=t.length;for(let e=0;e<h;e+=2){if(isNaN(t[e])){l[e]=l[e+1]=NaN;continue}l[e]=t[e],l[e+1]=t[e+1]}h=this.#af(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2}return this.#ab(l,h),this.newFreeDrawOutline(l,o,this.#r4,this.#ar,this.#r8,this.#r7)}#am(t){let e=this.#at,[i,s,n,r]=this.#r4,[a,o,l,h]=this.#ac(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#r4,this.#ar,this.#r8,this.#r7)}#ab(t,e){let i=this.#r6;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#af(t,e){let i=this.#at.subarray(4,6),s=this.#at.subarray(16,18),[n,r,a,o]=this.#r4,[l,h,d,c]=this.#ac();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+=24}}class su extends sd{#r4;#aA=new Float32Array(4);#r8;#r7;#ao;#ar;#av;constructor(t,e,i,s,n,r){super(),this.#av=t,this.#ao=e,this.#r4=i,this.#ar=s,this.#r8=n,this.#r7=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#ay(r);const[a,o,l,h]=this.#aA;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#av[4]} ${this.#av[5]}`];for(let e=6,i=this.#av.length;e<i;e+=6){if(isNaN(this.#av[e])){t.push(`L${this.#av[e+4]} ${this.#av[e+5]}`);continue}t.push(`C${this.#av[e]} ${this.#av[e+1]} ${this.#av[e+2]} ${this.#av[e+3]} ${this.#av[e+4]} ${this.#av[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){let r,a,o=i-t,l=s-e;switch(n){case 0:r=sd._rescale(this.#av,t,s,o,-l),a=sd._rescale(this.#ao,t,s,o,-l);break;case 90:r=sd._rescaleAndSwap(this.#av,t,e,o,l),a=sd._rescaleAndSwap(this.#ao,t,e,o,l);break;case 180:r=sd._rescale(this.#av,i,e,-o,l),a=sd._rescale(this.#ao,i,e,-o,l);break;case 270:r=sd._rescaleAndSwap(this.#av,i,s,-o,-l),a=sd._rescaleAndSwap(this.#ao,i,s,-o,-l)}return{outline:Array.from(r),points:[Array.from(a)]}}#ay(t){let e=this.#av,i=e[4],s=e[5],n=[i,s,i,s],r=i,a=s,o=i,l=s,h=t?Math.max:Math.min,d=new Float32Array(4);for(let t=6,c=e.length;t<c;t+=6){let c=e[t+4],u=e[t+5];isNaN(e[t])?(F.pointBoundingBox(c,u,n),a>u?(r=c,a=u):a===u&&(r=h(r,c)),l<u?(o=c,l=u):l===u&&(o=h(o,c))):(d[0]=d[1]=1/0,d[2]=d[3]=-1/0,F.bezierBoundingBox(i,s,...e.slice(t,t+6),d),F.rectBoundingBox(d[0],d[1],d[2],d[3],n),a>d[1]?(r=d[0],a=d[1]):a===d[1]&&(r=h(r,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=h(o,d[2]))),i=c,s=u}let c=this.#aA;c[0]=n[0]-this.#r8,c[1]=n[1]-this.#r8,c[2]=n[2]-n[0]+2*this.#r8,c[3]=n[3]-n[1]+2*this.#r8,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#aA}newOutliner(t,e,i,s,n,r=0){return new sc(t,e,i,s,n,r)}getNewOutline(t,e){let[i,s,n,r]=this.#aA,[a,o,l,h]=this.#r4,d=n*l,c=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#ao[0]*d+u,y:this.#ao[1]*c+p},this.#r4,this.#ar,t,this.#r7,e??this.#r8);for(let t=2;t<this.#ao.length;t+=2)g.add({x:this.#ao[t]*d+u,y:this.#ao[t+1]*c+p});return g.getOutlines()}}class sp{#r4;#aw;#ax;#a_=[];#aC=[];constructor(t,e=0,i=0,s=!0){const n=[1/0,1/0,-1/0,-1/0];for(const{x:i,y:s,width:r,height:a}of t){const t=1e-4*Math.floor((i-e)/1e-4),o=1e-4*Math.ceil((i+r+e)/1e-4),l=1e-4*Math.floor((s-e)/1e-4),h=1e-4*Math.ceil((s+a+e)/1e-4),d=[t,l,h,!0],c=[o,l,h,!1];this.#a_.push(d,c),F.rectBoundingBox(t,l,o,h,n)}const r=n[2]-n[0]+2*i,a=n[3]-n[1]+2*i,o=n[0]-i,l=n[1]-i;let h=s?-1/0:1/0,d=1/0;const c=this.#a_.at(s?-1:-2),u=[c[0],c[2]];for(const t of this.#a_){const[e,i,n,c]=t;!c&&s?i<d?(d=i,h=e):i===d&&(h=Math.max(h,e)):c&&!s&&(i<d?(d=i,h=e):i===d&&(h=Math.min(h,e))),t[0]=(e-o)/r,t[1]=(i-l)/a,t[2]=(n-l)/a}this.#r4=new Float32Array([o,l,r,a]),this.#aw=[h,d],this.#ax=u}getOutlines(){this.#a_.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#a_)e[3]?(t.push(...this.#aS(e)),this.#aT(e)):(this.#aE(e),t.push(...this.#aS(e)));return this.#aM(t)}#aM(t){let e,i=[],s=new Set;for(let e of t){let[t,s,n]=e;i.push([t,s,e],[t,n,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],n=i[t+1][2];e.push(n),n.push(e),s.add(e),s.add(n)}let n=[];for(;s.size>0;){let t=s.values().next().value,[i,r,a,o,l]=t;s.delete(t);let h=i,d=r;for(e=[i,a],n.push(e);;){let t;if(s.has(o))t=o;else if(s.has(l))t=l;else break;s.delete(t),[i,r,a,o,l]=t,h!==i&&(e.push(h,d,i,d===r?r:a),h=i),d=d===r?a:r}e.push(h,d)}return new sg(n,this.#r4,this.#aw,this.#ax)}#aD(t){let e=this.#aC,i=0,s=e.length-1;for(;i<=s;){let n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#aT([,t,e]){let i=this.#aD(t);this.#aC.splice(i,0,[t,e])}#aE([,t,e]){let i=this.#aD(t);for(let s=i;s<this.#aC.length;s++){let[i,n]=this.#aC[s];if(i!==t)break;if(i===t&&n===e)return void this.#aC.splice(s,1)}for(let s=i-1;s>=0;s--){let[i,n]=this.#aC[s];if(i!==t)break;if(i===t&&n===e)return void this.#aC.splice(s,1)}}#aS(t){let[e,i,s]=t,n=[[e,i,s]],r=this.#aD(s);for(let t=0;t<r;t++){let[i,s]=this.#aC[t];for(let t=0,r=n.length;t<r;t++){let[,a,o]=n[t];if(!(s<=a)&&!(o<=i)){if(a>=i){if(o>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}continue}n[t][2]=i,o>s&&n.push([e,s,o])}}}return n}}class sg extends sd{#r4;#aP;constructor(t,e,i,s){super(),this.#aP=t,this.#r4=e,this.firstPoint=i,this.lastPoint=s}toSVGPath(){let t=[];for(let e of this.#aP){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){let r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){let r=[],a=i-t,o=s-e;for(let e of this.#aP){let i=Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*a,i[n+1]=s-e[n+1]*o;r.push(i)}return r}get box(){return this.#r4}get classNamesForOutlining(){return["highlightOutline"]}}class sm extends sc{newFreeDrawOutline(t,e,i,s,n,r){return new sf(t,e,i,s,n,r)}}class sf extends su{newOutliner(t,e,i,s,n,r=0){return new sm(t,e,i,s,n,r)}}class sb extends tL{#ak=null;#aI=0;#aB;#aF=null;#c=null;#aL=null;#aR=null;#aN=0;#aO=null;#aU=null;#I=null;#az=!1;#aw=null;#ax=null;#aH=null;#ec="";#aa;#a$="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=l.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=sb.prototype;return _(this,"_keyboardManager",new tD([[["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||sb._defaultColor,this.#aa=t.thickness||sb._defaultThickness,this.opacity=t.opacity||sb._defaultOpacity,this.#aB=t.boxes||null,this.#a$=t.methodOfCreation||"",this.#ec=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#az=!0,this.#aG(t),this.#aj()):this.#aB&&(this.#ak=t.anchorNode,this.#aI=t.anchorOffset,this.#aR=t.focusNode,this.#aN=t.focusOffset,this.#aV(),this.#aj(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#az?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#aa,methodOfCreation:this.#a$}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#aV(){let t=new sp(this.#aB,.001);this.#aU=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#aU.box;let e=new sp(this.#aB,.0025,.001,"ltr"===this._uiManager.direction);this.#aL=e.getOutlines();let{firstPoint:i}=this.#aU;this.#aw=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];let{lastPoint:s}=this.#aL;this.#ax=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#aG({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#aU=t,this.#aL=t.getNewOutline(this.#aa/2+1.5,.0025),e>=0)this.#I=e,this.#aF=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#aH=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#aL.box,path:{d:this.#aL.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#I,{bbox:sb.#aW(this.#aU.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#aH,{bbox:sb.#aW(this.#aL.box,e),path:{d:this.#aL.toSVGPath()}})}let[s,n,r,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=a;break;case 90:{let[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=a;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=a*t/e}}let{firstPoint:o}=t;this.#aw=[(o[0]-s)/r,(o[1]-n)/a];let{lastPoint:l}=this.#aL;this.#ax=[(l[0]-s)/r,(l[1]-n)/a]}static initialize(t,e){tL.initialize(t,e),sb._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case h.HIGHLIGHT_COLOR:sb._defaultColor=e;break;case h.HIGHLIGHT_THICKNESS:sb._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#ax}get commentButtonPosition(){return this.#aw}updateParams(t,e){switch(t){case h.HIGHLIGHT_COLOR:this.#rC(e);break;case h.HIGHLIGHT_THICKNESS:this.#aX(e)}}static get defaultPropertiesToUpdate(){return[[h.HIGHLIGHT_COLOR,sb._defaultColor],[h.HIGHLIGHT_THICKNESS,sb._defaultThickness]]}get propertiesToUpdate(){return[[h.HIGHLIGHT_COLOR,this.color||sb._defaultColor],[h.HIGHLIGHT_THICKNESS,this.#aa||sb._defaultThickness],[h.HIGHLIGHT_FREE,this.#az]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#I,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#c?.updateColor(this.color),super.onUpdatedColor()}#rC(t){let e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,sb._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:h.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#aX(t){let e=this.#aa,i=t=>{this.#aa=t,this.#aq(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:h.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#c=new iF({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#aK())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#aK())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#aY(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#aj(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#aY():t&&(this.#aj(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#aq(t){this.#az&&(this.#aG({highlightOutlines:this.#aU.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#aY(){null!==this.#I&&this.parent&&(this.parent.drawLayer.remove(this.#I),this.#I=null,this.parent.drawLayer.remove(this.#aH),this.#aH=null)}#aj(t=this.parent){null===this.#I&&({id:this.#I,clipPathId:this.#aF}=t.drawLayer.draw({bbox:this.#aU.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#az},path:{d:this.#aU.toSVGPath()}},!1,!0),this.#aH=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#az},bbox:this.#aL.box,path:{d:this.#aL.toSVGPath()}},this.#az),this.#aO&&(this.#aO.style.clipPath=this.#aF))}static #aW([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){let e,{drawLayer:i}=this.parent;this.#az?(t=(t-this.rotation+360)%360,e=sb.#aW(this.#aU.box,t)):e=sb.#aW([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#I,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#aH,{bbox:sb.#aW(this.#aL.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#ec&&(t.setAttribute("aria-label",this.#ec),t.setAttribute("role","mark")),this.#az?t.classList.add("free"):this.div.addEventListener("keydown",this.#aQ.bind(this),{signal:this._uiManager._signal});let e=this.#aO=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#aF,this.setDims(),tC(this,this.#aO,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#aH,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#aH,{rootClass:{hovered:!1}})}#aQ(t){sb._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#aJ(!0);break;case 1:case 3:this.#aJ(!1)}}#aJ(t){if(!this.#ak)return;let e=window.getSelection();t?e.setPosition(this.#ak,this.#aI):e.setPosition(this.#aR,this.#aN)}select(){super.select(),this.#aH&&this.parent?.drawLayer.updateProperties(this.#aH,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#aH&&(this.parent?.drawLayer.updateProperties(this.#aH,{rootClass:{selected:!1}}),this.#az||this.#aJ(!1))}get _mustFixPosition(){return!this.#az}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#I,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#aH,{rootClass:{hidden:!t}}))}#aK(){return this.#az?this.rotation:0}#aZ(){if(this.#az)return null;let[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#aB,r=new Float32Array(8*n.length),a=0;for(let{x:o,y:l,width:h,height:d}of n){let n=o*t+i,c=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=c,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=c-d*e,a+=8}return r}#a0(t){return this.#aU.serialize(t,this.#aK())}static startHighlighting(t,e,{target:i,x:s,y:n}){let{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#a1(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",te,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",tt,{signal:d}),i.addEventListener("pointermove",this.#a2.bind(this,t),{signal:d}),this._freeHighlight=new sm({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static #a2(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static #a1(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(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 async deserialize(t,e,i){let s=null;if(t instanceof se){let{data:{quadPoints:e,rect:i,rotation:n,id:r,color:a,opacity:o,popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:l.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}else if(t instanceof st){let{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,borderStyle:{rawWidth:o},popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:l.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}let{color:n,quadPoints:r,inkLists:a,opacity:o}=t,h=await super.deserialize(t,e,i);h.color=F.makeHexColor(...n),h.opacity=o||1,a&&(h.#aa=t.thickness),h._initialData=s,t.comment&&h.setCommentData(t);let[d,c]=h.pageDimensions,[u,p]=h.pageTranslation;if(r){let t=h.#aB=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-u)/d,y:1-(r[e+1]-p)/c,width:(r[e+2]-r[e])/d,height:(r[e+1]-r[e+5])/c});h.#aV(),h.#aj(),h.rotate(h.rotation)}else if(a){h.#az=!0;let t=a[0],i={x:t[0]-u,y:c-(t[1]-p)},s=new sm(i,[0,0,d,c],1,h.#aa/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-u,i.y=c-(t[e+1]-p),s.add(i);let{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);h.#aG({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),h.#aj(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=tL._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return(Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#aa,quadPoints:this.#aZ(),outlines:this.#a0(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#r5(i))?null:(i.id=this.annotationElementId,i)}#r5(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class sA{#a3=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#a3[t]=e}toSVGProperties(){let t=this.#a3;return this.#a3=Object.create(null),{root:t}}reset(){this.#a3=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){v("Not implemented")}}class sv extends tL{#a5=null;#a4;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static #a6=null;static #a8=null;static #a7=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#a4=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines(t){t.drawOutlines&&(this.#a9(t),this.#aj())}#a9({drawOutlines:t,drawId:e,drawingOptions:i}){this.#a5=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#ot(t,this.parent),this.#oe(t.box)}#ot(t,e){let{id:i}=e.drawLayer.draw(sv._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){v("Not implemented")}static get typesMap(){v("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(sv.#a6.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){let s=this._drawingOptions,n=s[e],r=i=>{s.updateProperty(e,i);let n=this.#a5.updateProperty(e,i);n&&this.#oe(n),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,sv._mergeSVGProperties(this.#a5.getPathResizingSVGProperties(this.#oi()),{bbox:this.#os()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,sv._mergeSVGProperties(this.#a5.getPathResizedSVGProperties(this.#oi()),{bbox:this.#os()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#os()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,sv._mergeSVGProperties(this.#a5.getPathTranslatedSVGProperties(this.#oi(),this.parentDimensions),{bbox:this.#os()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#a4&&(this.#a4=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#aY(),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#aj(),this.#oe(this.#a5.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#aY()):t&&(this._uiManager.addShouldRescale(this),this.#aj(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#aY(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#aj(t=this.parent){if(null===this._drawId||this.parent!==t){if(null!==this._drawId)return void this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);this._drawingOptions.updateAll(),this._drawId=this.#ot(this.#a5,t)}}#on([t,e,i,s]){let{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,r/n*i,n/r*s];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,r/n*i,n/r*s];default:return[t,e,i,s]}}#oi(){let{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,n/r*i,r/n*s];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,n/r*i,r/n*s];default:return[t,e,i,s]}}#oe(t){[this.x,this.y,this.width,this.height]=this.#on(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#os(){let{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-a/o*i,o/a*s,a/o*i];case 5:return[1-e,t,a/o*i,o/a*s];case 6:return[1-t-o/a*s,1-e,o/a*s,a/o*i];case 7:return[e-a/o*i,1-t-o/a*s,a/o*i,o/a*s];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-o/a*s,e,o/a*s,a/o*i];case 13:return[1-e-a/o*i,t-o/a*s,a/o*i,o/a*s];case 14:return[1-t,1-e-a/o*i,o/a*s,a/o*i];case 15:return[e,1-t,a/o*i,o/a*s];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,sv._mergeSVGProperties({bbox:this.#os()},this.#a5.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#oe(this.#a5.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){let t,e;if(this.div)return this.div;this._isCopy&&(t=this.x,e=this.y);let i=super.render();i.classList.add("draw");let s=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){v("Not implemented")}static startDrawing(t,e,i,s){let{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=s;if(tS.isInitializedAndDifferentPointerType(l))return;let{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=sv.#a8=new AbortController,p=t.combinedSignal(u);(tS.setPointer(l,o),window.addEventListener("pointerup",t=>{tS.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)},{signal:p}),window.addEventListener("pointercancel",t=>{tS.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",t=>{tS.isSamePointerType(t.pointerType)&&(tS.initializeAndAddPointerId(t.pointerId),sv.#a6.isCancellable()&&(sv.#a6.removeLastElement(),sv.#a6.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",tt,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",t=>{tS.isSameTimeStamp(t.timeStamp)&&te(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),sv.#a6)?t.drawLayer.updateProperties(this._currentDrawId,sv.#a6.startNew(r,a,d,c,h)):(e.updateUIForDefaultProperties(this),sv.#a6=this.createDrawerInstance(r,a,d,c,h),sv.#a7=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(sv.#a7.toSVGProperties(),sv.#a6.defaultSVGProperties),!0,!1))}static _drawMove(t){if(tS.isSameTimeStamp(t.timeStamp),!sv.#a6)return;let{offsetX:e,offsetY:i,pointerId:s}=t;if(tS.isSamePointerId(s)){if(tS.isUsingMultiplePointers())return void this._endDraw(t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,sv.#a6.add(e,i)),tS.setTimeStamp(t.timeStamp),te(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,sv.#a6=null,sv.#a7=null,tS.clearTimeStamp()),sv.#a8&&(sv.#a8.abort(),sv.#a8=null,tS.clearPointerIds())}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,sv.#a6.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=sv.#a6,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:h.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(h.DRAW_STEP),!sv.#a6.isEmpty()){let{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:sv.#a6.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:sv.#a7,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){v("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#a9({drawOutlines:o}),l.#aj(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#a5.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class sy{#at=new Float64Array(6);#rk;#or;#s2;#aa;#ao;#oa="";#oo=0;#aP=new sw;#ol;#oh;constructor(t,e,i,s,n,r){this.#ol=i,this.#oh=s,this.#s2=n,this.#aa=r,[t,e]=this.#od(t,e);const a=this.#rk=[NaN,NaN,NaN,NaN,t,e];this.#ao=[t,e],this.#or=[{line:a,points:this.#ao}],this.#at.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#aa=e)}#od(t,e){return sd._normalizePoint(t,e,this.#ol,this.#oh,this.#s2)}isEmpty(){return!this.#or||0===this.#or.length}isCancellable(){return this.#ao.length<=10}add(t,e){[t,e]=this.#od(t,e);let[i,s,n,r]=this.#at.subarray(2,6),a=t-n,o=e-r;return 2>=Math.hypot(this.#ol*a,this.#oh*o)?null:((this.#ao.push(t,e),isNaN(i))?(this.#at.set([n,r,t,e],2),this.#rk.push(NaN,NaN,NaN,NaN,t,e)):(isNaN(this.#at[0])&&this.#rk.splice(6,6),this.#at.set([i,s,n,r,t,e],0),this.#rk.push(...sd.createBezierPoints(i,s,n,r,t,e))),{path:{d:this.toSVGPath()}})}end(t,e){let i=this.add(t,e);return i||(2===this.#ao.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#ol=i,this.#oh=s,this.#s2=n,[t,e]=this.#od(t,e);let r=this.#rk=[NaN,NaN,NaN,NaN,t,e];this.#ao=[t,e];let a=this.#or.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#or.push({line:r,points:this.#ao}),this.#at.set(r,0),this.#oo=0,this.toSVGPath(),null}getLastElement(){return this.#or.at(-1)}setLastElement(t){return this.#or?(this.#or.push(t),this.#rk=t.line,this.#ao=t.points,this.#oo=0,{path:{d:this.toSVGPath()}}):this.#aP.setLastElement(t)}removeLastElement(){if(!this.#or)return this.#aP.removeLastElement();this.#or.pop(),this.#oa="";for(let t=0,e=this.#or.length;t<e;t++){let{line:e,points:i}=this.#or[t];this.#rk=e,this.#ao=i,this.#oo=0,this.toSVGPath()}return{path:{d:this.#oa}}}toSVGPath(){let t=sd.svgRound(this.#rk[4]),e=sd.svgRound(this.#rk[5]);if(2===this.#ao.length)return this.#oa=`${this.#oa} M ${t} ${e} Z`,this.#oa;if(this.#ao.length<=6){let i=this.#oa.lastIndexOf("M");this.#oa=`${this.#oa.slice(0,i)} M ${t} ${e}`,this.#oo=6}if(4===this.#ao.length){let t=sd.svgRound(this.#rk[10]),e=sd.svgRound(this.#rk[11]);return this.#oa=`${this.#oa} L ${t} ${e}`,this.#oo=12,this.#oa}let i=[];0===this.#oo&&(i.push(`M ${t} ${e}`),this.#oo=6);for(let t=this.#oo,e=this.#rk.length;t<e;t+=6){let[e,s,n,r,a,o]=this.#rk.slice(t,t+6).map(sd.svgRound);i.push(`C${e} ${s} ${n} ${r} ${a} ${o}`)}return this.#oa+=i.join(" "),this.#oo=this.#rk.length,this.#oa}getOutlines(t,e,i,s){let n=this.#or.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#aP.build(this.#or,t,e,i,this.#s2,this.#aa,s),this.#at=null,this.#rk=null,this.#or=null,this.#oa=null,this.#aP}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class sw extends sd{#aA;#oc=0;#r8;#or;#ol;#oh;#ou;#s2;#aa;build(t,e,i,s,n,r,a){this.#ol=e,this.#oh=i,this.#ou=s,this.#s2=n,this.#aa=r,this.#r8=a??0,this.#or=t,this.#op()}get thickness(){return this.#aa}setLastElement(t){return this.#or.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#or.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#or){if(t.push(`M${sd.svgRound(e[4])} ${sd.svgRound(e[5])}`),6===e.length){t.push("Z");continue}if(12===e.length&&isNaN(e[6])){t.push(`L${sd.svgRound(e[10])} ${sd.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){let[s,n,r,a,o,l]=e.subarray(i,i+6).map(sd.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}}return t.join("")}serialize([t,e,i,s],n){let r,a,o,l,h,d,c,u,p,g=[],m=[],[f,b,A,v]=this.#og();switch(this.#s2){case 0:p=sd._rescale,r=t,a=e+s,o=i,l=-s,h=t+f*i,d=e+(1-b-v)*s,c=t+(f+A)*i,u=e+(1-b)*s;break;case 90:p=sd._rescaleAndSwap,r=t,a=e,o=i,l=s,h=t+b*i,d=e+f*s,c=t+(b+v)*i,u=e+(f+A)*s;break;case 180:p=sd._rescale,r=t+i,a=e,o=-i,l=s,h=t+(1-f-A)*i,d=e+b*s,c=t+(1-f)*i,u=e+(b+v)*s;break;case 270:p=sd._rescaleAndSwap,r=t+i,a=e+s,o=-i,l=-s,h=t+(1-b-v)*i,d=e+(1-f-A)*s,c=t+(1-b)*i,u=e+(1-f)*s}for(let{line:t,points:e}of this.#or)g.push(p(t,r,a,o,l,n?Array(t.length):null)),m.push(p(e,r,a,o,l,n?Array(e.length):null));return{lines:g,points:m,rect:[h,d,c,u]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){let h,d,c,u,p,g=[];switch(o){case 0:p=sd._rescale,h=-t/i,d=e/s+1,c=1/i,u=-1/s;break;case 90:p=sd._rescaleAndSwap,h=-e/s,d=-t/i,c=1/s,u=1/i;break;case 180:p=sd._rescale,h=t/i+1,d=-e/s,c=-1/i,u=1/s;break;case 270:p=sd._rescaleAndSwap,h=e/s+1,d=t/i+1,c=-1/s,u=-1/i}if(!r)for(let t of(r=[],a)){let e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){let e=t[r],l=t[r+1];i.set(sd.createBezierPoints(s,n,a,o,e,l),(r-2)*3),[s,n,a,o]=[a,o,e,l]}}for(let t=0,e=r.length;t<e;t++)g.push({line:p(r[t].map(t=>t??NaN),h,d,c,u),points:p(a[t].map(t=>t??NaN),h,d,c,u)});let m=new this.prototype.constructor;return m.build(g,i,s,1,o,l,n),m}#om(t=this.#aa){let e=this.#r8+t/2*this.#ou;return this.#s2%180==0?[e/this.#ol,e/this.#oh]:[e/this.#oh,e/this.#ol]}#og(){let[t,e,i,s]=this.#aA,[n,r]=this.#om(0);return[t+n,e+r,i-2*n,s-2*r]}#op(){let t=this.#aA=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:e}of this.#or){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)F.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){let[r,a,o,l,h,d]=e.subarray(n,n+6);F.bezierBoundingBox(i,s,r,a,o,l,h,d,t),i=h,s=d}}let[e,i]=this.#om();t[0]=z(t[0]-e,0,1),t[1]=z(t[1]-i,0,1),t[2]=z(t[2]+e,0,1),t[3]=z(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#aA}updateProperty(t,e){return"stroke-width"===t?this.#aX(e):null}#aX(t){let[e,i]=this.#om();this.#aa=t;let[s,n]=this.#om(),[r,a]=[s-e,n-i],o=this.#aA;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){let[s,n]=this.#om();this.#ol=t,this.#oh=e,this.#ou=i;let[r,a]=this.#om(),o=r-s,l=a-n,h=this.#aA;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#oc=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#aA.map(sd.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#aA;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sd.svgRound(t)} ${sd.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#aA,i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#oc){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${sd.svgRound(a)} ${sd.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){let[n,r]=this.#om(),[a,o,l,h]=this.#aA;if(Math.abs(l-n)<=sd.PRECISION||Math.abs(h-r)<=sd.PRECISION){let n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${sd.svgRound(t)} ${sd.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}let d=(i-2*n)/(l-2*n),c=(s-2*r)/(h-2*r);return{path:{"transform-origin":`${sd.svgRound(a)} ${sd.svgRound(o)}`,transform:`${this.rotationTransform} scale(${l/i} ${h/s}) translate(${sd.svgRound(n)} ${sd.svgRound(r)}) scale(${d} ${c}) translate(${sd.svgRound(-n)} ${sd.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){let[n,r]=this.#om(),a=this.#aA,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=sd.PRECISION||Math.abs(d-r)<=sd.PRECISION){let n=t+i/2-(o+h/2),r=e+s/2-(l+d/2);for(let{line:t,points:e}of this.#or)sd._translate(t,n,r,t),sd._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sd.svgRound(t)} ${sd.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*n)/(h-2*n),u=(s-2*r)/(d-2*r),p=-c*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#or)sd._rescale(t,p,g,c,u,t),sd._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sd.svgRound(t)} ${sd.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[s,n]=i,r=this.#aA,a=t-r[0],o=e-r[1];if(this.#ol===s&&this.#oh===n)for(let{line:t,points:e}of this.#or)sd._translate(t,a,o,t),sd._translate(e,a,o,e);else{let t=this.#ol/s,e=this.#oh/n;for(let{line:i,points:r}of(this.#ol=s,this.#oh=n,this.#or))sd._rescale(i,a,o,t,e,i),sd._rescale(r,a,o,t,e,r);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${sd.svgRound(t)} ${sd.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#aA;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${sd.svgRound(t[0])} ${sd.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class sx extends sA{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:tL._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){let t=new sx(this._viewParameters);return t.updateAll(this),t}}class s_ extends sv{static _type="ink";static _editorType=l.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){tL.initialize(t,e),this._defaultDrawingOptions=new sx(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return _(this,"typesMap",new Map([[h.INK_THICKNESS,"stroke-width"],[h.INK_COLOR,"stroke"],[h.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new sy(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return sw.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof st){let{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:h},popupRef:d,richText:c,contentsObj:u,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;s=t={annotationType:l.INK,color:Array.from(a),thickness:h,opacity:o,paths:{points:e},boxes:null,pageIndex:m-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:d,richText:c,comment:u?.str||null,creationDate:p,modificationDate:g}}let n=await super.deserialize(t,e,i);return n._initialData=s,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||=new iL(this),[["colorPicker",this._colorPicker]]}get colorType(){return h.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=s_.getDefaultDrawingOptions({stroke:F.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:tL._colorManager.convert(s),opacity:n,thickness:r,paths:{lines:e,points:i}});return(this.addComment(a),t)?(a.isCopy=!0,a):this.annotationElementId&&!this.#r5(a)?null:(a.id=this.annotationElementId,a)}#r5(t){let{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class sC extends sw{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class sS{static #of={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static #ob(t,e,i,s){return(i-=t,s-=e,0===i)?s>0?0:4:1===i?s+6:2-s}static #oA=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static #ov(t,e,i,s,n,r,a){let o=this.#ob(i,s,n,r);for(let n=0;n<8;n++){let r=(-n+o-a+16)%8;if(0!==t[(i+this.#oA[2*r])*e+(s+this.#oA[2*r+1])])return r}return -1}static #oy(t,e,i,s,n,r,a){let o=this.#ob(i,s,n,r);for(let n=0;n<8;n++){let r=(n+o+a+16)%8;if(0!==t[(i+this.#oA[2*r])*e+(s+this.#oA[2*r+1])])return r}return -1}static #ow(t,e,i,s){let n,r=t.length,a=new Int32Array(r);for(let e=0;e<r;e++)a[e]=+(t[e]<=s);for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let o=1,l=[];for(let t=1;t<i-1;t++){n=1;for(let i=1;i<e-1;i++){let s,r=t*e+i,h=a[r];if(0===h)continue;let d=t,c=i;if(1===h&&0===a[r-1])o+=1,c-=1;else if(h>=1&&0===a[r+1])o+=1,c+=1,h>1&&(n=h);else{1!==h&&(n=Math.abs(h));continue}let u=[i,t],p=c===i+1,g={isHole:p,points:u,id:o,parent:0};for(let t of(l.push(g),l))if(t.id===n){s=t;break}s?s.isHole?g.parent=p?s.parent:n:g.parent=p?n:s.parent:g.parent=p?n:0;let m=this.#ov(a,e,t,i,d,c,0);if(-1===m){a[r]=-o,1!==a[r]&&(n=Math.abs(a[r]));continue}let f=this.#oA[2*m],b=this.#oA[2*m+1],A=t+f,v=i+b;d=A,c=v;let y=t,w=i;for(;;){let s=this.#oy(a,e,y,w,d,c,1);f=this.#oA[2*s],b=this.#oA[2*s+1];let l=y+f,h=w+b;u.push(h,l);let p=y*e+w;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&h===i&&y===A&&w===v){1!==a[r]&&(n=Math.abs(a[r]));break}d=y,c=w,y=l,w=h}}}return l}static #ox(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}let n=t[e],r=t[e+1],a=t[i-4]-n,o=t[i-3]-r,l=Math.hypot(a,o),h=a/l,d=o/l,c=h*r-d*n,u=1/l,p=Math.atan(o/a),g=Math.cos(p),m=Math.sin(p),f=u*(Math.abs(g)+Math.abs(m)),b=u*(1-f+f**2),A=Math.max(Math.atan(Math.abs(m+g)*b),Math.atan(Math.abs(m-g)*b)),v=0,y=e;for(let s=e+2;s<i-2;s+=2){let e=Math.abs(c-h*t[s+1]+d*t[s]);e>v&&(y=s,v=e)}v>(l*A)**2?(this.#ox(t,e,y+2,s),this.#ox(t,y,i,s)):s.push(n,r)}static #o_(t){let e=[],i=t.length;return this.#ox(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static #oC(t,e,i,s,n,r){let a=new Float32Array(r**2),o=-2*s**2,l=r>>1;for(let t=0;t<r;t++){let e=(t-l)**2;for(let i=0;i<r;i++)a[t*r+i]=Math.exp((e+(i-l)**2)/o)}let h=new Float32Array(256),d=-2*n**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);let c=new Uint8Array(t.length),u=new Uint32Array(256);for(let s=0;s<i;s++)for(let n=0;n<e;n++){let o=s*e+n,d=t[o],p=0,g=0;for(let o=0;o<r;o++){let c=s+o-l;if(!(c<0)&&!(c>=i))for(let i=0;i<r;i++){let s=n+i-l;if(s<0||s>=e)continue;let u=t[c*e+s],m=a[o*r+i]*h[Math.abs(u-d)];p+=u*m,g+=m}}let m=c[o]=Math.round(p/g);u[m]++}return[c,u]}static #oS(t){let e=new Uint32Array(256);for(let i of t)e[i]++;return e}static #oT(t){let e=new Uint8ClampedArray(t.length>>2),i=-1/0,s=1/0;for(let n=0,r=e.length;n<r;n++){let r=e[n]=t[n<<2];i=Math.max(i,r),s=Math.min(s,r)}let n=255/(i-s);for(let t=0,i=e.length;t<i;t++)e[t]=(e[t]-s)*n;return e}static #oE(t){let e,i=-1/0,s=-1/0,n=t.findIndex(t=>0!==t),r=n,a=n;for(e=n;e<256;e++){let n=t[e];n>i&&(e-r>s&&(s=e-r,a=e-1),i=n,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static #oM(t){let e=t,{width:i,height:s}=t,{maxDim:n}=this.#of,r=i,a=s;if(i>n||s>n){let o=i,l=s,h=Math.log2(Math.max(i,s)/n),d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){let i=new OffscreenCanvas(r=Math.ceil(o/2),a=Math.ceil(l/2));i.getContext("2d").drawImage(t,0,0,o,l,0,0,r,a),o=r,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}let c=Math.min(n/r,n/a);r=Math.round(r*c),a=Math.round(a*c)}let o=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,r,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,r,a);let l=o.getImageData(0,0,r,a).data;return[this.#oT(l),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),d=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:f,width:b}=h.measureText(t),A=Math.ceil(1.5*Math.max(Math.abs(c)+Math.abs(u)||0,b)),v=Math.ceil(1.5*Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(m)+Math.abs(f)||200));(h=(l=new OffscreenCanvas(A,v)).getContext("2d",{alpha:!0,willReadFrequently:!0})).font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,A,v),h.fillStyle="black",h.fillText(t,.5*A/2,1.5*v/2);let y=this.#oT(h.getImageData(0,0,A,v).data),w=this.#oS(y),x=this.#oE(w),_=this.#ow(y,A,v,x);return this.processDrawnLines({lines:{curves:_,width:A,height:v},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){let[r,a,o]=this.#oM(t),[l,h]=this.#oC(r,a,o,Math.hypot(a,o)*this.#of.sigmaSFactor,this.#of.sigmaR,this.#of.kernelSize),d=this.#oE(h),c=this.#ow(l,a,o,d);return this.processDrawnLines({lines:{curves:c,width:a,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:r,areContours:a}){s%180!=0&&([e,i]=[i,e]);let{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,m=[];for(let{points:t}of o){let e=r?this.#o_(t):t;if(!e)continue;m.push(e);let i=e.length,s=new Float32Array(i),n=new Float32Array(3*(2===i?2:i-2));if(c.push({line:n,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,n.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[a,o,l,h]=e;a*=p,o*=g,l*=p,h*=g,s.set([a,o,l,h],0),n.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<i;t+=2){let i=s[t]=e[t]*p,r=s[t+1]=e[t+1]*g;n.set(sd.createBezierPoints(a,o,l,h,i,r),(t-2)*3),[a,o,l,h]=[l,h,i,r]}}if(0===c.length)return null;let f=a?new sC:new sw;return f.build(c,e,i,1,s,a?0:d,n),{outline:f,newCurves:m,areContours:a,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let r,a=1/0,o=-1/0,l=0;for(let e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){let i=e[t]-e[t-2];a=Math.min(a,i),o=Math.max(o,i)}}r=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let h=t.length,d=8+3*h,c=new Uint32Array(d),u=0;for(let a of(c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*r.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=s,c[u++]=n,c[u++]=+!e,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=r.BYTES_PER_ELEMENT,t))c[u++]=a.length-2,c[u++]=a[0],c[u++]=a[1];let p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);let m=r.prototype.constructor;for(let e of t){let t=new m(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}return g.close(),new Uint8Array(await new Response(p.readable).arrayBuffer()).toBase64()}static async decompressSignature(t){try{let e,i=Uint8Array.fromBase64(t),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(i).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(let t of s)(a||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])).set(t,o),o+=t.length;let l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(0!==h)throw Error(`Invalid version: ${h}`);let d=l[2],c=l[3],u=0===l[4],p=l[5],g=l[6],m=l[7],f=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;switch(m){case Int8Array.BYTES_PER_ELEMENT:e=new Int8Array(a.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:e=new Int16Array(a.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:e=new Int32Array(a.buffer,b)}o=0;for(let t=0;t<g;t++){let i=l[3*t+8],s=new Float32Array(i+2);f.push(s);for(let e=0;e<2;e++)s[e]=l[3*t+8+e+1];for(let t=0;t<i;t++)s[t+2]=s[t]+e[o++]}return{areContours:u,thickness:p,outlines:f,width:d,height:c}}catch(t){return A(`decompressSignature: ${t}`),null}}}class sT extends sA{constructor(){super(),super.updateProperties({fill:tL._defaultLineColor,"stroke-width":0})}clone(){let t=new sT;return t.updateAll(this),t}}class sE extends sx{constructor(t){super(t),super.updateProperties({stroke:tL._defaultLineColor,"stroke-width":1})}clone(){let t=new sE(this._viewParameters);return t.updateAll(this),t}}class sM extends sv{#oD=!1;#oP=null;#ok=null;#oI=null;static _type="signature";static _editorType=l.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#ok=t.signatureData||null,this.#oP=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){tL.initialize(t,e),this._defaultDrawingOptions=new sT,this._defaultDrawnSignatureOptions=new sE(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return _(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#oP}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){let t,e;if(this.div)return this.div;let{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#ok){let{lines:t,mustSmooth:e,areContours:i,description:s,uuid:n,heightInPage:r}=this.#ok,{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,h=sS.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:sM._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,r,s,n)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#oP||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#oI=t,this.addEditToolbar()}getUuid(){return this.#oI}get description(){return this.#oP}set description(t){this.#oP=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#ok,r=Math.max(s,n),a=sS.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,s){let n,{x:r,y:a}=this,{outline:o}=this.#ok=t;this.#oD=o instanceof sC,this.description=i,this.#oD?n=sM.getDefaultDrawingOptions():(n=sM._defaultDrawnSignatureOptions.clone()).updateProperties({"stroke-width":o.thickness}),this._addOutlines({drawOutlines:o,drawingOptions:n});let[,l]=this.pageDimensions,h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=r,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sS.process(t,e,i,s,sM._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return sS.extractContoursFromText(t,e,i,s,n,sM._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sS.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:sM._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=sM.getDefaultDrawingOptions():(this._drawingOptions=sM._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#oD,color:[0,0,0],thickness:this.#oD?0:s});return this.addComment(n),t?(n.paths={lines:e,points:i},n.uuid=this.#oI,n.isCopy=!0):n.lines=e,this.#oP&&(n.accessibilityData={type:"Figure",alt:this.#oP}),n}static deserializeDraw(t,e,i,s,n,r){return r.areContours?sC.deserialize(t,e,i,s,n,r):sw.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=await super.deserialize(t,e,i);return s.#oD=t.areContours,s.description=t.accessibilityData?.alt||"",s.#oI=t.uuid,s}}class sD extends tL{#oB=null;#oF=null;#oL=null;#oR=null;#oN=null;#oO="";#oU=null;#oz=!1;#oH=null;#o$=!1;#oG=!1;static _type="stamp";static _editorType=l.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#oR=t.bitmapUrl,this.#oN=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){tL.initialize(t,e)}static isHandlingMimeForPasting(t){return th.includes(t)}static paste(t,e){e.pasteEditor({mode:l.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#oj(t,e=!1){t?(this.#oB=t.bitmap,e||(this.#oF=t.id,this.#o$=t.isSvg),t.file&&(this.#oO=t.file.name),this.#oV()):this.remove()}#oW(){if(this.#oL=null,this._uiManager.enableWaiting(!1),this.#oU){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oB)return void this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oB){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#oX(){if(this.#oF){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#oF).then(t=>this.#oj(t,!0)).finally(()=>this.#oW());return}if(this.#oR){let t=this.#oR;this.#oR=null,this._uiManager.enableWaiting(!0),this.#oL=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#oj(t)).finally(()=>this.#oW());return}if(this.#oN){let t=this.#oN;this.#oN=null,this._uiManager.enableWaiting(!0),this.#oL=this._uiManager.imageManager.getFromFile(t).then(t=>this.#oj(t)).finally(()=>this.#oW());return}let t=document.createElement("input");t.type="file",t.accept=th.join(",");let e=this._uiManager._signal;this.#oL=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#oj(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#oW()),t.click()}remove(){this.#oF&&(this.#oB=null,this._uiManager.imageManager.deleteId(this.#oF),this.#oU?.remove(),this.#oU=null,this.#oH&&(clearTimeout(this.#oH),this.#oH=null)),super.remove()}rebuild(){if(!this.parent){this.#oF&&this.#oX();return}super.rebuild(),null!==this.div&&(this.#oF&&null===this.#oU&&this.#oX(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#oL||this.#oB||this.#oR||this.#oN||this.#oF||this.#oz)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){let t,e;return this.div||(this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#oz||(this.#oB?this.#oV():this.#oX()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this)),this.div}setCanvas(t,e){let{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#oF=i,s&&(this.#oB=s),this.#oz=!1,this.#oV())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#oH&&clearTimeout(this.#oH),this.#oH=setTimeout(()=>{this.#oH=null,this.#oq()},200))}#oV(){let{div:t}=this,{width:e,height:i}=this.#oB,[s,n]=this.pageDimensions;if(this.width)e=this.width*s,i=this.height*n;else if(e>.75*s||i>.75*n){let t=Math.min(.75*s/e,.75*n/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);let r=this.#oU=document.createElement("canvas");r.setAttribute("role","img"),this.addContainer(r),this.width=e/s,this.height=i/n,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#oq(),this.#oG||(this.parent.addUndoableEditor(this),this.#oG=!0),this._reportTelemetry({action:"inserted_image"}),this.#oO&&this.div.setAttribute("aria-description",this.#oO),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);let{width:s,height:n}=this.#oB,r=new tl,a=this.#oB,o=s,l=n,h=null;if(e){if(s>e||n>e){let t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}let t=(h=document.createElement("canvas")).width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#o$||(a=this.#oK(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":td.isDarkMode&&(c="#8f8f9d",u="#42414d");let p=15*r.sx,g=15*r.sy,m=new OffscreenCanvas(2*p,2*g),f=m.getContext("2d");f.fillStyle=c,f.fillRect(0,0,2*p,2*g),f.fillStyle=u,f.fillRect(0,0,p,g),f.fillRect(p,g,p,g),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#oB,s>t||n>t){let r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#o$||(a=this.#oK(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#oK(t,e){let{width:i,height:s}=this.#oB,n=i,r=s,a=this.#oB;for(;n>2*t||r>2*e;){let i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));let o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a}#oq(){let[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new tl,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#oU;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;let l=this.#o$?this.#oB:this.#oK(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#oY(t){if(t){if(this.#o$){let t=this._uiManager.imageManager.getSvgUrl(this.#oF);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#oB,t.getContext("2d").drawImage(this.#oB,0,0),t.toDataURL()}if(this.#o$){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*j.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*j.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#oB,0,0,this.#oB.width,this.#oB.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#oB)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof sr){let r,a,{data:{rect:o,rotation:h,id:d,structParent:c,popupRef:u,richText:p,contentsObj:g,creationDate:m,modificationDate:f},container:b,parent:{page:{pageNumber:A}},canvas:v}=t;v?(delete t.canvas,{id:r,bitmap:a}=i.imageManager.getFromCanvas(b.id,v),v.remove()):(n=!0,t._hasNoCanvas=!0);let y=(await e._structTree.getAriaAttributes(`${U}${d}`))?.get("aria-label")||"";s=t={annotationType:l.STAMP,bitmapId:r,bitmap:a,pageIndex:A-1,rect:o.slice(0),rotation:h,annotationElementId:d,id:d,deleted:!1,accessibilityData:{decorative:!1,altText:y},isSvg:!1,structParent:c,popupRef:u,richText:p,comment:g?.str||null,creationDate:m,modificationDate:f}}let r=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:h,bitmapId:d,isSvg:c,accessibilityData:u}=t;n?(i.addMissingCanvas(t.id,r),r.#oz=!0):d&&i.imageManager.isValidId(d)?(r.#oF=d,o&&(r.#oB=o)):r.#oR=h,r.#o$=c;let[p,g]=r.pageDimensions;return r.width=(a[2]-a[0])/p,r.height=(a[3]-a[1])/g,u&&(r.altTextData=u),r._initialData=s,t.comment&&r.setCommentData(t),r.#oG=!!s,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i=Object.assign(super.serialize(t),{bitmapId:this.#oF,isSvg:this.#o$});if(this.addComment(i),t)return i.bitmapUrl=this.#oY(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;let{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){let t=this.#r5(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;let r=this.#o$?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#oF)){if(this.#o$){let t=e.stamps.get(this.#oF);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#oY(!1))}}else e.stamps.set(this.#oF,{area:r,serialized:i}),i.bitmap=this.#oY(!1);return i}#r5(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class sP{#rz;#oQ=!1;#oJ=null;#oZ=null;#o0=null;#o1=new Map;#o2=!1;#o3=!1;#o5=!1;#o4=null;#o6=null;#o8=null;#o7=null;#o9=null;#lt=-1;#C;static _initialized=!1;static #ti=new Map([sh,s_,sD,sb,sM].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const d=[...sP.#ti.values()];if(!sP._initialized)for(const e of(sP._initialized=!0,d))e.initialize(h,t);t.registerEditorTypes(d),this.#C=t,this.pageIndex=e,this.div=i,this.#rz=n,this.#oJ=r,this.viewport=l,this.#o8=o,this.drawLayer=a,this._structTree=s,this.#C.addLayer(this)}updatePageIndex(t){this.pageIndex=t}get isEmpty(){return 0===this.#o1.size}get isInvisible(){return this.isEmpty&&this.#C.getMode()===l.NONE}updateToolbar(t){this.#C.updateToolbar(t)}updateMode(t=this.#C.getMode()){switch(this.#le(),t){case l.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case l.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case l.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===l.POPUP)e.toggle("commentEditing",!0);else for(let i of(e.toggle("commentEditing",!1),sP.#ti.values()))e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#o8?.div}setEditingState(t){this.#C.setEditingState(t)}addCommands(t){this.#C.addCommands(t)}cleanUndoStack(t){this.#C.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#oJ?.togglePointerEvents(t)}get #li(){return 0!==this.#o1.size?this.#o1.values():this.#C.getEditors(this.pageIndex)}async enable(){this.#o5=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#o9?.abort(),this.#o9=null;let t=new Set;for(let e of this.#li)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#C.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));let e=this.#oJ;if(e)for(let i of e.getEditableAnnotations()){if(i.hide(),this.#C.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;let e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#o5=!1,this.#C._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o3=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#o8&&!this.#o9){this.#o9=new AbortController;let t=this.#C.combinedSignal(this.#o9);this.#o8.div.addEventListener("pointerdown",t=>{let e,{clientX:i,clientY:s,timeStamp:n}=t;if(n-this.#lt>500){this.#lt=n;return}this.#lt=-1;let{classList:r}=this.div;r.toggle("getElements",!0);let a=document.elementsFromPoint(i,s);if(r.toggle("getElements",!1),!this.div.contains(a[0]))return;let l=RegExp(`^${o}[0-9]+$`);for(let t of a)if(l.test(t.id)){e=t.id;break}if(!e)return;let h=this.#o1.get(e);h?.annotationElementId===null&&(t.stopPropagation(),t.preventDefault(),h.dblclick(t))},{signal:t,capture:!0})}let t=this.#oJ,e=[];if(t){let i=new Map,s=new Map;for(let t of this.#li){if(t.disableEditing(),!t.annotationElementId){e.push(t);continue}if(null!==t.serialize()){i.set(t.annotationElementId,t);continue}s.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()}for(let e of t.getEditableAnnotations()){let{id:t}=e.data;if(this.#C.isDeletedAnnotationElement(t)){e.updateEdited({deleted:!0});continue}let n=s.get(t);if(n){n.resetAnnotationElement(e),n.show(!1),e.show();continue}(n=i.get(t))&&(this.#C.addChangedExistingAnnotation(n),n.renderAnnotationElement(e)&&n.show(!1)),e.show()}}this.#le(),this.isEmpty&&(this.div.hidden=!0);let{classList:i}=this.div;for(let t of sP.#ti.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o3=!1}getEditableAnnotation(t){return this.#oJ?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#C.getActive()!==t&&this.#C.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#o8?.div&&!this.#o7){this.#o7=new AbortController;let t=this.#C.combinedSignal(this.#o7);this.#o8.div.addEventListener("pointerdown",this.#ls.bind(this),{signal:t}),this.#o8.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#o8?.div&&this.#o7&&(this.#o7.abort(),this.#o7=null,this.#o8.div.classList.remove("highlighting"))}#ls(t){this.#C.unselectAll();let{target:e}=t;if(e===this.#o8.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#o8.div.contains(e)){let{isMac:e}=I.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#C.showAllEditors("highlight",!0,!0),this.#o8.div.classList.add("free"),this.toggleDrawing(),sb.startHighlighting(this,"ltr"===this.#C.direction,{target:this.#o8.div,x:t.x,y:t.y}),this.#o8.div.addEventListener("pointerup",()=>{this.#o8.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#C._signal}),t.preventDefault()}}enableClick(){if(this.#oZ)return;this.#oZ=new AbortController;let t=this.#C.combinedSignal(this.#oZ);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#oZ?.abort(),this.#oZ=null}attach(t){this.#o1.set(t.id,t);let{annotationElementId:e}=t;e&&this.#C.isDeletedAnnotationElement(e)&&this.#C.removeDeletedAnnotationElement(t)}detach(t){this.#o1.delete(t.id),this.#rz?.removePointerInTextLayer(t.contentDiv),!this.#o3&&t.annotationElementId&&this.#C.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#C.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#C.addDeletedAnnotationElement(t),tL.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.#C.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#o5),this.#C.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#o0&&(t._focusEventsAllowed=!1,this.#o0=setTimeout(()=>{this.#o0=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#C._signal}),e.focus())},0)),t._structTreeParentId=this.#rz?.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})}getEditorByUID(t){for(let e of this.#o1.values())if(e.uid===t)return e;return null}getNextId(){return this.#C.getId()}get #ln(){return sP.#ti.get(this.#C.getMode())}combinedSignal(t){return this.#C.combinedSignal(t)}#lr(t){let e=this.#ln;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#ln?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#C.updateMode(t.mode);let{offsetX:i,offsetY:s}=this.#la(),n=this.getNextId(),r=this.#lr({parent:this,id:n,x:i,y:s,uiManager:this.#C,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await sP.#ti.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#C)||null}createAndAddNewEditor(t,e,i={}){let s=this.getNextId(),n=this.#lr({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#C,isCentered:e,...i});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}#la(){let{x:t,y:e,width:i,height:s}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),l=(n+a)/2-t,h=(r+o)/2-e,[d,c]=this.viewport.rotation%180==0?[l,h]:[h,l];return{offsetX:d,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#la(),!0,t)}setSelected(t){this.#C.setSelected(t)}toggleSelected(t){this.#C.toggleSelected(t)}unselect(t){this.#C.unselect(t)}pointerup(t){let{isMac:e}=I.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div||!this.#o2||(this.#o2=!1,this.#ln?.isDrawer&&this.#ln.supportMultipleDrawings))return;if(!this.#oQ){this.#oQ=!0;return}let i=this.#C.getMode();i===l.STAMP||i===l.SIGNATURE?this.#C.unselectAll():this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#C.getMode()===l.HIGHLIGHT&&this.enableTextSelection(),this.#o2){this.#o2=!1;return}let{isMac:e}=I.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;if(this.#o2=!0,this.#ln?.isDrawer)return void this.startDrawingSession(t);let i=this.#C.getActive();this.#oQ=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#o4)return void this.#ln.startDrawing(this,this.#C,!1,t);this.#C.setCurrentDrawingSession(this),this.#o4=new AbortController;let e=this.#C.combinedSignal(this.#o4);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#o6=null,this.commitOrRemove())},{signal:e}),this.#ln.startDrawing(this,this.#C,!1,t)}pause(t){if(t){let{activeElement:t}=document;this.div.contains(t)&&(this.#o6=t);return}this.#o6&&setTimeout(()=>{this.#o6?.focus(),this.#o6=null},0)}endDrawingSession(t=!1){return this.#o4?(this.#C.setCurrentDrawingSession(null),this.#o4.abort(),this.#o4=null,this.#o6=null,this.#ln.endDrawing(t)):null}findNewParent(t,e,i){let s=this.#C.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#o4&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#o4&&this.#ln.onScaleChangingWhenDrawing(this)}destroy(){for(let t of(this.commitOrRemove(),this.#C.getActive()?.parent===this&&(this.#C.commitOrRemove(),this.#C.setActiveEditor(null)),this.#o0&&(clearTimeout(this.#o0),this.#o0=null),this.#o1.values()))this.#rz?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#o1.clear(),this.#C.removeLayer(this)}#le(){for(let t of this.#o1.values())t.isEmpty()&&t.remove()}render({viewport:t}){for(let e of(this.viewport=t,to(this.div,t),this.#C.getEditors(this.pageIndex)))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#C.commitOrRemove(),this.#le();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,to(this.div,{rotation:i}),e!==i)for(let t of this.#o1.values())t.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#C.viewParameters.realScale}}class sk{#rd=null;#lo=new Map;#ll=new Map;static #I=0;setParent(t){if(!this.#rd){this.#rd=t;return}if(this.#rd!==t){if(this.#lo.size>0)for(let e of this.#lo.values())e.remove(),t.append(e);this.#rd=t}}static get _svgFactory(){return _(this,"_svgFactory",new iz)}static #lh(t,[e,i,s,n]){let{style:r}=t;r.top=`${100*i}%`,r.left=`${100*e}%`,r.width=`${100*s}%`,r.height=`${100*n}%`}#ld(){let t=sk._svgFactory.create(1,1,!0);return this.#rd.append(t),t.setAttribute("aria-hidden",!0),t}#lc(t,e){let i=sk._svgFactory.createElement("clipPath");t.append(i);let s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let n=sk._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#lu(t,e){for(let[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){let s=sk.#I++,n=this.#ld(),r=sk._svgFactory.createElement("defs");n.append(r);let a=sk._svgFactory.createElement("path");r.append(a);let o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#ll.set(s,a);let l=i?this.#lc(r,o):null,h=sk._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#lo.set(s,n),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){let i,s=sk.#I++,n=this.#ld(),r=sk._svgFactory.createElement("defs");n.append(r);let a=sk._svgFactory.createElement("path");r.append(a);let o=`path_${s}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e){let t=sk._svgFactory.createElement("mask");r.append(t),i=`mask_${s}`,t.setAttribute("id",i),t.setAttribute("maskUnits","objectBoundingBox");let e=sk._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");let n=sk._svgFactory.createElement("use");t.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}let l=sk._svgFactory.createElement("use");n.append(l),l.setAttribute("href",`#${o}`),i&&l.setAttribute("mask",`url(#${i})`);let h=l.cloneNode();return n.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(n,t),this.#lo.set(s,n),s}finalizeDraw(t,e){this.#ll.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:i,bbox:s,rootClass:n,path:r}=e,a="number"==typeof t?this.#lo.get(t):t;if(a){if(i&&this.#lu(a,i),s&&sk.#lh(a,s),n){let{classList:t}=a;for(let[e,i]of Object.entries(n))t.toggle(e,i)}if(r){let t=a.firstElementChild.firstElementChild;this.#lu(t,r)}}}updateParent(t,e){if(e===this)return;let i=this.#lo.get(t);i&&(e.#rd.append(i),this.#lo.delete(t),e.#lo.set(t,i))}remove(t){this.#ll.delete(t),null!==this.#rd&&(this.#lo.get(t).remove(),this.#lo.delete(t))}destroy(){for(let t of(this.#rd=null,this.#lo.values()))t.remove();this.#lo.clear(),this.#ll.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:sp},globalThis.pdfjsLib={AbortException:P,AnnotationEditorLayer:sP,AnnotationEditorParamsType:h,AnnotationEditorType:l,AnnotationEditorUIManager:tk,AnnotationLayer:so,AnnotationMode:a,AnnotationType:u,applyOpacity:tu,build:iB,ColorPicker:iF,createValidAbsoluteUrl:w,CSSConstants:tc,DOMSVGFactory:iz,DrawLayer:sk,FeatureTest:I,fetchData:V,findContrastColor:tA,getDocument:i_,getFilenameFromUrl:Y,getPdfFilenameFromUrl:Q,getRGB:tn,getUuid:O,getXfaPageViewport:ts,GlobalWorkerOptions:eK,ImageKind:c,InvalidPDFException:E,isDataScheme:q,isPdfFile:K,isValidExplicitDest:tY,MathClamp:z,noContextMenu:tt,normalizeUnicode:N,OPS:g,OutputScale:tl,PagesMapper:tw,PasswordResponses:m,PDFDataRangeTransport:iS,PDFDateString:ti,PDFWorker:iM,PermissionFlag:d,PixelsPerInch:j,RenderingCancelledException:X,renderRichText:tv,ResponseException:M,setLayerDimensions:to,shadow:_,SignatureExtractor:sS,stopEvent:te,SupportedImageMimeTypes:th,TextLayer:ix,TouchManager:tF,updateUrlHash:x,Util:F,VerbosityLevel:p,version:iI,XfaLayer:$}}}]);